pull/43/head
Jon Eugster 2 years ago
parent 75d1183d15
commit 96ec872f49

@ -1,2 +1,4 @@
import TestGame.Levels.Induction.L31_Sum
import TestGame.Levels.Induction.L32_Induction
import TestGame.Levels.Induction.L01_Simp
import TestGame.Levels.Induction.L02_Sum
import TestGame.Levels.Induction.L03_Induction
import TestGame.Levels.Induction.L04_SumOdd

@ -0,0 +1,44 @@
import Mathlib.Algebra.BigOperators.Basic
import Mathlib
import TestGame.Metadata
set_option tactic.hygienic false
Game "TestGame"
World "Induction"
Level 1
Title "Simp"
Introduction
"
In diesem Kapitel lernen wir endliche Summen und Induktion kennen.
Eine endliche Summe läuft erstmal immer über einen endlichen Index
`Fin n`, welcher $n$ Elemente
$\\{0, 1, \\ldots, n-1\\}$ beinhaltet.
Der Syntax für`∑ i : Fin n, (...)` (\\sum) ist der Syntax für $\\sum_{i=0}^n …$
Als kann die Taktik `simp` (für \"simplification\") ganz viel Triviales vereinfachen.
`simp` ist eine der stärksten Taktiken in Lean und verwendet
ganz viele markierte Lemmas um das Goal zu vereinfachen.
Zum Beispiel kennt es ein Lemma das ungefähr so aussieht:
```
@[simp]
lemma sum_const_add (n : ) : (∑ i in Fin n, 0) = 0 := by
[...]
```
Mit `simp?` anstatt `simp` kannst du zudem schauen, welche Lemmas von `simp` benutzt wurde.
"
Statement
"Zeige dass `∑_{i = 0} ^ {n-1} 0 = 0 + 0`."
(n : ) : (∑ i : Fin n, 0) = 0 + 0 := by
simp
Tactics simp

@ -0,0 +1,31 @@
import Mathlib.Algebra.BigOperators.Basic
import Mathlib
import TestGame.Metadata
set_option tactic.hygienic false
Game "TestGame"
World "Induction"
Level 2
Title "endliche Summe"
Introduction
"
Jetzt wollen wir ein paar Lemmas zu Summen kennenlernen, die `simp` nicht automatisch
verwendet.
Als erstes, kann man eine endliche Summe $\\sum_{i = 0}^n a_i + b_i$ mit
`rw rw [Finset.sum_add_distrib]` als zwei Summen $\\sum_{i = 0}^n a_i + \\sum_{j = 0}^n b_j$
auseinandernehmen.
"
Statement
"Zeige dass $\\sum_{i=0}^{n-1} (i + 1) = n + \\sum_{i=0}^{n-1} i$."
(n : ) : ∑ i : Fin n, ((i : ) + 1) = n + (∑ i : Fin n, (i : )) := by
rw [Finset.sum_add_distrib]
simp
ring
Tactics rw simp ring

@ -0,0 +1,44 @@
import TestGame.Metadata
import Mathlib.Tactic.Ring
import Mathlib
import TestGame.ToBePorted
Game "TestGame"
World "Induction"
Level 3
Title "Induktion"
Introduction
"
Induktion ist eine wichtige Beweismethode, nicht zuletzt auch wenn es um endliche Summen geht.
Die Taktik `induction' n with n n_ih` teilt das Goal in zwei Goals auf:
1. Induktionsanfang, wo `n` durch `0` ersetzt wird.
2. Induktionsschritt, wo `n` durch `n.succ` (also `(n + 1)`) ersetzt wird und man die
Induktionshypothese als Annahme `n_ih` kriegt.
Für den Induktionsschritt braucht man fast immer zwei technische Lemmas:
- `Fin.sum_univ_castSucc` um $\\sum_{i=0}^{n} a_i$ als
$\\sum_{i=0}^{n-1} a_i + a_n$ umzuschreiben.
- `nat_succ` um `n.succ` zu `n + 1` umzuschreiben.
"
-- Note: I don't want to deal with Nat-division, so I stated it as `2 * ... = ...` instead.
Statement
"Zeige $\\sum_{i = 0}^n i = \\frac{n ⬝ (n + 1)}{2}$."
(n : ) : 2 * (∑ i : Fin (n + 1), ↑i) = n * (n + 1) := by
induction n
simp
sorry
-- rw [Fin.sum_univ_castSucc]
-- simp [nat_succ]
-- rw [mul_add, hn]
-- ring
Tactics ring

@ -0,0 +1,31 @@
import TestGame.Metadata
import Mathlib.Tactic.Ring
import Mathlib
import TestGame.ToBePorted
Game "TestGame"
World "Induction"
Level 4
Title "Bernoulli Ungleichung"
Introduction
"
Hier nochmals eine Übung zur Induktion.
"
Statement
"Zeige folgende Gleichung zur Summe aller ungeraden Zahlen:
$\\sum_{i = 0}^n (2n + 1) = n ^ 2$."
(n : ) : (∑ i : Fin n, (2 * (i : ) + 1)) = n ^ 2 := by
induction' n with n hn
simp
rw [nat_succ]
sorry -- waiting on Algebra.BigOperators.Fin
--simp [Fin.sum_univ_cast_succ]
--rw [hn]
--ring
Tactics ring

@ -2,11 +2,13 @@ import TestGame.Metadata
import Mathlib.Tactic.Ring
import Mathlib
import TestGame.ToBePorted
Game "TestGame"
World "Induction"
Level 2
Level 5
Title "Induktion"
Title "Bernoulli Ungleichung"
Introduction
"
@ -15,13 +17,20 @@ TODO: Induktion (& induktion vs rcases)
"
theorem nat_succ (n : ) : Nat.succ n = n + 1 := rfl
example (x : ) (n : ) : 1 + n * x ≤ (x + 1) ^ n := by
induction' n with n hn
simp
rw [Nat.succ_mul]
rw [Nat.pow_succ]
sorry
lemma hh1 (n m : ) (h : 2 * m = n) : m = n / 2 := by
rw [←h]
rw [Nat.mul_div_right]
example (n : ) : (∑ i : Fin (n + 1), ↑(2 * i - 1)) = n ^ 2 := by
induction' n with n hn
simp
Statement
"Zeige $\\sum_{i = 0}^n i = \\frac{n ⬝ (n + 1)}{2}$."
(n : ) : (∑ i : Fin (n + 1), ↑i) = n * (n + 1) / 2 := by

@ -1,25 +0,0 @@
import Mathlib.Algebra.BigOperators.Basic
import Mathlib
import TestGame.Metadata
set_option tactic.hygienic false
Game "TestGame"
World "Induction"
Level 1
Title "Summe"
Introduction
"
"
Statement
""
(n : ) : 2 * (∑ i : Fin (n+1), ↑i) = n * (n + 1) := by
induction' n with n hn
simp
sorry -- done in Lean3.
Tactics intro constructor assumption

@ -10,3 +10,5 @@ lemma even_square (n : ) : Even n → Even (n ^ 2) := by
use 2 * x ^ 2
rw [hx]
ring
theorem nat_succ (n : ) : Nat.succ n = n + 1 := rfl

Loading…
Cancel
Save