Stage 03 · Step 14 of 50

Choose a side.

Core Lean8 minutesLean 4.36.0

01The idea

A pass may accept a student card or a library card. One valid option is enough.

Tacto · Your guide for this idea
Tacto pointing

To prove an “or” statement, choose the side you can prove.

02In maths

A proof of P gives a proof of P ∨ Q. A proof of Q also gives a proof of P ∨ Q.

Picture it

Proving an “or”: two doors, and you only need oneTwo rows, one for each example. Each goal P or Q is drawn as a wall with two doors, P and Q. Top row: you have hP : P. The tactic left picks the P door, the goal becomes P, and exact hP finishes, leaving no goals. Bottom row: you have hQ : Q. The tactic right picks the Q door, the goal becomes Q, and exact hQ finishes. In each row the other door stays shut, and that is fine.STARTP Q : ProphP : P⊢ P ∨ QleftPQPICKED PP Q : ProphP : P⊢ Pexact hPDONEno goalsSTARTP Q : ProphQ : Q⊢ P ∨ QrightPQPICKED QP Q : ProphQ : Q⊢ Qexact hQDONEno goals

Swipe sideways to see the whole picture.

An “or” is a wall with two doors, and getting through one door is enough. left says “I’ll prove P” and right says “I’ll prove Q”. Pick the door your key fits: with hP go left, with hQ go right. The other door can stay shut.

03In Lean

This code comes directly from the file checked by Lean.

E14.leanTry it live (opens official Lean editor)
example (P Q : Prop) (hP : P) : P ∨ Q := by
  left
  exact hP

example (P Q : Prop) (hQ : Q) : P ∨ Q := by
  right
  exact hQ

The symbol ∨ means “or.” Type it with \or. The technical name is disjunction.

The tactics left and right choose a constructor of a disjunction. The chosen proposition becomes the new goal.

This is inclusive or. It does not say that exactly one side holds.

04Step by step

Choose a line to see Lean’s recorded goal state after that line.

After line 1
P Q : Prop
hP : P
⊢ P ∨ Q
After line 1: example (P Q : Prop) (hP : P) : P ∨ Q := by
P Q : Prop
hP : P
⊢ P ∨ Q
After line 2: left
P Q : Prop
hP : P
⊢ P
After line 3: exact hP
no goals
After line 5: example (P Q : Prop) (hQ : Q) : P ∨ Q := by
P Q : Prop
hQ : Q
⊢ P ∨ Q
After line 6: right
P Q : Prop
hQ : Q
⊢ Q
After line 7: exact hQ
no goals

05Lean says

Captured from Lean 4.36.0
no goals

A goal is what remains to prove. The symbol ⊢ points to it. Meet the turnstile.

07Your turn

sorry is a placeholder for unfinished work. Replace it as you solve each task. A finished proof has no placeholders.

  1. Warm-up

    Prove P or Q using the supplied proof of Q.

  2. A little stretch

    Prove P or (Q or R) using R.

Exercises/E14.leanTry it live (opens official Lean editor)
example (P Q : Prop) (hQ : Q) : P ∨ Q := by
  sorry

example (P Q R : Prop) (h : R) : P ∨ (Q ∨ R) := by
  sorry

08A quick check

1. What does ∨ mean?

Read the answer and explanation

Or. At least one side must hold. Type it with \or.

2. Can both sides of an or statement be true?

Read the answer and explanation

Yes. This is inclusive or. Proving either side is enough, and both may hold.

One more idea in your toolkit.

Take your time. Progress is yours to mark.