-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
580 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
import Game.Levels.Addition | ||
import Game.MyNat.AdvAddition -- `zero_ne_succ` and `succ_inj` | ||
import Game.Levels.AdvAddition.L01assumption | ||
import Game.Levels.AdvAddition.L02more_assumption | ||
import Game.Levels.AdvAddition.L02assumption2 | ||
import Game.Levels.AdvAddition.L03apply | ||
import Game.Levels.AdvAddition.L04succ_inj1 | ||
import Game.Levels.AdvAddition.L04succ_inj | ||
import Game.Levels.AdvAddition.L05succ_inj2 | ||
import Game.Levels.AdvAddition.L06intro | ||
import Game.Levels.AdvAddition.L07intro2 | ||
import Game.Levels.AdvAddition.L08add_right_cancel | ||
import Game.Levels.AdvAddition.L09add_left_cancel | ||
import Game.Levels.AdvAddition.L10add_left_eq_self | ||
import Game.Levels.AdvAddition.L11add_right_eq_self | ||
|
||
|
||
World "AdvAddition" | ||
Title "Advanced Addition World" | ||
|
||
Introduction | ||
" | ||
In Advanced Addition World we'll learn the `apply` tactic, | ||
and several other tactics, enabling us to argue both forwards | ||
and backwards. | ||
We've proved that $2+2=4$; in Advanced Addition World we'll learn | ||
how to prove that $2+2\\neq 5$. | ||
We'll use this technique to prove that $2+2\\neq5$ | ||
and much more. | ||
In Addition World we proved *equalities* like `x + y = y + x`. | ||
In this world we'll learn how to prove *implications* | ||
like $x+n=y+n \\implies x=y$. We'll have to learn three new | ||
tactics to do this: `assumption`, `apply` and `intro`. | ||
We'll also learn two new fundamental facts about | ||
natural numbers, which Peano introduced as axioms. | ||
Click on \"Start\" to proceed. | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import Game.Levels.Addition | ||
import Game.MyNat.AdvAddition | ||
|
||
World "AdvAddition" | ||
Level 2 | ||
Title "`assumption` practice." | ||
|
||
namespace MyNat | ||
|
||
Introduction "If the goal is not *exactly* a hypothesis, we can sometimes | ||
use rewrites to fix things up." | ||
|
||
/-- Assuming $0+x=(0+y)+2$, we have $x=y+2$. -/ | ||
Statement (x : ℕ) (h : 0 + x = 0 + y + 2) : x = y + 2 := by | ||
Hint "Rewrite `zero_add` at `h` twice, to change `h` into the goal." | ||
repeat rw [zero_add] at h | ||
Hint "Now you could finish with `rw [h]` then `rfl`, but `assumption` | ||
does it in one line." | ||
assumption |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Game.Levels.Addition | ||
import Game.MyNat.AdvAddition | ||
|
||
World "AdvAddition" | ||
Level 7 | ||
Title "intro practice" | ||
|
||
namespace MyNat | ||
|
||
Introduction | ||
" Let's see if you can use the tactics we've learnt to prove $x+1=y+1\\implies x=y$. | ||
Try this one by yourself; if you need help then click on \"Show more help!\". | ||
" | ||
|
||
/-- $x+1=y+1\implies x=y$. -/ | ||
Statement (x : ℕ) : x + 1 = y + 1 → x = y := by | ||
Hint (hidden := true) "Start with `intro h` to assume the hypothesis." | ||
intro h | ||
Hint (hidden := true) "Now `repeat rw [← succ_eq_add_one] at h` is the quickest way to | ||
change `succ x = succ y`." | ||
repeat rw [← succ_eq_add_one] at h | ||
Hint (hidden := true) "Now `apply succ_inj at h` to cancel the `succ`s." | ||
apply succ_inj at h | ||
Hint (hidden := true) "Now `rw [h]` then `rfl` works, but `assumption` is quicker." | ||
assumption | ||
|
||
Conclusion "These worlds have been a tutorial on our new tactics. Now let's use them | ||
to prove some more fundamental facts about the naturals which we will need in later worlds." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Game.Levels.Addition | ||
import Game.MyNat.AdvAddition | ||
|
||
World "AdvAddition" | ||
Level 8 | ||
Title "add_right_cancel" | ||
|
||
namespace MyNat | ||
|
||
LemmaTab "Add" | ||
|
||
LemmaDoc MyNat.add_right_cancel as "add_right_cancel" in "Add" " | ||
`add_right_cancel a b n` is the theorem that $a+n=b+n \\implies a=b.$ | ||
" | ||
|
||
NewLemma MyNat.add_right_cancel | ||
|
||
Introduction | ||
"`add_right_cancel a b n` is the theorem that $a+n=b+n\\implies a=b$. | ||
Start with `induction n with d hd` and see if you can take it from there. | ||
" | ||
|
||
/-- $a+n=b+n\\implies a=b$. -/ | ||
Statement add_right_cancel (a b n : ℕ) : a + n = b + n → a = b := by | ||
induction n with d hd | ||
intro h | ||
repeat rw [add_zero] at h | ||
assumption | ||
intro h | ||
repeat rw [add_succ] at h | ||
apply succ_inj at h | ||
apply hd at h | ||
assumption | ||
|
||
Conclusion "Nice!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Game.Levels.AdvAddition.L08add_right_cancel | ||
|
||
World "AdvAddition" | ||
Level 9 | ||
Title "add_left_cancel" | ||
|
||
namespace MyNat | ||
|
||
LemmaTab "Add" | ||
|
||
LemmaDoc MyNat.add_left_cancel as "add_left_cancel" in "Add" " | ||
`add_left_cancel a b n` is the theorem that $n+a=n+b \\implies a=b.$ | ||
" | ||
|
||
NewLemma MyNat.add_left_cancel | ||
|
||
Introduction | ||
"`add_left_cancel a b n` is the theorem that $n+a=n+b\\implies a=b$. | ||
You can prove it by induction on `n` or you can deduce it from `add_left_cancel`. | ||
" | ||
|
||
/-- $a+n=b+n\implies a=b$. -/ | ||
Statement add_left_cancel (a b n : ℕ) : n + a = n + b → a = b := by | ||
repeat rw [add_comm n] | ||
intro h | ||
apply add_right_cancel at h | ||
assumption |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Game.Levels.AdvAddition.L09add_left_cancel | ||
|
||
World "AdvAddition" | ||
Level 10 | ||
Title "add_left_eq_self" | ||
|
||
namespace MyNat | ||
|
||
LemmaTab "Add" | ||
|
||
LemmaDoc MyNat.add_left_eq_self as "add_left_eq_self" in "Add" " | ||
`add_left_eq_self x y` is the theorem that $x + y = y\\implies x=0.$ | ||
" | ||
|
||
NewLemma MyNat.add_left_eq_self | ||
|
||
Introduction | ||
" | ||
`add_left_eq_self x y` is the theorem that $x + y = y\\implies x=0.$ | ||
" | ||
|
||
/-- $x + y = y\implies x=0.$ -/ | ||
Statement add_left_eq_self (x y : ℕ) : x + y = y → x = 0 := by | ||
intro h | ||
nth_rewrite 2 [← zero_add y] at h | ||
apply add_right_cancel at h | ||
assumption | ||
|
||
Conclusion "Did you use induction on `y`? | ||
Here's a proof of `add_left_eq_self` which uses `add_right_cancel`. | ||
If you want to inspect it, you can go into editor mode by clicking `</>` in the top right | ||
and then just cut and paste the proof and move your cursor around it | ||
(although you'll lose your own proof this way if you're not careful). Click `>_` to get | ||
back to command line mode. | ||
``` | ||
intro h | ||
nth_rewrite 2 [← zero_add y] at h | ||
apply add_right_cancel at h | ||
assumption | ||
``` | ||
" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Game.Levels.AdvAddition.L10add_left_eq_self | ||
|
||
World "AdvAddition" | ||
Level 11 | ||
Title "add_right_eq_self" | ||
|
||
LemmaTab "Add" | ||
|
||
namespace MyNat | ||
|
||
LemmaDoc MyNat.add_right_eq_self as "add_right_eq_self" in "Add" " | ||
`add_right_eq_self x y` is the theorem that $x + y = x\\implies y=0.$ | ||
" | ||
|
||
NewLemma MyNat.add_right_eq_self | ||
|
||
Introduction | ||
"`add_right_eq_self x y` is the theorem that $x + y = x\\implies y=0.$ | ||
" | ||
|
||
/-- $a+n=b+n\implies a=b$. -/ | ||
Statement add_right_eq_self (x y : ℕ) : x + y = x → y = 0 := by | ||
rw [add_comm] | ||
intro h | ||
apply add_left_eq_self at h | ||
assumption | ||
|
||
Conclusion "Here's a proof using `add_left_eq_self`: | ||
``` | ||
rw [add_comm] | ||
intro h | ||
apply add_left_eq_self at h | ||
assumption | ||
``` | ||
" |
Oops, something went wrong.