8.Β β€ World
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.
8.1.Β Level 1: The use tactic
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.
If x is a number, then x \le x.
New: 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 useing the
number which is morally b - a (i.e. use b - a)
Any of the following examples is possible assuming the type of the argument passed to the use function is accurate:
-
use 37 -
use a -
use a * a + 1
New: β€
a β€ b is notation for β c, b = a + c.
Because this game doesn't have negative numbers, this definition is mathematically valid.
This means that if you have a goal of the form a β€ b you can
make progress with the use tactic, and if you have a hypothesis
h : a β€ b, you can make progress with cases h with c hc.
theorem le_refl (x : β) : x β€ x
8.2.Β Level 2: 0 β€ x
To solve this level, you need to use a number c such that x = 0 + c.
If x is a number, then 0 \le x.
theorem zero_le (x : β) : 0 β€ x
8.3.Β Level 3: x β€ succ x
If you use the wrong number, you get stuck with a goal you can't prove.
What number will you use here?
If x is a number, then x \le \operatorname{succ}(x).
theorem le_succ_self (x : β) : x β€ succ x
Here's a two-liner:
use 1 exact succ_eq_add_one x
This works because succ_eq_add_one x is a proof of succ x = x + 1.
8.4.Β Level 4: x β€ y and y β€ z implies x β€ z
In this level, we see inequalities as hypotheses. We have not seen this before.
The cases tactic can be used to take hxy apart.
If x \leq y and y \leq z, then x \leq z.
theorem le_trans (x y z : β) (hxy : x β€ y) (hyz : y β€ z) : x β€ z
A passing mathematician remarks that with reflexivity and transitivity out of the way,
you have proved that β€ is a preorder on β.
8.5.Β Level 5: x β€ 0 β x = 0
It's "intuitively obvious" that there are no numbers less than zero, but to prove it you will need a result which you showed in advanced addition world.
If x \leq 0, then x=0.
theorem le_zero (x : β) (hx : x β€ 0) : x = 0
8.6.Β Level 6: x β€ y and y β€ x implies x = y
This level asks you to prove antisymmetry of \leq.
In other words, if x \leq y and y \leq x then x = y.
It's the trickiest one so far. Good luck!
If x \leq y and y \leq x, then x = y.
theorem le_antisymm (x y : β) (hxy : x β€ y) (hyx : y β€ x) : x = y
Here's my proof:
cases hxy with a ha cases hyx with b hb rw [ha] rw [ha, add_assoc] at hb symm at hb apply add_right_eq_self at hb apply add_right_eq_zero at hb rw [hb, add_zero] rfl
A passing mathematician remarks that with antisymmetry as well,
you have proved that β€ is a partial order on β.
The boss level of this world is to prove
that β€ is a total order. Let's learn two more easy tactics
first.
8.7.Β Level 7: Dealing with or
Totality of β€ is the boss level of this world, and it's coming up next. It says that
if a and b are naturals then either a β€ b or b β€ a.
But we haven't talked about or at all. Here's a run-through.
-
The notation for "or" is
β¨. You won't need to type it, but you can type it with\or. -
If you have an "or" statement in the goal, then two tactics make progress:
leftandright. But don't choose a direction unless your hypotheses guarantee that it's the correct one. -
If you have an "or" statement as a hypothesis
h, thencases h with h1 h2will create two goals, one where you went left, and the other where you went right.
If x=37 or y=42, then y=42 or x=37.
New: left
Summary
The left tactic changes a goal of P β¨ Q into a goal of P.
Use it when your hypotheses guarantee that the reason that P β¨ Q
is true is because in fact P is true.
Internally this tactic is just applying a theorem
saying that P \implies P \lor Q.
Note that this tactic can turn a solvable goal into an unsolvable one.
New: right
Summary
The right tactic changes a goal of P β¨ Q into a goal of Q.
Use it when your hypotheses guarantee that the reason that P β¨ Q
is true is because in fact Q is true.
Internally this tactic is just applying a theorem
saying that Q \implies P \lor Q.
Note that this tactic can turn a solvable goal into an unsolvable one.
example (x y : β) (h : x = 37 β¨ y = 42) : y = 42 β¨ x = 37
Ready for the boss level of this world?
8.8.Β Level 8: x β€ y or y β€ x
This is I think the toughest level yet. Tips: if a is a number
then cases a with b will split into cases a = 0 and a = succ b.
And don't go left or right until your hypotheses guarantee that
you can prove the resulting goal!
I've left hidden hints; if you need them, retry from the beginning and click on "Show more help!"
If x and y are numbers, then either x \leq y or y \leq x.
theorem le_total (x y : β) : x β€ y β¨ y β€ x
Very well done.
A passing mathematician remarks that with you've just proved that β is totally
ordered.
The final few levels in this world are much easier.
8.9.Β Level 9: succ x β€ succ y β x β€ y
We've proved that x β€ 0 implies x = 0. The last two levels
in this world will prove which numbers are β€ 1 and β€ 2.
This lemma will be helpful for them.
If \operatorname{succ}(x) \leq \operatorname{succ}(y) then x \leq y.
theorem succ_le_succ (x y : β) (hx : succ x β€ succ y) : x β€ y
Here's my proof:
cases hx with d hd use d rw [succ_add] at hd apply succ_inj at hd exact hd
8.10.Β Level 10: x β€ 1
We've seen le_zero, the proof that if x β€ 0 then x = 0.
Now we'll prove that if x β€ 1 then x = 0 or x = 1.
If x \leq 1 then either x = 0 or x = 1.
theorem le_one (x : β) (hx : x β€ 1) : x = 0 β¨ x = 1
Here's my proof:
cases x with y left rfl rw [one_eq_succ_zero] at hx β’ apply succ_le_succ at hx apply le_zero at hx rw [hx] right rfl
If you solved this level then you should be fine with the next level!
8.11.Β Level 11: le_two
We'll need this lemma to prove that two is prime!
You'll need to know that β¨ is right associative. This means that
x = 0 β¨ x = 1 β¨ x = 2 actually means x = 0 β¨ (x = 1 β¨ x = 2).
This affects how left and right work.
If x \leq 2 then x = 0 or 1 or 2.
theorem le_two (x : β) (hx : x β€ 2) : x = 0 β¨ x = 1 β¨ x = 2
Nice!
The next step in the development of order theory is to develop
the theory of the interplay between β€ and multiplication.
If you've already done Multiplication World, you're now ready for
Advanced Multiplication World. Click on "Home" to access it.