Propositions and Proofs #
As we have mentioned, proofs and propositions are terms, with propositions as types. The universe Prop is the type of propositions. To start with, it is best to ignore the difference between Prop and Type and treat them as the same.
A logical statement like 1 ≤ 2 is a proposition and has type Prop.
The proposition 0 ≤ 2 is true and has proof Nat.zero_le 2.
A proposition may be neither proved nor disproved. So we cannot evaluate it. We can evaluate it if it is decidable.
We can combine propositions to make propositions:
- If
PandQare propositions, thenP ∧ Qis the proposition "P and Q". - If
PandQare propositions, thenP ∨ Qis the proposition "P or Q". - If
PandQare propositions, thenP → Qis the proposition "if P then Q". - If
Pis a proposition, then¬ Pis the proposition "not P", which isP → False.
The key idea is that function application is exactly analogous to the logical rule of inference called modus ponens.
Equations
- application a f = f a
Instances For
We apply modus-ponens with P being 0 ≤ 2 and P → Q being Nat.succ_le_succ applied to 0 and 2.
Some proofs at term level
Proof Irrelevance #
In Lean, any two proof terms of the same proposition are equal by definition. This is called proof irrelevance.
Universes #
- Universes in Lean are called
Sorts, they areSort 0,Sort 1, etc. PropisSort 0.TypeisSort 1.Type nisSort n.succ.- Strictly speaking, the
nhere is a universe level, not a natural number.
Dependent Function Types #
The type of Nat.zero_le is ∀ (n : Nat), 0 ≤ n. We will write it more like a function type
We saw that if α and β are types (or props), then α → β is the type of functions from α to β.
If instead we have β : α → Typeor β : α → Prop, then (a : α) → β a (more formally Π (a : α), β a) is the type of dependent functions from a : α to β a.