prime_convolution_choi_trace
For d ≥ 1, every r in ZMod d and every complex d×d matrix σ, the trace of prime_convolution_choi d r σ equals the trace of σ.
Statement
theorem prime_convolution_choi_trace (d : ℕ) [NeZero d] (r : ZMod d) (σ : Matrix (Fin d) (Fin d) ℂ) :
(prime_convolution_choi d r σ).trace = σ.trace- Source
- Sanity lemma for prime_convolution_choi, serving OP-2466: the Choi matrix of a trace-one environment has trace one.
- Verified
- 27 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- prime_convolution_choiWith d : ℕ, r : ZMod d and σ : Matrix (Fin d) (Fin d) ℂ (no hypotheses), returns the complex matrix indexed by Fin d × Fin d whose entry…
The proof, explained
The proof evaluates the trace of prime_convolution_choi by expanding the definitions and swapping the order of summation. A private helper lemma shows that the innermost sum over b collapses to σ j l when j = l and vanishes when j ≠ l (because the condition a + j = a + l in ZMod d requires j = l). Applying this helper lemma collapses the sum over l to the diagonal entries σ j j. Finally, the sum over a yields a factor of d that cancels the normalization factor 1 / d, leaving the trace of σ.
When j = l, the inner sum over b ∈ Fin d evaluates to σ j j.
We split on whether j = l. When j = l, substituting l = j reduces the three indicator conditions to the single congruence b ≡ r * a + j (mod d). Since elements of Fin d are strictly less than d, they correspond bijectively to ZMod d via their canonical representatives (ZMod.val_lt, ZMod.val_cast_of_lt, ZMod.natCast_zmod_val). This uniquely determines b as ⟨(r * a + j).val, ...⟩, so the sum over Fin d collapses to the single non-zero term σ j j using sum_ite_eq'.
uses
and_self,and_true,ZMod.val_lt,ZMod.val_cast_of_lt,ZMod.natCast_zmod_val,sum_ite_eq',if_pos,mem_univsplit_ifs with hjl · subst hjl simp only [and_self, and_true] have hb : ∀ b : Fin d, ((b : ZMod d) = r * (a : ZMod d) + (j : ZMod d)) ↔ b = ⟨(r * (a : ZMod d) + (j : ZMod d)).val, ZMod.val_lt _⟩ := by intro b constructor · intro h ext have hbval : ((b.val : ℕ) : ZMod d).val = b.val := ZMod.val_cast_of_lt b.is_lt rw [← hbval, h] · rintro rfl exact ZMod.natCast_zmod_val _ simp_rw [hb] rw [sum_ite_eq', if_pos (mem_univ _)]
When j ≠ l, the inner sum over b ∈ Fin d evaluates to 0.
When j ≠ l, we show that no b can satisfy the conditions. The third condition a + j = a + l in ZMod d implies j = l in ZMod d by additive cancellation (add_left_cancel). Since j, l < d, their canonical representatives equal their values as natural numbers (ZMod.val_cast_of_lt, congrArg), which implies j = l in Fin d, contradicting j ≠ l. Thus each term in the sum is 0 (if_neg), and the sum vanishes (sum_const_zero).
uses
add_left_cancel,ZMod.val_cast_of_lt,congrArg,ZMod.val,sum_congr,if_neg,sum_const_zero· have hcond : ∀ b : Fin d, ¬ ((b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d)) := by intro b ⟨h1, h2, h3⟩ have hjl_zmod : (j : ZMod d) = (l : ZMod d) := by exact add_left_cancel h3 have hjl_fin : j = l := by ext have hjval : ((j.val : ℕ) : ZMod d).val = j.val := ZMod.val_cast_of_lt j.is_lt have hlval : ((l.val : ℕ) : ZMod d).val = l.val := ZMod.val_cast_of_lt l.is_lt rw [← hjval, ← hlval] exact congrArg ZMod.val hjl_zmod exact hjl hjl_fin have : (∑ b : Fin d, if (b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d) then σ j l else 0) = ∑ b : Fin d, (0 : ℂ) := by apply sum_congr rfl intro b _ rw [if_neg (hcond b)] rw [this, sum_const_zero]
The trace of the Choi matrix is rewritten as (1 / d) * ∑ a, ∑ b, ∑ j, ∑ l, (...).
We unfold the definitions of Matrix.trace, Matrix.diag, prime_convolution_choi, and Matrix.of_apply. Using Finset.mul_sum, we factor the scalar 1 / d out of the trace sum. Then Fintype.sum_prod_type splits the sum over pairs (a, b) ∈ Fin d × Fin d into two nested sums over a and b.
uses
Matrix.trace,Matrix.diag,prime_convolution_choi,Matrix.of_apply,Finset.mul_sum,Fintype.sum_prod_typesimp only [Matrix.trace, Matrix.diag, prime_convolution_choi, Matrix.of_apply] rw [← Finset.mul_sum] rw [Fintype.sum_prod_type]
The summation order is swapped so that the sum over b is the innermost sum.
Using Finset.sum_comm twice under Finset.sum_congr, we move the sum over b past the sums over j and l for each fixed a, placing the sum over b inside.
uses
Finset.sum_congr,Finset.sum_commhave hswap : (∑ a : Fin d, ∑ b : Fin d, ∑ j : Fin d, ∑ l : Fin d, if (b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d) then σ j l else 0) = ∑ a : Fin d, ∑ j : Fin d, ∑ l : Fin d, ∑ b : Fin d, if (b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d) then σ j l else 0 := by apply Finset.sum_congr rfl intro a _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro j _ rw [Finset.sum_comm] rw [hswap]
The sum over b and the sum over l collapse, leaving (1 / d) * ∑ a, ∑ j, σ j j.
We rewrite the inner sum over b using the helper theorem prime_convolution_choi_trace_inner_sum, which replaces it with (if j = l then σ j l else 0). Summing this indicator over l ∈ Fin d via Finset.sum_ite_eq selects the unique index l = j, reducing the inner expression to σ j j.
uses
prime_convolution_choi_trace_inner_sum,Finset.sum_ite_eq,Finset.mem_univ,ite_truesimp_rw [prime_convolution_choi_trace_inner_sum] simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true]The sum over a produces a factor of d, which cancels with 1 / d to leave the trace of σ.
The summand ∑ j, σ j j does not depend on a, so summing it over a ∈ Fin d multiplies it by the cardinality d of Fin d (Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul). Since d ≠ 0 (NeZero.ne, Nat.cast_ne_zero.mpr), (1 / d) * d cancels to 1 (one_div_mul_cancel), leaving ∑ j, σ j j, which is σ.trace.
uses
Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul,Nat.cast_ne_zero.mpr,NeZero.ne,mul_assoc,one_div_mul_cancel,one_mulsimp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] have hd : (d : ℂ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne d) rw [← mul_assoc, one_div_mul_cancel hd, one_mul]
and_self- conjunction with itself simplifies: (p ∧ p) = p
and_true- conjunction with True simplifies: (p ∧ True) = p
ZMod.val_lt- the canonical representative of any x in ZMod n is strictly less than n
ZMod.val_cast_of_lt- for a < n, the canonical representative of a cast into ZMod n is a itself
ZMod.natCast_zmod_val- casting the canonical representative of x in ZMod n back to ZMod n recovers x
sum_ite_eq'- summing an indicator if x = a then f x else 0 over a finite set evaluates to f a if a is in the set and 0 otherwise
if_pos- an if-then-else expression evaluates to its then branch when the condition holds
mem_univ- every element of a finite type belongs to Finset.univ
add_left_cancel- left cancellation in an additive structure: a + b = a + c implies b = c
congrArg- functions preserve equality: x = y implies f x = f y
ZMod.val- the canonical projection from ZMod n to its representative in {0, ..., n-1} as a natural number
sum_congr- two finite sums with identical bounds are equal if their summands agree at every point
if_neg- an if-then-else expression evaluates to its else branch when the negation of the condition holds
sum_const_zero- the sum of zero over any finite set is zero
Matrix.trace- the trace of a square matrix, defined as the sum of its diagonal entries
Matrix.diag- the diagonal of a square matrix as a function of the index
prime_convolution_choi- the Choi matrix of the prime convolution quantum channel with parameters d, r and input matrix σ
Matrix.of_apply- the (i, j)-entry of a matrix defined by Matrix.of f is f i j
Finset.mul_sum- multiplication by a constant distributes over finite sums: a * ∑ i, f i = ∑ i, a * f i
Fintype.sum_prod_type- a finite sum over a product type α × β equals the iterated sum over α and β
Finset.sum_congr- two finite sums with identical bounds are equal if their summands agree at every point
Finset.sum_comm- the order of summation in a double finite sum can be interchanged
prime_convolution_choi_trace_inner_sum- the inner sum over b of the prime convolution Choi indicator conditions equals σ j l when j = l and 0 otherwise
Finset.sum_ite_eq- summing an indicator if a = x then f x else 0 over a finite set evaluates to f a if a is in the set and 0 otherwise
Finset.mem_univ- every element of a finite type belongs to Finset.univ
ite_true- an if-then-else with condition True evaluates to the then branch
Finset.sum_const- summing a constant c over a finite set s equals |s| • c
Finset.card_univ- the cardinality of Finset.univ for a finite type α equals Fintype.card α
Fintype.card_fin- the cardinality of Fin n is n
nsmul_eq_mul- natural-number scalar multiplication n • a in a semiring equals ↑n * a
Nat.cast_ne_zero.mpr- if a natural number is nonzero, its cast into a nonzero semiring is nonzero
NeZero.ne- the element of a type with an NeZero instance is not equal to zero
mul_assoc- multiplication is associative: (a * b) * c = a * (b * c)
one_div_mul_cancel- (1 / a) * a = 1 for any nonzero element a in a division ring or group with zero
one_mul- multiplying by 1 on the left is the identity: 1 * a = a
- In Step 2, deducing j = l from a + j = a + l in ZMod d requires converting between Fin d and canonical representatives in ZMod d via ZMod.val_cast_of_lt, which is a formal type-casting detail with no paper counterpart.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
open Finsetprivate theorem prime_convolution_choi_trace_inner_sum {d : ℕ} [NeZero d] (r : ZMod d) (σ : Matrix (Fin d) (Fin d) ℂ) (a j l : Fin d) : (∑ b : Fin d, if (b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d) then σ j l else 0) = if j = l then σ j l else 0 := by split_ifs with hjl · subst hjl simp only [and_self, and_true] have hb : ∀ b : Fin d, ((b : ZMod d) = r * (a : ZMod d) + (j : ZMod d)) ↔ b = ⟨(r * (a : ZMod d) + (j : ZMod d)).val, ZMod.val_lt _⟩ := by intro b constructor · intro h ext have hbval : ((b.val : ℕ) : ZMod d).val = b.val := ZMod.val_cast_of_lt b.is_lt rw [← hbval, h] · rintro rfl exact ZMod.natCast_zmod_val _ simp_rw [hb] rw [sum_ite_eq', if_pos (mem_univ _)] · have hcond : ∀ b : Fin d, ¬ ((b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d)) := by intro b ⟨h1, h2, h3⟩ have hjl_zmod : (j : ZMod d) = (l : ZMod d) := by exact add_left_cancel h3 have hjl_fin : j = l := by ext have hjval : ((j.val : ℕ) : ZMod d).val = j.val := ZMod.val_cast_of_lt j.is_lt have hlval : ((l.val : ℕ) : ZMod d).val = l.val := ZMod.val_cast_of_lt l.is_lt rw [← hjval, ← hlval] exact congrArg ZMod.val hjl_zmod exact hjl hjl_fin have : (∑ b : Fin d, if (b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d) then σ j l else 0) = ∑ b : Fin d, (0 : ℂ) := by apply sum_congr rfl intro b _ rw [if_neg (hcond b)] rw [this, sum_const_zero]theorem prime_convolution_choi_trace (d : ℕ) [NeZero d] (r : ZMod d) (σ : Matrix (Fin d) (Fin d) ℂ) : (prime_convolution_choi d r σ).trace = σ.trace := by simp only [Matrix.trace, Matrix.diag, prime_convolution_choi, Matrix.of_apply] rw [← Finset.mul_sum] rw [Fintype.sum_prod_type] have hswap : (∑ a : Fin d, ∑ b : Fin d, ∑ j : Fin d, ∑ l : Fin d, if (b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d) then σ j l else 0) = ∑ a : Fin d, ∑ j : Fin d, ∑ l : Fin d, ∑ b : Fin d, if (b : ZMod d) = r * (a : ZMod d) + (j : ZMod d) ∧ (b : ZMod d) = r * (a : ZMod d) + (l : ZMod d) ∧ (a : ZMod d) + (j : ZMod d) = (a : ZMod d) + (l : ZMod d) then σ j l else 0 := by apply Finset.sum_congr rfl intro a _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro j _ rw [Finset.sum_comm] rw [hswap] simp_rw [prime_convolution_choi_trace_inner_sum] simp only [Finset.sum_ite_eq, Finset.mem_univ, ite_true] simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] have hd : (d : ℂ) ≠ 0 := Nat.cast_ne_zero.mpr (NeZero.ne d) rw [← mul_assoc, one_div_mul_cancel hd, one_mul]