Built with doc-gen4, running Lean4.
Bubbles () indicate interactive fragments: hover for details, tap to reveal contents.
Use Ctrl+↑Ctrl+↓to navigate, Ctrl+🖱️to focus.
On Mac, use Cmdinstead of Ctrl.
import Mathlib
/-!
# 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.
```lean
#eval 1 + 2 -- 3
#eval "Hello " ++ "world!" -- "Hello world!"
```
-/
23
/-!
## Defining functions
We next define some functions. These are defined in terms of previously defined functions.
-/
/-- Add `2` to a natural number -/
def
n
/-!
## Types
Terms in Lean, including functions, have types, which can be seen using `#check`
```lean
#check 1 + 2 -- ℕ
#check "Hello " ++ "world!" -- String
#check add_two -- ℕ → ℕ
#check cube -- ℕ → ℕ
#check ℕ -- Type
#check Type -- Type 1
#check ℕ → ℕ -- Type
```
-/
ℕ
/-!
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 `ℕ` to `ℕ`.
-/
/-- Sum of squares of natural numbers `x` and `y` -/
def