import MyNat.Definition
namespace MyNat
open MyNat
Proposition world.
Level 4: apply
.
Let's do the same level again a different way:
We are given a proof p
of P
and our goal is to find a proof of U
, or
in other words to find a path through the maze that links P
to U
.
In level 3 we solved this by using have
s to move forward, from P
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
.
Our goal is to prove U
. But l:T ⟹ U
is
an implication which we are assuming, so it would suffice to prove T
.
Tell Lean this by starting the proof below with
apply l,
and notice that our assumptions don't change but the goal changes
from ⊢ U
to ⊢ T
.
Keep apply
ing implications until your goal is P
, and try not
to get lost! Now solve this goal
with exact p
. Note: you will need to learn the difference between
exact p
(which works) and exact P
(which doesn't, because P
is
not a proof of P
).
Lemma : maze₂
We can solve a maze.
lemmamaze₂ (maze₂: ∀ (P Q R S T U : Prop), P → (P → Q) → (Q → R) → (Q → T) → (S → T) → (T → U) → UPP: PropQQ: PropRR: PropSS: PropTT: PropU:U: PropProp) (Prop: Typep :p: PP) (P: Proph :h: P → QP →P: PropQ) (Q: Prop:Q →Q: PropR) (R: Propj :j: Q → TQ →Q: PropT) (T: Prop:S →S: PropT) (T: Propl :l: T → UT →T: PropU) :U: PropU :=U: PropP, Q, R, S, T, U: Prop
p: P
h: P → Q
i: Q → R
j: Q → T
k: S → T
l: T → UUP, Q, R, S, T, U: Prop
p: P
h: P → Q
i: Q → R
j: Q → T
k: S → T
l: T → UTP, Q, R, S, T, U: Prop
p: P
h: P → Q
i: Q → R
j: Q → T
k: S → T
l: T → UQP, Q, R, S, T, U: Prop
p: P
h: P → Q
i: Q → R
j: Q → T
k: S → T
l: T → UPGoals accomplished! 🐙
Next up Level 5