Mini-course at Swiss-French workshops in algebraic geometry, 14th edition, Charmey (FR), January 13-17, 2025
-
Copy and paste the following:
import Mathlib
theorem Example1 (M : Type) [Monoid M] (a b c : M)
(h1 : a * b = 1) (h2 : c * a = 1) :
b = c := by
rw [← one_mul b]
rw [← h2]
rw [mul_assoc]
rw [h1]
rw [mul_one] -- hooray!
- Method 1: use https://live.lean-lang.org/ (as above)
- Method 2: follow the instructions at https://lean-lang.org/lean4/doc/quickstart.html.
If you use Method 2, then when you reach the step "Set up Lean 4 Project", I recommend you choose the option "Download an existing project" and use the URL for this Github page, https://github.com/loefflerd/Charmey. Then you will get a pre-prepared project with the examples from the lectures and a recent version of "Mathlib" already installed.
- Mathematics in Lean (Avigad-Massot): https://leanprover-community.github.io/mathematics_in_lean/
- Mechanics of Proof (Macbeth): https://hrmacbeth.github.io/math2001/
- Natural Numbers Game (Buzzard): https://adam.math.hhu.de
See the example file https://github.com/loefflerd/Charmey/blob/main/Charmey/Ideals.lean in this GitHub project.
rw
(rewrite): replace sub-expressions of the goal. Ifh
is a proof thatX = Y
, thenrw [h]
replaces allX
's in the goal withY
's, andrw [<- h]
replaces allY
's withX
's. Alsorw [...] at hyp
to rewrite in a hypothesis (not the goal).rw?
: search for rewrites that work.apply
: use a theorem from the library -- ifP
is a theorem stating that the goal is true, thenapply P
closes the main goal and opens new goals for the hypotheses ofP
(if any).apply?
searches for theorems that imply the goal.
use
: if the goal is that∃ x
satisfying some condition, thenuse q
will change the goal to proving thatx = q
works.obtain
: if you have a hypothesish
that∃ x
satisfying some condition, thenobtain ⟨x, hx⟩ := h
gets a specificx
and a proofhx
thatx
satisfies the condition.
have
: "I claim that..." -- introduce a claim, prove the claim, and then show that the claim implies the main goal.suffices
: "It suffices to prove that..." -- introduce a claim, prove that it implies the goal, and then prove the claim.
assumption
: the goal is already there in the contexttauto
: the goal follows from the assumptions by trivial logic (understandsand
,or
,not
andimplies
)
induction
: ifn
is a natural number variable, theninduction n with ...
sets up a proof by induction onn
.
See https://github.com/madvorak/lean4-tactics/blob/main/README.md for a slightly longer list.
See slides: https://github.com/loefflerd/Charmey/blob/main/TypeTheory.pdf