-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Lean 4 survival guide for Lean 3 users
Floris van Doorn edited this page May 25, 2023
·
50 revisions
- Lean 4 cheatsheet: https://github.com/madvorak/lean4-cheatsheet/blob/main/lean-tactics.pdf
- Differences with Lean 3 from the official Lean 4 manual: https://leanprover.github.io/lean4/doc/lean3changes.html
- Function notation changed from
λ x, f xtofun x => f xorλ x => f x. If you import (almost) any file from mathlib, you can also usefun x ↦ f xorλ x ↦ f x. - For infix notation like
+you cannot use(+)or(+ n)anymore, instead use(· + ·)or(· + n). The·(entered with\.) is an anonymous lambda expression. The lambda expression will be inserted at the nearest enclosing parentheses (see linked manual page).
- Enter tactic mode by using
byand then a newline, and indenting the tactics. Example:
example : True := by
trivial- Don't place comma's after tactics, you can go to the next tactic if you write it on a new line (in the same column)
- If you have multiple goals, you can focus on the first goal using
\.
example : (True → p) → q → p ∧ q := by
intros hp hq
constructor
· apply hp
trivial
· exact hq- If you want multiple tactics on the same line, you can use
tac1; tac2(which corresponds totac1, tac2in Lean 3) ortac1 <;> tac2(which corresponds totac1; tac2in Lean 3)
- The analogue of
refineisrefine'. - The square brackets in
rw [h]are mandatory -
splithas been removed. Useconstructor. - To work on the first goal use
· exact fooinstead of{exact foo}. Note that·is\., not\cdot.
- Named implicit arguments, like
f (x := 3)