You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lean4game/server/nng/NNG/Levels/Addition/Level_5.lean

56 lines
1.3 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import NNG.Metadata
import NNG.MyNat.Addition
import NNG.Levels.Addition.Level_4
Game "NNG"
World "Addition"
Level 5
Title "succ_eq_add_one"
open MyNat
namespace AdditionWorld
theorem add_comm (a b : ) : a + b = b + a := by
induction b with d hd
· rw [zero_add]
rw [add_zero]
rfl
· rw [add_succ]
rw [hd]
rw [succ_add]
rfl
theorem one_eq_succ_zero : (1 : ) = succ 0 := by simp only
NewLemma MyNat.add_comm MyNat.one_eq_succ_zero
Introduction
"
I've just added `one_eq_succ_zero` (a proof of $1 = \\operatorname{succ}(0)$)
to your list of theorems; this is true
by definition of $1$, but we didn't need it until now.
Levels 5 and 6 are the two last levels in Addition World.
Level 5 involves the number $1$. When you see a $1$ in your goal,
you can write `rw [one_eq_succ_zero]` to get back
to something which only mentions `0`. This is a good move because $0$ is easier for us to
manipulate than $1$ right now, because we have
some theorems about $0$ (`zero_add`, `add_zero`), but, other than `1 = succ 0`,
no theorems at all which mention $1$. Let's prove one now.
"
Statement --MyNat.succ_eq_add_one
"For any natural number $n$, we have
$ \\operatorname{succ}(n) = n+1$ ."
(n : ) : succ n = n + 1 := by
rw [one_eq_succ_zero]
rw [add_succ]
rw [add_zero]
rfl
Conclusion
"
Well done! On to the last level!
"