nng
This commit is contained in:
@@ -8,7 +8,9 @@ Title "add_assoc (associativity of addition)"
|
||||
|
||||
open MyNat
|
||||
|
||||
theorem MyNat.zero_add (n : ℕ) : 0 + n = n := by
|
||||
namespace AdditionWorld
|
||||
|
||||
theorem zero_add (n : ℕ) : 0 + n = n := by
|
||||
induction n with n hn
|
||||
· rw [add_zero]
|
||||
rfl
|
||||
|
||||
@@ -9,7 +9,9 @@ Title "succ_add"
|
||||
|
||||
open MyNat
|
||||
|
||||
theorem MyNat.add_assoc (a b c : ℕ) : (a + b) + c = a + (b + c) := by
|
||||
namespace AdditionWorld
|
||||
|
||||
theorem add_assoc (a b c : ℕ) : (a + b) + c = a + (b + c) := by
|
||||
induction c with c hc
|
||||
· rw [add_zero]
|
||||
rw [add_zero]
|
||||
@@ -20,7 +22,6 @@ theorem MyNat.add_assoc (a b c : ℕ) : (a + b) + c = a + (b + c) := by
|
||||
rw [hc]
|
||||
rfl
|
||||
|
||||
|
||||
Introduction
|
||||
"
|
||||
Oh no! On the way to `add_comm`, a wild `succ_add` appears. `succ_add`
|
||||
@@ -52,6 +53,7 @@ $ \\operatorname{succ}(a) + b = \\operatorname{succ}(a + b)$."
|
||||
Hint "Induction on `a` will not work."
|
||||
induction b with d hd
|
||||
· rw [add_zero]
|
||||
rw [add_zero]
|
||||
rfl
|
||||
· rw [add_succ]
|
||||
rw [hd]
|
||||
|
||||
@@ -9,9 +9,12 @@ Title "`add_comm` (boss level)"
|
||||
|
||||
open MyNat
|
||||
|
||||
theorem MyNat.succ_add (a b : ℕ) : succ a + b = succ (a + b) := by
|
||||
namespace AdditionWorld
|
||||
|
||||
theorem succ_add (a b : ℕ) : succ a + b = succ (a + b) := by
|
||||
induction b with d hd
|
||||
· rw [add_zero]
|
||||
rw [add_zero]
|
||||
rfl
|
||||
· rw [add_succ]
|
||||
rw [hd]
|
||||
|
||||
@@ -9,7 +9,9 @@ Title "succ_eq_add_one"
|
||||
|
||||
open MyNat
|
||||
|
||||
theorem MyNat.add_comm (a b : ℕ) : a + b = b + a := by
|
||||
namespace AdditionWorld
|
||||
|
||||
theorem add_comm (a b : ℕ) : a + b = b + a := by
|
||||
induction b with d hd
|
||||
· rw [zero_add]
|
||||
rw [add_zero]
|
||||
@@ -19,8 +21,7 @@ theorem MyNat.add_comm (a b : ℕ) : a + b = b + a := by
|
||||
rw [succ_add]
|
||||
rfl
|
||||
|
||||
theorem MyNat.one_eq_succ_zero : (1 : ℕ) = succ 0 := by
|
||||
rfl
|
||||
theorem one_eq_succ_zero : (1 : ℕ) = succ 0 := by simp only
|
||||
|
||||
NewLemma MyNat.add_comm MyNat.one_eq_succ_zero
|
||||
|
||||
|
||||
@@ -9,11 +9,13 @@ Title "add_right_comm"
|
||||
|
||||
open MyNat
|
||||
|
||||
namespace AdditionWorld
|
||||
|
||||
Introduction
|
||||
"
|
||||
Lean sometimes writes `a + b + c`. What does it mean? The convention is
|
||||
that if there are no brackets displayed in an addition formula, the brackets
|
||||
are around the left most `+` (Lean's addition is \"left associative\").
|
||||
are around the left most `+` (Lean's addition is \"left associative\").
|
||||
So the goal in this level is `(a + b) + c = (a + c) + b`. This isn't
|
||||
quite `add_assoc` or `add_comm`, it's something you'll have to prove
|
||||
by putting these two theorems together.
|
||||
|
||||
Reference in New Issue
Block a user