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. Ifhis a proof thatX = Y, thenrw [h]replaces allX's in the goal withY's, andrw [<- h]replaces allY's withX's. Alsorw [...] at hypto rewrite in a hypothesis (not the goal).rw?: search for rewrites that work.apply: use a theorem from the library -- ifPis a theorem stating that the goal is true, thenapply Pcloses 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∃ xsatisfying some condition, thenuse qwill change the goal to proving thatx = qworks.obtain: if you have a hypothesishthat∃ xsatisfying some condition, thenobtain ⟨x, hx⟩ := hgets a specificxand a proofhxthatxsatisfies 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,notandimplies)
induction: ifnis 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