Stefano M. Nicoletti

Lecture 2: Propositions, Proofs, and Logical Rules

1. Aim of the Lecture

This lecture recalls the role of the kernel and the typechecker, then introduces the way Lean reads propositions and proofs. The central point is the correspondence between propositions and types: a proposition P : Prop is a type, and a proof of P is a term inhabiting that type Theorem Proving in Lean 4, Propositions and Proofs.

We will work through minimal examples in order to observe, in the proof state, the introduction and elimination rules for the logical connectives and for a few specific constructs:

2. Kernel and Typechecker

We have seen that Lean lets us build proofs with tactics, library support, and interactive interfaces. These tools help the user, but in the end the kernel checks the formal object that has been produced and verifies that it has the required type de Moura and Ullrich, Lean 4.

The typechecker checks whether a term has a certain type. In proofs, the expected type is the proposition that we want to prove. A theorem is accepted when Lean can check the proof term against the statement. From the system's point of view, proving means constructing a well-typed term.

This explains why the proof state is useful. The goal shows the type that we must inhabit. The assumptions show the terms already available in the context. A tactic is an interactive way to transform this situation until all goals are closed.

3. Propositions as Types

In Lean, P : Prop says that P is a proposition. If the context contains hP : P, then hP is a proof of P. It is not just an informal label: it is a formal object that can be used to build other proofs.

Implication is the most direct example. A term of type P → Q behaves like a function: it takes a proof of P and returns a proof of Q. If we have

hPQ : P → Q
hP : P

then hPQ hP is a proof of Q.

4. Introduction and Elimination Rules

For each logical connective we distinguish two questions.

Looking at the goal means asking which introduction rule can construct it. Looking at the assumptions means asking which elimination rule can use them. This terminology follows the standard presentation of natural deduction rules Logic and Proof, Natural Deduction Rules.

5. Implication

To introduce P → Q, we temporarily assume P and construct Q.

-- Read connectives through their introduction and elimination rules. -- Implication introduction. -- To prove `P -> Q`, we temporarily assume `P` and construct `Q`. -- Rule: if, assuming P, we can prove Q, then we have P -> Q. theorem lecture02_imp_intro (P Q : Prop) (hQ : Q) : P Q := P:PropQ:ProphQ:QP Q P:PropQ:ProphQ:QhP:PQ -- hP : P is the temporary assumption introduced by the rule. All goals completed! 🐙

The line intro hP introduces the temporary assumption hP : P. In this example the conclusion Q is already available as hQ, so we close the goal with exact hQ.

To eliminate P → Q, we apply the implication to a proof of P.

-- Implication elimination. -- Rule: from P -> Q and P we obtain Q. This is modus ponens. theorem lecture02_imp_elim (P Q : Prop) : (P Q) P Q := P:PropQ:Prop(P Q) P Q P:PropQ:ProphPQ:P QP Q P:PropQ:ProphPQ:P QhP:PQ P:PropQ:ProphPQ:P QhP:PhQ:QQ All goals completed! 🐙

Here hPQ hP is function application: from P → Q and P we obtain Q. This is modus ponens again.

6. Conjunction

A conjunction P ∧ Q contains both pieces of information. To introduce it, we must provide a proof of both components. In the next example they are given as assumptions in the statement.

theorem lecture02_and_intro (P Q : Prop) (hP : P) (hQ : Q) : P Q := P:PropQ:ProphP:PhQ:QP Q -- Introduction rule: from P and Q we obtain P /\ Q. P:PropQ:ProphP:PhQ:QhPAndQ:P QP Q All goals completed! 🐙

The same rule And.intro can be used as a tactic. The goal P ∧ Q splits into two subgoals, one for P and one for Q.

theorem lecture02_and_intro_with_apply (P Q : Prop) (hP : P) (hQ : Q) : P Q := P:PropQ:ProphP:PhQ:QP Q -- Same rule, using the constructor explicitly as a tactic. Notice the creation of multiple subgoals. P:PropQ:ProphP:PhQ:QPP:PropQ:ProphP:PhQ:QQ P:PropQ:ProphP:PhQ:QP All goals completed! 🐙 P:PropQ:ProphP:PhQ:QQ All goals completed! 🐙

To eliminate a conjunction, we use its components and take the left or right conjunct.

theorem lecture02_and_elim_left (P Q : Prop) : P Q P := P:PropQ:PropP Q P P:PropQ:ProphPAndQ:P QP -- Left elimination rule: from P /\ Q we obtain P. All goals completed! 🐙
theorem lecture02_and_elim_right (P Q : Prop) : P Q Q := P:PropQ:PropP Q Q P:PropQ:ProphPAndQ:P QQ -- Right elimination rule: from P /\ Q we obtain Q. All goals completed! 🐙

7. Disjunction

A disjunction P ∨ Q contains one of the two pieces of information. To introduce it, it is enough to provide one side, using Or.inl or Or.inr.

theorem lecture02_or_intro_left (P Q : Prop) : P P Q := P:PropQ:PropP P Q P:PropQ:ProphP:PP Q -- Left introduction rule: from P we obtain P \/ Q. All goals completed! 🐙
theorem lecture02_or_intro_right (P Q : Prop) : Q P Q := P:PropQ:PropQ P Q P:PropQ:ProphQ:QP Q -- Right introduction rule: from Q we obtain P \/ Q. All goals completed! 🐙

To eliminate a disjunction, we reason by cases. If we have P ∨ Q, we do not generally know which side is available. To obtain a conclusion, we must produce it in both branches. In this example, we want to conclude Q ∨ P from P ∨ Q, so we consider the case where P is true and the case where Q is true.

theorem lecture02_or_elim (P Q : Prop) : P Q Q P := P:PropQ:PropP Q Q P P:PropQ:ProphPOrQ:P QQ P -- Elimination rule: from P \/ Q we must treat the P case and the Q case. -- In both cases we must prove the same goal, here Q \/ P. cases hPOrQ with P:PropQ:ProphP:PQ P -- Case 1: we have a proof of P. All goals completed! 🐙 P:PropQ:ProphQ:QQ P -- Case 2: we have a proof of Q. All goals completed! 🐙

The same structure can be written with Or.elim.

theorem lecture02_or_elim_with_or_elim (P Q : Prop) : P Q Q P := P:PropQ:PropP Q Q P P:PropQ:ProphPOrQ:P QQ P -- `Or.elim` is the same rule: one proof for the P case and one for the Q case. P:PropQ:ProphPOrQ:P QP Q PP:PropQ:ProphPOrQ:P QQ Q P P:PropQ:ProphPOrQ:P QP Q P P:PropQ:ProphPOrQ:P QhP:PQ P All goals completed! 🐙 P:PropQ:ProphPOrQ:P QQ Q P P:PropQ:ProphPOrQ:P QhQ:QQ P All goals completed! 🐙

8. False and Negation

False represents a contradictory state. If we have a proof of False, we can close any goal.

theorem lecture02_false_elim (P : Prop) : False P := P:PropFalse P P:ProphFalse:FalseP -- Same rule, using `exact`. All goals completed! 🐙

In Lean, negation is defined as implication to False: ¬P means P → False. To eliminate a negation, we apply it to a positive proof of P.

theorem lecture02_not_elim (P : Prop) : P ¬P False := P:PropP ¬P False P:ProphP:P¬P False P:ProphP:PhNonP:¬PFalse All goals completed! 🐙

To introduce ¬P, we temporarily assume P and derive False. The next example is the reasoning pattern of modus tollens. The line intro hP has this role: to prove ¬P, assume P and derive False. Observe how the goal changes.

theorem lecture02_not_intro (P Q : Prop) : (P Q) ¬Q ¬P := P:PropQ:Prop(P Q) ¬Q ¬P P:PropQ:ProphPQ:P Q¬Q ¬P P:PropQ:ProphPQ:P QhNonQ:¬Q¬P P:PropQ:ProphPQ:P QhNonQ:¬QhP:PFalse P:PropQ:ProphPQ:P QhNonQ:¬QhP:PhQ:QFalse All goals completed! 🐙

9. Tactics, Commands, and Shortcuts

In this lecture we mostly used tactics corresponding to the introduction and elimination rules for the connectives.

We also used some explicit constructors and eliminators:

10. Exercises and Solutions

The exercise and solution files (Exercises.lean and Solutions.lean) are available on the course website.

11. Sources and Further Reading