Welcome to the course #
We start with a quick tour, where we:
- Use Lean as a calculator
- Define some functions and call them.
- Look at some types.
- Look at some proofs.
We will then see
- A glimpse of AI.
- A detailed example with programs and proofs.
Lean as a calculator. #
We begin by using Lean as a calculator. We can use
#eval to evaluate expressions.
#eval 1 + 2 -- 3 #eval "Hello " ++ "world!" -- "Hello world!"
We next evaluate an expression involving a definition.
#eval some_number + 23 -- 65
Defining functions #
We next define some functions. These are defined in terms of previously defined functions.
#eval cube (add_two 3) -- 125
Terms in Lean, including functions, have types, which can be seen using
We next define a function of two arguments, and look at its type. We see that this is defined as a function from
ℕ to a function from
#check sum_of_squares -- ℕ → ℕ → ℕ #check sum_of_squares 3 -- ℕ → ℕ
We can also define this in a way that makes the type clearer.