Lecture 5: Quantifier Rules
1. Aim of the lecture
We review the formalizations from Lecture 4 and introduce the natural-deduction rules for ∀ and ∃. We first complete examples with functions and nested quantifiers. We then study how to construct and use universal and existential proofs, including the side conditions that make the four rules valid. Finally, we combine quantifiers with the propositional connectives.
Four recurring forms provide a useful review:
variable (Thing : Type)
variable (Student Reads Understands : Thing → Prop)
#check ∀ x : Thing, Student x → Reads x
#check ∃ x : Thing, Student x ∧ Reads x
#check ∀ x : Thing, Student x → Reads x → Understands x
#check ∃ x : Thing, Student x ∧ Reads x ∧ Understands x
2. Functions inside formulas
Terms built with functions can occur inside predicates, relations, and quantified statements.
variable (Thing : Type)
variable (hypatia : Thing)
variable (Student Reads Curious : Thing → Prop)
variable (motherOf : Thing → Thing)
variable (Knows : Thing → Thing → Prop)
#check Curious (motherOf hypatia)
#check ∀ x : Thing, Student x → Knows x (motherOf x)
#check ∃ x : Thing, Student x ∧ Reads (motherOf x)
The parentheses show that we first build motherOf x and then use that term as the argument of a predicate or relation.
3. Nested quantifiers
Quantifier order determines which choices may depend on others.
variable (Thing : Type)
variable (Person : Thing → Prop)
variable (Knows : Thing → Thing → Prop)
-- Every person knows someone.
#check ∀ x : Thing, Person x →
∃ y : Thing, Person y ∧ Knows x y
-- Someone knows every person.
#check ∃ x : Thing, Person x ∧
∀ y : Thing, Person y → Knows x y
-- Nobody knows every person.
#check ¬∃ x : Thing, Person x ∧
∀ y : Thing, Person y → Knows x y
In the first statement, the witness y may change when x changes. The second statement requires one fixed x who knows every relevant y.
4. Universal introduction, ∀I
To prove ∀ y : Thing, A y, introduce an arbitrary x. The goal becomes A x. Prove it without using any special property of x; the conclusion then holds for every object in the domain.
-- Universal introduction, ∀I.
-- The universal goal is opened by introducing a new arbitrary thing `x`.
-- Only the first `intro` applies ∀I; the next two introduce implications.
theorem
(Thing : Type)
(Person Curious : Thing → Prop) :
∀ y : Thing, Person y → Curious y → Curious y := Thing:TypePerson:Thing → PropCurious:Thing → Prop⊢ ∀ (y : Thing), Person y → Curious y → Curious y
Thing:TypePerson:Thing → PropCurious:Thing → Propx:Thing⊢ Person x → Curious x → Curious x
Thing:TypePerson:Thing → PropCurious:Thing → Propx:ThinghXPerson:Person x⊢ Curious x → Curious x
Thing:TypePerson:Thing → PropCurious:Thing → Propx:ThinghXPerson:Person xhXCurious:Curious x⊢ Curious x
All goals completed! 🐙Only the first intro applies ∀I. The following two introduce the assumptions of the implications.
The arbitrariness condition
The object introduced by ∀I cannot be a particular object selected because of a special property. From hHypatiaCurious : Curious hypatia, for example, we cannot conclude ∀ y : Thing, Curious y. After intro x, the goal would be Curious x, whereas the assumption proves only Curious hypatia.
Formally, the variable used in the derivation must not occur free in any open assumption. In Curious x, x is free. In ∀ y : Thing, Curious y, y is bound. Lean enforces this condition through scope: intro x creates a fresh local variable inside the universal goal.
If a source proof deliberately reuses an existing name, Lean may display the older variable as x✝:
x✝ : Thing
hXCurious : Curious x✝
x : Thing
|- Curious x
The dagger only marks automatic renaming. Curious x✝ and Curious x remain different types.
5. Universal elimination, ∀E
Given ∀ x : Thing, A x, choose a term t and apply the universal proof to it. This yields A t.
-- A fact about Hypatia does not establish the same fact for every thing.
-- After `intro x`, `hHypatiaCurious : Curious hypatia` cannot close the goal
-- `Curious x`. If a source proof reuses the name `x`, Lean displays the older
-- local variable as `x✝`; the two local objects remain distinct.
-- Universal elimination, ∀E.
-- Every student reads; Marta is a student; therefore Marta reads.
theorem
(Thing : Type)
(Student Reads : Thing → Prop)
(marta : Thing)
(hEveryStudentReads : ∀ x : Thing, Student x → Reads x)
(hMartaStudent : Student marta) :
Reads marta := Thing:TypeStudent:Thing → PropReads:Thing → Propmarta:ThinghEveryStudentReads:∀ (x : Thing), Student x → Reads xhMartaStudent:Student marta⊢ Reads marta
Thing:TypeStudent:Thing → PropReads:Thing → Propmarta:ThinghEveryStudentReads:∀ (x : Thing), Student x → Reads xhMartaStudent:Student martahIfMartaStudentThenReads:Student marta → Reads marta⊢ Reads marta
Thing:TypeStudent:Thing → PropReads:Thing → Propmarta:ThinghEveryStudentReads:∀ (x : Thing), Student x → Reads xhMartaStudent:Student martahIfMartaStudentThenReads:Student marta → Reads martahMartaReads:Reads marta⊢ Reads marta
All goals completed! 🐙Applying the universal assumption to marta produces Student marta → Reads marta, which can then be applied to hMartaStudent.
The chosen term need not be a simple name. It can be built by a function. If motherOf : Thing → Thing and hEverythingCurious : ∀ x : Thing, Curious x, then hEverythingCurious (motherOf hypatia) proves Curious (motherOf hypatia). Lean checks the term's type and handles bound variables without accidental capture.
6. Existential introduction, ∃I
To prove ∃ x : Thing, A x, choose a witness t and prove A t. Lean's constructor is Exists.intro.
-- Existential introduction, ∃I.
-- Choose Marta as the witness and use the assumption that she reads.
theorem
(Thing : Type)
(Reads : Thing → Prop)
(marta : Thing)
(hMartaReads : Reads marta) :
∃ x : Thing, Reads x := Thing:TypeReads:Thing → Propmarta:ThinghMartaReads:Reads marta⊢ ∃ x, Reads x
Thing:TypeReads:Thing → Propmarta:ThinghMartaReads:Reads marta⊢ Reads marta
All goals completed! 🐙Choosing marta turns the existential goal into Reads marta, which is already available as an assumption.
The witness can also be a compound term. To prove ∃ x : Thing, Curious x, we may choose motherOf hypatia when we have a proof of Curious (motherOf hypatia).
7. Existential elimination, ∃E
Given ∃ x : Thing, A x, we know that a witness exists but may not assume its identity. To derive B, introduce an arbitrary witness y together with A y, and derive a conclusion that does not depend on the identity of y.
-- Existential elimination, ∃E.
-- Someone filed a report; whenever someone files a report, an investigation
-- starts; therefore an investigation starts.
theorem
(Thing : Type)
(FiledReport : Thing → Prop)
(InvestigationStarts : Prop)
(hSomeoneFiledReport : ∃ x : Thing, FiledReport x)
(hReportStartsInvestigation :
(x : Thing) → FiledReport x → InvestigationStarts) :
InvestigationStarts := Thing:TypeFiledReport:Thing → PropInvestigationStarts:ProphSomeoneFiledReport:∃ x, FiledReport xhReportStartsInvestigation:∀ (x : Thing), FiledReport x → InvestigationStarts⊢ InvestigationStarts
Thing:TypeFiledReport:Thing → PropInvestigationStarts:ProphSomeoneFiledReport:∃ x, FiledReport xhReportStartsInvestigation:∀ (x : Thing), FiledReport x → InvestigationStarts⊢ ∀ (a : Thing), FiledReport a → InvestigationStarts
Thing:TypeFiledReport:Thing → PropInvestigationStarts:ProphSomeoneFiledReport:∃ x, FiledReport xhReportStartsInvestigation:∀ (x : Thing), FiledReport x → InvestigationStartsy:Thing⊢ FiledReport y → InvestigationStarts
Thing:TypeFiledReport:Thing → PropInvestigationStarts:ProphSomeoneFiledReport:∃ x, FiledReport xhReportStartsInvestigation:∀ (x : Thing), FiledReport x → InvestigationStartsy:ThinghYFiledReport:FiledReport y⊢ InvestigationStarts
Thing:TypeFiledReport:Thing → PropInvestigationStarts:ProphSomeoneFiledReport:∃ x, FiledReport xhReportStartsInvestigation:∀ (x : Thing), FiledReport x → InvestigationStartsy:ThinghYFiledReport:FiledReport yhIfYFiledThenInvestigationStarts:FiledReport y → InvestigationStarts⊢ InvestigationStarts
Thing:TypeFiledReport:Thing → PropInvestigationStarts:ProphSomeoneFiledReport:∃ x, FiledReport xhReportStartsInvestigation:∀ (x : Thing), FiledReport x → InvestigationStartsy:ThinghYFiledReport:FiledReport yhIfYFiledThenInvestigationStarts:FiledReport y → InvestigationStartshInvestigationStarts:InvestigationStarts⊢ InvestigationStarts
All goals completed! 🐙The x in the second assumption is a bound placeholder. We instantiate it with the local witness y, obtaining FiledReport y → InvestigationStarts, and then apply that implication to hYFiledReport.
The conclusion is fixed before the existential is opened and contains no free occurrence of y. Lean enforces this independence through the scope of y and the type of Exists.elim: the witness cannot escape the local derivation unless it is packaged inside another existential statement.
8. Combining the rules
Quantifier rules can be combined in one proof.
-- A more complex example combining ∃E, ∀E, and ∃I.
-- Someone has an umbrella; everyone with an umbrella stays dry;
-- therefore someone stays dry.
theorem
(Thing : Type)
(HasUmbrella StaysDry : Thing → Prop)
(hSomeoneHasUmbrella : ∃ x : Thing, HasUmbrella x)
(hUmbrellaStaysDry : ∀ x : Thing, HasUmbrella x → StaysDry x) :
∃ x : Thing, StaysDry x := Thing:TypeHasUmbrella:Thing → PropStaysDry:Thing → ProphSomeoneHasUmbrella:∃ x, HasUmbrella xhUmbrellaStaysDry:∀ (x : Thing), HasUmbrella x → StaysDry x⊢ ∃ x, StaysDry x
Thing:TypeHasUmbrella:Thing → PropStaysDry:Thing → ProphSomeoneHasUmbrella:∃ x, HasUmbrella xhUmbrellaStaysDry:∀ (x : Thing), HasUmbrella x → StaysDry x⊢ ∀ (a : Thing), HasUmbrella a → ∃ x, StaysDry x
Thing:TypeHasUmbrella:Thing → PropStaysDry:Thing → ProphSomeoneHasUmbrella:∃ x, HasUmbrella xhUmbrellaStaysDry:∀ (x : Thing), HasUmbrella x → StaysDry xy:Thing⊢ HasUmbrella y → ∃ x, StaysDry x
Thing:TypeHasUmbrella:Thing → PropStaysDry:Thing → ProphSomeoneHasUmbrella:∃ x, HasUmbrella xhUmbrellaStaysDry:∀ (x : Thing), HasUmbrella x → StaysDry xy:ThinghYHasUmbrella:HasUmbrella y⊢ ∃ x, StaysDry x
Thing:TypeHasUmbrella:Thing → PropStaysDry:Thing → ProphSomeoneHasUmbrella:∃ x, HasUmbrella xhUmbrellaStaysDry:∀ (x : Thing), HasUmbrella x → StaysDry xy:ThinghYHasUmbrella:HasUmbrella y⊢ StaysDry y
Thing:TypeHasUmbrella:Thing → PropStaysDry:Thing → ProphSomeoneHasUmbrella:∃ x, HasUmbrella xhUmbrellaStaysDry:∀ (x : Thing), HasUmbrella x → StaysDry xy:ThinghYHasUmbrella:HasUmbrella yhIfYHasUmbrellaThenStaysDry:HasUmbrella y → StaysDry y⊢ StaysDry y
Thing:TypeHasUmbrella:Thing → PropStaysDry:Thing → ProphSomeoneHasUmbrella:∃ x, HasUmbrella xhUmbrellaStaysDry:∀ (x : Thing), HasUmbrella x → StaysDry xy:ThinghYHasUmbrella:HasUmbrella yhIfYHasUmbrellaThenStaysDry:HasUmbrella y → StaysDry yhYStaysDry:StaysDry y⊢ StaysDry y
All goals completed! 🐙Here Exists.elim opens the first existential, applying hUmbrellaStaysDry to y uses ∀E, and Exists.intro y uses the same object as the witness of the new existential.
Universal quantification and conjunction
Every student who reads takes notes and understands. We introduce an arbitrary student, apply both universal assumptions, and construct the conjunction.
-- Combine ∀I, →I, ∀E, and ∧I.
theorem
(Thing : Type)
(Student Reads TakesNotes Understands : Thing → Prop)
(hReadersTakeNotes :
∀ x : Thing, Student x → Reads x → TakesNotes x)
(hReadersUnderstand :
∀ x : Thing, Student x → Reads x → Understands x) :
∀ x : Thing, Student x → Reads x → TakesNotes x ∧ Understands x := Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands x⊢ ∀ (x : Thing), Student x → Reads x → TakesNotes x ∧ Understands x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:Thing⊢ Student x → Reads x → TakesNotes x ∧ Understands x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student x⊢ Reads x → TakesNotes x ∧ Understands x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads x⊢ TakesNotes x ∧ Understands x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads x⊢ TakesNotes xThing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads x⊢ Understands x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads x⊢ TakesNotes x Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads xhIfXStudentThenReadingImpliesNotes:Student x → Reads x → TakesNotes x⊢ TakesNotes x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads xhIfXStudentThenReadingImpliesNotes:Student x → Reads x → TakesNotes xhIfXReadsThenTakesNotes:Reads x → TakesNotes x⊢ TakesNotes x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads xhIfXStudentThenReadingImpliesNotes:Student x → Reads x → TakesNotes xhIfXReadsThenTakesNotes:Reads x → TakesNotes xhXTakesNotes:TakesNotes x⊢ TakesNotes x
All goals completed! 🐙
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads x⊢ Understands x Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads xhIfXStudentThenReadingImpliesUnderstanding:Student x → Reads x → Understands x⊢ Understands x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads xhIfXStudentThenReadingImpliesUnderstanding:Student x → Reads x → Understands xhIfXReadsThenUnderstands:Reads x → Understands x⊢ Understands x
Thing:TypeStudent:Thing → PropReads:Thing → PropTakesNotes:Thing → PropUnderstands:Thing → ProphReadersTakeNotes:∀ (x : Thing), Student x → Reads x → TakesNotes xhReadersUnderstand:∀ (x : Thing), Student x → Reads x → Understands xx:ThinghXStudent:Student xhXReads:Reads xhIfXStudentThenReadingImpliesUnderstanding:Student x → Reads x → Understands xhIfXReadsThenUnderstands:Reads x → Understands xhXUnderstands:Understands x⊢ Understands x
All goals completed! 🐙Existential quantification and disjunction
Someone visits Rome or Athens. We open the existential and consider both cases of the disjunction. Each case supplies a witness who sees a museum.
-- Combine ∃E, ∨E, ∀E, and ∃I.
theorem
(Thing : Type)
(VisitsRome VisitsAthens SeesMuseum : Thing → Prop)
(hSomeoneVisitsACity : ∃ x : Thing, VisitsRome x ∨ VisitsAthens x)
(hRomeVisitorsSeeMuseum : ∀ x : Thing, VisitsRome x → SeesMuseum x)
(hAthensVisitorsSeeMuseum : ∀ x : Thing, VisitsAthens x → SeesMuseum x) :
∃ x : Thing, SeesMuseum x := Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum x⊢ ∃ x, SeesMuseum x
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum x⊢ ∀ (a : Thing), VisitsRome a ∨ VisitsAthens a → ∃ x, SeesMuseum x
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:Thing⊢ VisitsRome y ∨ VisitsAthens y → ∃ x, SeesMuseum x
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsRomeOrAthens:VisitsRome y ∨ VisitsAthens y⊢ ∃ x, SeesMuseum x
cases hYVisitsRomeOrAthens with
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsRome:VisitsRome y⊢ ∃ x, SeesMuseum x
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsRome:VisitsRome y⊢ SeesMuseum y
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsRome:VisitsRome yhIfYVisitsRomeThenSeesMuseum:VisitsRome y → SeesMuseum y⊢ SeesMuseum y
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsRome:VisitsRome yhIfYVisitsRomeThenSeesMuseum:VisitsRome y → SeesMuseum yhYSeesMuseum:SeesMuseum y⊢ SeesMuseum y
All goals completed! 🐙
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsAthens:VisitsAthens y⊢ ∃ x, SeesMuseum x
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsAthens:VisitsAthens y⊢ SeesMuseum y
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsAthens:VisitsAthens yhIfYVisitsAthensThenSeesMuseum:VisitsAthens y → SeesMuseum y⊢ SeesMuseum y
Thing:TypeVisitsRome:Thing → PropVisitsAthens:Thing → PropSeesMuseum:Thing → ProphSomeoneVisitsACity:∃ x, VisitsRome x ∨ VisitsAthens xhRomeVisitorsSeeMuseum:∀ (x : Thing), VisitsRome x → SeesMuseum xhAthensVisitorsSeeMuseum:∀ (x : Thing), VisitsAthens x → SeesMuseum xy:ThinghYVisitsAthens:VisitsAthens yhIfYVisitsAthensThenSeesMuseum:VisitsAthens y → SeesMuseum yhYSeesMuseum:SeesMuseum y⊢ SeesMuseum y
All goals completed! 🐙Nested quantifiers
The existential witness may depend on the person introduced by the universal quantifier. We open the existential only after fixing that person.
-- Combine nested quantifiers, ∃E, ∃I, and ∧I.
-- Every person knows at least one person. Therefore, for every person, there
-- is someone whom they know and who is a person.
theorem
(Thing : Type)
(Person : Thing → Prop)
(Knows : Thing → Thing → Prop)
(hEveryPersonKnowsSomeone :
∀ x : Thing, Person x →
∃ y : Thing, Person y ∧ Knows x y) :
∀ x : Thing, Person x →
∃ y : Thing, Knows x y ∧ Person y := Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x y⊢ ∀ (x : Thing), Person x → ∃ y, Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:Thing⊢ Person x → ∃ y, Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person x⊢ ∃ y, Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x y⊢ ∃ y, Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x y⊢ ∃ y, Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x y⊢ ∀ (a : Thing), Person a ∧ Knows x a → ∃ y, Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x yy:Thing⊢ Person y ∧ Knows x y → ∃ y, Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x yy:ThinghYPersonAndXKnowsY:Person y ∧ Knows x y⊢ ∃ y, Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x yy:ThinghYPersonAndXKnowsY:Person y ∧ Knows x y⊢ Knows x y ∧ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x yy:ThinghYPersonAndXKnowsY:Person y ∧ Knows x y⊢ Knows x yThing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x yy:ThinghYPersonAndXKnowsY:Person y ∧ Knows x y⊢ Person y
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x yy:ThinghYPersonAndXKnowsY:Person y ∧ Knows x y⊢ Knows x y All goals completed! 🐙
Thing:TypePerson:Thing → PropKnows:Thing → Thing → ProphEveryPersonKnowsSomeone:∀ (x : Thing), Person x → ∃ y, Person y ∧ Knows x yx:ThinghXPerson:Person xhIfXPersonThenKnowsSomeone:Person x → ∃ y, Person y ∧ Knows x yhXKnowsSomeone:∃ y, Person y ∧ Knows x yy:ThinghYPersonAndXKnowsY:Person y ∧ Knows x y⊢ Person y All goals completed! 🐙Existential quantification and negation
A witness submitted but received no confirmation. The universal rule produces a confirmation for that witness, and the negation produces False.
-- Combine ∃E, ∧E, ∀E, and ¬E.
theorem
(Thing : Type)
(Submitted ReceivedConfirmation : Thing → Prop)
(hSubmissionGetsConfirmation :
∀ x : Thing, Submitted x → ReceivedConfirmation x)
(hCounterexample :
∃ x : Thing, Submitted x ∧ ¬ReceivedConfirmation x) :
False := Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation x⊢ False
Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation x⊢ ∀ (a : Thing), Submitted a ∧ ¬ReceivedConfirmation a → False
Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation xy:Thing⊢ Submitted y ∧ ¬ReceivedConfirmation y → False
Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation xy:ThinghYSubmittedAndNoConfirmation:Submitted y ∧ ¬ReceivedConfirmation y⊢ False
Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation xy:ThinghYSubmittedAndNoConfirmation:Submitted y ∧ ¬ReceivedConfirmation yhYSubmitted:Submitted y⊢ False
Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation xy:ThinghYSubmittedAndNoConfirmation:Submitted y ∧ ¬ReceivedConfirmation yhYSubmitted:Submitted yhYNoConfirmation:¬ReceivedConfirmation y⊢ False
Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation xy:ThinghYSubmittedAndNoConfirmation:Submitted y ∧ ¬ReceivedConfirmation yhYSubmitted:Submitted yhYNoConfirmation:¬ReceivedConfirmation yhIfYSubmittedThenConfirmation:Submitted y → ReceivedConfirmation y⊢ False
Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation xy:ThinghYSubmittedAndNoConfirmation:Submitted y ∧ ¬ReceivedConfirmation yhYSubmitted:Submitted yhYNoConfirmation:¬ReceivedConfirmation yhIfYSubmittedThenConfirmation:Submitted y → ReceivedConfirmation yhYReceivedConfirmation:ReceivedConfirmation y⊢ False
Thing:TypeSubmitted:Thing → PropReceivedConfirmation:Thing → ProphSubmissionGetsConfirmation:∀ (x : Thing), Submitted x → ReceivedConfirmation xhCounterexample:∃ x, Submitted x ∧ ¬ReceivedConfirmation xy:ThinghYSubmittedAndNoConfirmation:Submitted y ∧ ¬ReceivedConfirmation yhYSubmitted:Submitted yhYNoConfirmation:¬ReceivedConfirmation yhIfYSubmittedThenConfirmation:Submitted y → ReceivedConfirmation yhYReceivedConfirmation:ReceivedConfirmation yhContradiction:False⊢ False
All goals completed! 🐙Existential quantification and biconditional
We open the existential, instantiate the biconditional at its witness, and use Iff.mp to extract the required direction. The same object witnesses the goal.
-- Combine ∃E, ∀E, ↔E, and ∃I.
-- Being a square is equivalent to having four equal sides. A square exists;
-- therefore, something has four equal sides.
theorem
(Thing : Type)
(Square HasFourEqualSides : Thing → Prop)
(hEquivalence :
∀ x : Thing, Square x ↔ HasFourEqualSides x)
(hSquareExists : ∃ x : Thing, Square x) :
∃ x : Thing, HasFourEqualSides x := Thing:TypeSquare:Thing → PropHasFourEqualSides:Thing → ProphEquivalence:∀ (x : Thing), Square x ↔ HasFourEqualSides xhSquareExists:∃ x, Square x⊢ ∃ x, HasFourEqualSides x
Thing:TypeSquare:Thing → PropHasFourEqualSides:Thing → ProphEquivalence:∀ (x : Thing), Square x ↔ HasFourEqualSides xhSquareExists:∃ x, Square x⊢ ∀ (a : Thing), Square a → ∃ x, HasFourEqualSides x
Thing:TypeSquare:Thing → PropHasFourEqualSides:Thing → ProphEquivalence:∀ (x : Thing), Square x ↔ HasFourEqualSides xhSquareExists:∃ x, Square xy:Thing⊢ Square y → ∃ x, HasFourEqualSides x
Thing:TypeSquare:Thing → PropHasFourEqualSides:Thing → ProphEquivalence:∀ (x : Thing), Square x ↔ HasFourEqualSides xhSquareExists:∃ x, Square xy:ThinghYSquare:Square y⊢ ∃ x, HasFourEqualSides x
Thing:TypeSquare:Thing → PropHasFourEqualSides:Thing → ProphEquivalence:∀ (x : Thing), Square x ↔ HasFourEqualSides xhSquareExists:∃ x, Square xy:ThinghYSquare:Square y⊢ HasFourEqualSides y
Thing:TypeSquare:Thing → PropHasFourEqualSides:Thing → ProphEquivalence:∀ (x : Thing), Square x ↔ HasFourEqualSides xhSquareExists:∃ x, Square xy:ThinghYSquare:Square yhEquivalenceForY:Square y ↔ HasFourEqualSides y⊢ HasFourEqualSides y
Thing:TypeSquare:Thing → PropHasFourEqualSides:Thing → ProphEquivalence:∀ (x : Thing), Square x ↔ HasFourEqualSides xhSquareExists:∃ x, Square xy:ThinghYSquare:Square yhEquivalenceForY:Square y ↔ HasFourEqualSides yhForwardDirection:Square y → HasFourEqualSides y⊢ HasFourEqualSides y
Thing:TypeSquare:Thing → PropHasFourEqualSides:Thing → ProphEquivalence:∀ (x : Thing), Square x ↔ HasFourEqualSides xhSquareExists:∃ x, Square xy:ThinghYSquare:Square yhEquivalenceForY:Square y ↔ HasFourEqualSides yhForwardDirection:Square y → HasFourEqualSides yhYHasFourEqualSides:HasFourEqualSides y⊢ HasFourEqualSides y
All goals completed! 🐙In each example, we first handle the outer constructor of the goal, make local witnesses explicit, and then apply the propositional rules.
9. Working strategy
When reading a quantified formula, ask:
- Does the goal begin with
∀? Introduce an arbitrary object withintro. - Is there a universal assumption? Apply it to a term from the domain.
- Does the goal begin with
∃? Choose a witness withExists.intro. - Is there an existential assumption? Open it with
Exists.elimwithout presupposing the witness's identity. - Are several quantifiers nested? Check their order and dependencies.
This strategy extends the one used for propositional connectives. Inspect the main constructor of the goal for an introduction rule and compound assumptions for useful elimination rules.
10. Sources and further reading
- Jeremy Avigad, Robert Y. Lewis, and Floris van Doorn, Logic and Proof, “Natural Deduction Rules”: https://leanprover.github.io/logic_and_proof_lean3/nd_quickref.html.
- Lean developers, The Lean Language Reference, “Quantifiers”: https://lean-lang.org/doc/reference/latest/Basic-Propositions/Quantifiers/.
- Jeremy Avigad, Robert Y. Lewis, and Floris van Doorn, Logic and Proof, “First Order Logic in Lean”: https://leanprover.github.io/logic_and_proof_lean3/first_order_logic_in_lean.html.
- Jeremy Avigad, Robert Y. Lewis, and Floris van Doorn, Logic and Proof, “Natural Deduction for First Order Logic”: https://leanprover.github.io/logic_and_proof_lean3/natural_deduction_for_first_order_logic.html.
- Jeremy Avigad, Leonardo de Moura, Soonho Kong, and Sebastian Ullrich, Theorem Proving in Lean 4, “Classical Logic”: https://lean-lang.org/theorem_proving_in_lean4/Propositions-and-Proofs/.