Learning Lean
Prinz Software · Elkhart, Indiana, United States · 1 mo ago
Human ResourcesFull-time
About the role
This guide is for programmers who want to learn Lean, a proof assistant and programming language, starting from basic building blocks. The approach focuses on quickly moving toward distinctive Lean concepts using minimal assumptions.
Key Concepts
- Commands over expressions: Lean uses commands like #eval and #check instead of a REPL. For example: #eval 2 + 2 -- Output: 4 #check Nat -- Output: Nat : Type
- Inductive types: Define new types using constructors with the inductive keyword. inductive Direction where | north : Direction | south : Direction | east : Direction | west : Direction Constructors can carry data: inductive Shape where | circle (radius : Nat) : Shape | rectangle (width height : Nat) : Shape
- Functions:
- Use → for function types and => for function definitions.
- Anonymous functions use fun; named functions use def. def add2 (x : Nat) := x + 2
- Dependent function types: The output type can depend on the input value. def pick (t : Type) (x : t) : t := x This is equivalent to (t : Type) → t → t or ∀ t, t → t.
- Pi types: The arrow → and universal quantifier ∀ are the same primitive in Lean. Use:
- → when the result doesn’t depend on the argument.
- ∀ or (a : t) → β when the result depends on the argument.