bump gameserver
This commit is contained in:
@@ -33,8 +33,8 @@ To prove `0 + n = n` we need to use induction on $n$. While we're here,
|
||||
note that `zero_add` is about zero add something, and `add_zero` is about something add zero.
|
||||
The names of the proofs tell you what the theorems are. Anyway, let's prove `0 + n = n`.
|
||||
"
|
||||
/-- For all natural numbers $n$, we have $0 + n = n$. -/
|
||||
Statement MyNat.zero_add
|
||||
"For all natural numbers $n$, we have $0 + n = n$."
|
||||
(n : ℕ) : 0 + n = n := by
|
||||
Hint "You can start a proof by induction over `n` by typing:
|
||||
`induction n with d hd`.
|
||||
|
||||
@@ -19,11 +19,11 @@ that addition, as defined the way we've defined it, is associative.
|
||||
See if you can prove associativity of addition.
|
||||
"
|
||||
|
||||
/-- On the set of natural numbers, addition is associative.
|
||||
In other words, for all natural numbers $a, b$ and $c$, we have
|
||||
$ (a + b) + c = a + (b + c). $ -/
|
||||
Statement MyNat.add_assoc
|
||||
|
||||
"On the set of natural numbers, addition is associative.
|
||||
In other words, for all natural numbers $a, b$ and $c$, we have
|
||||
$ (a + b) + c = a + (b + c). $"
|
||||
(a b c : ℕ) : (a + b) + c = a + (b + c) := by
|
||||
Hint "Because addition was defined by recursion on the right-most variable,
|
||||
use induction on the right-most variable (try other variables at your peril!).
|
||||
|
||||
@@ -27,9 +27,9 @@ that `a + succ(b) = succ(a + b)`. The tactic `rw [add_succ]` just says to Lean \
|
||||
what the variables are\".
|
||||
"
|
||||
|
||||
/-- For all natural numbers $a, b$, we have
|
||||
$ \operatorname{succ}(a) + b = \operatorname{succ}(a + b)$. -/
|
||||
Statement MyNat.succ_add
|
||||
"For all natural numbers $a, b$, we have
|
||||
$ \\operatorname{succ}(a) + b = \\operatorname{succ}(a + b)$."
|
||||
(a b : ℕ) : succ a + b = succ (a + b) := by
|
||||
Hint (hidden := true) "You might again want to start by induction
|
||||
on the right-most variable."
|
||||
|
||||
@@ -15,10 +15,10 @@ Look in your inventory to see the proofs you have available.
|
||||
These should be enough.
|
||||
"
|
||||
|
||||
Statement MyNat.add_comm
|
||||
"On the set of natural numbers, addition is commutative.
|
||||
/-- On the set of natural numbers, addition is commutative.
|
||||
In other words, for all natural numbers $a$ and $b$, we have
|
||||
$a + b = b + a$."
|
||||
$a + b = b + a$. -/
|
||||
Statement MyNat.add_comm
|
||||
(a b : ℕ) : a + b = b + a := by
|
||||
Hint (hidden := true) "You might want to start by induction."
|
||||
Branch
|
||||
|
||||
@@ -24,9 +24,9 @@ some theorems about $0$ (`zero_add`, `add_zero`), but, other than `1 = succ 0`,
|
||||
no theorems at all which mention $1$. Let's prove one now.
|
||||
"
|
||||
|
||||
/-- For any natural number $n$, we have
|
||||
$ \\operatorname{succ}(n) = n+1$ . -/
|
||||
Statement MyNat.succ_eq_add_one
|
||||
"For any natural number $n$, we have
|
||||
$ \\operatorname{succ}(n) = n+1$ ."
|
||||
(n : ℕ) : succ n = n + 1 := by
|
||||
rw [one_eq_succ_zero]
|
||||
rw [add_succ]
|
||||
|
||||
@@ -33,9 +33,9 @@ attribute [simp] MyNat.succ_add
|
||||
-- TODO: like this, `simp` does not do assoc. and comm. and
|
||||
-- I don't think it does IRL either, does it?
|
||||
|
||||
/-- For all natural numbers $a, b$ and $c$, we have
|
||||
$a + b + c = a + c + b$. -/
|
||||
Statement MyNat.add_right_comm
|
||||
"For all natural numbers $a, b$ and $c$, we have
|
||||
$a + b + c = a + c + b$."
|
||||
(a b c : ℕ) : a + b + c = a + c + b := by
|
||||
Hint (hidden := true) "You want to change your goal to `a + (b + c) = _`
|
||||
so that you can then use commutativity."
|
||||
|
||||
@@ -20,9 +20,9 @@ succ_inj (a b : ℕ) :
|
||||
"
|
||||
|
||||
-- NOTE:
|
||||
/-- For all naturals $a$ and $b$, if we assume $\operatorname{succ}(a)=\operatorname{succ}(b)$,
|
||||
then we can deduce $a=b$. -/
|
||||
Statement -- MyNat.succ_inj'
|
||||
"For all naturals $a$ and $b$, if we assume $\\operatorname{succ}(a)=\\operatorname{succ}(b)$,
|
||||
then we can deduce $a=b$."
|
||||
{a b : ℕ} (hs : succ a = succ b) : a = b := by
|
||||
Hint "You should know a couple
|
||||
of ways to prove the below -- one directly using an `exact`,
|
||||
|
||||
@@ -18,10 +18,10 @@ say that these two terms are *definitionally equal*.
|
||||
The following lemma, $a+b=0\\implies b=0$, will be useful in inequality world.
|
||||
"
|
||||
|
||||
Statement MyNat.add_left_eq_zero
|
||||
"If $a$ and $b$ are natural numbers such that
|
||||
/-- If $a$ and $b$ are natural numbers such that
|
||||
$$ a + b = 0, $$
|
||||
then $b = 0$."
|
||||
then $b = 0$. -/
|
||||
Statement MyNat.add_left_eq_zero
|
||||
{a b : ℕ} (h : a + b = 0) : b = 0 := by
|
||||
Hint "
|
||||
You want to start of by making a distinction `b = 0` or `b = succ d` for some
|
||||
|
||||
@@ -13,10 +13,10 @@ We just proved `add_left_eq_zero (a b : ℕ) : a + b = 0 → b = 0`.
|
||||
Hopefully `add_right_eq_zero` shouldn't be too hard now.
|
||||
"
|
||||
|
||||
Statement MyNat.add_right_eq_zero
|
||||
"If $a$ and $b$ are natural numbers such that
|
||||
/-- If $a$ and $b$ are natural numbers such that
|
||||
$$ a + b = 0, $$
|
||||
then $a = 0$."
|
||||
then $a = 0$. -/
|
||||
Statement MyNat.add_right_eq_zero
|
||||
{a b : ℕ} : a + b = 0 → a = 0 := by
|
||||
intro h
|
||||
rw [add_comm] at h
|
||||
|
||||
@@ -19,9 +19,9 @@ succ_eq_add_one (n : ℕ) : succ n = n + 1
|
||||
but sometimes the other way is also convenient.
|
||||
"
|
||||
|
||||
/-- For any natural number $d$, we have
|
||||
$$ d+1 = \\operatorname{succ}(d). $$ -/
|
||||
Statement MyNat.add_one_eq_succ
|
||||
"For any natural number $d$, we have
|
||||
$$ d+1 = \\operatorname{succ}(d). $$"
|
||||
(d : ℕ) : d + 1 = succ d := by
|
||||
rw [succ_eq_add_one]
|
||||
rfl
|
||||
|
||||
@@ -13,9 +13,9 @@ The last level in Advanced Addition World is the statement
|
||||
that $n\\not=\\operatorname{succ}(n)$.
|
||||
"
|
||||
|
||||
/-- For any natural number $n$, we have
|
||||
$$ n \\neq \\operatorname{succ}(n). $$ -/
|
||||
Statement --ne_succ_self
|
||||
"For any natural number $n$, we have
|
||||
$$ n \\neq \\operatorname{succ}(n). $$"
|
||||
(n : ℕ) : n ≠ succ n := by
|
||||
Hint (hidden := true) "I would start a proof by induction on `n`."
|
||||
induction n with d hd
|
||||
|
||||
@@ -19,10 +19,10 @@ nowhere to be found, it's neither an assumption or a goal when we start
|
||||
this level. You can make it with `have` or you can use `apply`.
|
||||
"
|
||||
|
||||
/-- For all naturals $a$ and $b$, if we assume
|
||||
$\operatorname{succ}(\operatorname{succ}(a))=\operatorname{succ}(\operatorname{succ}(b))$,
|
||||
then we can deduce $a=b$. -/
|
||||
Statement
|
||||
"For all naturals $a$ and $b$, if we assume
|
||||
$\\operatorname{succ}(\\operatorname{succ}(a))=\\operatorname{succ}(\\operatorname{succ}(b))$,
|
||||
then we can deduce $a=b$. "
|
||||
{a b : ℕ} (h : succ (succ a) = succ (succ b)) : a = b := by
|
||||
Branch
|
||||
simp at h
|
||||
|
||||
@@ -14,8 +14,8 @@ We are going to prove something completely obvious: if $a=b$ then
|
||||
$\\operatorname{succ}(a)=\\operatorname{succ}(b)$. This is *not* `succ_inj`!
|
||||
"
|
||||
|
||||
/-- For all naturals $a$ and $b$, $a=b\\implies \\operatorname{succ}(a)=\\operatorname{succ}(b)$. -/
|
||||
Statement MyNat.succ_eq_succ_of_eq
|
||||
"For all naturals $a$ and $b$, $a=b\\implies \\operatorname{succ}(a)=\\operatorname{succ}(b)$."
|
||||
{a b : ℕ} : a = b → succ a = succ b := by
|
||||
Hint "This is trivial -- we can just rewrite our proof of `a=b`.
|
||||
But how do we get to that proof? Use the `intro` tactic."
|
||||
|
||||
@@ -13,9 +13,9 @@ Here is an `iff` goal. You can split it into two goals (the implications in both
|
||||
directions) using the `constructor` tactic, which is how you're going to have to start.
|
||||
"
|
||||
|
||||
/-- Two natural numbers are equal if and only if their successors are equal.
|
||||
-/
|
||||
Statement
|
||||
"Two natural numbers are equal if and only if their successors are equal.
|
||||
"
|
||||
(a b : ℕ) : succ a = succ b ↔ a = b := by
|
||||
Branch
|
||||
simp
|
||||
|
||||
@@ -14,11 +14,11 @@ The theorem `add_right_cancel` is the theorem that you can cancel on the right
|
||||
when you're doing addition -- if `a + t = b + t` then `a = b`.
|
||||
"
|
||||
|
||||
Statement MyNat.add_right_cancel
|
||||
"On the set of natural numbers, addition has the right cancellation property.
|
||||
/-- On the set of natural numbers, addition has the right cancellation property.
|
||||
In other words, if there are natural numbers $a, b$ and $c$ such that
|
||||
$$ a + t = b + t, $$
|
||||
then we have $a = b$."
|
||||
then we have $a = b$. -/
|
||||
Statement MyNat.add_right_cancel
|
||||
(a t b : ℕ) : a + t = b + t → a = b := by
|
||||
Hint (hidden := true) "You can either start with `induction t` or with
|
||||
`intro` and you will have to do the other one afterwards."
|
||||
|
||||
@@ -13,11 +13,11 @@ The theorem `add_left_cancel` is the theorem that you can cancel on the left
|
||||
when you're doing addition -- if `t + a = t + b` then `a = b`.
|
||||
"
|
||||
|
||||
Statement MyNat.add_left_cancel
|
||||
"On the set of natural numbers, addition has the left cancellation property.
|
||||
/-- On the set of natural numbers, addition has the left cancellation property.
|
||||
In other words, if there are natural numbers $a, b$ and $t$ such that
|
||||
$$ t + a = t + b, $$
|
||||
then we have $a = b$."
|
||||
then we have $a = b$. -/
|
||||
Statement MyNat.add_left_cancel
|
||||
(t a b : ℕ) : t + a = t + b → a = b := by
|
||||
Branch
|
||||
induction t
|
||||
|
||||
@@ -14,10 +14,10 @@ of theorems like `add_right_cancel`. Remember that you can use `constructor`
|
||||
to split an `↔` goal into the `→` goal and the `←` goal.
|
||||
"
|
||||
|
||||
Statement MyNat.add_right_cancel_iff
|
||||
"For all naturals $a$, $b$ and $t$,
|
||||
/-- For all naturals $a$, $b$ and $t$,
|
||||
$$ a + t = b + t\\iff a=b. $$
|
||||
"
|
||||
-/
|
||||
Statement MyNat.add_right_cancel_iff
|
||||
(t a b : ℕ) : a + t = b + t ↔ a = b := by
|
||||
Branch
|
||||
induction t
|
||||
|
||||
@@ -14,10 +14,10 @@ The lemma you're about to prove will be useful when we want to prove that $\\leq
|
||||
There are some wrong paths that you can take with this one.
|
||||
"
|
||||
|
||||
Statement MyNat.eq_zero_of_add_right_eq_self
|
||||
"If $a$ and $b$ are natural numbers such that
|
||||
/-- If $a$ and $b$ are natural numbers such that
|
||||
$$ a + b = a, $$
|
||||
then $b = 0$."
|
||||
then $b = 0$. -/
|
||||
Statement MyNat.eq_zero_of_add_right_eq_self
|
||||
{a b : ℕ} : a + b = a → b = 0 := by
|
||||
intro h
|
||||
Hint (hidden := true) "Look at `add_left_cancel`."
|
||||
|
||||
@@ -24,8 +24,8 @@ $X\\ne Y$ is *defined to mean* $X = Y\\implies{\\tt False}$, similar to how `¬A
|
||||
-- In particular, you can prove `succ_ne_zero` below by first using
|
||||
-- `symmetry` and then `exact zero_ne_succ a`.
|
||||
|
||||
/-- Zero is not the successor of any natural number. -/
|
||||
Statement MyNat.succ_ne_zero
|
||||
"Zero is not the successor of any natural number."
|
||||
(a : ℕ) : succ a ≠ 0 := by
|
||||
Hint "You have several options how to start. One would be to recall that `≠` is defined as
|
||||
`(· = ·) → False` and start with `intro`. Or do `rw [Ne, Not]` to explicitely remove the
|
||||
|
||||
@@ -29,8 +29,8 @@ out that `_` is supposed to be `3 * x + 2 * y + 1`.
|
||||
-- a weaker version of induction (you don't get the inductive hypothesis).
|
||||
|
||||
|
||||
/-- The product of two non-zero natural numbers is non-zero. -/
|
||||
Statement
|
||||
"The product of two non-zero natural numbers is non-zero."
|
||||
(a b : ℕ) : a ≠ 0 → b ≠ 0 → a * b ≠ 0 := by
|
||||
intro ha hb
|
||||
intro hab
|
||||
|
||||
@@ -12,8 +12,8 @@ Introduction
|
||||
A variant on the previous level.
|
||||
"
|
||||
|
||||
/-- If $ab = 0$, then at least one of $a$ or $b$ is equal to zero. -/
|
||||
Statement MyNat.eq_zero_or_eq_zero_of_mul_eq_zero
|
||||
"If $ab = 0$, then at least one of $a$ or $b$ is equal to zero."
|
||||
(a b : ℕ) (h : a * b = 0) :
|
||||
a = 0 ∨ b = 0 := by
|
||||
induction a with d hd
|
||||
|
||||
@@ -13,9 +13,9 @@ Introduction
|
||||
Now you have `eq_zero_or_eq_zero_of_mul_eq_zero` this is pretty straightforward.
|
||||
"
|
||||
|
||||
/-- $ab = 0$, if and only if at least one of $a$ or $b$ is equal to zero.
|
||||
-/
|
||||
Statement
|
||||
"$ab = 0$, if and only if at least one of $a$ or $b$ is equal to zero.
|
||||
"
|
||||
{a b : ℕ} : a * b = 0 ↔ a = 0 ∨ b = 0 := by
|
||||
constructor
|
||||
intro h
|
||||
|
||||
@@ -54,10 +54,10 @@ to be impossible (judging by the comments I've had about it!)
|
||||
-- generalizing b` as the first line of the proof.
|
||||
|
||||
|
||||
Statement MyNat.mul_left_cancel
|
||||
"If $a \\neq 0$, $b$ and $c$ are natural numbers such that
|
||||
/-- If $a \\neq 0$, $b$ and $c$ are natural numbers such that
|
||||
$ ab = ac, $
|
||||
then $b = c$."
|
||||
then $b = c$. -/
|
||||
Statement MyNat.mul_left_cancel
|
||||
(a b c : ℕ) (ha : a ≠ 0) : a * b = a * c → b = c := by
|
||||
Hint "NOTE: As is, this level is probably too hard and contains no hints yet.
|
||||
Good luck!
|
||||
|
||||
@@ -15,8 +15,8 @@ $P\\land Q$ is the proposition \"$P$ and $Q$\".
|
||||
"
|
||||
namespace MySet
|
||||
|
||||
/-- If $P$ and $Q$ are true, then $P\\land Q$ is true. -/
|
||||
Statement
|
||||
"If $P$ and $Q$ are true, then $P\\land Q$ is true."
|
||||
(P Q : Prop) (p : P) (q : Q) : P ∧ Q := by
|
||||
Hint "If your *goal* is `P ∧ Q` then
|
||||
you can make progress with the `constructor` tactic, which turns one goal `P ∧ Q`
|
||||
|
||||
@@ -17,10 +17,10 @@ constructive logic).
|
||||
|
||||
"
|
||||
|
||||
Statement
|
||||
"If $P$ and $Q$ are true/false statements, then
|
||||
/-- If $P$ and $Q$ are true/false statements, then
|
||||
$$(\\lnot Q\\implies \\lnot P)\\implies(P\\implies Q).$$
|
||||
"
|
||||
-/
|
||||
Statement
|
||||
(P Q : Prop) : (¬ Q → ¬ P) → (P → Q) := by
|
||||
Hint "For example, you could start as always with
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ But what if `P ∧ Q` is a hypothesis? In this case, the `rcases` tactic will en
|
||||
us to extract proofs of `P` and `Q` from this hypothesis.
|
||||
"
|
||||
|
||||
/-- If $P$ and $Q$ are true/false statements, then $P\\land Q\\implies Q\\land P$. -/
|
||||
Statement -- and_symm
|
||||
"If $P$ and $Q$ are true/false statements, then $P\\land Q\\implies Q\\land P$. "
|
||||
(P Q : Prop) : P ∧ Q → Q ∧ P := by
|
||||
Hint "The lemma below asks us to prove `P ∧ Q → Q ∧ P`, that is,
|
||||
symmetry of the \"and\" relation. The obvious first move is
|
||||
|
||||
@@ -13,9 +13,9 @@ Introduction
|
||||
Here is another exercise to `rcases` and `constructor`.
|
||||
"
|
||||
|
||||
/-- If $P$, $Q$ and $R$ are true/false statements, then $P\\land Q$ and
|
||||
$Q\\land R$ together imply $P\\land R$. -/
|
||||
Statement --and_trans
|
||||
"If $P$, $Q$ and $R$ are true/false statements, then $P\\land Q$ and
|
||||
$Q\\land R$ together imply $P\\land R$."
|
||||
(P Q R : Prop) : P ∧ Q → Q ∧ R → P ∧ R := by
|
||||
Hint "Here's a trick:
|
||||
|
||||
|
||||
@@ -16,9 +16,9 @@ to write an `↔` arrow you can do so by typing `\\iff`, but you shouldn't need
|
||||
|
||||
"
|
||||
|
||||
/-- If $P$, $Q$ and $R$ are true/false statements, then
|
||||
$P\\iff Q$ and $Q\\iff R$ together imply $P\\iff R$. -/
|
||||
Statement --iff_trans
|
||||
"If $P$, $Q$ and $R$ are true/false statements, then
|
||||
$P\\iff Q$ and $Q\\iff R$ together imply $P\\iff R$."
|
||||
(P Q R : Prop) : (P ↔ Q) → (Q ↔ R) → (P ↔ R) := by
|
||||
Hint "Similar to \"and\", you can use `intro` and `rcases` to add the `P ↔ Q` to your
|
||||
assumptions and split it into its constituent parts."
|
||||
|
||||
@@ -38,9 +38,9 @@ you cannot rewrite one-way implications, but you can rewrite two-way implication
|
||||
-- ### Another trick
|
||||
-- `cc` works on this sort of goal too.
|
||||
|
||||
/-- If $P$, $Q$ and $R$ are true/false statements, then `P ↔ Q` and `Q ↔ R` together imply `P ↔ R`.
|
||||
-/
|
||||
Statement --iff_trans
|
||||
"If $P$, $Q$ and $R$ are true/false statements, then `P ↔ Q` and `Q ↔ R` together imply `P ↔ R`.
|
||||
"
|
||||
(P Q R : Prop) : (P ↔ Q) → (Q ↔ R) → (P ↔ R) := by
|
||||
intro hpq hqr
|
||||
Hint "Make a choice and continue either with `constructor` or `rw`.
|
||||
|
||||
@@ -20,8 +20,8 @@ goal to `P`, and `right` changes it to `Q`.
|
||||
-- After the `intro`, one of `left` and `right` leads
|
||||
-- to an impossible goal, the other to an easy finish.
|
||||
|
||||
/-- If $P$ and $Q$ are true/false statements, then $Q\\implies(P\\lor Q)$. -/
|
||||
Statement
|
||||
"If $P$ and $Q$ are true/false statements, then $Q\\implies(P\\lor Q)$."
|
||||
(P Q : Prop) : Q → (P ∨ Q) := by
|
||||
Hint (hidden := true) "Let's start with an initial `intro` again."
|
||||
intro q
|
||||
|
||||
@@ -13,9 +13,9 @@ Introduction
|
||||
Proving that $(P\\lor Q)\\implies(Q\\lor P)$ involves an element of danger.
|
||||
"
|
||||
|
||||
/-- If $P$ and $Q$ are true/false statements, then
|
||||
$$P\\lor Q\\implies Q\\lor P.$$ -/
|
||||
Statement --or_symm
|
||||
"If $P$ and $Q$ are true/false statements, then
|
||||
$$P\\lor Q\\implies Q\\lor P.$$ "
|
||||
(P Q : Prop) : P ∨ Q → Q ∨ P := by
|
||||
Hint "`intro h` is the obvious start."
|
||||
intro h
|
||||
|
||||
@@ -16,9 +16,9 @@ The same is true for `∧` and `∨` -- in fact `∧` distributes
|
||||
over `∨` and `∨` distributes over `∧`. Let's prove one of these.
|
||||
"
|
||||
|
||||
/-- If $P$. $Q$ and $R$ are true/false statements, then
|
||||
$$P\\land(Q\\lor R)\\iff(P\\land Q)\\lor (P\\land R).$$ -/
|
||||
Statement --and_or_distrib_left
|
||||
"If $P$. $Q$ and $R$ are true/false statements, then
|
||||
$$P\\land(Q\\lor R)\\iff(P\\land Q)\\lor (P\\land R).$$ "
|
||||
(P Q R : Prop) : P ∧ (Q ∨ R) ↔ (P ∧ Q) ∨ (P ∧ R) := by
|
||||
constructor
|
||||
intro h
|
||||
|
||||
@@ -19,9 +19,9 @@ then after `rw not_iff_imp_false at h,` you can `apply h,` to make progress.
|
||||
Try solving this level without using `cc` or `tauto`, but using `exfalso` instead.
|
||||
"
|
||||
|
||||
/-- If $P$ and $Q$ are true/false statements, then
|
||||
$$(P\\land(\\lnot P))\\implies Q.$$ -/
|
||||
Statement --contra
|
||||
"If $P$ and $Q$ are true/false statements, then
|
||||
$$(P\\land(\\lnot P))\\implies Q.$$"
|
||||
(P Q : Prop) : (P ∧ ¬ P) → Q := by
|
||||
Hint "Start as usual with `intro ⟨p, np⟩`."
|
||||
Branch
|
||||
|
||||
@@ -33,8 +33,8 @@ i.e. you have a formula for it, then you can just write `exact <formula>`
|
||||
and this will close the goal.
|
||||
"
|
||||
|
||||
/-- If $P$ is true, and $P\\implies Q$ is also true, then $Q$ is true. -/
|
||||
Statement
|
||||
"If $P$ is true, and $P\\implies Q$ is also true, then $Q$ is true."
|
||||
(P Q : Prop) (p : P) (h : P → Q) : Q := by
|
||||
Hint
|
||||
"In this situation, we have sets $P$ and $Q$ (but Lean calls them types),
|
||||
|
||||
@@ -26,8 +26,8 @@ element $x\\in X$ and then, perhaps using $x$, make an element of $Y$.
|
||||
The Lean tactic for \"let $x\\in X$ be arbitrary\" is `intro x`.
|
||||
"
|
||||
|
||||
/-- We define a function from ℕ to ℕ. -/
|
||||
Statement
|
||||
"We define a function from ℕ to ℕ."
|
||||
: ℕ → ℕ := by
|
||||
Hint "To solve this goal,
|
||||
you have to come up with a function from `ℕ`
|
||||
|
||||
@@ -34,8 +34,8 @@ $$
|
||||
and so it's clear how to make the element of $U$ from the element of $P$.
|
||||
"
|
||||
|
||||
/-- Given an element of $P$ we can define an element of $U$. -/
|
||||
Statement
|
||||
"Given an element of $P$ we can define an element of $U$."
|
||||
(P Q R S T U: Type) (p : P) (h : P → Q) (i : Q → R) (j : Q → T) (k : S → T) (l : T → U) :
|
||||
U := by
|
||||
Hint "Indeed, we could solve this level in one move by typing
|
||||
|
||||
@@ -25,8 +25,8 @@ to $Q$ to $T$ to $U$. Using the `apply` tactic we can instead construct
|
||||
the path backwards, moving from $U$ to $T$ to $Q$ to $P$.
|
||||
"
|
||||
|
||||
/-- Given an element of $P$ we can define an element of $U$. -/
|
||||
Statement
|
||||
"Given an element of $P$ we can define an element of $U$."
|
||||
(P Q R S T U: Type)
|
||||
(p : P)
|
||||
(h : P → Q)
|
||||
|
||||
@@ -21,8 +21,8 @@ We don't know anything at all about the sets $P$ and $Q$, so initially
|
||||
this seems like a bit of a tall order. But let's give it a go.
|
||||
"
|
||||
|
||||
/-- We define an element of $\\operatorname{Hom}(P,\\operatorname{Hom}(Q,P))$. -/
|
||||
Statement
|
||||
"We define an element of $\\operatorname{Hom}(P,\\operatorname{Hom}(Q,P))$."
|
||||
(P Q : Type) : P → (Q → P) := by
|
||||
Hint "Our goal is `P → X` for some set $X=\\operatorname\{Hom}(Q,P)$, and if our
|
||||
goal is to construct a function then we almost always want to use the
|
||||
|
||||
@@ -22,10 +22,10 @@ we could just write `have j := f p,` but this way we can be sure that `j` is
|
||||
what we actually expect it to be.
|
||||
"
|
||||
|
||||
Statement
|
||||
"Whatever the sets $P$ and $Q$ and $R$ are, we
|
||||
/-- Whatever the sets $P$ and $Q$ and $R$ are, we
|
||||
make an element of $\\operatorname{Hom}(\\operatorname{Hom}(P,\\operatorname{Hom}(Q,R)),
|
||||
\\operatorname{Hom}(\\operatorname{Hom}(P,Q),\\operatorname{Hom}(P,R)))$."
|
||||
\\operatorname{Hom}(\\operatorname{Hom}(P,Q),\\operatorname{Hom}(P,R)))$. -/
|
||||
Statement
|
||||
(P Q R : Type) : (P → (Q → R)) → ((P → Q) → (P → R)) := by
|
||||
Hint "I recommend that you start with `intro f` rather than `intro p`
|
||||
because even though the goal starts `P → _`, the brackets mean that
|
||||
|
||||
@@ -19,10 +19,10 @@ know it as contravariance of $\\operatorname{Hom}(\\cdot,F)$
|
||||
functor.
|
||||
"
|
||||
|
||||
Statement
|
||||
"Whatever the sets $P$ and $Q$ and $F$ are, we
|
||||
/-- Whatever the sets $P$ and $Q$ and $F$ are, we
|
||||
make an element of $\\operatorname{Hom}(\\operatorname{Hom}(P,Q),
|
||||
\\operatorname{Hom}(\\operatorname{Hom}(Q,F),\\operatorname{Hom}(P,F)))$."
|
||||
\\operatorname{Hom}(\\operatorname{Hom}(Q,F),\\operatorname{Hom}(P,F)))$. -/
|
||||
Statement
|
||||
(P Q F : Type) : (P → Q) → ((Q → F) → (P → F)) := by
|
||||
intro f
|
||||
intro h
|
||||
|
||||
@@ -14,10 +14,10 @@ set $F$ with the empty set $\\emptyset$. The same proof will work (after all, ou
|
||||
previous proof worked for all sets, and the empty set is a set).
|
||||
"
|
||||
|
||||
Statement
|
||||
"Whatever the sets $P$ and $Q$ are, we
|
||||
/-- Whatever the sets $P$ and $Q$ are, we
|
||||
make an element of $\\operatorname{Hom}(\\operatorname{Hom}(P,Q),
|
||||
\\operatorname{Hom}(\\operatorname{Hom}(Q,\\emptyset),\\operatorname{Hom}(P,\\emptyset)))$."
|
||||
\\operatorname{Hom}(\\operatorname{Hom}(Q,\\emptyset),\\operatorname{Hom}(P,\\emptyset)))$. -/
|
||||
Statement
|
||||
(P Q : Type) : (P → Q) → ((Q → Empty) → (P → Empty)) := by
|
||||
Hint (hidden := true) "Maybe start again with `intro`."
|
||||
intro f h p
|
||||
|
||||
@@ -17,8 +17,8 @@ which could solve this sort of level in Lean.
|
||||
You can of course work both forwards and backwards, or you could crack and draw a picture.
|
||||
"
|
||||
|
||||
/-- Given a bunch of functions, we can define another one. -/
|
||||
Statement
|
||||
"Given a bunch of functions, we can define another one."
|
||||
(A B C D E F G H I J K L : Type)
|
||||
(f1 : A → B) (f2 : B → E) (f3 : E → D) (f4 : D → A) (f5 : E → F)
|
||||
(f6 : F → C) (f7 : B → C) (f8 : F → G) (f9 : G → J) (f10 : I → J)
|
||||
|
||||
@@ -35,9 +35,9 @@ before it and comment it out. See that the proof still compiles.
|
||||
|
||||
axiom TMP.add_comm (a b : ℕ) : a + b = b + a
|
||||
|
||||
/-- If $x$ is a natural number, then $x\\le 1+x$.
|
||||
-/
|
||||
Statement --one_add_le_self
|
||||
"If $x$ is a natural number, then $x\\le 1+x$.
|
||||
"
|
||||
(x : ℕ) : x ≤ 1 + x := by
|
||||
Hint "
|
||||
The goal below is to prove $x\\le 1+x$ for any natural number $x$.
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,9 +14,9 @@ Introduction
|
||||
Here's a nice easy one.
|
||||
"
|
||||
|
||||
/-- The $\\le$ relation is reflexive. In other words, if $x$ is a natural number,
|
||||
then $x\\le x$. -/
|
||||
Statement
|
||||
"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]
|
||||
|
||||
@@ -42,9 +42,9 @@ Now use `use` wisely and you're home.
|
||||
|
||||
"
|
||||
|
||||
/-- For all naturals $a$, $b$, if $a\\leq b$ then $a\\leq \\operatorname{succ}(b)$.
|
||||
-/
|
||||
Statement
|
||||
"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⟩
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Introduction
|
||||
|
||||
"
|
||||
|
||||
/-- -/
|
||||
Statement
|
||||
""
|
||||
: true := by
|
||||
trivial
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ We are given `mul_zero`, and the first thing to prove is `zero_mul`.
|
||||
Like `zero_add`, we of course prove it by induction.
|
||||
"
|
||||
|
||||
/-- For all natural numbers $m$, we have $ 0 \\cdot m = 0$. -/
|
||||
Statement MyNat.zero_mul
|
||||
"For all natural numbers $m$, we have $ 0 \\cdot m = 0$."
|
||||
(m : ℕ) : 0 * m = 0 := by
|
||||
induction m
|
||||
· rw [mul_zero]
|
||||
|
||||
@@ -19,8 +19,8 @@ begin to prove a couple of lemmas about how `1` behaves
|
||||
with respect to multiplication.
|
||||
"
|
||||
|
||||
/-- For any natural number $m$, we have $ m \\cdot 1 = m$. -/
|
||||
Statement MyNat.mul_one
|
||||
"For any natural number $m$, we have $ m \\cdot 1 = m$."
|
||||
(m : ℕ) : m * 1 = m := by
|
||||
rw [one_eq_succ_zero]
|
||||
rw [mul_succ]
|
||||
|
||||
@@ -22,8 +22,8 @@ for multiplication (just like we showed that
|
||||
with `add_zero` and `zero_add`).
|
||||
"
|
||||
|
||||
/-- For any natural number $m$, we have $ 1 \\cdot m = m$. -/
|
||||
Statement MyNat.one_mul
|
||||
"For any natural number $m$, we have $ 1 \\cdot m = m$."
|
||||
(m : ℕ): 1 * m = m := by
|
||||
induction m with d hd
|
||||
· rw [mul_zero]
|
||||
|
||||
@@ -25,10 +25,10 @@ I think `mul_add` is much easier to remember than \"`left_distrib`\",
|
||||
an alternative name for the proof of this lemma.
|
||||
"
|
||||
|
||||
Statement MyNat.mul_add
|
||||
"Multiplication is distributive over addition.
|
||||
/-- Multiplication is distributive over addition.
|
||||
In other words, for all natural numbers $a$, $b$ and $t$, we have
|
||||
$t(a + b) = ta + tb$."
|
||||
$t(a + b) = ta + tb$. -/
|
||||
Statement MyNat.mul_add
|
||||
(t a b : ℕ) : t * (a + b) = t * a + t * b := by
|
||||
induction b with d hd
|
||||
· Branch
|
||||
|
||||
@@ -17,10 +17,10 @@ You can do `repeat rw [mul_succ]` to repeat a tactic as often as possible.
|
||||
|
||||
"
|
||||
|
||||
Statement MyNat.mul_assoc
|
||||
"Multiplication is associative.
|
||||
/-- Multiplication is associative.
|
||||
In other words, for all natural numbers $a$, $b$ and $c$, we have
|
||||
$(ab)c = a(bc)$."
|
||||
$(ab)c = a(bc)$. -/
|
||||
Statement MyNat.mul_assoc
|
||||
(a b c : ℕ) : (a * b) * c = a * (b * c) := by
|
||||
induction c with d hd
|
||||
· repeat rw [mul_zero]
|
||||
|
||||
@@ -27,9 +27,9 @@ of rewrites of `add_assoc` and `add_comm`. Use if
|
||||
you're getting lazy!
|
||||
"
|
||||
|
||||
/-- For all natural numbers $a$ and $b$, we have
|
||||
$\\operatorname{succ}(a) \\cdot b = ab + b$. -/
|
||||
Statement MyNat.succ_mul
|
||||
"For all natural numbers $a$ and $b$, we have
|
||||
$\\operatorname{succ}(a) \\cdot b = ab + b$."
|
||||
(a b : ℕ) : succ a * b = a * b + b := by
|
||||
induction b with d hd
|
||||
· rw [mul_zero]
|
||||
|
||||
@@ -21,10 +21,10 @@ don't mess around doing it explicitly with `add_comm` and `add_assoc`,
|
||||
just try `simp`.
|
||||
"
|
||||
|
||||
Statement MyNat.add_mul
|
||||
"Addition is distributive over multiplication.
|
||||
/-- Addition is distributive over multiplication.
|
||||
In other words, for all natural numbers $a$, $b$ and $t$, we have
|
||||
$(a + b) \\cdot t = at + bt$."
|
||||
$(a + b) \\cdot t = at + bt$. -/
|
||||
Statement MyNat.add_mul
|
||||
(a b t : ℕ) : (a + b) * t = a * t + b * t := by
|
||||
induction b with d hd
|
||||
· rw [zero_mul]
|
||||
|
||||
@@ -17,8 +17,8 @@ but I would recommend you hold on to them, sometimes it's convenient
|
||||
to have exactly the right tools to do a job.
|
||||
"
|
||||
|
||||
/-- Multiplication is commutative. -/
|
||||
Statement MyNat.mul_comm
|
||||
"Multiplication is commutative."
|
||||
(a b : ℕ) : a * b = b * a := by
|
||||
induction b with d hd
|
||||
· rw [zero_mul]
|
||||
|
||||
@@ -27,8 +27,8 @@ attribute [simp] MyNat.succ_mul
|
||||
attribute [simp] MyNat.mul_one
|
||||
attribute [simp] MyNat.one_mul
|
||||
|
||||
/-- For all natural numbers $a$ $b$ and $c$, we have $a(bc)=b(ac)$. -/
|
||||
Statement MyNat.mul_left_comm
|
||||
"For all natural numbers $a$ $b$ and $c$, we have $a(bc)=b(ac)$."
|
||||
(a b c : ℕ) : a * (b * c) = b * (a * c) := by
|
||||
Branch
|
||||
induction c
|
||||
|
||||
@@ -8,8 +8,8 @@ Title "zero_pow_zero"
|
||||
|
||||
open MyNat
|
||||
|
||||
/-- $0 ^ 0 = 1$ -/
|
||||
Statement MyNat.zero_pow_zero
|
||||
"$0 ^ 0 = 1$"
|
||||
: (0 : ℕ) ^ 0 = 1 := by
|
||||
rw [pow_zero]
|
||||
rfl
|
||||
|
||||
@@ -7,8 +7,8 @@ Title "zero_pow_succ"
|
||||
|
||||
open MyNat
|
||||
|
||||
/-- For all naturals $m$, $0 ^{\\operatorname{succ} (m)} = 0$. -/
|
||||
Statement MyNat.zero_pow_succ
|
||||
"For all naturals $m$, $0 ^{\\operatorname{succ} (m)} = 0$."
|
||||
(m : ℕ) : (0 : ℕ) ^ (succ m) = 0 := by
|
||||
rw [pow_succ]
|
||||
rw [mul_zero]
|
||||
|
||||
@@ -7,8 +7,8 @@ Title "pow_one"
|
||||
|
||||
open MyNat
|
||||
|
||||
/-- For all naturals $a$, $a ^ 1 = a$. -/
|
||||
Statement MyNat.pow_one
|
||||
"For all naturals $a$, $a ^ 1 = a$."
|
||||
(a : ℕ) : a ^ 1 = a := by
|
||||
rw [one_eq_succ_zero]
|
||||
rw [pow_succ]
|
||||
|
||||
@@ -8,8 +8,8 @@ Title "one_pow"
|
||||
|
||||
open MyNat
|
||||
|
||||
/-- For all naturals $m$, $1 ^ m = 1$. -/
|
||||
Statement MyNat.one_pow
|
||||
"For all naturals $m$, $1 ^ m = 1$."
|
||||
(m : ℕ) : (1 : ℕ) ^ m = 1 := by
|
||||
induction m with t ht
|
||||
· rw [pow_zero]
|
||||
|
||||
@@ -8,8 +8,8 @@ Title "pow_add"
|
||||
|
||||
open MyNat
|
||||
|
||||
/-- For all naturals $a$, $m$, $n$, we have $a^{m + n} = a ^ m a ^ n$. -/
|
||||
Statement MyNat.pow_add
|
||||
"For all naturals $a$, $m$, $n$, we have $a^{m + n} = a ^ m a ^ n$."
|
||||
(a m n : ℕ) : a ^ (m + n) = a ^ m * a ^ n := by
|
||||
induction n with t ht
|
||||
· rw [add_zero, pow_zero, mul_one]
|
||||
|
||||
@@ -15,8 +15,8 @@ Multiplication World and take a look -- you won't lose any of your
|
||||
proofs.
|
||||
"
|
||||
|
||||
/-- For all naturals $a$, $b$, $n$, we have $(ab) ^ n = a ^ nb ^ n$. -/
|
||||
Statement MyNat.mul_pow
|
||||
"For all naturals $a$, $b$, $n$, we have $(ab) ^ n = a ^ nb ^ n$."
|
||||
(a b n : ℕ) : (a * b) ^ n = a ^ n * b ^ n := by
|
||||
induction n with t Ht
|
||||
· rw [pow_zero, pow_zero, pow_zero, mul_one]
|
||||
|
||||
@@ -12,8 +12,8 @@ Introduction
|
||||
Boss level! What will the collectible be?
|
||||
"
|
||||
|
||||
/-- For all naturals $a$, $m$, $n$, we have $(a ^ m) ^ n = a ^ {mn}$. -/
|
||||
Statement MyNat.pow_pow
|
||||
"For all naturals $a$, $m$, $n$, we have $(a ^ m) ^ n = a ^ {mn}$."
|
||||
(a m n : ℕ) : (a ^ m) ^ n = a ^ (m * n) := by
|
||||
induction n with t Ht
|
||||
· rw [mul_zero, pow_zero, pow_zero]
|
||||
|
||||
@@ -26,9 +26,9 @@ of thing in the way that will magically disappear
|
||||
but only when you've beaten the boss.
|
||||
"
|
||||
|
||||
/-- For all naturals $a$ and $b$, we have
|
||||
$$(a+b)^2=a^2+b^2+2ab.$$ -/
|
||||
Statement MyNat.add_squared
|
||||
"For all naturals $a$ and $b$, we have
|
||||
$$(a+b)^2=a^2+b^2+2ab.$$"
|
||||
(a b : ℕ) : (a + b) ^ 2 = a ^ 2 + b ^ 2 + 2 * a * b := by
|
||||
Branch
|
||||
simp? [two_eq_succ_one]
|
||||
|
||||
@@ -20,8 +20,8 @@ The levels in proposition world are \"back to normal\", we're proving
|
||||
theorems, not constructing elements of sets. Or are we?
|
||||
"
|
||||
|
||||
/-- If $P$ is true, and $P\\implies Q$ is also true, then $Q$ is true. -/
|
||||
Statement
|
||||
"If $P$ is true, and $P\\implies Q$ is also true, then $Q$ is true."
|
||||
(P Q : Prop) (p : P) (h : P → Q) : Q := by
|
||||
Hint
|
||||
"
|
||||
|
||||
@@ -38,8 +38,8 @@ then `intro p`, meaning \"assume $p$ is a proof of $P$\", will make progress.
|
||||
|
||||
"
|
||||
|
||||
/-- If $P$ is a proposition then $P\\implies P$. -/
|
||||
Statement
|
||||
"If $P$ is a proposition then $P\\implies P$."
|
||||
{P : Prop} : P → P := by
|
||||
Hint "
|
||||
To solve this goal, you have to come up with a function from
|
||||
|
||||
@@ -37,8 +37,8 @@ and so it's clear how to deduce $U$ from $P$.
|
||||
|
||||
"
|
||||
|
||||
/-- In the maze of logical implications above, if $P$ is true then so is $U$. -/
|
||||
Statement
|
||||
"In the maze of logical implications above, if $P$ is true then so is $U$."
|
||||
(P Q R S T U: Prop) (p : P) (h : P → Q) (i : Q → R)
|
||||
(j : Q → T) (k : S → T) (l : T → U) : U := by
|
||||
Hint "Indeed, we could solve this level in one move by typing
|
||||
|
||||
@@ -27,8 +27,8 @@ to $Q$ to $T$ to $U$. Using the `apply` tactic we can instead construct
|
||||
the path backwards, moving from $U$ to $T$ to $Q$ to $P$.
|
||||
"
|
||||
|
||||
/-- We can solve a maze. -/
|
||||
Statement
|
||||
"We can solve a maze."
|
||||
(P Q R S T U: Prop) (p : P) (h : P → Q) (i : Q → R)
|
||||
(j : Q → T) (k : S → T) (l : T → U) : U := by
|
||||
Hint "Our goal is to prove $U$. But $l:T\\implies U$ is
|
||||
|
||||
@@ -22,9 +22,9 @@ We don't know whether $P$, $Q$ are true or false, so initially
|
||||
this seems like a bit of a tall order. But let's give it a go.
|
||||
"
|
||||
|
||||
/-- For any propositions $P$ and $Q$, we always have
|
||||
$P\\implies(Q\\implies P)$. -/
|
||||
Statement
|
||||
"For any propositions $P$ and $Q$, we always have
|
||||
$P\\implies(Q\\implies P)$."
|
||||
(P Q : Prop) : P → (Q → P) := by
|
||||
Hint "Our goal is `P → X` for some true/false statement $X$, and if our
|
||||
goal is to construct an implication then we almost always want to use the
|
||||
|
||||
@@ -16,11 +16,11 @@ that you can do things like `have j : Q → R := f p` if `f : P → (Q → R)`
|
||||
and `p : P`.
|
||||
"
|
||||
|
||||
Statement
|
||||
"If $P$ and $Q$ and $R$ are true/false statements, then
|
||||
/-- If $P$ and $Q$ and $R$ are true/false statements, then
|
||||
$$
|
||||
(P\\implies(Q\\implies R))\\implies((P\\implies Q)\\implies(P\\implies R)).
|
||||
$$"
|
||||
$$ -/
|
||||
Statement
|
||||
(P Q R : Prop) : (P → (Q → R)) → ((P → Q) → (P → R)) := by
|
||||
Hint "I recommend that you start with `intro f` rather than `intro p`
|
||||
because even though the goal starts `P → ...`, the brackets mean that
|
||||
|
||||
@@ -10,8 +10,8 @@ open MyNat
|
||||
|
||||
Introduction ""
|
||||
|
||||
/-- From $P\\implies Q$ and $Q\\implies R$ we can deduce $P\\implies R$. -/
|
||||
Statement
|
||||
"From $P\\implies Q$ and $Q\\implies R$ we can deduce $P\\implies R$."
|
||||
(P Q R : Prop) : (P → Q) → ((Q → R) → (P → R)) := by
|
||||
Hint (hidden := true)"If you start with `intro hpq` and then `intro hqr`
|
||||
the dust will clear a bit."
|
||||
|
||||
@@ -17,9 +17,9 @@ In lean, this is true *by definition*, so you can view and treat `¬A` as an imp
|
||||
`A → False`.
|
||||
"
|
||||
|
||||
/-- If $P$ and $Q$ are propositions, and $P\\implies Q$, then
|
||||
$\\lnot Q\\implies \\lnot P$. -/
|
||||
Statement
|
||||
"If $P$ and $Q$ are propositions, and $P\\implies Q$, then
|
||||
$\\lnot Q\\implies \\lnot P$. "
|
||||
(P Q : Prop) : (P → Q) → (¬ Q → ¬ P) := by
|
||||
Hint "However, if you would like to *see* `¬ Q` as `Q → False` because it makes you help
|
||||
understanding, you can call
|
||||
|
||||
@@ -21,8 +21,8 @@ automatisation ;)
|
||||
-- "Lean's "congruence closure" tactic `cc` is good at mazes. You might want to try it now.
|
||||
-- Perhaps I should have mentioned it earlier."
|
||||
|
||||
/-- There is a way through the following maze. -/
|
||||
Statement
|
||||
"There is a way through the following maze."
|
||||
(A B C D E F G H I J K L : Prop)
|
||||
(f1 : A → B) (f2 : B → E) (f3 : E → D) (f4 : D → A) (f5 : E → F)
|
||||
(f6 : F → C) (f7 : B → C) (f8 : F → G) (f9 : G → J) (f10 : I → J)
|
||||
|
||||
@@ -22,8 +22,8 @@ on your computer in the same order\" equal. For example, `x * y + z = x * y + z`
|
||||
but `x + y = y + x` cannot.
|
||||
"
|
||||
|
||||
/-- For all natural numbers $x, y$ and $z$, we have $xy + z = xy + z$. -/
|
||||
Statement
|
||||
"For all natural numbers $x, y$ and $z$, we have $xy + z = xy + z$."
|
||||
(x y z : ℕ) : x * y + z = x * y + z := by
|
||||
Hint "In order to use the tactic `rfl` you can enter it above and hit \"Execute\"."
|
||||
rfl
|
||||
|
||||
@@ -18,8 +18,8 @@ then the rewrite tactic will replace the `A` in your goal with a `B`.
|
||||
Here is a theorem which cannot be proved using rfl -- you need a rewrite first.
|
||||
"
|
||||
|
||||
/-- If $x$ and $y$ are natural numbers, and $y = x + 7$, then $2y = 2(x + 7)$. -/
|
||||
Statement
|
||||
"If $x$ and $y$ are natural numbers, and $y = x + 7$, then $2y = 2(x + 7)$."
|
||||
(x y : ℕ) (h : y = x + 7) : 2 * y = 2 * (x + 7) := by
|
||||
Hint "You can use `rw [h]` to replace the `{y}` with `x + 7`.
|
||||
Note that the assumption `h` is written
|
||||
|
||||
@@ -43,8 +43,8 @@ This game is all about seeing how far these axioms of Peano can take us.
|
||||
Now let us practise the use of `rw` with this new function `succ`:
|
||||
"
|
||||
|
||||
/-- If $\\operatorname{succ}(a) = b$, then $\\operatorname{succ}(\\operatorname{succ}(a)) = \\operatorname{succ}(b)$. -/
|
||||
Statement
|
||||
"If $\\operatorname{succ}(a) = b$, then $\\operatorname{succ}(\\operatorname{succ}(a)) = \\operatorname{succ}(b)$."
|
||||
(a b : ℕ) (h : (succ a) = b) : succ (succ a) = succ b := by
|
||||
Hint "You can use `rw` and your assumption `{h}` to substitute `succ a` with `b`.
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ LemmaDoc MyNat.add_succ as "add_succ" in "Add"
|
||||
LemmaDoc MyNat.add_zero as "add_zero" in "Add"
|
||||
"One of the two axioms defining addition. It says `n + 0 = n`."
|
||||
|
||||
/-- For all natural numbers $a$, we have $a + \\operatorname{succ}(0) = \\operatorname{succ}(a)$. -/
|
||||
Statement
|
||||
"For all natural numbers $a$, we have $a + \\operatorname{succ}(0) = \\operatorname{succ}(a)$."
|
||||
: a + succ 0 = succ a := by
|
||||
Hint "You find `{a} + succ …` in the goal, so you can use `rw` and `add_succ`
|
||||
to make progress."
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
{"git":
|
||||
{"url": "https://github.com/leanprover-community/lean4game.git",
|
||||
"subDir?": "server",
|
||||
"rev": "5072dacf947d4f682e14a56816eb10f9e46d7203",
|
||||
"rev": "adb93e30bd0c0364a91b7ee4c606a01d33c5acd4",
|
||||
"name": "GameServer",
|
||||
"inputRev?": "5072dacf947d4f682e14a56816eb10f9e46d7203"}},
|
||||
"inputRev?": "adb93e30bd0c0364a91b7ee4c606a01d33c5acd4"}},
|
||||
{"git":
|
||||
{"url": "https://github.com/leanprover/std4",
|
||||
"subDir?": null,
|
||||
|
||||
@@ -8,7 +8,7 @@ def LocalGameServer : Dependency := {
|
||||
|
||||
def RemoteGameServer : Dependency := {
|
||||
name := `GameServer
|
||||
src := Source.git "https://github.com/leanprover-community/lean4game.git" "5072dacf947d4f682e14a56816eb10f9e46d7203" "server"
|
||||
src := Source.git "https://github.com/leanprover-community/lean4game.git" "adb93e30bd0c0364a91b7ee4c606a01d33c5acd4" "server"
|
||||
}
|
||||
|
||||
/- Choose dependency depending on the environment variable NODE_ENV -/
|
||||
|
||||
Reference in New Issue
Block a user