nng levels
This commit is contained in:
@@ -1,23 +1,61 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
--import Mathlib.Tactic.Ring
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
Level 1
|
||||
Title ""
|
||||
Title "the `use` tactic"
|
||||
|
||||
open MyNat
|
||||
|
||||
Introduction
|
||||
"
|
||||
The goal below is to prove $x\\le 1+x$ for any natural number $x$.
|
||||
First let's turn the goal explicitly into an existence problem with
|
||||
|
||||
`rw le_iff_exists_add,`
|
||||
|
||||
and now the goal has become `∃ c : mynat, 1 + x = x + c`. Clearly
|
||||
this statement is true, and the proof is that $c=1$ will work (we also
|
||||
need the fact that addition is commutative, but we proved that a long
|
||||
time ago). How do we make progress with this goal?
|
||||
|
||||
The `use` tactic can be used on goals of the form `∃ c, ...`. The idea
|
||||
is that we choose which natural number we want to use, and then we use it.
|
||||
So try
|
||||
|
||||
`use 1,`
|
||||
|
||||
and now the goal becomes `⊢ 1 + x = x + 1`. You can solve this by
|
||||
`exact add_comm 1 x`, or if you are lazy you can just use the `ring` tactic,
|
||||
which is a powerful AI which will solve any equality in algebra which can
|
||||
be proved using the standard rules of addition and multiplication. Now
|
||||
look at your proof. We're going to remove a line.
|
||||
|
||||
## Important
|
||||
|
||||
An important time-saver here is to note that because `a ≤ b` is *defined*
|
||||
as `∃ c : mynat, b = a + c`, you *do not need to write* `rw le_iff_exists_add`.
|
||||
The `use` tactic will work directly on a goal of the form `a ≤ b`. Just
|
||||
use the difference `b - a` (note that we have not defined subtraction so
|
||||
this does not formally make sense, but you can do the calculation in your head).
|
||||
If you have written `rw le_iff_exists_add` below, then just put two minus signs `--`
|
||||
before it and comment it out. See that the proof still compiles.
|
||||
"
|
||||
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
axiom add_comm (a b : ℕ) : a + b = b + a
|
||||
|
||||
Statement --one_add_le_self
|
||||
"If $x$ is a natural number, then $x\\le 1+x$.
|
||||
"
|
||||
(x : ℕ) : x ≤ 1 + x := by
|
||||
rw [le_iff_exists_add]
|
||||
use 1
|
||||
rw [add_comm]
|
||||
rfl
|
||||
|
||||
Conclusion
|
||||
"
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
Level 2
|
||||
Title ""
|
||||
Title "le_rfl"
|
||||
|
||||
open MyNat
|
||||
|
||||
Introduction
|
||||
"
|
||||
|
||||
Here's a nice easy one.
|
||||
"
|
||||
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
"The $\\le$ relation is reflexive. In other words, if $x$ is a natural number,
|
||||
then $x\\le x$."
|
||||
(x : ℕ) : x ≤ x := by
|
||||
use 0
|
||||
rw [add_zero]
|
||||
rfl
|
||||
|
||||
Conclusion
|
||||
"
|
||||
|
||||
@@ -1,22 +1,57 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
import Std.Tactic.RCases
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
Level 3
|
||||
Title ""
|
||||
Title "le_succ_of_le"
|
||||
|
||||
open MyNat
|
||||
|
||||
Introduction
|
||||
"
|
||||
We have seen how the `use` tactic makes progress on goals of the form `⊢ ∃ c, ...`.
|
||||
But what do we do when we have a *hypothesis* of the form `h : ∃ c, ...`?
|
||||
The hypothesis claims that there exists some natural number `c` with some
|
||||
property. How are we going to get to that natural number `c`? It turns out
|
||||
that the `cases` tactic can be used (just like it was used to extract
|
||||
information from `∧` and `∨` and `↔` hypotheses). Let me talk you through
|
||||
the proof of $a\\le b\\implies a\\le\\operatorname{succ}(b)$.
|
||||
|
||||
The goal is an implication so we clearly want to start with
|
||||
|
||||
`intro h,`
|
||||
|
||||
. After this, if you *want*, you can do something like
|
||||
|
||||
`rw le_iff_exists_add at h ⊢,`
|
||||
|
||||
(get the sideways T with `\\|-` then space). This changes the `≤` into
|
||||
its `∃` form in `h` and the goal -- but if you are happy with just
|
||||
*imagining* the `∃` whenever you read a `≤` then you don't need to do this line.
|
||||
|
||||
Our hypothesis `h` is now `∃ (c : mynat), b = a + c` (or `a ≤ b` if you
|
||||
elected not to do the definitional rewriting) so
|
||||
|
||||
`cases h with c hc,`
|
||||
|
||||
gives you the natural number `c` and the hypothesis `hc : b = a + c`.
|
||||
Now use `use` wisely and you're home.
|
||||
|
||||
"
|
||||
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
"For all naturals $a$, $b$, if $a\\leq b$ then $a\\leq \\operatorname{succ}(b)$.
|
||||
"
|
||||
(a b : ℕ) : a ≤ b → a ≤ (succ b) := by
|
||||
intro h
|
||||
rcases h with ⟨c, hc⟩
|
||||
rw [hc]
|
||||
use c + 1
|
||||
sorry
|
||||
--rfl
|
||||
|
||||
Conclusion
|
||||
"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NNG.Metadata
|
||||
import NNG.MyNat.Addition
|
||||
import NNG.MyNat.LE
|
||||
import Mathlib.Tactic.Use
|
||||
|
||||
Game "NNG"
|
||||
World "Inequality"
|
||||
|
||||
Reference in New Issue
Block a user