verifying-crypto-with-lean/solutions/Ch03.lean
saymrwulf 45048d4898 Verifying Cryptography with Lean 4: complete 12-chapter curriculum
- 53-page LaTeX/TikZ book (main.pdf + full sources): from zero background
  to reading the real Ed25519/Pasta verification projects
- runnable exercises with sorry-holes + complete solutions for chapters
  2-7, 9, 12; every solution file compiles clean (zero errors, no sorry)
  against Lean v4.30.0-rc2 + Mathlib 5450b53e
- lake project pinned to the same toolchain/Mathlib the solutions were
  verified with; students fetch the Mathlib cache, never build it
- honesty ledger in README: what was machine-checked and how

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-03 09:44:40 +02:00

29 lines
734 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/- Chapter 3 — solutions. Term mode only, as required. -/
namespace Ch03
variable (P Q R : Prop)
theorem const_imp : P → Q → P :=
fun p _ => p
theorem and_to_or : P ∧ Q → P Q :=
fun h => Or.inl h.1
theorem modus_ponens : P → (P → Q) → Q :=
fun p f => f p
theorem and_assoc' : (P ∧ Q) ∧ R → P ∧ (Q ∧ R) :=
fun h => And.intro h.1.1 (And.intro h.1.2 h.2)
theorem or_swap : P Q → Q P :=
fun h => match h with
| Or.inl p => Or.inr p
| Or.inr q => Or.inl q
/- The program: "given evidence p for P and a refuter f of P, feed p to f."
A proof of ¬¬P is a function that defeats any would-be refutation. -/
theorem not_not_intro : P → ¬¬P :=
fun p f => f p
end Ch03