3.2 KiB
Lean syntax
rw
takes a list of rewrite rules and applies them—left to right—so if you have a rule of the formh : a = b
thenrw [h]
will replace alla
s in the goal withb
.rw [h] at h2
will do the same thing but in the assumptionh2
insteadrw \l [h]
will reverse the direction of rewrite rule, taking a theorem of the formh : a = b
and use it to rewrite allb
s intoa
-
repeat rw [...]
will apply the rewrite rules between the square brackets 0 or more times, as many times as it can- this is really useful when you need to do something like
repeat rw [add_succ]
in order to move a successor from deep inside a series of additions and pull it out to the front of the whole expression
- this is really useful when you need to do something like
-
apply
takes a theorem of the formh: A -> B
, in other words a function that transforms evidence thatA
is true and turns it into evidenceB
is true, and lets you either transform a goalB
into a goalA
(backwards reasoning) or lets you transform an assumptionA
into an assumptionB
- unlike
rw
,apply
always just takes one argument so it doesn't have the square brackets apply
can also just take a theorem of the formA
and apply it to a goalA
- unlike
-
intro h
lets you take a goal of the formA -> B
and turn it into a goal ofB
with the assumptionh : A
. This is, basically, function definition and you're declaring an argument namedh
with typeA
and you get to use thath
in the "body" of your "function" when making your proof-
You can actually do multiple
intro
on one line likeintro h1 h2 h3
in order to take a goal ofA -> B -> C -> D
and turn it into a goal ofD
with the assumptionsh1 : A
,h2 : B
,h3 : C
, &c.- Pop-quiz! If I have a goal of type
(A -> B) -> C
what is the type ofh
if I dointro h
?
- Pop-quiz! If I have a goal of type
-
use
lets you prove an existential goal by providing an example of a thing that fits the condition-
cases'
lets you take apart an existential assumption and get back a thing that satisfies the proposition. You don't get to know what it is specifically, just that it is a thingcases'
is also useful when you need to take a hypothesis offalse
and end the proof. Why does this work? Well, remember how in classical logicF -> q
evaluates to true no matter whatq
is?
obtain \<x,hX\> := blah
lets you take ablah
that's an existential type and turn it into anx
that satisfies the predicate and a proofhX
thatx
satisfies the predicateleft
let's you choose the left side of anor
, i.e. it turns a goal ofA \/ B
and turns it into a goal ofA
right
let's you choose the right side of anor
, i.e. it turns a goal ofA \/ B
and turns it into a goal ofB
On the true nature of things
x \in A \cup B
is an or-statement that can be broken up into two subgoals bycases'
x \in A \cap B
is an and-statement that can be broken into two hypotheses bycases'
Strategies
- If a proof isn't immediately obvious, try sketching it out with pen and paper instead
-
When proving an existential goal, think hard about what you need before you
use
something- Again, try writing it out
- Always take apart your existentials and ors in the hypotheses before make a
left
,right
, oruse
choice in your goals