AFTD Auto-Formalizing Theoretical Domains

prime_convolution_entanglement_breaking_iff_threshold

theoremverifiedoriginal

Let d be a prime with d ≥ 5, r ∈ ZMod d with r ≠ 0, r ≠ 1 and 2r ≠ 1 (r is not the inverse of 2), and p, t real numbers in [0, 1]. The normalised Choi matrix prime_convolution_choi d r (two_level_environment d p t) of the channel N_{r,p,t}(ρ) = Tr_2[U_r(ρ ⊗ σ_{p,t})U_r†] is separable (matrix_is_separable d d), i.e. the channel is entanglement breaking, if and only if t ≤ 1/(1 + d·√(p(1 − p))).

Statement

theorem prime_convolution_entanglement_breaking_iff_threshold :
    ∀ d : ℕ, d.Prime → 5 ≤ d → ∀ r : ZMod d, r ≠ 0 → r ≠ 1 → 2 * r ≠ 1 →
      ∀ p t : ℝ, 0 ≤ p → p ≤ 1 → 0 ≤ t → t ≤ 1 →
        (matrix_is_separable d d (prime_convolution_choi d r (two_level_environment d p t)) ↔
          t ≤ 1 / (1 + d * Real.sqrt (p * (1 - p))))
Related work
OP-2466 (proposed here; it builds on the qutrit convolution channels of arXiv:2609.16200, whose Theorem 8 gives the exact PPT and entanglement-breaking threshold 2/5 on a balanced two-level qutrit slice, and on arXiv:2611.09594, which shows PPT and entanglement breaking differ for another convolution environment). The entry asks whether the channel is entanglement breaking exactly up to the PPT boundary; the stabilizer-mixture theorem gives only a sufficient condition.
Verified
27 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 8
  • 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…
  • two_level_environmentWith d : ℕ and real numbers p, t, returns the complex d×d matrix (1 − t)·I/d + t·|ψ⟩⟨ψ|, where ψ : Fin d → ℝ has ψ j = √p when the…
  • matrix_is_separableWith dA dB : ℕ explicit arguments, in this order, and ρ : Matrix (Fin dA × Fin dB) (Fin dA × Fin dB) ℂ, the proposition that ρ is…
  • two_level_psiThe unit vector psi_p on Fin d with psi_p(j) = sqrt(p) for j = 0, sqrt(1 - p) for j = 1, and 0 for all other j (the pure state entering…
  • prime_convolution_critical_envThe critical (threshold) environment sigma_crit = |psi_p><psi_p| + sqrt(p(1-p)) * I on Fin d: the two-level pure environment shifted by…
  • prime_convolution_five_two_fifth_entanglement_breaking_iffFor every real t with 0 ≤ t ≤ 1: the matrix prime_convolution_choi 5 2 (two_level_environment 5 (1/5) t) (d = 5, r = 2, p = 1/5) is…
  • prime_convolution_separable_imp_thresholdLet d be a prime with d ≥ 5, r ∈ ZMod d with r ≠ 0, r ≠ 1 and 2r ≠ 1 (r is not the inverse of 2), and p, t real numbers in [0, 1]. If…
  • supportThe support $\mathrm{supp}(p) \subseteq \mathrm{Fin}\,n$ consists of coordinates where $p(i) \neq I$; the weight is…

Read back from the Lean

For every natural number $d$, if $d$ is prime and $d \ge 5$, then for every $r \in \mathbb{Z}/d\mathbb{Z}$ such that $r \ne 0$, $r \ne 1$, and $2r \ne 1$, and for all real numbers $p$ and $t$ with $0 \le p \le 1$ and $0 \le t \le 1$: the matrix prime_convolution_choi d r (two_level_environment d p t) is separable (i.e., matrix_is_separable d d ... holds) if and only if $$t \le \frac{1}{1 + d \sqrt{p(1 - p)}}.$$

Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.

The proof, explained

The quantum channel is entanglement breaking if and only if its Choi matrix is separable. Necessity of the threshold condition t ≤ 1 / (1 + d*√(p*(1-p))) is established by prime_convolution_separable_imp_threshold. For sufficiency, when t is at or below the threshold, the environment state decomposes into a non-negative linear combination of the critical environment state and the identity matrix. The Choi matrix of the critical environment is shown to be separable by explicitly decomposing it into a twirled convolution orbit of a product vector with two-point support plus a non-negative diagonal matrix. Both components, as well as the identity matrix, have separable Choi matrices, so convexity and linearity guarantee separability of the full Choi matrix.

  1. The diagonal twirl identity on a commutative ring holds for all ring elements j.

    Under r ≠ 0, r ≠ 1, and 2r ≠ 1, the four field offsets 0, 1, r, 1-r are pairwise distinct. A case split on whether j is 0, 1, r, 1-r, or outside this set verifies the identity A^2*B(j)^2 + B^2*B(j-r)^2 = P(j)^2 + A^2*B^2*[j ∈ {r, 1-r}] in each case.

    lines 19–33

    uses sub_eq_zero, Ne.symm

      have hr1r : r ≠ 1-r := by intro h; apply hr2; linear_combination h
      have hr10 : 1-r ≠ 0 := by intro h; apply hr1; linear_combination -h
      have hr11 : 1-r ≠ 1 := by intro h; apply hr0; linear_combination -h
      have e0 : j-r=0 ↔ j=r := sub_eq_zero
      have e1 : j-r=1-r ↔ j=1 := by constructor <;> intro h <;> linear_combination h
      simp only [in1249full_rectB, in1249full_rectP, e0, e1]
      by_cases h0 : j=0
      · subst j; simp [hr0, hr1, hr2, hr10, hr11, hr1r, Ne.symm hr0, Ne.symm hr10] <;> ring
      · by_cases h1 : j=1
        · subst j; simp [hr0, hr1, hr2, hr10, hr11, hr1r, Ne.symm hr1, Ne.symm hr11] <;> ring
        · by_cases h2 : j=r
          · subst j; simp [h0,h1,hr0,hr1,hr1r,hr10,hr11] <;> ring
          · by_cases h3 : j=1-r
            · subst j; simp [h0,h1,h2,hr0,hr1,hr1r,hr10,hr11, Ne.symm hr1r]
            · simp [h0,h1,h2,h3]
  2. The indicator product B(j) * B(j + 1 - r) vanishes unless j = 0.

    Since B is supported on {0, 1-r}, the product can only be non-zero if j ∈ {0, 1-r}. At j = 0, j + 1 - r = 1 - r, giving A*B. At j = 1 - r, j + 1 - r = 2*(1-r), which is distinct from both 0 and 1-r by the hypothesis 2*(1-r) ≠ 0. For any other j, B(j) = 0.

    lines 39–54

      have hr10 : 1-r ≠ 0 := by intro h; apply hr1; linear_combination -h
      have ht0 : (1-r)+(1-r) ≠ 0 := by
        intro h
        apply hdouble
        linear_combination h
      have hts : (1-r)+(1-r) ≠ 1-r := by
        intro h; apply hr10; linear_combination h
      by_cases h0 : j=0
      · subst j
        simp [in1249full_rectB, hr10]
      · by_cases h1 : j=1-r
        · subst j
          have heq : (1-r)+1-r = (1-r)+(1-r) := by ring
          rw [heq]
          simp [in1249full_rectB, hr10, ht0, hts]
        · simp [in1249full_rectB, h0, h1]
  3. The indicator product P(j) * P(j + 1) vanishes unless j = 0.

    Since P is supported on {0, 1}, non-vanishing requires j ∈ {0, 1}. At j = 0, j + 1 = 1, giving A^2*B^2. At j = 1, j + 1 = 2 ≠ 0, 1 since 2 ≠ 0 in the ring. For other j, P(j) = 0.

    lines 58–69

    uses one_ne_zero

      by_cases h0 : j=0
      · subst j
        simp [in1249full_rectP]
      · by_cases h1 : j=1
        · subst j
          have h21 : (1 : F)+1 ≠ 1 := by
            intro h
            have hh : (1 : F)=0 := by linear_combination h
            exact one_ne_zero hh
          have h20 : (1 : F)+1 ≠ 0 := by intro h; apply htwo; linear_combination h
          simp [in1249full_rectP, h20, h21]
        · simp [in1249full_rectP, h0, h1]
  4. The algebraic twirl formula holds for all j, l in a commutative ring.

    Case analysis on j - l: when j = l, it reduces to the diagonal twirl identity in1249full_rect_twirl_diagonal; when j - l = 1 or j - l = -1, the non-vanishing terms match the overlap lemmas in1249full_rect_B_overlap and in1249full_rect_P_overlap; when |j - l| > 1, both sides vanish due to disjoint supports.

    lines 80–138

    uses one_ne_zero, in1249full_rect_twirl_diagonal, in1249full_rect_B_overlap, in1249full_rect_P_overlap

      have hneg : (-1 : F) ≠ 0 := neg_ne_zero.mpr one_ne_zero
      have htwo' : (1 : F) ≠ -1 := by intro h; apply htwo; linear_combination h
      have hm2 : (-1 : F) - 1 ≠ 0 := by intro h; apply htwo; linear_combination -h
      have hm21 : (-1 : F) - 1 ≠ -1 := by
        intro h
        have hh : (1 : F) = 0 := by linear_combination -h
        exact one_ne_zero hh
      by_cases h0 : j=l
      · subst l
        simp only [sub_self, mul_zero, zero_add, zero_sub, in1249full_rectA, if_pos rfl, hneg, if_false, true_and]
        simp only [if_true]
        have he : r * (-1) + j = j-r := by ring
        rw [he]
        have hd := in1249full_rect_twirl_diagonal r hr0 hr1 hr2 A B j
        nlinarith [hd]
      · by_cases hp : j-l=1
        · have hj : j=l+1 := by linear_combination hp
          subst j
          have hl : l+1 ≠ l := by
            intro h
            have hh : (1 : F) = 0 := by linear_combination h
            exact one_ne_zero hh
          simp only [add_sub_cancel_left, in1249full_rectA, one_ne_zero, htwo', if_false, sub_self, if_pos rfl,
            mul_zero, zero_add, hl, false_and, ↓reduceIte, mul_zero, add_zero]
          have hb := in1249full_rect_B_overlap r hr1 hdouble A B l
          have hc := in1249full_rect_P_overlap htwo A B l
          by_cases hz : l = 0
          · simp only [if_pos hz] at hb hc
            linear_combination (A*B)*hb - hc
          · simp only [if_neg hz] at hb hc
            linear_combination (A*B)*hb - hc
        · by_cases hm : j-l= -1
          · have hl : l=j+1 := by linear_combination -hm
            subst l
            have hj : j ≠ j+1 := by
              intro h
              have hh : (1 : F) = 0 := by linear_combination -h
              exact one_ne_zero hh
            have he : j-(j+1) = (-1 : F) := by ring
            rw [he]
            simp only [in1249full_rectA, hneg, if_false, if_pos rfl,
              hm2, hm21, mul_zero, zero_add, hj, false_and, ↓reduceIte, add_zero]
            have hb := in1249full_rect_B_overlap r hr1 hdouble A B j
            have hc := in1249full_rect_P_overlap htwo A B j
            have hzarg : r*(-1)+(j+1) = j+1-r := by ring
            rw [hzarg]
            by_cases hz : j = 0
            · simp only [if_pos hz] at hb hc
              linear_combination (A*B)*hb - hc
            · simp only [if_neg hz] at hb hc
              linear_combination (A*B)*hb - hc
          · have hsub0 : j-l ≠ 0 := sub_ne_zero.mpr h0
            have hsub10 : j-l-1 ≠ 0 := by intro h; apply hp; linear_combination h
            have hsub1n : j-l-1 ≠ -1 := by intro h; apply hsub0; linear_combination h
            have hP : in1249full_rectP A B j * in1249full_rectP A B l = 0 := by
              simp only [in1249full_rectP]
              split_ifs with a b c d <;> simp_all <;> try ring
              all_goals exfalso <;> first | apply hp | apply hm | apply h0 <;> linear_combination a + b
            simp [in1249full_rectA, hsub0, hm, hsub10, hsub1n, h0, hP]
  5. The twirl sum over Fin (n+2) reduces to the two terms i = 0 and i = -1.

    The indicator A(i) vanishes for all i ∉ {0, -1}. Since 0 ≠ -1 in Fin (n+2) for n+2 ≥ 2, Fintype.sum_eq_add reduces the full sum over the ring to the sum of the two terms at i = 0 and i = -1.

    lines 156–168

    uses Fintype.sum_eq_add, Ne.symm

      have h01 : (0 : Fin (n+2)) ≠ -1 := by
        intro h
        have h1 : (1 : Fin (n+2)) = 0 := by linear_combination h
        have h1v : ((1 : Fin (n+2)) : ℕ) = 1 := by simp
        rw [h1] at h1v
        simp at h1v
      rw [Fintype.sum_eq_add 0 (-1) h01]
      · have h10 : (-1 : Fin (n+2)) ≠ 0 := Ne.symm h01
        simp only [in1249full_A, if_pos rfl, h01, h10, if_false, if_true]
        congr 1 <;> congr 1 <;> congr 1 <;> try ring
      · intro i ⟨hi0, hi1⟩
        simp [in1249full_A, hi0, hi1]
    
  6. The full twirl sum on Fin (n+2) matches the algebraic expansion for all j, l.

    Combining in1249full_twirl_support (reducing the sum to two terms) with in1249full_rect_twirl_algebra (evaluating those two terms) establishes the identity on Fin (n+2).

    lines 178–179

    uses in1249full_twirl_support, in1249full_rect_twirl_algebra

      rw [in1249full_twirl_support]
      exact in1249full_rect_twirl_algebra r hr0 hr1 hr2 htwo hdouble A B j l
  7. The twirl convolution of basis vectors δ_0 and δ_k equals δ_k(j)*δ_k(l).

    The factor δ_0(i) forces i = 0 via Finset.sum_eq_single. At i = 0, δ_0(j-l) forces j = l, yielding δ_k(j)*δ_k(l). If j ≠ l, both sides vanish.

    lines 187–198

    uses Finset.sum_eq_single, Finset.mem_univ

      classical
      rw [Finset.sum_eq_single 0]
      · simp only [in1249full_basis, if_pos rfl, zero_mul, zero_add, one_mul]
        by_cases h : j = l
        · subst l
          simp [in1249full_basis]
        · have hsub : j-l ≠ 0 := sub_ne_zero.mpr h
          simp [in1249full_basis, h, hsub]; aesop
      · intro i _ hi
        simp [in1249full_basis, hi]
      · intro h
        exact absurd (Finset.mem_univ _) h
  8. The Choi matrix of the rank-one projection |k⟩⟨k| is separable.

    By in1243_twirl_sep, the Choi matrix of any twirled convolution orbit is separable. Since |k⟩⟨k| is the orbit of δ_0 and δ_k by in1249full_basis_orbit, its Choi matrix is separable.

    lines 203–208

    uses in1243_twirl_sep, Complex.ofReal_mul, congrArg, in1249full_basis_orbit

      have h := in1243_twirl_sep n r (in1249full_basis n 0) (in1249full_basis n k)
      convert h using 1
      congr 1
      ext j l
      simp only [Matrix.of_apply, ← Complex.ofReal_mul]
      exact congrArg (fun x : ℝ => (x : ℂ)) (in1249full_basis_orbit n r k j l).symm
  9. The Choi matrix of any non-negative diagonal matrix is separable.

    A diagonal matrix decomposes into a non-negative sum ∑_k w_k |k⟩⟨k|. By Choi map linearity in1243_choi_linear, its Choi matrix is the sum of the Choi matrices of |k⟩⟨k|, each of which is separable by in1249full_basis_choi_sep and in1243_sep_smul, so the sum is separable by in1243_sep_sum.

    lines 214–237

    uses in1243_choi_linear, in1243_sep_sum, in1243_sep_smul, in1249full_basis_choi_sep

      classical
      let D : Fin (n+2) → Matrix (Fin (n+2)) (Fin (n+2)) ℂ :=
        fun k => Matrix.of fun j l => (in1249full_basis n k j * in1249full_basis n k l : ℂ)
      have heq : Matrix.diagonal (fun j => (w j : ℂ)) = ∑ k ∈ Finset.univ, (w k : ℂ) • D k := by
        ext j l
        simp only [Matrix.diagonal_apply, Matrix.sum_apply, Matrix.smul_apply, smul_eq_mul, D, Matrix.of_apply,
          in1249full_basis]
        by_cases h : j = l
        · subst l
          rw [Finset.sum_eq_single j]
          · simp
          · intro k _ hj
            have : j ≠ k := Ne.symm hj
            simp [this]
          · simp
        · simp only [apply_ite (fun a : ℝ => (a : ℂ)), Complex.ofReal_one, Complex.ofReal_zero]
          rw [Finset.sum_eq_zero]
          · simp [h]
          · intro k _
            by_cases hj : j=k <;> by_cases hl : l=k <;> simp_all
      rw [heq, in1243_choi_linear (n+2) (r : ZMod (n+2)) Finset.univ w D]
      apply in1243_sep_sum
      intro k _
      exact in1243_sep_smul _ _ _ (hw k) _ (in1249full_basis_choi_sep n r k)
  10. In Fin (n+2) with prime n+2 ≥ 5 and r ≠ 1, 2 ≠ 0 and 2*(1-r) ≠ 0.

    Using the ring equivalence ZMod.finEquiv between Fin (n+2) and ZMod (n+2), 2 is non-zero because 0 < 2 < n+2. Since ZMod (n+2) is a field for prime n+2, the product of the non-zero elements 2 and 1 - r is non-zero by mul_ne_zero.

    lines 242–268

    uses ZMod.finEquiv, ZMod.natCast_eq_zero_iff, Nat.not_dvd_of_pos_of_lt, map_add, map_one, mul_ne_zero

      letI : Fact (Nat.Prime (n+2)) := ⟨hp⟩
      let e := ZMod.finEquiv (n+2)
      have hz2 : (2 : ZMod (n+2)) ≠ 0 := by
        intro h
        have hdvd : n+2 ∣ 2 := (ZMod.natCast_eq_zero_iff 2 (n+2)).mp h
        have hlt : 0 < 2 ∧ 2 < n+2 := by omega
        exact (Nat.not_dvd_of_pos_of_lt hlt.1 hlt.2) hdvd
      have he2 : e 2 = (2 : ZMod (n+2)) := by
        calc e 2 = e (1 + 1) := by congr 1 <;> norm_num
             _ = e 1 + e 1 := map_add e 1 1
             _ = 2 := by simp only [map_one]; exact one_add_one_eq_two
      have he1 : e (1-r) = 1 - e r := by simp [e]
      have hfr : 1-e r ≠ 0 := by
        intro h
        have heq : e r = e 1 := by simpa using (sub_eq_zero.mp h).symm
        exact hr1 (e.injective heq)
      constructor
      · intro h
        have := congrArg e h
        simp [he2] at this
        exact hz2 this
      · intro h
        have hz : (2 : ZMod (n+2)) * (1-e r) = 0 := by
          have := congrArg e h
          simpa [he2,he1] using this
        exact (mul_ne_zero hz2 hfr) hz
    
  11. The critical environment matrix decomposes into an orbit twirl matrix plus a non-negative diagonal matrix.

    Setting amplitudes A = p^(1/4), B = (1-p)^(1/4), and q = √(p(1-p)), the orbit twirl produces P(j)P(l) plus q on the diagonal at indices r and 1-r. Adding the diagonal matrix w(j) = (if j ∈ {r, 1-r} then 0 else q) completes the diagonal to q everywhere, matching the critical environment matrix.

    lines 281–325

    uses Real.sq_sqrt, Real.sqrt_nonneg, Real.sqrt_mul, in1249full_prime_fin_nonzero, Fin.ext, in1249full_twirl_complete

      classical
      let A := Real.sqrt (Real.sqrt p)
      let B := Real.sqrt (Real.sqrt (1-p))
      let q := Real.sqrt (p*(1-p))
      let a := in1249full_A n A B
      let b := in1249full_B n r A B
      let w : Fin (n+2) → ℝ := fun j => if j=r ∨ j=1-r then 0 else q
      refine ⟨a,b,w, ?_, ?_⟩
      · intro j
        dsimp [w, q]
        split_ifs <;> positivity
      · have hp1' : 0 ≤ 1-p := by linarith
        have ha : A^2 = Real.sqrt p := Real.sq_sqrt (Real.sqrt_nonneg p)
        have hb : B^2 = Real.sqrt (1-p) := Real.sq_sqrt (Real.sqrt_nonneg (1-p))
        have hq : A^2*B^2 = q := by
          rw [ha,hb]
          dsimp [q]
          rw [Real.sqrt_mul hp0]
        obtain ⟨htwo,hdouble⟩ := in1249full_prime_fin_nonzero n hp h5 r hr1
        have hpsi (j : Fin (n+2)) : in1249full_P n A B j = two_level_psi (n+2) p j := by
          have h0 : ((j : ℕ) = 0) ↔ j=0 := by
            constructor
            · intro h; apply Fin.ext; simpa using h
            · intro h; subst j; rfl
          have h1 : ((j : ℕ) = 1) ↔ j=1 := by
            constructor
            · intro h; apply Fin.ext; simpa using h
            · intro h; subst j; simp
          simp [in1249full_P, two_level_psi, h0,h1,ha,hb]
        ext j l
        rw [Matrix.add_apply, Matrix.of_apply, Matrix.diagonal_apply]
        have ho := in1249full_twirl_complete n r hr0 hr1 hr2 htwo hdouble A B j l
        change _ = ((∑ i, in1249full_A n A B i * in1249full_B n r A B (r*i+j) *
          in1249full_A n A B (i+j-l) * in1249full_B n r A B (r*(i+j-l)+l) : ℝ) : ℂ) + _
        rw [ho, hpsi j, hpsi l, hq]
        simp only [prime_convolution_critical_env, Matrix.add_apply, Matrix.of_apply, Matrix.smul_apply,
          smul_eq_mul, Matrix.one_apply]
        dsimp [w]
        by_cases hjl : j=l
        · subst l
          by_cases hj : j=r ∨ j=1-r
          · simp [hj, q]
          · simp [hj, q]
        · simp [hjl]
    
  12. The Choi mapping of the prime convolution channel is additive.

    Specialising in1243_choi_linear to an index set of size two via Fin.sum_univ_two shows that prime_convolution_choi distributes over addition.

    lines 328–329

    uses in1243_choi_linear, Fin.sum_univ_two

      have h := in1243_choi_linear d r (Finset.univ : Finset (Fin 2)) (fun _ => (1 : ℝ)) ![X,Y]
      simpa [Fin.sum_univ_two] using h
  13. The Choi mapping of the prime convolution channel commutes with real scalar multiplication.

    Specialising in1243_choi_linear to an index set of size one via Fin.sum_univ_one shows that prime_convolution_choi commutes with scaling by real c.

    lines 333–334

    uses in1243_choi_linear, Fin.sum_univ_one

      have h := in1243_choi_linear d r (Finset.univ : Finset (Fin 1)) (fun _ => c) ![X]
      simpa [Fin.sum_univ_one] using h
  14. The Choi matrix of the critical environment state is separable.

    Using the decomposition in1249full_critical_orbit_decomposition and additivity in1249full_choi_add, the Choi matrix is the sum of the twirled orbit Choi matrix and a diagonal Choi matrix. The former is separable by in1243_twirl_sep and the latter by in1249full_diag_choi_sep, so their sum is separable by in1243_sep_add.

    lines 342–346

    uses in1249full_critical_orbit_decomposition, in1249full_choi_add, in1243_sep_add, in1243_twirl_sep, in1249full_diag_choi_sep

      obtain ⟨a,b,w,hw,heq⟩ := in1249full_critical_orbit_decomposition n hp h5 r hr0 hr1 hr2 p hp0 hp1
      rw [heq, in1249full_choi_add (n+2) (r : ZMod (n+2))]
      apply in1243_sep_add
      · exact in1243_twirl_sep n r a b
      · exact in1249full_diag_choi_sep n r w hw
  15. Whenever t ≤ 1 / (1 + (n+2)*√(p*(1-p))), the Choi matrix of the environment is separable.

    The environment state decomposes as t * σ_crit + c * I with c = (1-t)/(n+2) - t*√(p*(1-p)). The threshold condition guarantees c ≥ 0. By linearity of the Choi map, its Choi matrix is t * Choi(σ_crit) + c * Choi(I), which is separable as a positive combination of separable matrices.

    lines 355–383

    uses Real.sqrt_nonneg, le_div_iff₀, in1249full_choi_add, in1249full_choi_smul, in1243_sep_add, in1243_sep_smul, in1249full_critical_separable, in1249full_diag_choi_sep

      classical
      let q := Real.sqrt (p*(1-p))
      let c : ℝ := (1-t)/(n+2 : ℕ) - t*q
      have hq : 0 ≤ q := Real.sqrt_nonneg _
      have hd : (0 : ℝ) < (n+2 : ℕ) := by exact_mod_cast (by omega : 0 < n+2)
      have hc : 0 ≤ c := by
        have hb : 0 < 1 + ((n+2 : ℕ) : ℝ)*q := by positivity
        have ht'' : t ≤ 1 / (1 + ((n+2 : ℕ) : ℝ)*q) := by simpa [q] using ht
        have ht' := (le_div_iff₀ hb).mp ht'' 
        dsimp [c]
        rw [sub_nonneg, le_div_iff₀ hd]
        push_cast at *
        nlinarith
      have henv : two_level_environment (n+2) p t =
          (t : ℂ) • prime_convolution_critical_env (n+2) p +
          Matrix.diagonal (fun _ => (c : ℂ)) := by
        ext j l
        simp only [two_level_environment, prime_convolution_critical_env, two_level_psi,
          Matrix.of_apply, Matrix.add_apply, Matrix.smul_apply, Matrix.one_apply, Matrix.diagonal_apply,
          smul_eq_mul]
        set u : ℝ := if (j : ℕ) = 0 then Real.sqrt p else if (j : ℕ) = 1 then Real.sqrt (1-p) else 0
        set v : ℝ := if (l : ℕ) = 0 then Real.sqrt p else if (l : ℕ) = 1 then Real.sqrt (1-p) else 0
        dsimp [c,q]
        by_cases h : j=l <;> simp [h] <;> push_cast <;> ring
      rw [henv, in1249full_choi_add (n+2) (r : ZMod (n+2)), in1249full_choi_smul (n+2) (r : ZMod (n+2))]
      apply in1243_sep_add
      · exact in1243_sep_smul _ _ t ht0 _ (in1249full_critical_separable n hp h5 r hr0 hr1 hr2 p hp0 hp1)
      · exact in1249full_diag_choi_sep n r (fun _ => c) (fun _ => hc)
    
  16. The Choi matrix is separable if and only if t ≤ 1 / (1 + d*√(p*(1-p))).

    The forward implication is given by prime_convolution_separable_imp_threshold. For the reverse, since d ≥ 5, we write d = n + 2 and apply in1249full_threshold_sufficient.

    lines 389–394

    uses prime_convolution_separable_imp_threshold, in1249full_threshold_sufficient

      intro d hp h5 r hr0 hr1 hr2 p t hp0 hp1 ht0 ht1
      constructor
      · exact prime_convolution_separable_imp_threshold d hp h5 r hr0 hr1 hr2 p t hp0 hp1 ht0 ht1
      · intro ht
        obtain ⟨n,rfl⟩ : ∃ n, d = n+2 := ⟨d-2, by omega⟩
        exact in1249full_threshold_sufficient n hp h5 r hr0 hr1 hr2 p t hp0 hp1 ht0 ht
Fin.sum_univ_one
The sum over Fin 1 consists solely of the single term at index 0.
Fin.sum_univ_two
The sum over Fin 2 consists of the sum of the two terms at indices 0 and 1.
Fin.ext
Two elements of Fin n are equal if and only if their underlying natural values are equal.
Finset.mem_univ
Every element of a finite type belongs to its universal finset Finset.univ.
Finset.sum_eq_single
If all terms in a finite sum vanish except at a single index, the sum equals the term at that index.
Fintype.sum_eq_add
A sum over a finite type of a function supported on at most two distinct points equals the sum of the values at those two points.
Ne.symm
Inequality is symmetric: if a ≠ b, then b ≠ a.
Nat.not_dvd_of_pos_of_lt
For a positive integer less than another, the larger does not divide the smaller.
Real.sqrt_nonneg
The square root of any real number is non-negative.
Real.sq_sqrt
For a non-negative real x, (√x)^2 = x.
Real.sqrt_mul
For x ≥ 0, the square root of a product is the product of the square roots: √(x * y) = √x * √y.
ZMod.finEquiv
The canonical ring equivalence between Fin n and ZMod n.
ZMod.natCast_eq_zero_iff
In ZMod b, the cast of a natural number a is zero if and only if b divides a.
Complex.ofReal_mul
Casting a product of real numbers to the complex field equals the product of their complex casts.
congrArg
Equality is preserved by applying any function: a = b implies f a = f b.
in1249full_choi_add
The Choi mapping of the prime convolution channel preserves matrix addition.
in1249full_choi_smul
The Choi mapping of the prime convolution channel commutes with real scalar multiplication.
in1243_choi_linear
The Choi mapping commutes with finite linear combinations.
in1243_sep_add
The sum of two separable matrices is separable.
in1243_sep_sum
A finite sum of separable matrices is separable.
in1243_sep_smul
Multiplying a separable matrix by a non-negative real scalar yields a separable matrix.
in1243_twirl_sep
For any two functions a and b on Fin (n+2), the Choi matrix of their twirl orbit convolution is separable.
in1249full_basis_choi_sep
The Choi matrix of any standard basis rank-one projector |k⟩⟨k| is separable.
in1249full_basis_orbit
The twirl orbit convolution of the standard basis indicators at 0 and k evaluates to the rank-one projector δ_k(j)δ_k(l).
in1249full_critical_orbit_decomposition
The critical environment matrix decomposes into a twirled orbit convolution matrix plus a non-negative diagonal matrix.
in1249full_critical_separable
The Choi matrix of the critical environment state is separable.
in1249full_diag_choi_sep
The Choi matrix of any diagonal matrix with non-negative entries is separable.
in1249full_prime_fin_nonzero
For prime n+2 ≥ 5 and r ≠ 1, 2 ≠ 0 and 2*(1-r) ≠ 0 in Fin (n+2).
in1249full_rect_B_overlap
The product of indicator B(j) with its shift B(j + 1 - r) equals A*B when j = 0 and 0 otherwise.
in1249full_rect_P_overlap
The product of indicator P(j) with its shift P(j + 1) equals A^2*B^2 when j = 0 and 0 otherwise.
in1249full_rect_twirl_algebra
The twirl algebraic identity holds for all pairs of ring elements j, l.
in1249full_rect_twirl_diagonal
On a ring, the diagonal twirl sum A^2*B(j)^2 + B^2*B(j-r)^2 equals P(j)^2 + A^2*B^2 when j ∈ {r, 1-r}.
in1249full_threshold_sufficient
Sufficiency of the threshold: if t ≤ 1 / (1 + (n+2)*√(p*(1-p))), the Choi matrix of the environment is separable.
in1249full_twirl_complete
The complete twirl sum over Fin (n+2) equals P(j)*P(l) + A^2*B^2 when j = l and j ∈ {r, 1-r}.
in1249full_twirl_support
The twirl sum over Fin (n+2) reduces to the two non-zero support terms at indices 0 and -1.
le_div_iff₀
For a positive divisor c > 0, a ≤ b / c is equivalent to a * c ≤ b.
map_add
A ring homomorphism preserves addition: f(x + y) = f(x) + f(y).
map_one
A ring homomorphism preserves the multiplicative identity: f(1) = 1.
mul_ne_zero
In a domain or field, the product of two non-zero elements is non-zero.
one_ne_zero
In any non-trivial ring, 1 ≠ 0.
prime_convolution_separable_imp_threshold
Necessity of the threshold: if the convolution channel Choi matrix is separable, then t ≤ 1 / (1 + d*√(p*(1-p))).
sub_eq_zero
In an additive group, a - b = 0 if and only if a = b.

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

open Fin.CommRingset_option maxRecDepth 4096set_option maxHeartbeats 1000000set_option linter.all falsevariable {F : Type*} [CommRing F] [Nontrivial F] [DecidableEq F]def in1249full_rectP (A B : ℝ) (j : F) : ℝ :=  if j=0 then A^2 else if j=1 then B^2 else 0def in1249full_rectB (r : F) (A B : ℝ) (j : F) : ℝ :=  if j=0 then A else if j=1-r then B else 0-- Case j=l: the four distinct offsets are 0, 1, r, 1-r.theorem in1249full_rect_twirl_diagonal (r : F) (hr0 : r ≠ 0) (hr1 : r ≠ 1)    (hr2 : 2*r ≠ 1) (A B : ℝ) (j : F) :    A^2 * in1249full_rectB r A B j ^2 + B^2 * in1249full_rectB r A B (j-r)^2 =      in1249full_rectP A B j ^2 + A^2*B^2 * (if j=r ∨ j=1-r then 1 else 0) := by  have hr1r : r ≠ 1-r := by intro h; apply hr2; linear_combination h  have hr10 : 1-r ≠ 0 := by intro h; apply hr1; linear_combination -h  have hr11 : 1-r ≠ 1 := by intro h; apply hr0; linear_combination -h  have e0 : j-r=0 ↔ j=r := sub_eq_zero  have e1 : j-r=1-r ↔ j=1 := by constructor <;> intro h <;> linear_combination h  simp only [in1249full_rectB, in1249full_rectP, e0, e1]  by_cases h0 : j=0  · subst j; simp [hr0, hr1, hr2, hr10, hr11, hr1r, Ne.symm hr0, Ne.symm hr10] <;> ring  · by_cases h1 : j=1    · subst j; simp [hr0, hr1, hr2, hr10, hr11, hr1r, Ne.symm hr1, Ne.symm hr11] <;> ring    · by_cases h2 : j=r      · subst j; simp [h0,h1,hr0,hr1,hr1r,hr10,hr11] <;> ring      · by_cases h3 : j=1-r        · subst j; simp [h0,h1,h2,hr0,hr1,hr1r,hr10,hr11, Ne.symm hr1r]        · simp [h0,h1,h2,h3]-- The only overlapping translates of the two-support orbit occur at j=0.theorem in1249full_rect_B_overlap (r : F) (hr1 : r ≠ 1) (hdouble : 2*(1-r) ≠ 0)    (A B : ℝ) (j : F) :    in1249full_rectB r A B j * in1249full_rectB r A B (j+1-r) = if j=0 then A*B else 0 := by  have hr10 : 1-r ≠ 0 := by intro h; apply hr1; linear_combination -h  have ht0 : (1-r)+(1-r) ≠ 0 := by    intro h    apply hdouble    linear_combination h  have hts : (1-r)+(1-r) ≠ 1-r := by    intro h; apply hr10; linear_combination h  by_cases h0 : j=0  · subst j    simp [in1249full_rectB, hr10]  · by_cases h1 : j=1-r    · subst j      have heq : (1-r)+1-r = (1-r)+(1-r) := by ring      rw [heq]      simp [in1249full_rectB, hr10, ht0, hts]    · simp [in1249full_rectB, h0, h1]theorem in1249full_rect_P_overlap (htwo : (2 : F) ≠ 0) (A B : ℝ) (j : F) :    in1249full_rectP A B j * in1249full_rectP A B (j+1) = if j=0 then A^2*B^2 else 0 := by  by_cases h0 : j=0  · subst j    simp [in1249full_rectP]  · by_cases h1 : j=1    · subst j      have h21 : (1 : F)+1 ≠ 1 := by        intro h        have hh : (1 : F)=0 := by linear_combination h        exact one_ne_zero hh      have h20 : (1 : F)+1 ≠ 0 := by intro h; apply htwo; linear_combination h      simp [in1249full_rectP, h20, h21]    · simp [in1249full_rectP, h0, h1]def in1249full_rectA (A B : ℝ) (j : F) : ℝ :=  if j=0 then A else if j= -1 then B else 0theorem in1249full_rect_twirl_algebra (r : F) (hr0 : r ≠ 0) (hr1 : r ≠ 1)    (hr2 : 2*r ≠ 1) (htwo : (2 : F) ≠ 0) (hdouble : 2*(1-r) ≠ 0) (A B : ℝ) (j l : F) :    A * in1249full_rectB r A B j * in1249full_rectA A B (j-l) * in1249full_rectB r A B (r*(j-l)+l) +    B * in1249full_rectB r A B (j-r) * in1249full_rectA A B (j-l-1) * in1249full_rectB r A B (r*(j-l-1)+l) =      in1249full_rectP A B j * in1249full_rectP A B l +        A^2*B^2 * (if j=l ∧ (j=r ∨ j=1-r) then 1 else 0) := by  have hneg : (-1 : F) ≠ 0 := neg_ne_zero.mpr one_ne_zero  have htwo' : (1 : F) ≠ -1 := by intro h; apply htwo; linear_combination h  have hm2 : (-1 : F) - 1 ≠ 0 := by intro h; apply htwo; linear_combination -h  have hm21 : (-1 : F) - 1 ≠ -1 := by    intro h    have hh : (1 : F) = 0 := by linear_combination -h    exact one_ne_zero hh  by_cases h0 : j=l  · subst l    simp only [sub_self, mul_zero, zero_add, zero_sub, in1249full_rectA, if_pos rfl, hneg, if_false, true_and]    simp only [if_true]    have he : r * (-1) + j = j-r := by ring    rw [he]    have hd := in1249full_rect_twirl_diagonal r hr0 hr1 hr2 A B j    nlinarith [hd]  · by_cases hp : j-l=1    · have hj : j=l+1 := by linear_combination hp      subst j      have hl : l+1 ≠ l := by        intro h        have hh : (1 : F) = 0 := by linear_combination h        exact one_ne_zero hh      simp only [add_sub_cancel_left, in1249full_rectA, one_ne_zero, htwo', if_false, sub_self, if_pos rfl,        mul_zero, zero_add, hl, false_and, ↓reduceIte, mul_zero, add_zero]      have hb := in1249full_rect_B_overlap r hr1 hdouble A B l      have hc := in1249full_rect_P_overlap htwo A B l      by_cases hz : l = 0      · simp only [if_pos hz] at hb hc        linear_combination (A*B)*hb - hc      · simp only [if_neg hz] at hb hc        linear_combination (A*B)*hb - hc    · by_cases hm : j-l= -1      · have hl : l=j+1 := by linear_combination -hm        subst l        have hj : j ≠ j+1 := by          intro h          have hh : (1 : F) = 0 := by linear_combination -h          exact one_ne_zero hh        have he : j-(j+1) = (-1 : F) := by ring        rw [he]        simp only [in1249full_rectA, hneg, if_false, if_pos rfl,          hm2, hm21, mul_zero, zero_add, hj, false_and, ↓reduceIte, add_zero]        have hb := in1249full_rect_B_overlap r hr1 hdouble A B j        have hc := in1249full_rect_P_overlap htwo A B j        have hzarg : r*(-1)+(j+1) = j+1-r := by ring        rw [hzarg]        by_cases hz : j = 0        · simp only [if_pos hz] at hb hc          linear_combination (A*B)*hb - hc        · simp only [if_neg hz] at hb hc          linear_combination (A*B)*hb - hc      · have hsub0 : j-l ≠ 0 := sub_ne_zero.mpr h0        have hsub10 : j-l-1 ≠ 0 := by intro h; apply hp; linear_combination h        have hsub1n : j-l-1 ≠ -1 := by intro h; apply hsub0; linear_combination h        have hP : in1249full_rectP A B j * in1249full_rectP A B l = 0 := by          simp only [in1249full_rectP]          split_ifs with a b c d <;> simp_all <;> try ring          all_goals exfalso <;> first | apply hp | apply hm | apply h0 <;> linear_combination a + b        simp [in1249full_rectA, hsub0, hm, hsub10, hsub1n, h0, hP]open Fin.CommRingdef in1249full_A (n : ℕ) (A B : ℝ) (i : Fin (n+2)) : ℝ :=  if i = 0 then A else if i = -1 then B else 0def in1249full_B (n : ℕ) (r : Fin (n+2)) (A B : ℝ) (i : Fin (n+2)) : ℝ :=  if i = 0 then A else if i = 1-r then B else 0def in1249full_P (n : ℕ) (A B : ℝ) (i : Fin (n+2)) : ℝ :=  if i = 0 then A^2 else if i = 1 then B^2 else 0theorem in1249full_twirl_support (n : ℕ) (r : Fin (n+2)) (A B : ℝ)    (j l : Fin (n+2)) :    (∑ i, in1249full_A n A B i * in1249full_B n r A B (r*i+j) *      in1249full_A n A B (i+j-l) * in1249full_B n r A B (r*(i+j-l)+l)) =    A * in1249full_B n r A B j * in1249full_A n A B (j-l) * in1249full_B n r A B (r*(j-l)+l) +    B * in1249full_B n r A B (j-r) * in1249full_A n A B (j-l-1) * in1249full_B n r A B (r*(j-l-1)+l) := by  have h01 : (0 : Fin (n+2)) ≠ -1 := by    intro h    have h1 : (1 : Fin (n+2)) = 0 := by linear_combination h    have h1v : ((1 : Fin (n+2)) : ℕ) = 1 := by simp    rw [h1] at h1v    simp at h1v  rw [Fintype.sum_eq_add 0 (-1) h01]  · have h10 : (-1 : Fin (n+2)) ≠ 0 := Ne.symm h01    simp only [in1249full_A, if_pos rfl, h01, h10, if_false, if_true]    congr 1 <;> congr 1 <;> congr 1 <;> try ring  · intro i ⟨hi0, hi1⟩    simp [in1249full_A, hi0, hi1]theorem in1249full_twirl_complete (n : ℕ) (r : Fin (n+2))    (hr0 : r ≠ 0) (hr1 : r ≠ 1) (hr2 : 2*r ≠ 1)    (htwo : (2 : Fin (n+2)) ≠ 0) (hdouble : 2*(1-r) ≠ 0)    (A B : ℝ) (j l : Fin (n+2)) :    (∑ i, in1249full_A n A B i * in1249full_B n r A B (r*i+j) *      in1249full_A n A B (i+j-l) * in1249full_B n r A B (r*(i+j-l)+l)) =      in1249full_P n A B j * in1249full_P n A B l +        A^2*B^2 * (if j=l ∧ (j=r ∨ j=1-r) then 1 else 0) := by  rw [in1249full_twirl_support]  exact in1249full_rect_twirl_algebra r hr0 hr1 hr2 htwo hdouble A B j ldef in1249full_basis (n : ℕ) (k : Fin (n+2)) (j : Fin (n+2)) : ℝ := if j=k then 1 else 0theorem in1249full_basis_orbit (n : ℕ) (r k j l : Fin (n+2)) :    (∑ i, in1249full_basis n 0 i * in1249full_basis n k (r*i+j) *      in1249full_basis n 0 (i+j-l) * in1249full_basis n k (r*(i+j-l)+l)) =      in1249full_basis n k j * in1249full_basis n k l := by  classical  rw [Finset.sum_eq_single 0]  · simp only [in1249full_basis, if_pos rfl, zero_mul, zero_add, one_mul]    by_cases h : j = l    · subst l      simp [in1249full_basis]    · have hsub : j-l ≠ 0 := sub_ne_zero.mpr h      simp [in1249full_basis, h, hsub]; aesop  · intro i _ hi    simp [in1249full_basis, hi]  · intro h    exact absurd (Finset.mem_univ _) htheorem in1249full_basis_choi_sep (n : ℕ) (r k : Fin (n+2)) :    matrix_is_separable (n+2) (n+2)      (prime_convolution_choi (n+2) r (Matrix.of fun j l => (in1249full_basis n k j * in1249full_basis n k l : ℂ))) := by  have h := in1243_twirl_sep n r (in1249full_basis n 0) (in1249full_basis n k)  convert h using 1  congr 1  ext j l  simp only [Matrix.of_apply, ← Complex.ofReal_mul]  exact congrArg (fun x : ℝ => (x : ℂ)) (in1249full_basis_orbit n r k j l).symmtheorem in1249full_diag_choi_sep (n : ℕ) (r : Fin (n+2)) (w : Fin (n+2) → ℝ)    (hw : ∀ j, 0 ≤ w j) :    matrix_is_separable (n+2) (n+2)      (prime_convolution_choi (n+2) r (Matrix.diagonal (fun j => (w j : ℂ)))) := by  classical  let D : Fin (n+2) → Matrix (Fin (n+2)) (Fin (n+2)) ℂ :=    fun k => Matrix.of fun j l => (in1249full_basis n k j * in1249full_basis n k l : ℂ)  have heq : Matrix.diagonal (fun j => (w j : ℂ)) = ∑ k ∈ Finset.univ, (w k : ℂ) • D k := by    ext j l    simp only [Matrix.diagonal_apply, Matrix.sum_apply, Matrix.smul_apply, smul_eq_mul, D, Matrix.of_apply,      in1249full_basis]    by_cases h : j = l    · subst l      rw [Finset.sum_eq_single j]      · simp      · intro k _ hj        have : j ≠ k := Ne.symm hj        simp [this]      · simp    · simp only [apply_ite (fun a : ℝ => (a : ℂ)), Complex.ofReal_one, Complex.ofReal_zero]      rw [Finset.sum_eq_zero]      · simp [h]      · intro k _        by_cases hj : j=k <;> by_cases hl : l=k <;> simp_all  rw [heq, in1243_choi_linear (n+2) (r : ZMod (n+2)) Finset.univ w D]  apply in1243_sep_sum  intro k _  exact in1243_sep_smul _ _ _ (hw k) _ (in1249full_basis_choi_sep n r k)theorem in1249full_prime_fin_nonzero (n : ℕ) (hp : (n+2).Prime) (h5 : 5 ≤ n+2)    (r : Fin (n+2)) (hr1 : r ≠ 1) :    (2 : Fin (n+2)) ≠ 0 ∧ 2*(1-r) ≠ 0 := by  letI : Fact (Nat.Prime (n+2)) := ⟨hp⟩  let e := ZMod.finEquiv (n+2)  have hz2 : (2 : ZMod (n+2)) ≠ 0 := by    intro h    have hdvd : n+2 ∣ 2 := (ZMod.natCast_eq_zero_iff 2 (n+2)).mp h    have hlt : 0 < 2 ∧ 2 < n+2 := by omega    exact (Nat.not_dvd_of_pos_of_lt hlt.1 hlt.2) hdvd  have he2 : e 2 = (2 : ZMod (n+2)) := by    calc e 2 = e (1 + 1) := by congr 1 <;> norm_num         _ = e 1 + e 1 := map_add e 1 1         _ = 2 := by simp only [map_one]; exact one_add_one_eq_two  have he1 : e (1-r) = 1 - e r := by simp [e]  have hfr : 1-e r ≠ 0 := by    intro h    have heq : e r = e 1 := by simpa using (sub_eq_zero.mp h).symm    exact hr1 (e.injective heq)  constructor  · intro h    have := congrArg e h    simp [he2] at this    exact hz2 this  · intro h    have hz : (2 : ZMod (n+2)) * (1-e r) = 0 := by      have := congrArg e h      simpa [he2,he1] using this    exact (mul_ne_zero hz2 hfr) hzopen Fin.CommRingtheorem in1249full_critical_orbit_decomposition    (n : ℕ) (hp : (n+2).Prime) (h5 : 5 ≤ n+2)    (r : Fin (n+2)) (hr0 : r ≠ 0) (hr1 : r ≠ 1) (hr2 : 2*r ≠ 1)    (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) :    ∃ (a b w : Fin (n+2) → ℝ), (∀ j, 0 ≤ w j) ∧      prime_convolution_critical_env (n+2) p =        (Matrix.of fun j l =>          ((∑ i, a i * b (r*i+j) * a (i+j-l) * b (r*(i+j-l)+l) : ℝ) : ℂ)) +        Matrix.diagonal (fun j => (w j : ℂ)) := by  classical  let A := Real.sqrt (Real.sqrt p)  let B := Real.sqrt (Real.sqrt (1-p))  let q := Real.sqrt (p*(1-p))  let a := in1249full_A n A B  let b := in1249full_B n r A B  let w : Fin (n+2) → ℝ := fun j => if j=r ∨ j=1-r then 0 else q  refine ⟨a,b,w, ?_, ?_⟩  · intro j    dsimp [w, q]    split_ifs <;> positivity  · have hp1' : 0 ≤ 1-p := by linarith    have ha : A^2 = Real.sqrt p := Real.sq_sqrt (Real.sqrt_nonneg p)    have hb : B^2 = Real.sqrt (1-p) := Real.sq_sqrt (Real.sqrt_nonneg (1-p))    have hq : A^2*B^2 = q := by      rw [ha,hb]      dsimp [q]      rw [Real.sqrt_mul hp0]    obtain ⟨htwo,hdouble⟩ := in1249full_prime_fin_nonzero n hp h5 r hr1    have hpsi (j : Fin (n+2)) : in1249full_P n A B j = two_level_psi (n+2) p j := by      have h0 : ((j : ℕ) = 0) ↔ j=0 := by        constructor        · intro h; apply Fin.ext; simpa using h        · intro h; subst j; rfl      have h1 : ((j : ℕ) = 1) ↔ j=1 := by        constructor        · intro h; apply Fin.ext; simpa using h        · intro h; subst j; simp      simp [in1249full_P, two_level_psi, h0,h1,ha,hb]    ext j l    rw [Matrix.add_apply, Matrix.of_apply, Matrix.diagonal_apply]    have ho := in1249full_twirl_complete n r hr0 hr1 hr2 htwo hdouble A B j l    change _ = ((∑ i, in1249full_A n A B i * in1249full_B n r A B (r*i+j) *      in1249full_A n A B (i+j-l) * in1249full_B n r A B (r*(i+j-l)+l) : ℝ) : ℂ) + _    rw [ho, hpsi j, hpsi l, hq]    simp only [prime_convolution_critical_env, Matrix.add_apply, Matrix.of_apply, Matrix.smul_apply,      smul_eq_mul, Matrix.one_apply]    dsimp [w]    by_cases hjl : j=l    · subst l      by_cases hj : j=r ∨ j=1-r      · simp [hj, q]      · simp [hj, q]    · simp [hjl]theorem in1249full_choi_add (d : ℕ) (r : ZMod d) (X Y : Matrix (Fin d) (Fin d) ℂ) :    prime_convolution_choi d r (X + Y) = prime_convolution_choi d r X + prime_convolution_choi d r Y := by  have h := in1243_choi_linear d r (Finset.univ : Finset (Fin 2)) (fun _ => (1 : ℝ)) ![X,Y]  simpa [Fin.sum_univ_two] using htheorem in1249full_choi_smul (d : ℕ) (r : ZMod d) (c : ℝ) (X : Matrix (Fin d) (Fin d) ℂ) :    prime_convolution_choi d r ((c : ℂ) • X) = (c : ℂ) • prime_convolution_choi d r X := by  have h := in1243_choi_linear d r (Finset.univ : Finset (Fin 1)) (fun _ => c) ![X]  simpa [Fin.sum_univ_one] using htheorem in1249full_critical_separable    (n : ℕ) (hp : (n+2).Prime) (h5 : 5 ≤ n+2)    (r : Fin (n+2)) (hr0 : r ≠ 0) (hr1 : r ≠ 1) (hr2 : 2*r ≠ 1)    (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) :    matrix_is_separable (n+2) (n+2)      (prime_convolution_choi (n+2) r (prime_convolution_critical_env (n+2) p)) := by  obtain ⟨a,b,w,hw,heq⟩ := in1249full_critical_orbit_decomposition n hp h5 r hr0 hr1 hr2 p hp0 hp1  rw [heq, in1249full_choi_add (n+2) (r : ZMod (n+2))]  apply in1243_sep_add  · exact in1243_twirl_sep n r a b  · exact in1249full_diag_choi_sep n r w hwtheorem in1249full_threshold_sufficient    (n : ℕ) (hp : (n+2).Prime) (h5 : 5 ≤ n+2)    (r : Fin (n+2)) (hr0 : r ≠ 0) (hr1 : r ≠ 1) (hr2 : 2*r ≠ 1)    (p t : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (ht0 : 0 ≤ t)    (ht : t ≤ 1 / (1 + (n+2 : ℕ) * Real.sqrt (p*(1-p)))) :    matrix_is_separable (n+2) (n+2)      (prime_convolution_choi (n+2) r (two_level_environment (n+2) p t)) := by  classical  let q := Real.sqrt (p*(1-p))  let c : ℝ := (1-t)/(n+2 : ℕ) - t*q  have hq : 0 ≤ q := Real.sqrt_nonneg _  have hd : (0 : ℝ) < (n+2 : ℕ) := by exact_mod_cast (by omega : 0 < n+2)  have hc : 0 ≤ c := by    have hb : 0 < 1 + ((n+2 : ℕ) : ℝ)*q := by positivity    have ht'' : t ≤ 1 / (1 + ((n+2 : ℕ) : ℝ)*q) := by simpa [q] using ht    have ht' := (le_div_iff₀ hb).mp ht''     dsimp [c]    rw [sub_nonneg, le_div_iff₀ hd]    push_cast at *    nlinarith  have henv : two_level_environment (n+2) p t =      (t : ℂ) • prime_convolution_critical_env (n+2) p +      Matrix.diagonal (fun _ => (c : ℂ)) := by    ext j l    simp only [two_level_environment, prime_convolution_critical_env, two_level_psi,      Matrix.of_apply, Matrix.add_apply, Matrix.smul_apply, Matrix.one_apply, Matrix.diagonal_apply,      smul_eq_mul]    set u : ℝ := if (j : ℕ) = 0 then Real.sqrt p else if (j : ℕ) = 1 then Real.sqrt (1-p) else 0    set v : ℝ := if (l : ℕ) = 0 then Real.sqrt p else if (l : ℕ) = 1 then Real.sqrt (1-p) else 0    dsimp [c,q]    by_cases h : j=l <;> simp [h] <;> push_cast <;> ring  rw [henv, in1249full_choi_add (n+2) (r : ZMod (n+2)), in1249full_choi_smul (n+2) (r : ZMod (n+2))]  apply in1243_sep_add  · exact in1243_sep_smul _ _ t ht0 _ (in1249full_critical_separable n hp h5 r hr0 hr1 hr2 p hp0 hp1)  · exact in1249full_diag_choi_sep n r (fun _ => c) (fun _ => hc)theorem prime_convolution_entanglement_breaking_iff_threshold :    ∀ d : ℕ, d.Prime → 5 ≤ d → ∀ r : ZMod d, r ≠ 0 → r ≠ 1 → 2 * r ≠ 1 →      ∀ p t : ℝ, 0 ≤ p → p ≤ 1 → 0 ≤ t → t ≤ 1 →        (matrix_is_separable d d (prime_convolution_choi d r (two_level_environment d p t)) ↔          t ≤ 1 / (1 + d * Real.sqrt (p * (1 - p)))) := by  intro d hp h5 r hr0 hr1 hr2 p t hp0 hp1 ht0 ht1  constructor  · exact prime_convolution_separable_imp_threshold d hp h5 r hr0 hr1 hr2 p t hp0 hp1 ht0 ht1  · intro ht    obtain ⟨n,rfl⟩ : ∃ n, d = n+2 := ⟨d-2, by omega⟩    exact in1249full_threshold_sufficient n hp h5 r hr0 hr1 hr2 p t hp0 hp1 ht0 ht
See it in the graphDiscuss this resultChallenge it