Formal Software Verification

2.2. The Universal Quantifier🔗

To prove ∀ x, P x, consider an arbitrary element and prove the proposition at it. The tactic intro, which introduced implications in Lecture 1, also introduces universal quantifiers.

example (α : Type) (P Q : α Prop) (h : x, P x Q x) : x, P x := α:TypeP:α PropQ:α Proph: (x : α), P x Q x (x : α), P x α:TypeP:α PropQ:α Proph: (x : α), P x Q xa:αP a All goals completed! 🐙

The proof also uses the elimination rule. A hypothesis h : ∀ x, P x ∧ Q x is a function that returns a proof of P a ∧ Q a for each a, so the application h a instantiates it at a. This parallels Lecture 1, where a proof of an implication was a function on proofs. The tactic specialize instantiates a universal hypothesis in place.

example (α : Type) (P Q : α Prop) (h : x, P x Q x) (a : α) (hPa : P a) : Q a := α:TypeP:α PropQ:α Proph: (x : α), P x Q xa:αhPa:P aQ a α:TypeP:α PropQ:α Propa:αh:P a Q ahPa:P aQ a All goals completed! 🐙

The universal quantifier distributes over conjunction. The proof combines the rules for the quantifier with the rules of Lecture 1 for conjunction and the biconditional.

theorem forall_and_distrib (α : Type) (P Q : α Prop) : ( x, P x Q x) ( x, P x) ( x, Q x) := α:TypeP:α PropQ:α Prop(∀ (x : α), P x Q x) (∀ (x : α), P x) (x : α), Q x α:TypeP:α PropQ:α Prop(∀ (x : α), P x Q x) (∀ (x : α), P x) (x : α), Q xα:TypeP:α PropQ:α Prop((∀ (x : α), P x) (x : α), Q x) (x : α), P x Q x α:TypeP:α PropQ:α Prop(∀ (x : α), P x Q x) (∀ (x : α), P x) (x : α), Q x α:TypeP:α PropQ:α Proph: (x : α), P x Q x(∀ (x : α), P x) (x : α), Q x α:TypeP:α PropQ:α Proph: (x : α), P x Q x (x : α), P xα:TypeP:α PropQ:α Proph: (x : α), P x Q x (x : α), Q x α:TypeP:α PropQ:α Proph: (x : α), P x Q x (x : α), P x α:TypeP:α PropQ:α Proph: (x : α), P x Q xa:αP a All goals completed! 🐙 α:TypeP:α PropQ:α Proph: (x : α), P x Q x (x : α), Q x α:TypeP:α PropQ:α Proph: (x : α), P x Q xa:αQ a All goals completed! 🐙 α:TypeP:α PropQ:α Prop((∀ (x : α), P x) (x : α), Q x) (x : α), P x Q x α:TypeP:α PropQ:α Proph:(∀ (x : α), P x) (x : α), Q xa:αP a Q a All goals completed! 🐙