What does it mean to prove the conjunction
By definition, a proof of
In other words, this is an inductive definition, similar to what we saw for product types in Lecture 1. The proposition And P Q has only one constructor, called And.intro.
inductive And (P Q : Prop) : Prop
| intro : P → Q → And P Q
So, formally, defining a proposition is no different from defining a type.
We are starting to see that propositions behave like types, with functions between those types representings implications:
true or false) attached to a proposition.Here,
inductive False : Prop
The recursion principle attached to
Let us now compare
def cons_imp_classical {P Q : Prop} : (P → Q) → ¬(P ∧ ¬Q) :=
fun (f : P → Q) ↦
fun (And.intro (p : P) (g : Q → False)) ↦ g (f p)
The reverse implication does not hold constructively. To prove it for all
In Lean, you can choose to work constructively or classically. In Mathlib, most proofs use classical logic in one form or another (
Disjunctions are the propositional analogues of the sum types Or.inl and Or.inr).
inductive Or (P Q : Prop) : Prop
| inl : P → Or P Q
| inr : Q → Or P Q
To construct a proof of
This is classically but not constructively equivalent to
Similarly, the following implications hold constructively, but their converses do not.
The type of logical equivalences
inductive Iff (P Q : Prop) : Prop
| intro : (P → Q) → (Q → P) → Iff P Q
In Lean and other modern proof assistants, most (but not all) inductive types with only one constructor are passed as records, which are not technically part of Martin-Löf's type theory but are useful for the implementation (in Lean, records are declared using the keyword structure).
structure Iff (P Q : Prop) : Prop where
intro :: (mp : P → Q) (mpr : Q → P)
The basic tactics we shall need are the following:
exact and apply.intro and revert.constructor.rcases and cases.left and right.rfl.exact? and apply?.refine.All these tactics are presented in the accompanying file for this lecture.
In a type system such as Lean's, the natural deduction rule known as modus ponens is derived, not postulated. Namely, it is a consequence of the fact that functions can be evaluated.
theorem mp {P Q : Prop} : (P → Q) ∧ P → Q :=
fun t ↦ match t with | ⟨f, p⟩ => f p
Or, using the intro, rcases and exact tactics (curly brackets are optional).
theorem mp {P Q : Prop} : (P → Q) ∧ P → Q :=
by -- ⊢ (P → Q) ∧ P → Q
intro t -- (t : (P → Q) ∧ P) ⊢ Q
rcases t with ⟨f, p⟩ -- (f : P → Q) (p : P) ⊢ Q
exact f p -- No goals
A tautology is a proposition which is built up from older ones and which has a proof regardless of whether the old ones do. Proving such propositions help familiarise oneself with the basic tactics. Can you state and prove the following ones?
Let us now see the basic tactics in action (same file as at the start of the lecture).
I also include one more practice file, whose exercises are meant to illustrate the difference between constructive and classical logic.
Both are designed to help you get acquainted with Lean's basic tactics.
Thank you for your attention!