Holevo Additivity Gap in Lean 4

Lean explorer

Exact Lean source

Nonadditivity.InitialNetReduction

Download original .lean · View on GitHub · Jump to source

Relationships above come from literal import commands. The declarations below link to types and references extracted from Lean’s environment. Source text is complete and unchanged.

Declarations in this module

97 project constants, including generated, internal and private declarations.

97 declarations

Full module

1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.NetPolynomialSupport7import Nonadditivity.HaarMomentTail8import Nonadditivity.FreeEmbedding910/-! # The undoubled initial Gram construction for a symmetric test net1112The square coefficients have exactly `|B| * |J|` rows, and use only individual13branch words. The same coefficients are evaluated in finite representations14and on the actual infinite left regular Hilbert space.15-/1617noncomputable section18set_option backward.isDefEq.respectTransparency false19set_option maxHeartbeats 40000020set_option linter.unusedSectionVars false2122namespace Nonadditivity.InitialNetReduction23open scoped BigOperators ENNReal Matrix Matrix.Norms.L2Operator ComplexOrder MatrixOrder Kronecker24open FiniteSetFactorization (selector)25open RegularFactorization (term rectLift)2627section Construction28variable {G B J : Type} [Group G] [DecidableEq G]29  [Fintype B] [DecidableEq B] [Nonempty B] [Fintype J] [DecidableEq J]3031/-- The fixed, representation-independent positive coefficient matrix. -/32def gramMatrix (A : J → Matrix B B ℂ) : Matrix (B × J) (B × J) ℂ :=33  ((Fintype.card B : ℝ)⁻¹) • (1 + Matrix.blockDiagonal A)3435/-- A single fixed column is sufficient; no Hermitian doubling occurs. -/36def coefficient (A : J → Matrix B B ℂ) (b₀ b : B) : Matrix (B × J) (B × J) ℂ :=37  CFC.sqrt (gramMatrix A) * (selector (ι := J) b).conjTranspose * selector b₀3839def regularColumn (w : B → G) :40    RegularCoefficientEnergy.Hilbert G J →L[ℂ] RegularCoefficientEnergy.Hilbert G (B × J) :=41  ∑ b, term (selector (ι := J) b).conjTranspose (w b)4243def regularFactor (w : B → G) (A : J → Matrix B B ℂ) :44    RegularCoefficientEnergy.Hilbert G J →L[ℂ] RegularCoefficientEnergy.Hilbert G (B × J) :=45  (rectLift (CFC.sqrt (gramMatrix A))).comp (regularColumn w)4647def regularEval (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B) :=48  ∑ b, term (coefficient A b₀ b) (w b)4950def pairedCoefficient (A : J → Matrix B B ℂ) (p : B × B) (j : J) : ℂ :=51  (Fintype.card B : ℂ)⁻¹ * A j p.1 p.25253def pairedWord (w : B → G) (p : B × B) : G := (w p.1)⁻¹ * w p.25455def regularPaired (w : B → G) (A : J → Matrix B B ℂ) :=56  NetPolynomial.regularPolynomial (pairedWord w) (pairedCoefficient A)5758/-- Injective word substitution preserves the actual paired regular norm,59including the short free-group embedding used before tensor-factor reduction. -/60theorem regularPaired_injective_norm_eq {H : Type} [Group H] [DecidableEq H]61    (φ : G →* H) (hφ : Function.Injective φ) (w : B → G) (A : J → Matrix B B ℂ) :62    ‖regularPaired (fun b => φ (w b)) A‖ = ‖regularPaired w A‖ := by63  simpa only [regularPaired, NetPolynomial.regularPolynomial, pairedWord, map_mul, map_inv]64    using MatrixRegularRestriction.coefficientPolynomial_injective_norm_eq φ hφ65      (pairedWord w) (fun p => RegularCoefficientEnergy.coefficientOperator66        (NetPolynomial.diagonalCoefficient (pairedCoefficient A) p))6768theorem norm_le_hsLength (A : Matrix B B ℂ) (hA : A.IsHermitian) :69    ‖A‖ ≤ AdjointPurity.hsLength A := by70  have h := HaarMomentTail.norm_pow_le_trace_even A hA 171  simp only [show 2 * 1 = 2 by omega, pow_two] at h72  have hs := AdjointPurity.hsLength_sq_of_isHermitian A hA73  nlinarith [norm_nonneg A, AdjointPurity.hsLength_nonneg A]7475theorem gramMatrix_posSemidef (A : J → Matrix B B ℂ)76    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1) :77    (gramMatrix A).PosSemidef := by78  letI : CStarAlgebra (Matrix (B × J) (B × J) ℂ) := { }79  have hself : IsSelfAdjoint (Matrix.blockDiagonal A) :=80    (NetPolynomial.blockDiagonal_isHermitian A hA).isSelfAdjoint81  have hn : ‖Matrix.blockDiagonal A‖ ≤ 1 := by82    rw [NetPolynomial.blockDiagonal_norm]83    exact (pi_norm_le_iff_of_nonneg zero_le_one).mpr hnorm84  have hle := hself.neg_algebraMap_norm_le_self85  have hn' : -(1 : Matrix (B × J) (B × J) ℂ) ≤ Matrix.blockDiagonal A := by86    calc87      _ ≤ -algebraMap ℝ (Matrix (B × J) (B × J) ℂ) ‖Matrix.blockDiagonal A‖ := by88        apply neg_le_neg89        simpa only [Algebra.algebraMap_eq_smul_one, one_smul] using (smul_le_smul_of_nonneg_right hn (show (0 : Matrix (B × J) (B × J) ℂ) ≤ 1 from zero_le_one))90      _ ≤ _ := hle91  have hp : (1 + Matrix.blockDiagonal A).PosSemidef :=92    Matrix.LE.le.posSemidef (by simpa only [add_neg_cancel, add_comm] using add_le_add_left hn' 1)93  exact hp.smul (inv_nonneg.mpr (Nat.cast_nonneg _))9495theorem regularEval_eq (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B) :96    regularEval w A b₀ = (regularFactor w A).comp (rectLift (selector b₀)) := by97  unfold regularEval coefficient regularFactor regularColumn98  simp only [ContinuousLinearMap.comp_finset_sum, ContinuousLinearMap.finset_sum_comp]99  apply Finset.sum_congr rfl100  intro b _101  rw [← RegularFactorization.term_identity (G := G), RegularFactorization.term_mul,102    one_mul, ← RegularFactorization.term_identity (G := G),103    RegularFactorization.term_mul, mul_one]104105theorem regularEval_norm (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B) :106    ‖regularEval w A b₀‖ = ‖regularFactor w A‖ := by107  rw [regularEval_eq]108  apply RegularFactorization.norm_comp_coisometry109  rw [← RegularFactorization.rectLift_adjoint, ← RegularFactorization.rectLift_mul,110    FiniteSetFactorization.selector_mul_adjoint]111  simp112113theorem select_blockDiagonal (A : J → Matrix B B ℂ) (a b : B) :114    selector a * Matrix.blockDiagonal A * (selector b).conjTranspose =115      Matrix.diagonal (fun j => A j a b) := by116  ext j k117  by_cases hjk : j = k118  · subst k119    simp [Matrix.mul_apply, selector, Matrix.conjTranspose_apply, Matrix.blockDiagonal_apply,120      Fintype.sum_prod_type, eq_comm]121  · simp [Matrix.mul_apply, selector, Matrix.conjTranspose_apply, Matrix.blockDiagonal_apply,122      Fintype.sum_prod_type, eq_comm, hjk]123124theorem select_gramMatrix (A : J → Matrix B B ℂ) (a b : B) :125    selector a * gramMatrix A * (selector b).conjTranspose =126      ((Fintype.card B : ℝ)⁻¹) •127        ((if a = b then (1 : Matrix J J ℂ) else 0) + Matrix.diagonal (fun j => A j a b)) := by128  simp only [gramMatrix, Matrix.mul_smul, Matrix.smul_mul, Matrix.mul_add, Matrix.add_mul,129    Matrix.mul_one, FiniteSetFactorization.selector_mul_adjoint, select_blockDiagonal]130131/-- Evaluation of an arbitrary coefficient Gram matrix on the actual regular column. -/132theorem regularColumn_gram (w : B → G) (M : Matrix (B × J) (B × J) ℂ) :133    (regularColumn w).adjoint.comp ((rectLift M).comp (regularColumn w)) =134      ∑ a, ∑ b, term (selector a * M * (selector b).conjTranspose) ((w a)⁻¹ * w b) := by135  simp only [regularColumn, map_sum, ContinuousLinearMap.comp_finset_sum,136    ContinuousLinearMap.finset_sum_comp, RegularFactorization.term_adjoint,137    Matrix.conjTranspose_conjTranspose]138  rw [Finset.sum_comm]139  apply Finset.sum_congr rfl140  intro a _141  apply Finset.sum_congr rfl142  intro b _143  rw [← RegularFactorization.term_identity (G := G), RegularFactorization.term_mul,144    one_mul, RegularFactorization.term_mul]145  rw [Matrix.mul_assoc]146147theorem regularFactor_gram (w : B → G) (A : J → Matrix B B ℂ)148    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1) :149    (regularFactor w A).adjoint.comp (regularFactor w A) = regularPaired w A + 1 := by150  have hs := Linearization.positive_sqrt_gram (gramMatrix A) (gramMatrix_posSemidef A hA hnorm)151  rw [regularFactor, ContinuousLinearMap.adjoint_comp, ← RegularFactorization.rectLift_adjoint]152  rw [ContinuousLinearMap.comp_assoc,153    ← ContinuousLinearMap.comp_assoc (rectLift _),154    ← RegularFactorization.rectLift_mul, hs, regularColumn_gram]155  simp_rw [select_gramMatrix, RegularFactorization.term_smul, RegularFactorization.term_add]156  simp only [← Finset.smul_sum, Finset.sum_add_distrib]157  have hid : (∑ a : B, ∑ b : B, term (if a = b then (1 : Matrix J J ℂ) else 0)158      ((w a)⁻¹ * w b)) = (Fintype.card B : ℝ) • (1 :159        RegularCoefficientEnergy.Hilbert G J →L[ℂ] RegularCoefficientEnergy.Hilbert G J) := by160    have ht (a b : B) : term (if a = b then (1 : Matrix J J ℂ) else 0) ((w a)⁻¹ * w b) =161        if a = b then (1 : RegularCoefficientEnergy.Hilbert G J →L[ℂ] _) else 0 := by162      split_ifs with hab163      · subst b; simp164      · simp165    simp_rw [ht]166    simp [Nat.cast_smul_eq_nsmul]167  rw [hid, smul_add, smul_smul, inv_mul_cancel₀ (by exact_mod_cast Fintype.card_ne_zero), one_smul]168  rw [add_comm]169  congr 1170  rw [regularPaired, NetPolynomial.regularPolynomial_eq_terms, Fintype.sum_prod_type]171  simp only [Finset.smul_sum]172  apply Finset.sum_congr rfl173  intro a _174  apply Finset.sum_congr rfl175  intro b _176  rw [← RegularFactorization.term_smul]177  congr 1178  ext j k179  simp [NetPolynomial.diagonalCoefficient, pairedCoefficient, Matrix.diagonal_apply,180    Matrix.smul_apply]181182183theorem regularPaired_selfAdjoint (w : B → G) (A : J → Matrix B B ℂ)184    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1) :185    IsSelfAdjoint (regularPaired w A) := by186  have h : IsSelfAdjoint (regularPaired w A + 1) := by187    change (regularPaired w A + 1).adjoint = regularPaired w A + 1188    rw [← regularFactor_gram w A hA hnorm]189    simp190  simpa only [add_sub_cancel_right] using h.sub (IsSelfAdjoint.one _)191192theorem regularPaired_shifted_norm [Nonempty J] (w : B → G) (A : J → Matrix B B ℂ)193    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1)194    (e : J ≃ J) (he : ∀ j, A (e j) = -A j) :195    ‖regularPaired w A + 1‖ = ‖regularPaired w A‖ + 1 := by196  have hsym : spectrum ℝ (-regularPaired w A) = spectrum ℝ (regularPaired w A) := by197    apply NetPolynomial.regularPolynomial_spectrum_neg _ _ e198    intro p j199    simp [pairedCoefficient, he]200  have hm : ‖regularPaired w A‖ ∈ spectrum ℝ (regularPaired w A) := by201    rcases CStarAlgebra.norm_or_neg_norm_mem_spectrum (regularPaired_selfAdjoint w A hA hnorm) with h | h202    · exact h203    · have hh : ‖regularPaired w A‖ ∈ spectrum ℝ (-regularPaired w A) := by204        rw [← spectrum.neg_eq]205        exact h206      rwa [hsym] at hh207  simpa using NetPolynomial.shifted_norm_of_norm_mem_spectrum (regularPaired w A) hm 1 zero_le_one208209/-- Exact initial Gram identity at the genuine regular representation, with no doubling. -/210theorem regularEval_norm_sq [Nonempty J] (w : B → G) (A : J → Matrix B B ℂ)211    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1)212    (e : J ≃ J) (he : ∀ j, A (e j) = -A j) (b₀ : B) :213    ‖regularEval w A b₀‖ ^ 2 = ‖regularPaired w A‖ + 1 := by214  rw [regularEval_norm, pow_two, ← ContinuousLinearMap.norm_adjoint_comp_self,215    regularFactor_gram w A hA hnorm, regularPaired_shifted_norm w A hA hnorm e he]216217section Finite218variable {V : Type*} [Fintype V] [DecidableEq V]219220def finiteFactor (U : B → unitary (Matrix V V ℂ)) (A : J → Matrix B B ℂ) :221    Matrix ((B × J) × V) (J × V) ℂ :=222  (CFC.sqrt (gramMatrix A) ⊗ₖ (1 : Matrix V V ℂ)) * FiniteSetFactorization.unitaryColumn U223224def finiteEval (U : B → unitary (Matrix V V ℂ)) (A : J → Matrix B B ℂ) (b₀ : B) :225    Matrix ((B × J) × V) ((B × J) × V) ℂ :=226  ∑ b, coefficient A b₀ b ⊗ₖ (U b : Matrix V V ℂ)227228def finitePaired (U : B → unitary (Matrix V V ℂ)) (A : J → Matrix B B ℂ) :229    Matrix (J × V) (J × V) ℂ :=230  ∑ a, ∑ b, Matrix.diagonal (fun j => (Fintype.card B : ℂ)⁻¹ * A j a b) ⊗ₖ231    ((U a : Matrix V V ℂ).conjTranspose * (U b : Matrix V V ℂ))232233theorem finiteEval_eq (U : B → unitary (Matrix V V ℂ))234    (A : J → Matrix B B ℂ) (b₀ : B) :235    finiteEval U A b₀ = finiteFactor U A * (selector b₀ ⊗ₖ (1 : Matrix V V ℂ)) := by236  unfold finiteEval finiteFactor coefficient FiniteSetFactorization.unitaryColumn237  simp only [Matrix.mul_sum, Matrix.sum_mul, ← Matrix.mul_kronecker_mul,238    Matrix.one_mul, Matrix.mul_one, Matrix.mul_assoc]239240theorem finiteEval_norm (U : B → unitary (Matrix V V ℂ))241    (A : J → Matrix B B ℂ) (b₀ : B) :242    ‖finiteEval U A b₀‖ = ‖finiteFactor U A‖ := by243  rw [finiteEval_eq]244  apply Linearization.right_isometry_mul_norm245  simp [Matrix.conjTranspose_kronecker, ← Matrix.mul_kronecker_mul,246    FiniteSetFactorization.selector_mul_adjoint]247248theorem finiteColumn_gram (U : B → unitary (Matrix V V ℂ))249    (M : Matrix (B × J) (B × J) ℂ) :250    FiniteSetFactorization.evaluate U M =251      ∑ a, ∑ b, (selector a * M * (selector b).conjTranspose) ⊗ₖ252        ((U a : Matrix V V ℂ).conjTranspose * (U b : Matrix V V ℂ)) := by253  simp only [FiniteSetFactorization.evaluate, FiniteSetFactorization.unitaryColumn,254    Matrix.conjTranspose_sum, Matrix.sum_mul, Matrix.mul_sum,255    Matrix.conjTranspose_kronecker, Matrix.conjTranspose_conjTranspose,256    ← Matrix.mul_kronecker_mul, Matrix.mul_one]257  exact Finset.sum_comm258259theorem finiteFactor_gram (U : B → unitary (Matrix V V ℂ))260    (A : J → Matrix B B ℂ) (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1) :261    (finiteFactor U A).conjTranspose * finiteFactor U A = finitePaired U A + 1 := by262  have hs := Linearization.positive_sqrt_gram (gramMatrix A) (gramMatrix_posSemidef A hA hnorm)263  rw [finiteFactor, Linearization.gram_factorization]264  simp only [Matrix.conjTranspose_kronecker, ← Matrix.mul_kronecker_mul,265    Matrix.conjTranspose_one, Matrix.one_mul, hs]266  rw [← FiniteSetFactorization.evaluate, finiteColumn_gram]267  simp_rw [select_gramMatrix, Matrix.smul_kronecker, Matrix.add_kronecker]268  simp only [← Finset.smul_sum, Finset.sum_add_distrib]269  have hid : (∑ a : B, ∑ b : B, (if a = b then (1 : Matrix J J ℂ) else 0) ⊗ₖ270      ((U a : Matrix V V ℂ).conjTranspose * (U b : Matrix V V ℂ))) =271        (Fintype.card B : ℝ) • (1 : Matrix (J × V) (J × V) ℂ) := by272    have ht (a b : B) : (if a = b then (1 : Matrix J J ℂ) else 0) ⊗ₖ273        ((U a : Matrix V V ℂ).conjTranspose * (U b : Matrix V V ℂ)) =274          if a = b then (1 : Matrix (J × V) (J × V) ℂ) else 0 := by275      split_ifs with hab276      · subst b; simp [← Matrix.star_eq_conjTranspose]277      · simp278    simp_rw [ht]279    simp [Nat.cast_smul_eq_nsmul]280  rw [hid, smul_add, smul_smul, inv_mul_cancel₀ (by exact_mod_cast Fintype.card_ne_zero), one_smul]281  rw [add_comm]282  congr 1283  unfold finitePaired284  simp only [Finset.smul_sum, ← Matrix.smul_kronecker]285  apply Finset.sum_congr rfl286  intro a _287  apply Finset.sum_congr rfl288  intro b _289  congr 1290  ext j k291  simp [Matrix.diagonal_apply, Matrix.smul_apply]292293theorem finiteEval_norm_sq (U : B → unitary (Matrix V V ℂ))294    (A : J → Matrix B B ℂ) (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1)295    (b₀ : B) : ‖finiteEval U A b₀‖ ^ 2 = ‖finitePaired U A + 1‖ := by296  rw [finiteEval_norm, pow_two, ← Matrix.l2_opNorm_conjTranspose_mul_self,297    finiteFactor_gram U A hA hnorm]298299theorem finitePaired_selfAdjoint (U : B → unitary (Matrix V V ℂ))300    (A : J → Matrix B B ℂ) (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1) :301    IsSelfAdjoint (finitePaired U A) := by302  have h : IsSelfAdjoint (finitePaired U A + 1) := by303    change (finitePaired U A + 1).conjTranspose = finitePaired U A + 1304    rw [← finiteFactor_gram U A hA hnorm]305    simp306  simpa only [add_sub_cancel_right] using h.sub (IsSelfAdjoint.one _)307308theorem finitePaired_negation_reindex (U : B → unitary (Matrix V V ℂ))309    (A : J → Matrix B B ℂ) (e : J ≃ J) (he : ∀ j, A (e j) = -A j) :310    (finitePaired U A).submatrix (Equiv.prodCongr e (Equiv.refl V))311      (Equiv.prodCongr e (Equiv.refl V)) = -finitePaired U A := by312  ext ⟨j,x⟩ ⟨k,y⟩313  simp only [finitePaired, Matrix.submatrix_apply, Equiv.prodCongr_apply,314    Matrix.sum_apply, Matrix.kronecker_apply, Matrix.diagonal_apply, Matrix.neg_apply]315  by_cases h : j = k316  · subst k317    simp [he]318  · simp [h]319320theorem finitePaired_shifted_norm [Nonempty J] [Nonempty V]321    (U : B → unitary (Matrix V V ℂ)) (A : J → Matrix B B ℂ)322    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1)323    (e : J ≃ J) (he : ∀ j, A (e j) = -A j) :324    ‖finitePaired U A + 1‖ = ‖finitePaired U A‖ + 1 := by325  letI : CStarAlgebra (Matrix (J × V) (J × V) ℂ) := { }326  have hsym : spectrum ℝ (-finitePaired U A) = spectrum ℝ (finitePaired U A) := by327    let q := MatrixNormReindex.reindexStarAlgEquiv (Equiv.prodCongr e (Equiv.refl V)).symm328    have hq : q (finitePaired U A) = -finitePaired U A := finitePaired_negation_reindex U A e he329    rw [← hq]330    exact AlgEquiv.spectrum_eq (q.toAlgEquiv.restrictScalars ℝ) _331  have hm : ‖finitePaired U A‖ ∈ spectrum ℝ (finitePaired U A) := by332    rcases CStarAlgebra.norm_or_neg_norm_mem_spectrum (finitePaired_selfAdjoint U A hA hnorm) with h | h333    · exact h334    · have hh : ‖finitePaired U A‖ ∈ spectrum ℝ (-finitePaired U A) := by335        rw [← spectrum.neg_eq]336        exact h337      rwa [hsym] at hh338  apply le_antisymm339  · simpa using norm_add_le (finitePaired U A) 1340  · have hh : ‖finitePaired U A‖ + 1 ∈ spectrum ℝ (finitePaired U A + 1) := by341      rw [← map_one (algebraMap ℝ (Matrix (J × V) (J × V) ℂ)), ← spectrum.add_singleton_eq]342      exact Set.add_mem_add hm (Set.mem_singleton 1)343    simpa only [Real.norm_eq_abs, abs_of_nonneg (by positivity : 0 ≤ ‖finitePaired U A‖ + 1)]344      using spectrum.norm_le_norm_of_mem hh345346/-- Exact initial Gram identity at every finite unitary representation. -/347theorem finiteEval_norm_sq_symmetric [Nonempty J] [Nonempty V]348    (U : B → unitary (Matrix V V ℂ)) (A : J → Matrix B B ℂ)349    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1)350    (e : J ≃ J) (he : ∀ j, A (e j) = -A j) (b₀ : B) :351    ‖finiteEval U A b₀‖ ^ 2 = ‖finitePaired U A‖ + 1 := by352  rw [finiteEval_norm_sq U A hA hnorm, finitePaired_shifted_norm U A hA hnorm e he]353354/-- Swapping the two tensor coordinates identifies the paired matrix with355exactly the finite direct sum of the scalar observable tests. -/356theorem finitePaired_swap (U : B → unitary (Matrix V V ℂ)) (A : J → Matrix B B ℂ) :357    (finitePaired U A).submatrix (Equiv.prodComm V J) (Equiv.prodComm V J) =358      NetPolynomial.finitePolynomial359        (fun p : B × B => (U p.1 : Matrix V V ℂ).conjTranspose * (U p.2 : Matrix V V ℂ))360        (pairedCoefficient A) := by361  ext ⟨x,j⟩ ⟨y,k⟩362  simp only [finitePaired, NetPolynomial.finitePolynomial, Fintype.sum_prod_type,363    Matrix.submatrix_apply, Equiv.prodComm_apply, Prod.swap_prod_mk, Matrix.sum_apply,364    Matrix.kronecker_apply, NetPolynomial.diagonalCoefficient, Matrix.diagonal_apply]365  apply Finset.sum_congr rfl366  intro a _367  apply Finset.sum_congr rfl368  intro b _369  exact mul_comm _ _370371/-- The finite paired polynomial has exactly the maximum test norm. -/372theorem finitePaired_norm (U : B → unitary (Matrix V V ℂ)) (A : J → Matrix B B ℂ) :373    ‖finitePaired U A‖ =374      ‖fun j => ∑ a, ∑ b, ((Fintype.card B : ℂ)⁻¹ * A j a b) •375        ((U a : Matrix V V ℂ).conjTranspose * (U b : Matrix V V ℂ))‖ := by376  rw [← MatrixNormReindex.submatrix_equiv_norm (Equiv.prodComm V J) (finitePaired U A),377    finitePaired_swap, NetPolynomial.finitePolynomial_norm]378  simp only [Fintype.sum_prod_type, pairedCoefficient]379380end Finite381382section Collection383variable [Nonempty J]384385def collectedCoefficient (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B) (g : G) :386    Matrix (B × J) (B × J) ℂ := ∑ b, if w b = g then coefficient A b₀ b else 0387388/-- The actual polynomial record to which subsequent support reductions apply. -/389def polynomial (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B) :390    PolynomialReduction.Polynomial G where391  Index := B × J392  fintype := inferInstance393  decEq := inferInstance394  nonempty := inferInstance395  support := Finset.univ.image w396  coefficient := collectedCoefficient w A b₀397398@[simp] theorem polynomial_dimension (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B) :399    Fintype.card (polynomial w A b₀).Index = Fintype.card B * Fintype.card J :=400  Fintype.card_prod _ _401402@[simp] theorem polynomial_support (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B) :403    (polynomial w A b₀).support = Finset.univ.image w := rfl404405private theorem collection_sum {E : Type*} [AddCommMonoid E]406    (w : B → G) (f : B → G → E) :407    ∑ g ∈ Finset.univ.image w, ∑ b, (if w b = g then f b g else 0) = ∑ b, f b (w b) := by408  rw [Finset.sum_comm]409  apply Finset.sum_congr rfl410  intro b _411  rw [Finset.sum_ite_eq]412  simp413414@[simp] theorem polynomial_regularEval (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B) :415    (polynomial w A b₀).regularEval = regularEval w A b₀ := by416  change RegularCoefficientEnergy.regularPolynomial _ _ = _417  rw [RegularFactorization.polynomial_eq]418  simp only [polynomial, collectedCoefficient]419  have ht (g : G) : term (∑ b, if w b = g then coefficient A b₀ b else 0) g =420      ∑ b, if w b = g then term (coefficient A b₀ b) g else 0 := by421    simp only [term, RegularFactorization.rectLift_sum, ContinuousLinearMap.finset_sum_comp]422    apply Finset.sum_congr rfl423    intro b _424    split_ifs <;> simp425  simp_rw [ht]426  exact collection_sum w (fun b g => term (coefficient A b₀ b) g)427428@[simp] theorem polynomial_finiteEval {V : Type*} [Fintype V] [DecidableEq V]429    (w : B → G) (A : J → Matrix B B ℂ) (b₀ : B)430    (π : G →* unitary (Matrix V V ℂ)) :431    (polynomial w A b₀).finiteEval π = finiteEval (fun b => π (w b)) A b₀ := by432  ext x y433  change (∑ g ∈ Finset.univ.image w, collectedCoefficient w A b₀ g ⊗ₖ434    (π g : Matrix V V ℂ)) x y = (finiteEval (fun b => π (w b)) A b₀) x y435  rcases x with ⟨x,x'⟩436  rcases y with ⟨y,y'⟩437  simp only [finiteEval, Matrix.sum_apply, Matrix.kronecker_apply, collectedCoefficient,438    Finset.sum_mul, Matrix.ite_apply, Matrix.zero_apply, ite_mul, zero_mul]439  exact collection_sum w (fun b g => coefficient A b₀ b x y * (π g : Matrix V V ℂ) x' y')440441/-- Initial backward transfer with its exact additive constant one. All norm442identities refer to the coefficients constructed above and are proved internally. -/443theorem initial_backward_transfer {V : Type*} [Fintype V] [DecidableEq V] [Nonempty V]444    (w : B → G) (A : J → Matrix B B ℂ)445    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1)446    (e : J ≃ J) (he : ∀ j, A (e j) = -A j) (b₀ : B)447    (π : G →* unitary (Matrix V V ℂ)) (ε : ℝ) (hε : 0 ≤ ε) (hε1 : ε ≤ 1)448    (hQ : ‖(polynomial w A b₀).finiteEval π‖ ≤ (1+ε) * ‖(polynomial w A b₀).regularEval‖) :449    ‖finitePaired (fun b => π (w b)) A‖ - ‖regularPaired w A‖ ≤450      3 * ε * (1 + ‖regularPaired w A‖) := by451  rw [polynomial_finiteEval, polynomial_regularEval] at hQ452  exact Linearization.initial_backward_error453    ‖finitePaired (fun b => π (w b)) A‖ ‖regularPaired w A‖454    ‖finiteEval (fun b => π (w b)) A b₀‖ ‖regularEval w A b₀‖ ε455    (norm_nonneg _) (norm_nonneg _) hε hε1456    (finiteEval_norm_sq_symmetric _ A hA hnorm e he b₀)457    (regularEval_norm_sq w A hA hnorm e he b₀) hQ458459/-- The manuscript's initial relative-error factor `3(1+1/rho)` for the460actual, undoubled polynomial. -/461theorem initial_relative_transfer {V : Type*} [Fintype V] [DecidableEq V] [Nonempty V]462    (w : B → G) (A : J → Matrix B B ℂ)463    (hA : ∀ j, (A j).IsHermitian) (hnorm : ∀ j, ‖A j‖ ≤ 1)464    (e : J ≃ J) (he : ∀ j, A (e j) = -A j) (b₀ : B)465    (π : G →* unitary (Matrix V V ℂ)) (ε ρ : ℝ)466    (hε : 0 ≤ ε) (hε1 : ε ≤ 1) (hρ : 0 < ρ) (hr : ρ ≤ ‖regularPaired w A‖)467    (hQ : ‖(polynomial w A b₀).finiteEval π‖ ≤ (1+ε) * ‖(polynomial w A b₀).regularEval‖) :468    ‖finitePaired (fun b => π (w b)) A‖ ≤469      (1 + 3 * (1 + 1/ρ) * ε) * ‖regularPaired w A‖ := by470  have hb := initial_backward_transfer w A hA hnorm e he b₀ π ε hε hε1 hQ471  have hs : 1 ≤ ‖regularPaired w A‖ / ρ := (le_div_iff₀ hρ).mpr (by simpa using hr)472  have hm := mul_le_mul_of_nonneg_left hs (show 0 ≤ 3*ε by positivity)473  simp only [div_eq_mul_inv] at hm ⊢474  nlinarith475end Collection476477end Construction478479section Nets480open FreeModel FiniteRealization481variable {K n : ℕ}482local instance (tests : Finset (ObservableSpace (Branch K n))) : DecidableEq tests := Classical.decEq _483484/-- The generic paired polynomial is exactly the manuscript's test polynomial. -/485theorem net_regularPaired_eq (tests : Finset (ObservableSpace (Branch K n))) :486    regularPaired (branchWord (K := K) (n := n)) (fun j : tests => observableMatrix j.val) =487      NetPolynomial.netRegularPolynomial tests := by488  classical489  unfold regularPaired NetPolynomial.netRegularPolynomial NetPolynomial.regularTestPolynomial490  congr 1491  funext p j492  simp [pairedCoefficient, NetPolynomial.testCoefficient, Branch, one_div]493494set_option maxHeartbeats 1000000 in495/-- Construction of the initial polynomial with the exact undoubled coefficient496size and individual-word support, specialized to an actual symmetric observable net. -/497theorem exists_initial_net_polynomial (hK : 0 < K)498    (tests : Finset (ObservableSpace (Branch K n))) (hne : tests.Nonempty)499    (hnorm : ∀ x ∈ tests, ‖x‖ = 1) (hsymm : ∀ x ∈ tests, -x ∈ tests) :500    ∃ Q : PolynomialReduction.Polynomial (ProductFreeGroup K n),501      Fintype.card Q.Index = tests.card * K^n ∧502      Q.support = Finset.univ.image (branchWord (K := K) (n := n)) ∧503      ‖Q.regularEval‖ ^ 2 = ‖NetPolynomial.netRegularPolynomial tests‖ + 1 ∧504      ∀ (V : Type) [Fintype V] [DecidableEq V] [Nonempty V]505        (π : ProductFreeGroup K n →* unitary (Matrix V V ℂ)),506        ‖Q.finiteEval π‖ ^ 2 =507          ‖finitePaired (fun b => π (branchWord b)) (fun j : tests => observableMatrix j.val)‖ + 1 := by508  classical509  letI : Nonempty tests := hne.to_subtype510  letI : NeZero K := ⟨Nat.ne_of_gt hK⟩511  let A : tests → Matrix (Branch K n) (Branch K n) ℂ := fun j => observableMatrix j.val512  let b₀ : Branch K n := fun _ => ⟨0,hK⟩513  have hA : ∀ j, (A j).IsHermitian := fun j => observableMatrix_isHermitian j.val514  have hAn : ∀ j, ‖A j‖ ≤ 1 := by515    intro j516    have hhs : AdjointPurity.hsLength (A j) = 1 := by517      rw [← observable_norm_eq_hsLength]518      exact hnorm j.val j.property519    exact (norm_le_hsLength (A j) (hA j)).trans hhs.le520  let e := NetPolynomial.netNegationEquiv tests hsymm521  have he : ∀ j, A (e j) = -A j := fun _ => rfl522  refine ⟨polynomial branchWord A b₀, ?_, rfl, ?_, ?_⟩523  · simp only [polynomial_dimension, Fintype.card_coe, Branch, Fintype.card_fun,524      Fintype.card_fin, Nat.mul_comm]525  · rw [polynomial_regularEval, regularEval_norm_sq branchWord A hA hAn e he b₀]526    rw [show regularPaired branchWord A = NetPolynomial.netRegularPolynomial tests from527      net_regularPaired_eq tests]528  · intro V _ _ _ π529    rw [polynomial_finiteEval, finiteEval_norm_sq_symmetric _ A hA hAn e he b₀]530531end Nets532533534section ShortWords535536/-- Relabeling generators never increases reduced word length. -/537theorem norm_freeGroup_map_le {α β : Type*} [DecidableEq α] [DecidableEq β]538    (f : α → β) (w : FreeGroup α) : FreeGroup.norm (FreeGroup.map f w) ≤ FreeGroup.norm w := by539  calc540    FreeGroup.norm (FreeGroup.map f w) =541        FreeGroup.norm (FreeGroup.mk (w.toWord.map fun x => (f x.1,x.2))) := by542      rw [← FreeGroup.map.mk, FreeGroup.mk_toWord]543    _ ≤ _ := FreeGroup.norm_mk_le.trans (by simp [FreeGroup.norm])544545/-- The actual logarithmic-length embedding with the target generators named546`Fin 2`, as required by the one-factor support and linear-polynomial APIs. -/547def shortEmbedding (K : ℕ) (hK : 2 ≤ K) : FreeGroup (Fin K) →* FreeGroup (Fin 2) :=548  (FreeGroup.freeGroupCongr finTwoEquiv.symm).toMonoidHom.comp (FreeEmbedding.logarithmicEmbedding K hK)549550theorem shortEmbedding_injective (K : ℕ) (hK : 2 ≤ K) :551    Function.Injective (shortEmbedding K hK) :=552  (FreeGroup.freeGroupCongr finTwoEquiv.symm).injective.comp (FreeEmbedding.logarithmicEmbedding_injective K hK)553554def shortWord (K : ℕ) (hK : 2 ≤ K) (a : Fin K) : FreeGroup (Fin 2) :=555  shortEmbedding K hK (FreeGroup.of a)556557theorem shortWord_norm_le (K : ℕ) (hK : 2 ≤ K) (a : Fin K) :558    FreeGroup.norm (shortWord K hK a) ≤ 2 * Nat.log 2 (K-1) + 1 := by559  exact (norm_freeGroup_map_le finTwoEquiv.symm560    (FreeEmbedding.logarithmicEmbedding K hK (FreeGroup.of a))).trans561      (FreeEmbedding.norm_logarithmicEmbedding_of_le K hK a)562563def shortProductEmbedding (K n : ℕ) (hK : 2 ≤ K) :564    FreeModel.ProductFreeGroup K n →* (Fin n → FreeGroup (Fin 2)) where565  toFun g i := shortEmbedding K hK (g i)566  map_one' := by ext i; exact map_one _567  map_mul' g h := by ext i; exact map_mul _ _ _568569theorem shortProductEmbedding_injective (K n : ℕ) (hK : 2 ≤ K) :570    Function.Injective (shortProductEmbedding K n hK) := by571  intro g h hgh572  funext i573  exact shortEmbedding_injective K hK (congrFun hgh i)574575@[simp] theorem shortProductEmbedding_branchWord (K n : ℕ) (hK : 2 ≤ K)576    (a : FreeModel.Branch K n) :577    shortProductEmbedding K n hK (FreeModel.branchWord a) = fun i => shortWord K hK (a i) := rfl578579end ShortWords580581end Nonadditivity.InitialNetReduction