Formal Software Verification

2.7. Exercises🔗

Prove each statement in Lean, replacing sorry with a proof. Download the exercise file Lecture02.lean and open it in VS Code. The file already contains the definitions of Set, membership, inclusion, union, and intersection.

Exercise 1. The universal quantifier distributes over implication.

theorem declaration uses `sorry`exercise1 (α : Type) (P Q : α Prop) (h : x, P x Q x) (hP : x, P x) : x, Q x := α:TypeP:α PropQ:α Proph: (x : α), P x Q xhP: (x : α), P x (x : α), Q x All goals completed! 🐙

Exercise 2. The existential quantifier distributes over disjunction.

theorem declaration uses `sorry`exercise2 (α : 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 All goals completed! 🐙

Exercise 3. Eliminate the existential hypothesis, then instantiate the universal one at the witness.

theorem declaration uses `sorry`exercise3 (α : Type) (P : α Prop) (Q : Prop) (h : x, P x Q) (hP : x, P x) : Q := α:TypeP:α PropQ:Proph: x, P x QhP: (x : α), P xQ All goals completed! 🐙

Exercise 4. Inclusion is transitive.

theorem declaration uses `sorry`exercise4 (α : Type) (s t u : Set α) (hst : s t) (htu : t u) : s u := α:Types:Set αt:Set αu:Set αhst:s thtu:t us u All goals completed! 🐙

Exercise 5. Intersection distributes over union.

theorem declaration uses `sorry`exercise5 (α : Type) (s t u : Set α) : s (t u) (s t) (s u) := α:Types:Set αt:Set αu:Set αs (t u) s t s u All goals completed! 🐙