-
Notifications
You must be signed in to change notification settings - Fork 39
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
26 changed files
with
165 additions
and
38 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import GameServer.Commands | ||
import Game.Levels.LessOrEqual.L01le_refl | ||
import Game.Levels.LessOrEqual.L02zero_le | ||
import Game.Levels.LessOrEqual.L03le_succ_self | ||
import Game.Levels.LessOrEqual.L04le_zero | ||
|
||
World "LessOrEqual" | ||
Title "≤ World" | ||
|
||
Introduction | ||
" | ||
In this world we define `a ≤ b` and prove standard facts | ||
about it, such as \"if `a ≤ b` and `b ≤ c` then `a ≤ c`.\" | ||
The definition of `a ≤ b` is \"there exists a number `c` | ||
such that `b = a + c`. \" So we're going to have to learn | ||
a tactic to prove \"exists\" theorems, and another one | ||
to use \"exists\" hypotheses. | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Game.Metadata | ||
import Game.MyNat.LE | ||
import Game.Tactic.Use | ||
import Game.Levels.AdvAddition | ||
|
||
World "LessOrEqual" | ||
Level 1 | ||
Title "The `use` tactic" | ||
|
||
namespace MyNat | ||
|
||
TacticDoc use " | ||
## Summary | ||
The `use` tactic makes progress with goals which claim something *exists*. | ||
If the goal claims that some `x` exists with some property, and you know | ||
that `x = 37` will work, then `use 37` will make progress. | ||
Because `a ≤ b` is notation for \"there exists `c` such that `b = a + c`\", | ||
you can make progress on goals of the form `a ≤ b` by `use`ing the | ||
number which is morally `b - a`. | ||
" | ||
|
||
NewTactic use | ||
|
||
Introduction | ||
" | ||
`a ≤ b` is *notation* for `∃ c, b = a + c`. This \"backwards E\" | ||
means \"there exists\". So `a ≤ b` means that there exists | ||
a number `c` such that `b = a + c`. This definition works | ||
because there are no negative numbers in this game. | ||
To *prove* an \"exists\" statement, use the `use` tactic. | ||
Let's see an example. | ||
" | ||
|
||
LemmaDoc MyNat.le_refl as "le_refl" in "≤" " | ||
`le_refl x` is a proof of `x ≤ x`. | ||
The reason for the name is that this lemma is \"reflexivity of $\\le$\" | ||
" | ||
|
||
/-- If $x$ is a number, then $x \\le x$. -/ | ||
Statement le_refl (x : ℕ) : x ≤ x := by | ||
Hint "The reason `x ≤ x` is because `x = x + 0`. | ||
So you should start this proof with `use 0`." | ||
use 0 | ||
Hint "You can probably take it from here." | ||
rw [add_zero] | ||
rfl | ||
|
||
|
||
LemmaTab "≤" |
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,23 @@ | ||
import Game.Levels.LessOrEqual.L01le_refl | ||
|
||
World "LessOrEqual" | ||
Level 2 | ||
Title "0 ≤ x" | ||
|
||
namespace MyNat | ||
|
||
Introduction | ||
" | ||
Although subtraction doesn't make sense for general numbers in this game | ||
(because there are no negative numbers in this game), one way of thinking about | ||
how to prove `a ≤ b` is to `use b - a`. See how you get on with this level, | ||
which proves that every number in the game is at least 0. | ||
" | ||
|
||
/-- If $x$ is a number, then $0 \\le x$. -/ | ||
Statement le_refl (x : ℕ) : 0 ≤ x := by | ||
use x | ||
rw [zero_add] | ||
rfl | ||
|
||
LemmaTab "≤" |
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,26 @@ | ||
import Game.Levels.LessOrEqual.L02zero_le | ||
|
||
World "LessOrEqual" | ||
Level 3 | ||
Title "x ≤ succ x" | ||
|
||
namespace MyNat | ||
|
||
/-- If $x$ is a number, then $x \\le \\mathoperator{succ}(x)$. -/ | ||
Statement le_succ_self (x : ℕ) : x ≤ succ x := by | ||
use 1 | ||
rw [succ_eq_add_one] | ||
rfl | ||
|
||
LemmaTab "≤" | ||
|
||
/- | ||
Introduction | ||
" | ||
Because constanly rewriting `zero_add` and `add_zero` is a bit dull, | ||
let's unlock the `ring` tactic. This will prove any goal which is \"true | ||
in the language of ring theory\", for example `a + b + c = c + b + a`. | ||
It doesn't understand `succ` though, so use `succ_eq_add_one` in this | ||
level to get rid of it. | ||
" | ||
-/ |
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,31 @@ | ||
import Game.Levels.LessOrEqual.L03le_succ_self | ||
|
||
World "LessOrEqual" | ||
Level 4 | ||
Title "x ≤ 0 → x = 0" | ||
|
||
namespace MyNat | ||
|
||
Introduction " | ||
In this level, our inequality is a *hypothesis*. We have not seen this before. | ||
" | ||
/-- If $x \leq 0$, then $x=0$. -/ | ||
Statement le_zero (x : ℕ) (hx : x ≤ 0) : x = 0 := by | ||
cases' hx with y hy | ||
symm at hy | ||
apply eq_zero_of_add_right_eq_zero at hy | ||
exact hy | ||
|
||
LemmaTab "≤" | ||
|
||
/- | ||
Introduction | ||
" | ||
Because constanly rewriting `zero_add` and `add_zero` is a bit dull, | ||
let's unlock the `ring` tactic. This will prove any goal which is \"true | ||
in the language of ring theory\", for example `a + b + c = c + b + a`. | ||
It doesn't understand `succ` though, so use `succ_eq_add_one` in this | ||
level to get rid of it. | ||
" | ||
-/ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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