Formal Software Verification

5.8. Exercises🔗

Prove each statement in Lean, replacing sorry. Download the exercise file Lecture05.lean and open it in VS Code. Every exercise asks for a structured proof. Exercises 1 to 6 use fix, assume, have, show and the rule names only, no tactics; exercises 7 and 8 use calc; exercises 9 and 10 are optional.

Exercise 1. The S combinator, distributing an argument through two functions.

namespace Forward theorem declaration uses `sorry`S (a b c : Prop) : (a b c) (a b) a c := sorry end Forward

Exercise 2. Currying and uncurrying, the two directions as one biconditional.

namespace Forward theorem declaration uses `sorry`curry_iff (a b c : Prop) : (a b c) (a b c) := sorry end Forward

Exercise 3. A biconditional is symmetric, built from its two directions.

namespace Forward theorem declaration uses `sorry`iff_symm (a b : Prop) : (a b) (b a) := sorry end Forward

Exercise 4. Non-contradiction, recalling that ¬ a abbreviates a → False.

namespace Forward theorem declaration uses `sorry`non_contradiction (a : Prop) : ¬ (a ¬ a) := sorry end Forward

Exercise 5. An implication out of a disjunction splits into two.

namespace Forward theorem declaration uses `sorry`or_imp (a b c : Prop) : (a b c) (a c) (b c) := sorry end Forward

Exercise 6. A concrete one-point rule. Instantiating the guard at the fixed value collapses the quantifier.

namespace Forward theorem declaration uses `sorry`forall_eq_three (P : Prop) : ( x, x = 3 P x) P 3 := sorry end Forward

Exercise 7. Doubling a sum, by calc. Hint: Nat.two_mul opens the double and ac_rfl closes the rearrangement.

namespace Forward theorem declaration uses `sorry`two_distrib (a b : ) : 2 * (a + b) = a + a + (b + b) := sorry end Forward

Exercise 8. Right distributivity of multiplication over a sum, by calc.

namespace Forward theorem declaration uses `sorry`calc_chain (a b c : ) : (a + b) * c = a * c + b * c := sorry end Forward

Exercise 9. Optional. The concrete one-point rule for ∃, its mirror on the existential side.

namespace Forward theorem declaration uses `sorry`exists_eq_three (P : Prop) : ( x, x = 3 P x) P 3 := sorry end Forward

Exercise 10. Optional. Currying a threefold conjunction, both directions.

namespace Forward theorem declaration uses `sorry`curry_three (a b c d : Prop) : (a b c d) (a b c d) := sorry end Forward