Stage 03 · Step 12 of 50
Prove both halves.
01The idea
A two-item checklist needs two ticks. To prove an “and” statement, prove both parts.
Lean makes one goal for each part.
02In maths
Given P and Q separately, conclude P ∧ Q.
Picture it
Swipe sideways to see the whole picture.
P and a proof of Q. constructor splits the goal P ∧ Q into two goals, one per keyhole. Each gets its own key, exact hP and exact hQ, and the proof is finished only when both goals are closed.03In Lean
This code comes directly from the file checked by Lean.
example (P Q : Prop) (hP : P) (hQ : Q) : P ∧ Q := by
constructor
· exact hP
· exact hQ
The symbol ∧ means “and.” Type it with \and. Its technical name is conjunction.
The tactic constructor uses a way of building a value of the goal’s type. For a conjunction, it asks for both component proofs.
Each bullet · focuses one goal. Type that bullet with \cdot.
04Step by step
Choose a line to see Lean’s recorded goal state after that line.
P Q : Prop hP : P hQ : Q ⊢ P ∧ Q
After line 1: example (P Q : Prop) (hP : P) (hQ : Q) : P ∧ Q := by
P Q : Prop hP : P hQ : Q ⊢ P ∧ Q
After line 2: constructor
case left P Q : Prop hP : P hQ : Q ⊢ P case right P Q : Prop hP : P hQ : Q ⊢ Q
After line 3: · exact hP
no goals
After line 4: · exact hQ
no goals
05Lean says
no goals
A goal is what remains to prove. The symbol ⊢ points to it. Meet the turnstile.
06A common slip
Lean is telling us something useful here.
example : True ∧ True := by
constructor
· exact True.intro
unsolved goals case right ⊢ True
The second component goal is still open.
The fix: Finish both goals produced by the conjunction constructor.
07Your turn
sorry is a placeholder for unfinished work. Replace it as you solve each task. A finished proof has no placeholders.
- Warm-up
Build a proof of P and P from a single proof of P.
Show a hint
Use constructor to split the target.
One more hint
The same hypothesis can prove both goals.
- A little stretch
Build P and (Q and R) from the three supplied proofs.
Show a hint
The right side is another conjunction.
One more hint
The anonymous pair constructor can package all three proofs.
example (P : Prop) (h : P) : P ∧ P := by
sorry
example (P Q R : Prop) (hP : P) (hQ : Q) (hR : R) : P ∧ (Q ∧ R) := by
sorry
Compare with the checked solutions
There are often several valid proofs. These solutions were compiled with the same pinned Lean version.
example (P : Prop) (h : P) : P ∧ P := by
constructor
· exact h
· exact h
example (P Q R : Prop) (hP : P) (hQ : Q) (hR : R) : P ∧ (Q ∧ R) := by
exact ⟨hP, hQ, hR⟩
no goals
08A quick check
09New words & tools
Take your time. Progress is yours to mark.