Files
NNG/Game/Levels/Algorithm/L06is_zero.lean

69 lines
1.7 KiB
Lean4
Raw Normal View History

2023-10-27 19:40:15 +01:00
import Game.Levels.Algorithm.L05pred
2023-10-27 00:00:06 +01:00
World "Algorithm"
2023-10-27 19:40:15 +01:00
Level 6
2023-10-27 00:00:06 +01:00
Title "is_zero"
LemmaTab "Peano"
namespace MyNat
Introduction
"
2023-10-27 20:00:10 +01:00
We define a function `is_zero` thus:
2023-10-27 00:00:06 +01:00
```
is_zero 0 := True
is_zero (succ n) := False
```
2023-10-27 20:00:10 +01:00
We also create two lemmas, `is_zero_zero` and `is_zero_succ n`, saying that `is_zero 0 = True`
and `is_zero (succ n) = False`. Let's use these lemmas to prove `succ_ne_zero`, Peano's
Last Axiom. Actually, we have been using `zero_ne_succ` before, but it's handy to have
2023-12-19 15:59:38 +00:00
this opposite version too, which can be proved in the same way. Note: you can
cheat here by using `zero_ne_succ` but the point of this world is to show
you how to *prove* results like that.
2023-10-27 00:00:06 +01:00
If you can turn your goal into `True`, then the `triv` tactic will solve it.
2023-10-27 00:00:06 +01:00
"
LemmaDoc MyNat.is_zero_zero as "is_zero_zero" in "Peano"
"
`is_zero_zero` is a proof of `is_zero 0 = True`.
"
LemmaDoc MyNat.is_zero_succ as "is_zero_succ" in "Peano"
"
`is_zero_succ a` is a proof of `is_zero (succ a) = False`.
"
LemmaDoc MyNat.succ_ne_zero as "succ_ne_zero" in "Peano"
"
`succ_ne_zero a` is a proof of `succ a 0`.
"
2023-10-27 18:24:50 +01:00
NewLemma MyNat.is_zero_zero MyNat.is_zero_succ
2023-10-27 00:00:06 +01:00
TacticDoc triv "
# Summary
2023-12-19 15:54:19 +00:00
`triv` will solve the goal `True`.
"
NewTactic triv
/-- $\operatorname{succ}(a) \neq 0$. -/
2023-10-27 00:00:06 +01:00
Statement succ_ne_zero (a : ) : succ a 0 := by
2023-10-27 20:00:10 +01:00
Hint "Start with `intro h` (remembering that `X ≠ Y` is just notation
for `X = Y False`)."
2023-10-27 00:00:06 +01:00
intro h
2023-12-19 15:59:38 +00:00
Hint "We're going to change that `False` into `True`. Start by changing it into
`is_zero (succ a)` by executing `rw [ is_zero_succ a]`."
2023-10-27 00:00:06 +01:00
rw [ is_zero_succ a]
2023-12-19 15:59:38 +00:00
Hint "See if you can take it from here. Look at the new lemmas and tactic
available on the right."
2023-10-27 00:00:06 +01:00
rw [h]
rw [is_zero_zero]
triv