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"
|
|
|
|
|
|
|
2024-01-24 15:42:41 +00:00
|
|
|
|
TheoremTab "Peano"
|
2023-10-27 00:00:06 +01:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-12-18 17:51:19 +00:00
|
|
|
|
If you can turn your goal into `True`, then the `triv` tactic will solve it.
|
2023-10-27 00:00:06 +01:00
|
|
|
|
"
|
|
|
|
|
|
|
2024-01-24 15:45:29 +00:00
|
|
|
|
TheoremDoc MyNat.is_zero_zero as "is_zero_zero" in "Peano"
|
2023-10-27 00:00:06 +01:00
|
|
|
|
"
|
|
|
|
|
|
`is_zero_zero` is a proof of `is_zero 0 = True`.
|
|
|
|
|
|
"
|
|
|
|
|
|
|
2024-01-24 15:45:29 +00:00
|
|
|
|
TheoremDoc MyNat.is_zero_succ as "is_zero_succ" in "Peano"
|
2023-10-27 00:00:06 +01:00
|
|
|
|
"
|
|
|
|
|
|
`is_zero_succ a` is a proof of `is_zero (succ a) = False`.
|
|
|
|
|
|
"
|
|
|
|
|
|
|
2024-01-24 15:45:29 +00:00
|
|
|
|
TheoremDoc MyNat.succ_ne_zero as "succ_ne_zero" in "Peano"
|
2023-10-27 00:00:06 +01:00
|
|
|
|
"
|
|
|
|
|
|
`succ_ne_zero a` is a proof of `succ a ≠ 0`.
|
|
|
|
|
|
"
|
|
|
|
|
|
|
2024-01-24 16:39:45 +00:00
|
|
|
|
NewTheorem MyNat.is_zero_zero MyNat.is_zero_succ
|
2023-10-27 00:00:06 +01:00
|
|
|
|
|
2023-12-18 17:51:19 +00:00
|
|
|
|
TacticDoc triv "
|
|
|
|
|
|
# Summary
|
|
|
|
|
|
|
2023-12-19 15:54:19 +00:00
|
|
|
|
`triv` will solve the goal `True`.
|
2023-12-18 17:51:19 +00:00
|
|
|
|
|
|
|
|
|
|
"
|
|
|
|
|
|
|
|
|
|
|
|
NewTactic triv
|
|
|
|
|
|
|
2023-10-30 10:10:51 +01:00
|
|
|
|
/-- $\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]
|
2023-12-18 17:51:19 +00:00
|
|
|
|
triv
|