import MyNat.Definition
namespace MyNat
open MyNat
Function World
Level 4: the apply
tactic.
Let's do the same level again a different way:
We are given p ∈ P
and our goal is to find an element 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 construct an element of the set U
. But l:T → U
is
a function, so it would suffice to construct an element of 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 functions 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 an element of P
).
Definition
Given an element of P
we can define an element of U
.
example (example: (P Q R S T U : Type) → P → (P → Q) → (Q → R) → (Q → T) → (S → T) → (T → U) → UPP: TypeQQ: TypeRR: TypeSS: TypeTT: TypeU:U: TypeType) (Type: Type 1p :p: PP) (P: Typeh :h: P → QP →P: TypeQ) (Q: Type:Q →Q: TypeR) (R: Typej :j: Q → TQ →Q: TypeT) (T: Type:S →S: TypeT) (T: Typel :l: T → UT →T: TypeU) :U: TypeU :=U: TypeP, Q, R, S, T, U: Type
p: P
h: P → Q
i: Q → R
j: Q → T
k: S → T
l: T → UUP, Q, R, S, T, U: Type
p: P
h: P → Q
i: Q → R
j: Q → T
k: S → T
l: T → UTP, Q, R, S, T, U: Type
p: P
h: P → Q
i: Q → R
j: Q → T
k: S → T
l: T → UQP, Q, R, S, T, U: Type
p: P
h: P → Q
i: Q → R
j: Q → T
k: S → T
l: T → UPGoals accomplished! 🐙
Next up Level 5