This problem set prepares your capstone (Lecture 14). It has two halves. The first is a worked example: a small formalization planned with the seven-part proposal template (Definition 1) and then built sorry-first. Its proofs are your problems, from the sanity checks (Problem 1, Problem 2) through two lemmas (Problem 3, Problem 4) to the main theorem (Problem 5). The second half is your own proposal (Problem 6), written in the same format.

How to work on it. Open the lean/ folder (not the course root) in VS Code with the Lean 4 extension, then open LeanFV/Homework/HW06.lean. It imports Mathlib, and every definition in it is complete. Each problem below names its theorem in that file, such as HW06.kolm_self. The file builds now, with one sorry warning per theorem, and is finished when none are left. The solutions are collapsed under each problem, and LeanFV/Solutions/HW06.lean has the same statements, proved.

The proposal template

A proposal is short: one or two pages of prose and a Lean file that builds. Its job is to make the hard decisions before you are deep in a proof.

Definition 1 (Capstone proposal).

A capstone proposal has seven parts.

  1. Problem. The statement in ordinary mathematics, with its source (paper, book, equation number), and why it is worth formalizing.
  2. Representation. How each object becomes a Lean type, which alternatives you considered, and what Mathlib or Physlib already provides.
  3. Definitions. The Lean definitions, each with a docstring.
  4. Sanity checks. Small facts the definitions must satisfy, a statement showing that a hypothesis is needed, and an example showing that all the hypotheses can hold at once.
  5. Main statement. The Lean statement, with an argument that it says what part 1 says.
  6. Blueprint. Five to ten nodes, each a definition or a lemma, with what each one uses.
  7. Risks. The node most likely to fail, why, and what you will do if it does.

Parts 3, 4 and 6 are Lean, stated sorry-first; parts 1, 2, 5 and 7 are prose. The rest of this page is a complete proposal for a small theorem, written part by part.

A worked example: the classical Fuchs–van de Graaf inequality

1. Problem. For probability vectors on outcomes, the Kolmogorov distance is and the Bhattacharyya coefficient is . They satisfy

This is the left half of inequality (43) in Fuchs and van de Graaf, Cryptographic distinguishability measures for quantum-mechanical states; is their Definition 5 and their Definition 7. It is the first step of capstone Option B, and small enough to finish in a week.

2. Representation. A probability vector becomes a function Fin n → ℝ together with a separate hypothesis IsProb p: the entries are nonnegative and sum to 1. This choice is called unbundled, because the property is not part of the type. The bundled alternative is a type of vectors that carry their own proof, and Mathlib has one:

import Mathlib
 
#check stdSimplex

Lean prints

stdSimplex.{u_1, u_2} (𝕜 : Type u_2) (ι : Type u_1) [Semiring 𝕜] [PartialOrder 𝕜] [Fintype ι] : Set (ι → 𝕜)

so the standard simplex is a set of functions. A vector p : stdSimplex ℝ (Fin n) would carry its proof, at the cost of a coercion back to Fin n → ℝ in every formula. For a project of ten nodes the unbundled version is simpler; for a library it might not be. One junk value matters here: Real.sqrt returns 0 for a negative number, so the Lean bhatt below is defined for every vector but means the Bhattacharyya coefficient only when the entries are nonnegative.

3. Definitions. Real numbers cannot be computed with exactly, so the two definitions that take square roots or divide are marked noncomputable.

namespace HW06
 
/-- A probability vector on `n` outcomes. -/
def IsProb {n : ℕ} (p : Fin n → ℝ) : Prop :=
  (∀ i, 0 ≤ p i) ∧ ∑ i, p i = 1
 
/-- The Bhattacharyya coefficient `B(p, q) = ∑ √(p i * q i)`. -/
noncomputable def bhatt {n : ℕ} (p q : Fin n → ℝ) : ℝ :=
  ∑ i, Real.sqrt (p i * q i)
 
/-- The Kolmogorov distance `K(p, q) = (∑ |p i - q i|) / 2`. -/
noncomputable def kolm {n : ℕ} (p q : Fin n → ℝ) : ℝ :=
  (∑ i, |p i - q i|) / 2
 
end HW06

4–5. Sanity checks and the main statement, sorry-first. Every remaining node of the blueprint, stated with sorry. This is exactly the skeleton in HW06.lean. Lean accepts it with one sorry warning per theorem: it checks that the statements fit together, and nothing more. Proving them is the problem set below.

namespace HW06
 
theorem kolm_self {n : ℕ} (p : Fin n → ℝ) : kolm p p = 0 := by
  sorry
 
theorem bhatt_self {n : ℕ} {p : Fin n → ℝ} (hp : IsProb p) :
    bhatt p p = 1 := by
  sorry
 
theorem hyp_needed :
    ¬ (1 - bhatt (fun _ : Fin 2 => (0 : ℝ)) (fun _ => 0)
        ≤ kolm (fun _ : Fin 2 => (0 : ℝ)) (fun _ => 0)) := by
  sorry
 
theorem isProb_half : IsProb (fun _ : Fin 2 => (1 / 2 : ℝ)) := by
  sorry
 
theorem sq_sqrt_sub_le {a b : ℝ} (ha : 0 ≤ a) (hb : 0 ≤ b) :
    (Real.sqrt a - Real.sqrt b) ^ 2 ≤ |a - b| := by
  sorry
 
theorem sum_sq_sqrt_sub {n : ℕ} {p q : Fin n → ℝ} (hp : IsProb p)
    (hq : IsProb q) :
    ∑ i, (Real.sqrt (p i) - Real.sqrt (q i)) ^ 2 = 2 - 2 * bhatt p q := by
  sorry
 
theorem one_sub_bhatt_le_kolm {n : ℕ} {p q : Fin n → ℝ} (hp : IsProb p)
    (hq : IsProb q) : 1 - bhatt p q ≤ kolm p q := by
  sorry
 
end HW06

Does one_sub_bhatt_le_kolm say what part 1 says? Read it against the paper, piece by piece:

  • kolm divides by 2, as Definition 5 does. Without the factor, the inequality would be weaker and still provable, so no proof attempt would ever catch the slip; only reading does.
  • bhatt takes , as Definition 7 does, not . The two agree when the entries are nonnegative, which IsProb guarantees.
  • Both vectors are assumed to be probability vectors, as in the paper. hyp_needed shows the inequality fails for the zero vectors, so the hypotheses do real work, and isProb_half shows they can hold, so the theorem is not vacuous.
  • The subtraction 1 - bhatt p q is in ℝ, so it cannot be cut off at zero, as it would be in ℕ.

6. Blueprint. Ten nodes. The proof idea fits in one line: for each , ; summed over , the left side is and the right side is .

nodeLean namekinduses
1IsProbdefinition
2bhattdefinition
3kolmdefinition
4kolm_selfsanity check3
5bhatt_selfsanity check1, 2
6hyp_neededa hypothesis is needed2, 3
7isProb_halfhypotheses can hold1
8sq_sqrt_sub_lelemma: one index
9sum_sq_sqrt_sublemma: the sum is 1, 2
10one_sub_bhatt_le_kolmmain theorem1, 2, 3, 8, 9

7. Risks. Node 9 is the riskiest. It is an identity between sums involving square roots, and each rewrite of as needs at that index. If it resists, the fallback is to prove it for first, where the sums can be written out, to separate the algebra from the bookkeeping. Node 8 needs a case split on which root is larger, the kind of goal where nlinarith succeeds only with the right facts in context. The capstone version carries a larger risk, the existence of a measurement that achieves the fidelity, which Lecture 14 discusses under Option B.

Problems

Problem 1 (Sanity checks).

Prove HW06.kolm_self (a distribution is at distance 0 from itself) and HW06.bhatt_self (a probability vector has Bhattacharyya coefficient 1 with itself).

Problem 2 (The hypotheses matter, and can hold).

Prove HW06.hyp_needed: for the zero vectors on two outcomes, which are not probability vectors, is false. Then prove HW06.isProb_half: the uniform distribution on two outcomes satisfies IsProb.

Problem 3 (One index at a time).

Prove HW06.sq_sqrt_sub_le: for , .

Problem 4 (The sum identity).

Prove HW06.sum_sq_sqrt_sub: for probability vectors, .

Problem 5 (The main theorem).

Prove HW06.one_sub_bhatt_le_kolm: for probability vectors , .

Problem 6 (Your capstone proposal).

Write a proposal for your own capstone in the seven parts of the proposal template (Definition 1). Parts 1, 2, 5 and 7 are one or two pages of prose; parts 3, 4 and 6 are a Lean file that builds with every proof sorry. Put the Lean file in a project made with lake new … math (Lecture 14 shows how), or at the end of LeanFV/Homework/HW06.lean inside namespace HW06.Mine. The blueprint has five to ten nodes, and every node is stated in Lean. There is no model solution; the worked example above is the model.