Formal Software Verification

2.5. The Order of Quantifiers🔗

Consecutive quantifiers of the same kind commute, and quantifiers of different kinds do not. One direction of the exchange holds. A witness that satisfies R with every y in particular satisfies R with each given y.

theorem exists_forall_swap (α β : Type) (R : α β Prop) (h : x, y, R x y) : y, x, R x y := α:Typeβ:TypeR:α β Proph: x, (y : β), R x y (y : β), x, R x y α:Typeβ:TypeR:α β Proph: x, (y : β), R x yb:β x, R x b α:Typeβ:TypeR:α β Propb:βa:αha: (y : β), R a y x, R x b All goals completed! 🐙

The converse fails. Over the natural numbers, take R x y to be x ≥ y. Then ∀ y, ∃ x, R x y holds, since each y satisfies y ≥ y, and ∃ x, ∀ y, R x y states that some natural number is greater than or equal to every natural number, which is false.