import Mathlib namespace QuantumParallelRepetition noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder open Matrix variable {X Y A B : Type*} structure Game (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] where questionWeight : X → Y → ℝ weight_nonneg : ∀ x y, 0 ≤ questionWeight x y weight_normalized : (∑ x : X, ∑ y : Y, questionWeight x y) = 1 predicate : X → Y → A → B → Bool namespace Game variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def marginalX (G : Game X Y A B) (x : X) : ℝ := ∑ y : Y, G.questionWeight x y def marginalY (G : Game X Y A B) (y : Y) : ℝ := ∑ x : X, G.questionWeight x y theorem marginalX_nonneg (G : Game X Y A B) (x : X) : 0 ≤ G.marginalX x := by unfold marginalX exact Finset.sum_nonneg fun y _ => G.weight_nonneg x y theorem marginalY_nonneg (G : Game X Y A B) (y : Y) : 0 ≤ G.marginalY y := by unfold marginalY exact Finset.sum_nonneg fun x _ => G.weight_nonneg x y theorem marginalX_normalized (G : Game X Y A B) : (∑ x : X, G.marginalX x) = 1 := by simpa [marginalX] using G.weight_normalized theorem marginalY_normalized (G : Game X Y A B) : (∑ y : Y, G.marginalY y) = 1 := by unfold marginalY rw [Finset.sum_comm] exact G.weight_normalized def «repeat» (G : Game X Y A B) (n : ℕ) : Game (Fin n → X) (Fin n → Y) (Fin n → A) (Fin n → B) where questionWeight xs ys := ∏ i : Fin n, G.questionWeight (xs i) (ys i) weight_nonneg xs ys := Finset.prod_nonneg fun i _ => G.weight_nonneg (xs i) (ys i) weight_normalized := by classical calc (∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∏ i : Fin n, G.questionWeight (xs i) (ys i)) = ∑ xs : Fin n → X, ∏ i : Fin n, ∑ y : Y, G.questionWeight (xs i) y := by apply Finset.sum_congr rfl intro xs _ exact (Fintype.prod_sum (fun i : Fin n => fun y : Y => G.questionWeight (xs i) y)).symm _ = ∏ _i : Fin n, ∑ x : X, ∑ y : Y, G.questionWeight x y := by exact (Fintype.prod_sum (fun _i : Fin n => fun x : X => ∑ y : Y, G.questionWeight x y)).symm _ = 1 := by simp [G.weight_normalized] predicate xs ys as bs := decide (∀ i : Fin n, G.predicate (xs i) (ys i) (as i) (bs i) = true) @[simp] theorem repeat_questionWeight (G : Game X Y A B) (n : ℕ) (xs : Fin n → X) (ys : Fin n → Y) : (G.repeat n).questionWeight xs ys = ∏ i : Fin n, G.questionWeight (xs i) (ys i) := rfl @[simp] theorem repeat_predicate_eq_true (G : Game X Y A B) (n : ℕ) (xs : Fin n → X) (ys : Fin n → Y) (as : Fin n → A) (bs : Fin n → B) : (G.repeat n).predicate xs ys as bs = true ↔ ∀ i : Fin n, G.predicate (xs i) (ys i) (as i) (bs i) = true := by simp [«repeat»] end Game structure DensityMatrix (d : Type*) [Fintype d] where matrix : Matrix d d ℂ positive : matrix.PosSemidef trace_one : Matrix.trace matrix = 1 structure POVM (ι d : Type*) [Fintype ι] [Fintype d] [DecidableEq d] where effect : ι → Matrix d d ℂ positive : ∀ i, (effect i).PosSemidef complete : (∑ i : ι, effect i) = 1 structure Strategy [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (_G : Game X Y A B) where Alice : Type Bob : Type [alice_fintype : Fintype Alice] [bob_fintype : Fintype Bob] [alice_decidableEq : DecidableEq Alice] [bob_decidableEq : DecidableEq Bob] state : DensityMatrix (Alice × Bob) aliceMeasurement : X → POVM A Alice bobMeasurement : Y → POVM B Bob attribute [instance] Strategy.alice_fintype Strategy.bob_fintype Strategy.alice_decidableEq Strategy.bob_decidableEq theorem trace_mul_posSemidef_nonneg {d : Type*} [Fintype d] [DecidableEq d] {R E : Matrix d d ℂ} (hR : R.PosSemidef) (hE : E.PosSemidef) : 0 ≤ (Matrix.trace (R * E)).re := by obtain ⟨K, rfl⟩ := CStarAlgebra.nonneg_iff_eq_star_mul_self.mp hR.nonneg have hpositive : (K * E * star K).PosSemidef := by simpa [star_eq_conjTranspose] using hE.mul_mul_conjTranspose_same K have htrace : 0 ≤ (Matrix.trace (K * E * star K)).re := (Complex.nonneg_iff.mp hpositive.trace_nonneg).1 rw [Matrix.trace_mul_cycle] at htrace exact htrace namespace Strategy variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable {G : Game X Y A B} def jointEffect (S : Strategy G) (x : X) (y : Y) (a : A) (b : B) : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ := (S.aliceMeasurement x).effect a ⊗ₖ (S.bobMeasurement y).effect b theorem jointEffect_positive (S : Strategy G) (x : X) (y : Y) (a : A) (b : B) : (S.jointEffect x y a b).PosSemidef := by exact ((S.aliceMeasurement x).positive a).kronecker ((S.bobMeasurement y).positive b) def outcomeProbability (S : Strategy G) (x : X) (y : Y) (a : A) (b : B) : ℝ := (Matrix.trace (S.state.matrix * S.jointEffect x y a b)).re theorem outcomeProbability_nonneg (S : Strategy G) (x : X) (y : Y) (a : A) (b : B) : 0 ≤ S.outcomeProbability x y a b := by exact trace_mul_posSemidef_nonneg S.state.positive (S.jointEffect_positive x y a b) theorem jointEffect_complete (S : Strategy G) (x : X) (y : Y) : (∑ a : A, ∑ b : B, S.jointEffect x y a b) = 1 := by classical calc (∑ a : A, ∑ b : B, S.jointEffect x y a b) = (∑ a : A, (S.aliceMeasurement x).effect a) ⊗ₖ (∑ b : B, (S.bobMeasurement y).effect b) := by ext ⟨i, j⟩ ⟨k, l⟩ simp only [jointEffect, Matrix.sum_apply, Matrix.kroneckerMap_apply] rw [Finset.sum_mul] simp_rw [Finset.mul_sum] _ = 1 := by rw [(S.aliceMeasurement x).complete, (S.bobMeasurement y).complete] exact Matrix.one_kronecker_one theorem outcomeProbability_normalized (S : Strategy G) (x : X) (y : Y) : (∑ a : A, ∑ b : B, S.outcomeProbability x y a b) = 1 := by classical calc (∑ a : A, ∑ b : B, S.outcomeProbability x y a b) = (Matrix.trace (S.state.matrix * (∑ a : A, ∑ b : B, S.jointEffect x y a b))).re := by simp [outcomeProbability, Matrix.mul_sum, Matrix.trace_sum] _ = (Matrix.trace S.state.matrix).re := by rw [S.jointEffect_complete x y] simp _ = 1 := by rw [S.state.trace_one]; rfl def winProbability (S : Strategy G) : ℝ := ∑ x : X, ∑ y : Y, G.questionWeight x y * ∑ a : A, ∑ b : B, if G.predicate x y a b = true then S.outcomeProbability x y a b else 0 theorem winProbability_nonneg (S : Strategy G) : 0 ≤ S.winProbability := by unfold winProbability refine Finset.sum_nonneg fun x _ => Finset.sum_nonneg fun y _ => ?_ apply mul_nonneg (G.weight_nonneg x y) exact Finset.sum_nonneg fun a _ => Finset.sum_nonneg fun b _ => by split <;> simp [S.outcomeProbability_nonneg] theorem winProbability_le_one (S : Strategy G) : S.winProbability ≤ 1 := by classical have hxy (x : X) (y : Y) : (∑ a : A, ∑ b : B, if G.predicate x y a b = true then S.outcomeProbability x y a b else 0) ≤ 1 := by calc (∑ a : A, ∑ b : B, if G.predicate x y a b = true then S.outcomeProbability x y a b else 0) ≤ ∑ a : A, ∑ b : B, S.outcomeProbability x y a b := by apply Finset.sum_le_sum intro a _ apply Finset.sum_le_sum intro b _ split · exact le_rfl · exact S.outcomeProbability_nonneg x y a b _ = 1 := S.outcomeProbability_normalized x y calc S.winProbability = ∑ x : X, ∑ y : Y, G.questionWeight x y * (∑ a : A, ∑ b : B, if G.predicate x y a b = true then S.outcomeProbability x y a b else 0) := rfl _ ≤ ∑ x : X, ∑ y : Y, G.questionWeight x y * 1 := by apply Finset.sum_le_sum intro x _ apply Finset.sum_le_sum intro y _ exact mul_le_mul_of_nonneg_left (hxy x y) (G.weight_nonneg x y) _ = 1 := by simpa using G.weight_normalized end Strategy def entangledValue [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) : ℝ := sSup (Set.range (Strategy.winProbability (G := G))) theorem winProbabilities_bddAbove [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) : BddAbove (Set.range (Strategy.winProbability (G := G))) := by refine ⟨1, ?_⟩ rintro _ ⟨S, rfl⟩ exact S.winProbability_le_one theorem entangledValue_le_one [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) : entangledValue G ≤ 1 := by unfold entangledValue by_cases h : (Set.range (Strategy.winProbability (G := G))).Nonempty · apply csSup_le h rintro _ ⟨S, rfl⟩ exact S.winProbability_le_one · rw [Set.not_nonempty_iff_eq_empty.mp h, Real.sSup_empty] exact zero_le_one theorem entangledValue_nonneg [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) : 0 ≤ entangledValue G := by unfold entangledValue by_cases h : (Set.range (Strategy.winProbability (G := G))).Nonempty · rcases h with ⟨_, S, rfl⟩ exact le_trans S.winProbability_nonneg (le_csSup (winProbabilities_bddAbove G) ⟨S, rfl⟩) · rw [Set.not_nonempty_iff_eq_empty.mp h, Real.sSup_empty] def repeatedEntangledValue [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) : ℝ := entangledValue (G.repeat n) end noncomputable section open scoped BigOperators ComplexConjugate InnerProductSpace variable {H : Type*} [NormedAddCommGroup H] [InnerProductSpace ℂ H] def quadraticExpectation (W : H →L[ℂ] H) (z : H) : ℝ := (⟪z, W z⟫_ℂ).re theorem positive_quadraticExpectation_nonneg (W : H →L[ℂ] H) (hW : W.IsPositive) (z : H) : 0 ≤ quadraticExpectation W z := by exact hW.re_inner_nonneg_right z theorem positive_complement_quadraticExpectation_le (W : H →L[ℂ] H) (h_complement : (1 - W).IsPositive) (z : H) : quadraticExpectation W z ≤ ‖z‖ ^ 2 := by have h := h_complement.re_inner_nonneg_right z have hnorm : (⟪z, z⟫_ℂ).re = ‖z‖ ^ 2 := by rw [inner_self_eq_norm_sq_to_K] simp [pow_two, Complex.mul_re] change 0 ≤ (⟪z, z - W z⟫_ℂ).re at h rw [inner_sub_right, Complex.sub_re, hnorm] at h unfold quadraticExpectation exact sub_nonneg.mp h theorem norm_le_of_operator_contraction (W : H →L[ℂ] H) (hW : ‖W‖ ≤ 1) (z : H) : ‖W z‖ ≤ ‖z‖ := by calc ‖W z‖ ≤ ‖W‖ * ‖z‖ := W.le_opNorm z _ ≤ 1 * ‖z‖ := mul_le_mul_of_nonneg_right hW (norm_nonneg z) _ = ‖z‖ := one_mul _ theorem quadraticExpectation_sub_le (W : H →L[ℂ] H) (hW : ‖W‖ ≤ 1) (z w : H) : |quadraticExpectation W z - quadraticExpectation W w| ≤ (‖z‖ + ‖w‖) * ‖z - w‖ := by have h_expand : ⟪z, W z⟫_ℂ - ⟪w, W w⟫_ℂ = ⟪z - w, W z⟫_ℂ + ⟪w, W (z - w)⟫_ℂ := by simp [map_sub] have hz := norm_le_of_operator_contraction W hW z have hdiff := norm_le_of_operator_contraction W hW (z - w) unfold quadraticExpectation calc |(⟪z, W z⟫_ℂ).re - (⟪w, W w⟫_ℂ).re| = |(⟪z, W z⟫_ℂ - ⟪w, W w⟫_ℂ).re| := by rw [Complex.sub_re] _ ≤ ‖⟪z, W z⟫_ℂ - ⟪w, W w⟫_ℂ‖ := Complex.abs_re_le_norm _ _ = ‖⟪z - w, W z⟫_ℂ + ⟪w, W (z - w)⟫_ℂ‖ := by rw [h_expand] _ ≤ ‖⟪z - w, W z⟫_ℂ‖ + ‖⟪w, W (z - w)⟫_ℂ‖ := norm_add_le _ _ _ ≤ ‖z - w‖ * ‖W z‖ + ‖w‖ * ‖W (z - w)‖ := add_le_add (norm_inner_le_norm _ _) (norm_inner_le_norm _ _) _ ≤ ‖z - w‖ * ‖z‖ + ‖w‖ * ‖z - w‖ := by gcongr _ = (‖z‖ + ‖w‖) * ‖z - w‖ := by ring theorem weighted_real_cauchy {ι : Type*} [Fintype ι] (weight f g : ι → ℝ) (h_weight : ∀ i, 0 ≤ weight i) : (∑ i : ι, weight i * f i * g i) ≤ Real.sqrt (∑ i : ι, weight i * f i ^ 2) * Real.sqrt (∑ i : ι, weight i * g i ^ 2) := by have h := Real.sum_mul_le_sqrt_mul_sqrt Finset.univ (fun i : ι => Real.sqrt (weight i) * f i) (fun i : ι => Real.sqrt (weight i) * g i) have hsq (i : ι) : Real.sqrt (weight i) ^ 2 = weight i := Real.sq_sqrt (h_weight i) have h_left : (∑ i : ι, (Real.sqrt (weight i) * f i) * (Real.sqrt (weight i) * g i)) = ∑ i : ι, weight i * f i * g i := by apply Finset.sum_congr rfl intro i _ calc (Real.sqrt (weight i) * f i) * (Real.sqrt (weight i) * g i) = Real.sqrt (weight i) ^ 2 * f i * g i := by ring _ = weight i * f i * g i := by rw [hsq i] have h_f : (∑ i : ι, (Real.sqrt (weight i) * f i) ^ 2) = ∑ i : ι, weight i * f i ^ 2 := by apply Finset.sum_congr rfl intro i _ rw [mul_pow, hsq i] have h_g : (∑ i : ι, (Real.sqrt (weight i) * g i) ^ 2) = ∑ i : ι, weight i * g i ^ 2 := by apply Finset.sum_congr rfl intro i _ rw [mul_pow, hsq i] simpa [h_left, h_f, h_g] using h end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder Matrix.Norms.L2Operator theorem matrixEffectCLM_isPositive {d : Type*} [Fintype d] [DecidableEq d] (E : Matrix d d ℂ) (hE : E.PosSemidef) : (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) E).IsPositive := by apply (ContinuousLinearMap.isPositive_toLinearMap_iff _).mp exact Matrix.isPositive_toEuclideanLin_iff.mpr hE theorem matrixEffectCLM_complement_isPositive {d : Type*} [Fintype d] [DecidableEq d] (E : Matrix d d ℂ) (hE : (1 - E).PosSemidef) : (1 - Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) E).IsPositive := by simpa using matrixEffectCLM_isPositive (1 - E) hE theorem matrixEffectCLM_norm_le_one {d : Type*} [Fintype d] [DecidableEq d] (E : Matrix d d ℂ) (hE : E.PosSemidef) (h_complement : (1 - E).PosSemidef) : ‖Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) E‖ ≤ 1 := by have h_positive := matrixEffectCLM_isPositive E hE have h_nonneg : 0 ≤ Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) E := (ContinuousLinearMap.nonneg_iff_isPositive _).mpr h_positive apply (CStarAlgebra.norm_le_one_iff_of_nonneg _ h_nonneg).mpr exact (ContinuousLinearMap.le_def _ _).mpr (matrixEffectCLM_complement_isPositive E h_complement) namespace Strategy variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable {G : Game X Y A B} def winningEffect (S : Strategy G) (x : X) (y : Y) : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then S.jointEffect x y a b else 0 theorem winningEffect_born (S : Strategy G) (x : X) (y : Y) : (Matrix.trace (S.state.matrix * S.winningEffect x y)).re = ∑ a : A, ∑ b : B, if G.predicate x y a b = true then S.outcomeProbability x y a b else 0 := by classical simp [winningEffect, outcomeProbability, Matrix.mul_sum, Matrix.trace_sum] apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ split <;> simp theorem winProbability_eq_winningEffect_born (S : Strategy G) : S.winProbability = ∑ x : X, ∑ y : Y, G.questionWeight x y * (Matrix.trace (S.state.matrix * S.winningEffect x y)).re := by simp_rw [S.winningEffect_born] rfl end Strategy end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder open Matrix variable {X Y A B : Type*} {J : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable [Fintype J] [DecidableEq J] variable {G : Game X Y A B} theorem posSemidef_blockDiagonal' {ι : Type*} [Fintype ι] [DecidableEq ι] {d : ι → Type*} [∀ j, Fintype (d j)] (M : ∀ j, Matrix (d j) (d j) ℂ) (hM : ∀ j, (M j).PosSemidef) : (Matrix.blockDiagonal' M).PosSemidef := by classical choose K hK using fun j => CStarAlgebra.nonneg_iff_eq_star_mul_self.mp (hM j).nonneg apply Matrix.LE.le.posSemidef apply CStarAlgebra.nonneg_iff_eq_star_mul_self.mpr refine ⟨Matrix.blockDiagonal' K, ?_⟩ calc Matrix.blockDiagonal' M = Matrix.blockDiagonal' (fun j => star (K j) * K j) := by congr 1 funext j exact hK j _ = star (Matrix.blockDiagonal' K) * Matrix.blockDiagonal' K := by simp [star_eq_conjTranspose, ← Matrix.blockDiagonal'_mul] abbrev mixtureAlice (S : J → Strategy G) := Σ j : J, (S j).Alice abbrev mixtureBob (S : J → Strategy G) := Σ j : J, (S j).Bob abbrev mixtureMatched (S : J → Strategy G) := Σ j : J, (S j).Alice × (S j).Bob def mixtureMatchedIndex (S : J → Strategy G) : mixtureMatched S → mixtureAlice S × mixtureBob S | ⟨j, (a, b)⟩ => (⟨j, a⟩, ⟨j, b⟩) omit [Fintype J] [DecidableEq J] in theorem mixtureMatchedIndex_injective (S : J → Strategy G) : Function.Injective (mixtureMatchedIndex S) := by rintro ⟨i, a, b⟩ ⟨j, c, d⟩ h have hflag : i = j := congrArg (fun q => q.1.1) h subst j have ha : a = c := eq_of_heq (Sigma.mk.inj (congrArg Prod.fst h)).2 have hb : b = d := eq_of_heq (Sigma.mk.inj (congrArg Prod.snd h)).2 subst c subst d rfl def mixtureEmbedding (S : J → Strategy G) : Matrix (mixtureAlice S × mixtureBob S) (mixtureMatched S) ℂ := by classical exact fun q r => if q = mixtureMatchedIndex S r then 1 else 0 theorem mixtureEmbedding_isometry (S : J → Strategy G) : (mixtureEmbedding S)ᴴ * mixtureEmbedding S = 1 := by classical ext i j by_cases h : i = j · subst j simp [mixtureEmbedding, Matrix.mul_apply, Matrix.conjTranspose_apply] · have hindex : mixtureMatchedIndex S i ≠ mixtureMatchedIndex S j := fun hij => h (mixtureMatchedIndex_injective S hij) simp [mixtureEmbedding, Matrix.mul_apply, Matrix.conjTranspose_apply, h, hindex.symm] theorem mixtureEmbedding_compress (S : J → Strategy G) (E : Matrix (mixtureAlice S × mixtureBob S) (mixtureAlice S × mixtureBob S) ℂ) : (mixtureEmbedding S)ᴴ * E * mixtureEmbedding S = E.submatrix (mixtureMatchedIndex S) (mixtureMatchedIndex S) := by classical ext i j simp [mixtureEmbedding, Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.submatrix_apply] def mixtureBlockMatrix (p : J → ℝ) (S : J → Strategy G) : Matrix (mixtureMatched S) (mixtureMatched S) ℂ := Matrix.blockDiagonal' fun j => p j • (S j).state.matrix theorem mixtureBlockMatrix_posSemidef (p : J → ℝ) (hp : ∀ j, 0 ≤ p j) (S : J → Strategy G) : (mixtureBlockMatrix p S).PosSemidef := by unfold mixtureBlockMatrix apply posSemidef_blockDiagonal' intro j exact (S j).state.positive.smul (hp j) theorem mixtureBlockMatrix_trace (p : J → ℝ) (S : J → Strategy G) : Matrix.trace (mixtureBlockMatrix p S) = (↑(∑ j : J, p j) : ℂ) := by unfold mixtureBlockMatrix rw [Matrix.trace_blockDiagonal'] simp [Matrix.trace_smul, DensityMatrix.trace_one] def mixtureDensityMatrix (p : J → ℝ) (hp : ∀ j, 0 ≤ p j) (h_normalized : (∑ j : J, p j) = 1) (S : J → Strategy G) : DensityMatrix (mixtureAlice S × mixtureBob S) where matrix := mixtureEmbedding S * mixtureBlockMatrix p S * (mixtureEmbedding S)ᴴ positive := (mixtureBlockMatrix_posSemidef p hp S).mul_mul_conjTranspose_same (mixtureEmbedding S) trace_one := by rw [Matrix.trace_mul_cycle, mixtureEmbedding_isometry, Matrix.one_mul, mixtureBlockMatrix_trace, h_normalized] norm_num def mixtureAlicePOVM (S : J → Strategy G) (x : X) : POVM A (mixtureAlice S) where effect a := Matrix.blockDiagonal' fun j => ((S j).aliceMeasurement x).effect a positive a := by apply posSemidef_blockDiagonal' intro j exact ((S j).aliceMeasurement x).positive a complete := by classical ext ⟨i, u⟩ ⟨j, v⟩ by_cases h : i = j · subst j have h_complete := congrArg (fun M : Matrix (S i).Alice (S i).Alice ℂ => M u v) ((S i).aliceMeasurement x).complete simpa [Matrix.sum_apply, Matrix.blockDiagonal'_apply, Matrix.one_apply] using h_complete · simp [Matrix.sum_apply, Matrix.blockDiagonal'_apply, h] def mixtureBobPOVM (S : J → Strategy G) (y : Y) : POVM B (mixtureBob S) where effect b := Matrix.blockDiagonal' fun j => ((S j).bobMeasurement y).effect b positive b := by apply posSemidef_blockDiagonal' intro j exact ((S j).bobMeasurement y).positive b complete := by classical ext ⟨i, u⟩ ⟨j, v⟩ by_cases h : i = j · subst j have h_complete := congrArg (fun M : Matrix (S i).Bob (S i).Bob ℂ => M u v) ((S i).bobMeasurement y).complete simpa [Matrix.sum_apply, Matrix.blockDiagonal'_apply, Matrix.one_apply] using h_complete · simp [Matrix.sum_apply, Matrix.blockDiagonal'_apply, h] def convexMixtureStrategy (p : J → ℝ) (hp : ∀ j, 0 ≤ p j) (h_normalized : (∑ j : J, p j) = 1) (S : J → Strategy G) : Strategy G where Alice := mixtureAlice S Bob := mixtureBob S alice_fintype := inferInstance bob_fintype := inferInstance alice_decidableEq := inferInstance bob_decidableEq := inferInstance state := mixtureDensityMatrix p hp h_normalized S aliceMeasurement := mixtureAlicePOVM S bobMeasurement := mixtureBobPOVM S theorem mixtureJointEffect_compress (S : J → Strategy G) (x : X) (y : Y) (a : A) (b : B) : (((mixtureAlicePOVM S x).effect a ⊗ₖ (mixtureBobPOVM S y).effect b).submatrix (mixtureMatchedIndex S) (mixtureMatchedIndex S)) = Matrix.blockDiagonal' fun j => (S j).jointEffect x y a b := by classical ext ⟨i, u, v⟩ ⟨j, u', v'⟩ by_cases h : i = j · subst j simp [Matrix.submatrix_apply, Matrix.kroneckerMap_apply, mixtureMatchedIndex, mixtureAlicePOVM, mixtureBobPOVM, Matrix.blockDiagonal'_apply, Strategy.jointEffect] · simp [Matrix.submatrix_apply, Matrix.kroneckerMap_apply, mixtureMatchedIndex, mixtureAlicePOVM, mixtureBobPOVM, Matrix.blockDiagonal'_apply, Strategy.jointEffect, h] theorem mixtureEmbedding_trace_mul (S : J → Strategy G) (R : Matrix (mixtureMatched S) (mixtureMatched S) ℂ) (E : Matrix (mixtureAlice S × mixtureBob S) (mixtureAlice S × mixtureBob S) ℂ) : Matrix.trace ((mixtureEmbedding S * R * (mixtureEmbedding S)ᴴ) * E) = Matrix.trace (R * E.submatrix (mixtureMatchedIndex S) (mixtureMatchedIndex S)) := by calc Matrix.trace ((mixtureEmbedding S * R * (mixtureEmbedding S)ᴴ) * E) = Matrix.trace ((mixtureEmbedding S * R) * ((mixtureEmbedding S)ᴴ * E)) := by congr 1 simp [Matrix.mul_assoc] _ = Matrix.trace (((mixtureEmbedding S)ᴴ * E) * (mixtureEmbedding S * R)) := Matrix.trace_mul_comm _ _ _ = Matrix.trace (((mixtureEmbedding S)ᴴ * E * mixtureEmbedding S) * R) := by congr 1 simp [Matrix.mul_assoc] _ = Matrix.trace (R * ((mixtureEmbedding S)ᴴ * E * mixtureEmbedding S)) := Matrix.trace_mul_comm _ _ _ = Matrix.trace (R * E.submatrix (mixtureMatchedIndex S) (mixtureMatchedIndex S)) := by rw [mixtureEmbedding_compress] theorem mixtureBlockMatrix_trace_mul (p : J → ℝ) (S : J → Strategy G) (E : ∀ j : J, Matrix ((S j).Alice × (S j).Bob) ((S j).Alice × (S j).Bob) ℂ) : Matrix.trace (mixtureBlockMatrix p S * Matrix.blockDiagonal' E) = ∑ j : J, p j • Matrix.trace ((S j).state.matrix * E j) := by unfold mixtureBlockMatrix rw [← Matrix.blockDiagonal'_mul, Matrix.trace_blockDiagonal'] simp [Matrix.trace_smul] theorem convexMixtureStrategy_outcomeProbability (p : J → ℝ) (hp : ∀ j, 0 ≤ p j) (h_normalized : (∑ j : J, p j) = 1) (S : J → Strategy G) (x : X) (y : Y) (a : A) (b : B) : (convexMixtureStrategy p hp h_normalized S).outcomeProbability x y a b = ∑ j : J, p j * (S j).outcomeProbability x y a b := by change (Matrix.trace ((mixtureEmbedding S * mixtureBlockMatrix p S * (mixtureEmbedding S)ᴴ) * ((mixtureAlicePOVM S x).effect a ⊗ₖ (mixtureBobPOVM S y).effect b))).re = _ rw [mixtureEmbedding_trace_mul, mixtureJointEffect_compress, mixtureBlockMatrix_trace_mul] simp [Strategy.outcomeProbability] theorem convexMixtureStrategy_winProbability (p : J → ℝ) (hp : ∀ j, 0 ≤ p j) (h_normalized : (∑ j : J, p j) = 1) (S : J → Strategy G) : (convexMixtureStrategy p hp h_normalized S).winProbability = ∑ j : J, p j * (S j).winProbability := by classical have h_branch (x : X) (y : Y) (a : A) (b : B) : (if G.predicate x y a b = true then ∑ j : J, p j * (S j).outcomeProbability x y a b else 0) = ∑ j : J, p j * (if G.predicate x y a b = true then (S j).outcomeProbability x y a b else 0) := by split <;> simp have h_swap (f : X → Y → A → B → J → ℝ) : (∑ x : X, ∑ y : Y, ∑ a : A, ∑ b : B, ∑ j : J, f x y a b j) = ∑ j : J, ∑ x : X, ∑ y : Y, ∑ a : A, ∑ b : B, f x y a b j := by calc (∑ x : X, ∑ y : Y, ∑ a : A, ∑ b : B, ∑ j : J, f x y a b j) = ∑ x : X, ∑ y : Y, ∑ a : A, ∑ j : J, ∑ b : B, f x y a b j := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ apply Finset.sum_congr rfl intro a _ exact Finset.sum_comm _ = ∑ x : X, ∑ y : Y, ∑ j : J, ∑ a : A, ∑ b : B, f x y a b j := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ exact Finset.sum_comm _ = ∑ x : X, ∑ j : J, ∑ y : Y, ∑ a : A, ∑ b : B, f x y a b j := by apply Finset.sum_congr rfl intro x _ exact Finset.sum_comm _ = ∑ j : J, ∑ x : X, ∑ y : Y, ∑ a : A, ∑ b : B, f x y a b j := Finset.sum_comm unfold Strategy.winProbability simp_rw [convexMixtureStrategy_outcomeProbability p hp h_normalized S] simp_rw [h_branch] simp_rw [Finset.mul_sum] rw [h_swap (fun x y a b j => G.questionWeight x y * (p j * (if G.predicate x y a b = true then (S j).outcomeProbability x y a b else 0)))] apply Finset.sum_congr rfl intro j _ apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ ring end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace def pureDensityMatrix {d : Type*} [Fintype d] [DecidableEq d] (z : EuclideanSpace ℂ d) (hz : ‖z‖ = 1) : DensityMatrix d where matrix := Matrix.vecMulVec (ofLp z) (star (ofLp z)) positive := Matrix.posSemidef_vecMulVec_self_star (ofLp z) trace_one := by rw [Matrix.trace_vecMulVec, ← EuclideanSpace.inner_eq_star_dotProduct z z, inner_self_eq_norm_sq_to_K, hz] norm_num theorem pureDensityMatrix_trace_mul {d : Type*} [Fintype d] [DecidableEq d] (z : EuclideanSpace ℂ d) (hz : ‖z‖ = 1) (E : Matrix d d ℂ) : (Matrix.trace ((pureDensityMatrix z hz).matrix * E)).re = quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) E) z := by unfold pureDensityMatrix quadraticExpectation congr 1 calc Matrix.trace (Matrix.vecMulVec (ofLp z) (star (ofLp z)) * E) = Matrix.trace (E * Matrix.vecMulVec (ofLp z) (star (ofLp z))) := Matrix.trace_mul_comm _ _ _ = E.mulVec (ofLp z) ⬝ᵥ star (ofLp z) := by rw [Matrix.mul_vecMulVec, Matrix.trace_vecMulVec] _ = ⟪z, Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) E z⟫_ℂ := by rw [EuclideanSpace.inner_eq_star_dotProduct] rfl def pureVectorStrategy {X Y A B : Type*} {dA dB : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (G : Game X Y A B) (z : EuclideanSpace ℂ (dA × dB)) (hz : ‖z‖ = 1) (PA : X → POVM A dA) (PB : Y → POVM B dB) : Strategy G where Alice := dA Bob := dB alice_fintype := inferInstance bob_fintype := inferInstance alice_decidableEq := inferInstance bob_decidableEq := inferInstance state := pureDensityMatrix z hz aliceMeasurement := PA bobMeasurement := PB theorem pureVectorStrategy_outcomeProbability {X Y A B : Type*} {dA dB : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (G : Game X Y A B) (z : EuclideanSpace ℂ (dA × dB)) (hz : ‖z‖ = 1) (PA : X → POVM A dA) (PB : Y → POVM B dB) (x : X) (y : Y) (a : A) (b : B) : (pureVectorStrategy G z hz PA PB).outcomeProbability x y a b = quadraticExpectation (Matrix.toEuclideanCLM (n := dA × dB) (𝕜 := ℂ) ((PA x).effect a ⊗ₖ (PB y).effect b)) z := by change (Matrix.trace ((pureDensityMatrix z hz).matrix * ((PA x).effect a ⊗ₖ (PB y).effect b))).re = _ exact pureDensityMatrix_trace_mul z hz ((PA x).effect a ⊗ₖ (PB y).effect b) def pureFlaggedStrategy {X Y A B : Type*} {dA dB J : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] [Fintype J] [DecidableEq J] (G : Game X Y A B) (p : J → ℝ) (hp : ∀ j, 0 ≤ p j) (h_normalized : (∑ j : J, p j) = 1) (z : J → EuclideanSpace ℂ (dA × dB)) (hz : ∀ j, ‖z j‖ = 1) (PA : J → X → POVM A dA) (PB : J → Y → POVM B dB) : Strategy G := convexMixtureStrategy p hp h_normalized (fun j => pureVectorStrategy G (z j) (hz j) (PA j) (PB j)) theorem pureFlaggedStrategy_winProbability {X Y A B : Type*} {dA dB J : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] [Fintype J] [DecidableEq J] (G : Game X Y A B) (p : J → ℝ) (hp : ∀ j, 0 ≤ p j) (h_normalized : (∑ j : J, p j) = 1) (z : J → EuclideanSpace ℂ (dA × dB)) (hz : ∀ j, ‖z j‖ = 1) (PA : J → X → POVM A dA) (PB : J → Y → POVM B dB) : (pureFlaggedStrategy G p hp h_normalized z hz PA PB).winProbability = ∑ j : J, p j * (pureVectorStrategy G (z j) (hz j) (PA j) (PB j)).winProbability := by exact convexMixtureStrategy_winProbability p hp h_normalized (fun j => pureVectorStrategy G (z j) (hz j) (PA j) (PB j)) end noncomputable section open scoped BigOperators structure FiniteEventLaw (Ω : Type*) [Fintype Ω] where weight : Ω → ℝ weight_nonneg : ∀ ω, 0 ≤ weight ω weight_sum : (∑ ω, weight ω) = 1 namespace FiniteEventLaw variable {Ω ι : Type*} [Fintype Ω] def eventMass (law : FiniteEventLaw Ω) (event : Finset Ω) : ℝ := ∑ ω ∈ event, law.weight ω theorem eventMass_univ (law : FiniteEventLaw Ω) : law.eventMass Finset.univ = 1 := by simpa [eventMass] using law.weight_sum theorem eventMass_mono (law : FiniteEventLaw Ω) {s t : Finset Ω} (h : s ⊆ t) : law.eventMass s ≤ law.eventMass t := by unfold eventMass exact Finset.sum_le_sum_of_subset_of_nonneg h (fun ω _ _ => law.weight_nonneg ω) def winEvent [Fintype ι] (wins : ι → Ω → Bool) (D : Finset ι) : Finset Ω := Finset.univ.filter (fun ω => ∀ i ∈ D, wins i ω = true) theorem winEvent_empty [Fintype ι] (wins : ι → Ω → Bool) : winEvent wins ∅ = Finset.univ := by classical simp [winEvent] theorem winEvent_antitone [Fintype ι] (wins : ι → Ω → Bool) {D E : Finset ι} (h : D ⊆ E) : winEvent wins E ⊆ winEvent wins D := by classical intro ω hω have h_all : ∀ i ∈ E, wins i ω = true := by simpa [winEvent] using hω simp only [winEvent, Finset.mem_filter, Finset.mem_univ, true_and] exact fun i hi => h_all i (h hi) theorem allWinMass_le_partial [Fintype ι] (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) (D : Finset ι) : law.eventMass (winEvent wins Finset.univ) ≤ law.eventMass (winEvent wins D) := by apply law.eventMass_mono exact winEvent_antitone wins (Finset.subset_univ D) def failureMass [Fintype ι] [DecidableEq ι] (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) (D : Finset ι) (i : ι) : ℝ := law.eventMass (winEvent wins D) - law.eventMass (winEvent wins (insert i D)) theorem exists_greedy_stopping [Fintype ι] [DecidableEq ι] (mass : Finset ι → ℝ) {θ η : ℝ} {T : ℕ} (_hθ : 0 < θ) (_hη : 0 < η) (hη_one : η ≤ 1) (hT : T ≤ Fintype.card ι) (hempty : mass ∅ = 1) (hfloor : ∀ D : Finset ι, θ ≤ mass D) (h_terminal : (1 - η) ^ T < θ) : ∃ D : Finset ι, D.card < T ∧ θ ≤ mass D ∧ (∑ i ∈ Finset.univ \ D, (mass D - mass (insert i D))) < ((Finset.univ \ D).card : ℝ) * (η * mass D) := by classical let candidates : Finset (Finset ι) := Finset.univ.powerset.filter (fun D => D.card ≤ T ∧ mass D ≤ (1 - η) ^ D.card) have h_candidates : candidates.Nonempty := by refine ⟨∅, ?_⟩ simp [candidates, hempty] obtain ⟨D, hD, hmax⟩ := Finset.exists_max_image candidates (fun E : Finset ι => E.card) h_candidates have hD_data : D.card ≤ T ∧ mass D ≤ (1 - η) ^ D.card := (Finset.mem_filter.mp hD).2 have hD_lt : D.card < T := by have hne : D.card ≠ T := by intro heq have hupper : mass D ≤ (1 - η) ^ T := by simpa [heq] using hD_data.2 linarith [hfloor D] exact lt_of_le_of_ne hD_data.1 hne refine ⟨D, hD_lt, hfloor D, ?_⟩ by_contra h_not_stopped have h_sum : ((Finset.univ \ D).card : ℝ) * (η * mass D) ≤ ∑ i ∈ Finset.univ \ D, (mass D - mass (insert i D)) := le_of_not_gt h_not_stopped have h_card : D.card < (Finset.univ : Finset ι).card := by simpa using hD_lt.trans_le hT have h_remaining : (Finset.univ \ D).Nonempty := Finset.sdiff_nonempty_of_card_lt_card h_card have h_sum_constant : (∑ _i ∈ Finset.univ \ D, η * mass D) ≤ ∑ i ∈ Finset.univ \ D, (mass D - mass (insert i D)) := by simpa using h_sum obtain ⟨i, hi, hfailure⟩ := Finset.exists_le_of_sum_le h_remaining h_sum_constant have hi_not : i ∉ D := (Finset.mem_sdiff.mp hi).2 have hnext_card : (insert i D).card ≤ T := by rw [Finset.card_insert_of_notMem hi_not] omega have hshrink : mass (insert i D) ≤ (1 - η) * mass D := by linarith have hnext_bound : mass (insert i D) ≤ (1 - η) ^ (insert i D).card := by calc mass (insert i D) ≤ (1 - η) * mass D := hshrink _ ≤ (1 - η) * (1 - η) ^ D.card := mul_le_mul_of_nonneg_left hD_data.2 (sub_nonneg.mpr hη_one) _ = (1 - η) ^ (insert i D).card := by rw [Finset.card_insert_of_notMem hi_not, pow_succ] ring have hnext_mem : insert i D ∈ candidates := by simp only [candidates, Finset.mem_filter, Finset.mem_powerset] exact ⟨Finset.subset_univ _, hnext_card, hnext_bound⟩ have h_impossible := hmax (insert i D) hnext_mem rw [Finset.card_insert_of_notMem hi_not] at h_impossible omega theorem exists_conditioned_win_set [Fintype ι] [DecidableEq ι] (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) {θ η : ℝ} {T : ℕ} (hθ : 0 < θ) (hη : 0 < η) (hη_one : η ≤ 1) (hT : T ≤ Fintype.card ι) (hwin : θ ≤ law.eventMass (winEvent wins Finset.univ)) (h_terminal : (1 - η) ^ T < θ) : ∃ D : Finset ι, D.card < T ∧ θ ≤ law.eventMass (winEvent wins D) ∧ (∑ i ∈ Finset.univ \ D, failureMass law wins D i) < ((Finset.univ \ D).card : ℝ) * (η * law.eventMass (winEvent wins D)) := by let mass : Finset ι → ℝ := fun D => law.eventMass (winEvent wins D) have hempty : mass ∅ = 1 := by dsimp [mass] rw [winEvent_empty] exact law.eventMass_univ have hfloor : ∀ D : Finset ι, θ ≤ mass D := by intro D exact hwin.trans (law.allWinMass_le_partial wins D) obtain ⟨D, hD, hp, hstop⟩ := exists_greedy_stopping mass hθ hη hη_one hT hempty hfloor h_terminal refine ⟨D, hD, hp, ?_⟩ simpa [failureMass, mass] using hstop end FiniteEventLaw section StrategyEventLaw variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev StrategyOutcome (X Y A B : Type*) := X × Y × A × B def strategyEventLaw (G : Game X Y A B) (S : Strategy G) : FiniteEventLaw (StrategyOutcome X Y A B) where weight ω := G.questionWeight ω.1 ω.2.1 * S.outcomeProbability ω.1 ω.2.1 ω.2.2.1 ω.2.2.2 weight_nonneg ω := mul_nonneg (G.weight_nonneg ω.1 ω.2.1) (S.outcomeProbability_nonneg ω.1 ω.2.1 ω.2.2.1 ω.2.2.2) weight_sum := by classical change (∑ ω : X × Y × A × B, G.questionWeight ω.1 ω.2.1 * S.outcomeProbability ω.1 ω.2.1 ω.2.2.1 ω.2.2.2) = 1 simp_rw [Fintype.sum_prod_type] calc (∑ x : X, ∑ y : Y, ∑ a : A, ∑ b : B, G.questionWeight x y * S.outcomeProbability x y a b) = ∑ x : X, ∑ y : Y, G.questionWeight x y * (∑ a : A, ∑ b : B, S.outcomeProbability x y a b) := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ simp only [Finset.mul_sum] _ = ∑ x : X, ∑ y : Y, G.questionWeight x y * 1 := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [S.outcomeProbability_normalized x y] _ = 1 := by simpa using G.weight_normalized def strategyWinEvent (G : Game X Y A B) : Finset (StrategyOutcome X Y A B) := Finset.univ.filter (fun ω => G.predicate ω.1 ω.2.1 ω.2.2.1 ω.2.2.2 = true) theorem strategyEventLaw_winEvent (G : Game X Y A B) (S : Strategy G) : (strategyEventLaw G S).eventMass (strategyWinEvent G) = S.winProbability := by classical unfold FiniteEventLaw.eventMass strategyWinEvent simp only [Finset.sum_filter] change (∑ ω : X × Y × A × B, if G.predicate ω.1 ω.2.1 ω.2.2.1 ω.2.2.2 = true then G.questionWeight ω.1 ω.2.1 * S.outcomeProbability ω.1 ω.2.1 ω.2.2.1 ω.2.2.2 else 0) = S.winProbability simp_rw [Fintype.sum_prod_type] unfold Strategy.winProbability apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro a _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro b _ split <;> simp def repeatedCoordinateWin (G : Game X Y A B) (n : ℕ) (i : Fin n) (ω : StrategyOutcome (Fin n → X) (Fin n → Y) (Fin n → A) (Fin n → B)) : Bool := G.predicate (ω.1 i) (ω.2.1 i) (ω.2.2.1 i) (ω.2.2.2 i) theorem repeated_allWinEvent_eq (G : Game X Y A B) (n : ℕ) : FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (Finset.univ : Finset (Fin n)) = strategyWinEvent (G.repeat n) := by classical ext ω simp [FiniteEventLaw.winEvent, strategyWinEvent, repeatedCoordinateWin, Game.repeat_predicate_eq_true] theorem repeated_allWinMass_eq (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) : (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (Finset.univ : Finset (Fin n))) = S.winProbability := by rw [repeated_allWinEvent_eq] exact strategyEventLaw_winEvent (G.repeat n) S theorem repeatedStrategy_exists_greedy_conditioning (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) {θ η : ℝ} {T : ℕ} (hθ : 0 < θ) (hη : 0 < η) (hη_one : η ≤ 1) (hT : T ≤ n) (hwin : θ ≤ S.winProbability) (h_terminal : (1 - η) ^ T < θ) : ∃ D : Finset (Fin n), D.card < T ∧ θ ≤ (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) ∧ (∑ i ∈ Finset.univ \ D, FiniteEventLaw.failureMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D i) < ((Finset.univ \ D).card : ℝ) * (η * (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) := by have h_card : T ≤ Fintype.card (Fin n) := by simpa using hT have h_full : θ ≤ (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (Finset.univ : Finset (Fin n))) := by rw [repeated_allWinMass_eq] exact hwin exact FiniteEventLaw.exists_conditioned_win_set (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) hθ hη hη_one h_card h_full h_terminal end StrategyEventLaw end noncomputable section open scoped BigOperators variable {ι : Type*} theorem negMulLog_rescale {W p : ℝ} (hW : 0 < W) (hp : 0 < p) : W * Real.negMulLog (p / W) = p * Real.log (W / p) := by unfold Real.negMulLog rw [Real.log_div hp.ne' hW.ne', Real.log_div hW.ne' hp.ne'] field_simp ring theorem finite_weighted_entropy_le (s : Finset ι) (w h : ι → ℝ) {W p : ℝ} (hw : ∀ i ∈ s, 0 ≤ w i) (hh : ∀ i ∈ s, 0 ≤ h i) (hW : 0 < W) (hp : 0 < p) (hw_sum : (∑ i ∈ s, w i) = W) (hp_sum : (∑ i ∈ s, w i * h i) = p) : (∑ i ∈ s, w i * Real.negMulLog (h i)) ≤ p * Real.log (W / p) := by classical have h_normalized : (∑ i ∈ s, w i / W) = 1 := by calc (∑ i ∈ s, w i / W) = (∑ i ∈ s, w i) / W := by rw [Finset.sum_div] _ = W / W := by rw [hw_sum] _ = 1 := div_self hW.ne' have h_mean : (∑ i ∈ s, (w i / W) * h i) = p / W := by calc (∑ i ∈ s, (w i / W) * h i) = ∑ i ∈ s, (w i * h i) / W := by apply Finset.sum_congr rfl intro i hi ring _ = (∑ i ∈ s, w i * h i) / W := by rw [Finset.sum_div] _ = p / W := by rw [hp_sum] have h_jensen : (∑ i ∈ s, (w i / W) * Real.negMulLog (h i)) ≤ Real.negMulLog (∑ i ∈ s, (w i / W) * h i) := by simpa only [smul_eq_mul] using (Real.concaveOn_negMulLog.le_map_sum (t := s) (w := fun i => w i / W) (p := h) (fun i hi => div_nonneg (hw i hi) hW.le) h_normalized (fun i hi => show h i ∈ Set.Ici (0 : ℝ) from hh i hi)) calc (∑ i ∈ s, w i * Real.negMulLog (h i)) = W * (∑ i ∈ s, (w i / W) * Real.negMulLog (h i)) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i hi field_simp _ ≤ W * Real.negMulLog (∑ i ∈ s, (w i / W) * h i) := mul_le_mul_of_nonneg_left h_jensen hW.le _ = W * Real.negMulLog (p / W) := by rw [h_mean] _ = p * Real.log (W / p) := negMulLog_rescale hW hp theorem finite_weighted_entropy_le_of_weight_bound (s : Finset ι) (w h : ι → ℝ) {W N p : ℝ} (hw : ∀ i ∈ s, 0 ≤ w i) (hh : ∀ i ∈ s, 0 ≤ h i) (hW : 0 < W) (hp : 0 < p) (hw_sum : (∑ i ∈ s, w i) = W) (hp_sum : (∑ i ∈ s, w i * h i) = p) (hWN : W ≤ N) : (∑ i ∈ s, w i * Real.negMulLog (h i)) ≤ p * Real.log (N / p) := by have hquot : W / p ≤ N / p := by exact (div_le_div_iff_of_pos_right hp).mpr hWN have hlog : Real.log (W / p) ≤ Real.log (N / p) := Real.log_le_log (div_pos hW hp) hquot exact (finite_weighted_entropy_le s w h hw hh hW hp hw_sum hp_sum).trans (mul_le_mul_of_nonneg_left hlog hp.le) end noncomputable section open scoped BigOperators theorem noncommutative_resolvent_identity {R : Type*} [Ring R] (F M S RF RM : R) (hF : RF * (F + S) = 1) (hM : (M + S) * RM = 1) : RF - RM = RF * (M - F) * RM := by calc RF - RM = RF * ((M + S) * RM) - (RF * (F + S)) * RM := by rw [hM, hF] simp _ = RF * (M - F) * RM := by noncomm_ring theorem noncommutative_filtered_resolvent_identity {R : Type*} [Ring R] (F M S RF RM : R) (hF_left : (F + S) * RF = 1) (hF_right : RF * (F + S) = 1) (hM_left : (M + S) * RM = 1) : F * RF - M * RM = S * (RF * (F - M) * RM) := by have hFR : F * RF = 1 - S * RF := by have h : F * RF + S * RF = 1 := by simpa [add_mul] using hF_left exact eq_sub_of_add_eq h have hMR : M * RM = 1 - S * RM := by have h : M * RM + S * RM = 1 := by simpa [add_mul] using hM_left exact eq_sub_of_add_eq h have hdiff : RM - RF = RF * (F - M) * RM := by calc RM - RF = -(RF - RM) := by noncomm_ring _ = -(RF * (M - F) * RM) := by rw [noncommutative_resolvent_identity F M S RF RM hF_right hM_left] _ = RF * (F - M) * RM := by noncomm_ring rw [hFR, hMR] calc (1 - S * RF) - (1 - S * RM) = S * (RM - RF) := by noncomm_ring _ = S * (RF * (F - M) * RM) := by rw [hdiff] theorem noncommutative_resolvent_second_order {R : Type*} [Ring R] (F M S RF RM : R) (hF_left : (F + S) * RF = 1) (hF_right : RF * (F + S) = 1) (hM_left : (M + S) * RM = 1) (hM_right : RM * (M + S) = 1) : RF = RM - RM * (F - M) * RM + RM * (F - M) * RF * (F - M) * RM := by have hleft : RM - RF = RM * (F - M) * RF := noncommutative_resolvent_identity M F S RM RF hM_right hF_left have hright : RF - RM = RF * (M - F) * RM := noncommutative_resolvent_identity F M S RF RM hF_right hM_left have hfirst : RF = RM - RM * (F - M) * RF := by calc RF = RM - (RM - RF) := by noncomm_ring _ = RM - RM * (F - M) * RF := by rw [hleft] have hsecond : RF = RM - RF * (F - M) * RM := by calc RF = RM + (RF - RM) := by noncomm_ring _ = RM + RF * (M - F) * RM := by rw [hright] _ = RM - RF * (F - M) * RM := by noncomm_ring calc RF = RM - RM * (F - M) * RF := hfirst _ = RM - RM * (F - M) * (RM - RF * (F - M) * RM) := by rw [← hsecond] _ = RM - RM * (F - M) * RM + RM * (F - M) * RF * (F - M) * RM := by noncomm_ring theorem noncommutative_weighted_resolvent_second_order {ι R : Type*} [Fintype ι] [Ring R] (weight : ι → R) (F : ι → R) (M S : R) (RF : ι → R) (RM : R) (normalized : (∑ i : ι, weight i) = 1) (centered : (∑ i : ι, weight i * (F i - M)) = 0) (commute_mean : ∀ i, weight i * RM = RM * weight i) (hF_left : ∀ i, (F i + S) * RF i = 1) (hF_right : ∀ i, RF i * (F i + S) = 1) (hM_left : (M + S) * RM = 1) (hM_right : RM * (M + S) = 1) : (∑ i : ι, weight i * RF i) - RM = RM * (∑ i : ι, weight i * ((F i - M) * RF i * (F i - M))) * RM := by have hterm (i : ι) : weight i * RF i = weight i * RM - RM * (weight i * (F i - M)) * RM + RM * (weight i * ((F i - M) * RF i * (F i - M))) * RM := by nth_rewrite 1 [noncommutative_resolvent_second_order (F i) M S (RF i) RM (hF_left i) (hF_right i) hM_left hM_right] have hw := commute_mean i calc weight i * (RM - RM * (F i - M) * RM + RM * (F i - M) * RF i * (F i - M) * RM) = weight i * RM - (weight i * RM) * (F i - M) * RM + (weight i * RM) * ((F i - M) * RF i * (F i - M)) * RM := by noncomm_ring _ = weight i * RM - (RM * weight i) * (F i - M) * RM + (RM * weight i) * ((F i - M) * RF i * (F i - M)) * RM := by rw [hw] _ = weight i * RM - RM * (weight i * (F i - M)) * RM + RM * (weight i * ((F i - M) * RF i * (F i - M))) * RM := by noncomm_ring calc (∑ i : ι, weight i * RF i) - RM = (∑ i : ι, (weight i * RM - RM * (weight i * (F i - M)) * RM + RM * (weight i * ((F i - M) * RF i * (F i - M))) * RM)) - RM := by congr 1 exact Finset.sum_congr rfl (fun i _ => hterm i) _ = (∑ i : ι, weight i) * RM - RM * (∑ i : ι, weight i * (F i - M)) * RM + RM * (∑ i : ι, weight i * ((F i - M) * RF i * (F i - M))) * RM - RM := by simp only [Finset.sum_add_distrib, Finset.sum_sub_distrib, ← Finset.sum_mul, ← Finset.mul_sum] _ = RM * (∑ i : ι, weight i * ((F i - M) * RF i * (F i - M))) * RM := by rw [normalized, centered] noncomm_ring end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder theorem posSemidef_hermitian_sandwich {d : Type*} [Fintype d] [DecidableEq d] {A D : Matrix d d ℂ} (hA : A.PosSemidef) (hD : D.IsHermitian) : (D * A * D).PosSemidef := by simpa [hD.eq] using hA.mul_mul_conjTranspose_same D theorem shifted_posSemidef_matrix_posDef {d : Type*} [Fintype d] [DecidableEq d] {F : Matrix d d ℂ} (hF : F.PosSemidef) {s : ℝ} (hs : 0 < s) : (F + s • (1 : Matrix d d ℂ)).PosDef := by have hshift : (s • (1 : Matrix d d ℂ)).PosDef := Matrix.PosDef.one.smul hs exact Matrix.PosDef.posSemidef_add hF hshift theorem shifted_posSemidef_matrix_inverse_posSemidef {d : Type*} [Fintype d] [DecidableEq d] {F : Matrix d d ℂ} (hF : F.PosSemidef) {s : ℝ} (hs : 0 < s) : ((F + s • (1 : Matrix d d ℂ))⁻¹).PosSemidef := (shifted_posSemidef_matrix_posDef hF hs).posSemidef.inv theorem matrix_weighted_centered {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (normalized : (∑ i : ι, weight i) = 1) (mean : (∑ i : ι, weight i • F i) = M) : (∑ i : ι, weight i • (F i - M)) = 0 := by simp_rw [smul_sub] rw [Finset.sum_sub_distrib, mean, ← Finset.sum_smul, normalized] simp theorem weighted_positive_matrix_mean {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (nonnegative : ∀ i, 0 ≤ weight i) (positive : ∀ i, (F i).PosSemidef) : (∑ i : ι, weight i • F i).PosSemidef := by exact Matrix.posSemidef_sum Finset.univ (fun i _ => (positive i).smul (nonnegative i)) end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology theorem scalar_resolvent_purification_integrable_of_pos {z : ℝ} (hz : 0 < z) : IntegrableOn (fun s : ℝ => (z / (z + s)) ^ 2) (Ioi 0) := by have hpower : IntegrableOn (fun s : ℝ => (s + z) ^ (-2 : ℝ)) (Ioi 0) := by exact integrableOn_add_rpow_Ioi_of_lt (a := (-2 : ℝ)) (c := (0 : ℝ)) (m := z) (by norm_num) (by linarith) have hscaled : IntegrableOn (fun s : ℝ => z ^ 2 * (s + z) ^ (-2 : ℝ)) (Ioi 0) := hpower.const_mul (z ^ 2) refine hscaled.congr_fun (fun s hs => ?_) measurableSet_Ioi have hspos : 0 < s + z := by have : 0 < s := hs linarith change z ^ 2 * (s + z) ^ (-2 : ℝ) = (z / (z + s)) ^ 2 rw [show (-2 : ℝ) = -(2 : ℝ) by norm_num, Real.rpow_neg hspos.le, Real.rpow_two] rw [div_pow] simp [div_eq_mul_inv, add_comm] theorem scalar_resolvent_purification_integrable {z : ℝ} (hz : 0 ≤ z) : IntegrableOn (fun s : ℝ => (z / (z + s)) ^ 2) (Ioi 0) := by rcases hz.eq_or_lt with rfl | hzpos · simp · exact scalar_resolvent_purification_integrable_of_pos hzpos theorem scalar_resolvent_purification_integral {z : ℝ} (hz : 0 ≤ z) : (∫ s in Ioi (0 : ℝ), (z / (z + s)) ^ 2) = z := by rcases hz.eq_or_lt with rfl | hzpos · simp · have hderiv : ∀ x ∈ Ici (0 : ℝ), HasDerivAt (fun t : ℝ => -(z ^ 2) / (z + t)) ((z / (z + x)) ^ 2) x := by intro x hx have hden : z + x ≠ 0 := by have hx_nonneg : 0 ≤ x := hx exact ne_of_gt (by linarith) have hd := ((hasDerivAt_const x (-(z ^ 2))).div ((hasDerivAt_const x z).add (hasDerivAt_id x)) hden) have hfun : (fun t : ℝ => -(z ^ 2) / (z + t)) = (fun _t : ℝ => -(z ^ 2)) / ((fun _t : ℝ => z) + id) := by funext t rfl rw [hfun] simpa [div_pow] using hd have hlimit : Tendsto (fun t : ℝ => -(z ^ 2) / (z + t)) atTop (𝓝 (0 : ℝ)) := by have hden : Tendsto (fun t : ℝ => t + z) atTop atTop := tendsto_atTop_add_const_right atTop z tendsto_id have hzero : Tendsto (fun t : ℝ => -(z ^ 2) / (t + z)) atTop (𝓝 (0 : ℝ)) := tendsto_const_nhds.div_atTop hden simpa [add_comm] using hzero have hftc := integral_Ioi_of_hasDerivAt_of_tendsto' hderiv (scalar_resolvent_purification_integrable_of_pos hzpos) hlimit calc (∫ s in Ioi (0 : ℝ), (z / (z + s)) ^ 2) = (0 : ℝ) - (-(z ^ 2) / (z + 0)) := hftc _ = z := by field_simp ; ring end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace def diagonalPurificationGram {d : Type*} [Fintype d] [DecidableEq d] (eigenvalue : d → ℝ) (s : ℝ) : Matrix d d ℂ := Matrix.diagonal fun i => (((eigenvalue i / (eigenvalue i + s)) ^ 2 : ℝ) : ℂ) theorem diagonalPurificationGram_integrable {d : Type*} [Fintype d] [DecidableEq d] (eigenvalue : d → ℝ) (h_nonneg : ∀ i, 0 ≤ eigenvalue i) : IntegrableOn (diagonalPurificationGram eigenvalue) (Ioi 0) := by apply MeasureTheory.Integrable.of_eval intro i apply MeasureTheory.Integrable.of_eval intro j classical by_cases h : i = j · subst j have hcomplex : Integrable (fun s : ℝ => (((eigenvalue i / (eigenvalue i + s)) ^ 2 : ℝ) : ℂ)) (volume.restrict (Ioi 0)) := MeasureTheory.Integrable.ofReal (𝕜 := ℂ) (scalar_resolvent_purification_integrable (h_nonneg i)) simpa only [diagonalPurificationGram, Matrix.diagonal_apply_eq] using hcomplex · simp [diagonalPurificationGram, h] theorem integral_diagonalPurificationGram {d : Type*} [Fintype d] [DecidableEq d] (eigenvalue : d → ℝ) (h_nonneg : ∀ i, 0 ≤ eigenvalue i) : (∫ s in Ioi (0 : ℝ), diagonalPurificationGram eigenvalue s) = Matrix.diagonal (fun i => (eigenvalue i : ℂ)) := by classical have hmatrix := diagonalPurificationGram_integrable eigenvalue h_nonneg have hrows : ∀ i : d, Integrable (fun s : ℝ => diagonalPurificationGram eigenvalue s i) (volume.restrict (Ioi 0)) := fun i => hmatrix.eval i have hentry (i : d) : ∀ j : d, Integrable (fun s : ℝ => diagonalPurificationGram eigenvalue s i j) (volume.restrict (Ioi 0)) := fun j => (hrows i).eval j ext i j rw [MeasureTheory.eval_integral hrows i, MeasureTheory.eval_integral (hentry i) j] by_cases h : i = j · subst j simp only [diagonalPurificationGram, Matrix.diagonal_apply_eq] calc (∫ s in Ioi (0 : ℝ), (((eigenvalue i / (eigenvalue i + s)) ^ 2 : ℝ) : ℂ)) = ((∫ s in Ioi (0 : ℝ), (eigenvalue i / (eigenvalue i + s)) ^ 2 : ℝ) : ℂ) := integral_ofReal _ = (eigenvalue i : ℂ) := by rw [scalar_resolvent_purification_integral (h_nonneg i)] · simp [diagonalPurificationGram, h] def spectralConjugationCLM {d : Type*} [Fintype d] [DecidableEq d] (U : Matrix.unitaryGroup d ℂ) : Matrix d d ℂ →L[ℝ] Matrix d d ℂ := LinearMap.toContinuousLinearMap (Unitary.conjStarAlgAut ℝ (Matrix d d ℂ) U).toAlgEquiv.toLinearEquiv.toLinearMap @[simp] theorem spectralConjugationCLM_apply {d : Type*} [Fintype d] [DecidableEq d] (U : Matrix.unitaryGroup d ℂ) (A : Matrix d d ℂ) : spectralConjugationCLM U A = (U : Matrix d d ℂ) * A * star (U : Matrix d d ℂ) := by rfl def spectralPurificationGram {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (s : ℝ) : Matrix d d ℂ := spectralConjugationCLM hF.isHermitian.eigenvectorUnitary (diagonalPurificationGram hF.isHermitian.eigenvalues s) theorem spectralPurificationGram_integrable {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : IntegrableOn (spectralPurificationGram F hF) (Ioi 0) := by have hdiag := diagonalPurificationGram_integrable hF.isHermitian.eigenvalues (fun i => hF.eigenvalues_nonneg i) exact (spectralConjugationCLM hF.isHermitian.eigenvectorUnitary).integrable_comp hdiag theorem integral_spectralPurificationGram {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : (∫ s in Ioi (0 : ℝ), spectralPurificationGram F hF s) = F := by let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues have hdiag := diagonalPurificationGram_integrable eigenvalue (fun i => hF.eigenvalues_nonneg i) calc (∫ s in Ioi (0 : ℝ), spectralPurificationGram F hF s) = spectralConjugationCLM U (∫ s in Ioi (0 : ℝ), diagonalPurificationGram eigenvalue s) := by exact ContinuousLinearMap.integral_comp_comm (spectralConjugationCLM U) hdiag _ = spectralConjugationCLM U (Matrix.diagonal (fun i => (eigenvalue i : ℂ))) := by rw [integral_diagonalPurificationGram eigenvalue (fun i => hF.eigenvalues_nonneg i)] _ = F := by simpa [U, eigenvalue, Function.comp_def, Unitary.conjStarAlgAut_apply] using hF.isHermitian.spectral_theorem.symm end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Kronecker Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace def spectralPurificationFilter {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (s : ℝ) : Matrix d d ℂ := spectralConjugationCLM hF.isHermitian.eigenvectorUnitary (Matrix.diagonal fun i => ((hF.isHermitian.eigenvalues i / (hF.isHermitian.eigenvalues i + s) : ℝ) : ℂ)) theorem spectralPurificationFilter_gram {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (s : ℝ) : star (spectralPurificationFilter F hF s) * spectralPurificationFilter F hF s = spectralPurificationGram F hF s := by classical let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues let D : Matrix d d ℂ := Matrix.diagonal fun i => ((eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) let e := Unitary.conjStarAlgAut ℂ (Matrix d d ℂ) U have hDhermitian : D.IsHermitian := by apply Matrix.isHermitian_diagonal_iff.mpr intro i change star ((eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) = _ simp have hDstar : star D = D := by simpa only [Matrix.star_eq_conjTranspose] using hDhermitian.eq have hDsquare : D * D = diagonalPurificationGram eigenvalue s := by dsimp [D] rw [Matrix.diagonal_mul_diagonal] ext i j by_cases h : i = j · subst j simp [diagonalPurificationGram, pow_two] · simp [diagonalPurificationGram, h] change star (e D) * e D = e (diagonalPurificationGram eigenvalue s) calc star (e D) * e D = e (star D) * e D := by rw [map_star] _ = e (star D * D) := (map_mul e (star D) D).symm _ = e (diagonalPurificationGram eigenvalue s) := by rw [hDstar, hDsquare] theorem integral_spectralPurificationFilter_gram {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : (∫ s in Ioi (0 : ℝ), star (spectralPurificationFilter F hF s) * spectralPurificationFilter F hF s) = F := by simp_rw [spectralPurificationFilter_gram] exact integral_spectralPurificationGram F hF theorem spectralPurificationFilter_gram_integrable {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : IntegrableOn (fun s : ℝ => star (spectralPurificationFilter F hF s) * spectralPurificationFilter F hF s) (Ioi 0) := by simpa only [spectralPurificationFilter_gram] using spectralPurificationGram_integrable F hF def bornTracePairing {dA dB : Type*} [Fintype dA] [Fintype dB] (ρ : Matrix (dA × dB) (dA × dB) ℂ) : Matrix dA dA ℂ →ₗ[ℝ] Matrix dB dB ℂ →ₗ[ℝ] ℝ where toFun F := { toFun := fun G => (Matrix.trace (ρ * (F ⊗ₖ G))).re map_add' := by intro G H simp [Matrix.kronecker_add, Matrix.mul_add, Matrix.trace_add] map_smul' := by intro r G simp [Matrix.kronecker_smul, mul_smul_comm, Matrix.trace_smul] } map_add' := by intro F H ext G simp [Matrix.add_kronecker, Matrix.mul_add, Matrix.trace_add] map_smul' := by intro r F ext G simp [Matrix.smul_kronecker, mul_smul_comm, Matrix.trace_smul] end noncomputable section open scoped BigOperators Kronecker namespace Game variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem questionWeight_le_marginalX (G : Game X Y A B) (x : X) (y : Y) : G.questionWeight x y ≤ G.marginalX x := by unfold marginalX exact Finset.single_le_sum (fun y _ => G.weight_nonneg x y) (Finset.mem_univ y) theorem questionWeight_le_marginalY (G : Game X Y A B) (x : X) (y : Y) : G.questionWeight x y ≤ G.marginalY y := by unfold marginalY exact Finset.single_le_sum (fun x _ => G.weight_nonneg x y) (Finset.mem_univ x) def conditionalYGivenX (G : Game X Y A B) (x : X) (y : Y) : ℝ := G.questionWeight x y / G.marginalX x def conditionalXGivenY (G : Game X Y A B) (y : Y) (x : X) : ℝ := G.questionWeight x y / G.marginalY y theorem conditionalYGivenX_nonneg (G : Game X Y A B) (x : X) (y : Y) : 0 ≤ G.conditionalYGivenX x y := by exact div_nonneg (G.weight_nonneg x y) (G.marginalX_nonneg x) theorem conditionalXGivenY_nonneg (G : Game X Y A B) (y : Y) (x : X) : 0 ≤ G.conditionalXGivenY y x := by exact div_nonneg (G.weight_nonneg x y) (G.marginalY_nonneg y) theorem marginalX_mul_conditionalYGivenX (G : Game X Y A B) (x : X) (y : Y) : G.marginalX x * G.conditionalYGivenX x y = G.questionWeight x y := by unfold conditionalYGivenX by_cases hx : G.marginalX x = 0 · have hzero : G.questionWeight x y = 0 := by have hle := G.questionWeight_le_marginalX x y have hnonneg := G.weight_nonneg x y rw [hx] at hle linarith simp [hx, hzero] · field_simp theorem marginalY_mul_conditionalXGivenY (G : Game X Y A B) (x : X) (y : Y) : G.marginalY y * G.conditionalXGivenY y x = G.questionWeight x y := by unfold conditionalXGivenY by_cases hy : G.marginalY y = 0 · have hzero : G.questionWeight x y = 0 := by have hle := G.questionWeight_le_marginalY x y have hnonneg := G.weight_nonneg x y rw [hy] at hle linarith simp [hy, hzero] · field_simp theorem conditionalYGivenX_sum (G : Game X Y A B) (x : X) (hx : 0 < G.marginalX x) : (∑ y : Y, G.conditionalYGivenX x y) = 1 := by unfold conditionalYGivenX rw [← Finset.sum_div] change G.marginalX x / G.marginalX x = 1 exact div_self hx.ne' theorem conditionalXGivenY_sum (G : Game X Y A B) (y : Y) (hy : 0 < G.marginalY y) : (∑ x : X, G.conditionalXGivenY y x) = 1 := by unfold conditionalXGivenY rw [← Finset.sum_div] change G.marginalY y / G.marginalY y = 1 exact div_self hy.ne' end Game section MixedHistories variable {X Y A B U V : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable [AddCommGroup U] [Module ℝ U] variable [AddCommGroup V] [Module ℝ V] def conditionalBobAverage (G : Game X Y A B) (K : Y → V) (x : X) : V := ∑ y : Y, G.conditionalYGivenX x y • K y def conditionalAliceAverage (G : Game X Y A B) (H : X → U) (y : Y) : U := ∑ x : X, G.conditionalXGivenY y x • H x theorem alice_mixed_history_pairing (G : Game X Y A B) (pair : U →ₗ[ℝ] V →ₗ[ℝ] ℝ) (H : X → U) (K : Y → V) : (∑ x : X, G.marginalX x * pair (H x) (conditionalBobAverage G K x)) = ∑ x : X, ∑ y : Y, G.questionWeight x y * pair (H x) (K y) := by classical apply Finset.sum_congr rfl intro x _ unfold conditionalBobAverage rw [map_sum, Finset.mul_sum] apply Finset.sum_congr rfl intro y _ rw [map_smul] simp only [smul_eq_mul] rw [← mul_assoc, G.marginalX_mul_conditionalYGivenX x y] theorem bob_mixed_history_pairing (G : Game X Y A B) (pair : U →ₗ[ℝ] V →ₗ[ℝ] ℝ) (H : X → U) (K : Y → V) : (∑ y : Y, G.marginalY y * pair (conditionalAliceAverage G H y) (K y)) = ∑ x : X, ∑ y : Y, G.questionWeight x y * pair (H x) (K y) := by classical calc (∑ y : Y, G.marginalY y * pair (conditionalAliceAverage G H y) (K y)) = ∑ y : Y, ∑ x : X, G.questionWeight x y * pair (H x) (K y) := by apply Finset.sum_congr rfl intro y _ unfold conditionalAliceAverage rw [map_sum] simp only [LinearMap.sum_apply, map_smul, LinearMap.smul_apply, smul_eq_mul] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro x _ rw [← mul_assoc, G.marginalY_mul_conditionalXGivenY x y] _ = ∑ x : X, ∑ y : Y, G.questionWeight x y * pair (H x) (K y) := by rw [Finset.sum_comm] theorem alice_reveal_increment (G : Game X Y A B) (pair : U →ₗ[ℝ] V →ₗ[ℝ] ℝ) (H : X → U) (M : Y → U) (K : Y → V) (f : U → U) : (∑ x : X, G.marginalX x * pair (f (H x)) (conditionalBobAverage G K x)) - (∑ y : Y, G.marginalY y * pair (f (M y)) (K y)) = ∑ y : Y, G.marginalY y * pair (conditionalAliceAverage G (fun x => f (H x)) y - f (M y)) (K y) := by classical rw [alice_mixed_history_pairing G pair (fun x => f (H x)) K] rw [← bob_mixed_history_pairing G pair (fun x => f (H x)) K] rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro y _ rw [map_sub] simp only [LinearMap.sub_apply] ring end MixedHistories section RepeatedQuantumFilters open scoped ComplexOrder MatrixOrder variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def conditionedAliceEffect (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (α : {i : Fin n // i ∈ D} → A) (xs : Fin n → X) : Matrix S.Alice S.Alice ℂ := by classical exact ∑ answers : Fin n → A, if ∀ (i : Fin n) (hi : i ∈ D), answers i = α ⟨i, hi⟩ then (S.aliceMeasurement xs).effect answers else 0 def conditionedBobEffect (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (β : {i : Fin n // i ∈ D} → B) (ys : Fin n → Y) : Matrix S.Bob S.Bob ℂ := by classical exact ∑ answers : Fin n → B, if ∀ (i : Fin n) (hi : i ∈ D), answers i = β ⟨i, hi⟩ then (S.bobMeasurement ys).effect answers else 0 theorem conditionedAliceEffect_positive (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (α : {i : Fin n // i ∈ D} → A) (xs : Fin n → X) : (conditionedAliceEffect G n S D α xs).PosSemidef := by classical unfold conditionedAliceEffect apply Matrix.posSemidef_sum Finset.univ intro answers _ split_ifs · exact (S.aliceMeasurement xs).positive answers · exact Matrix.PosSemidef.zero theorem conditionedBobEffect_positive (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (β : {i : Fin n // i ∈ D} → B) (ys : Fin n → Y) : (conditionedBobEffect G n S D β ys).PosSemidef := by classical unfold conditionedBobEffect apply Matrix.posSemidef_sum Finset.univ intro answers _ split_ifs · exact (S.bobMeasurement ys).positive answers · exact Matrix.PosSemidef.zero theorem conditionedAliceEffect_complement_positive (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (α : {i : Fin n // i ∈ D} → A) (xs : Fin n → X) : (1 - conditionedAliceEffect G n S D α xs).PosSemidef := by classical have hsplit : 1 - conditionedAliceEffect G n S D α xs = ∑ answers : Fin n → A, if ∀ (i : Fin n) (hi : i ∈ D), answers i = α ⟨i, hi⟩ then 0 else (S.aliceMeasurement xs).effect answers := by unfold conditionedAliceEffect rw [← (S.aliceMeasurement xs).complete, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro answers _ split_ifs <;> simp rw [hsplit] apply Matrix.posSemidef_sum Finset.univ intro answers _ split_ifs · exact Matrix.PosSemidef.zero · exact (S.aliceMeasurement xs).positive answers theorem conditionedBobEffect_complement_positive (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (β : {i : Fin n // i ∈ D} → B) (ys : Fin n → Y) : (1 - conditionedBobEffect G n S D β ys).PosSemidef := by classical have hsplit : 1 - conditionedBobEffect G n S D β ys = ∑ answers : Fin n → B, if ∀ (i : Fin n) (hi : i ∈ D), answers i = β ⟨i, hi⟩ then 0 else (S.bobMeasurement ys).effect answers := by unfold conditionedBobEffect rw [← (S.bobMeasurement ys).complete, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro answers _ split_ifs <;> simp rw [hsplit] apply Matrix.posSemidef_sum Finset.univ intro answers _ split_ifs · exact Matrix.PosSemidef.zero · exact (S.bobMeasurement ys).positive answers end RepeatedQuantumFilters theorem history_forward_telescope (E : ℕ → ℝ) (m : ℕ) : (∑ k ∈ Finset.range m, (E (k + 1) - E k)) = E m - E 0 := by simpa [Nat.succ_eq_add_one] using Finset.sum_range_sub E m end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder def spectralSupportFunctional {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (f : ℝ → ℝ) : Matrix d d ℂ := (Unitary.conjStarAlgAut ℂ (Matrix d d ℂ) hF.isHermitian.eigenvectorUnitary) (Matrix.diagonal fun i => (f (hF.isHermitian.eigenvalues i) : ℂ)) theorem spectralSupportFunctional_mul {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (f g : ℝ → ℝ) : spectralSupportFunctional F hF f * spectralSupportFunctional F hF g = spectralSupportFunctional F hF (fun x => f x * g x) := by classical let e := Unitary.conjStarAlgAut ℂ (Matrix d d ℂ) hF.isHermitian.eigenvectorUnitary change e _ * e _ = e _ rw [← map_mul, Matrix.diagonal_mul_diagonal] congr 1 funext i push_cast rfl theorem spectralSupportFunctional_id {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : spectralSupportFunctional F hF (fun x => x) = F := by simpa [spectralSupportFunctional, Function.comp_def] using hF.isHermitian.spectral_theorem.symm theorem spectralSupportFunctional_congr {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) {f g : ℝ → ℝ} (h : ∀ i : d, f (hF.isHermitian.eigenvalues i) = g (hF.isHermitian.eigenvalues i)) : spectralSupportFunctional F hF f = spectralSupportFunctional F hF g := by unfold spectralSupportFunctional congr 2 funext i exact_mod_cast h i theorem spectralSupportFunctional_isHermitian {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (f : ℝ → ℝ) : (spectralSupportFunctional F hF f).IsHermitian := by classical let e := Unitary.conjStarAlgAut ℂ (Matrix d d ℂ) hF.isHermitian.eigenvectorUnitary let D : Matrix d d ℂ := Matrix.diagonal fun i => (f (hF.isHermitian.eigenvalues i) : ℂ) have hD : D.IsHermitian := by apply Matrix.isHermitian_diagonal_iff.mpr intro i change star (f (hF.isHermitian.eigenvalues i) : ℂ) = _ simp have hDstar : star D = D := by simpa only [Matrix.star_eq_conjTranspose] using hD.eq change Matrix.conjTranspose (e D) = e D simpa only [Matrix.star_eq_conjTranspose] using (show star (e D) = e D by rw [← map_star, hDstar]) def spectralSupportInverse {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : Matrix d d ℂ := spectralSupportFunctional F hF (fun x => x⁻¹) def spectralSupportProjection {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : Matrix d d ℂ := spectralSupportFunctional F hF (fun x => if x = 0 then 0 else 1) def spectralSupportSqrt {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : Matrix d d ℂ := spectralSupportFunctional F hF Real.sqrt theorem spectralSupportInverse_isHermitian {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : (spectralSupportInverse F hF).IsHermitian := spectralSupportFunctional_isHermitian F hF _ theorem spectralSupportProjection_isHermitian {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : (spectralSupportProjection F hF).IsHermitian := spectralSupportFunctional_isHermitian F hF _ theorem spectralSupportInverse_mul {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : spectralSupportInverse F hF * F = spectralSupportProjection F hF := by change spectralSupportFunctional F hF (fun x => x⁻¹) * F = spectralSupportFunctional F hF (fun x => if x = 0 then 0 else 1) calc spectralSupportFunctional F hF (fun x => x⁻¹) * F = spectralSupportFunctional F hF (fun x => x⁻¹) * spectralSupportFunctional F hF (fun x => x) := by rw [spectralSupportFunctional_id] _ = spectralSupportFunctional F hF (fun x => x⁻¹ * x) := spectralSupportFunctional_mul F hF _ _ _ = _ := spectralSupportFunctional_congr F hF (by intro i by_cases hi : hF.isHermitian.eigenvalues i = 0 · simp [hi] · simp [hi]) theorem mul_spectralSupportInverse {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : F * spectralSupportInverse F hF = spectralSupportProjection F hF := by change F * spectralSupportFunctional F hF (fun x => x⁻¹) = spectralSupportFunctional F hF (fun x => if x = 0 then 0 else 1) calc F * spectralSupportFunctional F hF (fun x => x⁻¹) = spectralSupportFunctional F hF (fun x => x) * spectralSupportFunctional F hF (fun x => x⁻¹) := by rw [spectralSupportFunctional_id] _ = spectralSupportFunctional F hF (fun x => x * x⁻¹) := spectralSupportFunctional_mul F hF _ _ _ = _ := spectralSupportFunctional_congr F hF (by intro i by_cases hi : hF.isHermitian.eigenvalues i = 0 · simp [hi] · simp [hi]) theorem spectralSupportProjection_mul {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : spectralSupportProjection F hF * F = F := by change spectralSupportFunctional F hF (fun x => if x = 0 then 0 else 1) * F = F calc spectralSupportFunctional F hF (fun x => if x = 0 then 0 else 1) * F = spectralSupportFunctional F hF (fun x => if x = 0 then 0 else 1) * spectralSupportFunctional F hF (fun x => x) := by rw [spectralSupportFunctional_id] _ = spectralSupportFunctional F hF (fun x => (if x = 0 then 0 else 1) * x) := spectralSupportFunctional_mul F hF _ _ _ = spectralSupportFunctional F hF (fun x => x) := spectralSupportFunctional_congr F hF (by intro i by_cases hi : hF.isHermitian.eigenvalues i = 0 <;> simp [hi]) _ = F := spectralSupportFunctional_id F hF theorem spectralSupportInverse_penrose {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : spectralSupportInverse F hF * F * spectralSupportInverse F hF = spectralSupportInverse F hF := by change spectralSupportFunctional F hF (fun x => x⁻¹) * F * spectralSupportFunctional F hF (fun x => x⁻¹) = spectralSupportFunctional F hF (fun x => x⁻¹) calc spectralSupportFunctional F hF (fun x => x⁻¹) * F * spectralSupportFunctional F hF (fun x => x⁻¹) = (spectralSupportFunctional F hF (fun x => x⁻¹) * spectralSupportFunctional F hF (fun x => x)) * spectralSupportFunctional F hF (fun x => x⁻¹) := by rw [spectralSupportFunctional_id] _ = spectralSupportFunctional F hF (fun x => (x⁻¹ * x) * x⁻¹) := by rw [spectralSupportFunctional_mul, spectralSupportFunctional_mul] _ = _ := spectralSupportFunctional_congr F hF (by intro i by_cases hi : hF.isHermitian.eigenvalues i = 0 · simp [hi] · simp [hi]) theorem spectralSupportSqrt_sq {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : spectralSupportSqrt F hF * spectralSupportSqrt F hF = F := by change spectralSupportFunctional F hF Real.sqrt * spectralSupportFunctional F hF Real.sqrt = F calc spectralSupportFunctional F hF Real.sqrt * spectralSupportFunctional F hF Real.sqrt = spectralSupportFunctional F hF (fun x => Real.sqrt x * Real.sqrt x) := spectralSupportFunctional_mul F hF _ _ _ = spectralSupportFunctional F hF (fun x => x) := spectralSupportFunctional_congr F hF (by intro i exact Real.mul_self_sqrt (hF.eigenvalues_nonneg i)) _ = F := spectralSupportFunctional_id F hF end noncomputable section open Matrix open scoped BigOperators ComplexOrder MatrixOrder theorem mul_spectralSupportProjection {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : F * spectralSupportProjection F hF = F := by have h := congrArg Matrix.conjTranspose (spectralSupportProjection_mul F hF) simpa [Matrix.conjTranspose_mul, (spectralSupportProjection_isHermitian F hF).eq, hF.isHermitian.eq] using h theorem posSemidef_kernel_of_sub_posSemidef {d : Type*} [Fintype d] [DecidableEq d] {F A : Matrix d d ℂ} (hA : A.PosSemidef) (hsub : (F - A).PosSemidef) {x : d → ℂ} (hx : F *ᵥ x = 0) : A *ᵥ x = 0 := by apply (hA.dotProduct_mulVec_zero_iff x).mp have hA_nonneg : 0 ≤ star x ⬝ᵥ (A *ᵥ x) := hA.dotProduct_mulVec_nonneg x have hsub_nonneg : 0 ≤ star x ⬝ᵥ ((F - A) *ᵥ x) := hsub.dotProduct_mulVec_nonneg x have hzero : star x ⬝ᵥ (A *ᵥ x) + star x ⬝ᵥ ((F - A) *ᵥ x) = 0 := by calc star x ⬝ᵥ (A *ᵥ x) + star x ⬝ᵥ ((F - A) *ᵥ x) = star x ⬝ᵥ ((A + (F - A)) *ᵥ x) := by rw [Matrix.add_mulVec, dotProduct_add] _ = star x ⬝ᵥ (F *ᵥ x) := by have hsum : A + (F - A) = F := by abel rw [hsum] _ = 0 := by rw [hx]; simp exact (add_eq_zero_iff_of_nonneg hA_nonneg hsub_nonneg).mp hzero |>.1 theorem posSemidef_mul_spectralSupportProjection {d : Type*} [Fintype d] [DecidableEq d] {F A : Matrix d d ℂ} (hF : F.PosSemidef) (hA : A.PosSemidef) (hsub : (F - A).PosSemidef) : A * spectralSupportProjection F hF = A := by let P := spectralSupportProjection F hF have hFP : F * P = F := mul_spectralSupportProjection F hF have hkernel : F * (1 - P) = 0 := by rw [mul_sub, mul_one, hFP, sub_self] have hAzero : A * (1 - P) = 0 := by apply Matrix.ext_of_mulVec_single intro i have hxi : F *ᵥ ((1 - P) *ᵥ Pi.single i 1) = 0 := by have h := congrArg (fun M : Matrix d d ℂ => M *ᵥ Pi.single i 1) hkernel simpa only [Matrix.mulVec_mulVec, Matrix.zero_mulVec] using h have hAi := posSemidef_kernel_of_sub_posSemidef hA hsub hxi simpa only [Matrix.mulVec_mulVec, Matrix.zero_mulVec] using hAi have hdiff : A - A * P = 0 := by simpa [mul_sub] using hAzero exact (sub_eq_zero.mp hdiff).symm theorem spectralSupportProjection_mul_posSemidef {d : Type*} [Fintype d] [DecidableEq d] {F A : Matrix d d ℂ} (hF : F.PosSemidef) (hA : A.PosSemidef) (hsub : (F - A).PosSemidef) : spectralSupportProjection F hF * A = A := by have h := congrArg Matrix.conjTranspose (posSemidef_mul_spectralSupportProjection hF hA hsub) simpa [Matrix.conjTranspose_mul, (spectralSupportProjection_isHermitian F hF).eq, hA.isHermitian.eq] using h theorem refinement_complement_posSemidef {ι d : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] [DecidableEq d] (effect : ι → Matrix d d ℂ) (hpositive : ∀ a, (effect a).PosSemidef) (a : ι) : ((∑ b : ι, effect b) - effect a).PosSemidef := by have herase : (∑ b ∈ Finset.univ.erase a, effect b).PosSemidef := by apply Matrix.posSemidef_sum (Finset.univ.erase a) intro c _ exact hpositive c have hsum : effect a + (∑ b ∈ Finset.univ.erase a, effect b) = ∑ b : ι, effect b := by simp rw [← hsum, add_sub_cancel_left] exact herase end noncomputable section open Matrix open scoped BigOperators ComplexOrder MatrixOrder set_option maxHeartbeats 400000 def purificationRangeProjection {d e : Type*} [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) : Matrix e e ℂ := Γ * spectralSupportInverse F hF * Matrix.conjTranspose Γ theorem purificationRangeProjection_isHermitian {d e : Type*} [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) : (purificationRangeProjection F hF Γ).IsHermitian := by unfold purificationRangeProjection change Matrix.conjTranspose (Γ * spectralSupportInverse F hF * Matrix.conjTranspose Γ) = _ simp [Matrix.conjTranspose_mul, (spectralSupportInverse_isHermitian F hF).eq, Matrix.mul_assoc] theorem purificationRangeProjection_idempotent {d e : Type*} [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) : purificationRangeProjection F hF Γ * purificationRangeProjection F hF Γ = purificationRangeProjection F hF Γ := by unfold purificationRangeProjection calc (Γ * spectralSupportInverse F hF * Matrix.conjTranspose Γ) * (Γ * spectralSupportInverse F hF * Matrix.conjTranspose Γ) = Γ * (spectralSupportInverse F hF * (Matrix.conjTranspose Γ * Γ) * spectralSupportInverse F hF) * Matrix.conjTranspose Γ := by simp only [Matrix.mul_assoc] _ = Γ * (spectralSupportInverse F hF * F * spectralSupportInverse F hF) * Matrix.conjTranspose Γ := by rw [hΓ] _ = Γ * spectralSupportInverse F hF * Matrix.conjTranspose Γ := by rw [spectralSupportInverse_penrose] theorem purificationRangeProjection_complement_posSemidef {d e : Type*} [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) : (1 - purificationRangeProjection F hF Γ).PosSemidef := by let P := purificationRangeProjection F hF Γ have hPstar : Matrix.conjTranspose P = P := (purificationRangeProjection_isHermitian F hF Γ).eq have hPsq : P * P = P := purificationRangeProjection_idempotent F hF Γ hΓ have hsquare : Matrix.conjTranspose (1 - P) * (1 - P) = 1 - P := by calc Matrix.conjTranspose (1 - P) * (1 - P) = (1 - P) * (1 - P) := by simp [Matrix.conjTranspose_sub, hPstar] _ = 1 - P - P + P * P := by noncomm_ring _ = 1 - P := by rw [hPsq]; noncomm_ring have hpositive := Matrix.posSemidef_conjTranspose_mul_self (1 - P) rw [hsquare] at hpositive exact hpositive def purifiedRefinementCore {ι d e : Type*} [Fintype ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (effect : ι → Matrix d d ℂ) (a : ι) : Matrix e e ℂ := Γ * spectralSupportInverse F hF * effect a * spectralSupportInverse F hF * Matrix.conjTranspose Γ theorem purifiedRefinementCore_posSemidef {ι d e : Type*} [Fintype ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (effect : ι → Matrix d d ℂ) (hpositive : ∀ a, (effect a).PosSemidef) (a : ι) : (purifiedRefinementCore F hF Γ effect a).PosSemidef := by have h := (hpositive a).mul_mul_conjTranspose_same (Γ * spectralSupportInverse F hF) simpa [purifiedRefinementCore, Matrix.conjTranspose_mul, (spectralSupportInverse_isHermitian F hF).eq, Matrix.mul_assoc] using h theorem purifiedRefinementCore_sum {ι d e : Type*} [Fintype ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (effect : ι → Matrix d d ℂ) (hsum : (∑ a : ι, effect a) = F) : (∑ a : ι, purifiedRefinementCore F hF Γ effect a) = purificationRangeProjection F hF Γ := by unfold purifiedRefinementCore purificationRangeProjection calc (∑ a : ι, Γ * spectralSupportInverse F hF * effect a * spectralSupportInverse F hF * Matrix.conjTranspose Γ) = Γ * spectralSupportInverse F hF * (∑ a : ι, effect a) * spectralSupportInverse F hF * Matrix.conjTranspose Γ := by simp only [Matrix.mul_sum, Matrix.sum_mul] _ = Γ * spectralSupportInverse F hF * F * spectralSupportInverse F hF * Matrix.conjTranspose Γ := by rw [hsum] _ = Γ * (spectralSupportInverse F hF * F * spectralSupportInverse F hF) * Matrix.conjTranspose Γ := by simp only [Matrix.mul_assoc] _ = Γ * spectralSupportInverse F hF * Matrix.conjTranspose Γ := by rw [spectralSupportInverse_penrose] def purifiedRefinedEffect {ι d e : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (effect : ι → Matrix d d ℂ) (a₀ a : ι) : Matrix e e ℂ := purifiedRefinementCore F hF Γ effect a + if a = a₀ then 1 - purificationRangeProjection F hF Γ else 0 theorem purifiedRefinedEffect_posSemidef {ι d e : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) (effect : ι → Matrix d d ℂ) (hpositive : ∀ a, (effect a).PosSemidef) (a₀ a : ι) : (purifiedRefinedEffect F hF Γ effect a₀ a).PosSemidef := by change (purifiedRefinementCore F hF Γ effect a + if a = a₀ then 1 - purificationRangeProjection F hF Γ else 0).PosSemidef refine (purifiedRefinementCore_posSemidef F hF Γ effect hpositive a).add ?_ split · exact purificationRangeProjection_complement_posSemidef F hF Γ hΓ · exact Matrix.PosSemidef.zero theorem purifiedRefinedEffect_complete {ι d e : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (effect : ι → Matrix d d ℂ) (hsum : (∑ a : ι, effect a) = F) (a₀ : ι) : (∑ a : ι, purifiedRefinedEffect F hF Γ effect a₀ a) = 1 := by classical unfold purifiedRefinedEffect rw [Finset.sum_add_distrib] rw [purifiedRefinementCore_sum F hF Γ effect hsum] simp theorem purificationRangeProjection_compression {d e : Type*} [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) : Matrix.conjTranspose Γ * purificationRangeProjection F hF Γ * Γ = F := by unfold purificationRangeProjection calc Matrix.conjTranspose Γ * (Γ * spectralSupportInverse F hF * Matrix.conjTranspose Γ) * Γ = (Matrix.conjTranspose Γ * Γ) * spectralSupportInverse F hF * (Matrix.conjTranspose Γ * Γ) := by simp only [Matrix.mul_assoc] _ = F * spectralSupportInverse F hF * F := by rw [hΓ] _ = spectralSupportProjection F hF * F := by rw [mul_spectralSupportInverse] _ = F := spectralSupportProjection_mul F hF theorem purificationRangeProjection_complement_compression {d e : Type*} [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) : Matrix.conjTranspose Γ * (1 - purificationRangeProjection F hF Γ) * Γ = 0 := by calc Matrix.conjTranspose Γ * (1 - purificationRangeProjection F hF Γ) * Γ = Matrix.conjTranspose Γ * Γ - Matrix.conjTranspose Γ * purificationRangeProjection F hF Γ * Γ := by rw [Matrix.mul_sub, Matrix.sub_mul] simp _ = F - F := by rw [hΓ, purificationRangeProjection_compression F hF Γ hΓ] _ = 0 := sub_self F theorem purifiedRefinementCore_compression {ι d e : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) (effect : ι → Matrix d d ℂ) (hpositive : ∀ a, (effect a).PosSemidef) (hsum : (∑ a : ι, effect a) = F) (a : ι) : Matrix.conjTranspose Γ * purifiedRefinementCore F hF Γ effect a * Γ = effect a := by have hsub : (F - effect a).PosSemidef := by rw [← hsum] exact refinement_complement_posSemidef effect hpositive a unfold purifiedRefinementCore calc Matrix.conjTranspose Γ * (Γ * spectralSupportInverse F hF * effect a * spectralSupportInverse F hF * Matrix.conjTranspose Γ) * Γ = (Matrix.conjTranspose Γ * Γ) * spectralSupportInverse F hF * effect a * spectralSupportInverse F hF * (Matrix.conjTranspose Γ * Γ) := by simp only [Matrix.mul_assoc] _ = F * spectralSupportInverse F hF * effect a * spectralSupportInverse F hF * F := by rw [hΓ] _ = (F * spectralSupportInverse F hF) * effect a * (spectralSupportInverse F hF * F) := by simp only [Matrix.mul_assoc] _ = spectralSupportProjection F hF * effect a * spectralSupportProjection F hF := by rw [mul_spectralSupportInverse, spectralSupportInverse_mul] _ = effect a := by rw [spectralSupportProjection_mul_posSemidef hF (hpositive a) hsub] exact posSemidef_mul_spectralSupportProjection hF (hpositive a) hsub theorem purifiedRefinedEffect_compression {ι d e : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) (effect : ι → Matrix d d ℂ) (hpositive : ∀ a, (effect a).PosSemidef) (hsum : (∑ a : ι, effect a) = F) (a₀ a : ι) : Matrix.conjTranspose Γ * purifiedRefinedEffect F hF Γ effect a₀ a * Γ = effect a := by have hdefect : Matrix.conjTranspose Γ * (if a = a₀ then 1 - purificationRangeProjection F hF Γ else 0) * Γ = 0 := by split · exact purificationRangeProjection_complement_compression F hF Γ hΓ · simp change Matrix.conjTranspose Γ * (purifiedRefinementCore F hF Γ effect a + if a = a₀ then 1 - purificationRangeProjection F hF Γ else 0) * Γ = effect a rw [Matrix.mul_add, Matrix.add_mul] rw [purifiedRefinementCore_compression F hF Γ hΓ effect hpositive hsum a, hdefect, add_zero] def purifiedRefinedPOVM {ι d e : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) (effect : ι → Matrix d d ℂ) (hpositive : ∀ a, (effect a).PosSemidef) (hsum : (∑ a : ι, effect a) = F) (a₀ : ι) : POVM ι e where effect := purifiedRefinedEffect F hF Γ effect a₀ positive a := purifiedRefinedEffect_posSemidef F hF Γ hΓ effect hpositive a₀ a complete := purifiedRefinedEffect_complete F hF Γ effect hsum a₀ theorem purifiedRefinedPOVM_compression {ι d e : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] [DecidableEq d] [Fintype e] [DecidableEq e] (F : Matrix d d ℂ) (hF : F.PosSemidef) (Γ : Matrix e d ℂ) (hΓ : Matrix.conjTranspose Γ * Γ = F) (effect : ι → Matrix d d ℂ) (hpositive : ∀ a, (effect a).PosSemidef) (hsum : (∑ a : ι, effect a) = F) (a₀ a : ι) : Matrix.conjTranspose Γ * (purifiedRefinedPOVM F hF Γ hΓ effect hpositive hsum a₀).effect a * Γ = effect a := purifiedRefinedEffect_compression F hF Γ hΓ effect hpositive hsum a₀ a end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 600000 def fullHistoryRemaining (n : ℕ) (D L : Finset (Fin n)) : Finset (Fin n) := (Finset.univ \ D) \ L @[ext (iff := false)] structure FullSubsetHistory (X Y : Type*) [Fintype X] [Fintype Y] (n : ℕ) (D L : Finset (Fin n)) where aliceConditioned : {i : Fin n // i ∈ D} → X bobConditioned : {i : Fin n // i ∈ D} → Y aliceRevealed : {i : Fin n // i ∈ L} → X bobRemaining : {i : Fin n // i ∈ fullHistoryRemaining n D L} → Y deriving Fintype def fullHistoryAliceQuestion {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (hidden : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X) : Fin n → X := fun i => if hiD : i ∈ D then h.aliceConditioned ⟨i, hiD⟩ else if hiL : i ∈ L then h.aliceRevealed ⟨i, hiL⟩ else hidden ⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩ def fullHistoryBobQuestion {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (hidden : {i : Fin n // i ∈ L} → Y) : Fin n → Y := fun i => if hiD : i ∈ D then h.bobConditioned ⟨i, hiD⟩ else if hiL : i ∈ L then hidden ⟨i, hiL⟩ else h.bobRemaining ⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩ def fullHistoryQuestionEquiv {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (hL : L ⊆ Finset.univ \ D) : (FullSubsetHistory X Y n D L × ({i : Fin n // i ∈ fullHistoryRemaining n D L} → X) × ({i : Fin n // i ∈ L} → Y)) ≃ ((Fin n → X) × (Fin n → Y)) where toFun t := (fullHistoryAliceQuestion t.1 t.2.1, fullHistoryBobQuestion t.1 t.2.2) invFun q := (⟨fun i => q.1 i, fun i => q.2 i, fun i => q.1 i, fun i => q.2 i⟩, (fun i => q.1 i), (fun i => q.2 i)) left_inv := by rintro ⟨h, hx, hy⟩ apply Prod.ext · apply FullSubsetHistory.ext · funext i simp [fullHistoryAliceQuestion, i.property] · funext i simp [fullHistoryBobQuestion, i.property] · funext i have hiD : (i : Fin n) ∉ D := (Finset.mem_sdiff.mp (hL i.property)).2 simp [fullHistoryAliceQuestion, hiD, i.property] · funext i have hiD : (i : Fin n) ∉ D := by have := i.property simpa [fullHistoryRemaining] using (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp i.property).1).2 have hiL : (i : Fin n) ∉ L := (Finset.mem_sdiff.mp i.property).2 simp [fullHistoryBobQuestion, hiD, hiL] · apply Prod.ext · funext i have hiD : (i : Fin n) ∉ D := (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp i.property).1).2 have hiL : (i : Fin n) ∉ L := (Finset.mem_sdiff.mp i.property).2 simp [fullHistoryAliceQuestion, hiD, hiL] · funext i have hiD : (i : Fin n) ∉ D := (Finset.mem_sdiff.mp (hL i.property)).2 simp [fullHistoryBobQuestion, hiD, i.property] right_inv := by rintro ⟨xs, ys⟩ apply Prod.ext · funext i by_cases hiD : i ∈ D · simp [fullHistoryAliceQuestion, hiD] · by_cases hiL : i ∈ L <;> simp [fullHistoryAliceQuestion, hiD, hiL] · funext i by_cases hiD : i ∈ D · simp [fullHistoryBobQuestion, hiD] · by_cases hiL : i ∈ L <;> simp [fullHistoryBobQuestion, hiD, hiL] section ActualHistoryWeights variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def fullHistoryWeight (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) : ℝ := (∏ i : {i : Fin n // i ∈ D}, G.questionWeight (h.aliceConditioned i) (h.bobConditioned i)) * (∏ i : {i : Fin n // i ∈ L}, G.marginalX (h.aliceRevealed i)) * (∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.marginalY (h.bobRemaining i)) def fullHistoryHiddenAliceWeight (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (hidden : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X) : ℝ := ∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.conditionalXGivenY (h.bobRemaining i) (hidden i) def fullHistoryHiddenBobWeight (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (hidden : {i : Fin n // i ∈ L} → Y) : ℝ := ∏ i : {i : Fin n // i ∈ L}, G.conditionalYGivenX (h.aliceRevealed i) (hidden i) theorem fullHistoryWeight_nonneg (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) : 0 ≤ fullHistoryWeight G h := by unfold fullHistoryWeight apply mul_nonneg · apply mul_nonneg · exact Finset.prod_nonneg fun i _ => G.weight_nonneg (h.aliceConditioned i) (h.bobConditioned i) · exact Finset.prod_nonneg fun i _ => G.marginalX_nonneg (h.aliceRevealed i) · exact Finset.prod_nonneg fun i _ => G.marginalY_nonneg (h.bobRemaining i) theorem fullHistoryHiddenAliceWeight_nonneg (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (hidden : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X) : 0 ≤ fullHistoryHiddenAliceWeight G h hidden := by unfold fullHistoryHiddenAliceWeight exact Finset.prod_nonneg fun i _ => G.conditionalXGivenY_nonneg (h.bobRemaining i) (hidden i) theorem fullHistoryHiddenBobWeight_nonneg (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (hidden : {i : Fin n // i ∈ L} → Y) : 0 ≤ fullHistoryHiddenBobWeight G h hidden := by unfold fullHistoryHiddenBobWeight exact Finset.prod_nonneg fun i _ => G.conditionalYGivenX_nonneg (h.aliceRevealed i) (hidden i) theorem fullHistoryWeight_mul_hidden (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (hL : L ⊆ Finset.univ \ D) (h : FullSubsetHistory X Y n D L) (hx : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X) (hy : {i : Fin n // i ∈ L} → Y) : fullHistoryWeight G h * fullHistoryHiddenAliceWeight G h hx * fullHistoryHiddenBobWeight G h hy = (G.repeat n).questionWeight (fullHistoryAliceQuestion h hx) (fullHistoryBobQuestion h hy) := by classical let q : Fin n → ℝ := fun i => G.questionWeight (fullHistoryAliceQuestion h hx i) (fullHistoryBobQuestion h hy i) have hDprod : (∏ i : {i : Fin n // i ∈ D}, G.questionWeight (h.aliceConditioned i) (h.bobConditioned i)) = ∏ i ∈ D, q i := by calc (∏ i : {i : Fin n // i ∈ D}, G.questionWeight (h.aliceConditioned i) (h.bobConditioned i)) = ∏ i : {i : Fin n // i ∈ D}, q i := by apply Finset.prod_congr rfl intro i _ simp [q, fullHistoryAliceQuestion, fullHistoryBobQuestion, i.property] _ = ∏ i ∈ D, q i := Finset.prod_coe_sort D q have hLprod : (∏ i : {i : Fin n // i ∈ L}, G.marginalX (h.aliceRevealed i)) * (∏ i : {i : Fin n // i ∈ L}, G.conditionalYGivenX (h.aliceRevealed i) (hy i)) = ∏ i ∈ L, q i := by rw [← Finset.prod_mul_distrib] calc (∏ i : {i : Fin n // i ∈ L}, G.marginalX (h.aliceRevealed i) * G.conditionalYGivenX (h.aliceRevealed i) (hy i)) = ∏ i : {i : Fin n // i ∈ L}, q i := by apply Finset.prod_congr rfl intro i _ have hiD : (i : Fin n) ∉ D := (Finset.mem_sdiff.mp (hL i.property)).2 simpa [q, fullHistoryAliceQuestion, fullHistoryBobQuestion, hiD, i.property] using G.marginalX_mul_conditionalYGivenX (h.aliceRevealed i) (hy i) _ = ∏ i ∈ L, q i := Finset.prod_coe_sort L q have hRprod : (∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.marginalY (h.bobRemaining i)) * (∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.conditionalXGivenY (h.bobRemaining i) (hx i)) = ∏ i ∈ fullHistoryRemaining n D L, q i := by rw [← Finset.prod_mul_distrib] calc (∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.marginalY (h.bobRemaining i) * G.conditionalXGivenY (h.bobRemaining i) (hx i)) = ∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, q i := by apply Finset.prod_congr rfl intro i _ have hiD : (i : Fin n) ∉ D := (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp i.property).1).2 have hiL : (i : Fin n) ∉ L := (Finset.mem_sdiff.mp i.property).2 simpa [q, fullHistoryAliceQuestion, fullHistoryBobQuestion, hiD, hiL] using G.marginalY_mul_conditionalXGivenY (hx i) (h.bobRemaining i) _ = ∏ i ∈ fullHistoryRemaining n D L, q i := Finset.prod_coe_sort (fullHistoryRemaining n D L) q have hDL : Disjoint D L := by apply Finset.disjoint_left.mpr intro i hiD hiL exact (Finset.mem_sdiff.mp (hL hiL)).2 hiD have hDR : Disjoint (D ∪ L) (fullHistoryRemaining n D L) := by apply Finset.disjoint_left.mpr intro i hiUnion hiR have hiD : i ∉ D := (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp hiR).1).2 have hiL : i ∉ L := (Finset.mem_sdiff.mp hiR).2 rcases Finset.mem_union.mp hiUnion with hi | hi · exact hiD hi · exact hiL hi have hcover : D ∪ L ∪ fullHistoryRemaining n D L = (Finset.univ : Finset (Fin n)) := by ext i simp [fullHistoryRemaining] tauto rw [Game.repeat_questionWeight] change fullHistoryWeight G h * fullHistoryHiddenAliceWeight G h hx * fullHistoryHiddenBobWeight G h hy = ∏ i : Fin n, q i unfold fullHistoryWeight fullHistoryHiddenAliceWeight fullHistoryHiddenBobWeight calc ((∏ i : {i : Fin n // i ∈ D}, G.questionWeight (h.aliceConditioned i) (h.bobConditioned i)) * (∏ i : {i : Fin n // i ∈ L}, G.marginalX (h.aliceRevealed i)) * (∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.marginalY (h.bobRemaining i))) * (∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.conditionalXGivenY (h.bobRemaining i) (hx i)) * (∏ i : {i : Fin n // i ∈ L}, G.conditionalYGivenX (h.aliceRevealed i) (hy i)) = (∏ i : {i : Fin n // i ∈ D}, G.questionWeight (h.aliceConditioned i) (h.bobConditioned i)) * ((∏ i : {i : Fin n // i ∈ L}, G.marginalX (h.aliceRevealed i)) * (∏ i : {i : Fin n // i ∈ L}, G.conditionalYGivenX (h.aliceRevealed i) (hy i))) * ((∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.marginalY (h.bobRemaining i)) * (∏ i : {i : Fin n // i ∈ fullHistoryRemaining n D L}, G.conditionalXGivenY (h.bobRemaining i) (hx i))) := by ring _ = (∏ i ∈ D, q i) * (∏ i ∈ L, q i) * (∏ i ∈ fullHistoryRemaining n D L, q i) := by rw [hDprod, hLprod, hRprod] _ = ∏ i : Fin n, q i := by rw [← Finset.prod_union hDL, ← Finset.prod_union hDR, hcover] def fullHistoryAliceFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (α : {i : Fin n // i ∈ D} → A) : Matrix S.Alice S.Alice ℂ := ∑ hidden : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X, fullHistoryHiddenAliceWeight G h hidden • conditionedAliceEffect G n S D α (fullHistoryAliceQuestion h hidden) def fullHistoryBobFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (β : {i : Fin n // i ∈ D} → B) : Matrix S.Bob S.Bob ℂ := ∑ hidden : {i : Fin n // i ∈ L} → Y, fullHistoryHiddenBobWeight G h hidden • conditionedBobEffect G n S D β (fullHistoryBobQuestion h hidden) theorem fullHistoryAliceFilter_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (α : {i : Fin n // i ∈ D} → A) : (fullHistoryAliceFilter G n S D L h α).PosSemidef := by unfold fullHistoryAliceFilter apply Matrix.posSemidef_sum Finset.univ intro hidden _ exact (conditionedAliceEffect_positive G n S D α (fullHistoryAliceQuestion h hidden)).smul (fullHistoryHiddenAliceWeight_nonneg G h hidden) theorem fullHistoryBobFilter_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (β : {i : Fin n // i ∈ D} → B) : (fullHistoryBobFilter G n S D L h β).PosSemidef := by unfold fullHistoryBobFilter apply Matrix.posSemidef_sum Finset.univ intro hidden _ exact (conditionedBobEffect_positive G n S D β (fullHistoryBobQuestion h hidden)).smul (fullHistoryHiddenBobWeight_nonneg G h hidden) def fullHistoryWinIndicator (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (α : {i : Fin n // i ∈ D} → A) (β : {i : Fin n // i ∈ D} → B) : ℝ := by classical exact if ∀ i : {i : Fin n // i ∈ D}, G.predicate (h.aliceConditioned i) (h.bobConditioned i) (α i) (β i) = true then 1 else 0 theorem fullHistoryWinIndicator_nonneg (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (α : {i : Fin n // i ∈ D} → A) (β : {i : Fin n // i ∈ D} → B) : 0 ≤ fullHistoryWinIndicator G h α β := by classical unfold fullHistoryWinIndicator split <;> norm_num theorem conditionedAnswerMatches_iff {T : Type*} {n : ℕ} (D : Finset (Fin n)) (answer : Fin n → T) (α : {i : Fin n // i ∈ D} → T) : (∀ (i : Fin n) (hi : i ∈ D), answer i = α ⟨i, hi⟩) ↔ α = fun i : {i : Fin n // i ∈ D} => answer (i : Fin n) := by constructor · intro h funext i exact (h i i.property).symm · intro h i hi subst α rfl theorem conditionedEffects_born_expansion [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (α : {i : Fin n // i ∈ D} → A) (β : {i : Fin n // i ∈ D} → B) (xs : Fin n → X) (ys : Fin n → Y) : bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α xs) (conditionedBobEffect G n S D β ys) = ∑ aa : Fin n → A, ∑ bb : Fin n → B, if ∀ (i : Fin n) (hi : i ∈ D), aa i = α ⟨i, hi⟩ then if ∀ (i : Fin n) (hi : i ∈ D), bb i = β ⟨i, hi⟩ then S.outcomeProbability xs ys aa bb else 0 else 0 := by classical simp only [conditionedAliceEffect, conditionedBobEffect, map_sum, LinearMap.sum_apply] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro aa _ split_ifs with ha · apply Finset.sum_congr rfl intro bb _ split_ifs with hb · rfl · exact map_zero _ · simp theorem finite_sum_four_swap {I J K T : Type*} [Fintype I] [Fintype J] [Fintype K] [Fintype T] (f : I → J → K → T → ℝ) : (∑ i : I, ∑ j : J, ∑ k : K, ∑ t : T, f i j k t) = ∑ k : K, ∑ t : T, ∑ i : I, ∑ j : J, f i j k t := by classical calc (∑ i : I, ∑ j : J, ∑ k : K, ∑ t : T, f i j k t) = ∑ i : I, ∑ k : K, ∑ j : J, ∑ t : T, f i j k t := by apply Finset.sum_congr rfl intro i _ rw [Finset.sum_comm] _ = ∑ k : K, ∑ i : I, ∑ j : J, ∑ t : T, f i j k t := by rw [Finset.sum_comm] _ = ∑ k : K, ∑ i : I, ∑ t : T, ∑ j : J, f i j k t := by apply Finset.sum_congr rfl intro k _ apply Finset.sum_congr rfl intro i _ rw [Finset.sum_comm] _ = ∑ k : K, ∑ t : T, ∑ i : I, ∑ j : J, f i j k t := by apply Finset.sum_congr rfl intro k _ rw [Finset.sum_comm] def fullQuestionWinIndicator (G : Game X Y A B) {n : ℕ} (D : Finset (Fin n)) (xs : Fin n → X) (ys : Fin n → Y) (α : {i : Fin n // i ∈ D} → A) (β : {i : Fin n // i ∈ D} → B) : ℝ := by classical exact if ∀ i : {i : Fin n // i ∈ D}, G.predicate (xs i) (ys i) (α i) (β i) = true then 1 else 0 theorem fullHistoryWinIndicator_eq_question (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (hx : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X) (hy : {i : Fin n // i ∈ L} → Y) (α : {i : Fin n // i ∈ D} → A) (β : {i : Fin n // i ∈ D} → B) : fullHistoryWinIndicator G h α β = fullQuestionWinIndicator G D (fullHistoryAliceQuestion h hx) (fullHistoryBobQuestion h hy) α β := by classical unfold fullHistoryWinIndicator fullQuestionWinIndicator congr 1 apply propext constructor · intro hw i simpa [fullHistoryAliceQuestion, fullHistoryBobQuestion, i.property] using hw i · intro hw i simpa [fullHistoryAliceQuestion, fullHistoryBobQuestion, i.property] using hw i theorem conditionedEffects_postselection_sum [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (xs : Fin n → X) (ys : Fin n → Y) : (∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullQuestionWinIndicator G D xs ys α β * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α xs) (conditionedBobEffect G n S D β ys)) = ∑ aa : Fin n → A, ∑ bb : Fin n → B, if ∀ i : {i : Fin n // i ∈ D}, G.predicate (xs i) (ys i) (aa i) (bb i) = true then S.outcomeProbability xs ys aa bb else 0 := by classical simp_rw [conditionedEffects_born_expansion G n S D] calc (∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullQuestionWinIndicator G D xs ys α β * (∑ aa : Fin n → A, ∑ bb : Fin n → B, if ∀ (i : Fin n) (hi : i ∈ D), aa i = α ⟨i, hi⟩ then if ∀ (i : Fin n) (hi : i ∈ D), bb i = β ⟨i, hi⟩ then S.outcomeProbability xs ys aa bb else 0 else 0)) = ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, ∑ aa : Fin n → A, ∑ bb : Fin n → B, fullQuestionWinIndicator G D xs ys α β * (if ∀ (i : Fin n) (hi : i ∈ D), aa i = α ⟨i, hi⟩ then if ∀ (i : Fin n) (hi : i ∈ D), bb i = β ⟨i, hi⟩ then S.outcomeProbability xs ys aa bb else 0 else 0) := by simp only [Finset.mul_sum] _ = ∑ aa : Fin n → A, ∑ bb : Fin n → B, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullQuestionWinIndicator G D xs ys α β * (if ∀ (i : Fin n) (hi : i ∈ D), aa i = α ⟨i, hi⟩ then if ∀ (i : Fin n) (hi : i ∈ D), bb i = β ⟨i, hi⟩ then S.outcomeProbability xs ys aa bb else 0 else 0) := finite_sum_four_swap _ _ = ∑ aa : Fin n → A, ∑ bb : Fin n → B, if ∀ i : {i : Fin n // i ∈ D}, G.predicate (xs i) (ys i) (aa i) (bb i) = true then S.outcomeProbability xs ys aa bb else 0 := by apply Finset.sum_congr rfl intro aa _ apply Finset.sum_congr rfl intro bb _ simp [conditionedAnswerMatches_iff, fullQuestionWinIndicator, mul_ite] theorem repeated_partialWinMass_expansion (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ aa : Fin n → A, ∑ bb : Fin n → B, (G.repeat n).questionWeight xs ys * (if ∀ i : {i : Fin n // i ∈ D}, G.predicate (xs i) (ys i) (aa i) (bb i) = true then S.outcomeProbability xs ys aa bb else 0) := by classical unfold FiniteEventLaw.eventMass FiniteEventLaw.winEvent simp only [Finset.sum_filter] simp only [repeatedCoordinateWin, strategyEventLaw] change (∑ ω : (Fin n → X) × (Fin n → Y) × (Fin n → A) × (Fin n → B), if ∀ i ∈ D, G.predicate (ω.1 i) (ω.2.1 i) (ω.2.2.1 i) (ω.2.2.2 i) = true then (G.repeat n).questionWeight ω.1 ω.2.1 * S.outcomeProbability ω.1 ω.2.1 ω.2.2.1 ω.2.2.2 else 0) = _ simp_rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ apply Finset.sum_congr rfl intro aa _ apply Finset.sum_congr rfl intro bb _ have hiff : (∀ i ∈ D, G.predicate (xs i) (ys i) (aa i) (bb i) = true) ↔ (∀ i : {i : Fin n // i ∈ D}, G.predicate (xs i) (ys i) (aa i) (bb i) = true) := by constructor · intro h i exact h i i.property · intro h i hi exact h ⟨i, hi⟩ by_cases hw : ∀ i : {i : Fin n // i ∈ D}, G.predicate (xs i) (ys i) (aa i) (bb i) = true · rw [if_pos (hiff.mpr hw), if_pos hw] · rw [if_neg (mt hiff.mp hw), if_neg hw, mul_zero] theorem fullQuestionConditionedBornMass_eq [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, (G.repeat n).questionWeight xs ys * fullQuestionWinIndicator G D xs ys α β * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α xs) (conditionedBobEffect G n S D β ys)) = (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) := by classical calc (∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, (G.repeat n).questionWeight xs ys * fullQuestionWinIndicator G D xs ys α β * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α xs) (conditionedBobEffect G n S D β ys)) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, (G.repeat n).questionWeight xs ys * (∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullQuestionWinIndicator G D xs ys α β * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α xs) (conditionedBobEffect G n S D β ys)) := by apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ simp only [Finset.mul_sum, mul_assoc] _ = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ aa : Fin n → A, ∑ bb : Fin n → B, (G.repeat n).questionWeight xs ys * (if ∀ i : {i : Fin n // i ∈ D}, G.predicate (xs i) (ys i) (aa i) (bb i) = true then S.outcomeProbability xs ys aa bb else 0) := by apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ rw [conditionedEffects_postselection_sum G n S D xs ys] simp only [Finset.mul_sum] _ = _ := (repeated_partialWinMass_expansion G n S D).symm theorem fullHistoryFilters_born_expansion (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (α : {i : Fin n // i ∈ D} → A) (β : {i : Fin n // i ∈ D} → B) : bornTracePairing S.state.matrix (fullHistoryAliceFilter G n S D L h α) (fullHistoryBobFilter G n S D L h β) = ∑ hx : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X, ∑ hy : {i : Fin n // i ∈ L} → Y, fullHistoryHiddenAliceWeight G h hx * fullHistoryHiddenBobWeight G h hy * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α (fullHistoryAliceQuestion h hx)) (conditionedBobEffect G n S D β (fullHistoryBobQuestion h hy)) := by classical unfold fullHistoryAliceFilter fullHistoryBobFilter simp only [map_sum, LinearMap.sum_apply, map_smul, LinearMap.smul_apply, smul_eq_mul, Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro hx _ apply Finset.sum_congr rfl intro hy _ ring theorem fullSubsetHistory_mass_eq_postselection [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (hL : L ⊆ Finset.univ \ D) : (∑ h : FullSubsetHistory X Y n D L, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * bornTracePairing S.state.matrix (fullHistoryAliceFilter G n S D L h α) (fullHistoryBobFilter G n S D L h β)) = (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) := by classical calc (∑ h : FullSubsetHistory X Y n D L, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * bornTracePairing S.state.matrix (fullHistoryAliceFilter G n S D L h α) (fullHistoryBobFilter G n S D L h β)) = ∑ h : FullSubsetHistory X Y n D L, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, ∑ hx : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X, ∑ hy : {i : Fin n // i ∈ L} → Y, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * fullHistoryHiddenAliceWeight G h hx * fullHistoryHiddenBobWeight G h hy * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α (fullHistoryAliceQuestion h hx)) (conditionedBobEffect G n S D β (fullHistoryBobQuestion h hy)) := by apply Finset.sum_congr rfl intro h _ apply Finset.sum_congr rfl intro α _ apply Finset.sum_congr rfl intro β _ rw [fullHistoryFilters_born_expansion G n S D L h α β] simp only [Finset.mul_sum, mul_assoc] _ = ∑ h : FullSubsetHistory X Y n D L, ∑ hx : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X, ∑ hy : {i : Fin n // i ∈ L} → Y, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * fullHistoryHiddenAliceWeight G h hx * fullHistoryHiddenBobWeight G h hy * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α (fullHistoryAliceQuestion h hx)) (conditionedBobEffect G n S D β (fullHistoryBobQuestion h hy)) := by apply Finset.sum_congr rfl intro h _ exact finite_sum_four_swap _ _ = ∑ h : FullSubsetHistory X Y n D L, ∑ hx : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X, ∑ hy : {i : Fin n // i ∈ L} → Y, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, (G.repeat n).questionWeight (fullHistoryAliceQuestion h hx) (fullHistoryBobQuestion h hy) * fullQuestionWinIndicator G D (fullHistoryAliceQuestion h hx) (fullHistoryBobQuestion h hy) α β * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α (fullHistoryAliceQuestion h hx)) (conditionedBobEffect G n S D β (fullHistoryBobQuestion h hy)) := by apply Finset.sum_congr rfl intro h _ apply Finset.sum_congr rfl intro hx _ apply Finset.sum_congr rfl intro hy _ apply Finset.sum_congr rfl intro α _ apply Finset.sum_congr rfl intro β _ rw [fullHistoryWinIndicator_eq_question G D L h hx hy α β] rw [← fullHistoryWeight_mul_hidden G D L hL h hx hy] ring _ = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, (G.repeat n).questionWeight xs ys * fullQuestionWinIndicator G D xs ys α β * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α xs) (conditionedBobEffect G n S D β ys) := by let f : ((Fin n → X) × (Fin n → Y)) → ℝ := fun q => ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, (G.repeat n).questionWeight q.1 q.2 * fullQuestionWinIndicator G D q.1 q.2 α β * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D α q.1) (conditionedBobEffect G n S D β q.2) simpa only [f, fullHistoryQuestionEquiv, Equiv.coe_fn_mk, Fintype.sum_prod_type] using (fullHistoryQuestionEquiv (X := X) (Y := Y) D L hL).sum_comp f _ = _ := fullQuestionConditionedBornMass_eq G n S D end ActualHistoryWeights end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem spectralPurificationFilter_mul_shift {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) {s : ℝ} (hs : 0 < s) : spectralPurificationFilter F hF s * (F + s • (1 : Matrix d d ℂ)) = F := by classical let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues let D : Matrix d d ℂ := Matrix.diagonal fun i => (eigenvalue i : ℂ) let T : Matrix d d ℂ := Matrix.diagonal fun i => ((eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) let e := Unitary.conjStarAlgAut ℂ (Matrix d d ℂ) U have heigenvalue (i : d) : 0 ≤ eigenvalue i := hF.eigenvalues_nonneg i have hden (i : d) : eigenvalue i + s ≠ 0 := ne_of_gt (add_pos_of_nonneg_of_pos (heigenvalue i) hs) have hFspec : F = e D := by simpa [D, eigenvalue, e, Function.comp_def] using hF.isHermitian.spectral_theorem have hshift_inner : D + s • (1 : Matrix d d ℂ) = Matrix.diagonal fun i => ((eigenvalue i + s : ℝ) : ℂ) := by ext i j by_cases hij : i = j · subst j simp [D] · simp [D, hij] have hproduct : T * (D + s • (1 : Matrix d d ℂ)) = D := by rw [hshift_inner] change Matrix.diagonal (fun i => ((eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ)) * Matrix.diagonal (fun i => ((eigenvalue i + s : ℝ) : ℂ)) = Matrix.diagonal (fun i => (eigenvalue i : ℂ)) rw [Matrix.diagonal_mul_diagonal] congr 1 funext i push_cast have hden_complex : (eigenvalue i : ℂ) + (s : ℂ) ≠ 0 := by exact_mod_cast hden i rw [div_mul_cancel₀ _ hden_complex] have hscalar : e (s • (1 : Matrix d d ℂ)) = s • (1 : Matrix d d ℂ) := by change (U : Matrix d d ℂ) * (s • (1 : Matrix d d ℂ)) * star (U : Matrix d d ℂ) = s • (1 : Matrix d d ℂ) rw [mul_smul_comm, mul_one, smul_mul_assoc] simp change e T * (F + s • (1 : Matrix d d ℂ)) = F rw [hFspec, ← hscalar, ← map_add, ← map_mul, hproduct] theorem spectralPurificationFilter_eq_resolvent {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) {s : ℝ} (hs : 0 < s) : spectralPurificationFilter F hF s = F * (F + s • (1 : Matrix d d ℂ))⁻¹ := by have hdet : IsUnit (F + s • (1 : Matrix d d ℂ)).det := (Matrix.isUnit_iff_isUnit_det _).mp (shifted_posSemidef_matrix_posDef hF hs).isUnit calc spectralPurificationFilter F hF s = spectralPurificationFilter F hF s * ((F + s • (1 : Matrix d d ℂ)) * (F + s • (1 : Matrix d d ℂ))⁻¹) := by rw [Matrix.mul_nonsing_inv _ hdet, mul_one] _ = (spectralPurificationFilter F hF s * (F + s • (1 : Matrix d d ℂ))) * (F + s • (1 : Matrix d d ℂ))⁻¹ := by rw [mul_assoc] _ = F * (F + s • (1 : Matrix d d ℂ))⁻¹ := by rw [spectralPurificationFilter_mul_shift F hF hs] end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem spectralPurificationFilter_square_contraction {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) {s : ℝ} (hs : 0 < s) : (spectralPurificationFilter F hF s - star (spectralPurificationFilter F hF s) * spectralPurificationFilter F hF s).PosSemidef := by classical let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues let D : Matrix d d ℂ := Matrix.diagonal fun i => ((eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) let e := Unitary.conjStarAlgAut ℂ (Matrix d d ℂ) U have hDhermitian : D.IsHermitian := by apply Matrix.isHermitian_diagonal_iff.mpr intro i change star ((eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) = _ simp have hDstar : star D = D := by simpa only [Matrix.star_eq_conjTranspose] using hDhermitian.eq have hdiag : (D - D * D).PosSemidef := by rw [show D * D = Matrix.diagonal (fun i => (((eigenvalue i / (eigenvalue i + s)) ^ 2 : ℝ) : ℂ)) by dsimp [D] rw [Matrix.diagonal_mul_diagonal] congr 1 funext i simp [pow_two]] have hsub : D - Matrix.diagonal (fun i => (((eigenvalue i / (eigenvalue i + s)) ^ 2 : ℝ) : ℂ)) = Matrix.diagonal (fun i => ((eigenvalue i / (eigenvalue i + s) - (eigenvalue i / (eigenvalue i + s)) ^ 2 : ℝ) : ℂ)) := by ext i j by_cases hij : i = j · subst j simp [D] · simp [D, hij] rw [hsub] apply Matrix.PosSemidef.diagonal intro i change 0 ≤ ((eigenvalue i / (eigenvalue i + s) - (eigenvalue i / (eigenvalue i + s)) ^ 2 : ℝ) : ℂ) apply Complex.nonneg_iff.mpr constructor · have hnonneg : 0 ≤ eigenvalue i / (eigenvalue i + s) := div_nonneg (hF.eigenvalues_nonneg i) (le_of_lt (add_pos_of_nonneg_of_pos (hF.eigenvalues_nonneg i) hs)) have hle : eigenvalue i / (eigenvalue i + s) ≤ 1 := (div_le_one (add_pos_of_nonneg_of_pos (hF.eigenvalues_nonneg i) hs)).mpr (by linarith) change 0 ≤ eigenvalue i / (eigenvalue i + s) - (eigenvalue i / (eigenvalue i + s)) ^ 2 nlinarith · simp only [Complex.ofReal_im] change (e D - star (e D) * e D).PosSemidef rw [← map_star, hDstar, ← map_mul, ← map_sub] change ((U : Matrix d d ℂ) * (D - D * D) * star (U : Matrix d d ℂ)).PosSemidef simpa [Matrix.star_eq_conjTranspose] using hdiag.mul_mul_conjTranspose_same (U : Matrix d d ℂ) end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace def matrixQuadraticCLM {d : Type*} [Fintype d] (x : d → ℂ) : Matrix d d ℂ →L[ℝ] ℂ := LinearMap.toContinuousLinearMap { toFun := fun A => star x ⬝ᵥ A.mulVec x map_add' := by intro A B simp [Matrix.mulVec, dotProduct, add_mul, mul_add, Finset.sum_add_distrib] map_smul' := by intro r A change (∑ i, star (x i) * ∑ j, ((r : ℂ) * A i j) * x j) = (r : ℂ) * (∑ i, star (x i) * ∑ j, A i j * x j) simp_rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring } def matrixAdjointCLM {d : Type*} [Fintype d] : Matrix d d ℂ →L[ℝ] Matrix d d ℂ := LinearMap.toContinuousLinearMap { toFun := fun A => star A map_add' := by intro A B exact star_add A B map_smul' := by intro r A simp } theorem bochner_integral_posSemidef {α d : Type*} [MeasurableSpace α] [Fintype d] [DecidableEq d] {μ : Measure α} {f : α → Matrix d d ℂ} (hf : Integrable f μ) (hpos : ∀ᵐ t ∂μ, (f t).PosSemidef) : (∫ t, f t ∂μ).PosSemidef := by have hadjoint : star (∫ t, f t ∂μ) = ∫ t, star (f t) ∂μ := by exact (ContinuousLinearMap.integral_comp_comm matrixAdjointCLM hf).symm have hadjoint_ae : (fun t => star (f t)) =ᵐ[μ] f := by filter_upwards [hpos] with t ht simpa only [Matrix.star_eq_conjTranspose] using ht.isHermitian.eq have hhermitian : (∫ t, f t ∂μ).IsHermitian := by apply Matrix.IsHermitian.ext intro i j have hstar : star (∫ t, f t ∂μ) = ∫ t, f t ∂μ := hadjoint.trans (integral_congr_ae hadjoint_ae) have hentry := congr_fun (congr_fun hstar i) j simpa [Matrix.star_eq_conjTranspose, Matrix.conjTranspose] using hentry apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg hhermitian intro x have hcomm : (∫ t, matrixQuadraticCLM x (f t) ∂μ) = matrixQuadraticCLM x (∫ t, f t ∂μ) := ContinuousLinearMap.integral_comp_comm (matrixQuadraticCLM x) hf change 0 ≤ matrixQuadraticCLM x (∫ t, f t ∂μ) rw [← hcomm] apply integral_nonneg_of_ae filter_upwards [hpos] with t ht exact ht.dotProduct_mulVec_nonneg x end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem spectralPurificationFilter_eq_one_sub_shifted_inverse {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) {s : ℝ} (hs : 0 < s) : spectralPurificationFilter F hF s = 1 - s • (F + s • (1 : Matrix d d ℂ))⁻¹ := by have hdet : IsUnit (F + s • (1 : Matrix d d ℂ)).det := (Matrix.isUnit_iff_isUnit_det _).mp (shifted_posSemidef_matrix_posDef hF hs).isUnit rw [spectralPurificationFilter_eq_resolvent F hF hs] apply eq_sub_of_add_eq simpa [add_mul, smul_mul_assoc] using Matrix.mul_nonsing_inv (F + s • (1 : Matrix d d ℂ)) hdet theorem shifted_inverse_square_contraction {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) {s : ℝ} (hs : 0 < s) : (s • (F + s • (1 : Matrix d d ℂ))⁻¹ - s ^ 2 • ((F + s • (1 : Matrix d d ℂ))⁻¹ * (F + s • (1 : Matrix d d ℂ))⁻¹)).PosSemidef := by let R : Matrix d d ℂ := (F + s • (1 : Matrix d d ℂ))⁻¹ have hstar : star R = R := by simpa only [Matrix.star_eq_conjTranspose] using (shifted_posSemidef_matrix_inverse_posSemidef hF hs).isHermitian.eq have h := spectralPurificationFilter_square_contraction F hF hs rw [spectralPurificationFilter_eq_one_sub_shifted_inverse F hF hs] at h change (s • R - s ^ 2 • (R * R)).PosSemidef change ((1 - s • R) - star (1 - s • R) * (1 - s • R)).PosSemidef at h convert h using 1 simp only [star_sub, star_one, star_smul, star_trivial, hstar, sub_mul, mul_sub, one_mul, mul_one, smul_mul_assoc, mul_smul_comm, pow_two] module end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem spectralPurificationFilter_sub_resolvent {d : Type*} [Fintype d] [DecidableEq d] (F M : Matrix d d ℂ) (hF : F.PosSemidef) (hM : M.PosSemidef) {s : ℝ} (hs : 0 < s) : spectralPurificationFilter F hF s - spectralPurificationFilter M hM s = s • ((F + s • (1 : Matrix d d ℂ))⁻¹ * (F - M) * (M + s • (1 : Matrix d d ℂ))⁻¹) := by have hdetF : IsUnit (F + s • (1 : Matrix d d ℂ)).det := (Matrix.isUnit_iff_isUnit_det _).mp (shifted_posSemidef_matrix_posDef hF hs).isUnit have hdetM : IsUnit (M + s • (1 : Matrix d d ℂ)).det := (Matrix.isUnit_iff_isUnit_det _).mp (shifted_posSemidef_matrix_posDef hM hs).isUnit rw [spectralPurificationFilter_eq_resolvent F hF hs, spectralPurificationFilter_eq_resolvent M hM hs] simpa [smul_mul_assoc] using noncommutative_filtered_resolvent_identity F M (s • (1 : Matrix d d ℂ)) (F + s • (1 : Matrix d d ℂ))⁻¹ (M + s • (1 : Matrix d d ℂ))⁻¹ (Matrix.mul_nonsing_inv _ hdetF) (Matrix.nonsing_inv_mul _ hdetF) (Matrix.mul_nonsing_inv _ hdetM) theorem spectralPurificationFilter_sub_gram {d : Type*} [Fintype d] [DecidableEq d] (F M : Matrix d d ℂ) (hF : F.PosSemidef) (hM : M.PosSemidef) {s : ℝ} (hs : 0 < s) : star (spectralPurificationFilter F hF s - spectralPurificationFilter M hM s) * (spectralPurificationFilter F hF s - spectralPurificationFilter M hM s) = s ^ 2 • ((M + s • (1 : Matrix d d ℂ))⁻¹ * (F - M) * ((F + s • (1 : Matrix d d ℂ))⁻¹ * (F + s • (1 : Matrix d d ℂ))⁻¹) * (F - M) * (M + s • (1 : Matrix d d ℂ))⁻¹) := by let RF : Matrix d d ℂ := (F + s • (1 : Matrix d d ℂ))⁻¹ let RM : Matrix d d ℂ := (M + s • (1 : Matrix d d ℂ))⁻¹ let D : Matrix d d ℂ := F - M have hRF : star RF = RF := by simpa only [Matrix.star_eq_conjTranspose] using (shifted_posSemidef_matrix_inverse_posSemidef hF hs).isHermitian.eq have hRM : star RM = RM := by simpa only [Matrix.star_eq_conjTranspose] using (shifted_posSemidef_matrix_inverse_posSemidef hM hs).isHermitian.eq have hD : star D = D := by simpa only [Matrix.star_eq_conjTranspose] using (hF.isHermitian.sub hM.isHermitian).eq rw [spectralPurificationFilter_sub_resolvent F M hF hM hs] change star (s • (RF * D * RM)) * (s • (RF * D * RM)) = s ^ 2 • (RM * D * (RF * RF) * D * RM) simp only [star_smul, star_trivial, star_mul, hRF, hRM, hD, smul_mul_assoc, mul_smul_comm, smul_smul, pow_two] congr 1 noncomm_ring end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem weighted_shifted_inverse_second_order {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (normalized : (∑ i : ι, weight i) = 1) (mean : (∑ i : ι, weight i • F i) = M) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) {s : ℝ} (hs : 0 < s) : (∑ i : ι, weight i • (F i + s • (1 : Matrix d d ℂ))⁻¹) - (M + s • (1 : Matrix d d ℂ))⁻¹ = (M + s • (1 : Matrix d d ℂ))⁻¹ * (∑ i : ι, weight i • ((F i - M) * (F i + s • (1 : Matrix d d ℂ))⁻¹ * (F i - M))) * (M + s • (1 : Matrix d d ℂ))⁻¹ := by let W : ι → Matrix d d ℂ := fun i => weight i • (1 : Matrix d d ℂ) let RF : ι → Matrix d d ℂ := fun i => (F i + s • (1 : Matrix d d ℂ))⁻¹ let RM : Matrix d d ℂ := (M + s • (1 : Matrix d d ℂ))⁻¹ have hW_normalized : (∑ i : ι, W i) = 1 := by dsimp [W] rw [← Finset.sum_smul, normalized] simp have hW_centered : (∑ i : ι, W i * (F i - M)) = 0 := by dsimp [W] simp_rw [smul_mul_assoc, one_mul] exact matrix_weighted_centered weight F M normalized mean have hW_commutes (i : ι) : W i * RM = RM * W i := by dsimp [W] rw [smul_mul_assoc, one_mul, mul_smul_comm, mul_one] have hdetF (i : ι) : IsUnit (F i + s • (1 : Matrix d d ℂ)).det := (Matrix.isUnit_iff_isUnit_det _).mp (shifted_posSemidef_matrix_posDef (positive i) hs).isUnit have hdetM : IsUnit (M + s • (1 : Matrix d d ℂ)).det := (Matrix.isUnit_iff_isUnit_det _).mp (shifted_posSemidef_matrix_posDef hM hs).isUnit have hidentity := noncommutative_weighted_resolvent_second_order W F M (s • (1 : Matrix d d ℂ)) RF RM hW_normalized hW_centered hW_commutes (fun i => Matrix.mul_nonsing_inv _ (hdetF i)) (fun i => Matrix.nonsing_inv_mul _ (hdetF i)) (Matrix.mul_nonsing_inv _ hdetM) (Matrix.nonsing_inv_mul _ hdetM) simpa [W, RF, RM, smul_mul_assoc] using hidentity theorem weighted_spectralPurificationFilter_variance_le_inverse_jensen {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (nonnegative : ∀ i, 0 ≤ weight i) (normalized : (∑ i : ι, weight i) = 1) (mean : (∑ i : ι, weight i • F i) = M) (positive : ∀ i, (F i).PosSemidef) {s : ℝ} (hs : 0 < s) : let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive (s • ((∑ i : ι, weight i • (F i + s • (1 : Matrix d d ℂ))⁻¹) - (M + s • (1 : Matrix d d ℂ))⁻¹) - ∑ i : ι, weight i • (star (spectralPurificationFilter (F i) (positive i) s - spectralPurificationFilter M hM s) * (spectralPurificationFilter (F i) (positive i) s - spectralPurificationFilter M hM s))).PosSemidef := by dsimp let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive let RF : ι → Matrix d d ℂ := fun i => (F i + s • (1 : Matrix d d ℂ))⁻¹ let RM : Matrix d d ℂ := (M + s • (1 : Matrix d d ℂ))⁻¹ let D : ι → Matrix d d ℂ := fun i => F i - M let K : ι → Matrix d d ℂ := fun i => s • RF i - s ^ 2 • (RF i * RF i) have hK (i : ι) : (K i).PosSemidef := shifted_inverse_square_contraction (F i) (positive i) hs have hD (i : ι) : (D i).IsHermitian := (positive i).isHermitian.sub hM.isHermitian have hinner : (∑ i : ι, weight i • (D i * K i * D i)).PosSemidef := by apply Matrix.posSemidef_sum intro i _ exact (posSemidef_hermitian_sandwich (hK i) (hD i)).smul (nonnegative i) have hRM : RM.IsHermitian := (shifted_posSemidef_matrix_inverse_posSemidef hM hs).isHermitian have houter : (RM * (∑ i : ι, weight i • (D i * K i * D i)) * RM).PosSemidef := posSemidef_hermitian_sandwich hinner hRM have hsecond : (∑ i : ι, weight i • RF i) - RM = RM * (∑ i : ι, weight i • (D i * RF i * D i)) * RM := weighted_shifted_inverse_second_order weight F M normalized mean positive hM hs have hgram (i : ι) : star (spectralPurificationFilter (F i) (positive i) s - spectralPurificationFilter M hM s) * (spectralPurificationFilter (F i) (positive i) s - spectralPurificationFilter M hM s) = s ^ 2 • (RM * D i * (RF i * RF i) * D i * RM) := spectralPurificationFilter_sub_gram (F i) M (positive i) hM hs change (s • ((∑ i : ι, weight i • RF i) - RM) - ∑ i : ι, weight i • (star (spectralPurificationFilter (F i) (positive i) s - spectralPurificationFilter M hM s) * (spectralPurificationFilter (F i) (positive i) s - spectralPurificationFilter M hM s))).PosSemidef rw [hsecond] simp_rw [hgram] convert houter using 1 simp only [Finset.mul_sum, Finset.sum_mul, Finset.smul_sum, mul_smul_comm, smul_mul_assoc, smul_smul, mul_sub, sub_mul, K] rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i _ rw [smul_sub, smul_smul, smul_smul, mul_comm s (weight i)] simp only [mul_assoc] end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem scalarResolventFilter_memLp_two {z : ℝ} (hz : 0 ≤ z) : MemLp (fun s : ℝ => z / (z + s)) 2 (volume.restrict (Ioi 0)) := by have hmeas : AEStronglyMeasurable (fun s : ℝ => z / (z + s)) (volume.restrict (Ioi 0)) := by exact (measurable_const.div (measurable_const.add measurable_id)).aestronglyMeasurable exact (memLp_two_iff_integrable_sq hmeas).mpr (scalar_resolvent_purification_integrable hz) theorem spectralPurificationFilter_memLp_two {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : MemLp (spectralPurificationFilter F hF) 2 (volume.restrict (Ioi 0)) := by classical let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues apply MemLp.of_eval intro i apply MemLp.of_eval intro j have hform : (fun s : ℝ => spectralPurificationFilter F hF s i j) = (fun s : ℝ => ∑ k : d, (U : Matrix d d ℂ) i k * ((eigenvalue k / (eigenvalue k + s) : ℝ) : ℂ) * star (U : Matrix d d ℂ) k j) := by funext s change ((U : Matrix d d ℂ) * Matrix.diagonal (fun k => ((eigenvalue k / (eigenvalue k + s) : ℝ) : ℂ)) * star (U : Matrix d d ℂ)) i j = _ simp [Matrix.mul_apply, Matrix.diagonal, mul_ite] rw [hform] apply memLp_finsetSum Finset.univ intro k _ exact ((scalarResolventFilter_memLp_two (hF.eigenvalues_nonneg k)).ofReal.const_mul ((U : Matrix d d ℂ) i k)).mul_const (star (U : Matrix d d ℂ) k j) theorem matrix_memLp_two_mul_integrable {α d : Type*} [MeasurableSpace α] [Fintype d] {μ : Measure α} {f g : α → Matrix d d ℂ} (hf : MemLp f 2 μ) (hg : MemLp g 2 μ) : Integrable (fun t => f t * g t) μ := by classical apply Integrable.of_eval intro i apply Integrable.of_eval intro j change Integrable (fun t => ∑ k : d, f t i k * g t k j) μ apply integrable_finsetSum Finset.univ intro k _ exact ((hf.eval i).eval k).integrable_mul ((hg.eval k).eval j) theorem spectralPurificationFilter_difference_gram_integrable {d : Type*} [Fintype d] [DecidableEq d] (F M : Matrix d d ℂ) (hF : F.PosSemidef) (hM : M.PosSemidef) : IntegrableOn (fun s : ℝ => star (spectralPurificationFilter F hF s - spectralPurificationFilter M hM s) * (spectralPurificationFilter F hF s - spectralPurificationFilter M hM s)) (Ioi 0) := by have hdelta : MemLp (fun s : ℝ => spectralPurificationFilter F hF s - spectralPurificationFilter M hM s) 2 (volume.restrict (Ioi 0)) := (spectralPurificationFilter_memLp_two F hF).sub (spectralPurificationFilter_memLp_two M hM) exact matrix_memLp_two_mul_integrable hdelta.star hdelta end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem scalar_entropy_resolvent_integrable {z : ℝ} (hz : 0 ≤ z) : IntegrableOn (fun s : ℝ => z / (1 + s) - z / (z + s)) (Ioi 0) := by have hone : MemLp (fun s : ℝ => 1 / (1 + s)) 2 (volume.restrict (Ioi 0)) := scalarResolventFilter_memLp_two (z := 1) (by norm_num) have hzfilter := scalarResolventFilter_memLp_two hz have hproduct : Integrable (fun s : ℝ => (1 / (1 + s)) * (z / (z + s))) (volume.restrict (Ioi 0)) := hone.integrable_mul hzfilter have hscaled : IntegrableOn (fun s : ℝ => (z - 1) * ((1 / (1 + s)) * (z / (z + s)))) (Ioi 0) := hproduct.const_mul (z - 1) refine hscaled.congr_fun (fun s hs => ?_) measurableSet_Ioi have hspos : 0 < s := hs have hzone : 1 + s ≠ 0 := ne_of_gt (by linarith) have hzden : z + s ≠ 0 := ne_of_gt (by linarith) field_simp ; ring def spectralEntropyKernel {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (s : ℝ) : Matrix d d ℂ := spectralConjugationCLM hF.isHermitian.eigenvectorUnitary (Matrix.diagonal fun i => ((hF.isHermitian.eigenvalues i / (1 + s) - hF.isHermitian.eigenvalues i / (hF.isHermitian.eigenvalues i + s) : ℝ) : ℂ)) theorem spectralEntropyKernel_integrable {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : IntegrableOn (spectralEntropyKernel F hF) (Ioi 0) := by classical let eigenvalue := hF.isHermitian.eigenvalues have hdiag : IntegrableOn (fun s : ℝ => Matrix.diagonal fun i : d => ((eigenvalue i / (1 + s) - eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ)) (Ioi 0) := by apply Integrable.of_eval intro i apply Integrable.of_eval intro j by_cases hij : i = j · subst j have heigenvalue : 0 ≤ eigenvalue i := hF.eigenvalues_nonneg i have hcomplex : Integrable (fun s : ℝ => ((eigenvalue i / (1 + s) - eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ)) (volume.restrict (Ioi 0)) := MeasureTheory.Integrable.ofReal (𝕜 := ℂ) (scalar_entropy_resolvent_integrable heigenvalue) simpa only [Matrix.diagonal_apply_eq] using hcomplex · simp [hij] exact (spectralConjugationCLM hF.isHermitian.eigenvectorUnitary).integrable_comp hdiag end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem spectralEntropyKernel_eq_scalar_sub_filter {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (s : ℝ) : spectralEntropyKernel F hF s = (1 / (1 + s) : ℝ) • F - spectralPurificationFilter F hF s := by classical let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues let L := spectralConjugationCLM U let D : Matrix d d ℂ := Matrix.diagonal fun i => (eigenvalue i : ℂ) let G : Matrix d d ℂ := Matrix.diagonal fun i => ((eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) let K : Matrix d d ℂ := Matrix.diagonal fun i => ((eigenvalue i / (1 + s) - eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) have hFspec : F = L D := by simpa [L, U, D, eigenvalue, Function.comp_def, Unitary.conjStarAlgAut_apply] using hF.isHermitian.spectral_theorem have hdiag : K = (1 / (1 + s) : ℝ) • D - G := by ext i j by_cases hij : i = j · subst j simp [K, D, G, div_eq_mul_inv, mul_comm] · simp [K, D, G, hij] change L K = (1 / (1 + s) : ℝ) • F - L G rw [hFspec, ← L.map_smul, ← L.map_sub, hdiag] def weightedSpectralFilterVariance {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (s : ℝ) : Matrix d d ℂ := ∑ i : ι, weight i • (star (spectralPurificationFilter (F i) (positive i) s - spectralPurificationFilter M hM s) * (spectralPurificationFilter (F i) (positive i) s - spectralPurificationFilter M hM s)) def weightedSpectralEntropyJensen {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (s : ℝ) : Matrix d d ℂ := (∑ i : ι, weight i • spectralEntropyKernel (F i) (positive i) s) - spectralEntropyKernel M hM s theorem weightedSpectralFilterVariance_integrable {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : IntegrableOn (weightedSpectralFilterVariance weight F M positive hM) (Ioi 0) := by unfold weightedSpectralFilterVariance apply integrable_finsetSum Finset.univ intro i _ exact (spectralPurificationFilter_difference_gram_integrable (F i) M (positive i) hM).smul (weight i) theorem weightedSpectralEntropyJensen_integrable {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : IntegrableOn (weightedSpectralEntropyJensen weight F M positive hM) (Ioi 0) := by unfold weightedSpectralEntropyJensen apply Integrable.sub · apply integrable_finsetSum Finset.univ intro i _ exact (spectralEntropyKernel_integrable (F i) (positive i)).smul (weight i) · exact spectralEntropyKernel_integrable M hM theorem weightedSpectralEntropyJensen_eq_shifted_inverse {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (normalized : (∑ i : ι, weight i) = 1) (mean : (∑ i : ι, weight i • F i) = M) {s : ℝ} (hs : 0 < s) : weightedSpectralEntropyJensen weight F M positive hM s = s • ((∑ i : ι, weight i • (F i + s • (1 : Matrix d d ℂ))⁻¹) - (M + s • (1 : Matrix d d ℂ))⁻¹) := by classical let c : ℝ := 1 / (1 + s) let RF : ι → Matrix d d ℂ := fun i => (F i + s • (1 : Matrix d d ℂ))⁻¹ let RM : Matrix d d ℂ := (M + s • (1 : Matrix d d ℂ))⁻¹ have hscalar : (∑ i : ι, weight i • (c • F i)) = c • M := by calc (∑ i : ι, weight i • (c • F i)) = ∑ i : ι, c • (weight i • F i) := by apply Finset.sum_congr rfl intro i _ simp only [smul_smul, mul_comm] _ = c • (∑ i : ι, weight i • F i) := by rw [Finset.smul_sum] _ = c • M := by rw [mean] have hscale : (∑ i : ι, weight i • (s • RF i)) = s • (∑ i : ι, weight i • RF i) := by calc (∑ i : ι, weight i • (s • RF i)) = ∑ i : ι, s • (weight i • RF i) := by apply Finset.sum_congr rfl intro i _ simp only [smul_smul, mul_comm] _ = s • (∑ i : ι, weight i • RF i) := by rw [Finset.smul_sum] have hfilter_sum : (∑ i : ι, weight i • spectralPurificationFilter (F i) (positive i) s) = 1 - s • (∑ i : ι, weight i • RF i) := by calc (∑ i : ι, weight i • spectralPurificationFilter (F i) (positive i) s) = ∑ i : ι, weight i • (1 - s • RF i) := by apply Finset.sum_congr rfl intro i _ rw [spectralPurificationFilter_eq_one_sub_shifted_inverse (F i) (positive i) hs] _ = 1 - s • (∑ i : ι, weight i • RF i) := by simp_rw [smul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_smul, normalized, hscale] simp unfold weightedSpectralEntropyJensen simp_rw [spectralEntropyKernel_eq_scalar_sub_filter] change (∑ i : ι, weight i • (c • F i - spectralPurificationFilter (F i) (positive i) s)) - (c • M - spectralPurificationFilter M hM s) = s • ((∑ i : ι, weight i • RF i) - RM) simp_rw [smul_sub] rw [Finset.sum_sub_distrib, hscalar, hfilter_sum, spectralPurificationFilter_eq_one_sub_shifted_inverse M hM hs] module theorem integrated_weighted_spectralPurificationFilter_jensen {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (nonnegative : ∀ i, 0 ≤ weight i) (normalized : (∑ i : ι, weight i) = 1) (mean : (∑ i : ι, weight i • F i) = M) (positive : ∀ i, (F i).PosSemidef) : let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive ((∫ s in Ioi (0 : ℝ), weightedSpectralEntropyJensen weight F M positive hM s) - (∫ s in Ioi (0 : ℝ), weightedSpectralFilterVariance weight F M positive hM s)).PosSemidef := by dsimp let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive have hentropy := weightedSpectralEntropyJensen_integrable weight F M positive hM have hvariance := weightedSpectralFilterVariance_integrable weight F M positive hM have hremainder : Integrable (fun s : ℝ => weightedSpectralEntropyJensen weight F M positive hM s - weightedSpectralFilterVariance weight F M positive hM s) (volume.restrict (Ioi 0)) := hentropy.sub hvariance have hpointwise : ∀ᵐ s ∂(volume.restrict (Ioi (0 : ℝ))), (weightedSpectralEntropyJensen weight F M positive hM s - weightedSpectralFilterVariance weight F M positive hM s).PosSemidef := by filter_upwards [ae_restrict_mem measurableSet_Ioi] with s hs have hspos : 0 < s := hs rw [weightedSpectralEntropyJensen_eq_shifted_inverse weight F M positive hM normalized mean hspos] unfold weightedSpectralFilterVariance exact weighted_spectralPurificationFilter_variance_le_inverse_jensen weight F M nonnegative normalized mean positive hspos have hintegral := bochner_integral_posSemidef hremainder hpointwise rw [integral_sub hentropy hvariance] at hintegral exact hintegral end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem scalar_entropy_resolvent_integral {z : ℝ} (hz : 0 ≤ z) : (∫ s in Ioi (0 : ℝ), (z / (1 + s) - z / (z + s))) = z * Real.log z := by rcases hz.eq_or_lt with rfl | hzpos · simp · have hderiv : ∀ x ∈ Ici (0 : ℝ), HasDerivAt (fun t : ℝ => z * Real.log ((1 + t) / (z + t))) (z / (1 + x) - z / (z + x)) x := by intro x hx have hxnonneg : 0 ≤ x := hx have hnum : 1 + x ≠ 0 := ne_of_gt (by linarith) have hden : z + x ≠ 0 := ne_of_gt (by linarith) have hratio : (1 + x) / (z + x) ≠ 0 := div_ne_zero hnum hden have hdnum := (hasDerivAt_const x (1 : ℝ)).add (hasDerivAt_id x) have hdden := (hasDerivAt_const x z).add (hasDerivAt_id x) have hd : HasDerivAt (fun t : ℝ => z * Real.log ((1 + t) / (z + t))) (z * (((z + x) - (1 + x)) / (z + x) ^ 2 / ((1 + x) / (z + x)))) x := by simpa [Function.comp_def] using ((hdnum.div hdden hden).log hratio).const_mul z apply hd.congr_deriv field_simp [hnum, hden] have hden_top : Tendsto (fun t : ℝ => z + t) atTop atTop := by simpa [add_comm] using tendsto_atTop_add_const_right atTop z tendsto_id have hzero : Tendsto (fun t : ℝ => (1 - z) / (z + t)) atTop (𝓝 (0 : ℝ)) := tendsto_const_nhds.div_atTop hden_top have hratio_limit : Tendsto (fun t : ℝ => (1 + t) / (z + t)) atTop (𝓝 (1 : ℝ)) := by have hone : Tendsto (fun _ : ℝ => (1 : ℝ)) atTop (𝓝 (1 : ℝ)) := tendsto_const_nhds have h' : Tendsto (fun t : ℝ => 1 + (1 - z) / (z + t)) atTop (𝓝 (1 : ℝ)) := by simpa using hone.add hzero apply h'.congr' filter_upwards [eventually_gt_atTop (-z)] with t ht have hden : z + t ≠ 0 := ne_of_gt (by linarith) field_simp ; ring have hlog_limit : Tendsto (fun t : ℝ => Real.log ((1 + t) / (z + t))) atTop (𝓝 (0 : ℝ)) := by have hlog : Tendsto (Real.log ∘ (fun t : ℝ => (1 + t) / (z + t))) atTop (𝓝 (Real.log (1 : ℝ))) := (Real.continuousAt_log (by norm_num : (1 : ℝ) ≠ 0)).tendsto.comp hratio_limit change Tendsto (fun t : ℝ => Real.log ((1 + t) / (z + t))) atTop (𝓝 (Real.log (1 : ℝ))) at hlog simpa only [Real.log_one] using hlog have hlimit : Tendsto (fun t : ℝ => z * Real.log ((1 + t) / (z + t))) atTop (𝓝 (0 : ℝ)) := by simpa using tendsto_const_nhds.mul hlog_limit have hftc := integral_Ioi_of_hasDerivAt_of_tendsto' hderiv (scalar_entropy_resolvent_integrable hzpos.le) hlimit calc (∫ s in Ioi (0 : ℝ), (z / (1 + s) - z / (z + s))) = 0 - z * Real.log ((1 + 0) / (z + 0)) := hftc _ = z * Real.log z := by simp [Real.log_inv] end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace def diagonalEntropyKernel {d : Type*} [Fintype d] [DecidableEq d] (eigenvalue : d → ℝ) (s : ℝ) : Matrix d d ℂ := Matrix.diagonal fun i => ((eigenvalue i / (1 + s) - eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) theorem diagonalEntropyKernel_integrable {d : Type*} [Fintype d] [DecidableEq d] (eigenvalue : d → ℝ) (nonnegative : ∀ i, 0 ≤ eigenvalue i) : IntegrableOn (diagonalEntropyKernel eigenvalue) (Ioi 0) := by classical apply Integrable.of_eval intro i apply Integrable.of_eval intro j by_cases hij : i = j · subst j have hcomplex : Integrable (fun s : ℝ => ((eigenvalue i / (1 + s) - eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ)) (volume.restrict (Ioi 0)) := MeasureTheory.Integrable.ofReal (𝕜 := ℂ) (scalar_entropy_resolvent_integrable (nonnegative i)) simpa only [diagonalEntropyKernel, Matrix.diagonal_apply_eq] using hcomplex · simp [diagonalEntropyKernel, hij] theorem integral_diagonalEntropyKernel {d : Type*} [Fintype d] [DecidableEq d] (eigenvalue : d → ℝ) (nonnegative : ∀ i, 0 ≤ eigenvalue i) : (∫ s in Ioi (0 : ℝ), diagonalEntropyKernel eigenvalue s) = Matrix.diagonal fun i => ((eigenvalue i * Real.log (eigenvalue i) : ℝ) : ℂ) := by classical have hmatrix := diagonalEntropyKernel_integrable eigenvalue nonnegative have hrows : ∀ i : d, Integrable (fun s : ℝ => diagonalEntropyKernel eigenvalue s i) (volume.restrict (Ioi 0)) := fun i => hmatrix.eval i have hentry (i : d) : ∀ j : d, Integrable (fun s : ℝ => diagonalEntropyKernel eigenvalue s i j) (volume.restrict (Ioi 0)) := fun j => (hrows i).eval j ext i j rw [MeasureTheory.eval_integral hrows i, MeasureTheory.eval_integral (hentry i) j] by_cases hij : i = j · subst j simp only [diagonalEntropyKernel, Matrix.diagonal_apply_eq] calc (∫ s in Ioi (0 : ℝ), ((eigenvalue i / (1 + s) - eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ)) = ((∫ s in Ioi (0 : ℝ), eigenvalue i / (1 + s) - eigenvalue i / (eigenvalue i + s) : ℝ) : ℂ) := integral_ofReal _ = ((eigenvalue i * Real.log (eigenvalue i) : ℝ) : ℂ) := by rw [scalar_entropy_resolvent_integral (nonnegative i)] · simp [diagonalEntropyKernel, hij] theorem integral_spectralEntropyKernel_eq_cfc {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : (∫ s in Ioi (0 : ℝ), spectralEntropyKernel F hF s) = cfc (fun z : ℝ => z * Real.log z) F := by let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues have hdiag := diagonalEntropyKernel_integrable eigenvalue (fun i => hF.eigenvalues_nonneg i) calc (∫ s in Ioi (0 : ℝ), spectralEntropyKernel F hF s) = spectralConjugationCLM U (∫ s in Ioi (0 : ℝ), diagonalEntropyKernel eigenvalue s) := by exact ContinuousLinearMap.integral_comp_comm (spectralConjugationCLM U) hdiag _ = spectralConjugationCLM U (Matrix.diagonal fun i => ((eigenvalue i * Real.log (eigenvalue i) : ℝ) : ℂ)) := by rw [integral_diagonalEntropyKernel eigenvalue (fun i => hF.eigenvalues_nonneg i)] _ = cfc (fun z : ℝ => z * Real.log z) F := by rw [hF.isHermitian.cfc_eq] rfl end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem integral_weightedSpectralEntropyJensen_eq_cfc {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : (∫ s in Ioi (0 : ℝ), weightedSpectralEntropyJensen weight F M positive hM s) = (∑ i : ι, weight i • cfc (fun z : ℝ => z * Real.log z) (F i)) - cfc (fun z : ℝ => z * Real.log z) M := by have hterm (i : ι) : Integrable (fun s : ℝ => weight i • spectralEntropyKernel (F i) (positive i) s) (volume.restrict (Ioi 0)) := (spectralEntropyKernel_integrable (F i) (positive i)).smul (weight i) have hsum : Integrable (fun s : ℝ => ∑ i : ι, weight i • spectralEntropyKernel (F i) (positive i) s) (volume.restrict (Ioi 0)) := integrable_finsetSum Finset.univ (fun i _ => hterm i) have hmean := spectralEntropyKernel_integrable M hM unfold weightedSpectralEntropyJensen rw [integral_sub hsum hmean] rw [integral_finsetSum Finset.univ (fun i _ => hterm i)] simp_rw [integral_smul, integral_spectralEntropyKernel_eq_cfc] theorem exact_matrix_log_entropy_filter_jensen {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (nonnegative : ∀ i, 0 ≤ weight i) (normalized : (∑ i : ι, weight i) = 1) (mean : (∑ i : ι, weight i • F i) = M) (positive : ∀ i, (F i).PosSemidef) : let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive ((∑ i : ι, weight i • cfc (fun z : ℝ => z * Real.log z) (F i)) - cfc (fun z : ℝ => z * Real.log z) M - (∫ s in Ioi (0 : ℝ), weightedSpectralFilterVariance weight F M positive hM s)).PosSemidef := by dsimp let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive have h := integrated_weighted_spectralPurificationFilter_jensen weight F M nonnegative normalized mean positive change ((∫ s in Ioi (0 : ℝ), weightedSpectralEntropyJensen weight F M positive hM s) - (∫ s in Ioi (0 : ℝ), weightedSpectralFilterVariance weight F M positive hM s)).PosSemidef at h rw [integral_weightedSpectralEntropyJensen_eq_cfc weight F M positive hM] at h exact h end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 600000 section HistoryContractions variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem Game.conditionalYGivenX_sum_le_one (G : Game X Y A B) (x : X) : (∑ y : Y, G.conditionalYGivenX x y) ≤ 1 := by by_cases hx : G.marginalX x = 0 · simp [Game.conditionalYGivenX, hx] · have hpos : 0 < G.marginalX x := lt_of_le_of_ne (G.marginalX_nonneg x) (Ne.symm hx) rw [G.conditionalYGivenX_sum x hpos] theorem Game.conditionalXGivenY_sum_le_one (G : Game X Y A B) (y : Y) : (∑ x : X, G.conditionalXGivenY y x) ≤ 1 := by by_cases hy : G.marginalY y = 0 · simp [Game.conditionalXGivenY, hy] · have hpos : 0 < G.marginalY y := lt_of_le_of_ne (G.marginalY_nonneg y) (Ne.symm hy) rw [G.conditionalXGivenY_sum y hpos] theorem fullHistoryHiddenAliceWeight_sum_le_one (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) : (∑ hidden : {i : Fin n // i ∈ fullHistoryRemaining n D L} → X, fullHistoryHiddenAliceWeight G h hidden) ≤ 1 := by unfold fullHistoryHiddenAliceWeight rw [← Fintype.prod_sum] apply Finset.prod_le_one · intro i _ exact Finset.sum_nonneg fun x _ => G.conditionalXGivenY_nonneg (h.bobRemaining i) x · intro i _ exact G.conditionalXGivenY_sum_le_one (h.bobRemaining i) theorem fullHistoryHiddenBobWeight_sum_le_one (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) : (∑ hidden : {i : Fin n // i ∈ L} → Y, fullHistoryHiddenBobWeight G h hidden) ≤ 1 := by unfold fullHistoryHiddenBobWeight rw [← Fintype.prod_sum] apply Finset.prod_le_one · intro i _ exact Finset.sum_nonneg fun y _ => G.conditionalYGivenX_nonneg (h.aliceRevealed i) y · intro i _ exact G.conditionalYGivenX_sum_le_one (h.aliceRevealed i) theorem fullHistoryAliceFilter_complement_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (α : {i : Fin n // i ∈ D} → A) : (1 - fullHistoryAliceFilter G n S D L h α).PosSemidef := by classical let w : ({i : Fin n // i ∈ fullHistoryRemaining n D L} → X) → ℝ := fullHistoryHiddenAliceWeight G h let E : ({i : Fin n // i ∈ fullHistoryRemaining n D L} → X) → Matrix S.Alice S.Alice ℂ := fun x => conditionedAliceEffect G n S D α (fullHistoryAliceQuestion h x) have hsum : (∑ x, w x) ≤ 1 := fullHistoryHiddenAliceWeight_sum_le_one G h have hsplit : 1 - (∑ x, w x • E x) = (1 - (∑ x, w x)) • (1 : Matrix S.Alice S.Alice ℂ) + ∑ x, w x • (1 - E x) := by simp_rw [smul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_smul] module change (1 - ∑ x, w x • E x).PosSemidef rw [hsplit] apply Matrix.PosSemidef.add · exact Matrix.PosSemidef.one.smul (sub_nonneg.mpr hsum) · apply Matrix.posSemidef_sum Finset.univ intro x _ exact (conditionedAliceEffect_complement_positive G n S D α (fullHistoryAliceQuestion h x)).smul (fullHistoryHiddenAliceWeight_nonneg G h x) theorem fullHistoryBobFilter_complement_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (β : {i : Fin n // i ∈ D} → B) : (1 - fullHistoryBobFilter G n S D L h β).PosSemidef := by classical let w : ({i : Fin n // i ∈ L} → Y) → ℝ := fullHistoryHiddenBobWeight G h let E : ({i : Fin n // i ∈ L} → Y) → Matrix S.Bob S.Bob ℂ := fun y => conditionedBobEffect G n S D β (fullHistoryBobQuestion h y) have hsum : (∑ y, w y) ≤ 1 := fullHistoryHiddenBobWeight_sum_le_one G h have hsplit : 1 - (∑ y, w y • E y) = (1 - (∑ y, w y)) • (1 : Matrix S.Bob S.Bob ℂ) + ∑ y, w y • (1 - E y) := by simp_rw [smul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_smul] module change (1 - ∑ y, w y • E y).PosSemidef rw [hsplit] apply Matrix.PosSemidef.add · exact Matrix.PosSemidef.one.smul (sub_nonneg.mpr hsum) · apply Matrix.posSemidef_sum Finset.univ intro y _ exact (conditionedBobEffect_complement_positive G n S D β (fullHistoryBobQuestion h y)).smul (fullHistoryHiddenBobWeight_nonneg G h y) theorem matrixLogEntropy_nonpos_of_contraction {d : Type*} [Fintype d] [DecidableEq d] {F : Matrix d d ℂ} (hF : F.PosSemidef) (hcomplement : (1 - F).PosSemidef) : (-(cfc (fun z : ℝ => z * Real.log z) F)).PosSemidef := by have hFle : F ≤ (1 : Matrix d d ℂ) := Matrix.le_iff.mpr hcomplement have hupper : ∀ z ∈ spectrum ℝ F, z ≤ 1 := (CFC.le_one_iff (R := ℝ) F hF.isHermitian).mp hFle have hlower : ∀ z ∈ spectrum ℝ F, 0 ≤ z := by intro z hz rw [hF.isHermitian.spectrum_real_eq_range_eigenvalues] at hz obtain ⟨i, rfl⟩ := hz exact hF.eigenvalues_nonneg i have hnonpos : cfc (fun z : ℝ => z * Real.log z) F ≤ (0 : Matrix d d ℂ) := by apply cfc_nonpos intro z hz exact Real.mul_log_nonpos (hlower z hz) (hupper z hz) simpa using Matrix.le_iff.mp hnonpos theorem matrixLogEntropy_born_nonpos_left {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (G : Matrix dB dB ℂ) (hF : F.PosSemidef) (hFcomplement : (1 - F).PosSemidef) (hG : G.PosSemidef) : bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G ≤ 0 := by have hneg := matrixLogEntropy_nonpos_of_contraction hF hFcomplement have hpair : 0 ≤ bornTracePairing ρ.matrix (-(cfc (fun z : ℝ => z * Real.log z) F)) G := by exact trace_mul_posSemidef_nonneg ρ.positive (hneg.kronecker hG) have hrewrite : bornTracePairing ρ.matrix (-(cfc (fun z : ℝ => z * Real.log z) F)) G = -bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G := by simp rw [hrewrite] at hpair exact neg_nonneg.mp hpair theorem matrixLogEntropy_born_nonpos_right {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (G : Matrix dB dB ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (hGcomplement : (1 - G).PosSemidef) : bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) ≤ 0 := by have hneg := matrixLogEntropy_nonpos_of_contraction hG hGcomplement have hpair : 0 ≤ bornTracePairing ρ.matrix F (-(cfc (fun z : ℝ => z * Real.log z) G)) := by exact trace_mul_posSemidef_nonneg ρ.positive (hF.kronecker hneg) have hrewrite : bornTracePairing ρ.matrix F (-(cfc (fun z : ℝ => z * Real.log z) G)) = -bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) := (bornTracePairing ρ.matrix F).map_neg _ rw [hrewrite] at hpair exact neg_nonneg.mp hpair def fullHistoryAliceEntropyPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) : ℝ := ∑ h : FullSubsetHistory X Y n D L, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (fullHistoryAliceFilter G n S D L h α)) (fullHistoryBobFilter G n S D L h β) theorem fullHistoryAliceEntropyPotential_nonpos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) : fullHistoryAliceEntropyPotential G n S D L ≤ 0 := by unfold fullHistoryAliceEntropyPotential apply Finset.sum_nonpos intro h _ apply Finset.sum_nonpos intro α _ apply Finset.sum_nonpos intro β _ apply mul_nonpos_of_nonneg_of_nonpos · exact mul_nonneg (fullHistoryWeight_nonneg G h) (fullHistoryWinIndicator_nonneg G h α β) · exact matrixLogEntropy_born_nonpos_left S.state (fullHistoryAliceFilter G n S D L h α) (fullHistoryBobFilter G n S D L h β) (fullHistoryAliceFilter_posSemidef G n S D L h α) (fullHistoryAliceFilter_complement_posSemidef G n S D L h α) (fullHistoryBobFilter_posSemidef G n S D L h β) end HistoryContractions def positiveMatrixSpectralAtom {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (i : d) : Matrix d d ℂ := spectralConjugationCLM hF.isHermitian.eigenvectorUnitary (Matrix.diagonal (Pi.single i (1 : ℂ))) theorem positiveMatrixSpectralAtom_posSemidef {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (i : d) : (positiveMatrixSpectralAtom F hF i).PosSemidef := by classical have hdiag : (Matrix.diagonal (Pi.single i (1 : ℂ))).PosSemidef := by apply Matrix.PosSemidef.diagonal intro j by_cases hij : i = j · subst j simp · simp [hij] unfold positiveMatrixSpectralAtom rw [spectralConjugationCLM_apply] simpa [Matrix.star_eq_conjTranspose] using hdiag.mul_mul_conjTranspose_same (hF.isHermitian.eigenvectorUnitary : Matrix d d ℂ) theorem positiveMatrixSpectralAtom_sum {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) : (∑ i : d, positiveMatrixSpectralAtom F hF i) = 1 := by classical let U := hF.isHermitian.eigenvectorUnitary have hdiag : (∑ i : d, Matrix.diagonal (Pi.single i (1 : ℂ))) = (1 : Matrix d d ℂ) := by ext j k by_cases hjk : j = k · subst k simp [Matrix.sum_apply, Pi.single_apply] · simp [Matrix.sum_apply, hjk] change (∑ i : d, spectralConjugationCLM U (Matrix.diagonal (Pi.single i (1 : ℂ)))) = 1 rw [← map_sum, hdiag] simp [spectralConjugationCLM_apply] theorem positiveMatrix_cfc_spectral_sum {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (f : ℝ → ℝ) : cfc f F = ∑ i : d, f (hF.isHermitian.eigenvalues i) • positiveMatrixSpectralAtom F hF i := by classical let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues have hdiag : (∑ i : d, f (eigenvalue i) • Matrix.diagonal (Pi.single i (1 : ℂ))) = Matrix.diagonal fun i => (f (eigenvalue i) : ℂ) := by ext j k by_cases hjk : j = k · subst k simp [Matrix.sum_apply, Pi.single_apply] · simp [Matrix.sum_apply, hjk] calc cfc f F = spectralConjugationCLM U (Matrix.diagonal fun i => (f (eigenvalue i) : ℂ)) := by rw [hF.isHermitian.cfc_eq] rfl _ = spectralConjugationCLM U (∑ i : d, f (eigenvalue i) • Matrix.diagonal (Pi.single i (1 : ℂ))) := by rw [hdiag] _ = ∑ i : d, f (eigenvalue i) • positiveMatrixSpectralAtom F hF i := by simp [positiveMatrixSpectralAtom, U, eigenvalue] def leftSpectralBornWeight {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (G : Matrix dB dB ℂ) (i : dA) : ℝ := bornTracePairing ρ.matrix (positiveMatrixSpectralAtom F hF i) G theorem leftSpectralBornWeight_nonneg {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) (i : dA) : 0 ≤ leftSpectralBornWeight ρ F hF G i := by exact trace_mul_posSemidef_nonneg ρ.positive ((positiveMatrixSpectralAtom_posSemidef F hF i).kronecker hG) theorem leftSpectralBornWeight_sum {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (G : Matrix dB dB ℂ) : (∑ i : dA, leftSpectralBornWeight ρ F hF G i) = bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G := by unfold leftSpectralBornWeight calc (∑ i : dA, bornTracePairing ρ.matrix (positiveMatrixSpectralAtom F hF i) G) = bornTracePairing ρ.matrix (∑ i : dA, positiveMatrixSpectralAtom F hF i) G := by simp [map_sum, LinearMap.sum_apply] _ = bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G := by rw [positiveMatrixSpectralAtom_sum] theorem leftSpectralBornWeight_moment {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (G : Matrix dB dB ℂ) : (∑ i : dA, leftSpectralBornWeight ρ F hF G i * hF.isHermitian.eigenvalues i) = bornTracePairing ρ.matrix F G := by have hspectral : F = ∑ i : dA, hF.isHermitian.eigenvalues i • positiveMatrixSpectralAtom F hF i := by calc F = cfc (fun z : ℝ => z) F := (cfc_id' ℝ F hF.isHermitian).symm _ = _ := positiveMatrix_cfc_spectral_sum F hF (fun z : ℝ => z) have h := congrArg (fun H : Matrix dA dA ℂ => bornTracePairing ρ.matrix H G) hspectral simp only [map_sum, LinearMap.sum_apply, map_smul, LinearMap.smul_apply, smul_eq_mul] at h calc (∑ i : dA, leftSpectralBornWeight ρ F hF G i * hF.isHermitian.eigenvalues i) = ∑ i : dA, hF.isHermitian.eigenvalues i * bornTracePairing ρ.matrix (positiveMatrixSpectralAtom F hF i) G := by apply Finset.sum_congr rfl intro i _ unfold leftSpectralBornWeight ring _ = bornTracePairing ρ.matrix F G := h.symm theorem leftSpectralBornWeight_entropy {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (G : Matrix dB dB ℂ) : bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G = ∑ i : dA, leftSpectralBornWeight ρ F hF G i * (hF.isHermitian.eigenvalues i * Real.log (hF.isHermitian.eigenvalues i)) := by have hspectral := positiveMatrix_cfc_spectral_sum F hF (fun z : ℝ => z * Real.log z) have h := congrArg (fun H : Matrix dA dA ℂ => bornTracePairing ρ.matrix H G) hspectral simp only [map_sum, LinearMap.sum_apply, map_smul, LinearMap.smul_apply, smul_eq_mul] at h calc bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G = ∑ i : dA, (hF.isHermitian.eigenvalues i * Real.log (hF.isHermitian.eigenvalues i)) * bornTracePairing ρ.matrix (positiveMatrixSpectralAtom F hF i) G := h _ = ∑ i : dA, leftSpectralBornWeight ρ F hF G i * (hF.isHermitian.eigenvalues i * Real.log (hF.isHermitian.eigenvalues i)) := by apply Finset.sum_congr rfl intro i _ unfold leftSpectralBornWeight ring theorem bornTracePairing_one_one {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) : bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) (1 : Matrix dB dB ℂ) = 1 := by simp [bornTracePairing, ρ.trace_one] theorem bornTracePairing_one_le_one {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (G : Matrix dB dB ℂ) (hGcomplement : (1 - G).PosSemidef) : bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G ≤ 1 := by have hpositive : 0 ≤ bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) (1 - G) := trace_mul_posSemidef_nonneg ρ.positive (Matrix.PosSemidef.one.kronecker hGcomplement) have hdiff : bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) (1 - G) = bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) (1 : Matrix dB dB ℂ) - bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G := (bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ)).map_sub 1 G rw [hdiff, bornTracePairing_one_one] at hpositive linarith theorem positiveContraction_eigenvalue_le_one {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (hcomplement : (1 - F).PosSemidef) (i : d) : hF.isHermitian.eigenvalues i ≤ 1 := by have hFle : F ≤ (1 : Matrix d d ℂ) := Matrix.le_iff.mpr hcomplement have hspectrum : ∀ z ∈ spectrum ℝ F, z ≤ 1 := (CFC.le_one_iff (R := ℝ) F hF.isHermitian).mp hFle exact hspectrum _ (hF.isHermitian.eigenvalues_mem_spectrum_real i) theorem leftSpectralBornWeight_negEntropy {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (G : Matrix dB dB ℂ) : -bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G = ∑ i : dA, leftSpectralBornWeight ρ F hF G i * Real.negMulLog (hF.isHermitian.eigenvalues i) := by rw [leftSpectralBornWeight_entropy ρ F hF G, ← Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro i _ simp [Real.negMulLog] theorem matrixLogEntropy_born_lower_bound_left {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (hFcomplement : (1 - F).PosSemidef) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) (hGcomplement : (1 - G).PosSemidef) : -bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G ≤ Real.negMulLog (bornTracePairing ρ.matrix F G) := by classical have hp_nonneg : 0 ≤ bornTracePairing ρ.matrix F G := trace_mul_posSemidef_nonneg ρ.positive (hF.kronecker hG) have hmass_le : bornTracePairing ρ.matrix F G ≤ bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G := by calc bornTracePairing ρ.matrix F G = ∑ i : dA, leftSpectralBornWeight ρ F hF G i * hF.isHermitian.eigenvalues i := (leftSpectralBornWeight_moment ρ F hF G).symm _ ≤ ∑ i : dA, leftSpectralBornWeight ρ F hF G i := by apply Finset.sum_le_sum intro i _ exact mul_le_of_le_one_right (leftSpectralBornWeight_nonneg ρ F hF G hG i) (positiveContraction_eigenvalue_le_one F hF hFcomplement i) _ = bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G := leftSpectralBornWeight_sum ρ F hF G by_cases hp : bornTracePairing ρ.matrix F G = 0 · have hzero : (∑ i : dA, leftSpectralBornWeight ρ F hF G i * hF.isHermitian.eigenvalues i) = 0 := by rw [leftSpectralBornWeight_moment, hp] have hterm (i : dA) : leftSpectralBornWeight ρ F hF G i * hF.isHermitian.eigenvalues i = 0 := (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => mul_nonneg (leftSpectralBornWeight_nonneg ρ F hF G hG j) (hF.eigenvalues_nonneg j))).mp hzero i (Finset.mem_univ i) have hentropy : (∑ i : dA, leftSpectralBornWeight ρ F hF G i * Real.negMulLog (hF.isHermitian.eigenvalues i)) = 0 := by apply Finset.sum_eq_zero intro i _ rcases mul_eq_zero.mp (hterm i) with hw | he · simp [hw] · simp [he] calc -bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G = ∑ i : dA, leftSpectralBornWeight ρ F hF G i * Real.negMulLog (hF.isHermitian.eigenvalues i) := leftSpectralBornWeight_negEntropy ρ F hF G _ = 0 := hentropy _ ≤ Real.negMulLog (bornTracePairing ρ.matrix F G) := by rw [hp] simp · have hp_pos : 0 < bornTracePairing ρ.matrix F G := lt_of_le_of_ne hp_nonneg (Ne.symm hp) have hW_pos : 0 < bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G := lt_of_lt_of_le hp_pos hmass_le have hscalar := finite_weighted_entropy_le_of_weight_bound (Finset.univ : Finset dA) (leftSpectralBornWeight ρ F hF G) hF.isHermitian.eigenvalues (W := bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G) (N := (1 : ℝ)) (p := bornTracePairing ρ.matrix F G) (fun i _ => leftSpectralBornWeight_nonneg ρ F hF G hG i) (fun i _ => hF.eigenvalues_nonneg i) hW_pos hp_pos (leftSpectralBornWeight_sum ρ F hF G) (leftSpectralBornWeight_moment ρ F hF G) (bornTracePairing_one_le_one ρ G hGcomplement) calc -bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G = ∑ i : dA, leftSpectralBornWeight ρ F hF G i * Real.negMulLog (hF.isHermitian.eigenvalues i) := leftSpectralBornWeight_negEntropy ρ F hF G _ ≤ bornTracePairing ρ.matrix F G * Real.log (1 / bornTracePairing ρ.matrix F G) := hscalar _ = Real.negMulLog (bornTracePairing ρ.matrix F G) := by rw [one_div, Real.log_inv] simp [Real.negMulLog] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def rawEmbezzlementState (n : ℕ) : EuclideanSpace ℂ (Fin n × Fin n) := toLp 2 fun q : Fin n × Fin n => if q.1 = q.2 then (↑((Real.sqrt ((q.1.val : ℝ) + 1))⁻¹) : ℂ) else 0 theorem rawEmbezzlementState_ne_zero (n : ℕ) (hn : 0 < n) : rawEmbezzlementState n ≠ 0 := by intro h let j : Fin n := ⟨0, hn⟩ have hj := congrArg (fun z : EuclideanSpace ℂ (Fin n × Fin n) => z (j, j)) h simp [rawEmbezzlementState, j] at hj def harmonicNumber (n : ℕ) : ℝ := ∑ j : Fin n, ((j.val : ℝ) + 1)⁻¹ theorem rawEmbezzlementState_norm_sq (n : ℕ) : ‖rawEmbezzlementState n‖ ^ 2 = harmonicNumber n := by classical have hamp (j : Fin n) : ‖(↑((Real.sqrt ((j.val : ℝ) + 1))⁻¹) : ℂ)‖ ^ 2 = ((j.val : ℝ) + 1)⁻¹ := by rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (by positivity), inv_pow, Real.sq_sqrt (by positivity)] have hterm (i j : Fin n) : ‖if i = j then (↑((Real.sqrt ((i.val : ℝ) + 1))⁻¹) : ℂ) else 0‖ ^ 2 = if i = j then ‖(↑((Real.sqrt ((i.val : ℝ) + 1))⁻¹) : ℂ)‖ ^ 2 else 0 := by split_ifs <;> simp rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] unfold harmonicNumber apply Finset.sum_congr rfl intro i _ change (∑ j : Fin n, ‖if i = j then (↑((Real.sqrt ((i.val : ℝ) + 1))⁻¹) : ℂ) else 0‖ ^ 2) = ((i.val : ℝ) + 1)⁻¹ calc (∑ j : Fin n, ‖if i = j then (↑((Real.sqrt ((i.val : ℝ) + 1))⁻¹) : ℂ) else 0‖ ^ 2) = ‖(↑((Real.sqrt ((i.val : ℝ) + 1))⁻¹) : ℂ)‖ ^ 2 := by simp_rw [hterm] simp _ = ((i.val : ℝ) + 1)⁻¹ := hamp i def embezzlementState (n : ℕ) : EuclideanSpace ℂ (Fin n × Fin n) := (‖rawEmbezzlementState n‖⁻¹ : ℝ) • rawEmbezzlementState n theorem embezzlementState_norm (n : ℕ) (hn : 0 < n) : ‖embezzlementState n‖ = 1 := by have hraw : ‖rawEmbezzlementState n‖ ≠ 0 := norm_ne_zero_iff.mpr (rawEmbezzlementState_ne_zero n hn) rw [embezzlementState, norm_smul, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr (norm_nonneg _)), inv_mul_cancel₀ hraw] theorem embezzlementState_apply (n : ℕ) (i j : Fin n) : embezzlementState n (i, j) = (‖rawEmbezzlementState n‖⁻¹ : ℝ) • (if i = j then (↑((Real.sqrt ((i.val : ℝ) + 1))⁻¹) : ℂ) else 0) := by rfl abbrev BipartiteUnitVector (d : ℕ) := {ξ : EuclideanSpace ℂ (Fin d × Fin d) // ‖ξ‖ = 1} def spectralAtomOverlap {d : Type*} [Fintype d] [DecidableEq d] (F G : Matrix d d ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (i j : d) : ℝ := (Matrix.trace (positiveMatrixSpectralAtom F hF i * positiveMatrixSpectralAtom G hG j)).re theorem spectralAtomOverlap_nonneg {d : Type*} [Fintype d] [DecidableEq d] (F G : Matrix d d ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (i j : d) : 0 ≤ spectralAtomOverlap F G hF hG i j := by exact trace_mul_posSemidef_nonneg (positiveMatrixSpectralAtom_posSemidef F hF i) (positiveMatrixSpectralAtom_posSemidef G hG j) theorem spectralAtom_trace {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (i : d) : Matrix.trace (positiveMatrixSpectralAtom F hF i) = 1 := by classical unfold positiveMatrixSpectralAtom rw [spectralConjugationCLM_apply, Matrix.trace_mul_cycle, Matrix.UnitaryGroup.star_mul_self, one_mul, Matrix.trace_diagonal] simp [Pi.single_apply] theorem spectralAtom_mul {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (i j : d) : positiveMatrixSpectralAtom F hF i * positiveMatrixSpectralAtom F hF j = if i = j then positiveMatrixSpectralAtom F hF i else 0 := by classical let e := Unitary.conjStarAlgAut ℝ (Matrix d d ℂ) hF.isHermitian.eigenvectorUnitary change e (Matrix.diagonal (Pi.single i (1 : ℂ))) * e (Matrix.diagonal (Pi.single j (1 : ℂ))) = if i = j then e (Matrix.diagonal (Pi.single i (1 : ℂ))) else 0 by_cases hij : i = j · subst j simp only [ite_true] rw [← map_mul, Matrix.diagonal_mul_diagonal] congr 1 ext k l simp only [Matrix.diagonal_apply, Pi.single_apply] split_ifs <;> simp_all · simp only [hij, ite_false] rw [← map_mul, Matrix.diagonal_mul_diagonal, ← map_zero e] congr 1 ext k l by_cases hik : k = i · subst k simp [Matrix.diagonal_apply, Pi.single_apply, hij] · simp [Matrix.diagonal_apply, Pi.single_apply, hik] theorem spectralAtomSum_mul_self {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (s : Finset d) : (∑ i ∈ s, positiveMatrixSpectralAtom F hF i) * (∑ i ∈ s, positiveMatrixSpectralAtom F hF i) = ∑ i ∈ s, positiveMatrixSpectralAtom F hF i := by classical calc (∑ i ∈ s, positiveMatrixSpectralAtom F hF i) * (∑ i ∈ s, positiveMatrixSpectralAtom F hF i) = ∑ i ∈ s, ∑ j ∈ s, positiveMatrixSpectralAtom F hF i * positiveMatrixSpectralAtom F hF j := by simp only [Matrix.sum_mul, Matrix.mul_sum] rw [Finset.sum_comm] _ = ∑ i ∈ s, positiveMatrixSpectralAtom F hF i := by apply Finset.sum_congr rfl intro i hi simp [spectralAtom_mul, hi] theorem rectangularMatrix_norm_sq {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] (K : Matrix e d ℂ) (z : EuclideanSpace ℂ d) : ‖toLp 2 (K.mulVec (ofLp z))‖ ^ 2 = quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) (K.conjTranspose * K)) z := by calc ‖toLp 2 (K.mulVec (ofLp z))‖ ^ 2 = (inner ℂ (toLp 2 (K.mulVec (ofLp z))) (toLp 2 (K.mulVec (ofLp z)))).re := norm_sq_eq_re_inner (𝕜 := ℂ) (toLp 2 (K.mulVec (ofLp z))) _ = (star (K.mulVec (ofLp z)) ⬝ᵥ K.mulVec (ofLp z)).re := by rw [EuclideanSpace.inner_eq_star_dotProduct] change (K.mulVec (ofLp z) ⬝ᵥ star (K.mulVec (ofLp z))).re = _ rw [dotProduct_comm] _ = (star (ofLp z) ⬝ᵥ (K.conjTranspose * K).mulVec (ofLp z)).re := by rw [Matrix.star_mulVec, ← Matrix.dotProduct_mulVec, Matrix.mulVec_mulVec] _ = quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) (K.conjTranspose * K)) z := by unfold quadraticExpectation rw [EuclideanSpace.inner_eq_star_dotProduct] change (star (ofLp z) ⬝ᵥ (K.conjTranspose * K).mulVec (ofLp z)).re = ((K.conjTranspose * K).mulVec (ofLp z) ⬝ᵥ star (ofLp z)).re rw [dotProduct_comm] def coherentBinaryJointOutcome {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (P : POVM Bool d) (Q : POVM Bool e) (z : EuclideanSpace ℂ (d × e)) (a b : Bool) : EuclideanSpace ℂ (d × e) := toLp 2 (((P.effect a ⊗ₖ Q.effect b)).mulVec (ofLp z)) theorem coherentBinaryJointOutcome_norm_sq {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (P : POVM Bool d) (Q : POVM Bool e) (hP : ∀ c : Bool, P.effect c * P.effect c = P.effect c) (hQ : ∀ c : Bool, Q.effect c * Q.effect c = Q.effect c) (z : EuclideanSpace ℂ (d × e)) (hz : ‖z‖ = 1) (a b : Bool) : ‖coherentBinaryJointOutcome P Q z a b‖ ^ 2 = (Matrix.trace ((pureDensityMatrix z hz).matrix * (P.effect a ⊗ₖ Q.effect b))).re := by let K : Matrix (d × e) (d × e) ℂ := P.effect a ⊗ₖ Q.effect b have hgram : K.conjTranspose * K = K := by dsimp [K] rw [Matrix.conjTranspose_kronecker, (P.positive a).isHermitian.eq, (Q.positive b).isHermitian.eq, ← Matrix.mul_kronecker_mul, hP a, hQ b] calc ‖coherentBinaryJointOutcome P Q z a b‖ ^ 2 = quadraticExpectation (Matrix.toEuclideanCLM (n := d × e) (𝕜 := ℂ) (K.conjTranspose * K)) z := rectangularMatrix_norm_sq K z _ = quadraticExpectation (Matrix.toEuclideanCLM (n := d × e) (𝕜 := ℂ) K) z := by rw [hgram] _ = (Matrix.trace ((pureDensityMatrix z hz).matrix * K)).re := (pureDensityMatrix_trace_mul z hz K).symm def finiteTensorVector {ι d : Type*} [Fintype ι] [Fintype d] (v : ι → EuclideanSpace ℂ d) : EuclideanSpace ℂ (ι → d) := toLp 2 fun q : ι → d => ∏ i : ι, v i (q i) theorem finiteTensorVector_norm_sq {ι d : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] (v : ι → EuclideanSpace ℂ d) : ‖finiteTensorVector v‖ ^ 2 = ∏ i : ι, ‖v i‖ ^ 2 := by classical rw [EuclideanSpace.norm_sq_eq] change (∑ q : ι → d, ‖∏ i : ι, v i (q i)‖ ^ 2) = ∏ i : ι, ‖v i‖ ^ 2 calc (∑ q : ι → d, ‖∏ i : ι, v i (q i)‖ ^ 2) = ∑ q : ι → d, ∏ i : ι, ‖v i (q i)‖ ^ 2 := by apply Finset.sum_congr rfl intro q _ rw [norm_prod, ← Finset.prod_pow] _ = ∏ i : ι, ∑ a : d, ‖v i a‖ ^ 2 := (Fintype.prod_sum (fun i : ι => fun a : d => ‖v i a‖ ^ 2)).symm _ = ∏ i : ι, ‖v i‖ ^ 2 := by apply Finset.prod_congr rfl intro i _ exact (EuclideanSpace.norm_sq_eq (v i)).symm theorem finiteTensorVector_norm {ι d : Type*} [Fintype ι] [DecidableEq ι] [Fintype d] (v : ι → EuclideanSpace ℂ d) (hv : ∀ i, ‖v i‖ = 1) : ‖finiteTensorVector v‖ = 1 := by have hsquare := finiteTensorVector_norm_sq v simp_rw [hv, one_pow, Finset.prod_const_one] at hsquare nlinarith [norm_nonneg (finiteTensorVector v)] theorem spectralAtomOverlap_sum_right {d : Type*} [Fintype d] [DecidableEq d] (F G : Matrix d d ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (i : d) : (∑ j : d, spectralAtomOverlap F G hF hG i j) = 1 := by classical calc (∑ j : d, spectralAtomOverlap F G hF hG i j) = (Matrix.trace (positiveMatrixSpectralAtom F hF i * (∑ j : d, positiveMatrixSpectralAtom G hG j))).re := by simp only [spectralAtomOverlap, Matrix.mul_sum, Matrix.trace_sum, Complex.re_sum] _ = (Matrix.trace (positiveMatrixSpectralAtom F hF i)).re := by rw [positiveMatrixSpectralAtom_sum] simp _ = 1 := by rw [spectralAtom_trace] rfl theorem spectralAtomOverlap_sum_left {d : Type*} [Fintype d] [DecidableEq d] (F G : Matrix d d ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (j : d) : (∑ i : d, spectralAtomOverlap F G hF hG i j) = 1 := by classical calc (∑ i : d, spectralAtomOverlap F G hF hG i j) = (Matrix.trace ((∑ i : d, positiveMatrixSpectralAtom F hF i) * positiveMatrixSpectralAtom G hG j)).re := by simp only [spectralAtomOverlap, Matrix.sum_mul, Matrix.trace_sum, Complex.re_sum] _ = (Matrix.trace (positiveMatrixSpectralAtom G hG j)).re := by rw [positiveMatrixSpectralAtom_sum] simp _ = 1 := by rw [spectralAtom_trace] rfl theorem positiveDensity_eigenvalues_sum {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (htrace : Matrix.trace F = 1) : (∑ i : d, hF.isHermitian.eigenvalues i) = 1 := by have hspectral := congrArg Complex.re hF.isHermitian.trace_eq_sum_eigenvalues simpa [htrace, Complex.re_sum] using hspectral.symm theorem spectralAtomOverlap_schmidtMass_le_one {d : Type*} [Fintype d] [DecidableEq d] (F G : Matrix d d ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (hFtrace : Matrix.trace F = 1) (hGtrace : Matrix.trace G = 1) : (∑ i : d, ∑ j : d, Real.sqrt (hF.isHermitian.eigenvalues i) * Real.sqrt (hG.isHermitian.eigenvalues j) * spectralAtomOverlap F G hF hG i j) ≤ 1 := by classical let w : d × d → ℝ := fun q => spectralAtomOverlap F G hF hG q.1 q.2 let f : d × d → ℝ := fun q => Real.sqrt (hF.isHermitian.eigenvalues q.1) let g : d × d → ℝ := fun q => Real.sqrt (hG.isHermitian.eigenvalues q.2) have hf : (∑ q : d × d, w q * f q ^ 2) = 1 := by dsimp [w, f] rw [Fintype.sum_prod_type] simp_rw [Real.sq_sqrt (hF.eigenvalues_nonneg _)] calc (∑ i : d, ∑ j : d, spectralAtomOverlap F G hF hG i j * hF.isHermitian.eigenvalues i) = ∑ i : d, hF.isHermitian.eigenvalues i * (∑ j : d, spectralAtomOverlap F G hF hG i j) := by apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j _ ring _ = ∑ i : d, hF.isHermitian.eigenvalues i := by simp_rw [spectralAtomOverlap_sum_right, mul_one] _ = 1 := positiveDensity_eigenvalues_sum F hF hFtrace have hg : (∑ q : d × d, w q * g q ^ 2) = 1 := by dsimp [w, g] rw [Fintype.sum_prod_type] simp_rw [Real.sq_sqrt (hG.eigenvalues_nonneg _)] calc (∑ i : d, ∑ j : d, spectralAtomOverlap F G hF hG i j * hG.isHermitian.eigenvalues j) = ∑ j : d, hG.isHermitian.eigenvalues j * (∑ i : d, spectralAtomOverlap F G hF hG i j) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro j _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ ring _ = ∑ j : d, hG.isHermitian.eigenvalues j := by simp_rw [spectralAtomOverlap_sum_left, mul_one] _ = 1 := positiveDensity_eigenvalues_sum G hG hGtrace calc (∑ i : d, ∑ j : d, Real.sqrt (hF.isHermitian.eigenvalues i) * Real.sqrt (hG.isHermitian.eigenvalues j) * spectralAtomOverlap F G hF hG i j) = ∑ q : d × d, w q * f q * g q := by rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ dsimp [w, f, g] ring _ ≤ Real.sqrt (∑ q : d × d, w q * f q ^ 2) * Real.sqrt (∑ q : d × d, w q * g q ^ 2) := by apply weighted_real_cauchy intro q exact spectralAtomOverlap_nonneg F G hF hG q.1 q.2 _ = 1 := by rw [hf, hg]; norm_num def binaryBornProbability {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (ρ : DensityMatrix (d × e)) (P : POVM Bool d) (Q : POVM Bool e) (a b : Bool) : ℝ := (Matrix.trace (ρ.matrix * (P.effect a ⊗ₖ Q.effect b))).re theorem binaryBornProbability_normalized {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (ρ : DensityMatrix (d × e)) (P : POVM Bool d) (Q : POVM Bool e) : (∑ a : Bool, ∑ b : Bool, binaryBornProbability ρ P Q a b) = 1 := by classical have hjoint : (∑ a : Bool, ∑ b : Bool, P.effect a ⊗ₖ Q.effect b) = (1 : Matrix (d × e) (d × e) ℂ) := by calc (∑ a : Bool, ∑ b : Bool, P.effect a ⊗ₖ Q.effect b) = (∑ a : Bool, P.effect a) ⊗ₖ (∑ b : Bool, Q.effect b) := by ext ⟨i, j⟩ ⟨k, l⟩ simp only [Matrix.sum_apply, Matrix.kroneckerMap_apply] rw [Finset.sum_mul] simp_rw [Finset.mul_sum] _ = 1 := by rw [P.complete, Q.complete] exact Matrix.one_kronecker_one calc (∑ a : Bool, ∑ b : Bool, binaryBornProbability ρ P Q a b) = (Matrix.trace (ρ.matrix * (∑ a : Bool, ∑ b : Bool, P.effect a ⊗ₖ Q.effect b))).re := by simp only [Fintype.sum_bool, binaryBornProbability, Matrix.mul_add, Matrix.trace_add, Complex.add_re] _ = (Matrix.trace ρ.matrix).re := by rw [hjoint] simp _ = 1 := by rw [ρ.trace_one] rfl def binaryContinueProbability {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (ρ : DensityMatrix (d × e)) (P : POVM Bool d) (Q : POVM Bool e) : ℝ := binaryBornProbability ρ P Q false false def binaryJointSuccessProbability {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (ρ : DensityMatrix (d × e)) (P : POVM Bool d) (Q : POVM Bool e) : ℝ := binaryBornProbability ρ P Q true true def binaryMismatchProbability {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (ρ : DensityMatrix (d × e)) (P : POVM Bool d) (Q : POVM Bool e) : ℝ := binaryBornProbability ρ P Q true false + binaryBornProbability ρ P Q false true theorem binaryStoppingPartition {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (ρ : DensityMatrix (d × e)) (P : POVM Bool d) (Q : POVM Bool e) : binaryContinueProbability ρ P Q + binaryJointSuccessProbability ρ P Q + binaryMismatchProbability ρ P Q = 1 := by have hnormalized := binaryBornProbability_normalized ρ P Q simp only [Fintype.sum_bool] at hnormalized unfold binaryContinueProbability binaryJointSuccessProbability binaryMismatchProbability linarith theorem unitVector_distance_of_real_overlap {ι : Type*} [Fintype ι] (z w : EuclideanSpace ℂ ι) (hz : ‖z‖ = 1) (hw : ‖w‖ = 1) (ε : ℝ) (hε : 0 ≤ ε) (hoverlap : 1 - ε ≤ (inner ℂ z w).re) : ‖z - w‖ ≤ Real.sqrt (2 * ε) := by have hoverlap' : 1 - ε ≤ RCLike.re (inner ℂ z w) := by exact hoverlap have hsq : ‖z - w‖ ^ 2 ≤ 2 * ε := by rw [@norm_sub_sq ℂ, hz, hw] nlinarith [hoverlap'] have hsqrt : (Real.sqrt (2 * ε)) ^ 2 = 2 * ε := Real.sq_sqrt (by positivity) nlinarith [norm_nonneg (z - w), Real.sqrt_nonneg (2 * ε)] def sharedThresholdResourceRaw {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) : EuclideanSpace ℂ ((Σ _ : κ, d) × (Σ _ : κ, d)) := toLp 2 fun q : (Σ _ : κ, d) × (Σ _ : κ, d) => if q.1.1 = q.2.1 ∧ q.1.2 = q.2.2 then (τ q.1.1 : ℂ) else 0 theorem sharedThresholdResourceRaw_norm_sq {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) : ‖sharedThresholdResourceRaw (d := d) τ‖ ^ 2 = (Fintype.card d : ℝ) * ∑ k : κ, τ k ^ 2 := by classical have hterm (k l : κ) (i j : d) : ‖if k = l ∧ i = j then (τ k : ℂ) else 0‖ ^ 2 = if k = l then if i = j then τ k ^ 2 else 0 else 0 := by split_ifs <;> simp_all [Complex.norm_real, Real.norm_eq_abs, sq_abs] rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] simp_rw [Fintype.sum_sigma] change (∑ k : κ, ∑ i : d, ∑ l : κ, ∑ j : d, ‖if k = l ∧ i = j then (τ k : ℂ) else 0‖ ^ 2) = (Fintype.card d : ℝ) * ∑ k : κ, τ k ^ 2 simp_rw [hterm] simp [Finset.mul_sum] theorem sharedThresholdResourceRaw_ne_zero {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) (k : κ) (i : d) (hk : τ k ≠ 0) : sharedThresholdResourceRaw (d := d) τ ≠ 0 := by intro hzero have hentry := congrArg (fun z : EuclideanSpace ℂ ((Σ _ : κ, d) × (Σ _ : κ, d)) => z (⟨k, i⟩, ⟨k, i⟩)) hzero have hcast : (τ k : ℂ) = 0 := by simpa [sharedThresholdResourceRaw] using hentry exact hk (by exact_mod_cast hcast) def sharedThresholdResource {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) : EuclideanSpace ℂ ((Σ _ : κ, d) × (Σ _ : κ, d)) := (‖sharedThresholdResourceRaw (d := d) τ‖⁻¹ : ℝ) • sharedThresholdResourceRaw (d := d) τ theorem sharedThresholdResource_norm {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) (k : κ) (i : d) (hk : τ k ≠ 0) : ‖sharedThresholdResource (d := d) τ‖ = 1 := by have hnorm : ‖sharedThresholdResourceRaw (d := d) τ‖ ≠ 0 := norm_ne_zero_iff.mpr (sharedThresholdResourceRaw_ne_zero τ k i hk) rw [sharedThresholdResource, norm_smul, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr (norm_nonneg _)), inv_mul_cancel₀ hnorm] def transposePOVM {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (P : POVM ι d) : POVM ι d where effect b := (P.effect b).transpose positive b := (P.positive b).transpose complete := by classical ext i j have hc := congrArg (fun M : Matrix d d ℂ => M j i) P.complete simpa [Matrix.sum_apply, Matrix.transpose_apply, Matrix.one_apply, eq_comm] using hc theorem transposePOVM_projective {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (P : POVM ι d) (hP : ∀ b : ι, P.effect b * P.effect b = P.effect b) (b : ι) : (transposePOVM P).effect b * (transposePOVM P).effect b = (transposePOVM P).effect b := by change (P.effect b).transpose * (P.effect b).transpose = (P.effect b).transpose rw [← Matrix.transpose_mul, hP b] theorem sharedThresholdResourceRaw_eq_vec {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) : sharedThresholdResourceRaw (d := d) τ = toLp 2 (Matrix.vec (Matrix.diagonal (fun q : Σ _ : κ, d => (τ q.1 : ℂ)))) := by ext ⟨⟨k, i⟩, ⟨l, j⟩⟩ by_cases h : k = l · subst l by_cases hij : i = j · subst j simp [sharedThresholdResourceRaw, Matrix.vec] · simp [sharedThresholdResourceRaw, Matrix.vec, hij, Ne.symm hij] · simp [sharedThresholdResourceRaw, Matrix.vec, h, Ne.symm h] theorem sharedThresholdResourceRaw_local_action {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) (A B : Matrix (Σ _ : κ, d) (Σ _ : κ, d) ℂ) : toLp 2 ((A ⊗ₖ B.transpose).mulVec (ofLp (sharedThresholdResourceRaw (d := d) τ))) = toLp 2 (Matrix.vec (B.transpose * Matrix.diagonal (fun q : Σ _ : κ, d => (τ q.1 : ℂ)) * A.transpose)) := by rw [sharedThresholdResourceRaw_eq_vec] apply WithLp.ofLp_injective change (A ⊗ₖ B.transpose).mulVec (Matrix.vec (Matrix.diagonal (fun q : Σ _ : κ, d => (τ q.1 : ℂ)))) = Matrix.vec (B.transpose * Matrix.diagonal (fun q : Σ _ : κ, d => (τ q.1 : ℂ)) * A.transpose) exact Matrix.kronecker_mulVec_vec B.transpose (Matrix.diagonal (fun q : Σ _ : κ, d => (τ q.1 : ℂ))) A theorem matrixVectorization_norm_sq {d e : Type*} [Fintype d] [Fintype e] (K : Matrix d e ℂ) : ‖toLp 2 (Matrix.vec K)‖ ^ 2 = (Matrix.trace (K.conjTranspose * K)).re := by calc ‖toLp 2 (Matrix.vec K)‖ ^ 2 = (inner ℂ (toLp 2 (Matrix.vec K)) (toLp 2 (Matrix.vec K))).re := norm_sq_eq_re_inner (𝕜 := ℂ) (toLp 2 (Matrix.vec K)) _ = (star (Matrix.vec K) ⬝ᵥ Matrix.vec K).re := by rw [EuclideanSpace.inner_eq_star_dotProduct] change (Matrix.vec K ⬝ᵥ star (Matrix.vec K)).re = (star (Matrix.vec K) ⬝ᵥ Matrix.vec K).re rw [dotProduct_comm] _ = (Matrix.trace (K.conjTranspose * K)).re := by rw [Matrix.star_vec_dotProduct_vec] theorem sharedThresholdDiagonal_eq_block {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) : Matrix.diagonal (fun q : Σ _ : κ, d => (τ q.1 : ℂ)) = Matrix.blockDiagonal' fun k : κ => (τ k : ℂ) • (1 : Matrix d d ℂ) := by classical ext ⟨k, i⟩ ⟨l, j⟩ by_cases h : k = l · subst l by_cases hij : i = j · subst j simp [Matrix.blockDiagonal'_apply] · simp [Matrix.blockDiagonal'_apply, hij] · simp [Matrix.blockDiagonal'_apply, h] theorem sharedThresholdResourceRaw_block_action {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) (A B : κ → Matrix d d ℂ) : toLp 2 ((Matrix.blockDiagonal' A ⊗ₖ (Matrix.blockDiagonal' B).transpose).mulVec (ofLp (sharedThresholdResourceRaw (d := d) τ))) = toLp 2 (Matrix.vec ((Matrix.blockDiagonal' fun k : κ => (τ k : ℂ) • (A k * B k)).transpose)) := by rw [sharedThresholdResourceRaw_local_action] congr 2 rw [sharedThresholdDiagonal_eq_block] simp only [Matrix.blockDiagonal'_transpose] rw [← Matrix.blockDiagonal'_mul, ← Matrix.blockDiagonal'_mul] congr 1 funext k simp [Matrix.transpose_mul] theorem projectorProduct_hilbertSchmidt_trace {d : Type*} [Fintype d] [DecidableEq d] (A B : Matrix d d ℂ) (hA : A.PosSemidef) (hB : B.PosSemidef) (hAA : A * A = A) (hBB : B * B = B) : Matrix.trace ((A * B).conjTranspose * (A * B)) = Matrix.trace (A * B) := by rw [Matrix.conjTranspose_mul, hA.isHermitian.eq, hB.isHermitian.eq] calc Matrix.trace ((B * A) * (A * B)) = Matrix.trace (B * (A * A) * B) := by congr 1 simp [Matrix.mul_assoc] _ = Matrix.trace (B * A * B) := by rw [hAA] _ = Matrix.trace (B * B * A) := by rw [Matrix.trace_mul_cycle] _ = Matrix.trace (B * A) := by rw [hBB] _ = Matrix.trace (A * B) := Matrix.trace_mul_comm B A theorem weightedProjectorProduct_hilbertSchmidt_trace {d : Type*} [Fintype d] [DecidableEq d] (t : ℝ) (A B : Matrix d d ℂ) (hA : A.PosSemidef) (hB : B.PosSemidef) (hAA : A * A = A) (hBB : B * B = B) : (Matrix.trace (((t : ℂ) • (A * B)).conjTranspose * ((t : ℂ) • (A * B)))).re = t ^ 2 * (Matrix.trace (A * B)).re := by have hgram := projectorProduct_hilbertSchmidt_trace A B hA hB hAA hBB rw [Matrix.conjTranspose_smul, Matrix.smul_mul, Matrix.mul_smul, Matrix.trace_smul, Matrix.trace_smul, hgram] simp [Complex.mul_re, pow_two, mul_assoc] theorem sharedThresholdResourceRaw_block_action_norm_sq {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) (A B : κ → Matrix d d ℂ) (hA : ∀ k, (A k).PosSemidef) (hB : ∀ k, (B k).PosSemidef) (hAA : ∀ k, A k * A k = A k) (hBB : ∀ k, B k * B k = B k) : ‖toLp 2 ((Matrix.blockDiagonal' A ⊗ₖ (Matrix.blockDiagonal' B).transpose).mulVec (ofLp (sharedThresholdResourceRaw (d := d) τ)))‖ ^ 2 = ∑ k : κ, τ k ^ 2 * (Matrix.trace (A k * B k)).re := by rw [sharedThresholdResourceRaw_block_action, matrixVectorization_norm_sq] let K : Matrix (Σ _ : κ, d) (Σ _ : κ, d) ℂ := Matrix.blockDiagonal' fun k : κ => (τ k : ℂ) • (A k * B k) change (Matrix.trace (K.transpose.conjTranspose * K.transpose)).re = ∑ k : κ, τ k ^ 2 * (Matrix.trace (A k * B k)).re rw [Matrix.transpose_conjTranspose, ← Matrix.conjTranspose_transpose, Matrix.trace_transpose_mul] change (Matrix.trace ((Matrix.blockDiagonal' fun k : κ => (τ k : ℂ) • (A k * B k)).conjTranspose * (Matrix.blockDiagonal' fun k : κ => (τ k : ℂ) • (A k * B k)))).re = _ rw [Matrix.blockDiagonal'_conjTranspose, ← Matrix.blockDiagonal'_mul, Matrix.trace_blockDiagonal', Complex.re_sum] apply Finset.sum_congr rfl intro k _ exact weightedProjectorProduct_hilbertSchmidt_trace (τ k) (A k) (B k) (hA k) (hB k) (hAA k) (hBB k) theorem sharedThresholdResource_block_action_norm_sq {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) (A B : κ → Matrix d d ℂ) (hA : ∀ k, (A k).PosSemidef) (hB : ∀ k, (B k).PosSemidef) (hAA : ∀ k, A k * A k = A k) (hBB : ∀ k, B k * B k = B k) : ‖toLp 2 ((Matrix.blockDiagonal' A ⊗ₖ (Matrix.blockDiagonal' B).transpose).mulVec (ofLp (sharedThresholdResource (d := d) τ)))‖ ^ 2 = (∑ k : κ, τ k ^ 2 * (Matrix.trace (A k * B k)).re) / ((Fintype.card d : ℝ) * ∑ k : κ, τ k ^ 2) := by let M : Matrix ((Σ _ : κ, d) × (Σ _ : κ, d)) ((Σ _ : κ, d) × (Σ _ : κ, d)) ℂ := Matrix.blockDiagonal' A ⊗ₖ (Matrix.blockDiagonal' B).transpose change ‖Matrix.toEuclideanLin M (sharedThresholdResource (d := d) τ)‖ ^ 2 = _ rw [sharedThresholdResource, (Matrix.toEuclideanLin M).map_smul_of_tower, norm_smul, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr (norm_nonneg _)), mul_pow, inv_pow] change (‖sharedThresholdResourceRaw (d := d) τ‖ ^ 2)⁻¹ * ‖toLp 2 ((Matrix.blockDiagonal' A ⊗ₖ (Matrix.blockDiagonal' B).transpose).mulVec (ofLp (sharedThresholdResourceRaw (d := d) τ)))‖ ^ 2 = _ rw [sharedThresholdResourceRaw_norm_sq, sharedThresholdResourceRaw_block_action_norm_sq τ A B hA hB hAA hBB] simp [div_eq_mul_inv, mul_comm] theorem doublyStochasticSchmidtMass_le_one {ι κ : Type*} [Fintype ι] [Fintype κ] (σ : ι → ℝ) (μ : κ → ℝ) (w : ι → κ → ℝ) (hσunit : (∑ i : ι, σ i ^ 2) = 1) (hμunit : (∑ j : κ, μ j ^ 2) = 1) (hw : ∀ i j, 0 ≤ w i j) (hrow : ∀ i, (∑ j : κ, w i j) = 1) (hcol : ∀ j, (∑ i : ι, w i j) = 1) : (∑ i : ι, ∑ j : κ, σ i * μ j * w i j) ≤ 1 := by classical let W : ι × κ → ℝ := fun q => w q.1 q.2 let f : ι × κ → ℝ := fun q => σ q.1 let g : ι × κ → ℝ := fun q => μ q.2 have hf : (∑ q : ι × κ, W q * f q ^ 2) = 1 := by dsimp [W, f] rw [Fintype.sum_prod_type] calc (∑ i : ι, ∑ j : κ, w i j * σ i ^ 2) = ∑ i : ι, σ i ^ 2 * (∑ j : κ, w i j) := by apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j _ ring_nf _ = ∑ i : ι, σ i ^ 2 := by simp_rw [hrow, mul_one] _ = 1 := hσunit have hg : (∑ q : ι × κ, W q * g q ^ 2) = 1 := by dsimp [W, g] rw [Fintype.sum_prod_type] calc (∑ i : ι, ∑ j : κ, w i j * μ j ^ 2) = ∑ j : κ, μ j ^ 2 * (∑ i : ι, w i j) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro j _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ ring _ = ∑ j : κ, μ j ^ 2 := by simp_rw [hcol, mul_one] _ = 1 := hμunit calc (∑ i : ι, ∑ j : κ, σ i * μ j * w i j) = ∑ q : ι × κ, W q * f q * g q := by rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ dsimp [W, f, g] ring _ ≤ Real.sqrt (∑ q : ι × κ, W q * f q ^ 2) * Real.sqrt (∑ q : ι × κ, W q * g q ^ 2) := by apply weighted_real_cauchy intro q exact hw q.1 q.2 _ = 1 := by rw [hf, hg]; norm_num theorem doublyStochasticSchmidtEnergy_eq {ι κ : Type*} [Fintype ι] [Fintype κ] (σ : ι → ℝ) (μ : κ → ℝ) (w : ι → κ → ℝ) (hσunit : (∑ i : ι, σ i ^ 2) = 1) (hμunit : (∑ j : κ, μ j ^ 2) = 1) (hrow : ∀ i, (∑ j : κ, w i j) = 1) (hcol : ∀ j, (∑ i : ι, w i j) = 1) : (∑ i : ι, ∑ j : κ, (σ i - μ j) ^ 2 * w i j) = 2 - 2 * (∑ i : ι, ∑ j : κ, σ i * μ j * w i j) := by classical have hfirst : (∑ i : ι, ∑ j : κ, σ i ^ 2 * w i j) = 1 := by calc (∑ i : ι, ∑ j : κ, σ i ^ 2 * w i j) = ∑ i : ι, σ i ^ 2 * (∑ j : κ, w i j) := by simp_rw [Finset.mul_sum] _ = ∑ i : ι, σ i ^ 2 := by simp_rw [hrow, mul_one] _ = 1 := hσunit have hsecond : (∑ i : ι, ∑ j : κ, μ j ^ 2 * w i j) = 1 := by calc (∑ i : ι, ∑ j : κ, μ j ^ 2 * w i j) = ∑ j : κ, μ j ^ 2 * (∑ i : ι, w i j) := by rw [Finset.sum_comm] simp_rw [Finset.mul_sum] _ = ∑ j : κ, μ j ^ 2 := by simp_rw [hcol, mul_one] _ = 1 := hμunit calc (∑ i : ι, ∑ j : κ, (σ i - μ j) ^ 2 * w i j) = (∑ i : ι, ∑ j : κ, σ i ^ 2 * w i j) - 2 * (∑ i : ι, ∑ j : κ, σ i * μ j * w i j) + (∑ i : ι, ∑ j : κ, μ j ^ 2 * w i j) := by simp_rw [sub_sq] simp only [sub_mul, add_mul, Finset.sum_add_distrib, Finset.sum_sub_distrib, Finset.mul_sum] ring_nf _ = 2 - 2 * (∑ i : ι, ∑ j : κ, σ i * μ j * w i j) := by rw [hfirst, hsecond] ring def weightedComplexOverlapVector {ι κ : Type*} [Fintype ι] [Fintype κ] (σ : ι → ℝ) (μ : κ → ℝ) (L : ι → κ → ℂ) : EuclideanSpace ℂ (ι × κ) := toLp 2 fun q : ι × κ => (Real.sqrt (σ q.1 * μ q.2) : ℂ) * L q.1 q.2 theorem weightedComplexOverlapVector_norm_sq {ι κ : Type*} [Fintype ι] [Fintype κ] (σ : ι → ℝ) (μ : κ → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hμ : ∀ j, 0 ≤ μ j) (L : ι → κ → ℂ) : ‖weightedComplexOverlapVector σ μ L‖ ^ 2 = ∑ i : ι, ∑ j : κ, σ i * μ j * ‖L i j‖ ^ 2 := by rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ change ‖(Real.sqrt (σ i * μ j) : ℂ) * L i j‖ ^ 2 = σ i * μ j * ‖L i j‖ ^ 2 rw [norm_mul, mul_pow, Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _), Real.sq_sqrt (mul_nonneg (hσ i) (hμ j))] theorem complexInner_norm_sq_le {ι : Type*} [Fintype ι] (z w : EuclideanSpace ℂ ι) : ‖inner ℂ z w‖ ^ 2 ≤ ‖z‖ ^ 2 * ‖w‖ ^ 2 := by have hcauchy := @norm_inner_le_norm ℂ _ _ _ _ z w nlinarith [norm_nonneg (inner ℂ z w), norm_nonneg z, norm_nonneg w, mul_nonneg (norm_nonneg z) (norm_nonneg w)] theorem twoSidedSchmidtSpectralEnergy_le {ι κ ν : Type*} [Fintype ι] [Fintype κ] [Fintype ν] (ψ φ : EuclideanSpace ℂ ν) (hψ : ‖ψ‖ = 1) (hφ : ‖φ‖ = 1) (σ : ι → ℝ) (μ : κ → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hμ : ∀ j, 0 ≤ μ j) (hσunit : (∑ i : ι, σ i ^ 2) = 1) (hμunit : (∑ j : κ, μ j ^ 2) = 1) (L R : ι → κ → ℂ) (hLrow : ∀ i, (∑ j : κ, ‖L i j‖ ^ 2) = 1) (hLcol : ∀ j, (∑ i : ι, ‖L i j‖ ^ 2) = 1) (hRrow : ∀ i, (∑ j : κ, ‖R i j‖ ^ 2) = 1) (hRcol : ∀ j, (∑ i : ι, ‖R i j‖ ^ 2) = 1) (hinner : inner ℂ ψ φ = inner ℂ (weightedComplexOverlapVector σ μ L) (weightedComplexOverlapVector σ μ R)) : (∑ i : ι, ∑ j : κ, (σ i - μ j) ^ 2 * ‖L i j‖ ^ 2) ≤ 2 * ‖ψ - φ‖ ^ 2 := by classical let a : ℝ := ∑ i : ι, ∑ j : κ, σ i * μ j * ‖L i j‖ ^ 2 let b : ℝ := ∑ i : ι, ∑ j : κ, σ i * μ j * ‖R i j‖ ^ 2 have ha : 0 ≤ a := by dsimp [a] apply Finset.sum_nonneg intro i _ apply Finset.sum_nonneg intro j _ exact mul_nonneg (mul_nonneg (hσ i) (hμ j)) (sq_nonneg _) have hb : b ≤ 1 := by exact doublyStochasticSchmidtMass_le_one σ μ (fun i j => ‖R i j‖ ^ 2) hσunit hμunit (fun i j => sq_nonneg _) hRrow hRcol have hinnerbound : ‖inner ℂ ψ φ‖ ^ 2 ≤ a := by calc ‖inner ℂ ψ φ‖ ^ 2 = ‖inner ℂ (weightedComplexOverlapVector σ μ L) (weightedComplexOverlapVector σ μ R)‖ ^ 2 := by rw [hinner] _ ≤ ‖weightedComplexOverlapVector σ μ L‖ ^ 2 * ‖weightedComplexOverlapVector σ μ R‖ ^ 2 := complexInner_norm_sq_le (weightedComplexOverlapVector σ μ L) (weightedComplexOverlapVector σ μ R) _ = a * b := by rw [weightedComplexOverlapVector_norm_sq σ μ hσ hμ L, weightedComplexOverlapVector_norm_sq σ μ hσ hμ R] _ ≤ a := by nlinarith have hre : (inner ℂ ψ φ).re ^ 2 ≤ a := by calc (inner ℂ ψ φ).re ^ 2 = (inner ℂ ψ φ).re * (inner ℂ ψ φ).re := by ring _ ≤ Complex.normSq (inner ℂ ψ φ) := Complex.re_sq_le_normSq (inner ℂ ψ φ) _ = ‖inner ℂ ψ φ‖ ^ 2 := Complex.normSq_eq_norm_sq (inner ℂ ψ φ) _ ≤ a := hinnerbound have hdistance : ‖ψ - φ‖ ^ 2 = 2 - 2 * (inner ℂ ψ φ).re := by rw [@norm_sub_sq ℂ, hψ, hφ] change 1 ^ 2 - 2 * (inner ℂ ψ φ).re + 1 ^ 2 = 2 - 2 * (inner ℂ ψ φ).re ring rw [doublyStochasticSchmidtEnergy_eq σ μ (fun i j => ‖L i j‖ ^ 2) hσunit hμunit hLrow hLcol, hdistance] change 2 - 2 * a ≤ 2 * (2 - 2 * (inner ℂ ψ φ).re) nlinarith [sq_nonneg ((inner ℂ ψ φ).re - 1)] def tensorEmbezzlementTarget {d n : ℕ} (ξ : BipartiteUnitVector d) : EuclideanSpace ℂ (Fin (d * n) × Fin (d * n)) := toLp 2 fun q : Fin (d * n) × Fin (d * n) => let a : Fin d × Fin n := finProdFinEquiv.symm q.1 let b : Fin d × Fin n := finProdFinEquiv.symm q.2 ξ.val (a.1, b.1) * embezzlementState n (a.2, b.2) theorem tensorEmbezzlementTarget_norm {d n : ℕ} (hn : 0 < n) (ξ : BipartiteUnitVector d) : ‖tensorEmbezzlementTarget (n := n) ξ‖ = 1 := by classical let e : ((Fin d × Fin d) × (Fin n × Fin n)) ≃ (Fin (d * n) × Fin (d * n)) := (Equiv.prodProdProdComm (Fin d) (Fin d) (Fin n) (Fin n)).trans (Equiv.prodCongr finProdFinEquiv finProdFinEquiv) have hpoint (p : (Fin d × Fin d) × (Fin n × Fin n)) : tensorEmbezzlementTarget (n := n) ξ (e p) = ξ.val p.1 * embezzlementState n p.2 := by rcases p with ⟨⟨a, b⟩, ⟨c, f⟩⟩ change ξ.val ((finProdFinEquiv.symm (finProdFinEquiv (a, c))).1, (finProdFinEquiv.symm (finProdFinEquiv (b, f))).1) * embezzlementState n ((finProdFinEquiv.symm (finProdFinEquiv (a, c))).2, (finProdFinEquiv.symm (finProdFinEquiv (b, f))).2) = ξ.val (a, b) * embezzlementState n (c, f) simp only [Equiv.symm_apply_apply] have hsum : (∑ q : Fin (d * n) × Fin (d * n), ‖tensorEmbezzlementTarget (n := n) ξ q‖ ^ 2) = ∑ p : (Fin d × Fin d) × (Fin n × Fin n), ‖ξ.val p.1 * embezzlementState n p.2‖ ^ 2 := by calc (∑ q : Fin (d * n) × Fin (d * n), ‖tensorEmbezzlementTarget (n := n) ξ q‖ ^ 2) = ∑ p : (Fin d × Fin d) × (Fin n × Fin n), ‖tensorEmbezzlementTarget (n := n) ξ (e p)‖ ^ 2 := (Equiv.sum_comp e (fun q : Fin (d * n) × Fin (d * n) => ‖tensorEmbezzlementTarget (n := n) ξ q‖ ^ 2)).symm _ = ∑ p : (Fin d × Fin d) × (Fin n × Fin n), ‖ξ.val p.1 * embezzlementState n p.2‖ ^ 2 := by apply Finset.sum_congr rfl intro p _ rw [hpoint p] have hfactor : (∑ p : (Fin d × Fin d) × (Fin n × Fin n), ‖ξ.val p.1 * embezzlementState n p.2‖ ^ 2) = (∑ a : Fin d × Fin d, ‖ξ.val a‖ ^ 2) * (∑ b : Fin n × Fin n, ‖embezzlementState n b‖ ^ 2) := by rw [Fintype.sum_prod_type] simp_rw [norm_mul, mul_pow] exact (Fintype.sum_mul_sum (fun a : Fin d × Fin d => ‖ξ.val a‖ ^ 2) (fun b : Fin n × Fin n => ‖embezzlementState n b‖ ^ 2)).symm have hsquare : ‖tensorEmbezzlementTarget (n := n) ξ‖ ^ 2 = 1 := by rw [EuclideanSpace.norm_sq_eq, hsum, hfactor, ← EuclideanSpace.norm_sq_eq, ← EuclideanSpace.norm_sq_eq, ξ.property, embezzlementState_norm n hn] norm_num nlinarith [norm_nonneg (tensorEmbezzlementTarget (n := n) ξ)] def localUnitaryAction {n : ℕ} (U V : Matrix.unitaryGroup (Fin n) ℂ) (ψ : EuclideanSpace ℂ (Fin n × Fin n)) : EuclideanSpace ℂ (Fin n × Fin n) := toLp 2 (((U : Matrix (Fin n) (Fin n) ℂ) ⊗ₖ (V : Matrix (Fin n) (Fin n) ℂ)).mulVec (ofLp ψ)) theorem localUnitaryAction_matrix_mem_unitary {n : ℕ} (U V : Matrix.unitaryGroup (Fin n) ℂ) : ((U : Matrix (Fin n) (Fin n) ℂ) ⊗ₖ (V : Matrix (Fin n) (Fin n) ℂ)) ∈ Matrix.unitaryGroup (Fin n × Fin n) ℂ := by exact Matrix.kronecker_mem_unitary U.property V.property theorem localUnitaryAction_norm {n : ℕ} (U V : Matrix.unitaryGroup (Fin n) ℂ) (ψ : EuclideanSpace ℂ (Fin n × Fin n)) : ‖localUnitaryAction U V ψ‖ = ‖ψ‖ := by let M : Matrix (Fin n × Fin n) (Fin n × Fin n) ℂ := (U : Matrix (Fin n) (Fin n) ℂ) ⊗ₖ (V : Matrix (Fin n) (Fin n) ℂ) have hM : M ∈ Matrix.unitaryGroup (Fin n × Fin n) ℂ := localUnitaryAction_matrix_mem_unitary U V have hclm : Matrix.toEuclideanCLM (n := Fin n × Fin n) (𝕜 := ℂ) M ∈ unitary (EuclideanSpace ℂ (Fin n × Fin n) →L[ℂ] EuclideanSpace ℂ (Fin n × Fin n)) := Unitary.map_mem (Matrix.toEuclideanCLM (n := Fin n × Fin n) (𝕜 := ℂ)) hM exact ContinuousLinearMap.norm_map_of_mem_unitary hclm ψ theorem unitary_row_norm_sq_sum {d : Type*} [Fintype d] [DecidableEq d] (U : Matrix.unitaryGroup d ℂ) (i : d) : (∑ j : d, ‖U i j‖ ^ 2) = 1 := by have hnorm (z : ℂ) : z.re * z.re + z.im * z.im = ‖z‖ ^ 2 := by rw [← Complex.normSq_eq_norm_sq, Complex.normSq_apply] have h := congrArg (fun M : Matrix d d ℂ => (M i i).re) U.property.2 simpa [Matrix.mul_apply, Matrix.star_eq_conjTranspose, Matrix.conjTranspose_apply, Complex.re_sum, Complex.mul_re, hnorm, Matrix.one_apply] using h theorem unitary_col_norm_sq_sum {d : Type*} [Fintype d] [DecidableEq d] (U : Matrix.unitaryGroup d ℂ) (j : d) : (∑ i : d, ‖U i j‖ ^ 2) = 1 := by have hnorm (z : ℂ) : z.re * z.re + z.im * z.im = ‖z‖ ^ 2 := by rw [← Complex.normSq_eq_norm_sq, Complex.normSq_apply] have h := congrArg (fun M : Matrix d d ℂ => (M j j).re) U.property.1 simpa [Matrix.mul_apply, Matrix.star_eq_conjTranspose, Matrix.conjTranspose_apply, Complex.re_sum, Complex.mul_re, hnorm, Matrix.one_apply] using h def unitaryBasisOverlap {d : Type*} [Fintype d] [DecidableEq d] (U V : Matrix.unitaryGroup d ℂ) : Matrix.unitaryGroup d ℂ := U⁻¹ * V def diagonalSchmidtState {d : Type*} [Fintype d] [DecidableEq d] (σ : d → ℝ) : EuclideanSpace ℂ (d × d) := toLp 2 fun q : d × d => if q.1 = q.2 then (σ q.1 : ℂ) else 0 theorem diagonalSchmidtState_norm_sq {d : Type*} [Fintype d] [DecidableEq d] (σ : d → ℝ) : ‖diagonalSchmidtState σ‖ ^ 2 = ∑ i : d, σ i ^ 2 := by rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro i _ change (∑ j : d, ‖if i = j then (σ i : ℂ) else 0‖ ^ 2) = σ i ^ 2 have hterm (j : d) : ‖if i = j then (σ i : ℂ) else 0‖ ^ 2 = if i = j then σ i ^ 2 else 0 := by split_ifs <;> simp [Complex.norm_real, Real.norm_eq_abs, sq_abs] simp_rw [hterm] simp def schmidtVector {d : ℕ} (σ : Fin d → ℝ) (U V : Matrix.unitaryGroup (Fin d) ℂ) : EuclideanSpace ℂ (Fin d × Fin d) := localUnitaryAction U V (diagonalSchmidtState σ) theorem schmidtVector_norm_sq {d : ℕ} (σ : Fin d → ℝ) (U V : Matrix.unitaryGroup (Fin d) ℂ) : ‖schmidtVector σ U V‖ ^ 2 = ∑ i : Fin d, σ i ^ 2 := by rw [schmidtVector, localUnitaryAction_norm, diagonalSchmidtState_norm_sq] theorem schmidtVector_apply {d : ℕ} (σ : Fin d → ℝ) (U V : Matrix.unitaryGroup (Fin d) ℂ) (a b : Fin d) : schmidtVector σ U V (a, b) = ∑ i : Fin d, (σ i : ℂ) * U a i * V b i := by classical simp [schmidtVector, localUnitaryAction, Matrix.mulVec, dotProduct, Matrix.kroneckerMap_apply, diagonalSchmidtState, Fintype.sum_prod_type, mul_assoc, mul_comm] theorem weightedComplexOverlapVector_inner {ι κ : Type*} [Fintype ι] [Fintype κ] (σ : ι → ℝ) (μ : κ → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hμ : ∀ j, 0 ≤ μ j) (L R : ι → κ → ℂ) : inner ℂ (weightedComplexOverlapVector σ μ (fun i j => star (L i j))) (weightedComplexOverlapVector σ μ R) = ∑ i : ι, ∑ j : κ, (σ i : ℂ) * (μ j : ℂ) * L i j * R i j := by classical rw [EuclideanSpace.inner_eq_star_dotProduct] change (∑ q : ι × κ, ((Real.sqrt (σ q.1 * μ q.2) : ℂ) * R q.1 q.2) * star ((Real.sqrt (σ q.1 * μ q.2) : ℂ) * star (L q.1 q.2))) = _ rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ have hsqrt : (Real.sqrt (σ i * μ j) : ℂ) * (Real.sqrt (σ i * μ j) : ℂ) = (σ i : ℂ) * (μ j : ℂ) := by norm_cast exact Real.mul_self_sqrt (mul_nonneg (hσ i) (hμ j)) calc ((Real.sqrt (σ i * μ j) : ℂ) * R i j) * star ((Real.sqrt (σ i * μ j) : ℂ) * star (L i j)) = ((Real.sqrt (σ i * μ j) : ℂ) * R i j) * ((Real.sqrt (σ i * μ j) : ℂ) * L i j) := by simp _ = ((Real.sqrt (σ i * μ j) : ℂ) * (Real.sqrt (σ i * μ j) : ℂ)) * L i j * R i j := by ring _ = (σ i : ℂ) * (μ j : ℂ) * L i j * R i j := by rw [hsqrt] theorem matrixVectorization_inner {d e : Type*} [Fintype d] [Fintype e] (X Y : Matrix d e ℂ) : inner ℂ (toLp 2 (Matrix.vec X)) (toLp 2 (Matrix.vec Y)) = Matrix.trace (X.conjTranspose * Y) := by rw [EuclideanSpace.inner_eq_star_dotProduct] change Matrix.vec Y ⬝ᵥ star (Matrix.vec X) = Matrix.trace (X.conjTranspose * Y) rw [dotProduct_comm, Matrix.star_vec_dotProduct_vec] theorem diagonalSchmidtState_eq_vec {d : Type*} [Fintype d] [DecidableEq d] (σ : d → ℝ) : diagonalSchmidtState σ = toLp 2 (Matrix.vec (Matrix.diagonal fun i => (σ i : ℂ))) := by ext ⟨i, j⟩ by_cases h : i = j · subst j simp [diagonalSchmidtState, Matrix.vec] · simp [diagonalSchmidtState, Matrix.vec, h, Ne.symm h] theorem schmidtVector_eq_vec {d : ℕ} (σ : Fin d → ℝ) (U V : Matrix.unitaryGroup (Fin d) ℂ) : schmidtVector σ U V = toLp 2 (Matrix.vec ((V : Matrix (Fin d) (Fin d) ℂ) * Matrix.diagonal (fun i => (σ i : ℂ)) * (U : Matrix (Fin d) (Fin d) ℂ).transpose)) := by rw [schmidtVector, localUnitaryAction, diagonalSchmidtState_eq_vec] apply WithLp.ofLp_injective exact Matrix.kronecker_mulVec_vec (V : Matrix (Fin d) (Fin d) ℂ) (Matrix.diagonal (fun i => (σ i : ℂ))) (U : Matrix (Fin d) (Fin d) ℂ) theorem weightedSchmidtMatrixTrace {d : Type*} [Fintype d] [DecidableEq d] (σ μ : d → ℝ) (L R : Matrix d d ℂ) : Matrix.trace (L.transpose * Matrix.diagonal (fun i => (σ i : ℂ)) * R * Matrix.diagonal (fun j => (μ j : ℂ))) = ∑ i : d, ∑ j : d, (σ i : ℂ) * (μ j : ℂ) * L i j * R i j := by classical simp [Matrix.trace, Matrix.mul_apply, Matrix.diagonal_apply, Matrix.transpose_apply, mul_assoc, mul_left_comm, mul_comm] rw [Finset.sum_comm] theorem schmidtVector_inner {d : ℕ} (σ μ : Fin d → ℝ) (U V X Y : Matrix.unitaryGroup (Fin d) ℂ) : inner ℂ (schmidtVector σ U V) (schmidtVector μ X Y) = ∑ i : Fin d, ∑ j : Fin d, (σ i : ℂ) * (μ j : ℂ) * (((U : Matrix (Fin d) (Fin d) ℂ).conjTranspose * (X : Matrix (Fin d) (Fin d) ℂ)) i j) * (((V : Matrix (Fin d) (Fin d) ℂ).conjTranspose * (Y : Matrix (Fin d) (Fin d) ℂ)) i j) := by classical rw [schmidtVector_eq_vec σ U V, schmidtVector_eq_vec μ X Y, matrixVectorization_inner] let S : Matrix (Fin d) (Fin d) ℂ := Matrix.diagonal fun i => (σ i : ℂ) let T : Matrix (Fin d) (Fin d) ℂ := Matrix.diagonal fun i => (μ i : ℂ) let A : Matrix (Fin d) (Fin d) ℂ := U let B : Matrix (Fin d) (Fin d) ℂ := V let C : Matrix (Fin d) (Fin d) ℂ := X let D : Matrix (Fin d) (Fin d) ℂ := Y change Matrix.trace ((B * S * A.transpose).conjTranspose * (D * T * C.transpose)) = _ calc Matrix.trace ((B * S * A.transpose).conjTranspose * (D * T * C.transpose)) = Matrix.trace (((B * S * A.transpose).conjTranspose * (D * T)) * C.transpose) := by congr 1 simp [Matrix.mul_assoc] _ = Matrix.trace (C.transpose * ((B * S * A.transpose).conjTranspose * (D * T))) := Matrix.trace_mul_comm _ _ _ = Matrix.trace ((A.conjTranspose * C).transpose * S * (B.conjTranspose * D) * T) := by congr 1 simp [Matrix.conjTranspose_mul, Matrix.transpose_mul, Matrix.transpose_conjTranspose, Matrix.conjTranspose_transpose, Matrix.diagonal_conjTranspose, S, Pi.star_def, Matrix.mul_assoc] _ = _ := weightedSchmidtMatrixTrace σ μ (A.conjTranspose * C) (B.conjTranspose * D) @[simp] theorem unitaryBasisOverlap_apply {d : Type*} [Fintype d] [DecidableEq d] (U V : Matrix.unitaryGroup d ℂ) (i j : d) : unitaryBasisOverlap U V i j = (((U : Matrix d d ℂ).conjTranspose * (V : Matrix d d ℂ)) i j) := by rfl theorem schmidtVector_spectralEnergy_le {d : ℕ} (σ μ : Fin d → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hμ : ∀ j, 0 ≤ μ j) (hσunit : (∑ i : Fin d, σ i ^ 2) = 1) (hμunit : (∑ j : Fin d, μ j ^ 2) = 1) (U V X Y : Matrix.unitaryGroup (Fin d) ℂ) : (∑ i : Fin d, ∑ j : Fin d, (σ i - μ j) ^ 2 * ‖unitaryBasisOverlap U X i j‖ ^ 2) ≤ 2 * ‖schmidtVector σ U V - schmidtVector μ X Y‖ ^ 2 := by have hψ : ‖schmidtVector σ U V‖ = 1 := by have h := schmidtVector_norm_sq σ U V rw [hσunit] at h nlinarith [norm_nonneg (schmidtVector σ U V)] have hφ : ‖schmidtVector μ X Y‖ = 1 := by have h := schmidtVector_norm_sq μ X Y rw [hμunit] at h nlinarith [norm_nonneg (schmidtVector μ X Y)] let L : Fin d → Fin d → ℂ := fun i j => star (unitaryBasisOverlap U X i j) let R : Fin d → Fin d → ℂ := fun i j => unitaryBasisOverlap V Y i j have hLrow : ∀ i, (∑ j : Fin d, ‖L i j‖ ^ 2) = 1 := by intro i simpa [L] using unitary_row_norm_sq_sum (unitaryBasisOverlap U X) i have hLcol : ∀ j, (∑ i : Fin d, ‖L i j‖ ^ 2) = 1 := by intro j simpa [L] using unitary_col_norm_sq_sum (unitaryBasisOverlap U X) j have hRrow : ∀ i, (∑ j : Fin d, ‖R i j‖ ^ 2) = 1 := by intro i exact unitary_row_norm_sq_sum (unitaryBasisOverlap V Y) i have hRcol : ∀ j, (∑ i : Fin d, ‖R i j‖ ^ 2) = 1 := by intro j exact unitary_col_norm_sq_sum (unitaryBasisOverlap V Y) j have hinner : inner ℂ (schmidtVector σ U V) (schmidtVector μ X Y) = inner ℂ (weightedComplexOverlapVector σ μ L) (weightedComplexOverlapVector σ μ R) := by rw [weightedComplexOverlapVector_inner σ μ hσ hμ (fun i j => unitaryBasisOverlap U X i j) (fun i j => unitaryBasisOverlap V Y i j)] simpa [unitaryBasisOverlap_apply] using schmidtVector_inner σ μ U V X Y simpa [L] using twoSidedSchmidtSpectralEnergy_le (schmidtVector σ U V) (schmidtVector μ X Y) hψ hφ σ μ hσ hμ hσunit hμunit L R hLrow hLcol hRrow hRcol hinner end noncomputable section open scoped ComplexOrder Matrix BigOperators InnerProductSpace open Complex Matrix Finset theorem linearMap_exists_singularBases {d : ℕ} (T : EuclideanSpace ℂ (Fin d) →ₗ[ℂ] EuclideanSpace ℂ (Fin d)) : ∃ (σ : Fin d → ℝ) (u v : OrthonormalBasis (Fin d) ℂ (EuclideanSpace ℂ (Fin d))), (∀ i, 0 ≤ σ i) ∧ (∀ i, T (v i) = (σ i : ℂ) • u i) := by classical let hT := T.isPositive_adjoint_comp_self let v : OrthonormalBasis (Fin d) ℂ (EuclideanSpace ℂ (Fin d)) := hT.isSymmetric.eigenvectorBasis finrank_euclideanSpace_fin let σ : Fin d → ℝ := fun i => Real.sqrt (hT.isSymmetric.eigenvalues finrank_euclideanSpace_fin i) have hσ (i : Fin d) : 0 ≤ σ i := Real.sqrt_nonneg _ have hσsq (i : Fin d) : σ i ^ 2 = hT.isSymmetric.eigenvalues finrank_euclideanSpace_fin i := by exact Real.sq_sqrt (hT.nonneg_eigenvalues finrank_euclideanSpace_fin i) have heigen (i : Fin d) : (T.adjoint ∘ₗ T) (v i) = ((σ i ^ 2 : ℝ) : ℂ) • v i := by rw [hσsq] exact hT.isSymmetric.apply_eigenvectorBasis finrank_euclideanSpace_fin i let s : Set (Fin d) := {i | σ i ≠ 0} let f : Fin d → EuclideanSpace ℂ (Fin d) := fun i => ((σ i : ℂ)⁻¹) • T (v i) have hGram (i j : Fin d) : inner ℂ (T (v i)) (T (v j)) = ((σ j ^ 2 : ℝ) : ℂ) * inner ℂ (v i) (v j) := by calc inner ℂ (T (v i)) (T (v j)) = inner ℂ (v i) (T.adjoint (T (v j))) := (T.adjoint_inner_right (v i) (T (v j))).symm _ = inner ℂ (v i) (((σ j ^ 2 : ℝ) : ℂ) • v j) := by rw [← heigen j] rfl _ = ((σ j ^ 2 : ℝ) : ℂ) * inner ℂ (v i) (v j) := by rw [inner_smul_right] have hf : Orthonormal ℂ (s.restrict f) := by rw [orthonormal_iff_ite] intro i j have hi : (σ (i : Fin d) : ℂ) ≠ 0 := by exact_mod_cast i.property have hj : (σ (j : Fin d) : ℂ) ≠ 0 := by exact_mod_cast j.property change inner ℂ (((σ (i : Fin d) : ℂ)⁻¹) • T (v i)) (((σ (j : Fin d) : ℂ)⁻¹) • T (v j)) = _ rw [inner_smul_left, inner_smul_right, hGram, v.inner_eq_ite] by_cases hij : i = j · subst j simp only [ite_true, mul_one] have hs : starRingEnd ℂ ((σ (i : Fin d) : ℂ)⁻¹) = ((σ (i : Fin d) : ℂ)⁻¹) := by simp rw [hs] push_cast field_simp · have hval : (i : Fin d) ≠ (j : Fin d) := by intro h exact hij (Subtype.ext h) simp [hij, hval] obtain ⟨u, hu⟩ := Orthonormal.exists_orthonormalBasis_extension_of_card_eq (by rw [Fintype.card_fin] exact finrank_euclideanSpace_fin) hf refine ⟨σ, u, v, hσ, ?_⟩ intro i by_cases hi : σ i = 0 · have hker : (T.adjoint ∘ₗ T) (v i) = 0 := by rw [heigen i, hi] simp have hTv : T (v i) = 0 := by apply LinearMap.mem_ker.mp rw [← T.ker_adjoint_comp_self] exact LinearMap.mem_ker.mpr hker simp [hi, hTv] · have hui : u i = f i := hu i hi rw [hui] change T (v i) = (σ i : ℂ) • (((σ i : ℂ)⁻¹) • T (v i)) rw [smul_smul, mul_inv_cancel₀] · simp · exact_mod_cast hi end open scoped ComplexOrder Matrix BigOperators InnerProductSpace open Complex Matrix Finset noncomputable section def orthonormalBasisUnitary {d : ℕ} (b : OrthonormalBasis (Fin d) ℂ (EuclideanSpace ℂ (Fin d))) : Matrix.unitaryGroup (Fin d) ℂ := ⟨(EuclideanSpace.basisFun (Fin d) ℂ).toBasis.toMatrix b.toBasis, (EuclideanSpace.basisFun (Fin d) ℂ).toMatrix_orthonormalBasis_mem_unitary b⟩ @[simp] theorem orthonormalBasisUnitary_apply {d : ℕ} (b : OrthonormalBasis (Fin d) ℂ (EuclideanSpace ℂ (Fin d))) (i j : Fin d) : orthonormalBasisUnitary b i j = b j i := by rfl def conjugateUnitary {d : ℕ} (U : Matrix.unitaryGroup (Fin d) ℂ) : Matrix.unitaryGroup (Fin d) ℂ := by refine ⟨(U.val.conjTranspose).transpose, ?_⟩ rw [Matrix.mem_unitaryGroup_iff'] change ((U.val.conjTranspose).transpose).conjTranspose * (U.val.conjTranspose).transpose = 1 have htranspose : ((U.val.conjTranspose).transpose).conjTranspose = U.val.transpose := by ext i j simp [Matrix.conjTranspose_apply, Matrix.transpose_apply] rw [htranspose] have h := congrArg Matrix.transpose U.property.1 simpa [Matrix.star_eq_conjTranspose, Matrix.transpose_mul] using h @[simp] theorem conjugateUnitary_apply {d : ℕ} (U : Matrix.unitaryGroup (Fin d) ℂ) (i j : Fin d) : conjugateUnitary U i j = star (U i j) := by rfl theorem exists_proofSchmidtDecomposition {d : ℕ} (ξ : EuclideanSpace ℂ (Fin d × Fin d)) : ∃ (σ : Fin d → ℝ) (U V : Matrix.unitaryGroup (Fin d) ℂ), (∀ i, 0 ≤ σ i) ∧ ξ = schmidtVector σ U V := by classical let C : Matrix (Fin d) (Fin d) ℂ := fun b a => ξ (a, b) let T : EuclideanSpace ℂ (Fin d) →ₗ[ℂ] EuclideanSpace ℂ (Fin d) := Matrix.toEuclideanLin C obtain ⟨σ, u, v, hσ, hsing⟩ := linearMap_exists_singularBases T refine ⟨σ, conjugateUnitary (orthonormalBasisUnitary v), orthonormalBasisUnitary u, hσ, ?_⟩ ext ⟨a, b⟩ rw [schmidtVector_apply] have hrepr : T ((EuclideanSpace.basisFun (Fin d) ℂ) a) = ∑ i : Fin d, inner ℂ (v i) ((EuclideanSpace.basisFun (Fin d) ℂ) a) • T (v i) := by calc T ((EuclideanSpace.basisFun (Fin d) ℂ) a) = T (∑ i : Fin d, inner ℂ (v i) ((EuclideanSpace.basisFun (Fin d) ℂ) a) • v i) := by rw [v.sum_repr'] _ = _ := by simp have hcoord := congrArg (fun z : EuclideanSpace ℂ (Fin d) => z b) hrepr simpa [T, C, Matrix.toLpLin_apply, EuclideanSpace.basisFun_apply, Matrix.mulVec_single_one, Matrix.col_apply, EuclideanSpace.inner_single_right, conjugateUnitary_apply, orthonormalBasisUnitary_apply, hsing, mul_assoc, mul_left_comm, mul_comm] using hcoord theorem exists_proofUnitSchmidtDecomposition {d : ℕ} (ξ : BipartiteUnitVector d) : ∃ (σ : Fin d → ℝ) (U V : Matrix.unitaryGroup (Fin d) ℂ), (∀ i, 0 ≤ σ i) ∧ (∑ i : Fin d, σ i ^ 2) = 1 ∧ ξ.val = schmidtVector σ U V := by obtain ⟨σ, U, V, hσ, hξ⟩ := exists_proofSchmidtDecomposition ξ.val refine ⟨σ, U, V, hσ, ?_, hξ⟩ have hnorm : ‖schmidtVector σ U V‖ ^ 2 = 1 := by rw [← hξ, ξ.property] norm_num exact (schmidtVector_norm_sq σ U V).symm.trans hnorm end noncomputable section open scoped BigOperators theorem harmonicNumber_eq_harmonic (n : ℕ) : harmonicNumber n = (harmonic n : ℝ) := by unfold harmonicNumber harmonic rw [Finset.sum_fin_eq_sum_range] simp only [Rat.cast_sum, Rat.cast_inv, Nat.cast_add, Nat.cast_one] apply Finset.sum_congr rfl intro i hi simp [Finset.mem_range.mp hi] theorem harmonicNumber_log_lower (n : ℕ) : Real.log ((n : ℝ) + 1) ≤ harmonicNumber n := by rw [harmonicNumber_eq_harmonic] simpa [Nat.cast_add, Nat.cast_one] using log_add_one_le_harmonic n theorem harmonicNumber_log_upper (n : ℕ) : harmonicNumber n ≤ 1 + Real.log (n : ℝ) := by rw [harmonicNumber_eq_harmonic] exact harmonic_le_one_add_log n theorem harmonicNumber_pos {n : ℕ} (hn : 0 < n) : 0 < harmonicNumber n := by have hnreal : 0 < (n : ℝ) := by exact_mod_cast hn exact (Real.log_pos (by linarith : (1 : ℝ) < (n : ℝ) + 1)).trans_le (harmonicNumber_log_lower n) theorem harmonicNumber_mul_le_add {d n : ℕ} (hd : 0 < d) (hn : 0 < n) : harmonicNumber (d * n) ≤ harmonicNumber n + (1 + Real.log (d : ℝ)) := by have hdreal : 0 < (d : ℝ) := by exact_mod_cast hd have hnreal : 0 < (n : ℝ) := by exact_mod_cast hn have hlogn : Real.log (n : ℝ) ≤ harmonicNumber n := by exact (Real.log_le_log hnreal (by linarith : (n : ℝ) ≤ (n : ℝ) + 1)).trans (harmonicNumber_log_lower n) calc harmonicNumber (d * n) ≤ 1 + Real.log ((d * n : ℕ) : ℝ) := harmonicNumber_log_upper (d * n) _ = 1 + (Real.log (d : ℝ) + Real.log (n : ℝ)) := by rw [Nat.cast_mul, Real.log_mul hdreal.ne' hnreal.ne'] _ ≤ harmonicNumber n + (1 + Real.log (d : ℝ)) := by linarith theorem exists_proofHarmonicNumber_gt (bound : ℝ) : ∃ n : ℕ, bound < harmonicNumber n := by obtain ⟨n, hn⟩ := exists_nat_gt (Real.exp bound) have hpositive : 0 < (n : ℝ) + 1 := by positivity have hlog : bound < Real.log ((n : ℝ) + 1) := by apply (Real.lt_log_iff_exp_lt hpositive).mpr exact lt_trans hn (by linarith) exact ⟨n, hlog.trans_le (harmonicNumber_log_lower n)⟩ theorem exists_proofHarmonicNumber_ratio_ge (d : ℕ) (hd : 0 < d) {ε : ℝ} (hε : 0 < ε) (hεone : ε ≤ 1) : ∃ n : ℕ, 0 < n ∧ 1 - ε ≤ harmonicNumber n / harmonicNumber (d * n) := by let C : ℝ := 1 + Real.log (d : ℝ) have hdreal : 0 < (d : ℝ) := by exact_mod_cast hd have hlogd : 0 ≤ Real.log (d : ℝ) := by apply Real.log_nonneg exact_mod_cast hd have hC : 0 < C := by dsimp [C] linarith obtain ⟨n, hnlarge⟩ := exists_proofHarmonicNumber_gt (C / ε) have hn : 0 < n := by have hzero : harmonicNumber 0 = 0 := by rw [harmonicNumber_eq_harmonic] simp by_contra hnot have hnzero : n = 0 := by omega rw [hnzero, hzero] at hnlarge have hpositive : 0 < C / ε := div_pos hC hε linarith have hden : 0 < harmonicNumber (d * n) := harmonicNumber_pos (Nat.mul_pos hd hn) have hupper := harmonicNumber_mul_le_add hd hn have hbudget : C < ε * harmonicNumber n := by have h := (div_lt_iff₀ hε).mp hnlarge nlinarith refine ⟨n, hn, (le_div_iff₀ hden).mpr ?_⟩ have hscaled := mul_le_mul_of_nonneg_left hupper (sub_nonneg.mpr hεone) have hproduct : 0 ≤ ε * C := mul_nonneg hε.le hC.le change (1 - ε) * harmonicNumber (d * n) ≤ harmonicNumber n change harmonicNumber (d * n) ≤ harmonicNumber n + C at hupper change (1 - ε) * harmonicNumber (d * n) ≤ (1 - ε) * (harmonicNumber n + C) at hscaled nlinarith end noncomputable section open WithLp open scoped BigOperators Kronecker def ePRState (m : ℕ) : EuclideanSpace ℂ (Fin m × Fin m) := toLp 2 fun q : Fin m × Fin m => if q.1 = q.2 then (↑((Real.sqrt (m : ℝ))⁻¹) : ℂ) else 0 theorem ePRState_norm (m : ℕ) (hm : 0 < m) : ‖ePRState m‖ = 1 := by have hmreal : 0 < (m : ℝ) := by exact_mod_cast hm have hamp : ‖(↑((Real.sqrt (m : ℝ))⁻¹) : ℂ)‖ ^ 2 = (m : ℝ)⁻¹ := by rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr (Real.sqrt_nonneg _)), inv_pow, Real.sq_sqrt hmreal.le] have hsquare : ‖ePRState m‖ ^ 2 = 1 := by rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] have hterm (i j : Fin m) : ‖if i = j then (↑((Real.sqrt (m : ℝ))⁻¹) : ℂ) else 0‖ ^ 2 = if i = j then (m : ℝ)⁻¹ else 0 := by split_ifs with h · exact hamp · simp change (∑ i : Fin m, ∑ j : Fin m, ‖if i = j then (↑((Real.sqrt (m : ℝ))⁻¹) : ℂ) else 0‖ ^ 2) = 1 simp_rw [hterm] simp [hmreal.ne'] nlinarith [norm_nonneg (ePRState m)] theorem permutationMatrix_mem_unitary {ι : Type*} [Fintype ι] [DecidableEq ι] (σ : Equiv.Perm ι) : σ.permMatrix ℂ ∈ Matrix.unitaryGroup ι ℂ := by rw [Matrix.mem_unitaryGroup_iff, Matrix.star_eq_conjTranspose, Matrix.conjTranspose_permMatrix, ← Matrix.permMatrix_mul] simp def permutationUnitary {ι : Type*} [Fintype ι] [DecidableEq ι] (σ : Equiv.Perm ι) : Matrix.unitaryGroup ι ℂ := ⟨σ.permMatrix ℂ, permutationMatrix_mem_unitary σ⟩ @[simp] theorem permutationUnitary_val {ι : Type*} [Fintype ι] [DecidableEq ι] (σ : Equiv.Perm ι) : (permutationUnitary σ : Matrix ι ι ℂ) = σ.permMatrix ℂ := rfl theorem localPermutationUnitaryAction_apply {n : ℕ} (σ : Equiv.Perm (Fin n)) (ψ : EuclideanSpace ℂ (Fin n × Fin n)) (i j : Fin n) : localUnitaryAction (permutationUnitary σ) (permutationUnitary σ) ψ (i, j) = ψ (σ i, σ j) := by let X : Matrix (Fin n) (Fin n) ℂ := fun a b => ψ (b, a) have hx : ofLp ψ = Matrix.vec X := by funext q rcases q with ⟨a, b⟩ rfl change (((σ.permMatrix ℂ) ⊗ₖ (σ.permMatrix ℂ)).mulVec (ofLp ψ)) (i, j) = ψ (σ i, σ j) rw [hx, Matrix.kronecker_mulVec_vec] change ((σ.permMatrix ℂ) * X * (σ.permMatrix ℂ).transpose) j i = ψ (σ i, σ j) rw [Matrix.transpose_permMatrix, PEquiv.toMatrix_toPEquiv_mul, PEquiv.mul_toMatrix_toPEquiv] rfl theorem diagonalInner_real_eq_sum {N : ℕ} (z w : EuclideanSpace ℂ (Fin N × Fin N)) (hz : ∀ i j : Fin N, i ≠ j → z (i, j) = 0) : (inner ℂ z w).re = ∑ i : Fin N, (inner ℂ (z (i, i)) (w (i, i))).re := by rw [PiLp.inner_apply, Complex.re_sum, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro i _ apply Finset.sum_eq_single i · intro j _ hji rw [hz i j (Ne.symm hji)] simp · simp end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem harmonicSchmidtFiber_count_sq_le {n : ℕ} (a x : ℝ) (ha : 0 ≤ a) (hx : 0 ≤ x) : (((Finset.univ.filter fun j : Fin n => x ≤ a * (Real.sqrt ((j.val : ℝ) + 1))⁻¹).card : ℕ) : ℝ) * x ^ 2 ≤ a ^ 2 := by classical let S : Finset (Fin n) := Finset.univ.filter fun j : Fin n => x ≤ a * (Real.sqrt ((j.val : ℝ) + 1))⁻¹ change (S.card : ℝ) * x ^ 2 ≤ a ^ 2 by_cases hs : S.Nonempty · let j : Fin n := S.max' hs have hjmem : j ∈ S := S.max'_mem hs have hjthreshold : x ≤ a * (Real.sqrt ((j.val : ℝ) + 1))⁻¹ := (Finset.mem_filter.mp hjmem).2 have hcard : S.card ≤ j.val + 1 := by calc S.card ≤ (Finset.Iic j).card := by apply Finset.card_le_card intro k hk exact Finset.mem_Iic.mpr (S.le_max' k hk) _ = j.val + 1 := by simp have hjpositive : 0 < (j.val : ℝ) + 1 := by positivity have hsqrtpositive : 0 < Real.sqrt ((j.val : ℝ) + 1) := Real.sqrt_pos.2 hjpositive have hscaled : x * Real.sqrt ((j.val : ℝ) + 1) ≤ a := by apply (le_div_iff₀ hsqrtpositive).mp simpa [div_eq_mul_inv] using hjthreshold have hsquares : ((j.val : ℝ) + 1) * x ^ 2 ≤ a ^ 2 := by have hnonneg : 0 ≤ x * Real.sqrt ((j.val : ℝ) + 1) := mul_nonneg hx (Real.sqrt_nonneg _) have hs : (x * Real.sqrt ((j.val : ℝ) + 1)) ^ 2 ≤ a ^ 2 := by nlinarith [mul_nonneg (sub_nonneg.mpr hscaled) (add_nonneg ha hnonneg)] rw [mul_pow, Real.sq_sqrt hjpositive.le] at hs nlinarith have hcardreal : (S.card : ℝ) ≤ (j.val : ℝ) + 1 := by exact_mod_cast hcard exact (mul_le_mul_of_nonneg_right hcardreal (sq_nonneg x)).trans hsquares · have hempty : S = ∅ := Finset.not_nonempty_iff_eq_empty.mp hs rw [hempty] simp [sq_nonneg a] def harmonicTensorSchmidtAmplitude {d n : ℕ} (σ : Fin d → ℝ) (q : Fin (d * n)) : ℝ := let p : Fin d × Fin n := finProdFinEquiv.symm q σ p.1 * (Real.sqrt ((p.2.val : ℝ) + 1))⁻¹ def descendingHarmonicSchmidtPermutation {d n : ℕ} (σ : Fin d → ℝ) : Equiv.Perm (Fin (d * n)) := Tuple.sort (fun q : Fin (d * n) => -harmonicTensorSchmidtAmplitude (n := n) σ q) theorem descendingHarmonicSchmidtPermutation_antitone {d n : ℕ} (σ : Fin d → ℝ) : Antitone (fun q : Fin (d * n) => harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ q)) := by intro i j hij have h := Tuple.monotone_sort (fun q : Fin (d * n) => -harmonicTensorSchmidtAmplitude (n := n) σ q) hij exact neg_le_neg_iff.mp h theorem harmonicSchmidtThreshold_card_eq {d n : ℕ} (σ : Fin d → ℝ) (x : ℝ) : (((Finset.univ.filter fun q : Fin (d * n) => x ≤ harmonicTensorSchmidtAmplitude (n := n) σ q).card : ℕ) : ℝ) = ∑ i : Fin d, (((Finset.univ.filter fun j : Fin n => x ≤ σ i * (Real.sqrt ((j.val : ℝ) + 1))⁻¹).card : ℕ) : ℝ) := by classical calc (((Finset.univ.filter fun q : Fin (d * n) => x ≤ harmonicTensorSchmidtAmplitude (n := n) σ q).card : ℕ) : ℝ) = ∑ q : Fin (d * n), if x ≤ harmonicTensorSchmidtAmplitude (n := n) σ q then (1 : ℝ) else 0 := by simp _ = ∑ p : Fin d × Fin n, if x ≤ harmonicTensorSchmidtAmplitude (n := n) σ (finProdFinEquiv p) then (1 : ℝ) else 0 := by exact (Equiv.sum_comp finProdFinEquiv (fun q : Fin (d * n) => if x ≤ harmonicTensorSchmidtAmplitude (n := n) σ q then (1 : ℝ) else 0)).symm _ = ∑ i : Fin d, (((Finset.univ.filter fun j : Fin n => x ≤ σ i * (Real.sqrt ((j.val : ℝ) + 1))⁻¹).card : ℕ) : ℝ) := by rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro i _ simp [harmonicTensorSchmidtAmplitude] theorem harmonicSchmidtThreshold_count_sq_le_one {d n : ℕ} (σ : Fin d → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (x : ℝ) (hx : 0 ≤ x) : (((Finset.univ.filter fun q : Fin (d * n) => x ≤ harmonicTensorSchmidtAmplitude (n := n) σ q).card : ℕ) : ℝ) * x ^ 2 ≤ 1 := by rw [harmonicSchmidtThreshold_card_eq] calc (∑ i : Fin d, (((Finset.univ.filter fun j : Fin n => x ≤ σ i * (Real.sqrt ((j.val : ℝ) + 1))⁻¹).card : ℕ) : ℝ)) * x ^ 2 = ∑ i : Fin d, (((Finset.univ.filter fun j : Fin n => x ≤ σ i * (Real.sqrt ((j.val : ℝ) + 1))⁻¹).card : ℕ) : ℝ) * x ^ 2 := by rw [Finset.sum_mul] _ ≤ ∑ i : Fin d, σ i ^ 2 := by apply Finset.sum_le_sum intro i _ exact harmonicSchmidtFiber_count_sq_le (σ i) x (hσ i) hx _ = 1 := hunit theorem descendingHarmonicSchmidtAmplitude_rank_sq_le_one {d n : ℕ} (σ : Fin d → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (k : Fin (d * n)) : (((k.val : ℝ) + 1) * harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) ^ 2) ≤ 1 := by classical let π := descendingHarmonicSchmidtPermutation (n := n) σ let x := harmonicTensorSchmidtAmplitude (n := n) σ (π k) let S : Finset (Fin (d * n)) := Finset.univ.filter fun q : Fin (d * n) => x ≤ harmonicTensorSchmidtAmplitude (n := n) σ q have hx : 0 ≤ x := by dsimp [x, harmonicTensorSchmidtAmplitude] exact mul_nonneg (hσ _) (inv_nonneg.mpr (Real.sqrt_nonneg _)) have hanti := descendingHarmonicSchmidtPermutation_antitone (n := n) σ have hcard : k.val + 1 ≤ S.card := by calc k.val + 1 = (Finset.Iic k).card := by simp _ = ((Finset.Iic k).map π.toEmbedding).card := by simp _ ≤ S.card := by apply Finset.card_le_card intro q hq obtain ⟨l, hl, hleq⟩ := Finset.mem_map.mp hq subst q apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _, ?_⟩ exact hanti (Finset.mem_Iic.mp hl) have hcardreal : (k.val : ℝ) + 1 ≤ (S.card : ℝ) := by exact_mod_cast hcard have htotal := harmonicSchmidtThreshold_count_sq_le_one (n := n) σ hσ hunit x hx change ((k.val : ℝ) + 1) * x ^ 2 ≤ 1 change (S.card : ℝ) * x ^ 2 ≤ 1 at htotal exact (mul_le_mul_of_nonneg_right hcardreal (sq_nonneg x)).trans htotal theorem descendingHarmonicSchmidtAmplitude_le_harmonic {d n : ℕ} (σ : Fin d → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (k : Fin (d * n)) : harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) ≤ (Real.sqrt ((k.val : ℝ) + 1))⁻¹ := by let x := harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) have hx : 0 ≤ x := by dsimp [x, harmonicTensorSchmidtAmplitude] exact mul_nonneg (hσ _) (inv_nonneg.mpr (Real.sqrt_nonneg _)) have hrank : 0 < (k.val : ℝ) + 1 := by positivity have hsqrt : 0 < Real.sqrt ((k.val : ℝ) + 1) := Real.sqrt_pos.mpr hrank have hrankbound := descendingHarmonicSchmidtAmplitude_rank_sq_le_one (n := n) σ hσ hunit k change x ≤ (Real.sqrt ((k.val : ℝ) + 1))⁻¹ rw [← one_div] apply (le_div_iff₀ hsqrt).2 have hsquare : (x * Real.sqrt ((k.val : ℝ) + 1)) ^ 2 ≤ 1 := by rw [mul_pow, Real.sq_sqrt hrank.le] nlinarith have hnonneg : 0 ≤ x * Real.sqrt ((k.val : ℝ) + 1) := mul_nonneg hx hsqrt.le nlinarith [sq_nonneg (x * Real.sqrt ((k.val : ℝ) + 1) + 1)] def diagonalSchmidtUnitVector {d : ℕ} (σ : Fin d → ℝ) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) : BipartiteUnitVector d := by refine ⟨diagonalSchmidtState σ, ?_⟩ have hsquare := diagonalSchmidtState_norm_sq σ rw [hunit] at hsquare nlinarith [norm_nonneg (diagonalSchmidtState σ)] theorem diagonalSchmidtTensorTarget_diagonal {d n : ℕ} (σ : Fin d → ℝ) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (q : Fin (d * n)) : tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit) (q, q) = (‖rawEmbezzlementState n‖⁻¹ : ℝ) • (harmonicTensorSchmidtAmplitude (n := n) σ q : ℂ) := by simp [tensorEmbezzlementTarget, diagonalSchmidtUnitVector, diagonalSchmidtState, embezzlementState_apply, harmonicTensorSchmidtAmplitude, mul_assoc, mul_comm] def harmonicSchmidtPermutationUnitary {d n : ℕ} (σ : Fin d → ℝ) : Matrix.unitaryGroup (Fin (d * n)) ℂ := permutationUnitary (descendingHarmonicSchmidtPermutation (n := n) σ).symm theorem harmonicSchmidtPermutationAction_off_diagonal {d n : ℕ} (σ : Fin d → ℝ) (i j : Fin (d * n)) (hij : i ≠ j) : localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n)) (i, j) = 0 := by rw [harmonicSchmidtPermutationUnitary, localPermutationUnitaryAction_apply, embezzlementState_apply] have hperm : (descendingHarmonicSchmidtPermutation (n := n) σ).symm i ≠ (descendingHarmonicSchmidtPermutation (n := n) σ).symm j := (descendingHarmonicSchmidtPermutation (n := n) σ).symm.injective.ne hij simp [hperm] theorem harmonicSchmidtPermutationAction_diagonal {d n : ℕ} (σ : Fin d → ℝ) (k : Fin (d * n)) : localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n)) (descendingHarmonicSchmidtPermutation (n := n) σ k, descendingHarmonicSchmidtPermutation (n := n) σ k) = (‖rawEmbezzlementState (d * n)‖⁻¹ : ℝ) • (↑((Real.sqrt ((k.val : ℝ) + 1))⁻¹) : ℂ) := by rw [harmonicSchmidtPermutationUnitary, localPermutationUnitaryAction_apply, embezzlementState_apply] simp theorem harmonicTensorSchmidtAmplitude_sq_sum {d n : ℕ} (σ : Fin d → ℝ) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) : (∑ q : Fin (d * n), harmonicTensorSchmidtAmplitude (n := n) σ q ^ 2) = harmonicNumber n := by have hterm (i : Fin d) (j : Fin n) : (σ i * (Real.sqrt ((j.val : ℝ) + 1))⁻¹) ^ 2 = σ i ^ 2 * ((j.val : ℝ) + 1)⁻¹ := by rw [mul_pow, inv_pow, Real.sq_sqrt (by positivity)] calc (∑ q : Fin (d * n), harmonicTensorSchmidtAmplitude (n := n) σ q ^ 2) = ∑ p : Fin d × Fin n, harmonicTensorSchmidtAmplitude (n := n) σ (finProdFinEquiv p) ^ 2 := by exact (Equiv.sum_comp finProdFinEquiv (fun q : Fin (d * n) => harmonicTensorSchmidtAmplitude (n := n) σ q ^ 2)).symm _ = ∑ i : Fin d, σ i ^ 2 * harmonicNumber n := by rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro i _ simp_rw [harmonicTensorSchmidtAmplitude, Equiv.symm_apply_apply] simp_rw [hterm] rw [← Finset.mul_sum] rfl _ = (∑ i : Fin d, σ i ^ 2) * harmonicNumber n := by rw [Finset.sum_mul] _ = harmonicNumber n := by rw [hunit, one_mul] theorem descendingHarmonicSchmidtAmplitude_sq_sum {d n : ℕ} (σ : Fin d → ℝ) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) : (∑ k : Fin (d * n), harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) ^ 2) = harmonicNumber n := by calc (∑ k : Fin (d * n), harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) ^ 2) = ∑ q : Fin (d * n), harmonicTensorSchmidtAmplitude (n := n) σ q ^ 2 := Equiv.sum_comp (descendingHarmonicSchmidtPermutation (n := n) σ) (fun q : Fin (d * n) => harmonicTensorSchmidtAmplitude (n := n) σ q ^ 2) _ = harmonicNumber n := harmonicTensorSchmidtAmplitude_sq_sum (n := n) σ hunit def universalCatalystOverlapTerm {d n : ℕ} (σ : Fin d → ℝ) (k : Fin (d * n)) : ℝ := ‖rawEmbezzlementState (d * n)‖⁻¹ * (Real.sqrt ((k.val : ℝ) + 1))⁻¹ * ‖rawEmbezzlementState n‖⁻¹ * harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) theorem universalCatalystOverlap_eq_sum {d n : ℕ} (σ : Fin d → ℝ) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) : (inner ℂ (localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n))) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit))).re = ∑ k : Fin (d * n), universalCatalystOverlapTerm (n := n) σ k := by rw [diagonalInner_real_eq_sum _ _ (harmonicSchmidtPermutationAction_off_diagonal (n := n) σ)] calc (∑ q : Fin (d * n), (inner ℂ (localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n)) (q, q)) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit) (q, q))).re) = ∑ k : Fin (d * n), (inner ℂ (localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n)) (descendingHarmonicSchmidtPermutation (n := n) σ k, descendingHarmonicSchmidtPermutation (n := n) σ k)) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit) (descendingHarmonicSchmidtPermutation (n := n) σ k, descendingHarmonicSchmidtPermutation (n := n) σ k))).re := by exact (Equiv.sum_comp (descendingHarmonicSchmidtPermutation (n := n) σ) (fun q : Fin (d * n) => (inner ℂ (localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n)) (q, q)) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit) (q, q))).re)).symm _ = ∑ k : Fin (d * n), universalCatalystOverlapTerm (n := n) σ k := by apply Finset.sum_congr rfl intro k _ rw [harmonicSchmidtPermutationAction_diagonal, diagonalSchmidtTensorTarget_diagonal] simp [universalCatalystOverlapTerm, mul_assoc, mul_comm, mul_left_comm] theorem universalCatalystOverlapTerm_lower {d n : ℕ} (σ : Fin d → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (k : Fin (d * n)) : ‖rawEmbezzlementState (d * n)‖⁻¹ * ‖rawEmbezzlementState n‖⁻¹ * harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) ^ 2 ≤ universalCatalystOverlapTerm (n := n) σ k := by let a := harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) let h := (Real.sqrt ((k.val : ℝ) + 1))⁻¹ let c := ‖rawEmbezzlementState (d * n)‖⁻¹ * ‖rawEmbezzlementState n‖⁻¹ have ha : 0 ≤ a := by dsimp [a, harmonicTensorSchmidtAmplitude] exact mul_nonneg (hσ _) (inv_nonneg.mpr (Real.sqrt_nonneg _)) have hc : 0 ≤ c := by dsimp [c] positivity have hah : a ≤ h := descendingHarmonicSchmidtAmplitude_le_harmonic (n := n) σ hσ hunit k change c * a ^ 2 ≤ _ calc c * a ^ 2 = (c * a) * a := by ring _ ≤ (c * a) * h := mul_le_mul_of_nonneg_left hah (mul_nonneg hc ha) _ = universalCatalystOverlapTerm (n := n) σ k := by dsimp [c, a, h, universalCatalystOverlapTerm] ring theorem universalDiagonalCatalystOverlap_lower {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (σ : Fin d → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) : ‖rawEmbezzlementState n‖ / ‖rawEmbezzlementState (d * n)‖ ≤ (inner ℂ (localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n))) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit))).re := by have hnraw : ‖rawEmbezzlementState n‖ ≠ 0 := norm_ne_zero_iff.mpr (rawEmbezzlementState_ne_zero n hn) have hdnraw : ‖rawEmbezzlementState (d * n)‖ ≠ 0 := norm_ne_zero_iff.mpr (rawEmbezzlementState_ne_zero (d * n) (Nat.mul_pos hd hn)) calc ‖rawEmbezzlementState n‖ / ‖rawEmbezzlementState (d * n)‖ = ‖rawEmbezzlementState (d * n)‖⁻¹ * ‖rawEmbezzlementState n‖⁻¹ * harmonicNumber n := by rw [← rawEmbezzlementState_norm_sq n] field_simp _ = ∑ k : Fin (d * n), ‖rawEmbezzlementState (d * n)‖⁻¹ * ‖rawEmbezzlementState n‖⁻¹ * harmonicTensorSchmidtAmplitude (n := n) σ (descendingHarmonicSchmidtPermutation (n := n) σ k) ^ 2 := by rw [← descendingHarmonicSchmidtAmplitude_sq_sum (n := n) σ hunit, Finset.mul_sum] _ ≤ ∑ k : Fin (d * n), universalCatalystOverlapTerm (n := n) σ k := by apply Finset.sum_le_sum intro k _ exact universalCatalystOverlapTerm_lower (n := n) σ hσ hunit k _ = (inner ℂ (localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n))) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit))).re := (universalCatalystOverlap_eq_sum (n := n) σ hunit).symm def harmonicTargetLiftUnitary {d n : ℕ} (U : Matrix.unitaryGroup (Fin d) ℂ) : Matrix.unitaryGroup (Fin (d * n)) ℂ := by let e : (Fin d × Fin n) ≃ Fin (d * n) := finProdFinEquiv let M : Matrix (Fin d × Fin n) (Fin d × Fin n) ℂ := (U.val ⊗ₖ (1 : Matrix (Fin n) (Fin n) ℂ)) have hM : M ∈ Matrix.unitaryGroup (Fin d × Fin n) ℂ := by exact Matrix.kronecker_mem_unitary U.property (show (1 : Matrix (Fin n) (Fin n) ℂ) ∈ Matrix.unitaryGroup (Fin n) ℂ from (Matrix.unitaryGroup (Fin n) ℂ).one_mem) refine ⟨(Matrix.reindex e e) M, ?_⟩ rw [Matrix.mem_unitaryGroup_iff'] have hstar : star ((Matrix.reindex e e) M) = (Matrix.reindex e e) (star M) := by ext i j simp [Matrix.star_eq_conjTranspose, Matrix.reindex_apply, Matrix.conjTranspose_apply] rw [hstar] change (Matrix.reindexRingEquiv ℂ e) (star M) * (Matrix.reindexRingEquiv ℂ e) M = 1 rw [← (Matrix.reindexRingEquiv ℂ e).map_mul, (Matrix.mem_unitaryGroup_iff').mp hM] exact (Matrix.reindexRingEquiv ℂ e).map_one @[simp] theorem harmonicTargetLiftUnitary_apply {d n : ℕ} (U : Matrix.unitaryGroup (Fin d) ℂ) (a b : Fin d) (i j : Fin n) : harmonicTargetLiftUnitary (n := n) U (finProdFinEquiv (a, i)) (finProdFinEquiv (b, j)) = if i = j then U a b else 0 := by change (Matrix.reindex finProdFinEquiv finProdFinEquiv (U.val ⊗ₖ (1 : Matrix (Fin n) (Fin n) ℂ))) (finProdFinEquiv (a, i)) (finProdFinEquiv (b, j)) = _ simp [Matrix.reindex_apply, Matrix.kroneckerMap_apply, Matrix.one_apply] theorem localUnitaryAction_comp {m : ℕ} (U₁ V₁ U₂ V₂ : Matrix.unitaryGroup (Fin m) ℂ) (ψ : EuclideanSpace ℂ (Fin m × Fin m)) : localUnitaryAction U₁ V₁ (localUnitaryAction U₂ V₂ ψ) = localUnitaryAction (U₁ * U₂) (V₁ * V₂) ψ := by apply WithLp.ofLp_injective change ((U₁.val ⊗ₖ V₁.val).mulVec ((U₂.val ⊗ₖ V₂.val).mulVec (ofLp ψ))) = ((U₁ * U₂).val ⊗ₖ (V₁ * V₂).val).mulVec (ofLp ψ) rw [Matrix.mulVec_mulVec, ← Matrix.mul_kronecker_mul] rfl theorem targetCatalystDoubleSum_reindex {d n : ℕ} (F : Fin (d * n) → Fin (d * n) → ℂ) : (∑ i : Fin (d * n), ∑ j : Fin (d * n), F i j) = ∑ p : Fin d × Fin n, ∑ q : Fin d × Fin n, F (finProdFinEquiv p) (finProdFinEquiv q) := by calc (∑ i : Fin (d * n), ∑ j : Fin (d * n), F i j) = ∑ p : Fin d × Fin n, ∑ j : Fin (d * n), F (finProdFinEquiv p) j := by exact (Equiv.sum_comp finProdFinEquiv (fun i : Fin (d * n) => ∑ j : Fin (d * n), F i j)).symm _ = ∑ p : Fin d × Fin n, ∑ q : Fin d × Fin n, F (finProdFinEquiv p) (finProdFinEquiv q) := by apply Finset.sum_congr rfl intro p _ exact (Equiv.sum_comp finProdFinEquiv (fun j : Fin (d * n) => F (finProdFinEquiv p) j)).symm theorem harmonicTargetLift_diagonal_action_apply {d n : ℕ} (σ : Fin d → ℝ) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (U V : Matrix.unitaryGroup (Fin d) ℂ) (a b : Fin d) (i j : Fin n) : localUnitaryAction (harmonicTargetLiftUnitary (n := n) U) (harmonicTargetLiftUnitary (n := n) V) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit)) (finProdFinEquiv (a, i), finProdFinEquiv (b, j)) = schmidtVector σ U V (a, b) * embezzlementState n (i, j) := by classical let LU := harmonicTargetLiftUnitary (n := n) U let LV := harmonicTargetLiftUnitary (n := n) V let T := tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit) have hT (p q : Fin d × Fin n) : T (finProdFinEquiv p, finProdFinEquiv q) = (if p.1 = q.1 then (σ p.1 : ℂ) else 0) * embezzlementState n (p.2, q.2) := by change (if (finProdFinEquiv.symm (finProdFinEquiv p)).1 = (finProdFinEquiv.symm (finProdFinEquiv q)).1 then (σ (finProdFinEquiv.symm (finProdFinEquiv p)).1 : ℂ) else 0) * embezzlementState n ((finProdFinEquiv.symm (finProdFinEquiv p)).2, (finProdFinEquiv.symm (finProdFinEquiv q)).2) = _ simp only [Equiv.symm_apply_apply] change ((LU.val ⊗ₖ LV.val).mulVec (ofLp T)) (finProdFinEquiv (a, i), finProdFinEquiv (b, j)) = _ calc ((LU.val ⊗ₖ LV.val).mulVec (ofLp T)) (finProdFinEquiv (a, i), finProdFinEquiv (b, j)) = ∑ r : Fin (d * n), ∑ s : Fin (d * n), LU (finProdFinEquiv (a, i)) r * LV (finProdFinEquiv (b, j)) s * T (r, s) := by simp [Matrix.mulVec, dotProduct, Matrix.kroneckerMap_apply, Fintype.sum_prod_type, mul_assoc] _ = ∑ p : Fin d × Fin n, ∑ q : Fin d × Fin n, LU (finProdFinEquiv (a, i)) (finProdFinEquiv p) * LV (finProdFinEquiv (b, j)) (finProdFinEquiv q) * T (finProdFinEquiv p, finProdFinEquiv q) := targetCatalystDoubleSum_reindex (fun r s => LU (finProdFinEquiv (a, i)) r * LV (finProdFinEquiv (b, j)) s * T (r, s)) _ = schmidtVector σ U V (a, b) * embezzlementState n (i, j) := by simp_rw [hT] simp [LU, LV, harmonicTargetLiftUnitary_apply, schmidtVector_apply, Fintype.sum_prod_type, mul_assoc, mul_comm, mul_left_comm] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro k _ ring theorem harmonicTargetLift_diagonal_action {d n : ℕ} (ξ : BipartiteUnitVector d) (σ : Fin d → ℝ) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (U V : Matrix.unitaryGroup (Fin d) ℂ) (hξ : ξ.val = schmidtVector σ U V) : localUnitaryAction (harmonicTargetLiftUnitary (n := n) U) (harmonicTargetLiftUnitary (n := n) V) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit)) = tensorEmbezzlementTarget (n := n) ξ := by ext ⟨r, s⟩ let p : Fin d × Fin n := finProdFinEquiv.symm r let q : Fin d × Fin n := finProdFinEquiv.symm s have hr : finProdFinEquiv p = r := Equiv.apply_symm_apply finProdFinEquiv r have hs : finProdFinEquiv q = s := Equiv.apply_symm_apply finProdFinEquiv s calc localUnitaryAction (harmonicTargetLiftUnitary (n := n) U) (harmonicTargetLiftUnitary (n := n) V) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit)) (r, s) = localUnitaryAction (harmonicTargetLiftUnitary (n := n) U) (harmonicTargetLiftUnitary (n := n) V) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit)) (finProdFinEquiv (p.1, p.2), finProdFinEquiv (q.1, q.2)) := by simp [hr, hs] _ = schmidtVector σ U V (p.1, q.1) * embezzlementState n (p.2, q.2) := harmonicTargetLift_diagonal_action_apply σ hunit U V p.1 q.1 p.2 q.2 _ = ξ.val (p.1, q.1) * embezzlementState n (p.2, q.2) := by rw [hξ] _ = tensorEmbezzlementTarget (n := n) ξ (finProdFinEquiv (p.1, p.2), finProdFinEquiv (q.1, q.2)) := by change _ = ξ.val ((finProdFinEquiv.symm (finProdFinEquiv (p.1, p.2))).1, (finProdFinEquiv.symm (finProdFinEquiv (q.1, q.2))).1) * embezzlementState n ((finProdFinEquiv.symm (finProdFinEquiv (p.1, p.2))).2, (finProdFinEquiv.symm (finProdFinEquiv (q.1, q.2))).2) simp only [Equiv.symm_apply_apply] _ = tensorEmbezzlementTarget (n := n) ξ (r, s) := by simp [hr, hs] theorem localUnitaryAction_sub {m : ℕ} (U V : Matrix.unitaryGroup (Fin m) ℂ) (z w : EuclideanSpace ℂ (Fin m × Fin m)) : localUnitaryAction U V (z - w) = localUnitaryAction U V z - localUnitaryAction U V w := by apply WithLp.ofLp_injective change ((U.val ⊗ₖ V.val).mulVec ((ofLp z) - (ofLp w))) = ((U.val ⊗ₖ V.val).mulVec (ofLp z)) - ((U.val ⊗ₖ V.val).mulVec (ofLp w)) exact Matrix.mulVec_sub _ _ _ theorem universalDiagonalCatalystOverlap_of_harmonic_ratio {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (σ : Fin d → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (δ : ℝ) (hδ : 0 ≤ δ) (hδone : δ ≤ 1) (hratio : 1 - δ ≤ harmonicNumber n / harmonicNumber (d * n)) : 1 - δ ≤ (inner ℂ (localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n))) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit))).re := by let q : ℝ := ‖rawEmbezzlementState n‖ / ‖rawEmbezzlementState (d * n)‖ have hq : 0 ≤ q := by dsimp [q] exact div_nonneg (norm_nonneg _) (norm_nonneg _) have hqsquare : q ^ 2 = harmonicNumber n / harmonicNumber (d * n) := by dsimp [q] rw [div_pow, rawEmbezzlementState_norm_sq, rawEmbezzlementState_norm_sq] have hgoalnonneg : 0 ≤ 1 - δ := sub_nonneg.mpr hδone have hgoalsquare : (1 - δ) ^ 2 ≤ 1 - δ := by nlinarith [mul_nonneg hδ hgoalnonneg] have hqbound : 1 - δ ≤ q := by rw [← hqsquare] at hratio nlinarith [sq_nonneg (q + (1 - δ))] exact hqbound.trans (universalDiagonalCatalystOverlap_lower hd hn σ hσ hunit) theorem universalDiagonalCatalyst_distance {d n : ℕ} (hd : 0 < d) (hn : 0 < n) (σ : Fin d → ℝ) (hσ : ∀ i, 0 ≤ σ i) (hunit : (∑ i : Fin d, σ i ^ 2) = 1) (δ : ℝ) (hδ : 0 ≤ δ) (hδone : δ ≤ 1) (hratio : 1 - δ ≤ harmonicNumber n / harmonicNumber (d * n)) : ‖localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n)) - tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit)‖ ≤ Real.sqrt (2 * δ) := by apply unitVector_distance_of_real_overlap (localUnitaryAction (harmonicSchmidtPermutationUnitary (n := n) σ) (harmonicSchmidtPermutationUnitary (n := n) σ) (embezzlementState (d * n))) (tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit)) (by rw [localUnitaryAction_norm, embezzlementState_norm (d * n) (Nat.mul_pos hd hn)]) (tensorEmbezzlementTarget_norm hn (diagonalSchmidtUnitVector σ hunit)) δ hδ exact universalDiagonalCatalystOverlap_of_harmonic_ratio hd hn σ hσ hunit δ hδ hδone hratio theorem exists_proofUniversalHarmonicCatalyst (d : ℕ) (hd : 0 < d) (ε : ℝ) (hε : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∀ ξ : BipartiteUnitVector d, ∃ U V : Matrix.unitaryGroup (Fin (d * n)) ℂ, ‖localUnitaryAction U V (embezzlementState (d * n)) - tensorEmbezzlementTarget (n := n) ξ‖ ≤ ε := by let δ : ℝ := min (ε ^ 2 / 2) 1 have hδ : 0 < δ := by dsimp [δ] exact lt_min (by positivity) zero_lt_one have hδone : δ ≤ 1 := min_le_right _ _ obtain ⟨n, hn, hratio⟩ := exists_proofHarmonicNumber_ratio_ge d hd hδ hδone refine ⟨n, hn, ?_⟩ intro ξ obtain ⟨σ, U, V, hσ, hunit, hξ⟩ := exists_proofUnitSchmidtDecomposition ξ let LU := harmonicTargetLiftUnitary (n := n) U let LV := harmonicTargetLiftUnitary (n := n) V let P := harmonicSchmidtPermutationUnitary (n := n) σ refine ⟨LU * P, LV * P, ?_⟩ have hdiagonal := universalDiagonalCatalyst_distance hd hn σ hσ hunit δ hδ.le hδone hratio have htarget := harmonicTargetLift_diagonal_action (n := n) ξ σ hunit U V hξ have hdeltaeps : 2 * δ ≤ ε ^ 2 := by have hmin : δ ≤ ε ^ 2 / 2 := min_le_left _ _ linarith have hsqrt : Real.sqrt (2 * δ) ≤ ε := by have hsq : (Real.sqrt (2 * δ)) ^ 2 = 2 * δ := Real.sq_sqrt (by positivity) nlinarith [Real.sqrt_nonneg (2 * δ)] calc ‖localUnitaryAction (LU * P) (LV * P) (embezzlementState (d * n)) - tensorEmbezzlementTarget (n := n) ξ‖ = ‖localUnitaryAction LU LV (localUnitaryAction P P (embezzlementState (d * n)) - tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit))‖ := by rw [localUnitaryAction_sub, localUnitaryAction_comp] rw [htarget] _ = ‖localUnitaryAction P P (embezzlementState (d * n)) - tensorEmbezzlementTarget (n := n) (diagonalSchmidtUnitVector σ hunit)‖ := localUnitaryAction_norm LU LV _ _ ≤ Real.sqrt (2 * δ) := hdiagonal _ ≤ ε := hsqrt def coherentSharedRandomControlledUnitary {Ω d : Type*} [Fintype Ω] [Fintype d] [DecidableEq Ω] [DecidableEq d] (U : Ω → Matrix.unitaryGroup d ℂ) : Matrix.unitaryGroup (Σ _ : Ω, d) ℂ := by refine ⟨Matrix.blockDiagonal' fun ω : Ω => (U ω : Matrix d d ℂ), ?_⟩ rw [Matrix.mem_unitaryGroup_iff', Matrix.star_eq_conjTranspose, Matrix.blockDiagonal'_conjTranspose, ← Matrix.blockDiagonal'_mul] have hblock (ω : Ω) : (U ω : Matrix d d ℂ).conjTranspose * (U ω : Matrix d d ℂ) = 1 := by simpa [Matrix.star_eq_conjTranspose] using (Matrix.mem_unitaryGroup_iff').mp (U ω).property simp_rw [hblock] ext ⟨ω, i⟩ ⟨ν, j⟩ by_cases hων : ω = ν <;> by_cases hij : i = j <;> simp [Matrix.blockDiagonal'_apply, Matrix.one_apply, hων, hij] def spectralPartitionPOVM {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (bin : d → κ) : POVM κ d where effect k := ∑ i ∈ Finset.univ.filter (fun i : d => bin i = k), positiveMatrixSpectralAtom F hF i positive k := by apply Matrix.posSemidef_sum intro i _ exact positiveMatrixSpectralAtom_posSemidef F hF i complete := by classical calc (∑ k : κ, ∑ i ∈ Finset.univ.filter (fun i : d => bin i = k), positiveMatrixSpectralAtom F hF i) = ∑ i : d, positiveMatrixSpectralAtom F hF i := by simp [Finset.sum_filter, Finset.sum_comm] _ = 1 := positiveMatrixSpectralAtom_sum F hF theorem spectralPartitionPOVM_projective {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (bin : d → κ) (k : κ) : (spectralPartitionPOVM F hF bin).effect k * (spectralPartitionPOVM F hF bin).effect k = (spectralPartitionPOVM F hF bin).effect k := by exact spectralAtomSum_mul_self F hF (Finset.univ.filter (fun i : d => bin i = k)) def bilateralWorkPairEquiv {ι d e : Type*} : ((ι → d) × (ι → e)) ≃ (ι → d × e) where toFun x i := (x.1 i, x.2 i) invFun x := (fun i => (x i).1, fun i => (x i).2) left_inv x := by rcases x with ⟨a, b⟩ rfl right_inv x := by funext i exact Prod.eta (x i) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3000000 set_option maxRecDepth 2048 theorem spectralPartitionPOVM_trace_eq_atom_count {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (bin : d → κ) (k : κ) : (Matrix.trace ((spectralPartitionPOVM F hF bin).effect k)).re = ∑ i : d, if bin i = k then (1 : ℝ) else 0 := by classical simp [spectralPartitionPOVM, Matrix.trace_sum, spectralAtom_trace] theorem spectralPartitionPOVM_trace_mul_eq_atom_overlap {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (F G : Matrix d d ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (binF binG : d → κ) (k : κ) : (Matrix.trace ((spectralPartitionPOVM F hF binF).effect k * (spectralPartitionPOVM G hG binG).effect k)).re = ∑ i ∈ (Finset.univ.filter fun i : d => binF i = k), ∑ j ∈ (Finset.univ.filter fun j : d => binG j = k), spectralAtomOverlap F G hF hG i j := by classical simp [spectralPartitionPOVM, spectralAtomOverlap, Matrix.sum_mul, Matrix.mul_sum, Matrix.trace_sum] rw [Finset.sum_comm] theorem spectralPartitionPOVM_weighted_trace_deficit_eq_mismatch {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (F G : Matrix d d ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (binF binG : d → κ) (τ : κ → ℝ) : (∑ k : κ, τ k ^ 2 * (Matrix.trace ((spectralPartitionPOVM G hG binG).effect k)).re) - (∑ k : κ, τ k ^ 2 * (Matrix.trace ((spectralPartitionPOVM F hF binF).effect k * (spectralPartitionPOVM G hG binG).effect k)).re) = ∑ i : d, ∑ j : d, if binF i = binG j then 0 else τ (binG j) ^ 2 * spectralAtomOverlap F G hF hG i j := by classical let w : d → d → ℝ := spectralAtomOverlap F G hF hG have hQ : (∑ k : κ, τ k ^ 2 * (Matrix.trace ((spectralPartitionPOVM G hG binG).effect k)).re) = ∑ j : d, τ (binG j) ^ 2 := by simp_rw [spectralPartitionPOVM_trace_eq_atom_count] calc (∑ k : κ, τ k ^ 2 * (∑ j : d, if binG j = k then (1 : ℝ) else 0)) = ∑ k : κ, ∑ j : d, if binG j = k then τ k ^ 2 else 0 := by apply Finset.sum_congr rfl intro k _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j _ split_ifs <;> simp _ = ∑ j : d, ∑ k : κ, if binG j = k then τ k ^ 2 else 0 := Finset.sum_comm _ = ∑ j : d, τ (binG j) ^ 2 := by simp have hPQ : (∑ k : κ, τ k ^ 2 * (Matrix.trace ((spectralPartitionPOVM F hF binF).effect k * (spectralPartitionPOVM G hG binG).effect k)).re) = ∑ i : d, ∑ j : d, if binF i = binG j then τ (binG j) ^ 2 * w i j else 0 := by have hsingle (k : κ) : τ k ^ 2 * (Matrix.trace ((spectralPartitionPOVM F hF binF).effect k * (spectralPartitionPOVM G hG binG).effect k)).re = ∑ i : d, ∑ j : d, if binF i = k ∧ binG j = k then τ k ^ 2 * w i j else 0 := by rw [spectralPartitionPOVM_trace_mul_eq_atom_overlap] dsimp [w] simp only [Finset.sum_filter, Finset.mul_sum, mul_ite, mul_zero] apply Finset.sum_congr rfl intro i _ by_cases hi : binF i = k · simp [hi] · simp [hi] simp_rw [hsingle] calc (∑ k : κ, ∑ i : d, ∑ j : d, if binF i = k ∧ binG j = k then τ k ^ 2 * w i j else 0) = ∑ i : d, ∑ j : d, ∑ k : κ, if binF i = k ∧ binG j = k then τ k ^ 2 * w i j else 0 := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro i _ rw [Finset.sum_comm] _ = ∑ i : d, ∑ j : d, if binF i = binG j then τ (binG j) ^ 2 * w i j else 0 := by apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ have reindex (k : κ) : (if binF i = k ∧ binG j = k then τ k ^ 2 * w i j else 0) = if binG j = k then if binF i = binG j then τ (binG j) ^ 2 * w i j else 0 else 0 := by by_cases hk : binG j = k · subst k simp · simp [hk] simp_rw [reindex] simp rw [hQ, hPQ] have hcolumn : ∀ j : d, (∑ i : d, w i j) = 1 := spectralAtomOverlap_sum_left F G hF hG have hfirst : (∑ j : d, τ (binG j) ^ 2) = ∑ i : d, ∑ j : d, τ (binG j) ^ 2 * w i j := by calc (∑ j : d, τ (binG j) ^ 2) = ∑ j : d, τ (binG j) ^ 2 * (∑ i : d, w i j) := by simp_rw [hcolumn] simp _ = ∑ i : d, ∑ j : d, τ (binG j) ^ 2 * w i j := by simp_rw [Finset.mul_sum] exact Finset.sum_comm rw [hfirst, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i _ rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro j _ split_ifs <;> simp [w] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 3072 def finiteUniformThresholdGrid (lower upper : ℝ) (N : ℕ) (k : Fin N) : ℝ := lower + (k.val : ℝ) * ((upper - lower) / (N : ℝ)) def finiteUniformThresholdCrossing (lower upper a b : ℝ) (N : ℕ) : ℝ := ((Finset.univ.filter fun k : Fin N => min a b ≤ finiteUniformThresholdGrid lower upper N k ∧ finiteUniformThresholdGrid lower upper N k ≤ max a b).card : ℝ) / (N : ℝ) theorem finiteUniformGrid_interval_card_le (N : ℕ) (offset step lo hi : ℝ) (positive : 0 < step) (ordered : lo ≤ hi) : (((Finset.univ.filter fun k : Fin N => lo ≤ offset + (k.val : ℝ) * step ∧ offset + (k.val : ℝ) * step ≤ hi).card : ℕ) : ℝ) ≤ (hi - lo) / step + 1 := by classical let selected : Finset (Fin N) := Finset.univ.filter fun k : Fin N => lo ≤ offset + (k.val : ℝ) * step ∧ offset + (k.val : ℝ) * step ≤ hi change (selected.card : ℝ) ≤ (hi - lo) / step + 1 by_cases present : selected.Nonempty · let first : Fin N := selected.min' present let last : Fin N := selected.max' present have first_mem : first ∈ selected := Finset.min'_mem selected present have last_mem : last ∈ selected := Finset.max'_mem selected present have interval : selected ⊆ Finset.Icc first last := by intro k hk apply Finset.mem_Icc.mpr constructor · exact Finset.min'_le selected k hk · exact Finset.le_max' selected k hk have cardinal : selected.card ≤ last.val + 1 - first.val := by have h := Finset.card_le_card interval simpa using h have ordered_indices : first.val ≤ last.val := by change (selected.min' present).val ≤ (selected.max' present).val exact Finset.min'_le_max' selected present have nat_bound : first.val ≤ last.val + 1 := by omega have real_cardinal : (selected.card : ℝ) ≤ (last.val : ℝ) + 1 - (first.val : ℝ) := by exact_mod_cast cardinal have first_lower : lo ≤ offset + (first.val : ℝ) * step := (Finset.mem_filter.mp first_mem).2.1 have last_upper : offset + (last.val : ℝ) * step ≤ hi := (Finset.mem_filter.mp last_mem).2.2 have spread : ((last.val : ℝ) - (first.val : ℝ)) * step ≤ hi - lo := by nlinarith have scaled : (last.val : ℝ) - (first.val : ℝ) ≤ (hi - lo) / step := (le_div_iff₀ positive).2 spread linarith · have empty : selected = ∅ := Finset.not_nonempty_iff_eq_empty.mp present rw [empty, Finset.card_empty, Nat.cast_zero] have difference : 0 ≤ hi - lo := sub_nonneg.mpr ordered exact add_nonneg (div_nonneg difference positive.le) (by norm_num) theorem finiteUniformThresholdCrossing_le {lower upper : ℝ} (window : lower < upper) (a b : ℝ) (N : ℕ) (nonempty : 0 < N) : finiteUniformThresholdCrossing lower upper a b N ≤ |a - b| / (upper - lower) + 1 / (N : ℝ) := by have realN : (0 : ℝ) < (N : ℝ) := by exact_mod_cast nonempty have width : 0 < upper - lower := sub_pos.mpr window have step : 0 < (upper - lower) / (N : ℝ) := div_pos width realN have count := finiteUniformGrid_interval_card_le N lower ((upper - lower) / (N : ℝ)) (min a b) (max a b) step min_le_max change ((Finset.univ.filter fun k : Fin N => min a b ≤ finiteUniformThresholdGrid lower upper N k ∧ finiteUniformThresholdGrid lower upper N k ≤ max a b).card : ℝ) / (N : ℝ) ≤ _ have same_count : ((Finset.univ.filter fun k : Fin N => min a b ≤ finiteUniformThresholdGrid lower upper N k ∧ finiteUniformThresholdGrid lower upper N k ≤ max a b).card : ℝ) ≤ (max a b - min a b) / ((upper - lower) / (N : ℝ)) + 1 := by simpa [finiteUniformThresholdGrid] using count calc ((Finset.univ.filter fun k : Fin N => min a b ≤ finiteUniformThresholdGrid lower upper N k ∧ finiteUniformThresholdGrid lower upper N k ≤ max a b).card : ℝ) / (N : ℝ) ≤ ((max a b - min a b) / ((upper - lower) / (N : ℝ)) + 1) / (N : ℝ) := div_le_div_of_nonneg_right same_count realN.le _ = |a - b| / (upper - lower) + 1 / (N : ℝ) := by rw [max_sub_min_eq_abs] have habs : |b - a| = |a - b| := abs_sub_comm b a rw [habs] field_simp [realN.ne', width.ne'] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem localUnitaryPureResidual_targetLocalInverse_reset {n : ℕ} (U V : Matrix.unitaryGroup (Fin n) ℂ) (x : EuclideanSpace ℂ (Fin n × Fin n)) : localUnitaryAction U⁻¹ V⁻¹ (localUnitaryAction U V x) = x := by rw [localUnitaryAction_comp, inv_mul_cancel, inv_mul_cancel] simp [localUnitaryAction] def targetCoefficientMatrix {d : ℕ} (ξ : BipartiteUnitVector d) : Matrix (Fin d) (Fin d) ℂ := fun b a => ξ.val (a, b) theorem targetCoefficientMatrix_vec {d : ℕ} (ξ : BipartiteUnitVector d) : toLp 2 (Matrix.vec (targetCoefficientMatrix ξ)) = ξ.val := by ext ⟨a, b⟩ rfl def targetReducedDensity {d : ℕ} (ξ : BipartiteUnitVector d) : Matrix (Fin d) (Fin d) ℂ := (targetCoefficientMatrix ξ).conjTranspose * targetCoefficientMatrix ξ theorem targetReducedDensity_posSemidef {d : ℕ} (ξ : BipartiteUnitVector d) : (targetReducedDensity ξ).PosSemidef := by exact Matrix.posSemidef_conjTranspose_mul_self (targetCoefficientMatrix ξ) theorem targetReducedDensity_trace {d : ℕ} (ξ : BipartiteUnitVector d) : Matrix.trace (targetReducedDensity ξ) = 1 := by have vectorized := matrixVectorization_inner (targetCoefficientMatrix ξ) (targetCoefficientMatrix ξ) rw [targetCoefficientMatrix_vec, inner_self_eq_one_of_norm_eq_one ξ.property] at vectorized exact vectorized.symm theorem targetSpectralAtom_apply {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (i a b : d) : positiveMatrixSpectralAtom F hF i a b = (hF.isHermitian.eigenvectorUnitary : Matrix d d ℂ) a i * star ((hF.isHermitian.eigenvectorUnitary : Matrix d d ℂ) b i) := by classical simp [positiveMatrixSpectralAtom, spectralConjugationCLM_apply, Matrix.mul_apply, Matrix.diagonal_apply, Pi.single_apply] theorem targetSpectralAtomOverlap_eq_basis_norm_sq {d : Type*} [Fintype d] [DecidableEq d] (F G : Matrix d d ℂ) (hF : F.PosSemidef) (hG : G.PosSemidef) (i j : d) : spectralAtomOverlap F G hF hG i j = ‖unitaryBasisOverlap hF.isHermitian.eigenvectorUnitary hG.isHermitian.eigenvectorUnitary i j‖ ^ 2 := by classical let U : Matrix d d ℂ := hF.isHermitian.eigenvectorUnitary let V : Matrix d d ℂ := hG.isHermitian.eigenvectorUnitary let z : ℂ := ∑ a : d, star (U a i) * V a j have cross : Matrix.trace (positiveMatrixSpectralAtom F hF i * positiveMatrixSpectralAtom G hG j) = star z * z := by simp only [Matrix.trace, Matrix.diag_apply, Matrix.mul_apply, targetSpectralAtom_apply] change (∑ a : d, ∑ b : d, (U a i * star (U b i)) * (V b j * star (V a j))) = star z * z dsimp [z] rw [map_sum, Finset.sum_mul] simp only [map_mul] simp_rw [Finset.mul_sum] apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ simp only [starRingEnd_apply, star_star] ring unfold spectralAtomOverlap rw [cross] have coeff : unitaryBasisOverlap hF.isHermitian.eigenvectorUnitary hG.isHermitian.eigenvectorUnitary i j = z := by simp [unitaryBasisOverlap_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, U, V, z] rw [coeff, ← Complex.normSq_eq_norm_sq] change (star z * z).re = Complex.normSq z simpa [Complex.star_def] using (congrArg Complex.re (@Complex.normSq_eq_conj_mul_self z)).symm end noncomputable section open scoped ComplexOrder Matrix BigOperators InnerProductSpace open Complex Matrix Finset open WithLp set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 8000000 set_option maxRecDepth 3072 def targetCanonicalSchmidtCoefficient {d : ℕ} (ξ : BipartiteUnitVector d) (i : Fin d) : ℝ := Real.sqrt ((targetReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) theorem targetCanonicalSchmidtCoefficient_nonneg {d : ℕ} (ξ : BipartiteUnitVector d) (i : Fin d) : 0 ≤ targetCanonicalSchmidtCoefficient ξ i := Real.sqrt_nonneg _ theorem targetCanonicalSchmidtCoefficient_sq_sum {d : ℕ} (ξ : BipartiteUnitVector d) : (∑ i : Fin d, targetCanonicalSchmidtCoefficient ξ i ^ 2) = 1 := by unfold targetCanonicalSchmidtCoefficient simp_rw [Real.sq_sqrt ((targetReducedDensity_posSemidef ξ).eigenvalues_nonneg _)] exact positiveDensity_eigenvalues_sum (targetReducedDensity ξ) (targetReducedDensity_posSemidef ξ) (targetReducedDensity_trace ξ) theorem exists_proofTargetCanonicalSpectralSchmidtDecomposition {d : ℕ} (ξ : BipartiteUnitVector d) : ∃ (V : Matrix.unitaryGroup (Fin d) ℂ), ξ.val = schmidtVector (targetCanonicalSchmidtCoefficient ξ) (conjugateUnitary (targetReducedDensity_posSemidef ξ).isHermitian.eigenvectorUnitary) V := by classical let C : Matrix (Fin d) (Fin d) ℂ := targetCoefficientMatrix ξ let T : EuclideanSpace ℂ (Fin d) →ₗ[ℂ] EuclideanSpace ℂ (Fin d) := Matrix.toEuclideanLin C let hF := targetReducedDensity_posSemidef ξ let v : OrthonormalBasis (Fin d) ℂ (EuclideanSpace ℂ (Fin d)) := hF.isHermitian.eigenvectorBasis let σ : Fin d → ℝ := targetCanonicalSchmidtCoefficient ξ have hσ (i : Fin d) : 0 ≤ σ i := targetCanonicalSchmidtCoefficient_nonneg ξ i have hσsq (i : Fin d) : σ i ^ 2 = hF.isHermitian.eigenvalues i := by exact Real.sq_sqrt (hF.eigenvalues_nonneg i) have heigen (i : Fin d) : (T.adjoint ∘ₗ T) (v i) = ((σ i ^ 2 : ℝ) : ℂ) • v i := by rw [← Matrix.toEuclideanLin_conjTranspose_eq_adjoint] change toLp 2 (C.conjTranspose.mulVec (C.mulVec (ofLp (v i)))) = ((σ i ^ 2 : ℝ) : ℂ) • v i rw [Matrix.mulVec_mulVec] have spectral := hF.isHermitian.mulVec_eigenvectorBasis i change (C.conjTranspose * C).mulVec (ofLp (v i)) = (hF.isHermitian.eigenvalues i) • (ofLp (v i)) at spectral rw [spectral, ← hσsq] rfl let s : Set (Fin d) := {i | σ i ≠ 0} let f : Fin d → EuclideanSpace ℂ (Fin d) := fun i => ((σ i : ℂ)⁻¹) • T (v i) have hGram (i j : Fin d) : inner ℂ (T (v i)) (T (v j)) = ((σ j ^ 2 : ℝ) : ℂ) * inner ℂ (v i) (v j) := by calc inner ℂ (T (v i)) (T (v j)) = inner ℂ (v i) (T.adjoint (T (v j))) := (T.adjoint_inner_right (v i) (T (v j))).symm _ = inner ℂ (v i) (((σ j ^ 2 : ℝ) : ℂ) • v j) := by rw [← heigen j] rfl _ = _ := by rw [inner_smul_right] have hf : Orthonormal ℂ (s.restrict f) := by rw [orthonormal_iff_ite] intro i j have hi : (σ (i : Fin d) : ℂ) ≠ 0 := by exact_mod_cast i.property have hj : (σ (j : Fin d) : ℂ) ≠ 0 := by exact_mod_cast j.property change inner ℂ (((σ (i : Fin d) : ℂ)⁻¹) • T (v i)) (((σ (j : Fin d) : ℂ)⁻¹) • T (v j)) = _ rw [inner_smul_left, inner_smul_right, hGram, v.inner_eq_ite] by_cases same : i = j · subst j simp only [ite_true, mul_one] have real_star : starRingEnd ℂ ((σ (i : Fin d) : ℂ)⁻¹) = ((σ (i : Fin d) : ℂ)⁻¹) := by simp rw [real_star] push_cast field_simp · have unequal : (i : Fin d) ≠ (j : Fin d) := by intro equal exact same (Subtype.ext equal) simp [same, unequal] obtain ⟨u, hu⟩ := Orthonormal.exists_orthonormalBasis_extension_of_card_eq (by rw [Fintype.card_fin] exact finrank_euclideanSpace_fin) hf have singular (i : Fin d) : T (v i) = (σ i : ℂ) • u i := by by_cases zero : σ i = 0 · have kernel : (T.adjoint ∘ₗ T) (v i) = 0 := by rw [heigen i, zero] simp have image : T (v i) = 0 := by apply LinearMap.mem_ker.mp rw [← T.ker_adjoint_comp_self] exact LinearMap.mem_ker.mpr kernel simp [zero, image] · have chosen : u i = f i := hu i zero rw [chosen] change T (v i) = (σ i : ℂ) • (((σ i : ℂ)⁻¹) • T (v i)) rw [smul_smul, mul_inv_cancel₀] · simp · exact_mod_cast zero refine ⟨orthonormalBasisUnitary u, ?_⟩ have eigen_unitary : orthonormalBasisUnitary v = hF.isHermitian.eigenvectorUnitary := rfl ext ⟨a, b⟩ rw [schmidtVector_apply] have repr : T ((EuclideanSpace.basisFun (Fin d) ℂ) a) = ∑ i : Fin d, inner ℂ (v i) ((EuclideanSpace.basisFun (Fin d) ℂ) a) • T (v i) := by calc T ((EuclideanSpace.basisFun (Fin d) ℂ) a) = T (∑ i : Fin d, inner ℂ (v i) ((EuclideanSpace.basisFun (Fin d) ℂ) a) • v i) := by rw [v.sum_repr'] _ = _ := by simp have coordinate := congrArg (fun z : EuclideanSpace ℂ (Fin d) => z b) repr have replace : conjugateUnitary hF.isHermitian.eigenvectorUnitary = conjugateUnitary (orthonormalBasisUnitary v) := by rw [eigen_unitary] rw [replace] simpa [T, C, σ, targetCoefficientMatrix, Matrix.toLpLin_apply, EuclideanSpace.basisFun_apply, Matrix.mulVec_single_one, Matrix.col_apply, EuclideanSpace.inner_single_right, conjugateUnitary_apply, orthonormalBasisUnitary_apply, singular, mul_assoc, mul_left_comm, mul_comm] using coordinate end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem conjugateUnitaryBasisOverlap_norm_sq {d : ℕ} (U V : Matrix.unitaryGroup (Fin d) ℂ) (i j : Fin d) : ‖unitaryBasisOverlap (conjugateUnitary U) (conjugateUnitary V) i j‖ ^ 2 = ‖unitaryBasisOverlap U V i j‖ ^ 2 := by have hconj : unitaryBasisOverlap (conjugateUnitary U) (conjugateUnitary V) i j = star (unitaryBasisOverlap U V i j) := by simp [unitaryBasisOverlap_apply, Matrix.mul_apply, Matrix.conjTranspose_apply, conjugateUnitary_apply] rw [hconj, norm_star] def targetCanonicalSpectralEnergy {d : ℕ} (ξ ζ : BipartiteUnitVector d) : ℝ := let F := targetReducedDensity ξ let G := targetReducedDensity ζ let hF := targetReducedDensity_posSemidef ξ let hG := targetReducedDensity_posSemidef ζ ∑ i : Fin d, ∑ j : Fin d, (Real.sqrt (hF.isHermitian.eigenvalues i) - Real.sqrt (hG.isHermitian.eigenvalues j)) ^ 2 * spectralAtomOverlap F G hF hG i j theorem targetCanonicalSpectralEnergy_le_of_canonicalSchmidt {d : ℕ} (ξ ζ : BipartiteUnitVector d) (V W : Matrix.unitaryGroup (Fin d) ℂ) (hξ : ξ.val = schmidtVector (fun i => Real.sqrt ((targetReducedDensity_posSemidef ξ).isHermitian.eigenvalues i)) (conjugateUnitary (targetReducedDensity_posSemidef ξ).isHermitian.eigenvectorUnitary) V) (hζ : ζ.val = schmidtVector (fun j => Real.sqrt ((targetReducedDensity_posSemidef ζ).isHermitian.eigenvalues j)) (conjugateUnitary (targetReducedDensity_posSemidef ζ).isHermitian.eigenvectorUnitary) W) : targetCanonicalSpectralEnergy ξ ζ ≤ 2 * ‖ξ.val - ζ.val‖ ^ 2 := by let F := targetReducedDensity ξ let G := targetReducedDensity ζ let hF : F.PosSemidef := targetReducedDensity_posSemidef ξ let hG : G.PosSemidef := targetReducedDensity_posSemidef ζ have hFtrace : Matrix.trace F = 1 := targetReducedDensity_trace ξ have hGtrace : Matrix.trace G = 1 := targetReducedDensity_trace ζ have hσunit : (∑ i : Fin d, (Real.sqrt (hF.isHermitian.eigenvalues i)) ^ 2) = 1 := by simp_rw [Real.sq_sqrt (hF.eigenvalues_nonneg _)] exact positiveDensity_eigenvalues_sum F hF hFtrace have hμunit : (∑ j : Fin d, (Real.sqrt (hG.isHermitian.eigenvalues j)) ^ 2) = 1 := by simp_rw [Real.sq_sqrt (hG.eigenvalues_nonneg _)] exact positiveDensity_eigenvalues_sum G hG hGtrace have henergy := schmidtVector_spectralEnergy_le (fun i => Real.sqrt (hF.isHermitian.eigenvalues i)) (fun j => Real.sqrt (hG.isHermitian.eigenvalues j)) (fun i => Real.sqrt_nonneg _) (fun j => Real.sqrt_nonneg _) hσunit hμunit (conjugateUnitary hF.isHermitian.eigenvectorUnitary) V (conjugateUnitary hG.isHermitian.eigenvectorUnitary) W simp_rw [conjugateUnitaryBasisOverlap_norm_sq, ← targetSpectralAtomOverlap_eq_basis_norm_sq F G hF hG] at henergy change targetCanonicalSpectralEnergy ξ ζ ≤ 2 * ‖ξ.val - ζ.val‖ ^ 2 simpa [targetCanonicalSpectralEnergy, F, G, hF, hG, hξ, hζ] using henergy theorem targetCanonicalSpectralEnergy_le {d : ℕ} (ξ ζ : BipartiteUnitVector d) : targetCanonicalSpectralEnergy ξ ζ ≤ 2 * ‖ξ.val - ζ.val‖ ^ 2 := by obtain ⟨V, hξ⟩ := exists_proofTargetCanonicalSpectralSchmidtDecomposition ξ obtain ⟨W, hζ⟩ := exists_proofTargetCanonicalSpectralSchmidtDecomposition ζ apply targetCanonicalSpectralEnergy_le_of_canonicalSchmidt ξ ζ V W · exact hξ · exact hζ end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 theorem harmonicCoherentSharedResource_inverseAbsorption_distance {d n : ℕ} (U V : Matrix.unitaryGroup (Fin (d * n)) ℂ) (resource : BipartiteUnitVector d) : ‖localUnitaryAction U⁻¹ V⁻¹ (tensorEmbezzlementTarget (n := n) resource) - embezzlementState (d * n)‖ = ‖localUnitaryAction U V (embezzlementState (d * n)) - tensorEmbezzlementTarget (n := n) resource‖ := by have reset : localUnitaryAction U V (localUnitaryAction U⁻¹ V⁻¹ (tensorEmbezzlementTarget (n := n) resource)) = tensorEmbezzlementTarget (n := n) resource := by simpa using (localUnitaryPureResidual_targetLocalInverse_reset U⁻¹ V⁻¹ (tensorEmbezzlementTarget (n := n) resource)) calc _ = ‖localUnitaryAction U V (localUnitaryAction U⁻¹ V⁻¹ (tensorEmbezzlementTarget (n := n) resource) - embezzlementState (d * n))‖ := (localUnitaryAction_norm U V _).symm _ = ‖tensorEmbezzlementTarget (n := n) resource - localUnitaryAction U V (embezzlementState (d * n))‖ := by rw [localUnitaryAction_sub, reset] _ = _ := norm_sub_rev _ _ end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 3072 theorem dSVProjectorSquaredDifference_trace {d : Type*} [Fintype d] [DecidableEq d] (P Q : Matrix d d ℂ) (hP : P * P = P) (hQ : Q * Q = Q) : (Matrix.trace ((P - Q) * (P - Q))).re = (Matrix.trace P).re + (Matrix.trace Q).re - 2 * (Matrix.trace (P * Q)).re := by have complex : Matrix.trace ((P - Q) * (P - Q)) = Matrix.trace P + Matrix.trace Q - 2 * Matrix.trace (P * Q) := by rw [Matrix.sub_mul, Matrix.mul_sub, Matrix.mul_sub, Matrix.trace_sub, Matrix.trace_sub, Matrix.trace_sub, hP, hQ, Matrix.trace_mul_comm Q P] ring rw [complex] simp end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 theorem dSVCanonicalFailurePrefix_card {d : ℕ} (r : Fin (d + 1)) : (Finset.univ.filter (fun i : Fin d => i.val < r.val)).card = r.val := by classical calc (Finset.univ.filter (fun i : Fin d => i.val < r.val)).card = (Finset.range r.val).card := by apply Finset.card_bij (fun i _ => i.val) · intro i member exact Finset.mem_range.mpr (Finset.mem_filter.mp member).2 · intro i _ j _ equal exact Fin.ext equal · intro j member have before : j < r.val := Finset.mem_range.mp member have bounded : j < d := by have endpoint : r.val ≤ d := by omega omega refine ⟨⟨j, bounded⟩, ?_, rfl⟩ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, before⟩ _ = r.val := Finset.card_range _ def dSVCanonicalFailurePrefix {d : ℕ} (r : Fin (d + 1)) : EuclideanSpace ℂ (Fin d × Fin d) := toLp 2 fun q : Fin d × Fin d => if q.1 = q.2 ∧ q.1.val < r.val then 1 else 0 theorem dSVCanonicalFailurePrefix_norm_sq {d : ℕ} (r : Fin (d + 1)) : ‖dSVCanonicalFailurePrefix r‖ ^ 2 = (r.val : ℝ) := by classical rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] change (∑ i : Fin d, ∑ j : Fin d, ‖if i = j ∧ i.val < r.val then (1 : ℂ) else 0‖ ^ 2) = (r.val : ℝ) have atom (i j : Fin d) : ‖if i = j ∧ i.val < r.val then (1 : ℂ) else 0‖ ^ 2 = if i = j then if i.val < r.val then (1 : ℝ) else 0 else 0 := by by_cases same : i = j · subst j by_cases before : i.val < r.val <;> simp [before] · simp [same] simp_rw [atom] have count := dSVCanonicalFailurePrefix_card r simpa [Finset.sum_boole] using congrArg (fun n : ℕ => (n : ℝ)) count end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 7000000 set_option maxRecDepth 3072 theorem dSVProjectorComplement_posSemidef {d : Type*} [Fintype d] [DecidableEq d] (P : Matrix d d ℂ) (positive : P.PosSemidef) (projective : P * P = P) : (1 - P).PosSemidef := by have gram : (1 - P).conjTranspose * (1 - P) = (1 - P) := by rw [Matrix.conjTranspose_sub, Matrix.conjTranspose_one, positive.isHermitian.eq] simp [Matrix.sub_mul, Matrix.mul_sub, projective] rw [← gram] exact Matrix.posSemidef_conjTranspose_mul_self (1 - P) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 3072 theorem dSVCanonicalFailurePrefix_inner {d : ℕ} (r s : Fin (d + 1)) : inner ℂ (dSVCanonicalFailurePrefix r) (dSVCanonicalFailurePrefix s) = (min r.val s.val : ℕ) := by classical rw [EuclideanSpace.inner_eq_star_dotProduct] change (∑ q : Fin d × Fin d, (if q.1 = q.2 ∧ q.1.val < s.val then (1 : ℂ) else 0) * star (if q.1 = q.2 ∧ q.1.val < r.val then (1 : ℂ) else 0)) = (min r.val s.val : ℕ) rw [Fintype.sum_prod_type] change (∑ i : Fin d, ∑ j : Fin d, (if i = j ∧ i.val < s.val then (1 : ℂ) else 0) * star (if i = j ∧ i.val < r.val then (1 : ℂ) else 0)) = (min r.val s.val : ℕ) have atom (i j : Fin d) : (if i = j ∧ i.val < s.val then (1 : ℂ) else 0) * star (if i = j ∧ i.val < r.val then (1 : ℂ) else 0) = if i = j then if i.val < min r.val s.val then (1 : ℂ) else 0 else 0 := by by_cases same : i = j · subst j by_cases belowr : i.val < r.val · by_cases belows : i.val < s.val · simp [belowr, belows] · simp [belowr, belows] · by_cases belows : i.val < s.val · simp [belowr, belows] · simp [belowr, belows] · simp [same] simp_rw [atom] let t : Fin (d + 1) := ⟨min r.val s.val, by have hr : r.val ≤ d := by omega have hs : s.val ≤ d := by omega omega⟩ have counted := dSVCanonicalFailurePrefix_card t have cast_counted := congrArg (fun n : ℕ => (n : ℂ)) counted simpa [t, Finset.sum_boole] using cast_counted theorem dSVCanonicalFailurePrefix_sub_norm_sq {d : ℕ} (r s : Fin (d + 1)) : ‖dSVCanonicalFailurePrefix r - dSVCanonicalFailurePrefix s‖ ^ 2 = |(r.val : ℝ) - (s.val : ℝ)| := by rw [@norm_sub_sq ℂ, dSVCanonicalFailurePrefix_norm_sq, dSVCanonicalFailurePrefix_norm_sq, dSVCanonicalFailurePrefix_inner] change (r.val : ℝ) - 2 * (min r.val s.val : ℕ) + (s.val : ℝ) = |(r.val : ℝ) - (s.val : ℝ)| by_cases order : r.val ≤ s.val · rw [min_eq_left order, abs_of_nonpos] · ring · exact sub_nonpos.mpr (by exact_mod_cast order) · have opposite : s.val ≤ r.val := Nat.le_of_not_ge order rw [min_eq_right opposite, abs_of_nonneg] · ring · exact sub_nonneg.mpr (by exact_mod_cast opposite) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVRankControlledTargetCatalystIndexEquiv {ι : Type*} [Fintype ι] (d n : ℕ) : ((Fin d × ι) × Fin n) ≃ Fin (d * (Fintype.card ι * n)) := (Equiv.prodAssoc (Fin d) ι (Fin n)).trans ((Equiv.prodCongr (Equiv.refl (Fin d)) ((Equiv.prodCongr (Fintype.equivFin ι) (Equiv.refl (Fin n))).trans finProdFinEquiv)).trans finProdFinEquiv) end noncomputable section open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem dSVMixedProjectorSuccessLoss_le_square {d : Type*} [Fintype d] [DecidableEq d] (P R : Matrix d d ℂ) (hcomplement : (1 - P).PosSemidef) (hR : R.PosSemidef) (hPP : P * P = P) (hRR : R * R = R) : (Matrix.trace P).re - (Matrix.trace (P * R)).re ≤ (Matrix.trace ((P - R) * (P - R))).re := by have remainder := trace_mul_posSemidef_nonneg hcomplement hR have square : (Matrix.trace ((P - R) * (P - R))).re = (Matrix.trace P).re + (Matrix.trace R).re - 2 * (Matrix.trace (P * R)).re := by rw [Matrix.sub_mul, Matrix.mul_sub, Matrix.mul_sub, hPP, hRR, Matrix.trace_sub, Matrix.trace_sub, Matrix.trace_sub, Matrix.trace_mul_comm R P] simp [Complex.sub_re] ring have rest : 0 ≤ (Matrix.trace R).re - (Matrix.trace (P * R)).re := by simpa [Matrix.sub_mul, Matrix.trace_sub] using remainder rw [square] linarith theorem dSVWeightedMixedProjectorSuccessLoss_le_square {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq d] (w : κ → ℝ) (nonnegative : ∀ k, 0 ≤ w k) (P R : κ → Matrix d d ℂ) (hcomplement : ∀ k, (1 - P k).PosSemidef) (hR : ∀ k, (R k).PosSemidef) (hPP : ∀ k, P k * P k = P k) (hRR : ∀ k, R k * R k = R k) : (∑ k : κ, w k * (Matrix.trace (P k)).re) - (∑ k : κ, w k * (Matrix.trace (P k * R k)).re) ≤ ∑ k : κ, w k * (Matrix.trace ((P k - R k) * (P k - R k))).re := by rw [← Finset.sum_sub_distrib] apply Finset.sum_le_sum intro k _ rw [← mul_sub] exact mul_le_mul_of_nonneg_left (dSVMixedProjectorSuccessLoss_le_square (P k) (R k) (hcomplement k) (hR k) (hPP k) (hRR k)) (nonnegative k) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVGlobalProjectorBinaryPOVM {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (P : κ → Matrix d d ℂ) (positive : ∀ k, (P k).PosSemidef) (complement : ∀ k, (1 - P k).PosSemidef) : POVM Bool (Σ _ : κ, d) where effect b := Matrix.blockDiagonal' fun k => if b then P k else 1 - P k positive b := by apply posSemidef_blockDiagonal' intro k cases b · exact complement k · exact positive k complete := by classical rw [Fintype.sum_bool] ext ⟨k, i⟩ ⟨l, j⟩ by_cases same : k = l · subst l simp [Matrix.blockDiagonal'_apply, Matrix.one_apply, Matrix.sub_apply] · simp [Matrix.blockDiagonal'_apply, same] theorem dSVGlobalProjectorBinaryPOVM_projective {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (P : κ → Matrix d d ℂ) (positive : ∀ k, (P k).PosSemidef) (complement : ∀ k, (1 - P k).PosSemidef) (projective : ∀ k, P k * P k = P k) (b : Bool) : (dSVGlobalProjectorBinaryPOVM P positive complement).effect b * (dSVGlobalProjectorBinaryPOVM P positive complement).effect b = (dSVGlobalProjectorBinaryPOVM P positive complement).effect b := by change Matrix.blockDiagonal' (fun k => if b then P k else 1 - P k) * Matrix.blockDiagonal' (fun k => if b then P k else 1 - P k) = Matrix.blockDiagonal' (fun k => if b then P k else 1 - P k) rw [← Matrix.blockDiagonal'_mul] apply congrArg (fun A : κ → Matrix d d ℂ => Matrix.blockDiagonal' A) funext k cases b · simp [Matrix.mul_sub, Matrix.sub_mul, projective k] · exact projective k theorem dSVActualGlobalMixedBornSuccess_eq {κ d : Type*} [Fintype κ] [Fintype d] [DecidableEq κ] [DecidableEq d] (τ : κ → ℝ) (k₀ : κ) (i₀ : d) (nonzero : τ k₀ ≠ 0) (P R : κ → Matrix d d ℂ) (hP : ∀ k, (P k).PosSemidef) (hPc : ∀ k, (1 - P k).PosSemidef) (hR : ∀ k, (R k).PosSemidef) (hRc : ∀ k, (1 - R k).PosSemidef) (hPP : ∀ k, P k * P k = P k) (hRR : ∀ k, R k * R k = R k) : binaryJointSuccessProbability (pureDensityMatrix (sharedThresholdResource (d := d) τ) (sharedThresholdResource_norm τ k₀ i₀ nonzero)) (dSVGlobalProjectorBinaryPOVM P hP hPc) (transposePOVM (dSVGlobalProjectorBinaryPOVM R hR hRc)) = (∑ k : κ, τ k ^ 2 * (Matrix.trace (P k * R k)).re) / ((Fintype.card d : ℝ) * ∑ k : κ, τ k ^ 2) := by let A := dSVGlobalProjectorBinaryPOVM P hP hPc let B := transposePOVM (dSVGlobalProjectorBinaryPOVM R hR hRc) let z := sharedThresholdResource (d := d) τ have hz : ‖z‖ = 1 := sharedThresholdResource_norm τ k₀ i₀ nonzero have hA : ∀ b : Bool, A.effect b * A.effect b = A.effect b := dSVGlobalProjectorBinaryPOVM_projective P hP hPc hPP have hB : ∀ b : Bool, B.effect b * B.effect b = B.effect b := transposePOVM_projective (dSVGlobalProjectorBinaryPOVM R hR hRc) (dSVGlobalProjectorBinaryPOVM_projective R hR hRc hRR) change binaryJointSuccessProbability (pureDensityMatrix z hz) A B = _ unfold binaryJointSuccessProbability binaryBornProbability rw [← coherentBinaryJointOutcome_norm_sq A B hA hB z hz true true] change ‖toLp 2 ((Matrix.blockDiagonal' P ⊗ₖ (Matrix.blockDiagonal' R).transpose).mulVec (ofLp (sharedThresholdResource (d := d) τ)))‖ ^ 2 = _ exact sharedThresholdResource_block_action_norm_sq τ P R hP hR hPP hRR end noncomputable section open scoped BigOperators def dSVRationalSoftPass (t x : ℝ) : ℝ := x / (x + t) theorem dSVRationalSoftPass_mem_unit {t x : ℝ} (positive : 0 < t) (nonnegative : 0 ≤ x) : 0 ≤ dSVRationalSoftPass t x ∧ dSVRationalSoftPass t x ≤ 1 := by unfold dSVRationalSoftPass have denominator : 0 < x + t := by linarith constructor · exact div_nonneg nonnegative denominator.le · apply (div_le_iff₀ denominator).mpr linarith theorem dSVRationalSoftPass_sub {t a b : ℝ} (positive : 0 < t) (ha : 0 ≤ a) (hb : 0 ≤ b) : dSVRationalSoftPass t a - dSVRationalSoftPass t b = t * (a - b) / ((a + t) * (b + t)) := by unfold dSVRationalSoftPass have da : a + t ≠ 0 := by linarith have db : b + t ≠ 0 := by linarith field_simp ring theorem dSVRationalSoftPass_lipschitz {t a b : ℝ} (positive : 0 < t) (ha : 0 ≤ a) (hb : 0 ≤ b) : |dSVRationalSoftPass t a - dSVRationalSoftPass t b| ≤ |a - b| / t := by have denominator : 0 < (a + t) * (b + t) := mul_pos (by linarith) (by linarith) rw [dSVRationalSoftPass_sub positive ha hb, abs_div, abs_mul, abs_of_pos positive, abs_of_pos denominator] apply (div_le_iff₀ denominator).mpr rw [div_mul_eq_mul_div] apply (le_div_iff₀ positive).mpr have wide : t ^ 2 ≤ (a + t) * (b + t) := by nlinarith [mul_nonneg ha hb] nlinarith [mul_le_mul_of_nonneg_left wide (abs_nonneg (a - b))] end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 7000000 set_option maxRecDepth 3072 theorem dSVAdaptiveSoft_sqrt_sub_sq_le_abs (a b : ℝ) (ha : 0 ≤ a) (hb : 0 ≤ b) : (Real.sqrt a - Real.sqrt b) ^ 2 ≤ |a - b| := by have sa : 0 ≤ Real.sqrt a := Real.sqrt_nonneg a have sb : 0 ≤ Real.sqrt b := Real.sqrt_nonneg b have square_a : Real.sqrt a ^ 2 = a := Real.sq_sqrt ha have square_b : Real.sqrt b ^ 2 = b := Real.sq_sqrt hb rcases le_total a b with ordered | ordered · rw [abs_of_nonpos (sub_nonpos.mpr ordered)] have roots := Real.sqrt_le_sqrt ordered nlinarith [mul_nonneg sa (sub_nonneg.mpr roots)] · rw [abs_of_nonneg (sub_nonneg.mpr ordered)] have roots := Real.sqrt_le_sqrt ordered nlinarith [mul_nonneg sb (sub_nonneg.mpr roots)] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVSoftBobLeftReducedDensity {d : ℕ} (ζ : BipartiteUnitVector d) : Matrix (Fin d) (Fin d) ℂ := targetCoefficientMatrix ζ * (targetCoefficientMatrix ζ).conjTranspose theorem dSVSoftBobLeftReducedDensity_posSemidef {d : ℕ} (ζ : BipartiteUnitVector d) : (dSVSoftBobLeftReducedDensity ζ).PosSemidef := by exact Matrix.posSemidef_self_mul_conjTranspose (targetCoefficientMatrix ζ) theorem dSVSoftBobLeftReducedDensity_trace {d : ℕ} (ζ : BipartiteUnitVector d) : Matrix.trace (dSVSoftBobLeftReducedDensity ζ) = 1 := by unfold dSVSoftBobLeftReducedDensity calc Matrix.trace (targetCoefficientMatrix ζ * (targetCoefficientMatrix ζ).conjTranspose) = Matrix.trace ((targetCoefficientMatrix ζ).conjTranspose * targetCoefficientMatrix ζ) := Matrix.trace_mul_comm _ _ _ = 1 := targetReducedDensity_trace ζ def dSVOriginalComputationalReindexedUnitary {ι : Type*} [Fintype ι] [DecidableEq ι] {D : ℕ} (e : ι ≃ Fin D) (U : Matrix.unitaryGroup ι ℂ) : Matrix.unitaryGroup (Fin D) ℂ := by classical let M : Matrix ι ι ℂ := U.val refine ⟨(Matrix.reindex e e) M, ?_⟩ rw [Matrix.mem_unitaryGroup_iff'] have compatible : star ((Matrix.reindex e e) M) = (Matrix.reindex e e) (star M) := by ext i j simp [Matrix.star_eq_conjTranspose, Matrix.reindex_apply, Matrix.conjTranspose_apply] rw [compatible] change (Matrix.reindexRingEquiv ℂ e) (star M) * (Matrix.reindexRingEquiv ℂ e) M = 1 rw [← (Matrix.reindexRingEquiv ℂ e).map_mul, (Matrix.mem_unitaryGroup_iff').mp U.property] exact (Matrix.reindexRingEquiv ℂ e).map_one end noncomputable section open scoped BigOperators ComplexOrder def dSVHeterogeneousRealPrefix (continuation : ℕ → ℝ) (k : ℕ) : ℝ := ∏ i ∈ Finset.range k, continuation i theorem dSVHeterogeneousRealPrefix_succ (continuation : ℕ → ℝ) (k : ℕ) : dSVHeterogeneousRealPrefix continuation (k + 1) = dSVHeterogeneousRealPrefix continuation k * continuation k := by simp [dSVHeterogeneousRealPrefix, Finset.prod_range_succ] theorem dSVHeterogeneousRealStopping_escape_identity (continuation : ℕ → ℝ) (N : ℕ) : (∑ k ∈ Finset.range N, dSVHeterogeneousRealPrefix continuation k * (1 - continuation k)) = 1 - dSVHeterogeneousRealPrefix continuation N := by induction N with | zero => simp [dSVHeterogeneousRealPrefix] | succ N ih => simp only [Finset.sum_range_succ, dSVHeterogeneousRealPrefix_succ] linear_combination ih theorem dSVHeterogeneousRealPrefix_nonneg (continuation : ℕ → ℝ) (nonnegative : ∀ k, 0 ≤ continuation k) (k : ℕ) : 0 ≤ dSVHeterogeneousRealPrefix continuation k := by unfold dSVHeterogeneousRealPrefix exact Finset.prod_nonneg (fun i _ => nonnegative i) theorem dSVHeterogeneousRealStopping_escape_budget (continuation escape : ℕ → ℝ) (continuation_nonnegative : ∀ k, 0 ≤ continuation k) (escape_bound : ∀ k, continuation k + escape k ≤ 1) (N : ℕ) : (∑ k ∈ Finset.range N, dSVHeterogeneousRealPrefix continuation k * escape k) ≤ 1 := by have each (k : ℕ) : dSVHeterogeneousRealPrefix continuation k * escape k ≤ dSVHeterogeneousRealPrefix continuation k * (1 - continuation k) := by apply mul_le_mul_of_nonneg_left · linarith [escape_bound k] · exact dSVHeterogeneousRealPrefix_nonneg continuation continuation_nonnegative k calc (∑ k ∈ Finset.range N, dSVHeterogeneousRealPrefix continuation k * escape k) ≤ ∑ k ∈ Finset.range N, dSVHeterogeneousRealPrefix continuation k * (1 - continuation k) := by exact Finset.sum_le_sum (fun k _ => each k) _ = 1 - dSVHeterogeneousRealPrefix continuation N := dSVHeterogeneousRealStopping_escape_identity continuation N _ ≤ 1 := by have := dSVHeterogeneousRealPrefix_nonneg continuation continuation_nonnegative N linarith end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder abbrev DSVUniformDensityThresholdLocalIndex (N d : ℕ) := Σ _ : Fin N, Fin d def dSVUniformDensityThresholdSharedState (N d : ℕ) : EuclideanSpace ℂ (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := sharedThresholdResource (d := Fin d) (fun _ : Fin N => (1 : ℝ)) theorem dSVUniformDensityThresholdRaw_norm_sq (N d : ℕ) : ‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖ ^ 2 = (d : ℝ) * (N : ℝ) := by simpa using sharedThresholdResourceRaw_norm_sq (d := Fin d) (fun _ : Fin N => (1 : ℝ)) theorem dSVUniformDensityThresholdSharedState_norm {N d : ℕ} (grid : 0 < N) (dimension : 0 < d) : ‖dSVUniformDensityThresholdSharedState N d‖ = 1 := by exact sharedThresholdResource_norm (fun _ : Fin N => (1 : ℝ)) ⟨0, grid⟩ ⟨0, dimension⟩ (by norm_num) theorem dSVUniformDensityThresholdSharedState_mismatchedFlag (N d : ℕ) (k l : Fin N) (i j : Fin d) (different : k ≠ l) : dSVUniformDensityThresholdSharedState N d (⟨k, i⟩, ⟨l, j⟩) = 0 := by simp [dSVUniformDensityThresholdSharedState, sharedThresholdResource, sharedThresholdResourceRaw, different] theorem dSVUniformDensityThresholdSharedState_mismatchedWork (N d : ℕ) (k l : Fin N) (i j : Fin d) (different : i ≠ j) : dSVUniformDensityThresholdSharedState N d (⟨k, i⟩, ⟨l, j⟩) = 0 := by simp [dSVUniformDensityThresholdSharedState, sharedThresholdResource, sharedThresholdResourceRaw, different] def dSVUniformDensityThresholdSharedDensity {N d : ℕ} (grid : 0 < N) (dimension : 0 < d) : DensityMatrix (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := pureDensityMatrix (dSVUniformDensityThresholdSharedState N d) (dSVUniformDensityThresholdSharedState_norm grid dimension) theorem dSVUniformDensityThresholdShared_mixedBorn_eq {N d : ℕ} (grid : 0 < N) (dimension : 0 < d) (P R : Fin N → Matrix (Fin d) (Fin d) ℂ) (hP : ∀ k, (P k).PosSemidef) (hPc : ∀ k, (1 - P k).PosSemidef) (hR : ∀ k, (R k).PosSemidef) (hRc : ∀ k, (1 - R k).PosSemidef) (hPP : ∀ k, P k * P k = P k) (hRR : ∀ k, R k * R k = R k) : binaryJointSuccessProbability (dSVUniformDensityThresholdSharedDensity grid dimension) (dSVGlobalProjectorBinaryPOVM P hP hPc) (transposePOVM (dSVGlobalProjectorBinaryPOVM R hR hRc)) = (∑ k : Fin N, (Matrix.trace (P k * R k)).re) / ((d : ℝ) * (N : ℝ)) := by simpa [dSVUniformDensityThresholdSharedDensity, dSVUniformDensityThresholdSharedState] using dSVActualGlobalMixedBornSuccess_eq (fun _ : Fin N => (1 : ℝ)) ⟨0, grid⟩ ⟨0, dimension⟩ (by norm_num) P R hP hPc hR hRc hPP hRR theorem dSVUniformDensityThresholdShared_diagonalBorn_eq {N d : ℕ} (grid : 0 < N) (dimension : 0 < d) (P : Fin N → Matrix (Fin d) (Fin d) ℂ) (hP : ∀ k, (P k).PosSemidef) (hPc : ∀ k, (1 - P k).PosSemidef) (hPP : ∀ k, P k * P k = P k) : binaryJointSuccessProbability (dSVUniformDensityThresholdSharedDensity grid dimension) (dSVGlobalProjectorBinaryPOVM P hP hPc) (transposePOVM (dSVGlobalProjectorBinaryPOVM P hP hPc)) = (∑ k : Fin N, (Matrix.trace (P k)).re) / ((d : ℝ) * (N : ℝ)) := by rw [dSVUniformDensityThresholdShared_mixedBorn_eq grid dimension P P hP hPc hP hPc hPP hPP] simp_rw [hPP] abbrev DSVUniformDensityIndependentHistoryLocalIndex (L N d : ℕ) := Fin L → DSVUniformDensityThresholdLocalIndex N d def dSVUniformDensityIndependentHistoryPairReindex (L N d : ℕ) : EuclideanSpace ℂ (Fin L → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) ≃ₗᵢ[ℂ] EuclideanSpace ℂ (DSVUniformDensityIndependentHistoryLocalIndex L N d × DSVUniformDensityIndependentHistoryLocalIndex L N d) := by classical exact LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ bilateralWorkPairEquiv.symm def dSVUniformDensityIndependentSharedState (L N d : ℕ) : EuclideanSpace ℂ (DSVUniformDensityIndependentHistoryLocalIndex L N d × DSVUniformDensityIndependentHistoryLocalIndex L N d) := dSVUniformDensityIndependentHistoryPairReindex L N d (finiteTensorVector (fun _ : Fin L => dSVUniformDensityThresholdSharedState N d)) theorem dSVUniformDensityIndependentSharedState_apply (L N d : ℕ) (alice bob : DSVUniformDensityIndependentHistoryLocalIndex L N d) : dSVUniformDensityIndependentSharedState L N d (alice, bob) = ∏ j : Fin L, dSVUniformDensityThresholdSharedState N d (alice j, bob j) := by simp [dSVUniformDensityIndependentSharedState, dSVUniformDensityIndependentHistoryPairReindex, LinearIsometryEquiv.piLpCongrLeft_apply, finiteTensorVector, bilateralWorkPairEquiv] theorem dSVUniformDensityIndependentSharedState_norm (L : ℕ) {N d : ℕ} (grid : 0 < N) (dimension : 0 < d) : ‖dSVUniformDensityIndependentSharedState L N d‖ = 1 := by unfold dSVUniformDensityIndependentSharedState rw [LinearIsometryEquiv.norm_map] exact finiteTensorVector_norm (fun _ : Fin L => dSVUniformDensityThresholdSharedState N d) (fun _ => dSVUniformDensityThresholdSharedState_norm grid dimension) end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 7000000 set_option maxRecDepth 3072 def dSVUniformDensitySpectralAtomDiscrepancy {d : ℕ} (ξ ζ : BipartiteUnitVector d) : ℝ := ∑ i : Fin d, ∑ j : Fin d, |targetCanonicalSchmidtCoefficient ξ i ^ 2 - targetCanonicalSchmidtCoefficient ζ j ^ 2| * spectralAtomOverlap (targetReducedDensity ξ) (targetReducedDensity ζ) (targetReducedDensity_posSemidef ξ) (targetReducedDensity_posSemidef ζ) i j def dSVUniformDensitySchmidtSumMass {d : ℕ} (ξ ζ : BipartiteUnitVector d) : ℝ := ∑ i : Fin d, ∑ j : Fin d, (targetCanonicalSchmidtCoefficient ξ i + targetCanonicalSchmidtCoefficient ζ j) ^ 2 * spectralAtomOverlap (targetReducedDensity ξ) (targetReducedDensity ζ) (targetReducedDensity_posSemidef ξ) (targetReducedDensity_posSemidef ζ) i j theorem dSVUniformDensitySchmidtSumMass_le_four {d : ℕ} (ξ ζ : BipartiteUnitVector d) : dSVUniformDensitySchmidtSumMass ξ ζ ≤ 4 := by let F := targetReducedDensity ξ let G := targetReducedDensity ζ let hF : F.PosSemidef := targetReducedDensity_posSemidef ξ let hG : G.PosSemidef := targetReducedDensity_posSemidef ζ let σ := targetCanonicalSchmidtCoefficient ξ let μ := targetCanonicalSchmidtCoefficient ζ let overlap := spectralAtomOverlap F G hF hG have left : (∑ i : Fin d, ∑ j : Fin d, σ i ^ 2 * overlap i j) = 1 := by calc _ = ∑ i : Fin d, σ i ^ 2 := by apply Finset.sum_congr rfl intro i _ rw [← Finset.mul_sum, spectralAtomOverlap_sum_right F G hF hG i] simp _ = 1 := targetCanonicalSchmidtCoefficient_sq_sum ξ have right : (∑ i : Fin d, ∑ j : Fin d, μ j ^ 2 * overlap i j) = 1 := by rw [Finset.sum_comm] calc (∑ j : Fin d, ∑ i : Fin d, μ j ^ 2 * overlap i j) = ∑ j : Fin d, μ j ^ 2 := by apply Finset.sum_congr rfl intro j _ rw [← Finset.mul_sum, spectralAtomOverlap_sum_left F G hF hG j] simp _ = 1 := targetCanonicalSchmidtCoefficient_sq_sum ζ have cross : (∑ i : Fin d, ∑ j : Fin d, σ i * μ j * overlap i j) ≤ 1 := by exact spectralAtomOverlap_schmidtMass_le_one F G hF hG (targetReducedDensity_trace ξ) (targetReducedDensity_trace ζ) have split : dSVUniformDensitySchmidtSumMass ξ ζ = (∑ i : Fin d, ∑ j : Fin d, σ i ^ 2 * overlap i j) + (∑ i : Fin d, ∑ j : Fin d, μ j ^ 2 * overlap i j) + 2 * (∑ i : Fin d, ∑ j : Fin d, σ i * μ j * overlap i j) := by unfold dSVUniformDensitySchmidtSumMass change (∑ i : Fin d, ∑ j : Fin d, (σ i + μ j) ^ 2 * overlap i j) = _ simp_rw [Finset.mul_sum] simp_rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring rw [split, left, right] nlinarith theorem dSVUniformDensitySpectralAtomDiscrepancy_le {d : ℕ} (ξ ζ : BipartiteUnitVector d) : dSVUniformDensitySpectralAtomDiscrepancy ξ ζ ≤ 2 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ := by let F := targetReducedDensity ξ let G := targetReducedDensity ζ let hF : F.PosSemidef := targetReducedDensity_posSemidef ξ let hG : G.PosSemidef := targetReducedDensity_posSemidef ζ let σ := targetCanonicalSchmidtCoefficient ξ let μ := targetCanonicalSchmidtCoefficient ζ let weight : Fin d × Fin d → ℝ := fun ij => spectralAtomOverlap F G hF hG ij.1 ij.2 let f : Fin d × Fin d → ℝ := fun ij => |σ ij.1 - μ ij.2| let g : Fin d × Fin d → ℝ := fun ij => σ ij.1 + μ ij.2 have hweight : ∀ ij, 0 ≤ weight ij := fun ij => spectralAtomOverlap_nonneg F G hF hG ij.1 ij.2 have cauchy := weighted_real_cauchy weight f g hweight have exact_l1 : (∑ ij : Fin d × Fin d, weight ij * f ij * g ij) = dSVUniformDensitySpectralAtomDiscrepancy ξ ζ := by rw [Fintype.sum_prod_type] unfold dSVUniformDensitySpectralAtomDiscrepancy apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ have sum_nonnegative : 0 ≤ σ i + μ j := add_nonneg (targetCanonicalSchmidtCoefficient_nonneg ξ i) (targetCanonicalSchmidtCoefficient_nonneg ζ j) have factor : σ i ^ 2 - μ j ^ 2 = (σ i - μ j) * (σ i + μ j) := by ring rw [factor, abs_mul, abs_of_nonneg sum_nonnegative] dsimp [weight, f, g, F, G, hF, hG, σ, μ] ring have exact_energy : (∑ ij : Fin d × Fin d, weight ij * f ij ^ 2) = targetCanonicalSpectralEnergy ξ ζ := by rw [Fintype.sum_prod_type] unfold targetCanonicalSpectralEnergy dsimp [weight, f, F, G, hF, hG, σ, μ, targetCanonicalSchmidtCoefficient] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ rw [sq_abs] ring have exact_mass : (∑ ij : Fin d × Fin d, weight ij * g ij ^ 2) = dSVUniformDensitySchmidtSumMass ξ ζ := by rw [Fintype.sum_prod_type] unfold dSVUniformDensitySchmidtSumMass apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ dsimp [weight, g, F, G, hF, hG, σ, μ] ring rw [exact_l1, exact_energy, exact_mass] at cauchy have target_energy := targetCanonicalSpectralEnergy_le ξ ζ have sum_mass := dSVUniformDensitySchmidtSumMass_le_four ξ ζ have first : Real.sqrt (targetCanonicalSpectralEnergy ξ ζ) ≤ Real.sqrt 2 * ‖ξ.val - ζ.val‖ := by apply Real.sqrt_le_iff.mpr constructor · positivity · have square_two : Real.sqrt (2 : ℝ) ^ 2 = 2 := Real.sq_sqrt (by norm_num) nlinarith [sq_nonneg ‖ξ.val - ζ.val‖] have second : Real.sqrt (dSVUniformDensitySchmidtSumMass ξ ζ) ≤ 2 := by apply Real.sqrt_le_iff.mpr constructor · norm_num · nlinarith calc _ ≤ Real.sqrt (targetCanonicalSpectralEnergy ξ ζ) * Real.sqrt (dSVUniformDensitySchmidtSumMass ξ ζ) := cauchy _ ≤ (Real.sqrt 2 * ‖ξ.val - ζ.val‖) * 2 := mul_le_mul first second (Real.sqrt_nonneg _) (by positivity) _ = 2 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ := by ring end noncomputable section open scoped BigOperators namespace ClassicalSampling variable {α : Type*} [Fintype α] [DecidableEq α] def markedFirst (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) (permutation : Equiv.Perm α) : α := permutation.symm (rank.symm ((marked.image (fun a => rank (permutation a))).min' (nonempty.image (fun a => rank (permutation a))))) omit [DecidableEq α] in theorem markedFirst_mem (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) (permutation : Equiv.Perm α) : markedFirst rank marked nonempty permutation ∈ marked := by have hmin := (marked.image (fun a => rank (permutation a))).min'_mem (nonempty.image (fun a => rank (permutation a))) obtain ⟨a, ha, heq⟩ := Finset.mem_image.mp hmin simpa [markedFirst, ← heq] using ha omit [DecidableEq α] in theorem markedFirst_rank (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) (permutation : Equiv.Perm α) : rank (permutation (markedFirst rank marked nonempty permutation)) = (marked.image (fun a => rank (permutation a))).min' (nonempty.image (fun a => rank (permutation a))) := by simp [markedFirst] omit [DecidableEq α] in theorem markedFirst_rank_le (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) (permutation : Equiv.Perm α) {a : α} (ha : a ∈ marked) : rank (permutation (markedFirst rank marked nonempty permutation)) ≤ rank (permutation a) := by rw [markedFirst_rank] exact Finset.min'_le _ _ (Finset.mem_image.mpr ⟨a, ha, rfl⟩) omit [DecidableEq α] in theorem markedFirst_eq_of_mem_of_rank_le (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) (permutation : Equiv.Perm α) {a : α} (ha : a ∈ marked) (hle : ∀ b ∈ marked, rank (permutation a) ≤ rank (permutation b)) : markedFirst rank marked nonempty permutation = a := by apply permutation.injective apply rank.injective exact le_antisymm (markedFirst_rank_le rank marked nonempty permutation ha) (hle _ (markedFirst_mem rank marked nonempty permutation)) omit [DecidableEq α] in theorem markedFirst_subset_eq_of_mem (rank : α ≃ Fin (Fintype.card α)) {small large : Finset α} (hsmall : small.Nonempty) (hlarge : large.Nonempty) (permutation : Equiv.Perm α) (hsub : small ⊆ large) (hmem : markedFirst rank large hlarge permutation ∈ small) : markedFirst rank small hsmall permutation = markedFirst rank large hlarge permutation := by apply markedFirst_eq_of_mem_of_rank_le rank small hsmall permutation hmem intro a ha exact markedFirst_rank_le rank large hlarge permutation (hsub ha) theorem markedFirst_eq_iff_union_first_mem_inter (rank : α ≃ Fin (Fintype.card α)) (left right : Finset α) (hleft : left.Nonempty) (hright : right.Nonempty) (permutation : Equiv.Perm α) : markedFirst rank left hleft permutation = markedFirst rank right hright permutation ↔ markedFirst rank (left ∪ right) (hleft.mono Finset.subset_union_left) permutation ∈ left ∩ right := by let hunion : (left ∪ right).Nonempty := hleft.mono Finset.subset_union_left constructor · intro hagree have hfirst : markedFirst rank (left ∪ right) hunion permutation = markedFirst rank left hleft permutation := by apply markedFirst_eq_of_mem_of_rank_le rank (left ∪ right) hunion permutation · exact Finset.mem_union_left right (markedFirst_mem rank left hleft permutation) · intro a ha rcases Finset.mem_union.mp ha with ha | ha · exact markedFirst_rank_le rank left hleft permutation ha · rw [hagree] exact markedFirst_rank_le rank right hright permutation ha apply Finset.mem_inter.mpr constructor · rw [hfirst] exact markedFirst_mem rank left hleft permutation · rw [hfirst, hagree] exact markedFirst_mem rank right hright permutation · intro hcommon have hleft' := markedFirst_subset_eq_of_mem rank hleft hunion permutation Finset.subset_union_left (Finset.mem_inter.mp hcommon).1 have hright' := markedFirst_subset_eq_of_mem rank hright hunion permutation Finset.subset_union_right (Finset.mem_inter.mp hcommon).2 exact hleft'.trans hright'.symm theorem markedFirst_ne_iff_union_first_mem_symmDiff (rank : α ≃ Fin (Fintype.card α)) (left right : Finset α) (hleft : left.Nonempty) (hright : right.Nonempty) (permutation : Equiv.Perm α) : markedFirst rank left hleft permutation ≠ markedFirst rank right hright permutation ↔ markedFirst rank (left ∪ right) (hleft.mono Finset.subset_union_left) permutation ∈ (left \ right) ∪ (right \ left) := by let hunion : (left ∪ right).Nonempty := hleft.mono Finset.subset_union_left let a := markedFirst rank (left ∪ right) hunion permutation have ha : a ∈ left ∪ right := markedFirst_mem rank (left ∪ right) hunion permutation have hagree := markedFirst_eq_iff_union_first_mem_inter rank left right hleft hright permutation change markedFirst rank left hleft permutation ≠ markedFirst rank right hright permutation ↔ a ∈ (left \ right) ∪ (right \ left) constructor · intro hne have hninter : a ∉ left ∩ right := by intro hinter exact hne (hagree.mpr hinter) rcases Finset.mem_union.mp ha with hla | hra · apply Finset.mem_union_left exact Finset.mem_sdiff.mpr ⟨hla, fun hright' => hninter (Finset.mem_inter.mpr ⟨hla, hright'⟩)⟩ · apply Finset.mem_union_right exact Finset.mem_sdiff.mpr ⟨hra, fun hleft' => hninter (Finset.mem_inter.mpr ⟨hleft', hra⟩)⟩ · intro hdiff heq have hinter : a ∈ left ∩ right := hagree.mp heq rcases Finset.mem_union.mp hdiff with hdiff | hdiff · exact (Finset.mem_sdiff.mp hdiff).2 (Finset.mem_inter.mp hinter).2 · exact (Finset.mem_sdiff.mp hdiff).2 (Finset.mem_inter.mp hinter).1 omit [Fintype α] in theorem swap_mem_iff_of_mem {marked : Finset α} {x y : α} (hx : x ∈ marked) (hy : y ∈ marked) (a : α) : Equiv.swap x y a ∈ marked ↔ a ∈ marked := by by_cases hax : a = x · subst a simp [hx, hy] · by_cases hay : a = y · subst a simp [hx, hy] · rw [Equiv.swap_apply_of_ne_of_ne hax hay] theorem markedFirst_swap_trans (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) {x y : α} (hx : x ∈ marked) (hy : y ∈ marked) (permutation : Equiv.Perm α) : markedFirst rank marked nonempty ((Equiv.swap x y).trans permutation) = Equiv.swap x y (markedFirst rank marked nonempty permutation) := by apply markedFirst_eq_of_mem_of_rank_le rank marked nonempty ((Equiv.swap x y).trans permutation) · exact (swap_mem_iff_of_mem hx hy _).mpr (markedFirst_mem rank marked nonempty permutation) · intro a ha have hminimal := markedFirst_rank_le rank marked nonempty permutation ((swap_mem_iff_of_mem hx hy a).mpr ha) simpa [Equiv.trans_apply] using hminimal def firstFiber (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) (a : α) : Finset (Equiv.Perm α) := Finset.univ.filter fun permutation => markedFirst rank marked nonempty permutation = a theorem firstFiber_card_eq (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) {x y : α} (hx : x ∈ marked) (hy : y ∈ marked) : (firstFiber rank marked nonempty x).card = (firstFiber rank marked nonempty y).card := by classical refine Finset.card_bij' (fun permutation _ => (Equiv.swap x y).trans permutation) (fun permutation _ => (Equiv.swap x y).trans permutation) ?_ ?_ ?_ ?_ · intro permutation hpermutation have hfirst : markedFirst rank marked nonempty permutation = x := (Finset.mem_filter.mp hpermutation).2 apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _, ?_⟩ rw [markedFirst_swap_trans rank marked nonempty hx hy permutation, hfirst, Equiv.swap_apply_left] · intro permutation hpermutation have hfirst : markedFirst rank marked nonempty permutation = y := (Finset.mem_filter.mp hpermutation).2 apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _, ?_⟩ rw [markedFirst_swap_trans rank marked nonempty hx hy permutation, hfirst, Equiv.swap_apply_right] · intro permutation _ ext a simp [Equiv.trans_apply] · intro permutation _ ext a simp [Equiv.trans_apply] theorem markedFirst_event_card_mul (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) (event : Finset α) (hevent : event ⊆ marked) : (Finset.univ.filter fun permutation : Equiv.Perm α => markedFirst rank marked nonempty permutation ∈ event).card * marked.card = event.card * Fintype.card (Equiv.Perm α) := by classical obtain ⟨base, hbase⟩ := nonempty have hevent_card : (Finset.univ.filter fun permutation : Equiv.Perm α => markedFirst rank marked ⟨base, hbase⟩ permutation ∈ event).card = event.card * (firstFiber rank marked ⟨base, hbase⟩ base).card := by calc (Finset.univ.filter fun permutation : Equiv.Perm α => markedFirst rank marked ⟨base, hbase⟩ permutation ∈ event).card = ∑ a ∈ event, (firstFiber rank marked ⟨base, hbase⟩ a).card := by symm simpa [firstFiber] using (Finset.sum_card_fiberwise_eq_card_filter (Finset.univ : Finset (Equiv.Perm α)) event (markedFirst rank marked ⟨base, hbase⟩)) _ = event.card * (firstFiber rank marked ⟨base, hbase⟩ base).card := Finset.sum_const_nat fun a ha => firstFiber_card_eq rank marked ⟨base, hbase⟩ (hevent ha) hbase have htotal_card : Fintype.card (Equiv.Perm α) = marked.card * (firstFiber rank marked ⟨base, hbase⟩ base).card := by calc Fintype.card (Equiv.Perm α) = (Finset.univ : Finset (Equiv.Perm α)).card := by simp _ = ∑ a ∈ marked, (firstFiber rank marked ⟨base, hbase⟩ a).card := by simpa [firstFiber] using (Finset.card_eq_sum_card_fiberwise (f := markedFirst rank marked ⟨base, hbase⟩) (s := (Finset.univ : Finset (Equiv.Perm α))) (t := marked) (fun permutation _ => markedFirst_mem rank marked ⟨base, hbase⟩ permutation)) _ = marked.card * (firstFiber rank marked ⟨base, hbase⟩ base).card := Finset.sum_const_nat fun a ha => firstFiber_card_eq rank marked ⟨base, hbase⟩ ha hbase change (Finset.univ.filter fun permutation : Equiv.Perm α => markedFirst rank marked ⟨base, hbase⟩ permutation ∈ event).card * marked.card = event.card * Fintype.card (Equiv.Perm α) rw [hevent_card, htotal_card] ac_rfl theorem sharedPermutation_disagreement_card_mul (rank : α ≃ Fin (Fintype.card α)) (left right : Finset α) (hleft : left.Nonempty) (hright : right.Nonempty) : (Finset.univ.filter fun permutation : Equiv.Perm α => markedFirst rank left hleft permutation ≠ markedFirst rank right hright permutation).card * (left ∪ right).card = ((left \ right) ∪ (right \ left)).card * Fintype.card (Equiv.Perm α) := by classical let hunion : (left ∪ right).Nonempty := hleft.mono Finset.subset_union_left have hsubset : (left \ right) ∪ (right \ left) ⊆ left ∪ right := by intro a ha rcases Finset.mem_union.mp ha with ha | ha · exact Finset.mem_union_left right (Finset.mem_sdiff.mp ha).1 · exact Finset.mem_union_right left (Finset.mem_sdiff.mp ha).1 have hfilter : (Finset.univ.filter fun permutation : Equiv.Perm α => markedFirst rank left hleft permutation ≠ markedFirst rank right hright permutation) = (Finset.univ.filter fun permutation : Equiv.Perm α => markedFirst rank (left ∪ right) hunion permutation ∈ (left \ right) ∪ (right \ left)) := by ext permutation simp only [Finset.mem_filter, Finset.mem_univ, true_and] exact markedFirst_ne_iff_union_first_mem_symmDiff rank left right hleft hright permutation rw [hfilter] exact markedFirst_event_card_mul rank (left ∪ right) hunion ((left \ right) ∪ (right \ left)) hsubset def uniformPermutationProbability (event : Equiv.Perm α → Prop) : ℝ := by classical exact ((Finset.univ.filter fun permutation : Equiv.Perm α => event permutation).card : ℝ) / Fintype.card (Equiv.Perm α) theorem markedFirst_event_probability (rank : α ≃ Fin (Fintype.card α)) (marked : Finset α) (nonempty : marked.Nonempty) (event : Finset α) (hevent : event ⊆ marked) : uniformPermutationProbability (fun permutation : Equiv.Perm α => markedFirst rank marked nonempty permutation ∈ event) = (event.card : ℝ) / marked.card := by classical have hpermutation : 0 < (Fintype.card (Equiv.Perm α) : ℝ) := by exact_mod_cast (Fintype.card_pos_iff.mpr ⟨Equiv.refl α⟩ : 0 < Fintype.card (Equiv.Perm α)) have hmarked : 0 < (marked.card : ℝ) := by exact_mod_cast (Finset.card_pos.mpr nonempty : 0 < marked.card) unfold uniformPermutationProbability apply (div_eq_div_iff hpermutation.ne' hmarked.ne').mpr have hcount := markedFirst_event_card_mul rank marked nonempty event hevent have hreal : ((Finset.univ.filter fun permutation : Equiv.Perm α => markedFirst rank marked nonempty permutation ∈ event).card : ℝ) * (marked.card : ℝ) = (event.card : ℝ) * (Fintype.card (Equiv.Perm α) : ℝ) := by exact_mod_cast hcount simpa only [] using hreal theorem sharedPermutation_disagreement_probability (rank : α ≃ Fin (Fintype.card α)) (left right : Finset α) (hleft : left.Nonempty) (hright : right.Nonempty) : uniformPermutationProbability (fun permutation : Equiv.Perm α => markedFirst rank left hleft permutation ≠ markedFirst rank right hright permutation) = (((left \ right) ∪ (right \ left)).card : ℝ) / (left ∪ right).card := by classical have hpermutation : 0 < (Fintype.card (Equiv.Perm α) : ℝ) := by exact_mod_cast (Fintype.card_pos_iff.mpr ⟨Equiv.refl α⟩ : 0 < Fintype.card (Equiv.Perm α)) have hunion : 0 < ((left ∪ right).card : ℝ) := by exact_mod_cast (Finset.card_pos.mpr (hleft.mono Finset.subset_union_left) : 0 < (left ∪ right).card) unfold uniformPermutationProbability apply (div_eq_div_iff hpermutation.ne' hunion.ne').mpr exact_mod_cast sharedPermutation_disagreement_card_mul rank left right hleft hright theorem sharedPermutation_disagreement_probability_le (rank : α ≃ Fin (Fintype.card α)) (left right : Finset α) (hleft : left.Nonempty) (hright : right.Nonempty) : uniformPermutationProbability (fun permutation : Equiv.Perm α => markedFirst rank left hleft permutation ≠ markedFirst rank right hright permutation) ≤ (((left \ right) ∪ (right \ left)).card : ℝ) / left.card := by rw [sharedPermutation_disagreement_probability rank left right hleft hright] apply div_le_div_of_nonneg_left · positivity · exact_mod_cast (Finset.card_pos.mpr hleft : 0 < left.card) · exact_mod_cast (Finset.card_le_card Finset.subset_union_left : left.card ≤ (left ∪ right).card) def markedTotalVariation (left right : Finset α) : ℝ := (((left \ right) ∪ (right \ left)).card : ℝ) / (2 * (left.card : ℝ)) theorem sharedPermutation_disagreement_probability_le_two_mul_tv (rank : α ≃ Fin (Fintype.card α)) (left right : Finset α) (hleft : left.Nonempty) (hright : right.Nonempty) (_equal_card : left.card = right.card) : uniformPermutationProbability (fun permutation : Equiv.Perm α => markedFirst rank left hleft permutation ≠ markedFirst rank right hright permutation) ≤ 2 * markedTotalVariation left right := by calc uniformPermutationProbability (fun permutation : Equiv.Perm α => markedFirst rank left hleft permutation ≠ markedFirst rank right hright permutation) ≤ (((left \ right) ∪ (right \ left)).card : ℝ) / left.card := sharedPermutation_disagreement_probability_le rank left right hleft hright _ = 2 * markedTotalVariation left right := by unfold markedTotalVariation have hcard : (left.card : ℝ) ≠ 0 := by exact_mod_cast (Finset.card_ne_zero.mpr hleft) field_simp section RationalMarks variable {β : Type*} [Fintype β] [DecidableEq β] def rationalMarked (denominator : ℕ) (numerator : β → ℕ) : Finset (β × Fin denominator) := by classical exact Finset.univ.filter fun point => point.2.val < numerator point.1 theorem rationalMarked_fiber_card (denominator : ℕ) (numerator : β → ℕ) (letter : β) : ((rationalMarked denominator numerator).filter fun point => point.1 = letter).card = min denominator (numerator letter) := by classical calc ((rationalMarked denominator numerator).filter fun point => point.1 = letter).card = (Finset.univ.filter fun copy : Fin denominator => copy.val < numerator letter).card := by refine Finset.card_bij' (fun point _ => point.2) (fun copy _ => (letter, copy)) ?_ ?_ ?_ ?_ · intro point hpoint have hpoint' : point.2.val < numerator point.1 ∧ point.1 = letter := by simpa [rationalMarked] using hpoint apply Finset.mem_filter.mpr exact ⟨Finset.mem_univ _, by simpa [hpoint'.2] using hpoint'.1⟩ · intro copy hcopy have hcopy' : copy.val < numerator letter := (Finset.mem_filter.mp hcopy).2 simp [rationalMarked, hcopy'] · intro point hpoint have hletter : point.1 = letter := (Finset.mem_filter.mp hpoint).2 apply Prod.ext · exact hletter.symm · rfl · intro copy _ rfl _ = min denominator (numerator letter) := by simpa using (Fin.card_filter_val_lt (n := denominator) (m := numerator letter)) omit [DecidableEq β] in theorem rationalNumerator_le_denominator (denominator : ℕ) (numerator : β → ℕ) (normalized : (∑ letter, numerator letter) = denominator) (letter : β) : numerator letter ≤ denominator := by rw [← normalized] exact Finset.single_le_sum (fun a _ => Nat.zero_le (numerator a)) (Finset.mem_univ letter) theorem rationalMarked_card (denominator : ℕ) (numerator : β → ℕ) (normalized : (∑ letter, numerator letter) = denominator) : (rationalMarked denominator numerator).card = denominator := by classical calc (rationalMarked denominator numerator).card = ∑ letter : β, ((rationalMarked denominator numerator).filter fun point => point.1 = letter).card := by simpa using (Finset.card_eq_sum_card_fiberwise (f := fun point : β × Fin denominator => point.1) (s := rationalMarked denominator numerator) (t := (Finset.univ : Finset β)) (fun _ _ => Finset.mem_univ _)) _ = ∑ letter : β, numerator letter := by apply Finset.sum_congr rfl intro letter _ rw [rationalMarked_fiber_card] exact min_eq_right (rationalNumerator_le_denominator denominator numerator normalized letter) _ = denominator := normalized theorem rationalMarked_nonempty (denominator : ℕ) (numerator : β → ℕ) (normalized : (∑ letter, numerator letter) = denominator) (positive : 0 < denominator) : (rationalMarked denominator numerator).Nonempty := by apply Finset.card_pos.mp rw [rationalMarked_card denominator numerator normalized] exact positive theorem rationalMarked_letter_probability (denominator : ℕ) (numerator : β → ℕ) (normalized : (∑ letter, numerator letter) = denominator) (nonempty : (rationalMarked denominator numerator).Nonempty) (rank : (β × Fin denominator) ≃ Fin (Fintype.card (β × Fin denominator))) (letter : β) : uniformPermutationProbability (fun permutation : Equiv.Perm (β × Fin denominator) => (markedFirst rank (rationalMarked denominator numerator) nonempty permutation).1 = letter) = (numerator letter : ℝ) / denominator := by classical let marked := rationalMarked denominator numerator let event := marked.filter fun point => point.1 = letter have hsub : event ⊆ marked := Finset.filter_subset _ _ calc uniformPermutationProbability (fun permutation : Equiv.Perm (β × Fin denominator) => (markedFirst rank marked nonempty permutation).1 = letter) = uniformPermutationProbability (fun permutation : Equiv.Perm (β × Fin denominator) => markedFirst rank marked nonempty permutation ∈ event) := by congr 1 funext permutation apply propext simp [event, markedFirst_mem rank marked nonempty permutation] _ = (event.card : ℝ) / marked.card := markedFirst_event_probability rank marked nonempty event hsub _ = (numerator letter : ℝ) / denominator := by change (((rationalMarked denominator numerator).filter fun point => point.1 = letter).card : ℝ) / (rationalMarked denominator numerator).card = (numerator letter : ℝ) / denominator rw [rationalMarked_fiber_card, min_eq_right (rationalNumerator_le_denominator denominator numerator normalized letter), rationalMarked_card denominator numerator normalized] end RationalMarks end ClassicalSampling namespace Pinsker theorem centered_log_lower_of_one_le {x : ℝ} (hx : 1 ≤ x) : 2 * (x - 1) / (x + 1) ≤ Real.log x := by have hden : 0 < x + 1 := by linarith let t : ℝ := (x - 1) / (x + 1) have ht0 : 0 ≤ t := by exact div_nonneg (sub_nonneg.mpr hx) hden.le have ht1 : t < 1 := by apply (div_lt_one hden).mpr linarith have hratio : (1 + t) / (1 - t) = x := by dsimp [t] field_simp ring have hseries : t ≤ (1 / 2 : ℝ) * Real.log ((1 + t) / (1 - t)) := by simpa using (Real.sum_range_le_log_div ht0 ht1 1) rw [hratio] at hseries dsimp [t] at hseries calc 2 * (x - 1) / (x + 1) = 2 * ((x - 1) / (x + 1)) := by ring _ ≤ Real.log x := by linarith theorem centered_log_upper_of_le_one {x : ℝ} (hx0 : 0 < x) (hx1 : x ≤ 1) : Real.log x ≤ 2 * (x - 1) / (x + 1) := by have hinv : 1 ≤ (1 : ℝ) / x := by apply (le_div_iff₀ hx0).mpr simpa using hx1 have h := centered_log_lower_of_one_le hinv have hratio : 2 * ((1 : ℝ) / x - 1) / ((1 : ℝ) / x + 1) = -(2 * (x - 1) / (x + 1)) := by field_simp ring rw [hratio, Real.log_div (by norm_num : (1 : ℝ) ≠ 0) hx0.ne', Real.log_one] at h linarith def pinskerScalarGap (x : ℝ) : ℝ := InformationTheory.klFun x - 3 * (x - 1) ^ 2 / (2 * (x + 2)) theorem hasDerivAt_pinskerScalarGap {x : ℝ} (hx : 0 < x) : HasDerivAt pinskerScalarGap (Real.log x - 3 * (x - 1) * (x + 5) / (2 * (x + 2) ^ 2)) x := by have hden : 2 * (x + 2) ≠ 0 := by positivity have hnumerator := (((hasDerivAt_id x).sub_const 1).pow 2).const_mul 3 have hdenominator := ((hasDerivAt_id x).add_const 2).const_mul 2 have hquotient := hnumerator.div hdenominator hden have hgap := (InformationTheory.hasDerivAt_klFun hx.ne').sub hquotient have hfunction : (InformationTheory.klFun - (fun y => 3 * ((fun z => id z - 1) ^ 2) y) / (fun y => 2 * (id y + 2))) = pinskerScalarGap := by funext y change InformationTheory.klFun y - 3 * (y - 1) ^ 2 / (2 * (y + 2)) = InformationTheory.klFun y - 3 * (y - 1) ^ 2 / (2 * (y + 2)) rfl rw [hfunction] at hgap apply hgap.congr_deriv dsimp field_simp ring theorem pinsker_rational_coefficient_le {x : ℝ} (hx : 0 < x) : 3 * (x + 5) / (2 * (x + 2) ^ 2) ≤ 2 / (x + 1) := by have hleft : 0 < 2 * (x + 2) ^ 2 := by positivity have hright : 0 < x + 1 := by linarith apply (div_le_div_iff₀ hleft hright).mpr nlinarith [sq_nonneg (x - 1)] theorem pinskerScalarGap_derivative_nonneg {x : ℝ} (hx : 1 ≤ x) : 0 ≤ Real.log x - 3 * (x - 1) * (x + 5) / (2 * (x + 2) ^ 2) := by have hx0 : 0 < x := by linarith have hcoefficient := pinsker_rational_coefficient_le hx0 have hscaled := mul_le_mul_of_nonneg_left hcoefficient (sub_nonneg.mpr hx) have hrational : 3 * (x - 1) * (x + 5) / (2 * (x + 2) ^ 2) ≤ 2 * (x - 1) / (x + 1) := by calc 3 * (x - 1) * (x + 5) / (2 * (x + 2) ^ 2) = (x - 1) * (3 * (x + 5) / (2 * (x + 2) ^ 2)) := by ring _ ≤ (x - 1) * (2 / (x + 1)) := hscaled _ = 2 * (x - 1) / (x + 1) := by ring have hlog := centered_log_lower_of_one_le hx linarith theorem pinskerScalarGap_derivative_nonpos {x : ℝ} (hx0 : 0 < x) (hx1 : x ≤ 1) : Real.log x - 3 * (x - 1) * (x + 5) / (2 * (x + 2) ^ 2) ≤ 0 := by have hcoefficient := pinsker_rational_coefficient_le hx0 have hscaled := mul_le_mul_of_nonpos_left hcoefficient (sub_nonpos.mpr hx1) have hrational : 2 * (x - 1) / (x + 1) ≤ 3 * (x - 1) * (x + 5) / (2 * (x + 2) ^ 2) := by calc 2 * (x - 1) / (x + 1) = (x - 1) * (2 / (x + 1)) := by ring _ ≤ (x - 1) * (3 * (x + 5) / (2 * (x + 2) ^ 2)) := hscaled _ = 3 * (x - 1) * (x + 5) / (2 * (x + 2) ^ 2) := by ring have hlog := centered_log_upper_of_le_one hx0 hx1 linarith theorem pinskerScalarGap_nonneg {x : ℝ} (hx : 0 ≤ x) : 0 ≤ pinskerScalarGap x := by by_cases hzero : x = 0 · subst x norm_num [pinskerScalarGap, InformationTheory.klFun] have hxpos : 0 < x := lt_of_le_of_ne hx (Ne.symm hzero) by_cases hone : 1 ≤ x · let derivative : ℝ → ℝ := fun y => Real.log y - 3 * (y - 1) * (y + 5) / (2 * (y + 2) ^ 2) have hcontinuous : ContinuousOn pinskerScalarGap (Set.Icc 1 x) := by intro y hy have hypos : 0 < y := by have hyone := (Set.mem_Icc.mp hy).1 linarith exact (hasDerivAt_pinskerScalarGap hypos).continuousAt.continuousWithinAt have hmonotone : MonotoneOn pinskerScalarGap (Set.Icc 1 x) := by apply monotoneOn_of_hasDerivWithinAt_nonneg (f' := derivative) (convex_Icc 1 x) hcontinuous · intro y hy have hymem : y ∈ Set.Icc (1 : ℝ) x := interior_subset hy have hypos : 0 < y := by have hyone := (Set.mem_Icc.mp hymem).1 linarith exact (hasDerivAt_pinskerScalarGap hypos).hasDerivWithinAt · intro y hy have hymem : y ∈ Set.Icc (1 : ℝ) x := interior_subset hy exact pinskerScalarGap_derivative_nonneg (Set.mem_Icc.mp hymem).1 have hbound := hmonotone (show (1 : ℝ) ∈ Set.Icc 1 x from ⟨le_rfl, hone⟩) (show x ∈ Set.Icc (1 : ℝ) x from ⟨hone, le_rfl⟩) hone simpa [pinskerScalarGap, InformationTheory.klFun] using hbound · have hxone : x ≤ 1 := le_of_not_ge hone let derivative : ℝ → ℝ := fun y => Real.log y - 3 * (y - 1) * (y + 5) / (2 * (y + 2) ^ 2) have hcontinuous : ContinuousOn pinskerScalarGap (Set.Icc x 1) := by intro y hy have hypos : 0 < y := hxpos.trans_le (Set.mem_Icc.mp hy).1 exact (hasDerivAt_pinskerScalarGap hypos).continuousAt.continuousWithinAt have hantitone : AntitoneOn pinskerScalarGap (Set.Icc x 1) := by apply antitoneOn_of_hasDerivWithinAt_nonpos (f' := derivative) (convex_Icc x 1) hcontinuous · intro y hy have hymem : y ∈ Set.Icc x (1 : ℝ) := interior_subset hy have hypos : 0 < y := hxpos.trans_le (Set.mem_Icc.mp hymem).1 exact (hasDerivAt_pinskerScalarGap hypos).hasDerivWithinAt · intro y hy have hymem : y ∈ Set.Icc x (1 : ℝ) := interior_subset hy have hypos : 0 < y := hxpos.trans_le (Set.mem_Icc.mp hymem).1 exact pinskerScalarGap_derivative_nonpos hypos (Set.mem_Icc.mp hymem).2 have hbound := hantitone (show x ∈ Set.Icc x (1 : ℝ) from ⟨le_rfl, hxone⟩) (show (1 : ℝ) ∈ Set.Icc x 1 from ⟨hxone, le_rfl⟩) hxone simpa [pinskerScalarGap, InformationTheory.klFun] using hbound theorem quadratic_le_klFun {x : ℝ} (hx : 0 ≤ x) : 3 * (x - 1) ^ 2 / (2 * (x + 2)) ≤ InformationTheory.klFun x := by have h := pinskerScalarGap_nonneg hx dsimp [pinskerScalarGap] at h linarith def finiteRelativeEntropy {ι : Type*} [Fintype ι] (p q : ι → ℝ) : ℝ := ∑ i, q i * InformationTheory.klFun (p i / q i) def finiteTotalVariation {ι : Type*} [Fintype ι] (p q : ι → ℝ) : ℝ := (∑ i, |p i - q i|) / 2 theorem quadratic_density_le_weighted_kl {p q : ℝ} (hp : 0 ≤ p) (hq : 0 < q) : 3 * (p - q) ^ 2 / (2 * (p + 2 * q)) ≤ q * InformationTheory.klFun (p / q) := by have hscalar := quadratic_le_klFun (div_nonneg hp hq.le) have hweighted := mul_le_mul_of_nonneg_left hscalar hq.le calc 3 * (p - q) ^ 2 / (2 * (p + 2 * q)) = q * (3 * (p / q - 1) ^ 2 / (2 * (p / q + 2))) := by field_simp [hq.ne'] _ ≤ q * InformationTheory.klFun (p / q) := hweighted theorem finiteRelativeEntropy_eq_log_sum {ι : Type*} [Fintype ι] (p q : ι → ℝ) (hq : ∀ i, 0 < q i) (hp_normalized : (∑ i, p i) = 1) (hq_normalized : (∑ i, q i) = 1) : finiteRelativeEntropy p q = ∑ i, p i * Real.log (p i / q i) := by unfold finiteRelativeEntropy calc (∑ i, q i * InformationTheory.klFun (p i / q i)) = ∑ i, (p i * Real.log (p i / q i) + q i - p i) := by apply Finset.sum_congr rfl intro i _ unfold InformationTheory.klFun field_simp [(hq i).ne'] _ = ∑ i, p i * Real.log (p i / q i) := by rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, hp_normalized, hq_normalized] ring theorem finite_pinsker {ι : Type*} [Fintype ι] (p q : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 < q i) (hp_normalized : (∑ i, p i) = 1) (hq_normalized : (∑ i, q i) = 1) : 2 * (finiteTotalVariation p q) ^ 2 ≤ finiteRelativeEntropy p q := by classical let weight : ι → ℝ := fun i => (p i + 2 * q i) / 3 have hweight : ∀ i, 0 < weight i := by intro i dsimp [weight] have hpi := hp i have hqi := hq i positivity have hweight_sum : (∑ i, weight i) = 1 := by dsimp [weight] calc (∑ i, (p i + 2 * q i) / 3) = ((∑ i, p i) + 2 * (∑ i, q i)) / 3 := by rw [← Finset.sum_div, Finset.sum_add_distrib, ← Finset.mul_sum] _ = 1 := by rw [hp_normalized, hq_normalized]; norm_num have hcauchy : (∑ i, |p i - q i|) ^ 2 ≤ ∑ i, |p i - q i| ^ 2 / weight i := by have h := Finset.sq_sum_div_le_sum_sq_div (Finset.univ : Finset ι) (fun i => |p i - q i|) (g := weight) (fun i _ => hweight i) simpa [hweight_sum] using h have hpoint : ∀ i, |p i - q i| ^ 2 / weight i ≤ 2 * (q i * InformationTheory.klFun (p i / q i)) := by intro i have hdensity := quadratic_density_le_weighted_kl (hp i) (hq i) calc |p i - q i| ^ 2 / weight i = 2 * (3 * (p i - q i) ^ 2 / (2 * (p i + 2 * q i))) := by dsimp [weight] rw [sq_abs] have hden : p i + 2 * q i ≠ 0 := by have hpi := hp i have hqi := hq i positivity field_simp [hden] _ ≤ 2 * (q i * InformationTheory.klFun (p i / q i)) := mul_le_mul_of_nonneg_left hdensity (by norm_num) have hsum : (∑ i, |p i - q i| ^ 2 / weight i) ≤ 2 * finiteRelativeEntropy p q := by calc (∑ i, |p i - q i| ^ 2 / weight i) ≤ ∑ i, 2 * (q i * InformationTheory.klFun (p i / q i)) := Finset.sum_le_sum fun i _ => hpoint i _ = 2 * finiteRelativeEntropy p q := by unfold finiteRelativeEntropy rw [Finset.mul_sum] have hmain : (∑ i, |p i - q i|) ^ 2 ≤ 2 * finiteRelativeEntropy p q := hcauchy.trans hsum unfold finiteTotalVariation nlinarith theorem sum_over_positive_reference_support {ι : Type*} [Fintype ι] (q f : ι → ℝ) (hq : ∀ i, 0 ≤ q i) (hzero : ∀ i, q i = 0 → f i = 0) : (∑ i : {i : ι // 0 < q i}, f i) = ∑ i, f i := by classical calc (∑ i : {i : ι // 0 < q i}, f i) = ∑ i ∈ (Finset.univ.filter fun i : ι => 0 < q i), f i := by simpa using (Finset.sum_subtype_eq_sum_filter (s := (Finset.univ : Finset ι)) (p := fun i : ι => 0 < q i) f) _ = ∑ i, f i := by apply Finset.sum_filter_of_ne intro i _ hfi have hqi : q i ≠ 0 := by intro hqi exact hfi (hzero i hqi) exact lt_of_le_of_ne (hq i) hqi.symm theorem finite_pinsker_of_absolute_continuity {ι : Type*} [Fintype ι] (p q : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 ≤ q i) (absolute_continuity : ∀ i, q i = 0 → p i = 0) (hp_normalized : (∑ i, p i) = 1) (hq_normalized : (∑ i, q i) = 1) : 2 * (finiteTotalVariation p q) ^ 2 ≤ finiteRelativeEntropy p q := by classical let p' : {i : ι // 0 < q i} → ℝ := fun i => p i let q' : {i : ι // 0 < q i} → ℝ := fun i => q i have hp'_nonnegative : ∀ i, 0 ≤ p' i := fun i => hp i have hq'_positive : ∀ i, 0 < q' i := fun i => i.property have hp'_normalized : (∑ i, p' i) = 1 := by change (∑ i : {i : ι // 0 < q i}, p i) = 1 rw [sum_over_positive_reference_support q p hq absolute_continuity, hp_normalized] have hq'_normalized : (∑ i, q' i) = 1 := by change (∑ i : {i : ι // 0 < q i}, q i) = 1 rw [sum_over_positive_reference_support q q hq (fun _ h => h), hq_normalized] have htv : finiteTotalVariation p' q' = finiteTotalVariation p q := by unfold finiteTotalVariation change (∑ i : {i : ι // 0 < q i}, |p i - q i|) / 2 = (∑ i, |p i - q i|) / 2 rw [sum_over_positive_reference_support q (fun i => |p i - q i|) hq] intro i hqi simp [hqi, absolute_continuity i hqi] have hkl : finiteRelativeEntropy p' q' = finiteRelativeEntropy p q := by unfold finiteRelativeEntropy change (∑ i : {i : ι // 0 < q i}, q i * InformationTheory.klFun (p i / q i)) = ∑ i, q i * InformationTheory.klFun (p i / q i) apply sum_over_positive_reference_support q (fun i => q i * InformationTheory.klFun (p i / q i)) hq intro i hqi simp [hqi] have h := finite_pinsker p' q' hp'_nonnegative hq'_positive hp'_normalized hq'_normalized rwa [htv, hkl] at h theorem finiteRelativeEntropy_eq_log_sum_of_absolute_continuity {ι : Type*} [Fintype ι] (p q : ι → ℝ) (hq : ∀ i, 0 ≤ q i) (absolute_continuity : ∀ i, q i = 0 → p i = 0) (hp_normalized : (∑ i, p i) = 1) (hq_normalized : (∑ i, q i) = 1) : finiteRelativeEntropy p q = ∑ i, p i * Real.log (p i / q i) := by unfold finiteRelativeEntropy calc (∑ i, q i * InformationTheory.klFun (p i / q i)) = ∑ i, (p i * Real.log (p i / q i) + q i - p i) := by apply Finset.sum_congr rfl intro i _ by_cases hqi : q i = 0 · simp [hqi, absolute_continuity i hqi] · unfold InformationTheory.klFun have hqpos : 0 < q i := lt_of_le_of_ne (hq i) (Ne.symm hqi) field_simp [hqpos.ne'] _ = ∑ i, p i * Real.log (p i / q i) := by rw [Finset.sum_sub_distrib, Finset.sum_add_distrib, hp_normalized, hq_normalized] ring theorem finite_pinsker_sqrt_of_absolute_continuity {ι : Type*} [Fintype ι] (p q : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 ≤ q i) (absolute_continuity : ∀ i, q i = 0 → p i = 0) (hp_normalized : (∑ i, p i) = 1) (hq_normalized : (∑ i, q i) = 1) : finiteTotalVariation p q ≤ Real.sqrt (finiteRelativeEntropy p q / 2) := by apply Real.le_sqrt_of_sq_le have h := finite_pinsker_of_absolute_continuity p q hp hq absolute_continuity hp_normalized hq_normalized nlinarith end Pinsker namespace ClassicalInformation open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalSampling variable {ι : Type*} [Fintype ι] [DecidableEq ι] def distributionFloorNumerator (denominator : ℕ) (p : ι → ℝ) : ι → ℕ := fun i => Nat.floor (p i * (denominator : ℝ)) def distributionFloorResidual (denominator : ℕ) (p : ι → ℝ) : ℕ := denominator - ∑ i, distributionFloorNumerator denominator p i def distributionRoundedNumerator (base : ι) (denominator : ℕ) (p : ι → ℝ) : ι → ℕ := fun i => distributionFloorNumerator denominator p i + if i = base then distributionFloorResidual denominator p else 0 def distributionFloorProbability (denominator : ℕ) (p : ι → ℝ) : ι → ℝ := fun i => (distributionFloorNumerator denominator p i : ℝ) / denominator def distributionRoundedProbability (base : ι) (denominator : ℕ) (p : ι → ℝ) : ι → ℝ := fun i => (distributionRoundedNumerator base denominator p i : ℝ) / denominator omit [Fintype ι] [DecidableEq ι] in theorem distributionFloorNumerator_cast_le (denominator : ℕ) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (i : ι) : (distributionFloorNumerator denominator p i : ℝ) ≤ p i * denominator := by unfold distributionFloorNumerator exact Nat.floor_le (mul_nonneg (hp i) (Nat.cast_nonneg _)) omit [Fintype ι] [DecidableEq ι] in theorem distributionFloorProbability_le (denominator : ℕ) (positive : 0 < denominator) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (i : ι) : distributionFloorProbability denominator p i ≤ p i := by have hden : 0 < (denominator : ℝ) := by exact_mod_cast positive unfold distributionFloorProbability apply (div_le_iff₀ hden).mpr exact distributionFloorNumerator_cast_le denominator p hp i omit [Fintype ι] [DecidableEq ι] in theorem distributionFloorProbability_error_lt (denominator : ℕ) (positive : 0 < denominator) (p : ι → ℝ) (i : ι) : p i - distributionFloorProbability denominator p i < (1 : ℝ) / denominator := by have hden : 0 < (denominator : ℝ) := by exact_mod_cast positive apply (lt_div_iff₀ hden).mpr have hupper := Nat.lt_floor_add_one (p i * (denominator : ℝ)) unfold distributionFloorProbability distributionFloorNumerator calc (p i - (Nat.floor (p i * (denominator : ℝ)) : ℝ) / (denominator : ℝ)) * (denominator : ℝ) = p i * (denominator : ℝ) - Nat.floor (p i * (denominator : ℝ)) := by field_simp _ < 1 := by linarith omit [DecidableEq ι] in theorem distributionFloorNumerator_sum_le (denominator : ℕ) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (normalized : (∑ i, p i) = 1) : (∑ i, distributionFloorNumerator denominator p i) ≤ denominator := by have hreal : ((∑ i, distributionFloorNumerator denominator p i) : ℝ) ≤ (denominator : ℝ) := by calc ((∑ i, distributionFloorNumerator denominator p i) : ℝ) = ∑ i, (distributionFloorNumerator denominator p i : ℝ) := by simp _ ≤ ∑ i, p i * (denominator : ℝ) := Finset.sum_le_sum fun i _ => distributionFloorNumerator_cast_le denominator p hp i _ = (denominator : ℝ) := by rw [← Finset.sum_mul, normalized] simp exact_mod_cast hreal theorem distributionRoundedNumerator_sum (base : ι) (denominator : ℕ) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (normalized : (∑ i, p i) = 1) : (∑ i, distributionRoundedNumerator base denominator p i) = denominator := by have hfloor := distributionFloorNumerator_sum_le denominator p hp normalized unfold distributionRoundedNumerator rw [Finset.sum_add_distrib] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] unfold distributionFloorResidual omega omit [DecidableEq ι] in theorem distributionFloorResidual_probability_eq_sum (denominator : ℕ) (positive : 0 < denominator) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (normalized : (∑ i, p i) = 1) : (distributionFloorResidual denominator p : ℝ) / denominator = ∑ i, (p i - distributionFloorProbability denominator p i) := by have hfloor := distributionFloorNumerator_sum_le denominator p hp normalized have hden : (denominator : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt positive) unfold distributionFloorResidual distributionFloorProbability rw [Nat.cast_sub hfloor, Nat.cast_sum, Finset.sum_sub_distrib, normalized, ← Finset.sum_div] field_simp theorem distributionRoundedProbability_eq_floor_add (base : ι) (denominator : ℕ) (p : ι → ℝ) (i : ι) : distributionRoundedProbability base denominator p i = distributionFloorProbability denominator p i + if i = base then (distributionFloorResidual denominator p : ℝ) / denominator else 0 := by by_cases hbase : i = base · simp [distributionRoundedProbability, distributionRoundedNumerator, distributionFloorProbability, hbase, Nat.cast_add] ring · simp [distributionRoundedProbability, distributionRoundedNumerator, distributionFloorProbability, hbase] theorem distributionRoundedProbability_totalVariation_le (base : ι) (denominator : ℕ) (positive : 0 < denominator) (p : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (normalized : (∑ i, p i) = 1) : finiteTotalVariation p (distributionRoundedProbability base denominator p) ≤ (Fintype.card ι : ℝ) / denominator := by have hden : 0 < (denominator : ℝ) := by exact_mod_cast positive have hres : 0 ≤ (distributionFloorResidual denominator p : ℝ) / denominator := div_nonneg (Nat.cast_nonneg _) hden.le have hpoint : ∀ i, |p i - distributionRoundedProbability base denominator p i| ≤ (p i - distributionFloorProbability denominator p i) + if i = base then (distributionFloorResidual denominator p : ℝ) / denominator else 0 := by intro i have hdefect : 0 ≤ p i - distributionFloorProbability denominator p i := sub_nonneg.mpr (distributionFloorProbability_le denominator positive p hp i) have htriangle := abs_sub_le (p i) (distributionFloorProbability denominator p i) (distributionRoundedProbability base denominator p i) rw [abs_of_nonneg hdefect] at htriangle have hcorrection : |distributionFloorProbability denominator p i - distributionRoundedProbability base denominator p i| = if i = base then (distributionFloorResidual denominator p : ℝ) / denominator else 0 := by rw [distributionRoundedProbability_eq_floor_add] by_cases hbase : i = base · simp [hbase, abs_of_nonneg hres] · simp [hbase] rw [hcorrection] at htriangle exact htriangle have htv_defect : finiteTotalVariation p (distributionRoundedProbability base denominator p) ≤ ∑ i, (p i - distributionFloorProbability denominator p i) := by calc finiteTotalVariation p (distributionRoundedProbability base denominator p) = (∑ i, |p i - distributionRoundedProbability base denominator p i|) / 2 := rfl _ ≤ (∑ i, ((p i - distributionFloorProbability denominator p i) + if i = base then (distributionFloorResidual denominator p : ℝ) / denominator else 0)) / 2 := by apply (div_le_div_iff_of_pos_right (by norm_num : (0 : ℝ) < 2)).mpr exact Finset.sum_le_sum fun i _ => hpoint i _ = ∑ i, (p i - distributionFloorProbability denominator p i) := by rw [Finset.sum_add_distrib] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] rw [distributionFloorResidual_probability_eq_sum denominator positive p hp normalized] ring calc finiteTotalVariation p (distributionRoundedProbability base denominator p) ≤ ∑ i, (p i - distributionFloorProbability denominator p i) := htv_defect _ ≤ ∑ _i : ι, (1 : ℝ) / denominator := Finset.sum_le_sum fun i _ => (distributionFloorProbability_error_lt denominator positive p i).le _ = (Fintype.card ι : ℝ) / denominator := by simp [div_eq_mul_inv] omit [Fintype ι] [DecidableEq ι] in theorem finite_log_sum_inequality (indices : Finset ι) (p q : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 ≤ q i) (absolute_continuity : ∀ i, q i = 0 → p i = 0) (positive_mass : 0 < ∑ i ∈ indices, q i) : (∑ i ∈ indices, q i) * InformationTheory.klFun ((∑ i ∈ indices, p i) / (∑ i ∈ indices, q i)) ≤ ∑ i ∈ indices, q i * InformationTheory.klFun (p i / q i) := by let total : ℝ := ∑ i ∈ indices, q i have htotal : 0 < total := positive_mass have hnormalized : (∑ i ∈ indices, q i / total) = 1 := by rw [← Finset.sum_div] exact div_self htotal.ne' have hmean : (∑ i ∈ indices, (q i / total) * (p i / q i)) = (∑ i ∈ indices, p i) / total := by calc (∑ i ∈ indices, (q i / total) * (p i / q i)) = ∑ i ∈ indices, p i / total := by apply Finset.sum_congr rfl intro i _ by_cases hqi : q i = 0 · simp [hqi, absolute_continuity i hqi] · field_simp [hqi, htotal.ne'] _ = (∑ i ∈ indices, p i) / total := by rw [Finset.sum_div] have hjensen : InformationTheory.klFun ((∑ i ∈ indices, p i) / total) ≤ ∑ i ∈ indices, (q i / total) * InformationTheory.klFun (p i / q i) := by have h := InformationTheory.convexOn_klFun.map_sum_le (t := indices) (w := fun i => q i / total) (p := fun i => p i / q i) (fun i _ => div_nonneg (hq i) htotal.le) hnormalized (fun i _ => show p i / q i ∈ Set.Ici (0 : ℝ) from div_nonneg (hp i) (hq i)) simpa only [smul_eq_mul, hmean] using h change total * InformationTheory.klFun ((∑ i ∈ indices, p i) / total) ≤ ∑ i ∈ indices, q i * InformationTheory.klFun (p i / q i) calc total * InformationTheory.klFun ((∑ i ∈ indices, p i) / total) ≤ total * (∑ i ∈ indices, (q i / total) * InformationTheory.klFun (p i / q i)) := mul_le_mul_of_nonneg_left hjensen htotal.le _ = ∑ i ∈ indices, q i * InformationTheory.klFun (p i / q i) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ field_simp [htotal.ne'] section CoarseGraining variable {κ : Type*} [Fintype κ] [DecidableEq κ] def groupedMass (map : ι → κ) (p : ι → ℝ) (j : κ) : ℝ := ∑ i ∈ (Finset.univ.filter fun i => map i = j), p i omit [DecidableEq ι] in theorem finite_relative_entropy_data_processing (map : ι → κ) (p q : ι → ℝ) (hp : ∀ i, 0 ≤ p i) (hq : ∀ i, 0 ≤ q i) (absolute_continuity : ∀ i, q i = 0 → p i = 0) : finiteRelativeEntropy (groupedMass map p) (groupedMass map q) ≤ finiteRelativeEntropy p q := by change (∑ j : κ, groupedMass map q j * InformationTheory.klFun (groupedMass map p j / groupedMass map q j)) ≤ ∑ i : ι, q i * InformationTheory.klFun (p i / q i) calc (∑ j : κ, groupedMass map q j * InformationTheory.klFun (groupedMass map p j / groupedMass map q j)) ≤ ∑ j : κ, ∑ i ∈ (Finset.univ.filter fun i => map i = j), q i * InformationTheory.klFun (p i / q i) := by apply Finset.sum_le_sum intro j _ let indices : Finset ι := Finset.univ.filter fun i => map i = j change (∑ i ∈ indices, q i) * InformationTheory.klFun ((∑ i ∈ indices, p i) / (∑ i ∈ indices, q i)) ≤ ∑ i ∈ indices, q i * InformationTheory.klFun (p i / q i) have hreference : 0 ≤ ∑ i ∈ indices, q i := Finset.sum_nonneg (fun i _ => hq i) by_cases hzero : (∑ i ∈ indices, q i) = 0 · rw [hzero, zero_mul] apply Finset.sum_nonneg intro i _ exact mul_nonneg (hq i) (InformationTheory.klFun_nonneg (div_nonneg (hp i) (hq i))) · exact finite_log_sum_inequality indices p q hp hq absolute_continuity (lt_of_le_of_ne hreference (Ne.symm hzero)) _ = ∑ i : ι, q i * InformationTheory.klFun (p i / q i) := by simpa only [] using (Finset.sum_fiberwise (Finset.univ : Finset ι) map (fun i => q i * InformationTheory.klFun (p i / q i))) end CoarseGraining section JointChainRule variable {κ : Type*} [Fintype κ] def jointFirstMarginal (joint : ι × κ → ℝ) : ι → ℝ := fun i => ∑ j : κ, joint (i, j) def jointConditional (joint : ι × κ → ℝ) (i : ι) : κ → ℝ := fun j => joint (i, j) / jointFirstMarginal joint i omit [Fintype ι] [DecidableEq ι] in theorem jointFirstMarginal_nonneg (joint : ι × κ → ℝ) (nonnegative : ∀ point, 0 ≤ joint point) (i : ι) : 0 ≤ jointFirstMarginal joint i := by exact Finset.sum_nonneg (fun j _ => nonnegative (i, j)) omit [DecidableEq ι] in theorem jointFirstMarginal_sum (joint : ι × κ → ℝ) : (∑ i : ι, jointFirstMarginal joint i) = ∑ point : ι × κ, joint point := by exact (Fintype.sum_prod_type joint).symm omit [Fintype ι] [DecidableEq ι] in theorem jointFirstMarginal_absolute_continuity (p q : ι × κ → ℝ) (hq : ∀ point, 0 ≤ q point) (absolute_continuity : ∀ point, q point = 0 → p point = 0) (i : ι) : jointFirstMarginal q i = 0 → jointFirstMarginal p i = 0 := by intro hzero change (∑ j : κ, q (i, j)) = 0 at hzero have hcoordinates : ∀ j : κ, q (i, j) = 0 := by intro j exact (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => hq (i, j))).mp hzero j (Finset.mem_univ j) change (∑ j : κ, p (i, j)) = 0 exact Finset.sum_eq_zero (fun j _ => absolute_continuity (i, j) (hcoordinates j)) omit [Fintype ι] [DecidableEq ι] in theorem jointConditional_sum (joint : ι × κ → ℝ) (i : ι) (nonzero : jointFirstMarginal joint i ≠ 0) : (∑ j : κ, jointConditional joint i j) = 1 := by unfold jointConditional rw [← Finset.sum_div] exact div_self nonzero omit [DecidableEq ι] in theorem finite_relative_entropy_joint_chain_rule (p q : ι × κ → ℝ) (hp : ∀ point, 0 ≤ p point) (hq : ∀ point, 0 ≤ q point) (absolute_continuity : ∀ point, q point = 0 → p point = 0) (hp_normalized : (∑ point, p point) = 1) (hq_normalized : (∑ point, q point) = 1) : finiteRelativeEntropy p q = finiteRelativeEntropy (jointFirstMarginal p) (jointFirstMarginal q) + ∑ i : ι, jointFirstMarginal p i * finiteRelativeEntropy (jointConditional p i) (jointConditional q i) := by have hp_marginal : (∑ i : ι, jointFirstMarginal p i) = 1 := (jointFirstMarginal_sum p).trans hp_normalized have hq_marginal : (∑ i : ι, jointFirstMarginal q i) = 1 := (jointFirstMarginal_sum q).trans hq_normalized have h_marginal_absolute : ∀ i : ι, jointFirstMarginal q i = 0 → jointFirstMarginal p i = 0 := jointFirstMarginal_absolute_continuity p q hq absolute_continuity have h_joint_log : finiteRelativeEntropy p q = ∑ point : ι × κ, p point * Real.log (p point / q point) := finiteRelativeEntropy_eq_log_sum_of_absolute_continuity p q hq absolute_continuity hp_normalized hq_normalized have h_marginal_log : finiteRelativeEntropy (jointFirstMarginal p) (jointFirstMarginal q) = ∑ i : ι, jointFirstMarginal p i * Real.log (jointFirstMarginal p i / jointFirstMarginal q i) := finiteRelativeEntropy_eq_log_sum_of_absolute_continuity (jointFirstMarginal p) (jointFirstMarginal q) (jointFirstMarginal_nonneg q hq) h_marginal_absolute hp_marginal hq_marginal calc finiteRelativeEntropy p q = ∑ point : ι × κ, p point * Real.log (p point / q point) := h_joint_log _ = ∑ i : ι, ∑ j : κ, p (i, j) * Real.log (p (i, j) / q (i, j)) := Fintype.sum_prod_type _ _ = ∑ i : ι, (jointFirstMarginal p i * Real.log (jointFirstMarginal p i / jointFirstMarginal q i) + jointFirstMarginal p i * finiteRelativeEntropy (jointConditional p i) (jointConditional q i)) := by apply Finset.sum_congr rfl intro i _ by_cases hpzero : jointFirstMarginal p i = 0 · have hcoordinates : ∀ j : κ, p (i, j) = 0 := by intro j apply (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => hp (i, j))).mp (show (∑ j : κ, p (i, j)) = 0 from hpzero) j (Finset.mem_univ j) simp [hpzero, hcoordinates] · have hqzero : jointFirstMarginal q i ≠ 0 := by intro hzero exact hpzero (h_marginal_absolute i hzero) have hconditional_absolute : ∀ j : κ, jointConditional q i j = 0 → jointConditional p i j = 0 := by intro j hzero change q (i, j) / jointFirstMarginal q i = 0 at hzero have hpoint : q (i, j) = 0 := by rcases (div_eq_zero_iff.mp hzero) with hpoint | hmarginal · exact hpoint · exact (hqzero hmarginal).elim simp [jointConditional, absolute_continuity (i, j) hpoint] have hconditional_log : finiteRelativeEntropy (jointConditional p i) (jointConditional q i) = ∑ j : κ, jointConditional p i j * Real.log (jointConditional p i j / jointConditional q i j) := by apply finiteRelativeEntropy_eq_log_sum_of_absolute_continuity · intro j exact div_nonneg (hq (i, j)) (jointFirstMarginal_nonneg q hq i) · exact hconditional_absolute · exact jointConditional_sum p i hpzero · exact jointConditional_sum q i hqzero rw [hconditional_log] calc (∑ j : κ, p (i, j) * Real.log (p (i, j) / q (i, j))) = ∑ j : κ, (p (i, j) * Real.log (jointFirstMarginal p i / jointFirstMarginal q i) + jointFirstMarginal p i * (jointConditional p i j * Real.log (jointConditional p i j / jointConditional q i j))) := by apply Finset.sum_congr rfl intro j _ by_cases hpj : p (i, j) = 0 · simp [hpj, jointConditional] · have hqj : q (i, j) ≠ 0 := by intro hzero exact hpj (absolute_continuity (i, j) hzero) have hfactorization : p (i, j) / q (i, j) = (jointFirstMarginal p i / jointFirstMarginal q i) * (jointConditional p i j / jointConditional q i j) := by unfold jointConditional field_simp [hpzero, hqzero, hqj] have hfirst : jointFirstMarginal p i / jointFirstMarginal q i ≠ 0 := div_ne_zero hpzero hqzero have hsecond : jointConditional p i j / jointConditional q i j ≠ 0 := by unfold jointConditional exact div_ne_zero (div_ne_zero hpj hpzero) (div_ne_zero hqj hqzero) rw [hfactorization, Real.log_mul hfirst hsecond] unfold jointConditional field_simp [hpzero] _ = jointFirstMarginal p i * Real.log (jointFirstMarginal p i / jointFirstMarginal q i) + jointFirstMarginal p i * (∑ j : κ, jointConditional p i j * Real.log (jointConditional p i j / jointConditional q i j)) := by rw [Finset.sum_add_distrib, ← Finset.sum_mul, ← Finset.mul_sum] rfl _ = (∑ i : ι, jointFirstMarginal p i * Real.log (jointFirstMarginal p i / jointFirstMarginal q i)) + ∑ i : ι, jointFirstMarginal p i * finiteRelativeEntropy (jointConditional p i) (jointConditional q i) := by rw [Finset.sum_add_distrib] _ = finiteRelativeEntropy (jointFirstMarginal p) (jointFirstMarginal q) + ∑ i : ι, jointFirstMarginal p i * finiteRelativeEntropy (jointConditional p i) (jointConditional q i) := by rw [h_marginal_log] end JointChainRule section SharedPermutationSampling def rationalPermutationOutput (denominator : ℕ) (numerator : ι → ℕ) (nonempty : (rationalMarked denominator numerator).Nonempty) (permutation : Equiv.Perm (ι × Fin denominator)) : ι := (markedFirst (Fintype.equivFin (ι × Fin denominator)) (rationalMarked denominator numerator) nonempty permutation).1 theorem rationalPermutationOutput_probability (denominator : ℕ) (numerator : ι → ℕ) (normalized : (∑ i, numerator i) = denominator) (nonempty : (rationalMarked denominator numerator).Nonempty) (letter : ι) : uniformPermutationProbability (fun permutation : Equiv.Perm (ι × Fin denominator) => rationalPermutationOutput denominator numerator nonempty permutation = letter) = (numerator letter : ℝ) / denominator := by exact rationalMarked_letter_probability denominator numerator normalized nonempty (Fintype.equivFin (ι × Fin denominator)) letter theorem rationalMarked_inter (denominator : ℕ) (left right : ι → ℕ) : rationalMarked denominator left ∩ rationalMarked denominator right = rationalMarked denominator (fun i => min (left i) (right i)) := by ext point simp [rationalMarked] theorem rationalMarked_inter_card (denominator : ℕ) (left right : ι → ℕ) (hleft : (∑ i, left i) = denominator) (_hright : (∑ i, right i) = denominator) : (rationalMarked denominator left ∩ rationalMarked denominator right).card = ∑ i : ι, min (left i) (right i) := by rw [rationalMarked_inter] calc (rationalMarked denominator (fun i => min (left i) (right i))).card = ∑ i : ι, ((rationalMarked denominator (fun i => min (left i) (right i))).filter fun point => point.1 = i).card := by simpa using (Finset.card_eq_sum_card_fiberwise (f := fun point : ι × Fin denominator => point.1) (s := rationalMarked denominator (fun i => min (left i) (right i))) (t := (Finset.univ : Finset ι)) (fun _ _ => Finset.mem_univ _)) _ = ∑ i : ι, min (left i) (right i) := by apply Finset.sum_congr rfl intro i _ rw [rationalMarked_fiber_card, min_eq_right] exact (min_le_left (left i) (right i)).trans (rationalNumerator_le_denominator denominator left hleft i) theorem rationalMarked_markedTotalVariation_eq (denominator : ℕ) (positive : 0 < denominator) (left right : ι → ℕ) (hleft : (∑ i, left i) = denominator) (hright : (∑ i, right i) = denominator) : markedTotalVariation (rationalMarked denominator left) (rationalMarked denominator right) = finiteTotalVariation (fun i => (left i : ℝ) / denominator) (fun i => (right i : ℝ) / denominator) := by let L := rationalMarked denominator left let R := rationalMarked denominator right have hL : L.card = denominator := rationalMarked_card denominator left hleft have hR : R.card = denominator := rationalMarked_card denominator right hright have hI : ((L ∩ R).card : ℝ) = ∑ i : ι, (min (left i) (right i) : ℝ) := by change (((rationalMarked denominator left ∩ rationalMarked denominator right).card : ℕ) : ℝ) = ∑ i : ι, (min (left i) (right i) : ℝ) rw [rationalMarked_inter_card denominator left right hleft hright, Nat.cast_sum] simp only [Nat.cast_min] have hdisjoint : Disjoint (L \ R) (R \ L) := by apply Finset.disjoint_left.mpr intro point hpoint_left hpoint_right exact (Finset.mem_sdiff.mp hpoint_left).2 (Finset.mem_sdiff.mp hpoint_right).1 have hunion : (((L \ R) ∪ (R \ L)).card : ℝ) = ((L \ R).card : ℝ) + ((R \ L).card : ℝ) := by exact_mod_cast (Finset.card_union_of_disjoint hdisjoint) have hleft_difference : ((L \ R).card : ℝ) + ((L ∩ R).card : ℝ) = (L.card : ℝ) := by exact_mod_cast (Finset.card_sdiff_add_card_inter L R) have hright_difference : ((R \ L).card : ℝ) + ((L ∩ R).card : ℝ) = (R.card : ℝ) := by have h := Finset.card_sdiff_add_card_inter R L rw [Finset.inter_comm R L] at h exact_mod_cast h have hsymmetric : (((L \ R) ∪ (R \ L)).card : ℝ) = (denominator : ℝ) + denominator - 2 * ∑ i : ι, (min (left i) (right i) : ℝ) := by have hLreal : (L.card : ℝ) = denominator := by exact_mod_cast hL have hRreal : (R.card : ℝ) = denominator := by exact_mod_cast hR linarith have hpointwise : ∀ i : ι, |(left i : ℝ) / denominator - (right i : ℝ) / denominator| = ((left i : ℝ) + right i - 2 * (min (left i) (right i) : ℝ)) / denominator := by intro i rw [← sub_div, abs_div] have hdenominator_abs : |(denominator : ℝ)| = denominator := abs_of_nonneg (Nat.cast_nonneg denominator) rw [hdenominator_abs] by_cases horder : left i ≤ right i · have hreal : (left i : ℝ) ≤ right i := by exact_mod_cast horder rw [min_eq_left hreal, abs_of_nonpos (sub_nonpos.mpr hreal)] ring · have horder' : right i ≤ left i := (Nat.le_of_lt (Nat.lt_of_not_ge horder)) have hreal : (right i : ℝ) ≤ left i := by exact_mod_cast horder' rw [min_eq_right hreal, abs_of_nonneg (sub_nonneg.mpr hreal)] ring have hleft_real : (∑ i : ι, (left i : ℝ)) = denominator := by exact_mod_cast hleft have hright_real : (∑ i : ι, (right i : ℝ)) = denominator := by exact_mod_cast hright have hdenominator : (denominator : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt positive) change (((L \ R) ∪ (R \ L)).card : ℝ) / (2 * (L.card : ℝ)) = (∑ i : ι, |(left i : ℝ) / denominator - (right i : ℝ) / denominator|) / 2 rw [hsymmetric, hL] simp_rw [hpointwise] rw [← Finset.sum_div, Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum, hleft_real, hright_real] field_simp [hdenominator] theorem uniformPermutationProbability_mono {α : Type*} [Fintype α] [DecidableEq α] (small large : Equiv.Perm α → Prop) (hinclusion : ∀ permutation, small permutation → large permutation) : uniformPermutationProbability small ≤ uniformPermutationProbability large := by classical unfold uniformPermutationProbability apply div_le_div_of_nonneg_right · exact_mod_cast Finset.card_le_card (show (Finset.univ.filter fun permutation : Equiv.Perm α => small permutation) ⊆ (Finset.univ.filter fun permutation : Equiv.Perm α => large permutation) from by intro permutation hpermutation exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hinclusion permutation (Finset.mem_filter.mp hpermutation).2⟩) · exact_mod_cast (Nat.zero_le (Fintype.card (Equiv.Perm α))) theorem rationalPermutationOutput_disagreement_le_two_mul_tv (denominator : ℕ) (left right : ι → ℕ) (hleft : (∑ i, left i) = denominator) (hright : (∑ i, right i) = denominator) (nonempty_left : (rationalMarked denominator left).Nonempty) (nonempty_right : (rationalMarked denominator right).Nonempty) : uniformPermutationProbability (fun permutation : Equiv.Perm (ι × Fin denominator) => rationalPermutationOutput denominator left nonempty_left permutation ≠ rationalPermutationOutput denominator right nonempty_right permutation) ≤ 2 * markedTotalVariation (rationalMarked denominator left) (rationalMarked denominator right) := by let rank := Fintype.equivFin (ι × Fin denominator) calc uniformPermutationProbability (fun permutation : Equiv.Perm (ι × Fin denominator) => rationalPermutationOutput denominator left nonempty_left permutation ≠ rationalPermutationOutput denominator right nonempty_right permutation) ≤ uniformPermutationProbability (fun permutation : Equiv.Perm (ι × Fin denominator) => markedFirst rank (rationalMarked denominator left) nonempty_left permutation ≠ markedFirst rank (rationalMarked denominator right) nonempty_right permutation) := by apply uniformPermutationProbability_mono intro permutation hdifferent hequal apply hdifferent exact congrArg Prod.fst hequal _ ≤ 2 * markedTotalVariation (rationalMarked denominator left) (rationalMarked denominator right) := by apply sharedPermutation_disagreement_probability_le_two_mul_tv calc (rationalMarked denominator left).card = denominator := rationalMarked_card denominator left hleft _ = (rationalMarked denominator right).card := (rationalMarked_card denominator right hright).symm theorem rationalPermutationOutput_disagreement_le_two_mul_finiteTotalVariation (denominator : ℕ) (positive : 0 < denominator) (left right : ι → ℕ) (hleft : (∑ i, left i) = denominator) (hright : (∑ i, right i) = denominator) (nonempty_left : (rationalMarked denominator left).Nonempty) (nonempty_right : (rationalMarked denominator right).Nonempty) : uniformPermutationProbability (fun permutation : Equiv.Perm (ι × Fin denominator) => rationalPermutationOutput denominator left nonempty_left permutation ≠ rationalPermutationOutput denominator right nonempty_right permutation) ≤ 2 * finiteTotalVariation (fun i => (left i : ℝ) / denominator) (fun i => (right i : ℝ) / denominator) := by calc uniformPermutationProbability (fun permutation : Equiv.Perm (ι × Fin denominator) => rationalPermutationOutput denominator left nonempty_left permutation ≠ rationalPermutationOutput denominator right nonempty_right permutation) ≤ 2 * markedTotalVariation (rationalMarked denominator left) (rationalMarked denominator right) := rationalPermutationOutput_disagreement_le_two_mul_tv denominator left right hleft hright nonempty_left nonempty_right _ = 2 * finiteTotalVariation (fun i => (left i : ℝ) / denominator) (fun i => (right i : ℝ) / denominator) := by rw [rationalMarked_markedTotalVariation_eq denominator positive left right hleft hright] end SharedPermutationSampling end ClassicalInformation end noncomputable section open WithLp open scoped BigOperators ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 7000000 set_option maxRecDepth 3072 def dSVUniformLeftDensityConjugateSwapVector {d : ℕ} (z : EuclideanSpace ℂ (Fin d × Fin d)) : EuclideanSpace ℂ (Fin d × Fin d) := toLp 2 (fun ij : Fin d × Fin d => star (z (ij.2, ij.1))) theorem dSVUniformLeftDensityConjugateSwapVector_norm {d : ℕ} (z : EuclideanSpace ℂ (Fin d × Fin d)) : ‖dSVUniformLeftDensityConjugateSwapVector z‖ = ‖z‖ := by have squares : ‖dSVUniformLeftDensityConjugateSwapVector z‖ ^ 2 = ‖z‖ ^ 2 := by rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type, Fintype.sum_prod_type] change (∑ i : Fin d, ∑ j : Fin d, ‖star (z (j, i))‖ ^ 2) = ∑ i : Fin d, ∑ j : Fin d, ‖z (i, j)‖ ^ 2 simp_rw [norm_star] rw [Finset.sum_comm] nlinarith [norm_nonneg (dSVUniformLeftDensityConjugateSwapVector z), norm_nonneg z] theorem dSVUniformLeftDensityConjugateSwapVector_distance {d : ℕ} (z w : EuclideanSpace ℂ (Fin d × Fin d)) : ‖dSVUniformLeftDensityConjugateSwapVector z - dSVUniformLeftDensityConjugateSwapVector w‖ = ‖z - w‖ := by have difference : dSVUniformLeftDensityConjugateSwapVector z - dSVUniformLeftDensityConjugateSwapVector w = dSVUniformLeftDensityConjugateSwapVector (z - w) := by ext ij change star (z (ij.2, ij.1)) - star (w (ij.2, ij.1)) = star ((z - w) (ij.2, ij.1)) simp rw [difference, dSVUniformLeftDensityConjugateSwapVector_norm] def dSVUniformLeftDensityConjugateSwap {d : ℕ} (ξ : BipartiteUnitVector d) : BipartiteUnitVector d := ⟨dSVUniformLeftDensityConjugateSwapVector ξ.val, (dSVUniformLeftDensityConjugateSwapVector_norm ξ.val).trans ξ.property⟩ theorem dSVUniformLeftDensityConjugateSwap_coefficient {d : ℕ} (ξ : BipartiteUnitVector d) : targetCoefficientMatrix (dSVUniformLeftDensityConjugateSwap ξ) = (targetCoefficientMatrix ξ).conjTranspose := by ext b a rfl theorem dSVUniformLeftDensityConjugateSwap_density {d : ℕ} (ξ : BipartiteUnitVector d) : targetReducedDensity (dSVUniformLeftDensityConjugateSwap ξ) = dSVSoftBobLeftReducedDensity ξ := by unfold targetReducedDensity dSVSoftBobLeftReducedDensity rw [dSVUniformLeftDensityConjugateSwap_coefficient, Matrix.conjTranspose_conjTranspose] theorem dSVUniformLeftDensityConjugateSwap_distance {d : ℕ} (ξ ζ : BipartiteUnitVector d) : ‖(dSVUniformLeftDensityConjugateSwap ξ).val - (dSVUniformLeftDensityConjugateSwap ζ).val‖ = ‖ξ.val - ζ.val‖ := dSVUniformLeftDensityConjugateSwapVector_distance ξ.val ζ.val def dSVUniformLeftDensitySchmidtCoefficient {d : ℕ} (ξ : BipartiteUnitVector d) (i : Fin d) : ℝ := Real.sqrt ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) def dSVUniformLeftDensitySpectralAtomDiscrepancy {d : ℕ} (ξ ζ : BipartiteUnitVector d) : ℝ := ∑ i : Fin d, ∑ j : Fin d, |dSVUniformLeftDensitySchmidtCoefficient ξ i ^ 2 - dSVUniformLeftDensitySchmidtCoefficient ζ j ^ 2| * spectralAtomOverlap (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) i j theorem dSVUniformLeftDensitySpectralAtomDiscrepancy_eq_swap {d : ℕ} (ξ ζ : BipartiteUnitVector d) : dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ = dSVUniformDensitySpectralAtomDiscrepancy (dSVUniformLeftDensityConjugateSwap ξ) (dSVUniformLeftDensityConjugateSwap ζ) := by unfold dSVUniformLeftDensitySpectralAtomDiscrepancy dSVUniformDensitySpectralAtomDiscrepancy dSVUniformLeftDensitySchmidtCoefficient targetCanonicalSchmidtCoefficient simp only [dSVUniformLeftDensityConjugateSwap_density] theorem dSVUniformLeftDensitySpectralAtomDiscrepancy_le {d : ℕ} (ξ ζ : BipartiteUnitVector d) : dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ ≤ 2 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ := by rw [dSVUniformLeftDensitySpectralAtomDiscrepancy_eq_swap] have bound := dSVUniformDensitySpectralAtomDiscrepancy_le (dSVUniformLeftDensityConjugateSwap ξ) (dSVUniformLeftDensityConjugateSwap ζ) rwa [dSVUniformLeftDensityConjugateSwap_distance] at bound end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def dSVUniformDensityThresholdGrid (N : ℕ) (k : Fin N) : ℝ := finiteUniformThresholdGrid (1 / (N : ℝ)) (1 + 1 / (N : ℝ)) N k theorem dSVUniformDensityThresholdGrid_apply {N : ℕ} (positive : 0 < N) (k : Fin N) : dSVUniformDensityThresholdGrid N k = ((k.val : ℝ) + 1) / (N : ℝ) := by have nonzero : (N : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt positive) unfold dSVUniformDensityThresholdGrid finiteUniformThresholdGrid field_simp ring def dSVUniformDensityThresholdWeight (N : ℕ) (_k : Fin N) : ℝ := 1 / (N : ℝ) theorem dSVUniformDensityThresholdWeight_nonneg (N : ℕ) (k : Fin N) : 0 ≤ dSVUniformDensityThresholdWeight N k := by unfold dSVUniformDensityThresholdWeight positivity def dSVUniformDensityGridPrefix (N : ℕ) (density : ℝ) : ℝ := ∑ k : Fin N, dSVUniformDensityThresholdWeight N k * if dSVUniformDensityThresholdGrid N k ≤ density then 1 else 0 theorem dSVUniformDensityGridPrefix_eq_count (N : ℕ) (density : ℝ) : dSVUniformDensityGridPrefix N density = ((Finset.univ.filter fun k : Fin N => dSVUniformDensityThresholdGrid N k ≤ density).card : ℝ) / (N : ℝ) := by classical unfold dSVUniformDensityGridPrefix dSVUniformDensityThresholdWeight simp_rw [mul_ite, mul_one, mul_zero] rw [← Finset.sum_filter] simp [div_eq_mul_inv, mul_comm] def dSVUniformDensityThresholdMismatch (N : ℕ) (alice bob : ℝ) : ℝ := ∑ k : Fin N, dSVUniformDensityThresholdWeight N k * if ((dSVUniformDensityThresholdGrid N k ≤ alice) ↔ (dSVUniformDensityThresholdGrid N k ≤ bob)) then 0 else 1 theorem dSVUniformDensityThresholdMismatch_indicator_le_crossing {N : ℕ} (k : Fin N) (alice bob : ℝ) : (if ((dSVUniformDensityThresholdGrid N k ≤ alice) ↔ (dSVUniformDensityThresholdGrid N k ≤ bob)) then (0 : ℝ) else 1) ≤ if min alice bob ≤ dSVUniformDensityThresholdGrid N k ∧ dSVUniformDensityThresholdGrid N k ≤ max alice bob then 1 else 0 := by classical by_cases left : dSVUniformDensityThresholdGrid N k ≤ alice · by_cases right : dSVUniformDensityThresholdGrid N k ≤ bob · simp only [left, right, iff_self, ↓reduceIte] split <;> norm_num · have lower : bob < dSVUniformDensityThresholdGrid N k := lt_of_not_ge right have interval : min alice bob ≤ dSVUniformDensityThresholdGrid N k ∧ dSVUniformDensityThresholdGrid N k ≤ max alice bob := ⟨(min_le_right alice bob).trans lower.le, left.trans (le_max_left alice bob)⟩ simp [left, right, interval] · by_cases right : dSVUniformDensityThresholdGrid N k ≤ bob · have lower : alice < dSVUniformDensityThresholdGrid N k := lt_of_not_ge left have interval : min alice bob ≤ dSVUniformDensityThresholdGrid N k ∧ dSVUniformDensityThresholdGrid N k ≤ max alice bob := ⟨(min_le_left alice bob).trans lower.le, right.trans (le_max_right alice bob)⟩ simp [left, right, interval] · simp [left, right] theorem dSVUniformDensityThresholdMismatch_le {N : ℕ} (positive : 0 < N) (alice bob : ℝ) : dSVUniformDensityThresholdMismatch N alice bob ≤ |alice - bob| + 1 / (N : ℝ) := by classical have window : (1 / (N : ℝ)) < 1 + 1 / (N : ℝ) := by linarith calc dSVUniformDensityThresholdMismatch N alice bob ≤ finiteUniformThresholdCrossing (1 / (N : ℝ)) (1 + 1 / (N : ℝ)) alice bob N := by unfold dSVUniformDensityThresholdMismatch finiteUniformThresholdCrossing calc (∑ k : Fin N, dSVUniformDensityThresholdWeight N k * if ((dSVUniformDensityThresholdGrid N k ≤ alice) ↔ (dSVUniformDensityThresholdGrid N k ≤ bob)) then 0 else 1) ≤ ∑ k : Fin N, dSVUniformDensityThresholdWeight N k * if min alice bob ≤ dSVUniformDensityThresholdGrid N k ∧ dSVUniformDensityThresholdGrid N k ≤ max alice bob then 1 else 0 := by apply Finset.sum_le_sum intro k _ exact mul_le_mul_of_nonneg_left (dSVUniformDensityThresholdMismatch_indicator_le_crossing k alice bob) (dSVUniformDensityThresholdWeight_nonneg N k) _ = _ := by unfold dSVUniformDensityThresholdWeight dSVUniformDensityThresholdGrid simp_rw [mul_ite, mul_one, mul_zero] rw [← Finset.sum_filter] simp [div_eq_mul_inv, mul_comm] _ ≤ |alice - bob| / ((1 + 1 / (N : ℝ)) - (1 / (N : ℝ))) + 1 / (N : ℝ) := finiteUniformThresholdCrossing_le window alice bob N positive _ = |alice - bob| + 1 / (N : ℝ) := by ring theorem dSVUniformDensityThresholdGrid_count_eq_floor {N : ℕ} (positive : 0 < N) (density : ℝ) (nonnegative : 0 ≤ density) (bounded : density ≤ 1) : (Finset.univ.filter fun k : Fin N => dSVUniformDensityThresholdGrid N k ≤ density).card = Nat.floor (density * (N : ℝ)) := by classical have gridpositive : (0 : ℝ) < N := by exact_mod_cast positive have densitypositive : 0 ≤ density * (N : ℝ) := mul_nonneg nonnegative gridpositive.le have floor_bound : Nat.floor (density * (N : ℝ)) ≤ N := by have product : density * (N : ℝ) ≤ (N : ℝ) := by nlinarith have floor := Nat.floor_mono product simpa using floor have same : (Finset.univ.filter fun k : Fin N => dSVUniformDensityThresholdGrid N k ≤ density) = (Finset.univ.filter fun k : Fin N => k.val < Nat.floor (density * (N : ℝ))) := by ext k simp only [Finset.mem_filter, Finset.mem_univ, true_and] rw [dSVUniformDensityThresholdGrid_apply positive, div_le_iff₀ gridpositive] constructor · intro threshold have cast : ((k.val + 1 : ℕ) : ℝ) ≤ density * (N : ℝ) := by simpa using threshold have below := (Nat.le_floor_iff densitypositive).2 cast omega · intro below have integer : k.val + 1 ≤ Nat.floor (density * (N : ℝ)) := by omega have cast := (Nat.le_floor_iff densitypositive).1 integer simpa using cast rw [same, Fin.card_filter_val_lt, min_eq_right floor_bound] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 12000000 set_option maxRecDepth 4096 theorem dSVUniformDensityBinarySpectral_false_eq_complement {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (bin : d → Bool) : (spectralPartitionPOVM F hF bin).effect false = 1 - (spectralPartitionPOVM F hF bin).effect true := by have complete := (spectralPartitionPOVM F hF bin).complete rw [Fintype.sum_bool] at complete rw [add_comm] at complete exact eq_sub_of_add_eq complete end noncomputable section open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem dSVUniformDensitySchmidtVector_sub {d : ℕ} (σ τ : Fin d → ℝ) (U V : Matrix.unitaryGroup (Fin d) ℂ) : schmidtVector σ U V - schmidtVector τ U V = schmidtVector (fun i => σ i - τ i) U V := by unfold schmidtVector rw [← localUnitaryAction_sub] congr 1 ext ⟨i, j⟩ by_cases equal : i = j · subst j simp [diagonalSchmidtState] · simp [diagonalSchmidtState, equal] theorem dSVUniformDensity_normalize_sub_self_norm {d : ℕ} (v : EuclideanSpace ℂ (Fin d × Fin d)) (nonzero : v ≠ 0) : ‖NormedSpace.normalize v - v‖ = |1 - ‖v‖| := by have positive : 0 < ‖v‖ := norm_pos_iff.mpr nonzero calc ‖NormedSpace.normalize v - v‖ = ‖((‖v‖⁻¹ - 1 : ℝ) • v)‖ := by unfold NormedSpace.normalize congr 1 rw [sub_smul, one_smul] _ = |‖v‖⁻¹ - 1| * ‖v‖ := by rw [norm_smul, Real.norm_eq_abs] _ = |(‖v‖⁻¹ - 1) * ‖v‖| := by rw [abs_mul, abs_of_nonneg (norm_nonneg v)] _ = |1 - ‖v‖| := by congr 1 field_simp [positive.ne'] end noncomputable section variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] attribute [local instance] Classical.propDecidable def normalizeOrDefault (fallback z : E) : E := if z = 0 then fallback else NormedSpace.normalize z theorem normalizeOrDefault_norm (fallback z : E) (hfallback : ‖fallback‖ = 1) : ‖normalizeOrDefault fallback z‖ = 1 := by classical by_cases hz : z = 0 · simp [normalizeOrDefault, hz, hfallback] · simp [normalizeOrDefault, hz, NormedSpace.norm_normalize hz] theorem normalizeOrDefault_sub_le (fallback u v : E) (hfallback : ‖fallback‖ = 1) (hu : u ≠ 0) : ‖normalizeOrDefault fallback u - normalizeOrDefault fallback v‖ ≤ 2 * ‖u - v‖ / ‖u‖ := by classical have hupos : 0 < ‖u‖ := norm_pos_iff.mpr hu by_cases hv : v = 0 · simp only [normalizeOrDefault, hu, ↓reduceIte, hv, sub_zero] calc ‖NormedSpace.normalize u - fallback‖ ≤ ‖NormedSpace.normalize u‖ + ‖fallback‖ := norm_sub_le _ _ _ = 2 := by rw [NormedSpace.norm_normalize hu, hfallback]; norm_num _ = 2 * ‖u‖ / ‖u‖ := by field_simp · simp only [normalizeOrDefault, hu, hv, ↓reduceIte] let u₀ := NormedSpace.normalize u let v₀ := NormedSpace.normalize v have hv₀ : ‖v₀‖ = 1 := NormedSpace.norm_normalize hv have hrevu : ‖u‖ • u₀ = u := NormedSpace.norm_smul_normalize u have hrevv : ‖v‖ • v₀ = v := NormedSpace.norm_smul_normalize v have hreverse : |‖v‖ - ‖u‖| ≤ ‖u - v‖ := by simpa [norm_sub_rev] using abs_norm_sub_norm_le v u have hscaled : ‖u‖ * ‖u₀ - v₀‖ = ‖u - ‖u‖ • v₀‖ := by calc ‖u‖ * ‖u₀ - v₀‖ = ‖‖u‖ • (u₀ - v₀)‖ := by rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (norm_nonneg u)] _ = ‖u - ‖u‖ • v₀‖ := by rw [smul_sub, hrevu] have hsecond : ‖v - ‖u‖ • v₀‖ = |‖v‖ - ‖u‖| := by calc ‖v - ‖u‖ • v₀‖ = ‖‖v‖ • v₀ - ‖u‖ • v₀‖ := by rw [hrevv] _ = ‖(‖v‖ - ‖u‖) • v₀‖ := by rw [sub_smul] _ = |‖v‖ - ‖u‖| := by rw [norm_smul, Real.norm_eq_abs, hv₀, mul_one] have hbound : ‖u‖ * ‖u₀ - v₀‖ ≤ 2 * ‖u - v‖ := by rw [hscaled] calc ‖u - ‖u‖ • v₀‖ ≤ ‖u - v‖ + ‖v - ‖u‖ • v₀‖ := by have hsplit : u - ‖u‖ • v₀ = (u - v) + (v - ‖u‖ • v₀) := by abel rw [hsplit] exact norm_add_le _ _ _ = ‖u - v‖ + |‖v‖ - ‖u‖| := by rw [hsecond] _ ≤ 2 * ‖u - v‖ := by linarith change ‖u₀ - v₀‖ ≤ 2 * ‖u - v‖ / ‖u‖ exact (le_div_iff₀ hupos).mpr (by nlinarith) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 3072 def dSVCanonicalFailureUnitRankFamily (d : ℕ) (positive : 0 < d) (rank : Fin (d + 1)) : BipartiteUnitVector d := ⟨normalizeOrDefault (embezzlementState d) (dSVCanonicalFailurePrefix rank), normalizeOrDefault_norm (embezzlementState d) (dSVCanonicalFailurePrefix rank) (embezzlementState_norm d positive)⟩ theorem dSVCanonicalFailurePrefix_eq_zero_of_rank_zero {d : ℕ} (rank : Fin (d + 1)) (zero : rank.val = 0) : dSVCanonicalFailurePrefix rank = 0 := by have squared : ‖dSVCanonicalFailurePrefix rank‖ ^ 2 = 0 := by simpa [zero] using dSVCanonicalFailurePrefix_norm_sq rank have normzero : ‖dSVCanonicalFailurePrefix rank‖ = 0 := by nlinarith [norm_nonneg (dSVCanonicalFailurePrefix rank)] exact norm_eq_zero.mp normzero theorem dSVCanonicalFailurePrefix_norm_eq_sqrt {d : ℕ} (rank : Fin (d + 1)) : ‖dSVCanonicalFailurePrefix rank‖ = Real.sqrt (rank.val : ℝ) := by have squared := dSVCanonicalFailurePrefix_norm_sq rank have root := Real.sq_sqrt (by positivity : 0 ≤ (rank.val : ℝ)) nlinarith [norm_nonneg (dSVCanonicalFailurePrefix rank), Real.sqrt_nonneg (rank.val : ℝ)] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVUniformDensityThresholdLeftBobBasis {d : ℕ} (ζ : BipartiteUnitVector d) : Matrix.unitaryGroup (Fin d) ℂ := (dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvectorUnitary end noncomputable section open WithLp open scoped BigOperators ComplexOrder MatrixOrder def dSVUniformDensityPolarConjugateSwap {d : ℕ} (v : EuclideanSpace ℂ (Fin d × Fin d)) : EuclideanSpace ℂ (Fin d × Fin d) := toLp 2 (fun q : Fin d × Fin d => star (v (q.2, q.1))) theorem dSVUniformDensityPolarConjugateSwap_norm {d : ℕ} (v : EuclideanSpace ℂ (Fin d × Fin d)) : ‖dSVUniformDensityPolarConjugateSwap v‖ = ‖v‖ := by have squares : ‖dSVUniformDensityPolarConjugateSwap v‖ ^ 2 = ‖v‖ ^ 2 := by rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type, Fintype.sum_prod_type] simp only [dSVUniformDensityPolarConjugateSwap, norm_star] exact Finset.sum_comm nlinarith [norm_nonneg (dSVUniformDensityPolarConjugateSwap v), norm_nonneg v] def dSVUniformDensityPolarConjugateSwapTarget {d : ℕ} (ξ : BipartiteUnitVector d) : BipartiteUnitVector d := ⟨dSVUniformDensityPolarConjugateSwap ξ.val, by rw [dSVUniformDensityPolarConjugateSwap_norm] exact ξ.property⟩ theorem dSVUniformDensityPolarConjugateSwap_coefficient {d : ℕ} (ξ : BipartiteUnitVector d) : targetCoefficientMatrix (dSVUniformDensityPolarConjugateSwapTarget ξ) = (targetCoefficientMatrix ξ).conjTranspose := by ext b a rfl theorem dSVUniformDensityPolarConjugateSwap_reducedDensity {d : ℕ} (ξ : BipartiteUnitVector d) : targetReducedDensity (dSVUniformDensityPolarConjugateSwapTarget ξ) = dSVSoftBobLeftReducedDensity ξ := by unfold targetReducedDensity dSVSoftBobLeftReducedDensity rw [dSVUniformDensityPolarConjugateSwap_coefficient] simp def dSVUniformDensityPolarLeftSchmidtCoefficient {d : ℕ} (ξ : BipartiteUnitVector d) (i : Fin d) : ℝ := Real.sqrt ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) theorem exists_proofDSVUniformDensityPolarLeftCanonicalSchmidt {d : ℕ} (ξ : BipartiteUnitVector d) : ∃ A : Matrix.unitaryGroup (Fin d) ℂ, ξ.val = schmidtVector (dSVUniformDensityPolarLeftSchmidtCoefficient ξ) A (dSVUniformDensityThresholdLeftBobBasis ξ) := by let χ := dSVUniformDensityPolarConjugateSwapTarget ξ have density : targetReducedDensity χ = dSVSoftBobLeftReducedDensity ξ := dSVUniformDensityPolarConjugateSwap_reducedDensity ξ obtain ⟨V, decomposition⟩ := exists_proofTargetCanonicalSpectralSchmidtDecomposition χ have canonical_basis : (targetReducedDensity_posSemidef χ).isHermitian.eigenvectorUnitary = dSVUniformDensityThresholdLeftBobBasis ξ := by unfold dSVUniformDensityThresholdLeftBobBasis simp only [density] have canonical_coefficient : targetCanonicalSchmidtCoefficient χ = dSVUniformDensityPolarLeftSchmidtCoefficient ξ := by funext i unfold targetCanonicalSchmidtCoefficient dSVUniformDensityPolarLeftSchmidtCoefficient simp only [density] rw [canonical_basis, canonical_coefficient] at decomposition refine ⟨conjugateUnitary V, ?_⟩ ext ⟨a, b⟩ have coordinate := congrArg (fun v : EuclideanSpace ℂ (Fin d × Fin d) => v (b, a)) decomposition change star (ξ.val (a, b)) = _ at coordinate rw [schmidtVector_apply] at coordinate have unconjugated := congrArg star coordinate rw [schmidtVector_apply] simpa [map_sum, map_mul, conjugateUnitary_apply, mul_assoc, mul_left_comm, mul_comm] using unconjugated end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def finiteTensorLocalUnitaryMatrix {ι β : Type*} [Fintype ι] [Fintype β] [DecidableEq β] (U : ι → Matrix.unitaryGroup β ℂ) : Matrix (ι → β) (ι → β) ℂ := fun q r => ∏ i : ι, (U i : Matrix β β ℂ) (q i) (r i) theorem finiteTensorLocalUnitaryMatrix_gram {ι β : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] [DecidableEq β] (U : ι → Matrix.unitaryGroup β ℂ) : (finiteTensorLocalUnitaryMatrix U).conjTranspose * finiteTensorLocalUnitaryMatrix U = 1 := by classical ext p q change (∑ r : ι → β, star (∏ i : ι, (U i : Matrix β β ℂ) (r i) (p i)) * (∏ i : ι, (U i : Matrix β β ℂ) (r i) (q i))) = (1 : Matrix (ι → β) (ι → β) ℂ) p q have factor : (∑ r : ι → β, star (∏ i : ι, (U i : Matrix β β ℂ) (r i) (p i)) * (∏ i : ι, (U i : Matrix β β ℂ) (r i) (q i))) = ∏ i : ι, ∑ x : β, star ((U i : Matrix β β ℂ) x (p i)) * (U i : Matrix β β ℂ) x (q i) := by calc _ = ∑ r : ι → β, ∏ i : ι, (star ((U i : Matrix β β ℂ) (r i) (p i)) * (U i : Matrix β β ℂ) (r i) (q i)) := by apply Finset.sum_congr rfl intro r _ rw [star_prod, ← Finset.prod_mul_distrib] _ = _ := (Fintype.prod_sum fun i : ι => fun x : β => star ((U i : Matrix β β ℂ) x (p i)) * (U i : Matrix β β ℂ) x (q i)).symm rw [factor] have single (i : ι) : (∑ x : β, star ((U i : Matrix β β ℂ) x (p i)) * (U i : Matrix β β ℂ) x (q i)) = (1 : Matrix β β ℂ) (p i) (q i) := by have gram := (Matrix.mem_unitaryGroup_iff').mp (U i).property have entry := congrArg (fun M : Matrix β β ℂ => M (p i) (q i)) gram simpa [Matrix.star_eq_conjTranspose, Matrix.mul_apply, Matrix.conjTranspose_apply] using entry simp_rw [single] by_cases equal : p = q · subst q simp · have different : ∃ i : ι, p i ≠ q i := by by_contra h push Not at h exact equal (funext h) obtain ⟨i, hi⟩ := different have zero : (∏ j : ι, (1 : Matrix β β ℂ) (p j) (q j)) = 0 := by apply Finset.prod_eq_zero (Finset.mem_univ i) simp [hi] rw [zero] simp [equal] def finiteTensorLocalUnitary {ι β : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] [DecidableEq β] (U : ι → Matrix.unitaryGroup β ℂ) : Matrix.unitaryGroup (ι → β) ℂ := by refine ⟨finiteTensorLocalUnitaryMatrix U, ?_⟩ rw [Matrix.mem_unitaryGroup_iff', Matrix.star_eq_conjTranspose] exact finiteTensorLocalUnitaryMatrix_gram U def controlledFiniteTensorLocalUnitary {Ω ι β : Type*} [Fintype Ω] [DecidableEq Ω] [Fintype ι] [DecidableEq ι] [Fintype β] [DecidableEq β] (U : Ω → ι → Matrix.unitaryGroup β ℂ) : Matrix.unitaryGroup (Σ _ : Ω, (ι → β)) ℂ := coherentSharedRandomControlledUnitary (fun ω => finiteTensorLocalUnitary (U ω)) end noncomputable section open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem controlledFiniteTensorLocalUnitary_apply {Ω ι β : Type*} [Fintype Ω] [DecidableEq Ω] [Fintype ι] [DecidableEq ι] [Fintype β] [DecidableEq β] (U : Ω → ι → Matrix.unitaryGroup β ℂ) (ω ν : Ω) (q r : ι → β) : (controlledFiniteTensorLocalUnitary U : Matrix (Σ _ : Ω, (ι → β)) (Σ _ : Ω, (ι → β)) ℂ) ⟨ω, q⟩ ⟨ν, r⟩ = if ω = ν then ∏ i : ι, (U ω i : Matrix β β ℂ) (q i) (r i) else 0 := by classical by_cases equal : ω = ν · subst ν simp [controlledFiniteTensorLocalUnitary, coherentSharedRandomControlledUnitary, finiteTensorLocalUnitary, finiteTensorLocalUnitaryMatrix, Matrix.blockDiagonal'_apply] · simp [controlledFiniteTensorLocalUnitary, coherentSharedRandomControlledUnitary, Matrix.blockDiagonal'_apply, equal] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder abbrev DSVUniformDensityThresholdWholeHistoryLocalIndex (N d L : ℕ) := Σ _ : Fin (L + 1), Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d abbrev DSVUniformDensityThresholdWholeHistoryCatalystIndex (N d L : ℕ) := Fin N × (Fin (L + 1) × (Fin L → DSVUniformDensityThresholdLocalIndex N d)) def dSVUniformDensityThresholdWholeHistorySharedState (N d L : ℕ) : EuclideanSpace ℂ (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) := sharedThresholdResource (d := Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d) (fun flag : Fin (L + 1) => if flag.val = 0 then (1 : ℝ) else 0) theorem dSVUniformDensityThresholdWholeHistorySharedState_norm {N d : ℕ} (grid : 0 < N) (dimension : 0 < d) (L : ℕ) : ‖dSVUniformDensityThresholdWholeHistorySharedState N d L‖ = 1 := by let k : Fin (L + 1) := ⟨0, by omega⟩ let i : Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d := fun _ => ⟨⟨0, grid⟩, ⟨0, dimension⟩⟩ apply sharedThresholdResource_norm (fun flag : Fin (L + 1) => if flag.val = 0 then (1 : ℝ) else 0) k i simp [k] def dSVUniformDensityThresholdWholeHistoryTargetSplitEquiv (N d L : ℕ) : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L ≃ (Fin d × DSVUniformDensityThresholdWholeHistoryCatalystIndex N d L) where toFun q := ((q.2 0).2, ((q.2 0).1, (q.1, fun j => q.2 j.succ))) invFun q := ⟨q.2.2.1, Fin.cons (⟨q.2.1, q.1⟩ : DSVUniformDensityThresholdLocalIndex N d) q.2.2.2⟩ left_inv := by rintro ⟨flag, history⟩ change (⟨flag, Fin.cons (history 0) (fun j => history j.succ)⟩ : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) = ⟨flag, history⟩ congr 1 exact Fin.cons_self_tail history right_inv := by rintro ⟨target, threshold, flag, history⟩ simp def dSVUniformDensityAliceHistorySpectralCopy {N d : ℕ} (ξ : BipartiteUnitVector d) : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ := coherentSharedRandomControlledUnitary (fun _ : Fin N => (dSVUniformDensityThresholdLeftBobBasis ξ)⁻¹) def dSVUniformDensityBobHistoryCopyBasis {N d : ℕ} (ζ : BipartiteUnitVector d) : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ := coherentSharedRandomControlledUnitary (fun _ : Fin N => conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis ζ)) theorem dSVUniformDensityCompletePureHistory_raw_norm (N d L : ℕ) : ‖sharedThresholdResourceRaw (d := Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d) (fun flag : Fin (L + 1) => if flag.val = 0 then (1 : ℝ) else 0)‖ = ‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖ ^ (L + 1) := by let single := sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ)) let whole := sharedThresholdResourceRaw (d := Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d) (fun flag : Fin (L + 1) => if flag.val = 0 then (1 : ℝ) else 0) have hsquare : ‖single‖ ^ 2 = (d : ℝ) * (N : ℝ) := dSVUniformDensityThresholdRaw_norm_sq N d have hwhole : ‖whole‖ ^ 2 = (((N * d) ^ (L + 1) : ℕ) : ℝ) := by have original := sharedThresholdResourceRaw_norm_sq (d := Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d) (fun flag : Fin (L + 1) => if flag.val = 0 then (1 : ℝ) else 0) simpa [DSVUniformDensityThresholdLocalIndex, whole] using original have hpower : (‖single‖ ^ (L + 1)) ^ 2 = (((N * d) ^ (L + 1) : ℕ) : ℝ) := by calc (‖single‖ ^ (L + 1)) ^ 2 = (‖single‖ ^ 2) ^ (L + 1) := by simp [← pow_mul, Nat.mul_comm] _ = (((N * d) ^ (L + 1) : ℕ) : ℝ) := by rw [hsquare] push_cast ring change ‖whole‖ = ‖single‖ ^ (L + 1) nlinarith [norm_nonneg whole, pow_nonneg (norm_nonneg single) (L + 1)] theorem dSVUniformDensityCompletePureHistory_zeroFlag_apply (N d L : ℕ) (flag other : Fin (L + 1)) (alice bob : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d) : dSVUniformDensityThresholdWholeHistorySharedState N d L (⟨flag, alice⟩, ⟨other, bob⟩) = if flag.val = 0 ∧ other.val = 0 then dSVUniformDensityIndependentSharedState (L + 1) N d (alice, bob) else 0 := by classical let single := sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ)) let whole := sharedThresholdResourceRaw (d := Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d) (fun k : Fin (L + 1) => if k.val = 0 then (1 : ℝ) else 0) have normalization : ‖whole‖ = ‖single‖ ^ (L + 1) := dSVUniformDensityCompletePureHistory_raw_norm N d L have scalar : ‖whole‖⁻¹ = (‖single‖⁻¹) ^ (L + 1) := by rw [normalization, inv_pow] by_cases first_zero : flag = 0 · subst flag by_cases second_zero : other = 0 · subst other simp only [and_self] rw [dSVUniformDensityIndependentSharedState_apply] by_cases histories : alice = bob · subst bob have complex_scalar : ((‖whole‖⁻¹ : ℝ) : ℂ) = (((‖single‖⁻¹) ^ (L + 1) : ℝ) : ℂ) := by exact_mod_cast scalar have whole_amplitude : dSVUniformDensityThresholdWholeHistorySharedState N d L (⟨0, alice⟩, ⟨0, alice⟩) = ((‖whole‖⁻¹ : ℝ) : ℂ) := by simp [dSVUniformDensityThresholdWholeHistorySharedState, sharedThresholdResource, sharedThresholdResourceRaw, whole] have single_amplitude (q : DSVUniformDensityThresholdLocalIndex N d) : dSVUniformDensityThresholdSharedState N d (q, q) = ((‖single‖⁻¹ : ℝ) : ℂ) := by simp [dSVUniformDensityThresholdSharedState, sharedThresholdResource, sharedThresholdResourceRaw, single] rw [whole_amplitude] simp_rw [single_amplitude] simpa using complex_scalar · obtain ⟨j, different⟩ : ∃ j : Fin (L + 1), alice j ≠ bob j := by by_contra absent push Not at absent exact histories (funext absent) have zero : dSVUniformDensityThresholdSharedState N d (alice j, bob j) = 0 := by by_cases labels : (alice j).1 = (bob j).1 · have works : (alice j).2 ≠ (bob j).2 := by intro same apply different exact Sigma.ext labels (by simpa using same) exact dSVUniformDensityThresholdSharedState_mismatchedWork N d (alice j).1 (bob j).1 (alice j).2 (bob j).2 works · exact dSVUniformDensityThresholdSharedState_mismatchedFlag N d (alice j).1 (bob j).1 (alice j).2 (bob j).2 labels have product_zero : (∏ i : Fin (L + 1), dSVUniformDensityThresholdSharedState N d (alice i, bob i)) = 0 := Finset.prod_eq_zero (Finset.mem_univ j) zero rw [product_zero] simp [dSVUniformDensityThresholdWholeHistorySharedState, sharedThresholdResource, sharedThresholdResourceRaw, histories] · have nonzero : other.val ≠ 0 := by simpa using second_zero have different : (0 : Fin (L + 1)) ≠ other := by exact Ne.symm second_zero simp [dSVUniformDensityThresholdWholeHistorySharedState, sharedThresholdResource, sharedThresholdResourceRaw, different, nonzero] · have nonzero : flag.val ≠ 0 := by simpa using first_zero simp [dSVUniformDensityThresholdWholeHistorySharedState, sharedThresholdResource, sharedThresholdResourceRaw, first_zero, nonzero] end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace def scalarPurificationLp (z : ℝ) (hz : 0 ≤ z) : Lp ℂ 2 (volume.restrict (Ioi (0 : ℝ))) := ((scalarResolventFilter_memLp_two hz).ofReal (K := ℂ)).toLp (fun s : ℝ => ((z / (z + s) : ℝ) : ℂ)) theorem scalarPurificationLp_coeFn (z : ℝ) (hz : 0 ≤ z) : (scalarPurificationLp z hz : ℝ → ℂ) =ᵐ[volume.restrict (Ioi 0)] (fun s : ℝ => ((z / (z + s) : ℝ) : ℂ)) := ((scalarResolventFilter_memLp_two hz).ofReal (K := ℂ)).coeFn_toLp def commonPurificationGenerator {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : Sum (ι × d) d → Lp ℂ 2 (volume.restrict (Ioi (0 : ℝ))) | .inl (i, k) => scalarPurificationLp ((positive i).isHermitian.eigenvalues k) ((positive i).eigenvalues_nonneg k) | .inr k => scalarPurificationLp (hM.isHermitian.eigenvalues k) (hM.eigenvalues_nonneg k) def commonPurificationSubspace {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : Submodule ℂ (Lp ℂ 2 (volume.restrict (Ioi (0 : ℝ)))) := Submodule.span ℂ (Set.range (commonPurificationGenerator F M positive hM)) theorem commonPurificationSubspace_finiteDimensional {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : FiniteDimensional ℂ (commonPurificationSubspace F M positive hM) := by unfold commonPurificationSubspace exact FiniteDimensional.span_of_finite ℂ (Set.finite_range (commonPurificationGenerator F M positive hM)) theorem ensemble_scalarPurificationLp_mem_common {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (i : ι) (k : d) : scalarPurificationLp ((positive i).isHermitian.eigenvalues k) ((positive i).eigenvalues_nonneg k) ∈ commonPurificationSubspace F M positive hM := by apply Submodule.subset_span exact ⟨Sum.inl (i, k), rfl⟩ theorem mean_scalarPurificationLp_mem_common {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (k : d) : scalarPurificationLp (hM.isHermitian.eigenvalues k) (hM.eigenvalues_nonneg k) ∈ commonPurificationSubspace F M positive hM := by apply Submodule.subset_span exact ⟨Sum.inr k, rfl⟩ end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise InnerProductSpace set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace def spectralPurificationFilterEntryLp {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (i j : d) : Lp ℂ 2 (volume.restrict (Ioi (0 : ℝ))) := (((spectralPurificationFilter_memLp_two F hF).eval i).eval j).toLp (fun s : ℝ => spectralPurificationFilter F hF s i j) theorem spectralPurificationFilterEntryLp_coeFn {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (i j : d) : (spectralPurificationFilterEntryLp F hF i j : ℝ → ℂ) =ᵐ[volume.restrict (Ioi 0)] (fun s : ℝ => spectralPurificationFilter F hF s i j) := (((spectralPurificationFilter_memLp_two F hF).eval i).eval j).coeFn_toLp theorem spectralPurificationFilterEntryLp_eq_eigen_sum {d : Type*} [Fintype d] [DecidableEq d] (F : Matrix d d ℂ) (hF : F.PosSemidef) (i j : d) : spectralPurificationFilterEntryLp F hF i j = ∑ k : d, (((hF.isHermitian.eigenvectorUnitary : Matrix d d ℂ) i k) * (star (hF.isHermitian.eigenvectorUnitary : Matrix d d ℂ)) k j) • scalarPurificationLp (hF.isHermitian.eigenvalues k) (hF.eigenvalues_nonneg k) := by classical let U := hF.isHermitian.eigenvectorUnitary let eigenvalue := hF.isHermitian.eigenvalues let coefficient : d → ℂ := fun k => (U : Matrix d d ℂ) i k * star (U : Matrix d d ℂ) k j let generator : d → Lp ℂ 2 (volume.restrict (Ioi (0 : ℝ))) := fun k => scalarPurificationLp (eigenvalue k) (hF.eigenvalues_nonneg k) apply Lp.ext have hentry := spectralPurificationFilterEntryLp_coeFn F hF i j have hsum := Lp.coeFn_fun_finsetSum Finset.univ (fun k : d => coefficient k • generator k) have hgenerator : ∀ᵐ s ∂(volume.restrict (Ioi (0 : ℝ))), ∀ k : d, (coefficient k • generator k : Lp ℂ 2 (volume.restrict (Ioi (0 : ℝ)))) s = coefficient k * ((eigenvalue k / (eigenvalue k + s) : ℝ) : ℂ) := by apply ae_all_iff.mpr intro k have hsmul := Lp.coeFn_smul (coefficient k) (generator k) have hscalar := scalarPurificationLp_coeFn (eigenvalue k) (hF.eigenvalues_nonneg k) filter_upwards [hsmul, hscalar] with s hs ht rw [hs] change coefficient k * (scalarPurificationLp (eigenvalue k) (hF.eigenvalues_nonneg k) : ℝ → ℂ) s = _ rw [ht] filter_upwards [hentry, hsum, hgenerator] with s he hs hg rw [he, hs] change ((U : Matrix d d ℂ) * Matrix.diagonal (fun k => ((eigenvalue k / (eigenvalue k + s) : ℝ) : ℂ)) * star (U : Matrix d d ℂ)) i j = ∑ k : d, (coefficient k • generator k : Lp ℂ 2 (volume.restrict (Ioi (0 : ℝ)))) s simp_rw [hg] simp [Matrix.mul_apply, Matrix.diagonal, coefficient, mul_assoc, mul_comm] theorem ensemble_spectralPurificationFilterEntryLp_mem_common {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) (i j : d) : spectralPurificationFilterEntryLp (F a) (positive a) i j ∈ commonPurificationSubspace F M positive hM := by rw [spectralPurificationFilterEntryLp_eq_eigen_sum] apply (commonPurificationSubspace F M positive hM).sum_mem intro k _ apply (commonPurificationSubspace F M positive hM).smul_mem exact ensemble_scalarPurificationLp_mem_common F M positive hM a k theorem mean_spectralPurificationFilterEntryLp_mem_common {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (i j : d) : spectralPurificationFilterEntryLp M hM i j ∈ commonPurificationSubspace F M positive hM := by rw [spectralPurificationFilterEntryLp_eq_eigen_sum] apply (commonPurificationSubspace F M positive hM).sum_mem intro k _ apply (commonPurificationSubspace F M positive hM).smul_mem exact mean_scalarPurificationLp_mem_common F M positive hM k def ensemblePurificationSubspaceEntry {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) (i j : d) : commonPurificationSubspace F M positive hM := ⟨spectralPurificationFilterEntryLp (F a) (positive a) i j, ensemble_spectralPurificationFilterEntryLp_mem_common F M positive hM a i j⟩ def meanPurificationSubspaceEntry {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (i j : d) : commonPurificationSubspace F M positive hM := ⟨spectralPurificationFilterEntryLp M hM i j, mean_spectralPurificationFilterEntryLp_mem_common F M positive hM i j⟩ noncomputable def commonPurificationOrthonormalBasis {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : OrthonormalBasis (Fin (Module.finrank ℂ (commonPurificationSubspace F M positive hM))) ℂ (commonPurificationSubspace F M positive hM) := by letI : FiniteDimensional ℂ (commonPurificationSubspace F M positive hM) := commonPurificationSubspace_finiteDimensional F M positive hM exact stdOrthonormalBasis ℂ (commonPurificationSubspace F M positive hM) noncomputable def finitePurificationMatrix {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) : Matrix (d × Fin (Module.finrank ℂ (commonPurificationSubspace F M positive hM))) d ℂ := fun ik j => (commonPurificationOrthonormalBasis F M positive hM).repr (ensemblePurificationSubspaceEntry F M positive hM a ik.1 j) ik.2 noncomputable def meanFinitePurificationMatrix {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : Matrix (d × Fin (Module.finrank ℂ (commonPurificationSubspace F M positive hM))) d ℂ := fun ik j => (commonPurificationOrthonormalBasis F M positive hM).repr (meanPurificationSubspaceEntry F M positive hM ik.1 j) ik.2 end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise InnerProductSpace set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem finitePurificationMatrix_gram_apply {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) (i j : d) : ((finitePurificationMatrix F M positive hM a).conjTranspose * finitePurificationMatrix F M positive hM a) i j = ∑ r : d, inner ℂ (ensemblePurificationSubspaceEntry F M positive hM a r i) (ensemblePurificationSubspaceEntry F M positive hM a r j) := by classical simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, finitePurificationMatrix, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro r _ let b := commonPurificationOrthonormalBasis F M positive hM let u := ensemblePurificationSubspaceEntry F M positive hM a r i let v := ensemblePurificationSubspaceEntry F M positive hM a r j have hisometry := b.repr.inner_map_map u v change (∑ k, star (b.repr u k) * b.repr v k) = inner ℂ u v rw [← hisometry, EuclideanSpace.inner_eq_star_dotProduct] simp [dotProduct, mul_comm] theorem ensemblePurificationSubspaceEntry_inner_eq_integral {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) (r i j : d) : inner ℂ (ensemblePurificationSubspaceEntry F M positive hM a r i) (ensemblePurificationSubspaceEntry F M positive hM a r j) = ∫ s in Ioi (0 : ℝ), star (spectralPurificationFilter (F a) (positive a) s r i) * spectralPurificationFilter (F a) (positive a) s r j := by rw [Submodule.coe_inner, MeasureTheory.L2.inner_def] apply integral_congr_ae have hi := spectralPurificationFilterEntryLp_coeFn (F a) (positive a) r i have hj := spectralPurificationFilterEntryLp_coeFn (F a) (positive a) r j filter_upwards [hi, hj] with s hs ht change inner ℂ (spectralPurificationFilterEntryLp (F a) (positive a) r i s) (spectralPurificationFilterEntryLp (F a) (positive a) r j s) = _ rw [hs, ht] simp [RCLike.inner_apply, mul_comm] theorem finitePurificationMatrix_gram_eq_integral {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) : (finitePurificationMatrix F M positive hM a).conjTranspose * finitePurificationMatrix F M positive hM a = ∫ s in Ioi (0 : ℝ), star (spectralPurificationFilter (F a) (positive a) s) * spectralPurificationFilter (F a) (positive a) s := by classical have hfilter := spectralPurificationFilter_memLp_two (F a) (positive a) have hmatrix := spectralPurificationFilter_gram_integrable (F a) (positive a) have hrows : ∀ i : d, Integrable (fun s : ℝ => (star (spectralPurificationFilter (F a) (positive a) s) * spectralPurificationFilter (F a) (positive a) s) i) (volume.restrict (Ioi 0)) := fun i => hmatrix.eval i ext i j rw [finitePurificationMatrix_gram_apply] rw [MeasureTheory.eval_integral hrows i, MeasureTheory.eval_integral (fun k => (hrows i).eval k) j] simp_rw [ensemblePurificationSubspaceEntry_inner_eq_integral] have hproduct (r : d) : Integrable (fun s : ℝ => star (spectralPurificationFilter (F a) (positive a) s r i) * spectralPurificationFilter (F a) (positive a) s r j) (volume.restrict (Ioi 0)) := (((hfilter.eval r).eval i).star).integrable_mul ((hfilter.eval r).eval j) rw [← integral_finsetSum Finset.univ (fun r _ => hproduct r)] apply integral_congr_ae filter_upwards with s simp [Matrix.mul_apply, Matrix.star_apply] theorem finitePurificationMatrix_gram {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) : (finitePurificationMatrix F M positive hM a).conjTranspose * finitePurificationMatrix F M positive hM a = F a := by rw [finitePurificationMatrix_gram_eq_integral] exact integral_spectralPurificationFilter_gram (F a) (positive a) end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise InnerProductSpace set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem finitePurificationMatrix_difference_gram_apply {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) (i j : d) : ((finitePurificationMatrix F M positive hM a - meanFinitePurificationMatrix F M positive hM).conjTranspose * (finitePurificationMatrix F M positive hM a - meanFinitePurificationMatrix F M positive hM)) i j = ∑ r : d, inner ℂ (ensemblePurificationSubspaceEntry F M positive hM a r i - meanPurificationSubspaceEntry F M positive hM r i) (ensemblePurificationSubspaceEntry F M positive hM a r j - meanPurificationSubspaceEntry F M positive hM r j) := by classical simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.sub_apply, finitePurificationMatrix, meanFinitePurificationMatrix, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro r _ let b := commonPurificationOrthonormalBasis F M positive hM let u := ensemblePurificationSubspaceEntry F M positive hM a r i let u₀ := meanPurificationSubspaceEntry F M positive hM r i let v := ensemblePurificationSubspaceEntry F M positive hM a r j let v₀ := meanPurificationSubspaceEntry F M positive hM r j have hisometry := b.repr.inner_map_map (u - u₀) (v - v₀) change (∑ k, star (b.repr u k - b.repr u₀ k) * (b.repr v k - b.repr v₀ k)) = inner ℂ (u - u₀) (v - v₀) rw [← hisometry, EuclideanSpace.inner_eq_star_dotProduct] simp [dotProduct, map_sub, mul_comm] theorem purificationSubspaceEntry_difference_inner_eq_integral {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) (r i j : d) : inner ℂ (ensemblePurificationSubspaceEntry F M positive hM a r i - meanPurificationSubspaceEntry F M positive hM r i) (ensemblePurificationSubspaceEntry F M positive hM a r j - meanPurificationSubspaceEntry F M positive hM r j) = ∫ s in Ioi (0 : ℝ), star (spectralPurificationFilter (F a) (positive a) s r i - spectralPurificationFilter M hM s r i) * (spectralPurificationFilter (F a) (positive a) s r j - spectralPurificationFilter M hM s r j) := by rw [Submodule.coe_inner, MeasureTheory.L2.inner_def] apply integral_congr_ae let fi := spectralPurificationFilterEntryLp (F a) (positive a) r i let mi := spectralPurificationFilterEntryLp M hM r i let fj := spectralPurificationFilterEntryLp (F a) (positive a) r j let mj := spectralPurificationFilterEntryLp M hM r j have hsubi := Lp.coeFn_sub fi mi have hsubj := Lp.coeFn_sub fj mj have hfi := spectralPurificationFilterEntryLp_coeFn (F a) (positive a) r i have hmi := spectralPurificationFilterEntryLp_coeFn M hM r i have hfj := spectralPurificationFilterEntryLp_coeFn (F a) (positive a) r j have hmj := spectralPurificationFilterEntryLp_coeFn M hM r j filter_upwards [hsubi, hsubj, hfi, hmi, hfj, hmj] with s hi hj hfi' hmi' hfj' hmj' change inner ℂ ((fi - mi) s) ((fj - mj) s) = _ rw [hi, hj] change inner ℂ (fi s - mi s) (fj s - mj s) = _ change inner ℂ ((spectralPurificationFilterEntryLp (F a) (positive a) r i : ℝ → ℂ) s - (spectralPurificationFilterEntryLp M hM r i : ℝ → ℂ) s) ((spectralPurificationFilterEntryLp (F a) (positive a) r j : ℝ → ℂ) s - (spectralPurificationFilterEntryLp M hM r j : ℝ → ℂ) s) = _ rw [hfi', hmi', hfj', hmj'] simp [RCLike.inner_apply, mul_comm] theorem finitePurificationMatrix_difference_gram_eq_integral {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a : ι) : (finitePurificationMatrix F M positive hM a - meanFinitePurificationMatrix F M positive hM).conjTranspose * (finitePurificationMatrix F M positive hM a - meanFinitePurificationMatrix F M positive hM) = ∫ s in Ioi (0 : ℝ), star (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter M hM s) * (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter M hM s) := by classical have hdelta : MemLp (fun s : ℝ => spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter M hM s) 2 (volume.restrict (Ioi 0)) := (spectralPurificationFilter_memLp_two (F a) (positive a)).sub (spectralPurificationFilter_memLp_two M hM) have hmatrix := spectralPurificationFilter_difference_gram_integrable (F a) M (positive a) hM have hrows : ∀ i : d, Integrable (fun s : ℝ => (star (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter M hM s) * (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter M hM s)) i) (volume.restrict (Ioi 0)) := fun i => hmatrix.eval i ext i j rw [finitePurificationMatrix_difference_gram_apply] rw [MeasureTheory.eval_integral hrows i, MeasureTheory.eval_integral (fun k => (hrows i).eval k) j] simp_rw [purificationSubspaceEntry_difference_inner_eq_integral] have hproduct (r : d) : Integrable (fun s : ℝ => star (spectralPurificationFilter (F a) (positive a) s r i - spectralPurificationFilter M hM s r i) * (spectralPurificationFilter (F a) (positive a) s r j - spectralPurificationFilter M hM s r j)) (volume.restrict (Ioi 0)) := (((hdelta.eval r).eval i).star).integrable_mul ((hdelta.eval r).eval j) rw [← integral_finsetSum Finset.univ (fun r _ => hproduct r)] apply integral_congr_ae filter_upwards with s simp [Matrix.mul_apply, Matrix.star_apply] theorem weighted_finitePurificationMatrix_difference_gram {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) : (∑ a : ι, weight a • ((finitePurificationMatrix F M positive hM a - meanFinitePurificationMatrix F M positive hM).conjTranspose * (finitePurificationMatrix F M positive hM a - meanFinitePurificationMatrix F M positive hM))) = ∫ s in Ioi (0 : ℝ), weightedSpectralFilterVariance weight F M positive hM s := by classical have hterm (a : ι) : Integrable (fun s : ℝ => weight a • (star (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter M hM s) * (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter M hM s))) (volume.restrict (Ioi 0)) := (spectralPurificationFilter_difference_gram_integrable (F a) M (positive a) hM).smul (weight a) simp_rw [finitePurificationMatrix_difference_gram_eq_integral] unfold weightedSpectralFilterVariance rw [integral_finsetSum Finset.univ (fun a _ => hterm a)] simp_rw [integral_smul] end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise InnerProductSpace set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem finite_purification_log_entropy_jensen {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (nonnegative : ∀ i, 0 ≤ weight i) (normalized : (∑ i : ι, weight i) = 1) (mean : (∑ i : ι, weight i • F i) = M) (positive : ∀ i, (F i).PosSemidef) : let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive ((∑ i : ι, weight i • cfc (fun z : ℝ => z * Real.log z) (F i)) - cfc (fun z : ℝ => z * Real.log z) M - (∑ i : ι, weight i • ((finitePurificationMatrix F M positive hM i - meanFinitePurificationMatrix F M positive hM).conjTranspose * (finitePurificationMatrix F M positive hM i - meanFinitePurificationMatrix F M positive hM)))).PosSemidef := by dsimp let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive have h := exact_matrix_log_entropy_filter_jensen weight F M nonnegative normalized mean positive change ((∑ i : ι, weight i • cfc (fun z : ℝ => z * Real.log z) (F i)) - cfc (fun z : ℝ => z * Real.log z) M - (∫ s in Ioi (0 : ℝ), weightedSpectralFilterVariance weight F M positive hM s)).PosSemidef at h rw [← weighted_finitePurificationMatrix_difference_gram weight F M positive hM] at h exact h end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace def matrixPurificationVector {d : Type*} [Fintype d] (K : Matrix d d ℂ) : EuclideanSpace ℂ (d × d) := toLp 2 (Matrix.vec K) theorem matrixPurificationVector_norm_sq {d : Type*} [Fintype d] (K : Matrix d d ℂ) : ‖matrixPurificationVector K‖ ^ 2 = (Matrix.trace (Matrix.conjTranspose K * K)).re := by calc ‖matrixPurificationVector K‖ ^ 2 = (⟪matrixPurificationVector K, matrixPurificationVector K⟫_ℂ).re := norm_sq_eq_re_inner (𝕜 := ℂ) (matrixPurificationVector K) _ = (star (Matrix.vec K) ⬝ᵥ Matrix.vec K).re := by rw [EuclideanSpace.inner_eq_star_dotProduct] change (Matrix.vec K ⬝ᵥ star (Matrix.vec K)).re = (star (Matrix.vec K) ⬝ᵥ Matrix.vec K).re rw [dotProduct_comm] _ = (Matrix.trace (Matrix.conjTranspose K * K)).re := by rw [Matrix.star_vec_dotProduct_vec] def strategyPurificationShuffle (dA dB : Type) : ((dA × (dA × dB)) × dB) ≃ ((dA × dB) × (dA × dB)) where toFun q := (q.1.2, (q.1.1, q.2)) invFun q := ((q.2.1, q.1), q.2.2) left_inv := by rintro ⟨⟨a, k⟩, b⟩ rfl right_inv := by rintro ⟨k, ⟨a, b⟩⟩ rfl def strategyPurificationVector {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} (S : Strategy G) : EuclideanSpace ℂ ((S.Alice × (S.Alice × S.Bob)) × S.Bob) := toLp 2 (fun q => Matrix.vec (spectralSupportSqrt S.state.matrix S.state.positive) (strategyPurificationShuffle S.Alice S.Bob q)) theorem strategyPurificationVector_norm_sq {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} (S : Strategy G) : ‖strategyPurificationVector S‖ ^ 2 = ‖matrixPurificationVector (spectralSupportSqrt S.state.matrix S.state.positive)‖ ^ 2 := by rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq] simpa [strategyPurificationVector, matrixPurificationVector] using Equiv.sum_comp (strategyPurificationShuffle S.Alice S.Bob) (fun q : (S.Alice × S.Bob) × (S.Alice × S.Bob) => ‖Matrix.vec (spectralSupportSqrt S.state.matrix S.state.positive) q‖ ^ 2) theorem strategyPurificationVector_norm {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} (S : Strategy G) : ‖strategyPurificationVector S‖ = 1 := by let K := spectralSupportSqrt S.state.matrix S.state.positive have h_hermitian : (Matrix.conjTranspose K) = K := (spectralSupportFunctional_isHermitian S.state.matrix S.state.positive Real.sqrt).eq have h_sq : ‖strategyPurificationVector S‖ ^ 2 = 1 := by calc ‖strategyPurificationVector S‖ ^ 2 = ‖matrixPurificationVector K‖ ^ 2 := strategyPurificationVector_norm_sq S _ = (Matrix.trace (Matrix.conjTranspose K * K)).re := matrixPurificationVector_norm_sq K _ = (Matrix.trace S.state.matrix).re := by rw [h_hermitian] change (Matrix.trace (spectralSupportSqrt S.state.matrix S.state.positive * spectralSupportSqrt S.state.matrix S.state.positive)).re = (Matrix.trace S.state.matrix).re rw [spectralSupportSqrt_sq] _ = 1 := by rw [S.state.trace_one]; norm_num nlinarith [norm_nonneg (strategyPurificationVector S)] theorem reindexedMatrixQuadratic {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (φ : e ≃ d) (M : Matrix d d ℂ) (v : d → ℂ) : quadraticExpectation (Matrix.toEuclideanCLM (n := e) (𝕜 := ℂ) (M.submatrix φ φ)) (toLp 2 (v ∘ φ)) = (star v ⬝ᵥ M.mulVec v).re := by unfold quadraticExpectation rw [EuclideanSpace.inner_eq_star_dotProduct] change (((M.submatrix φ φ).mulVec (v ∘ φ)) ⬝ᵥ star (v ∘ φ)).re = (star v ⬝ᵥ M.mulVec v).re have h_mul : (M.submatrix φ φ).mulVec (v ∘ φ) = M.mulVec v ∘ φ := by simpa [Function.comp_def] using Matrix.submatrix_mulVec_equiv M (v ∘ φ) φ φ have h_star : star (v ∘ φ) = star v ∘ φ := by rfl rw [h_mul, h_star, comp_equiv_dotProduct_comp_equiv] rw [dotProduct_comm] def purificationAlicePOVM {ι d k : Type*} [Fintype ι] [Fintype d] [Fintype k] [DecidableEq d] [DecidableEq k] (P : POVM ι d) : POVM ι (d × k) where effect a := P.effect a ⊗ₖ (1 : Matrix k k ℂ) positive a := (P.positive a).kronecker Matrix.PosSemidef.one complete := by classical calc (∑ a : ι, P.effect a ⊗ₖ (1 : Matrix k k ℂ)) = (∑ a : ι, P.effect a) ⊗ₖ (1 : Matrix k k ℂ) := by ext ⟨i, u⟩ ⟨j, v⟩ simp [Matrix.sum_apply, Matrix.kroneckerMap_apply, Finset.sum_mul] _ = 1 := by rw [P.complete] exact Matrix.one_kronecker_one theorem purificationJointEffect_submatrix {dA dB : Type} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (A : Matrix dA dA ℂ) (B : Matrix dB dB ℂ) : (A ⊗ₖ (1 : Matrix (dA × dB) (dA × dB) ℂ)) ⊗ₖ B = ((1 : Matrix (dA × dB) (dA × dB) ℂ) ⊗ₖ (A ⊗ₖ B)).submatrix (strategyPurificationShuffle dA dB) (strategyPurificationShuffle dA dB) := by classical ext ⟨⟨a, k⟩, b⟩ ⟨⟨a', k'⟩, b'⟩ simp [Matrix.kroneckerMap_apply, Matrix.submatrix_apply, strategyPurificationShuffle, Matrix.one_apply] theorem strategyPurificationVector_quadratic {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} (S : Strategy G) (EA : Matrix S.Alice S.Alice ℂ) (EB : Matrix S.Bob S.Bob ℂ) : quadraticExpectation (Matrix.toEuclideanCLM (n := (S.Alice × (S.Alice × S.Bob)) × S.Bob) (𝕜 := ℂ) ((EA ⊗ₖ (1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ)) ⊗ₖ EB)) (strategyPurificationVector S) = (Matrix.trace (S.state.matrix * (EA ⊗ₖ EB))).re := by let K := spectralSupportSqrt S.state.matrix S.state.positive let E := EA ⊗ₖ EB let φ := strategyPurificationShuffle S.Alice S.Bob have h_hermitian : (Matrix.conjTranspose K) = K := (spectralSupportFunctional_isHermitian S.state.matrix S.state.positive Real.sqrt).eq have h_lift := purificationJointEffect_submatrix EA EB change quadraticExpectation (Matrix.toEuclideanCLM (n := (S.Alice × (S.Alice × S.Bob)) × S.Bob) (𝕜 := ℂ) ((EA ⊗ₖ (1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ)) ⊗ₖ EB)) (toLp 2 (Matrix.vec K ∘ φ)) = (Matrix.trace (S.state.matrix * E)).re rw [h_lift] rw [reindexedMatrixQuadratic φ ((1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ) ⊗ₖ E) (Matrix.vec K)] have h_vec : Matrix.mulVec ((1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ) ⊗ₖ E) (Matrix.vec K) = Matrix.vec (E * K) := by exact (Matrix.vec_mul_eq_mulVec E K).symm rw [h_vec, Matrix.star_vec_dotProduct_vec] rw [h_hermitian] congr 1 calc Matrix.trace (K * (E * K)) = Matrix.trace (K * E * K) := by rw [Matrix.mul_assoc] _ = Matrix.trace (K * K * E) := by rw [Matrix.trace_mul_cycle] _ = Matrix.trace (S.state.matrix * E) := by change Matrix.trace (spectralSupportSqrt S.state.matrix S.state.positive * spectralSupportSqrt S.state.matrix S.state.positive * E) = _ rw [spectralSupportSqrt_sq] def purifiedStrategy {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} (S : Strategy G) : Strategy G := pureVectorStrategy G (strategyPurificationVector S) (strategyPurificationVector_norm S) (fun x => purificationAlicePOVM (S.aliceMeasurement x)) S.bobMeasurement theorem purifiedStrategy_outcomeProbability {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} (S : Strategy G) (x : X) (y : Y) (a : A) (b : B) : (purifiedStrategy S).outcomeProbability x y a b = S.outcomeProbability x y a b := by unfold purifiedStrategy rw [pureVectorStrategy_outcomeProbability] exact strategyPurificationVector_quadratic S ((S.aliceMeasurement x).effect a) ((S.bobMeasurement y).effect b) theorem purifiedStrategy_winProbability {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} (S : Strategy G) : (purifiedStrategy S).winProbability = S.winProbability := by unfold Strategy.winProbability simp_rw [purifiedStrategy_outcomeProbability] theorem rectangular_matrix_mulVec_norm_sq {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] (K : Matrix e d ℂ) (z : EuclideanSpace ℂ d) : ‖toLp 2 (K.mulVec (ofLp z))‖ ^ 2 = quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) (K.conjTranspose * K)) z := by calc ‖toLp 2 (K.mulVec (ofLp z))‖ ^ 2 = (⟪toLp 2 (K.mulVec (ofLp z)), toLp 2 (K.mulVec (ofLp z))⟫_ℂ).re := norm_sq_eq_re_inner (𝕜 := ℂ) (toLp 2 (K.mulVec (ofLp z))) _ = (star (K.mulVec (ofLp z)) ⬝ᵥ K.mulVec (ofLp z)).re := by rw [EuclideanSpace.inner_eq_star_dotProduct] change (K.mulVec (ofLp z) ⬝ᵥ star (K.mulVec (ofLp z))).re = _ rw [dotProduct_comm] _ = (star (ofLp z) ⬝ᵥ (K.conjTranspose * K).mulVec (ofLp z)).re := by rw [Matrix.star_mulVec, ← Matrix.dotProduct_mulVec, Matrix.mulVec_mulVec] _ = quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) (K.conjTranspose * K)) z := by unfold quadraticExpectation rw [EuclideanSpace.inner_eq_star_dotProduct] change (star (ofLp z) ⬝ᵥ (K.conjTranspose * K).mulVec (ofLp z)).re = ((K.conjTranspose * K).mulVec (ofLp z) ⬝ᵥ star (ofLp z)).re rw [dotProduct_comm] def finiteLocalPurificationJointMatrix {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (KA : Matrix eA S.Alice ℂ) (KB : Matrix eB S.Bob ℂ) : Matrix ((eA × (S.Alice × S.Bob)) × eB) ((S.Alice × (S.Alice × S.Bob)) × S.Bob) ℂ := (KA ⊗ₖ (1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ)) ⊗ₖ KB def finiteLocalPurificationVector {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (KA : Matrix eA S.Alice ℂ) (KB : Matrix eB S.Bob ℂ) : EuclideanSpace ℂ ((eA × (S.Alice × S.Bob)) × eB) := toLp 2 ((finiteLocalPurificationJointMatrix S KA KB).mulVec (ofLp (strategyPurificationVector S))) theorem finiteLocalPurificationJointMatrix_gram {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (KA : Matrix eA S.Alice ℂ) (KB : Matrix eB S.Bob ℂ) : (finiteLocalPurificationJointMatrix S KA KB).conjTranspose * finiteLocalPurificationJointMatrix S KA KB = ((KA.conjTranspose * KA) ⊗ₖ (1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ)) ⊗ₖ (KB.conjTranspose * KB) := by unfold finiteLocalPurificationJointMatrix rw [Matrix.conjTranspose_kronecker, ← Matrix.mul_kronecker_mul, Matrix.conjTranspose_kronecker, ← Matrix.mul_kronecker_mul] simp theorem finiteLocalPurificationVector_norm_sq {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (KA : Matrix eA S.Alice ℂ) (KB : Matrix eB S.Bob ℂ) : ‖finiteLocalPurificationVector S KA KB‖ ^ 2 = (Matrix.trace (S.state.matrix * ((KA.conjTranspose * KA) ⊗ₖ (KB.conjTranspose * KB)))).re := by unfold finiteLocalPurificationVector rw [rectangular_matrix_mulVec_norm_sq, finiteLocalPurificationJointMatrix_gram] exact strategyPurificationVector_quadratic S (KA.conjTranspose * KA) (KB.conjTranspose * KB) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder InnerProductSpace theorem dSVUniformDensityMixedProtocolLocalAction_norm {ι : Type*} [Fintype ι] [DecidableEq ι] (U V : Matrix.unitaryGroup ι ℂ) (z : EuclideanSpace ℂ (ι × ι)) : ‖toLp 2 (((U : Matrix ι ι ℂ) ⊗ₖ (V : Matrix ι ι ℂ)).mulVec (ofLp z))‖ = ‖z‖ := by classical let M : Matrix (ι × ι) (ι × ι) ℂ := (U : Matrix ι ι ℂ) ⊗ₖ (V : Matrix ι ι ℂ) have unitary : M ∈ Matrix.unitaryGroup (ι × ι) ℂ := Matrix.kronecker_mem_unitary U.property V.property have gram : M.conjTranspose * M = 1 := by simpa [Matrix.star_eq_conjTranspose] using (Matrix.mem_unitaryGroup_iff'.mp unitary) have squared : ‖toLp 2 (M.mulVec (ofLp z))‖ ^ 2 = ‖z‖ ^ 2 := by rw [rectangular_matrix_mulVec_norm_sq, gram] simp [quadraticExpectation, ← Complex.ofReal_pow] change ‖toLp 2 (M.mulVec (ofLp z))‖ = ‖z‖ nlinarith [norm_nonneg (toLp 2 (M.mulVec (ofLp z))), norm_nonneg z] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVUniformDensityPhysicalAsyncSigmaContinuation {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] (U V : ι → Matrix.unitaryGroup κ ℂ) (z : EuclideanSpace ℂ ((Σ _ : ι, κ) × (Σ _ : ι, κ))) : EuclideanSpace ℂ ((Σ _ : ι, κ) × (Σ _ : ι, κ)) := by classical let A := coherentSharedRandomControlledUnitary U let B := coherentSharedRandomControlledUnitary V exact toLp 2 ((A.val ⊗ₖ B.val).mulVec (ofLp z)) theorem dSVUniformDensityPhysicalAsyncSigmaContinuation_norm {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] (U V : ι → Matrix.unitaryGroup κ ℂ) (z : EuclideanSpace ℂ ((Σ _ : ι, κ) × (Σ _ : ι, κ))) : ‖dSVUniformDensityPhysicalAsyncSigmaContinuation U V z‖ = ‖z‖ := by simpa [dSVUniformDensityPhysicalAsyncSigmaContinuation] using dSVUniformDensityMixedProtocolLocalAction_norm (coherentSharedRandomControlledUnitary U) (coherentSharedRandomControlledUnitary V) z theorem dSVUniformDensityFirstAcceptFinitePrefix {L : ℕ} (s : Finset (Fin L)) (j : Fin L) : (if h : s.Nonempty then (s.min' h).succ else (0 : Fin (L + 1))) = j.succ ↔ j ∈ s ∧ ∀ i : Fin L, i < j → i ∉ s := by classical constructor · intro selected by_cases nonempty : s.Nonempty · have minimum : s.min' nonempty = j := by have equal : (s.min' nonempty).succ = j.succ := by simpa [nonempty] using selected exact Fin.succ_injective L equal constructor · rw [← minimum] exact Finset.min'_mem s nonempty · intro i before contained have least : s.min' nonempty ≤ i := Finset.min'_le s i contained rw [minimum] at least exact (not_le_of_gt before) least · have impossible : (0 : Fin (L + 1)) = j.succ := by simpa [nonempty] using selected exact False.elim (Fin.succ_ne_zero j impossible.symm) · rintro ⟨accepted, prior⟩ have nonempty : s.Nonempty := ⟨j, accepted⟩ have minimum : s.min' nonempty = j := by apply (Finset.min'_eq_iff s nonempty j).mpr refine ⟨accepted, ?_⟩ intro i contained exact le_of_not_gt (fun before => prior i before contained) simp [nonempty, minimum] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 8000000 set_option maxRecDepth 3072 theorem dSVUniformDensityFirstAcceptControlledTensor_inv_apply {Ω ι β : Type*} [Fintype Ω] [DecidableEq Ω] [Fintype ι] [DecidableEq ι] [Fintype β] [DecidableEq β] (U : Ω → ι → Matrix.unitaryGroup β ℂ) (ω ν : Ω) (q r : ι → β) : (((controlledFiniteTensorLocalUnitary U)⁻¹ : Matrix.unitaryGroup (Σ _ : Ω, (ι → β)) ℂ) : Matrix (Σ _ : Ω, (ι → β)) (Σ _ : Ω, (ι → β)) ℂ) ⟨ω, q⟩ ⟨ν, r⟩ = if ω = ν then ∏ i : ι, star ((U ω i : Matrix β β ℂ) (r i) (q i)) else 0 := by classical change star ((controlledFiniteTensorLocalUnitary U : Matrix (Σ _ : Ω, (ι → β)) (Σ _ : Ω, (ι → β)) ℂ) ⟨ν, r⟩ ⟨ω, q⟩) = _ rw [controlledFiniteTensorLocalUnitary_apply] by_cases same : ω = ν · subst ν simp [star_prod] · have reversed : ν ≠ ω := Ne.symm same simp [same, reversed] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem coherentSharedRandomControlledUnitary_inv {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] (U : ι → Matrix.unitaryGroup κ ℂ) : (coherentSharedRandomControlledUnitary U)⁻¹ = coherentSharedRandomControlledUnitary (fun i => (U i)⁻¹) := by classical apply Subtype.ext ext ⟨i, x⟩ ⟨j, y⟩ change star ((coherentSharedRandomControlledUnitary U : Matrix (Σ _ : ι, κ) (Σ _ : ι, κ) ℂ) ⟨j, y⟩ ⟨i, x⟩) = (coherentSharedRandomControlledUnitary (fun i => (U i)⁻¹) : Matrix (Σ _ : ι, κ) (Σ _ : ι, κ) ℂ) ⟨i, x⟩ ⟨j, y⟩ by_cases same : i = j · subst j simp [coherentSharedRandomControlledUnitary, Matrix.blockDiagonal'_apply] · have reversed : j ≠ i := Ne.symm same simp [coherentSharedRandomControlledUnitary, Matrix.blockDiagonal'_apply, same, reversed] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable theorem dSVUniformDensityPhysicalAsync_doubleProductSum {ι β γ : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] [DecidableEq β] [Fintype γ] [DecidableEq γ] (f : ι → β → γ → ℝ) : (∑ x : ι → β, ∑ y : ι → γ, ∏ i : ι, f i (x i) (y i)) = ∏ i : ι, ∑ a : β, ∑ b : γ, f i a b := by classical calc (∑ x : ι → β, ∑ y : ι → γ, ∏ i : ι, f i (x i) (y i)) = ∑ x : ι → β, ∏ i : ι, ∑ b : γ, f i (x i) b := by apply Finset.sum_congr rfl intro x _ exact (Fintype.prod_sum (fun i : ι => fun b : γ => f i (x i) b)).symm _ = ∏ i : ι, ∑ a : β, ∑ b : γ, f i a b := (Fintype.prod_sum (fun i : ι => fun a : β => ∑ b : γ, f i a b)).symm end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem spectralPartitionPOVM_effect_eq_spectralDiagonal {κ ι : Type*} [Fintype κ] [DecidableEq κ] [Fintype ι] [DecidableEq ι] (F : Matrix ι ι ℂ) (positive : F.PosSemidef) (bin : ι → κ) (outcome : κ) : (spectralPartitionPOVM F positive bin).effect outcome = spectralConjugationCLM positive.isHermitian.eigenvectorUnitary (Matrix.diagonal fun i : ι => if bin i = outcome then (1 : ℂ) else 0) := by classical let selected : Finset ι := Finset.univ.filter fun i : ι => bin i = outcome have diagonal : (∑ i ∈ selected, Matrix.diagonal (Pi.single i (1 : ℂ))) = Matrix.diagonal fun i : ι => if bin i = outcome then (1 : ℂ) else 0 := by ext i j by_cases same : i = j · subst j simp [Matrix.sum_apply, selected, Pi.single_apply] · simp [Matrix.sum_apply, same] change (∑ i ∈ selected, spectralConjugationCLM positive.isHermitian.eigenvectorUnitary (Matrix.diagonal (Pi.single i (1 : ℂ)))) = _ rw [← map_sum, diagonal] theorem dSVUniformDensityPhysicalSpectralAliceCopy_inv {N d : ℕ} (ξ : BipartiteUnitVector d) : (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ)⁻¹ = coherentSharedRandomControlledUnitary (fun _ : Fin N => dSVUniformDensityThresholdLeftBobBasis ξ) := by unfold dSVUniformDensityAliceHistorySpectralCopy rw [coherentSharedRandomControlledUnitary_inv] simp theorem dSVUniformDensityPhysicalSpectralAliceCopy_transpose {N d : ℕ} (ξ : BipartiteUnitVector d) : (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ).transpose = (dSVUniformDensityBobHistoryCopyBasis (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) := by classical change (Matrix.blockDiagonal' (fun _ : Fin N => (((dSVUniformDensityThresholdLeftBobBasis ξ)⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ))).transpose = Matrix.blockDiagonal' (fun _ : Fin N => (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis ξ) : Matrix (Fin d) (Fin d) ℂ)) rw [Matrix.blockDiagonal'_transpose] apply congrArg Matrix.blockDiagonal' funext k ext i j rfl theorem dSVUniformDensityPhysicalSpectralAliceCopy_inv_transpose {N d : ℕ} (ξ : BipartiteUnitVector d) : ((((dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)).transpose = (((dSVUniformDensityBobHistoryCopyBasis (N := N) ξ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) := by calc _ = (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ).transpose.conjTranspose := by ext i j rfl _ = (dSVUniformDensityBobHistoryCopyBasis (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ).conjTranspose := by rw [dSVUniformDensityPhysicalSpectralAliceCopy_transpose] _ = _ := by rfl end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 16000000 set_option maxRecDepth 4096 attribute [local instance] Classical.propDecidable theorem dSVUniformDensityPhysicalMatched_doubleTensorSourceFactor {ι β : Type*} [Fintype ι] [DecidableEq ι] [Fintype β] [DecidableEq β] (A B : ι → Matrix β β ℂ) (source : β × β → ℂ) (a b : ι → β) : (∑ x : ι → β, ∑ y : ι → β, (∏ i : ι, A i (a i) (x i)) * (∏ i : ι, B i (b i) (y i)) * (∏ i : ι, source (x i, y i))) = ∏ i : ι, ∑ x : β, ∑ y : β, A i (a i) x * B i (b i) y * source (x, y) := by classical calc _ = ∑ x : ι → β, ∑ y : ι → β, ∏ i : ι, (A i (a i) (x i) * B i (b i) (y i) * source (x i, y i)) := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [← Finset.prod_mul_distrib, ← Finset.prod_mul_distrib] _ = ∑ x : ι → β, ∏ i : ι, ∑ y : β, (A i (a i) (x i) * B i (b i) y * source (x i, y)) := by apply Finset.sum_congr rfl intro x _ exact (Fintype.prod_sum fun i : ι => fun y : β => A i (a i) (x i) * B i (b i) y * source (x i, y)).symm _ = _ := (Fintype.prod_sum fun i : ι => fun x : β => ∑ y : β, A i (a i) x * B i (b i) y * source (x, y)).symm end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVUniformDensityCorrectedMatchedSigmaWeightedResidual {H : Type*} [Fintype H] {n : ℕ} (history : EuclideanSpace ℂ (H × H)) (work : H → H → EuclideanSpace ℂ (Fin n × Fin n)) : EuclideanSpace ℂ ((Σ _ : H, Fin n) × (Σ _ : H, Fin n)) := toLp 2 fun q : (Σ _ : H, Fin n) × (Σ _ : H, Fin n) => history (q.1.1, q.2.1) * work q.1.1 q.2.1 (q.1.2, q.2.2) theorem dSVUniformDensityCorrectedMatchedSigmaWeightedResidual_distance_sq {H : Type*} [Fintype H] {n : ℕ} (history : EuclideanSpace ℂ (H × H)) (work target : H → H → EuclideanSpace ℂ (Fin n × Fin n)) : ‖dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history work - dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history target‖ ^ 2 = ∑ a : H, ∑ b : H, ‖history (a, b)‖ ^ 2 * ‖work a b - target a b‖ ^ 2 := by classical rw [EuclideanSpace.norm_sq_eq] simp only [Fintype.sum_prod_type, Fintype.sum_sigma] change (∑ a : H, ∑ i : Fin n, ∑ b : H, ∑ j : Fin n, ‖history (a, b) * work a b (i, j) - history (a, b) * target a b (i, j)‖ ^ 2) = _ apply Finset.sum_congr rfl intro a _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro b _ rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type, Finset.mul_sum] apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j _ change ‖history (a, b) * work a b (i, j) - history (a, b) * target a b (i, j)‖ ^ 2 = ‖history (a, b)‖ ^ 2 * ‖work a b (i, j) - target a b (i, j)‖ ^ 2 rw [← mul_sub, norm_mul, mul_pow] theorem dSVUniformDensityCorrectedMatchedSigmaWeightedResidual_controlled {H : Type*} [Fintype H] [DecidableEq H] {n : ℕ} (history : EuclideanSpace ℂ (H × H)) (work : H → H → EuclideanSpace ℂ (Fin n × Fin n)) (U V : H → Matrix.unitaryGroup (Fin n) ℂ) : dSVUniformDensityPhysicalAsyncSigmaContinuation U V (dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history work) = dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history (fun a b => localUnitaryAction (U a) (V b) (work a b)) := by classical ext ⟨⟨a, i⟩, ⟨b, j⟩⟩ simp [dSVUniformDensityPhysicalAsyncSigmaContinuation, dSVUniformDensityCorrectedMatchedSigmaWeightedResidual, coherentSharedRandomControlledUnitary, localUnitaryAction, Matrix.mulVec, dotProduct, Matrix.kroneckerMap_apply, Matrix.blockDiagonal'_apply, Fintype.sum_prod_type, Fintype.sum_sigma, mul_assoc, mul_comm] simp_rw [Finset.mul_sum] theorem dSVUniformDensityCorrectedMatchedSigmaControlledReset_distance_sq {H : Type*} [Fintype H] [DecidableEq H] {n : ℕ} (history : EuclideanSpace ℂ (H × H)) (work target : H → H → EuclideanSpace ℂ (Fin n × Fin n)) (U V : H → Matrix.unitaryGroup (Fin n) ℂ) : ‖dSVUniformDensityPhysicalAsyncSigmaContinuation U V (dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history work) - dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history target‖ ^ 2 = ∑ a : H, ∑ b : H, ‖history (a, b)‖ ^ 2 * ‖localUnitaryAction (U a) (V b) (work a b) - target a b‖ ^ 2 := by rw [dSVUniformDensityCorrectedMatchedSigmaWeightedResidual_controlled, dSVUniformDensityCorrectedMatchedSigmaWeightedResidual_distance_sq] end noncomputable section open WithLp open scoped BigOperators ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalProjectiveThresholdBin (w : ℝ) (N : ℕ) (k : Fin N) (a : ℝ) : Bool := decide (dSVUniformDensityThresholdGrid N k ≤ dSVRationalSoftPass w a) def dSVDensityRationalProjectiveThresholdPOVM {ι : Type*} [Fintype ι] [DecidableEq ι] (w : ℝ) (N : ℕ) (k : Fin N) (F : Matrix ι ι ℂ) (positive : F.PosSemidef) : POVM Bool ι := spectralPartitionPOVM F positive (fun i : ι => dSVDensityRationalProjectiveThresholdBin w N k (positive.isHermitian.eigenvalues i)) theorem dSVDensityRationalProjectiveThresholdPOVM_projective {ι : Type*} [Fintype ι] [DecidableEq ι] (w : ℝ) (N : ℕ) (k : Fin N) (F : Matrix ι ι ℂ) (positive : F.PosSemidef) (outcome : Bool) : (dSVDensityRationalProjectiveThresholdPOVM w N k F positive).effect outcome * (dSVDensityRationalProjectiveThresholdPOVM w N k F positive).effect outcome = (dSVDensityRationalProjectiveThresholdPOVM w N k F positive).effect outcome := by exact spectralPartitionPOVM_projective F positive (fun i : ι => dSVDensityRationalProjectiveThresholdBin w N k (positive.isHermitian.eigenvalues i)) outcome def dSVDensityRationalLeftProjectiveThresholdPOVM {d : ℕ} (w : ℝ) (N : ℕ) (k : Fin N) (ξ : BipartiteUnitVector d) : POVM Bool (Fin d) := dSVDensityRationalProjectiveThresholdPOVM w N k (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) def dSVDensityRationalLeftProjectiveThresholdAtomMismatch {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : ℝ := let F := dSVSoftBobLeftReducedDensity ξ let G := dSVSoftBobLeftReducedDensity ζ let hF := dSVSoftBobLeftReducedDensity_posSemidef ξ let hG := dSVSoftBobLeftReducedDensity_posSemidef ζ ∑ i : Fin d, ∑ j : Fin d, spectralAtomOverlap F G hF hG i j * dSVUniformDensityThresholdMismatch N (dSVRationalSoftPass w (hF.isHermitian.eigenvalues i)) (dSVRationalSoftPass w (hG.isHermitian.eigenvalues j)) theorem dSVDensityRationalLeftProjectiveThresholdAtomMismatch_le_discrepancy {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ ≤ dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ / w + (d : ℝ) / N := by let F := dSVSoftBobLeftReducedDensity ξ let G := dSVSoftBobLeftReducedDensity ζ let hF : F.PosSemidef := dSVSoftBobLeftReducedDensity_posSemidef ξ let hG : G.PosSemidef := dSVSoftBobLeftReducedDensity_posSemidef ζ have overlap_mass : (∑ i : Fin d, ∑ j : Fin d, spectralAtomOverlap F G hF hG i j) = (d : ℝ) := by simp_rw [spectralAtomOverlap_sum_right] simp have discrepancy : (∑ i : Fin d, ∑ j : Fin d, |hF.isHermitian.eigenvalues i - hG.isHermitian.eigenvalues j| * spectralAtomOverlap F G hF hG i j) = dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ := by unfold dSVUniformLeftDensitySpectralAtomDiscrepancy dSVUniformLeftDensitySchmidtCoefficient apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ simp [Real.sq_sqrt ((dSVSoftBobLeftReducedDensity_posSemidef ξ).eigenvalues_nonneg i), Real.sq_sqrt ((dSVSoftBobLeftReducedDensity_posSemidef ζ).eigenvalues_nonneg j), F, G] calc dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ ≤ ∑ i : Fin d, ∑ j : Fin d, spectralAtomOverlap F G hF hG i j * (|hF.isHermitian.eigenvalues i - hG.isHermitian.eigenvalues j| / w + 1 / (N : ℝ)) := by unfold dSVDensityRationalLeftProjectiveThresholdAtomMismatch change (∑ i : Fin d, ∑ j : Fin d, spectralAtomOverlap F G hF hG i j * dSVUniformDensityThresholdMismatch N (dSVRationalSoftPass w (hF.isHermitian.eigenvalues i)) (dSVRationalSoftPass w (hG.isHermitian.eigenvalues j))) ≤ _ apply Finset.sum_le_sum intro i _ apply Finset.sum_le_sum intro j _ apply mul_le_mul_of_nonneg_left _ (spectralAtomOverlap_nonneg F G hF hG i j) exact (dSVUniformDensityThresholdMismatch_le grid _ _).trans (by simpa [add_comm] using (add_le_add_right (dSVRationalSoftPass_lipschitz width (hF.eigenvalues_nonneg i) (hG.eigenvalues_nonneg j)) (1 / (N : ℝ)))) _ = (∑ i : Fin d, ∑ j : Fin d, |hF.isHermitian.eigenvalues i - hG.isHermitian.eigenvalues j| * spectralAtomOverlap F G hF hG i j) / w + (1 / (N : ℝ)) * (∑ i : Fin d, ∑ j : Fin d, spectralAtomOverlap F G hF hG i j) := by calc (∑ i : Fin d, ∑ j : Fin d, spectralAtomOverlap F G hF hG i j * (|hF.isHermitian.eigenvalues i - hG.isHermitian.eigenvalues j| / w + 1 / (N : ℝ))) = ∑ i : Fin d, ∑ j : Fin d, ((|hF.isHermitian.eigenvalues i - hG.isHermitian.eigenvalues j| * spectralAtomOverlap F G hF hG i j) / w + (1 / (N : ℝ)) * spectralAtomOverlap F G hF hG i j) := by apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring _ = _ := by simp_rw [Finset.sum_add_distrib, Finset.sum_div, Finset.mul_sum] _ = dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ / w + (d : ℝ) / N := by rw [discrepancy, overlap_mass] ring theorem dSVUniformDensityGridPrefix_le_density {N : ℕ} (positive : 0 < N) {a : ℝ} (nonnegative : 0 ≤ a) (bounded : a ≤ 1) : dSVUniformDensityGridPrefix N a ≤ a := by have cast : (0 : ℝ) < N := by exact_mod_cast positive rw [dSVUniformDensityGridPrefix_eq_count, dSVUniformDensityThresholdGrid_count_eq_floor positive a nonnegative bounded] apply (div_le_iff₀ cast).mpr exact Nat.floor_le (mul_nonneg nonnegative cast.le) theorem dSVUniformDensityGridPrefix_density_sub_lt {N : ℕ} (positive : 0 < N) {a : ℝ} (nonnegative : 0 ≤ a) (bounded : a ≤ 1) : a - dSVUniformDensityGridPrefix N a < 1 / (N : ℝ) := by have cast : (0 : ℝ) < N := by exact_mod_cast positive rw [dSVUniformDensityGridPrefix_eq_count, dSVUniformDensityThresholdGrid_count_eq_floor positive a nonnegative bounded] apply (lt_div_iff₀ cast).mpr have floor := Nat.lt_floor_add_one (a * (N : ℝ)) calc (a - (Nat.floor (a * (N : ℝ)) : ℝ) / (N : ℝ)) * (N : ℝ) = a * (N : ℝ) - (Nat.floor (a * (N : ℝ)) : ℝ) := by field_simp _ < 1 := by linarith theorem dSVUniformDensityGridPrefix_density_sub_le {N : ℕ} (positive : 0 < N) {a : ℝ} (nonnegative : 0 ≤ a) (bounded : a ≤ 1) : a - 1 / (N : ℝ) ≤ dSVUniformDensityGridPrefix N a := by linarith [dSVUniformDensityGridPrefix_density_sub_lt positive nonnegative bounded] def dSVDensityRationalLeftProjectiveDiagonalMass {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : ℝ := let hF := dSVSoftBobLeftReducedDensity_posSemidef ξ ∑ i : Fin d, dSVUniformDensityGridPrefix N (dSVRationalSoftPass w (hF.isHermitian.eigenvalues i)) theorem dSVSoftBobLeftReducedDensity_eigenvalue_le_one {d : ℕ} (ξ : BipartiteUnitVector d) (i : Fin d) : (dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i ≤ 1 := by let F := dSVSoftBobLeftReducedDensity ξ let hF : F.PosSemidef := dSVSoftBobLeftReducedDensity_posSemidef ξ change hF.isHermitian.eigenvalues i ≤ 1 calc hF.isHermitian.eigenvalues i ≤ ∑ j : Fin d, hF.isHermitian.eigenvalues j := Finset.single_le_sum (fun j _ => hF.eigenvalues_nonneg j) (Finset.mem_univ i) _ = 1 := positiveDensity_eigenvalues_sum F hF (dSVSoftBobLeftReducedDensity_trace ξ) theorem dSVRationalSoftPass_ge_density_div_width_add_one {w a : ℝ} (width : 0 < w) (nonnegative : 0 ≤ a) (bounded : a ≤ 1) : a / (w + 1) ≤ dSVRationalSoftPass w a := by unfold dSVRationalSoftPass have denominator : 0 < a + w := by linarith have wider : 0 < w + 1 := by linarith apply (div_le_div_iff₀ wider denominator).mpr nlinarith theorem dSVDensityRationalLeftProjectiveDiagonalMass_lower {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ : BipartiteUnitVector d) : 1 / (w + 1) - (d : ℝ) / N ≤ dSVDensityRationalLeftProjectiveDiagonalMass w N ξ := by let F := dSVSoftBobLeftReducedDensity ξ let hF : F.PosSemidef := dSVSoftBobLeftReducedDensity_posSemidef ξ have density_sum : (∑ i : Fin d, hF.isHermitian.eigenvalues i) = 1 := positiveDensity_eigenvalues_sum F hF (dSVSoftBobLeftReducedDensity_trace ξ) have rational_sum : 1 / (w + 1) ≤ ∑ i : Fin d, dSVRationalSoftPass w (hF.isHermitian.eigenvalues i) := by calc 1 / (w + 1) = ∑ i : Fin d, hF.isHermitian.eigenvalues i / (w + 1) := by rw [← Finset.sum_div, density_sum] _ ≤ ∑ i : Fin d, dSVRationalSoftPass w (hF.isHermitian.eigenvalues i) := by apply Finset.sum_le_sum intro i _ exact dSVRationalSoftPass_ge_density_div_width_add_one width (hF.eigenvalues_nonneg i) (dSVSoftBobLeftReducedDensity_eigenvalue_le_one ξ i) calc 1 / (w + 1) - (d : ℝ) / N ≤ (∑ i : Fin d, dSVRationalSoftPass w (hF.isHermitian.eigenvalues i)) - (d : ℝ) / N := sub_le_sub_right rational_sum _ _ = ∑ i : Fin d, (dSVRationalSoftPass w (hF.isHermitian.eigenvalues i) - 1 / (N : ℝ)) := by simp [Finset.sum_sub_distrib] ring _ ≤ dSVDensityRationalLeftProjectiveDiagonalMass w N ξ := by unfold dSVDensityRationalLeftProjectiveDiagonalMass change (∑ i : Fin d, (dSVRationalSoftPass w (hF.isHermitian.eigenvalues i) - 1 / (N : ℝ))) ≤ ∑ i : Fin d, dSVUniformDensityGridPrefix N (dSVRationalSoftPass w (hF.isHermitian.eigenvalues i)) apply Finset.sum_le_sum intro i _ exact dSVUniformDensityGridPrefix_density_sub_le grid (dSVRationalSoftPass_mem_unit width (hF.eigenvalues_nonneg i)).1 (dSVRationalSoftPass_mem_unit width (hF.eigenvalues_nonneg i)).2 end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalPhysicalProjector {d N : ℕ} (w : ℝ) (ξ : BipartiteUnitVector d) (k : Fin N) : Matrix (Fin d) (Fin d) ℂ := (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect true theorem dSVDensityRationalPhysicalProjector_pos {d N : ℕ} (w : ℝ) (ξ : BipartiteUnitVector d) (k : Fin N) : (dSVDensityRationalPhysicalProjector w ξ k).PosSemidef := (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).positive true theorem dSVDensityRationalPhysicalProjector_projective {d N : ℕ} (w : ℝ) (ξ : BipartiteUnitVector d) (k : Fin N) : dSVDensityRationalPhysicalProjector w ξ k * dSVDensityRationalPhysicalProjector w ξ k = dSVDensityRationalPhysicalProjector w ξ k := by exact dSVDensityRationalProjectiveThresholdPOVM_projective w N k (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) true theorem dSVDensityRationalPhysicalProjector_complement_pos {d N : ℕ} (w : ℝ) (ξ : BipartiteUnitVector d) (k : Fin N) : (1 - dSVDensityRationalPhysicalProjector w ξ k).PosSemidef := dSVProjectorComplement_posSemidef (dSVDensityRationalPhysicalProjector w ξ k) (dSVDensityRationalPhysicalProjector_pos w ξ k) (dSVDensityRationalPhysicalProjector_projective w ξ k) def dSVDensityRationalPhysicalGlobalPOVM {d N : ℕ} (w : ℝ) (ξ : BipartiteUnitVector d) : POVM Bool (DSVUniformDensityThresholdLocalIndex N d) := dSVGlobalProjectorBinaryPOVM (dSVDensityRationalPhysicalProjector w ξ) (dSVDensityRationalPhysicalProjector_pos w ξ) (dSVDensityRationalPhysicalProjector_complement_pos w ξ) theorem dSVDensityRationalPhysicalProjectorSquare_eq_atomMismatch {d N : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) (k : Fin N) : (Matrix.trace ((dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k) * (dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k))).re = ∑ i : Fin d, ∑ j : Fin d, if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) then 0 else spectralAtomOverlap (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) i j := by classical let F := dSVSoftBobLeftReducedDensity ξ let G := dSVSoftBobLeftReducedDensity ζ let hF := dSVSoftBobLeftReducedDensity_posSemidef ξ let hG := dSVSoftBobLeftReducedDensity_posSemidef ζ let f : Fin d → Bool := fun i => dSVDensityRationalProjectiveThresholdBin w N k (hF.isHermitian.eigenvalues i) let g : Fin d → Bool := fun j => dSVDensityRationalProjectiveThresholdBin w N k (hG.isHermitian.eigenvalues j) let P := (spectralPartitionPOVM F hF f).effect true let R := (spectralPartitionPOVM G hG g).effect true have deficit := spectralPartitionPOVM_weighted_trace_deficit_eq_mismatch F G hF hG f g (fun _ : Bool => (1 : ℝ)) simp only [one_pow, one_mul] at deficit have ffalse := dSVUniformDensityBinarySpectral_false_eq_complement F hF f have gfalse := dSVUniformDensityBinarySpectral_false_eq_complement G hG g have hp : P * P = P := spectralPartitionPOVM_projective F hF f true have hr : R * R = R := spectralPartitionPOVM_projective G hG g true change (Matrix.trace ((P - R) * (P - R))).re = _ change (∑ b : Bool, (Matrix.trace ((spectralPartitionPOVM G hG g).effect b)).re) - (∑ b : Bool, (Matrix.trace ((spectralPartitionPOVM F hF f).effect b * (spectralPartitionPOVM G hG g).effect b)).re) = ∑ i : Fin d, ∑ j : Fin d, if f i = g j then 0 else spectralAtomOverlap F G hF hG i j at deficit rw [← deficit] simp only [Fintype.sum_bool] rw [ffalse, gfalse] change (Matrix.trace ((P - R) * (P - R))).re = (Matrix.trace R).re + (Matrix.trace (1 - R)).re - ((Matrix.trace (P * R)).re + (Matrix.trace ((1 - P) * (1 - R))).re) simp only [Matrix.sub_mul, Matrix.mul_sub, Matrix.one_mul, Matrix.mul_one, Matrix.trace_sub, Complex.sub_re, hp, hr] rw [Matrix.trace_mul_comm R P] ring theorem dSVDensityRationalPhysicalProjectorSquare_grid_eq {d N : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) : (∑ k : Fin N, (Matrix.trace ((dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k) * (dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k))).re) / (N : ℝ) = dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ := by classical simp_rw [dSVDensityRationalPhysicalProjectorSquare_eq_atomMismatch] let F := dSVSoftBobLeftReducedDensity ξ let G := dSVSoftBobLeftReducedDensity ζ let hF := dSVSoftBobLeftReducedDensity_posSemidef ξ let hG := dSVSoftBobLeftReducedDensity_posSemidef ζ let overlap := spectralAtomOverlap F G hF hG have commute : (∑ k : Fin N, ∑ i : Fin d, ∑ j : Fin d, if dSVDensityRationalProjectiveThresholdBin w N k (hF.isHermitian.eigenvalues i) = dSVDensityRationalProjectiveThresholdBin w N k (hG.isHermitian.eigenvalues j) then 0 else overlap i j) = ∑ i : Fin d, ∑ j : Fin d, ∑ k : Fin N, if dSVDensityRationalProjectiveThresholdBin w N k (hF.isHermitian.eigenvalues i) = dSVDensityRationalProjectiveThresholdBin w N k (hG.isHermitian.eigenvalues j) then 0 else overlap i j := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro i _ rw [Finset.sum_comm] change (∑ k : Fin N, ∑ i : Fin d, ∑ j : Fin d, if dSVDensityRationalProjectiveThresholdBin w N k (hF.isHermitian.eigenvalues i) = dSVDensityRationalProjectiveThresholdBin w N k (hG.isHermitian.eigenvalues j) then 0 else overlap i j) / (N : ℝ) = _ rw [commute] unfold dSVDensityRationalLeftProjectiveThresholdAtomMismatch change (∑ i : Fin d, ∑ j : Fin d, ∑ k : Fin N, if dSVDensityRationalProjectiveThresholdBin w N k (hF.isHermitian.eigenvalues i) = dSVDensityRationalProjectiveThresholdBin w N k (hG.isHermitian.eigenvalues j) then 0 else overlap i j) / (N : ℝ) = ∑ i : Fin d, ∑ j : Fin d, overlap i j * dSVUniformDensityThresholdMismatch N (dSVRationalSoftPass w (hF.isHermitian.eigenvalues i)) (dSVRationalSoftPass w (hG.isHermitian.eigenvalues j)) simp_rw [Finset.sum_div] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ unfold dSVUniformDensityThresholdMismatch dSVUniformDensityThresholdWeight rw [Finset.mul_sum] apply Finset.sum_congr rfl intro k _ unfold dSVDensityRationalProjectiveThresholdBin by_cases left : dSVUniformDensityThresholdGrid N k ≤ dSVRationalSoftPass w (hF.isHermitian.eigenvalues i) · by_cases right : dSVUniformDensityThresholdGrid N k ≤ dSVRationalSoftPass w (hG.isHermitian.eigenvalues j) · simp [left, right] · simp [left, right, div_eq_mul_inv] · by_cases right : dSVUniformDensityThresholdGrid N k ≤ dSVRationalSoftPass w (hG.isHermitian.eigenvalues j) · simp [left, right, div_eq_mul_inv] · simp [left, right] theorem dSVDensityRationalPhysicalProjector_weighted_rank_eq {d N : ℕ} (w : ℝ) (ξ : BipartiteUnitVector d) : (∑ k : Fin N, dSVUniformDensityThresholdWeight N k * (Matrix.trace (dSVDensityRationalPhysicalProjector w ξ k)).re) = dSVDensityRationalLeftProjectiveDiagonalMass w N ξ := by classical let F := dSVSoftBobLeftReducedDensity ξ let hF := dSVSoftBobLeftReducedDensity_posSemidef ξ change (∑ k : Fin N, dSVUniformDensityThresholdWeight N k * (Matrix.trace ((spectralPartitionPOVM F hF (fun i : Fin d => dSVDensityRationalProjectiveThresholdBin w N k (hF.isHermitian.eigenvalues i))).effect true)).re) = ∑ i : Fin d, dSVUniformDensityGridPrefix N (dSVRationalSoftPass w (hF.isHermitian.eigenvalues i)) simp_rw [spectralPartitionPOVM_trace_eq_atom_count] unfold dSVUniformDensityGridPrefix simp_rw [Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro k _ unfold dSVDensityRationalProjectiveThresholdBin by_cases accepted : dSVUniformDensityThresholdGrid N k ≤ dSVRationalSoftPass w (hF.isHermitian.eigenvalues i) · simp [accepted] · simp [accepted] def dSVDensityRationalPhysicalDiagonalBornSuccess {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ : BipartiteUnitVector d) : ℝ := binaryJointSuccessProbability (dSVUniformDensityThresholdSharedDensity grid dimension) (dSVDensityRationalPhysicalGlobalPOVM w ξ) (transposePOVM (dSVDensityRationalPhysicalGlobalPOVM w ξ)) theorem dSVDensityRationalPhysicalDiagonalBornSuccess_eq {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ : BipartiteUnitVector d) : dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ = dSVDensityRationalLeftProjectiveDiagonalMass w N ξ / (d : ℝ) := by have d_nonzero : (d : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt dimension) have n_nonzero : (N : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt grid) unfold dSVDensityRationalPhysicalDiagonalBornSuccess dSVDensityRationalPhysicalGlobalPOVM rw [dSVUniformDensityThresholdShared_diagonalBorn_eq grid dimension (dSVDensityRationalPhysicalProjector w ξ) (dSVDensityRationalPhysicalProjector_pos w ξ) (dSVDensityRationalPhysicalProjector_complement_pos w ξ) (dSVDensityRationalPhysicalProjector_projective w ξ)] rw [← dSVDensityRationalPhysicalProjector_weighted_rank_eq w ξ] unfold dSVUniformDensityThresholdWeight rw [← Finset.mul_sum] field_simp def dSVDensityRationalPhysicalProjectorCrossHazard {d : ℕ} (N : ℕ) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : ℝ := (∑ k : Fin N, (Matrix.trace ((dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k) * (dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k))).re) / ((d : ℝ) * (N : ℝ)) theorem dSVDensityRationalPhysicalProjectorCrossHazard_eq {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalPhysicalProjectorCrossHazard N w ξ ζ = dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / (d : ℝ) := by have d_nonzero : (d : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt dimension) have n_nonzero : (N : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt grid) unfold dSVDensityRationalPhysicalProjectorCrossHazard calc (∑ k : Fin N, (Matrix.trace ((dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k) * (dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k))).re) / ((d : ℝ) * (N : ℝ)) = ((∑ k : Fin N, (Matrix.trace ((dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k) * (dSVDensityRationalPhysicalProjector w ξ k - dSVDensityRationalPhysicalProjector w ζ k))).re) / (N : ℝ)) / (d : ℝ) := by field_simp _ = dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / (d : ℝ) := by rw [dSVDensityRationalPhysicalProjectorSquare_grid_eq w ξ ζ] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVDensityRationalCompleteProjectiveThresholdProjector {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (k : Fin N) : Matrix (Fin d) (Fin d) ℂ := (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect true theorem dSVDensityRationalCompleteProjectiveThresholdProjector_pos {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (k : Fin N) : (dSVDensityRationalCompleteProjectiveThresholdProjector w N ξ k).PosSemidef := (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).positive true theorem dSVDensityRationalCompleteProjectiveThresholdEffect_projective {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (k : Fin N) (a : Bool) : (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a * (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a = (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a := by exact dSVDensityRationalProjectiveThresholdPOVM_projective w N k (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) a theorem dSVDensityRationalCompleteProjectiveThresholdEffect_false {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (k : Fin N) : (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect false = 1 - dSVDensityRationalCompleteProjectiveThresholdProjector w N ξ k := by have complete := (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).complete rw [Fintype.sum_bool, add_comm] at complete exact eq_sub_of_add_eq complete theorem dSVDensityRationalCompleteProjectiveThresholdProjector_complement_pos {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (k : Fin N) : (1 - dSVDensityRationalCompleteProjectiveThresholdProjector w N ξ k).PosSemidef := by rw [← dSVDensityRationalCompleteProjectiveThresholdEffect_false] exact (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).positive false def dSVDensityRationalCompleteProjectiveBinaryPOVM {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : POVM Bool (DSVUniformDensityThresholdLocalIndex N d) := dSVGlobalProjectorBinaryPOVM (dSVDensityRationalCompleteProjectiveThresholdProjector w N ξ) (dSVDensityRationalCompleteProjectiveThresholdProjector_pos w N ξ) (dSVDensityRationalCompleteProjectiveThresholdProjector_complement_pos w N ξ) theorem dSVDensityRationalCompleteProjectiveBinaryPOVM_effect {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (a : Bool) : (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ).effect a = Matrix.blockDiagonal' (fun k : Fin N => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a) := by cases a · change Matrix.blockDiagonal' (fun k : Fin N => 1 - dSVDensityRationalCompleteProjectiveThresholdProjector w N ξ k) = _ congr 1 funext k exact (dSVDensityRationalCompleteProjectiveThresholdEffect_false w N ξ k).symm · rfl theorem dSVDensityRationalCompleteProjectiveBinaryPOVM_projective {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (a : Bool) : (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ).effect a * (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ).effect a = (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ).effect a := by exact dSVGlobalProjectorBinaryPOVM_projective (dSVDensityRationalCompleteProjectiveThresholdProjector w N ξ) (dSVDensityRationalCompleteProjectiveThresholdProjector_pos w N ξ) (dSVDensityRationalCompleteProjectiveThresholdProjector_complement_pos w N ξ) (fun k => dSVDensityRationalCompleteProjectiveThresholdEffect_projective w N ξ k true) a def dSVDensityRationalCompleteProjectiveOutcome {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (a b : Bool) : EuclideanSpace ℂ (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := coherentBinaryJointOutcome (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ) (transposePOVM (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ζ)) (dSVUniformDensityThresholdSharedState N d) a b theorem dSVDensityRationalCompleteProjectiveOutcome_eq_block_action {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (a b : Bool) : dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ a b = toLp 2 ((Matrix.blockDiagonal' (fun k : Fin N => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a) ⊗ₖ (Matrix.blockDiagonal' (fun k : Fin N => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ζ).effect b)).transpose).mulVec (ofLp (dSVUniformDensityThresholdSharedState N d))) := by unfold dSVDensityRationalCompleteProjectiveOutcome coherentBinaryJointOutcome change toLp 2 (((dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ).effect a ⊗ₖ ((dSVDensityRationalCompleteProjectiveBinaryPOVM w N ζ).effect b).transpose).mulVec (ofLp (dSVUniformDensityThresholdSharedState N d))) = _ rw [dSVDensityRationalCompleteProjectiveBinaryPOVM_effect, dSVDensityRationalCompleteProjectiveBinaryPOVM_effect] theorem dSVDensityRationalCompleteProjectiveOutcome_eq_blockVector {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (a b : Bool) : dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ a b = (‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) • toLp 2 (Matrix.vec ((Matrix.blockDiagonal' fun k : Fin N => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a * (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ζ).effect b).transpose)) := by classical rw [dSVDensityRationalCompleteProjectiveOutcome_eq_block_action] let τ : Fin N → ℝ := fun _ => 1 let P : Fin N → Matrix (Fin d) (Fin d) ℂ := fun k => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a let R : Fin N → Matrix (Fin d) (Fin d) ℂ := fun k => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ζ).effect b let M : Matrix (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) ℂ := Matrix.blockDiagonal' P ⊗ₖ (Matrix.blockDiagonal' R).transpose change Matrix.toEuclideanLin M (sharedThresholdResource (d := Fin d) τ) = _ rw [sharedThresholdResource, (Matrix.toEuclideanLin M).map_smul_of_tower] congr 1 have raw := sharedThresholdResourceRaw_block_action τ P R change toLp 2 (M.mulVec (ofLp (sharedThresholdResourceRaw (d := Fin d) τ))) = toLp 2 (Matrix.vec ((Matrix.blockDiagonal' fun k : Fin N => P k * R k).transpose)) simpa only [M, P, R, τ, Complex.ofReal_one, one_smul] using raw theorem dSVDensityRationalCompleteProjectiveOutcome_norm_sq_eq {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (a b : Bool) : ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ a b‖ ^ 2 = (∑ k : Fin N, (Matrix.trace ((dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a * (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ζ).effect b)).re) / ((d : ℝ) * (N : ℝ)) := by classical rw [dSVDensityRationalCompleteProjectiveOutcome_eq_block_action] let τ : Fin N → ℝ := fun _ => 1 let P : Fin N → Matrix (Fin d) (Fin d) ℂ := fun k => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a let R : Fin N → Matrix (Fin d) (Fin d) ℂ := fun k => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ζ).effect b change ‖toLp 2 ((Matrix.blockDiagonal' P ⊗ₖ (Matrix.blockDiagonal' R).transpose).mulVec (ofLp (sharedThresholdResource (d := Fin d) τ)))‖ ^ 2 = (∑ k : Fin N, (Matrix.trace (P k * R k)).re) / ((d : ℝ) * (N : ℝ)) simpa [τ] using sharedThresholdResource_block_action_norm_sq τ P R (fun k => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).positive a) (fun k => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ζ).positive b) (fun k => dSVDensityRationalCompleteProjectiveThresholdEffect_projective w N ξ k a) (fun k => dSVDensityRationalCompleteProjectiveThresholdEffect_projective w N ζ k b) end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder theorem dSVDensityRationalGridPrefix_nonneg (N : ℕ) (a : ℝ) : 0 ≤ dSVUniformDensityGridPrefix N a := by unfold dSVUniformDensityGridPrefix apply Finset.sum_nonneg intro k _ exact mul_nonneg (dSVUniformDensityThresholdWeight_nonneg N k) (by split <;> norm_num) theorem dSVDensityRationalSoftPass_rescaled_le_density {w a : ℝ} (width : 0 < w) (nonnegative : 0 ≤ a) : w * dSVRationalSoftPass w a ≤ a := by have denominator : 0 < a + w := by linarith unfold dSVRationalSoftPass calc w * (a / (a + w)) = w * a / (a + w) := by ring _ ≤ a := (div_le_iff₀ denominator).mpr (by nlinarith [sq_nonneg a]) theorem dSVDensityRationalSoftPass_density_defect_le {w a : ℝ} (width : 0 < w) (nonnegative : 0 ≤ a) (bounded : a ≤ 1) : a - w * dSVRationalSoftPass w a ≤ a / w := by have denominator : 0 < a + w := by linarith calc a - w * dSVRationalSoftPass w a = a ^ 2 / (a + w) := by unfold dSVRationalSoftPass field_simp ring _ ≤ a / w := by apply (div_le_div_iff₀ denominator width).mpr nlinarith [mul_nonneg (mul_nonneg nonnegative width.le) (sub_nonneg.mpr bounded), sq_nonneg a] theorem dSVDensityRationalGrid_rescaled_le_density {N : ℕ} {w a : ℝ} (width : 0 < w) (grid : 0 < N) (nonnegative : 0 ≤ a) : w * dSVUniformDensityGridPrefix N (dSVRationalSoftPass w a) ≤ a := by obtain ⟨pass_nonnegative, pass_bounded⟩ := dSVRationalSoftPass_mem_unit width nonnegative calc w * dSVUniformDensityGridPrefix N (dSVRationalSoftPass w a) ≤ w * dSVRationalSoftPass w a := mul_le_mul_of_nonneg_left (dSVUniformDensityGridPrefix_le_density grid pass_nonnegative pass_bounded) width.le _ ≤ a := dSVDensityRationalSoftPass_rescaled_le_density width nonnegative theorem dSVDensityRationalGrid_density_defect_le {N : ℕ} {w a : ℝ} (width : 0 < w) (grid : 0 < N) (nonnegative : 0 ≤ a) (bounded : a ≤ 1) : a - w * dSVUniformDensityGridPrefix N (dSVRationalSoftPass w a) ≤ a / w + w / (N : ℝ) := by obtain ⟨pass_nonnegative, pass_bounded⟩ := dSVRationalSoftPass_mem_unit width nonnegative have cell_bound : dSVRationalSoftPass w a - dSVUniformDensityGridPrefix N (dSVRationalSoftPass w a) ≤ 1 / (N : ℝ) := (dSVUniformDensityGridPrefix_density_sub_lt grid pass_nonnegative pass_bounded).le have scaled := mul_le_mul_of_nonneg_left cell_bound width.le have rational := dSVDensityRationalSoftPass_density_defect_le width nonnegative bounded calc a - w * dSVUniformDensityGridPrefix N (dSVRationalSoftPass w a) = (a - w * dSVRationalSoftPass w a) + w * (dSVRationalSoftPass w a - dSVUniformDensityGridPrefix N (dSVRationalSoftPass w a)) := by ring _ ≤ a / w + w * (1 / (N : ℝ)) := add_le_add rational scaled _ = a / w + w / (N : ℝ) := by ring def dSVDensityRationalCanonicalAcceptedCoefficient {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (i : Fin d) : ℝ := Real.sqrt (w * dSVUniformDensityGridPrefix N (dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i))) theorem dSVDensityRationalCanonicalAcceptedCoefficient_nonneg {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (i : Fin d) : 0 ≤ dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i := Real.sqrt_nonneg _ theorem dSVDensityRationalCanonicalAcceptedCoefficient_sq {d : ℕ} {w : ℝ} (width : 0 < w) (N : ℕ) (ξ : BipartiteUnitVector d) (i : Fin d) : dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i ^ 2 = w * dSVUniformDensityGridPrefix N (dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i)) := by unfold dSVDensityRationalCanonicalAcceptedCoefficient apply Real.sq_sqrt exact mul_nonneg width.le (dSVDensityRationalGridPrefix_nonneg _ _) def dSVDensityRationalCanonicalAliceBasis {d : ℕ} (ξ : BipartiteUnitVector d) : Matrix.unitaryGroup (Fin d) ℂ := Classical.choose (exists_proofDSVUniformDensityPolarLeftCanonicalSchmidt ξ) theorem dSVDensityRationalCanonicalAliceBasis_target {d : ℕ} (ξ : BipartiteUnitVector d) : ξ.val = schmidtVector (dSVUniformDensityPolarLeftSchmidtCoefficient ξ) (dSVDensityRationalCanonicalAliceBasis ξ) (dSVUniformDensityThresholdLeftBobBasis ξ) := Classical.choose_spec (exists_proofDSVUniformDensityPolarLeftCanonicalSchmidt ξ) def dSVDensityRationalCanonicalAcceptedTarget {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : EuclideanSpace ℂ (Fin d × Fin d) := schmidtVector (dSVDensityRationalCanonicalAcceptedCoefficient w N ξ) (dSVDensityRationalCanonicalAliceBasis ξ) (dSVUniformDensityThresholdLeftBobBasis ξ) theorem dSVDensityRationalCanonicalAcceptedTarget_norm_sq {d : ℕ} {w : ℝ} (width : 0 < w) (N : ℕ) (ξ : BipartiteUnitVector d) : ‖dSVDensityRationalCanonicalAcceptedTarget w N ξ‖ ^ 2 = w * dSVDensityRationalLeftProjectiveDiagonalMass w N ξ := by unfold dSVDensityRationalCanonicalAcceptedTarget rw [schmidtVector_norm_sq] simp_rw [dSVDensityRationalCanonicalAcceptedCoefficient_sq width] unfold dSVDensityRationalLeftProjectiveDiagonalMass rw [Finset.mul_sum] theorem dSVDensityRationalCanonicalAcceptedTarget_distance_sq_eq {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : ‖ξ.val - dSVDensityRationalCanonicalAcceptedTarget w N ξ‖ ^ 2 = ∑ i : Fin d, (dSVUniformDensityPolarLeftSchmidtCoefficient ξ i - dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i) ^ 2 := by rw [dSVDensityRationalCanonicalAliceBasis_target ξ] unfold dSVDensityRationalCanonicalAcceptedTarget rw [dSVUniformDensitySchmidtVector_sub, schmidtVector_norm_sq] theorem dSVDensityRationalCanonicalAcceptedCoefficient_error_sq_le {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ : BipartiteUnitVector d) (i : Fin d) : (dSVUniformDensityPolarLeftSchmidtCoefficient ξ i - dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i) ^ 2 ≤ ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) / w + w / (N : ℝ) := by let a := ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) let b := w * dSVUniformDensityGridPrefix N (dSVRationalSoftPass w a) have ha : 0 ≤ a := (dSVSoftBobLeftReducedDensity_posSemidef ξ).eigenvalues_nonneg i have ha_one : a ≤ 1 := dSVSoftBobLeftReducedDensity_eigenvalue_le_one ξ i have hb : 0 ≤ b := mul_nonneg width.le (dSVDensityRationalGridPrefix_nonneg N _) have below : b ≤ a := dSVDensityRationalGrid_rescaled_le_density width grid ha have roots := dSVAdaptiveSoft_sqrt_sub_sq_le_abs a b ha hb rw [abs_of_nonneg (sub_nonneg.mpr below)] at roots have defect := dSVDensityRationalGrid_density_defect_le width grid ha ha_one change (Real.sqrt a - Real.sqrt b) ^ 2 ≤ a / w + w / (N : ℝ) exact roots.trans defect theorem dSVDensityRationalCanonicalAcceptedTarget_distance_sq_le {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ : BipartiteUnitVector d) : ‖ξ.val - dSVDensityRationalCanonicalAcceptedTarget w N ξ‖ ^ 2 ≤ 1 / w + (d : ℝ) * w / (N : ℝ) := by rw [dSVDensityRationalCanonicalAcceptedTarget_distance_sq_eq] calc (∑ i : Fin d, (dSVUniformDensityPolarLeftSchmidtCoefficient ξ i - dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i) ^ 2) ≤ ∑ i : Fin d, (((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) / w + w / (N : ℝ)) := Finset.sum_le_sum (fun i _ => dSVDensityRationalCanonicalAcceptedCoefficient_error_sq_le width grid ξ i) _ = 1 / w + (d : ℝ) * w / (N : ℝ) := by rw [Finset.sum_add_distrib, ← Finset.sum_div] rw [positiveDensity_eigenvalues_sum (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_trace ξ)] simp ring theorem dSVDensityRationalCanonicalAcceptedTarget_distance_le {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ : BipartiteUnitVector d) : ‖ξ.val - dSVDensityRationalCanonicalAcceptedTarget w N ξ‖ ≤ Real.sqrt (1 / w + (d : ℝ) * w / (N : ℝ)) := by have nonnegative : 0 ≤ 1 / w + (d : ℝ) * w / (N : ℝ) := by positivity have squared := dSVDensityRationalCanonicalAcceptedTarget_distance_sq_le width grid ξ have exact_sqrt := Real.sq_sqrt nonnegative nlinarith [norm_nonneg (ξ.val - dSVDensityRationalCanonicalAcceptedTarget w N ξ), Real.sqrt_nonneg (1 / w + (d : ℝ) * w / (N : ℝ))] theorem dSVDensityRationalCanonicalAcceptedTarget_ne_zero {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (ξ : BipartiteUnitVector d) : dSVDensityRationalCanonicalAcceptedTarget w N ξ ≠ 0 := by intro zero have actual := dSVDensityRationalCanonicalAcceptedTarget_norm_sq width N ξ rw [zero, norm_zero, zero_pow (by norm_num : 2 ≠ 0)] at actual have lower := dSVDensityRationalLeftProjectiveDiagonalMass_lower width grid ξ nlinarith def dSVDensityRationalCanonicalNormalizedTarget {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : EuclideanSpace ℂ (Fin d × Fin d) := NormedSpace.normalize (dSVDensityRationalCanonicalAcceptedTarget w N ξ) theorem dSVDensityRationalCanonicalNormalizedTarget_norm {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (ξ : BipartiteUnitVector d) : ‖dSVDensityRationalCanonicalNormalizedTarget w N ξ‖ = 1 := by unfold dSVDensityRationalCanonicalNormalizedTarget exact NormedSpace.norm_normalize (dSVDensityRationalCanonicalAcceptedTarget_ne_zero width grid fine ξ) theorem dSVDensityRationalCanonicalNormalizedTarget_distance_le {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (ξ : BipartiteUnitVector d) : ‖ξ.val - dSVDensityRationalCanonicalNormalizedTarget w N ξ‖ ≤ 2 * Real.sqrt (1 / w + (d : ℝ) * w / (N : ℝ)) := by let v := dSVDensityRationalCanonicalAcceptedTarget w N ξ have nonzero : v ≠ 0 := dSVDensityRationalCanonicalAcceptedTarget_ne_zero width grid fine ξ have reverse : |1 - ‖v‖| ≤ ‖ξ.val - v‖ := by have actual := abs_norm_sub_norm_le ξ.val v simpa [ξ.property] using actual have movement : ‖v - NormedSpace.normalize v‖ = |1 - ‖v‖| := by rw [norm_sub_rev] exact dSVUniformDensity_normalize_sub_self_norm v nonzero change ‖ξ.val - NormedSpace.normalize v‖ ≤ _ calc ‖ξ.val - NormedSpace.normalize v‖ = ‖(ξ.val - v) + (v - NormedSpace.normalize v)‖ := by congr 1 abel _ ≤ ‖ξ.val - v‖ + ‖v - NormedSpace.normalize v‖ := norm_add_le _ _ _ ≤ 2 * ‖ξ.val - v‖ := by rw [movement] linarith _ ≤ 2 * Real.sqrt (1 / w + (d : ℝ) * w / (N : ℝ)) := by gcongr exact dSVDensityRationalCanonicalAcceptedTarget_distance_le width grid ξ def dSVDensityRationalCanonicalAcceptedUnitTarget {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (ξ : BipartiteUnitVector d) : BipartiteUnitVector d := ⟨dSVDensityRationalCanonicalNormalizedTarget w N ξ, dSVDensityRationalCanonicalNormalizedTarget_norm width grid fine ξ⟩ theorem dSVDensityRationalCanonicalAcceptedUnitTarget_distance_le {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (ξ : BipartiteUnitVector d) : ‖ξ.val - (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine ξ).val‖ ≤ 2 * Real.sqrt (1 / w + (d : ℝ) * w / (N : ℝ)) := dSVDensityRationalCanonicalNormalizedTarget_distance_le width grid fine ξ end noncomputable section open WithLp open scoped BigOperators ComplexOrder MatrixOrder theorem dSVDensityRationalLargeWidthDiagonalMass_half {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / N ≤ 1 / (2 * (w + 1))) (ξ : BipartiteUnitVector d) : 1 / (2 * (w + 1)) ≤ dSVDensityRationalLeftProjectiveDiagonalMass w N ξ := by have denominator : 0 < w + 1 := by linarith have arithmetic : 1 / (2 * (w + 1)) ≤ 1 / (w + 1) - (d : ℝ) / N := by have identity : 1 / (w + 1) - 1 / (2 * (w + 1)) = 1 / (2 * (w + 1)) := by field_simp; ring linarith exact arithmetic.trans (dSVDensityRationalLeftProjectiveDiagonalMass_lower width grid ξ) theorem dSVDensityRationalLargeWidthDiagonalMass_pos {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / N ≤ 1 / (2 * (w + 1))) (ξ : BipartiteUnitVector d) : 0 < dSVDensityRationalLeftProjectiveDiagonalMass w N ξ := by have lower := dSVDensityRationalLargeWidthDiagonalMass_half width grid fine ξ have positive : 0 < 1 / (2 * (w + 1)) := by positivity exact positive.trans_le lower theorem dSVDensityRationalLargeWidthRelativeMismatch_le_discrepancy {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / N ≤ 1 / (2 * (w + 1))) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / dSVDensityRationalLeftProjectiveDiagonalMass w N ξ ≤ 2 * (w + 1) * (dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ / w + (d : ℝ) / N) := by let M := dSVDensityRationalLeftProjectiveDiagonalMass w N ξ let D := dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ / w + (d : ℝ) / N have mass_positive : 0 < M := dSVDensityRationalLargeWidthDiagonalMass_pos width grid fine ξ have mass_floor : 1 / (2 * (w + 1)) ≤ M := dSVDensityRationalLargeWidthDiagonalMass_half width grid fine ξ have difference_nonnegative : 0 ≤ dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ := by unfold dSVUniformLeftDensitySpectralAtomDiscrepancy apply Finset.sum_nonneg intro i _ apply Finset.sum_nonneg intro j _ exact mul_nonneg (abs_nonneg _) (spectralAtomOverlap_nonneg _ _ _ _ i j) have defect_nonnegative : 0 ≤ D := by dsimp [D] exact add_nonneg (div_nonneg difference_nonnegative width.le) (by positivity) have actual := dSVDensityRationalLeftProjectiveThresholdAtomMismatch_le_discrepancy width grid ξ ζ change dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / M ≤ 2 * (w + 1) * D apply (div_le_iff₀ mass_positive).mpr have floor_scaled : 1 ≤ 2 * (w + 1) * M := by have denominator : 0 < 2 * (w + 1) := by positivity have crossed := (div_le_iff₀ denominator).mp mass_floor nlinarith change dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ ≤ (2 * (w + 1) * D) * M calc dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ ≤ D := actual _ ≤ D * (2 * (w + 1) * M) := by nlinarith [mul_nonneg defect_nonnegative (show 0 ≤ 2 * (w + 1) * M - 1 by linarith)] _ = (2 * (w + 1) * D) * M := by ring theorem dSVDensityRationalLargeWidthRelativeMismatch_le_targetDistance {d N : ℕ} {w : ℝ} (large : 1 ≤ w) (grid : 0 < N) (fine : (d : ℝ) / N ≤ 1 / (2 * (w + 1))) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / dSVDensityRationalLeftProjectiveDiagonalMass w N ξ ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (w + 1) * ((d : ℝ) / N) := by have width : 0 < w := lt_of_lt_of_le (by norm_num) large have distance := dSVUniformLeftDensitySpectralAtomDiscrepancy_le ξ ζ have root : 0 ≤ Real.sqrt (2 : ℝ) := Real.sqrt_nonneg _ have distance_nonnegative : 0 ≤ ‖ξ.val - ζ.val‖ := norm_nonneg _ have denominator : 0 < w := width have ratio : (w + 1) / w ≤ 2 := by apply (div_le_iff₀ denominator).mpr nlinarith calc dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / dSVDensityRationalLeftProjectiveDiagonalMass w N ξ ≤ 2 * (w + 1) * (dSVUniformLeftDensitySpectralAtomDiscrepancy ξ ζ / w + (d : ℝ) / N) := dSVDensityRationalLargeWidthRelativeMismatch_le_discrepancy width grid fine ξ ζ _ ≤ 2 * (w + 1) * ((2 * Real.sqrt 2 * ‖ξ.val - ζ.val‖) / w + (d : ℝ) / N) := by gcongr _ = 4 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ * ((w + 1) / w) + 2 * (w + 1) * ((d : ℝ) / N) := by field_simp; ring _ ≤ (4 * Real.sqrt 2 * ‖ξ.val - ζ.val‖) * 2 + 2 * (w + 1) * ((d : ℝ) / N) := by have scale_nonnegative : 0 ≤ 4 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ := by positivity have scaled := mul_le_mul_of_nonneg_left ratio scale_nonnegative exact add_le_add scaled (le_refl _) _ = 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (w + 1) * ((d : ℝ) / N) := by ring theorem dSVDensityRationalLargeWidth_exists_fine_grid (d : ℕ) (dimension : 0 < d) (w : ℝ) (width : 0 < w) (ε : ℝ) (precision : 0 < ε) : ∃ N : ℕ, 0 < N ∧ 2 * (w + 1) * ((d : ℝ) / N) ≤ ε := by have denominator : 0 < ε / (2 * (w + 1)) := by positivity obtain ⟨N, large⟩ := exists_nat_gt ((d : ℝ) / (ε / (2 * (w + 1)))) have real_dimension : 0 < (d : ℝ) := by exact_mod_cast dimension have real_grid : 0 < (N : ℝ) := lt_trans (div_pos real_dimension denominator) large have grid : 0 < N := by exact_mod_cast real_grid refine ⟨N, grid, ?_⟩ have crossed := (div_lt_iff₀ denominator).mp large have small : (d : ℝ) / N < ε / (2 * (w + 1)) := by apply (div_lt_iff₀ real_grid).mpr nlinarith have positive : 0 < 2 * (w + 1) := by positivity have scaled := (lt_div_iff₀ positive).mp small linarith theorem dSVDensityRationalLargeWidth_exists_sourceUniformParameters (d : ℕ) (dimension : 0 < d) (ε : ℝ) (precision : 0 < ε) (small : ε ≤ 1) : ∃ (w : ℝ) (N : ℕ), 1 ≤ w ∧ 0 < N ∧ 2 * (w + 1) * ((d : ℝ) / N) ≤ ε ∧ (1 / w + w * ((d : ℝ) / N) ≤ 3 * ε / 2) ∧ (∀ ξ : BipartiteUnitVector d, 0 < dSVDensityRationalLeftProjectiveDiagonalMass w N ξ) ∧ (∀ ξ ζ : BipartiteUnitVector d, dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / dSVDensityRationalLeftProjectiveDiagonalMass w N ξ ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + ε) := by let w : ℝ := 1 / ε have width : 0 < w := by dsimp [w]; positivity have large : 1 ≤ w := by dsimp [w] exact (le_div_iff₀ precision).mpr (by simpa using small) obtain ⟨N, grid, budget⟩ := dSVDensityRationalLargeWidth_exists_fine_grid d dimension w width ε precision have fine : (d : ℝ) / N ≤ 1 / (2 * (w + 1)) := by have denominator : 0 < 2 * (w + 1) := by positivity apply (le_div_iff₀ denominator).mpr nlinarith have inverse : 1 / w = ε := by dsimp [w] field_simp have rounding : 1 / w + w * ((d : ℝ) / N) ≤ 3 * ε / 2 := by have grid_cost : w * ((d : ℝ) / N) ≤ ε / 2 := by have weight : 0 ≤ (d : ℝ) / N := by positivity nlinarith rw [inverse] linarith refine ⟨w, N, large, grid, budget, rounding, ?_, ?_⟩ · intro ξ exact dSVDensityRationalLargeWidthDiagonalMass_pos width grid fine ξ · intro ξ ζ exact (dSVDensityRationalLargeWidthRelativeMismatch_le_targetDistance large grid fine ξ ζ).trans (by gcongr) theorem dSVDensityRationalLargeWidthPhysicalDiagonalBornSuccess_pos {d N : ℕ} (dimension : 0 < d) {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / N ≤ 1 / (2 * (w + 1))) (ξ : BipartiteUnitVector d) : 0 < dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ := by rw [dSVDensityRationalPhysicalDiagonalBornSuccess_eq grid dimension w ξ] exact div_pos (dSVDensityRationalLargeWidthDiagonalMass_pos width grid fine ξ) (by exact_mod_cast dimension) theorem dSVDensityRationalLargeWidthPhysicalRelativeHazard_eq {d N : ℕ} (dimension : 0 < d) {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / N ≤ 1 / (2 * (w + 1))) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalPhysicalProjectorCrossHazard N w ξ ζ / dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ = dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / dSVDensityRationalLeftProjectiveDiagonalMass w N ξ := by rw [dSVDensityRationalPhysicalProjectorCrossHazard_eq grid dimension w ξ ζ, dSVDensityRationalPhysicalDiagonalBornSuccess_eq grid dimension w ξ] have dimension_ne : (d : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt dimension) have mass_ne : dSVDensityRationalLeftProjectiveDiagonalMass w N ξ ≠ 0 := ne_of_gt (dSVDensityRationalLargeWidthDiagonalMass_pos width grid fine ξ) field_simp theorem dSVDensityRationalLargeWidthPhysicalRelativeHazard_le {d N : ℕ} (dimension : 0 < d) {w : ℝ} (large : 1 ≤ w) (grid : 0 < N) (fine : (d : ℝ) / N ≤ 1 / (2 * (w + 1))) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalPhysicalProjectorCrossHazard N w ξ ζ / dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (w + 1) * ((d : ℝ) / N) := by have width : 0 < w := lt_of_lt_of_le (by norm_num) large rw [dSVDensityRationalLargeWidthPhysicalRelativeHazard_eq dimension width grid fine ξ ζ] exact dSVDensityRationalLargeWidthRelativeMismatch_le_targetDistance large grid fine ξ ζ end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVDensityRationalPhysicalMixedBornSuccess {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : ℝ := binaryJointSuccessProbability (dSVUniformDensityThresholdSharedDensity grid dimension) (dSVDensityRationalPhysicalGlobalPOVM w ξ) (transposePOVM (dSVDensityRationalPhysicalGlobalPOVM w ζ)) theorem dSVDensityRationalPhysicalMixedBornSuccess_eq {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalPhysicalMixedBornSuccess grid dimension w ξ ζ = (∑ k : Fin N, (Matrix.trace (dSVDensityRationalPhysicalProjector w ξ k * dSVDensityRationalPhysicalProjector w ζ k)).re) / ((d : ℝ) * (N : ℝ)) := by unfold dSVDensityRationalPhysicalMixedBornSuccess dSVDensityRationalPhysicalGlobalPOVM exact dSVUniformDensityThresholdShared_mixedBorn_eq grid dimension (dSVDensityRationalPhysicalProjector w ξ) (dSVDensityRationalPhysicalProjector w ζ) (dSVDensityRationalPhysicalProjector_pos w ξ) (dSVDensityRationalPhysicalProjector_complement_pos w ξ) (dSVDensityRationalPhysicalProjector_pos w ζ) (dSVDensityRationalPhysicalProjector_complement_pos w ζ) (dSVDensityRationalPhysicalProjector_projective w ξ) (dSVDensityRationalPhysicalProjector_projective w ζ) theorem dSVDensityRationalPhysicalMixedBornSuccess_loss_le {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ - dSVDensityRationalPhysicalMixedBornSuccess grid dimension w ξ ζ ≤ dSVDensityRationalPhysicalProjectorCrossHazard N w ξ ζ := by have denominator : 0 < (d : ℝ) * (N : ℝ) := by exact mul_pos (by exact_mod_cast dimension) (by exact_mod_cast grid) have diagonal : dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ = (∑ k : Fin N, (Matrix.trace (dSVDensityRationalPhysicalProjector w ξ k)).re) / ((d : ℝ) * (N : ℝ)) := by unfold dSVDensityRationalPhysicalDiagonalBornSuccess dSVDensityRationalPhysicalGlobalPOVM exact dSVUniformDensityThresholdShared_diagonalBorn_eq grid dimension (dSVDensityRationalPhysicalProjector w ξ) (dSVDensityRationalPhysicalProjector_pos w ξ) (dSVDensityRationalPhysicalProjector_complement_pos w ξ) (dSVDensityRationalPhysicalProjector_projective w ξ) have ledger := dSVWeightedMixedProjectorSuccessLoss_le_square (fun _ : Fin N => (1 : ℝ)) (fun _ => zero_le_one) (dSVDensityRationalPhysicalProjector w ξ) (dSVDensityRationalPhysicalProjector w ζ) (dSVDensityRationalPhysicalProjector_complement_pos w ξ) (dSVDensityRationalPhysicalProjector_pos w ζ) (dSVDensityRationalPhysicalProjector_projective w ξ) (dSVDensityRationalPhysicalProjector_projective w ζ) simp only [one_mul] at ledger rw [diagonal, dSVDensityRationalPhysicalMixedBornSuccess_eq grid dimension w ξ ζ] unfold dSVDensityRationalPhysicalProjectorCrossHazard rw [← sub_div] exact (div_le_div_iff_of_pos_right denominator).mpr ledger end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder def dSVDensityRationalActualMixedSuccessMass {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : ℝ := ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ true true‖ ^ 2 def dSVDensityRationalActualMixedContinueMass {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : ℝ := ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ false false‖ ^ 2 def dSVDensityRationalActualMixedAsynchronousMass {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : ℝ := ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ true false‖ ^ 2 + ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ false true‖ ^ 2 theorem dSVDensityRationalActualMixedSuccessMass_eq {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalActualMixedSuccessMass w N ξ ζ = dSVDensityRationalPhysicalMixedBornSuccess grid dimension w ξ ζ := by unfold dSVDensityRationalActualMixedSuccessMass rw [dSVDensityRationalCompleteProjectiveOutcome_norm_sq_eq, dSVDensityRationalPhysicalMixedBornSuccess_eq grid dimension w ξ ζ] rfl theorem dSVDensityRationalActualMixedOutcome_norm_sq_eq_born {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) (a b : Bool) : ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ a b‖ ^ 2 = binaryBornProbability (dSVUniformDensityThresholdSharedDensity grid dimension) (dSVDensityRationalPhysicalGlobalPOVM w ξ) (transposePOVM (dSVDensityRationalPhysicalGlobalPOVM w ζ)) a b := by let A := dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ let B := dSVDensityRationalCompleteProjectiveBinaryPOVM w N ζ let z := dSVUniformDensityThresholdSharedState N d have alice_physical : A = dSVDensityRationalPhysicalGlobalPOVM w ξ := by rfl have bob_physical : B = dSVDensityRationalPhysicalGlobalPOVM w ζ := by rfl have actual := coherentBinaryJointOutcome_norm_sq A (transposePOVM B) (dSVDensityRationalCompleteProjectiveBinaryPOVM_projective w N ξ) (transposePOVM_projective B (dSVDensityRationalCompleteProjectiveBinaryPOVM_projective w N ζ)) z (dSVUniformDensityThresholdSharedState_norm grid dimension) a b rw [alice_physical, bob_physical] at actual simpa [z, dSVDensityRationalCompleteProjectiveOutcome, dSVUniformDensityThresholdSharedDensity, binaryBornProbability, ← alice_physical, ← bob_physical] using actual theorem dSVDensityRationalActualMixedContinueMass_eq_born {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalActualMixedContinueMass w N ξ ζ = binaryContinueProbability (dSVUniformDensityThresholdSharedDensity grid dimension) (dSVDensityRationalPhysicalGlobalPOVM w ξ) (transposePOVM (dSVDensityRationalPhysicalGlobalPOVM w ζ)) := by unfold dSVDensityRationalActualMixedContinueMass binaryContinueProbability exact dSVDensityRationalActualMixedOutcome_norm_sq_eq_born grid dimension w ξ ζ false false theorem dSVDensityRationalActualMixedAsynchronousMass_eq_born {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalActualMixedAsynchronousMass w N ξ ζ = binaryMismatchProbability (dSVUniformDensityThresholdSharedDensity grid dimension) (dSVDensityRationalPhysicalGlobalPOVM w ξ) (transposePOVM (dSVDensityRationalPhysicalGlobalPOVM w ζ)) := by unfold dSVDensityRationalActualMixedAsynchronousMass binaryMismatchProbability rw [dSVDensityRationalActualMixedOutcome_norm_sq_eq_born grid dimension w ξ ζ true false, dSVDensityRationalActualMixedOutcome_norm_sq_eq_born grid dimension w ξ ζ false true] theorem dSVDensityRationalActualMixed_mass_partition {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalActualMixedContinueMass w N ξ ζ + dSVDensityRationalActualMixedSuccessMass w N ξ ζ + dSVDensityRationalActualMixedAsynchronousMass w N ξ ζ = 1 := by rw [dSVDensityRationalActualMixedContinueMass_eq_born grid dimension w ξ ζ, dSVDensityRationalActualMixedSuccessMass_eq grid dimension w ξ ζ, dSVDensityRationalActualMixedAsynchronousMass_eq_born grid dimension w ξ ζ] unfold dSVDensityRationalPhysicalMixedBornSuccess exact binaryStoppingPartition (dSVUniformDensityThresholdSharedDensity grid dimension) (dSVDensityRationalPhysicalGlobalPOVM w ξ) (transposePOVM (dSVDensityRationalPhysicalGlobalPOVM w ζ)) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalCompletePhysicalStoppingCopyAccepted {N d : ℕ} (w : ℝ) (ξ : BipartiteUnitVector d) (q : DSVUniformDensityThresholdLocalIndex N d) : Prop := dSVDensityRationalProjectiveThresholdBin w N q.1 ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues q.2) = true end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVDensityRationalPhysicalAcceptedOutcome {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ true true def dSVDensityRationalPhysicalAcceptedRank {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (i : Fin d) : Fin (N + 1) := let selected : Finset (Fin N) := Finset.univ.filter fun k : Fin N => dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ⟨selected.card, by have bounded : selected.card ≤ N := by simpa using Finset.card_le_univ selected omega⟩ theorem dSVDensityRationalPhysicalAcceptedRank_gridPrefix {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (i : Fin d) : dSVUniformDensityGridPrefix N (dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i)) = ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) / (N : ℝ) := by classical rw [dSVUniformDensityGridPrefix_eq_count] simp [dSVDensityRationalPhysicalAcceptedRank, dSVDensityRationalProjectiveThresholdBin] theorem dSVDensityRationalPhysicalAcceptedRank_targetCoefficient_sq {d : ℕ} {w : ℝ} (width : 0 < w) (N : ℕ) (ξ : BipartiteUnitVector d) (i : Fin d) : dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i ^ 2 = w * ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) / (N : ℝ) := by rw [dSVDensityRationalCanonicalAcceptedCoefficient_sq width N ξ i, dSVDensityRationalPhysicalAcceptedRank_gridPrefix] ring end noncomputable section open WithLp open scoped BigOperators ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable theorem dSVUniformDensityGridPrefix_mono (N : ℕ) {a b : ℝ} (ordered : a ≤ b) : dSVUniformDensityGridPrefix N a ≤ dSVUniformDensityGridPrefix N b := by unfold dSVUniformDensityGridPrefix apply Finset.sum_le_sum intro k _ apply mul_le_mul_of_nonneg_left _ (dSVUniformDensityThresholdWeight_nonneg N k) by_cases low : dSVUniformDensityThresholdGrid N k ≤ a · have high : dSVUniformDensityThresholdGrid N k ≤ b := low.trans ordered simp [low, high] · by_cases high : dSVUniformDensityThresholdGrid N k ≤ b · simp [low, high] · simp [low, high] theorem dSVUniformDensityThresholdMismatch_eq_sub_of_le (N : ℕ) {a b : ℝ} (ordered : a ≤ b) : dSVUniformDensityThresholdMismatch N a b = dSVUniformDensityGridPrefix N b - dSVUniformDensityGridPrefix N a := by unfold dSVUniformDensityThresholdMismatch dSVUniformDensityGridPrefix rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro k _ by_cases low : dSVUniformDensityThresholdGrid N k ≤ a · have high : dSVUniformDensityThresholdGrid N k ≤ b := low.trans ordered simp [low, high] · by_cases high : dSVUniformDensityThresholdGrid N k ≤ b · simp [low, high] · simp [low, high] theorem dSVUniformDensityThresholdMismatch_eq_abs_gridPrefix (N : ℕ) (a b : ℝ) : dSVUniformDensityThresholdMismatch N a b = |dSVUniformDensityGridPrefix N a - dSVUniformDensityGridPrefix N b| := by rcases le_total a b with ordered | ordered · rw [dSVUniformDensityThresholdMismatch_eq_sub_of_le N ordered] rw [abs_of_nonpos (sub_nonpos.mpr (dSVUniformDensityGridPrefix_mono N ordered))] ring · have symmetric : dSVUniformDensityThresholdMismatch N a b = dSVUniformDensityThresholdMismatch N b a := by unfold dSVUniformDensityThresholdMismatch apply Finset.sum_congr rfl intro k _ by_cases low : dSVUniformDensityThresholdGrid N k ≤ a · by_cases high : dSVUniformDensityThresholdGrid N k ≤ b · simp [low, high] · simp [low, high] · by_cases high : dSVUniformDensityThresholdGrid N k ≤ b · simp [low, high] · simp [low, high] rw [symmetric, dSVUniformDensityThresholdMismatch_eq_sub_of_le N ordered, abs_of_nonneg (sub_nonneg.mpr (dSVUniformDensityGridPrefix_mono N ordered))] theorem dSVDensityRationalPhysicalAcceptedRankMismatch_eq_thresholdMismatch {d N : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : |((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) - ((dSVDensityRationalPhysicalAcceptedRank w N ζ j).val : ℝ)| / (N : ℝ) = dSVUniformDensityThresholdMismatch N (dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i)) (dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j)) := by rw [dSVUniformDensityThresholdMismatch_eq_abs_gridPrefix, dSVDensityRationalPhysicalAcceptedRank_gridPrefix, dSVDensityRationalPhysicalAcceptedRank_gridPrefix, ← sub_div, abs_div, abs_of_nonneg (by positivity : (0 : ℝ) ≤ N)] def dSVDensityRationalPrefixRankMismatch {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : ℝ := (∑ i : Fin d, ∑ j : Fin d, spectralAtomOverlap (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) i j * |((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) - ((dSVDensityRationalPhysicalAcceptedRank w N ζ j).val : ℝ)|) / (N : ℝ) theorem dSVDensityRationalPrefixRankMismatch_eq_atomMismatch {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalPrefixRankMismatch w N ξ ζ = dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ := by unfold dSVDensityRationalPrefixRankMismatch dSVDensityRationalLeftProjectiveThresholdAtomMismatch simp_rw [Finset.sum_div] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ rw [mul_div_assoc, dSVDensityRationalPhysicalAcceptedRankMismatch_eq_thresholdMismatch] theorem dSVDensityRationalPrefixRankMismatch_physicalHazard {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalPrefixRankMismatch w N ξ ζ / (d : ℝ) = dSVDensityRationalPhysicalProjectorCrossHazard N w ξ ζ := by rw [dSVDensityRationalPrefixRankMismatch_eq_atomMismatch, dSVDensityRationalPhysicalProjectorCrossHazard_eq grid dimension w ξ ζ] end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder theorem dSVDensityRationalPhysicalAcceptedRank_eq_floor {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ : BipartiteUnitVector d) (i : Fin d) : (dSVDensityRationalPhysicalAcceptedRank w N ξ i).val = Nat.floor (dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) * (N : ℝ)) := by have unit := dSVRationalSoftPass_mem_unit width ((dSVSoftBobLeftReducedDensity_posSemidef ξ).eigenvalues_nonneg i) simpa [dSVDensityRationalPhysicalAcceptedRank, dSVDensityRationalProjectiveThresholdBin] using (dSVUniformDensityThresholdGrid_count_eq_floor grid (dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i)) unit.1 unit.2) theorem dSVDensityRationalProjectiveThresholdBin_eq_true_iff_prefix {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ : BipartiteUnitVector d) (i : Fin d) (k : Fin N) : dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ↔ k.val < (dSVDensityRationalPhysicalAcceptedRank w N ξ i).val := by have real_grid : (0 : ℝ) < N := by exact_mod_cast grid have pass_nonnegative := (dSVRationalSoftPass_mem_unit width ((dSVSoftBobLeftReducedDensity_posSemidef ξ).eigenvalues_nonneg i)).1 have product_nonnegative : 0 ≤ dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) * (N : ℝ) := mul_nonneg pass_nonnegative real_grid.le rw [dSVDensityRationalPhysicalAcceptedRank_eq_floor width grid ξ i] unfold dSVDensityRationalProjectiveThresholdBin simp only [decide_eq_true_eq] rw [dSVUniformDensityThresholdGrid_apply grid, div_le_iff₀ real_grid] constructor · intro accepted have cast : ((k.val + 1 : ℕ) : ℝ) ≤ dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) * (N : ℝ) := by simpa using accepted have below := (Nat.le_floor_iff product_nonnegative).2 cast omega · intro below have integer : k.val + 1 ≤ Nat.floor (dSVRationalSoftPass w ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) * (N : ℝ)) := by omega have cast := (Nat.le_floor_iff product_nonnegative).1 integer simpa using cast end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalMixedSpectralAtomBlock {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (a b : Bool) (k : Fin N) : Matrix (Fin d) (Fin d) ℂ := let F := dSVSoftBobLeftReducedDensity ξ let G := dSVSoftBobLeftReducedDensity ζ let hF := dSVSoftBobLeftReducedDensity_posSemidef ξ let hG := dSVSoftBobLeftReducedDensity_posSemidef ζ ∑ i : Fin d, ∑ j : Fin d, if dSVDensityRationalProjectiveThresholdBin w N k (hF.isHermitian.eigenvalues i) = a ∧ dSVDensityRationalProjectiveThresholdBin w N k (hG.isHermitian.eigenvalues j) = b then positiveMatrixSpectralAtom F hF i * positiveMatrixSpectralAtom G hG j else 0 theorem dSVDensityRationalMixedSpectralAtomBlock_eq_projectorProduct {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (a b : Bool) (k : Fin N) : dSVDensityRationalMixedSpectralAtomBlock w N ξ ζ a b k = (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect a * (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ζ).effect b := by classical unfold dSVDensityRationalMixedSpectralAtomBlock dSVDensityRationalLeftProjectiveThresholdPOVM dSVDensityRationalProjectiveThresholdPOVM spectralPartitionPOVM simp only [Finset.sum_filter] rw [Finset.sum_mul] apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j _ by_cases alice : dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = a · by_cases bob : dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = b · simp [alice, bob] · simp [alice, bob] · by_cases bob : dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = b · simp [alice, bob] · simp [alice, bob] theorem dSVDensityRationalMixedSpectralAtomBlock_trace_eq {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (a b : Bool) (k : Fin N) : (Matrix.trace (dSVDensityRationalMixedSpectralAtomBlock w N ξ ζ a b k)).re = ∑ i : Fin d, ∑ j : Fin d, if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = a ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = b then spectralAtomOverlap (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) i j else 0 := by unfold dSVDensityRationalMixedSpectralAtomBlock simp only [Matrix.trace_sum, Complex.re_sum] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ split_ifs <;> simp [spectralAtomOverlap] end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder theorem dSVDensityRationalActualMixedAsynchronousMass_eq_crossHazard {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalActualMixedAsynchronousMass w N ξ ζ = dSVDensityRationalPhysicalProjectorCrossHazard N w ξ ζ := by classical unfold dSVDensityRationalActualMixedAsynchronousMass rw [dSVDensityRationalCompleteProjectiveOutcome_norm_sq_eq, dSVDensityRationalCompleteProjectiveOutcome_norm_sq_eq] unfold dSVDensityRationalPhysicalProjectorCrossHazard rw [← add_div] congr 1 rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro k _ rw [dSVDensityRationalCompleteProjectiveThresholdEffect_false w N ζ k, dSVDensityRationalCompleteProjectiveThresholdEffect_false w N ξ k] let P := dSVDensityRationalPhysicalProjector w ξ k let R := dSVDensityRationalPhysicalProjector w ζ k change (Matrix.trace (P * (1 - R))).re + (Matrix.trace ((1 - P) * R)).re = (Matrix.trace ((P - R) * (P - R))).re have square := dSVProjectorSquaredDifference_trace P R (dSVDensityRationalPhysicalProjector_projective w ξ k) (dSVDensityRationalPhysicalProjector_projective w ζ k) rw [square] simp [Matrix.mul_sub, Matrix.sub_mul, Matrix.trace_sub] ring theorem dSVDensityRationalActualMixed_escape_ge_diagonal {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ ≤ dSVDensityRationalActualMixedSuccessMass w N ξ ζ + dSVDensityRationalActualMixedAsynchronousMass w N ξ ζ := by have loss := dSVDensityRationalPhysicalMixedBornSuccess_loss_le grid dimension w ξ ζ rw [← dSVDensityRationalActualMixedSuccessMass_eq grid dimension w ξ ζ, ← dSVDensityRationalActualMixedAsynchronousMass_eq_crossHazard w N ξ ζ] at loss linarith end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalPhysicalMixedAcceptedIntersectionRank {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : Fin (N + 1) := ⟨min (dSVDensityRationalPhysicalAcceptedRank w N ξ i).val (dSVDensityRationalPhysicalAcceptedRank w N ζ j).val, by have left := (dSVDensityRationalPhysicalAcceptedRank w N ξ i).isLt have right := (dSVDensityRationalPhysicalAcceptedRank w N ζ j).isLt omega⟩ theorem dSVDensityRationalPhysicalMixedAcceptedThreshold_iff {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) (k : Fin N) : (dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true) ↔ k.val < (dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j).val := by rw [dSVDensityRationalProjectiveThresholdBin_eq_true_iff_prefix width grid ξ i k, dSVDensityRationalProjectiveThresholdBin_eq_true_iff_prefix width grid ζ j k] change _ ↔ k.val < min (dSVDensityRationalPhysicalAcceptedRank w N ξ i).val (dSVDensityRationalPhysicalAcceptedRank w N ζ j).val omega theorem dSVDensityRationalPhysicalMixedAcceptedThreshold_count {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : (Finset.univ.filter fun k : Fin N => dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true).card = (dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j).val := by let rank := dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j have bound : rank.val ≤ N := by have actual := rank.isLt omega have same : (Finset.univ.filter fun k : Fin N => dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true) = Finset.univ.filter fun k : Fin N => k.val < rank.val := by ext k simp only [Finset.mem_filter, Finset.mem_univ, true_and] exact dSVDensityRationalPhysicalMixedAcceptedThreshold_iff width grid ξ ζ i j k rw [same, Fin.card_filter_val_lt, min_eq_right bound] theorem dSVDensityRationalMixedAcceptedPrefix_norm_sq {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ ζ : BipartiteUnitVector d) : ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ true true‖ ^ 2 = (∑ i : Fin d, ∑ j : Fin d, spectralAtomOverlap (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) i j * ((dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j).val : ℝ)) / ((d : ℝ) * (N : ℝ)) := by classical rw [dSVDensityRationalCompleteProjectiveOutcome_norm_sq_eq] congr 1 let overlap := spectralAtomOverlap (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) have expand (k : Fin N) : (Matrix.trace ((dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect true * (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ζ).effect true)).re = ∑ i : Fin d, ∑ j : Fin d, if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true then overlap i j else 0 := by rw [← dSVDensityRationalMixedSpectralAtomBlock_eq_projectorProduct] exact dSVDensityRationalMixedSpectralAtomBlock_trace_eq w N ξ ζ true true k simp_rw [expand] calc (∑ k : Fin N, ∑ i : Fin d, ∑ j : Fin d, if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true then overlap i j else 0) = ∑ i : Fin d, ∑ j : Fin d, ∑ k : Fin N, if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true then overlap i j else 0 := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro i _ rw [Finset.sum_comm] _ = ∑ i : Fin d, ∑ j : Fin d, overlap i j * ((dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j).val : ℝ) := by apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ have counted := congrArg (fun r : ℕ => (r : ℝ)) (dSVDensityRationalPhysicalMixedAcceptedThreshold_count width grid ξ ζ i j) calc (∑ k : Fin N, if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true then overlap i j else 0) = overlap i j * ((Finset.univ.filter fun k : Fin N => dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true).card : ℝ) := by rw [← Finset.sum_boole] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro k _ split_ifs <;> simp _ = _ := by rw [counted] def dSVDensityRationalPhysicalMixedAcceptedPrefixWork {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : EuclideanSpace ℂ (Fin N × Fin N) := dSVCanonicalFailurePrefix (dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j) theorem dSVDensityRationalPhysicalMixedAcceptedPrefixWork_norm_sq {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : ‖dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j‖ ^ 2 = ((dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j).val : ℝ) := by exact dSVCanonicalFailurePrefix_norm_sq (dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVDensityRationalCanonicalPrefixMask {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := Matrix.blockDiagonal' fun k : Fin N => Matrix.diagonal fun i : Fin d => if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true then (1 : ℂ) else 0 theorem dSVDensityRationalCanonicalPrefixMask_transpose {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : (dSVDensityRationalCanonicalPrefixMask w N ξ).transpose = dSVDensityRationalCanonicalPrefixMask w N ξ := by classical simp [dSVDensityRationalCanonicalPrefixMask] theorem dSVDensityRationalPhysicalAcceptedProjector_eq_spectralMask {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : Matrix.blockDiagonal' (dSVDensityRationalPhysicalProjector w ξ) = (((dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) * dSVDensityRationalCanonicalPrefixMask w N ξ * (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) := by classical rw [dSVUniformDensityPhysicalSpectralAliceCopy_inv] change Matrix.blockDiagonal' (dSVDensityRationalPhysicalProjector w ξ) = Matrix.blockDiagonal' (fun _ : Fin N => (dSVUniformDensityThresholdLeftBobBasis ξ : Matrix (Fin d) (Fin d) ℂ)) * Matrix.blockDiagonal' (fun k : Fin N => Matrix.diagonal fun i : Fin d => if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true then (1 : ℂ) else 0) * Matrix.blockDiagonal' (fun _ : Fin N => (((dSVUniformDensityThresholdLeftBobBasis ξ)⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ)) rw [← Matrix.blockDiagonal'_mul, ← Matrix.blockDiagonal'_mul] apply congrArg Matrix.blockDiagonal' funext k unfold dSVDensityRationalPhysicalProjector dSVDensityRationalLeftProjectiveThresholdPOVM dSVDensityRationalProjectiveThresholdPOVM rw [spectralPartitionPOVM_effect_eq_spectralDiagonal] rfl def dSVDensityRationalCanonicalPrefixSpectralOutcome {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := toLp 2 (((dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) ⊗ₖ (((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)).mulVec (ofLp (dSVDensityRationalPhysicalAcceptedOutcome w N ξ ζ))) def dSVDensityRationalCompleteStoppedOptionalLocalEffect {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : Option Bool → Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ | none => 1 | some outcome => (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ).effect outcome def dSVDensityRationalCompleteStoppedOptionalOutcome {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (alice bob : Option Bool) : EuclideanSpace ℂ (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := toLp 2 (((dSVDensityRationalCompleteStoppedOptionalLocalEffect w N ξ alice) ⊗ₖ (dSVDensityRationalCompleteStoppedOptionalLocalEffect w N ζ bob).transpose).mulVec (ofLp (dSVUniformDensityThresholdSharedState N d))) theorem dSVDensityRationalCompleteStoppedOptionalOutcome_some_some {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (alice bob : Bool) : dSVDensityRationalCompleteStoppedOptionalOutcome w N ξ ζ (some alice) (some bob) = dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ alice bob := by rw [dSVDensityRationalCompleteProjectiveOutcome_eq_block_action] simp [dSVDensityRationalCompleteStoppedOptionalOutcome, dSVDensityRationalCompleteStoppedOptionalLocalEffect, dSVDensityRationalCompleteProjectiveBinaryPOVM_effect] theorem dSVDensityRationalCompleteStoppedOptionalOutcome_none_none {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalCompleteStoppedOptionalOutcome w N ξ ζ none none = dSVUniformDensityThresholdSharedState N d := by simp [dSVDensityRationalCompleteStoppedOptionalOutcome, dSVDensityRationalCompleteStoppedOptionalLocalEffect] def dSVDensityRationalCompleteStoppedOptionalLocalSchedule (L : ℕ) (hit copy : Fin (L + 1)) : Option Bool := if copy.val < L then if hit = 0 then some false else if copy.val + 1 < hit.val then some false else if copy.val + 1 = hit.val then some true else none else none theorem dSVDensityRationalCompleteStoppedOptionalLocalSchedule_zero (L : ℕ) (copy : Fin (L + 1)) : dSVDensityRationalCompleteStoppedOptionalLocalSchedule L 0 copy = if copy.val < L then some false else none := by simp [dSVDensityRationalCompleteStoppedOptionalLocalSchedule] theorem dSVDensityRationalCompleteStoppedOptionalLocalSchedule_hit {L : ℕ} (j : Fin L) : dSVDensityRationalCompleteStoppedOptionalLocalSchedule L j.succ j.castSucc = some true := by simp [dSVDensityRationalCompleteStoppedOptionalLocalSchedule, j.isLt] end noncomputable section open scoped Kronecker ComplexOrder MatrixOrder def dSVDensityRationalFirstAcceptLocalSpectralMask {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (outcome : Bool) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := Matrix.blockDiagonal' fun k : Fin N => Matrix.diagonal fun i : Fin d => if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = outcome then (1 : ℂ) else 0 theorem dSVDensityRationalFirstAcceptPhysicalEffect_eq_spectralMask {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (outcome : Bool) : (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ξ).effect outcome = (((dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) * dSVDensityRationalFirstAcceptLocalSpectralMask w N ξ outcome * (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) := by classical rw [dSVDensityRationalCompleteProjectiveBinaryPOVM_effect, dSVUniformDensityPhysicalSpectralAliceCopy_inv] change Matrix.blockDiagonal' (fun k : Fin N => (dSVDensityRationalLeftProjectiveThresholdPOVM w N k ξ).effect outcome) = Matrix.blockDiagonal' (fun _ : Fin N => (dSVUniformDensityThresholdLeftBobBasis ξ : Matrix (Fin d) (Fin d) ℂ)) * Matrix.blockDiagonal' (fun k : Fin N => Matrix.diagonal fun i : Fin d => if dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = outcome then (1 : ℂ) else 0) * Matrix.blockDiagonal' (fun _ : Fin N => (((dSVUniformDensityThresholdLeftBobBasis ξ)⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ)) rw [← Matrix.blockDiagonal'_mul, ← Matrix.blockDiagonal'_mul] apply congrArg Matrix.blockDiagonal' funext k unfold dSVDensityRationalLeftProjectiveThresholdPOVM dSVDensityRationalProjectiveThresholdPOVM rw [spectralPartitionPOVM_effect_eq_spectralDiagonal] rfl theorem dSVDensityRationalFirstAcceptLocalSpectralMask_transpose {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (outcome : Bool) : (dSVDensityRationalFirstAcceptLocalSpectralMask w N ξ outcome).transpose = dSVDensityRationalFirstAcceptLocalSpectralMask w N ξ outcome := by classical simp [dSVDensityRationalFirstAcceptLocalSpectralMask] theorem dSVDensityRationalFirstAcceptPhysicalBobEffect_eq_spectralMask {d : ℕ} (w : ℝ) (N : ℕ) (ζ : BipartiteUnitVector d) (outcome : Bool) : (transposePOVM (dSVDensityRationalCompleteProjectiveBinaryPOVM w N ζ)).effect outcome = (dSVUniformDensityBobHistoryCopyBasis (N := N) ζ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) * dSVDensityRationalFirstAcceptLocalSpectralMask w N ζ outcome * (((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) := by change ((dSVDensityRationalCompleteProjectiveBinaryPOVM w N ζ).effect outcome).transpose = _ rw [dSVDensityRationalFirstAcceptPhysicalEffect_eq_spectralMask w N ζ outcome, Matrix.transpose_mul, Matrix.transpose_mul, dSVDensityRationalFirstAcceptLocalSpectralMask_transpose, dSVUniformDensityPhysicalSpectralAliceCopy_transpose, dSVUniformDensityPhysicalSpectralAliceCopy_inv_transpose] simp [Matrix.mul_assoc] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalFirstAcceptActualTensorBasis {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (U : Matrix.unitaryGroup β ℂ) : Matrix.unitaryGroup (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ := controlledFiniteTensorLocalUnitary (fun (_stop : Fin (L + 1)) (_copy : Fin (L + 1)) => U) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 theorem tensorEmbezzlementTarget_sub_norm {d n : ℕ} (positive : 0 < n) (ξ ζ : BipartiteUnitVector d) : ‖tensorEmbezzlementTarget (n := n) ξ - tensorEmbezzlementTarget (n := n) ζ‖ = ‖ξ.val - ζ.val‖ := by classical let e : ((Fin d × Fin d) × (Fin n × Fin n)) ≃ (Fin (d * n) × Fin (d * n)) := (Equiv.prodProdProdComm (Fin d) (Fin d) (Fin n) (Fin n)).trans (Equiv.prodCongr finProdFinEquiv finProdFinEquiv) have point (q : (Fin d × Fin d) × (Fin n × Fin n)) : (tensorEmbezzlementTarget (n := n) ξ - tensorEmbezzlementTarget (n := n) ζ) (e q) = (ξ.val q.1 - ζ.val q.1) * embezzlementState n q.2 := by rcases q with ⟨⟨a, b⟩, ⟨i, j⟩⟩ change ξ.val ((finProdFinEquiv.symm (finProdFinEquiv (a, i))).1, (finProdFinEquiv.symm (finProdFinEquiv (b, j))).1) * embezzlementState n ((finProdFinEquiv.symm (finProdFinEquiv (a, i))).2, (finProdFinEquiv.symm (finProdFinEquiv (b, j))).2) - ζ.val ((finProdFinEquiv.symm (finProdFinEquiv (a, i))).1, (finProdFinEquiv.symm (finProdFinEquiv (b, j))).1) * embezzlementState n ((finProdFinEquiv.symm (finProdFinEquiv (a, i))).2, (finProdFinEquiv.symm (finProdFinEquiv (b, j))).2) = _ simp only [Equiv.symm_apply_apply] ring have reindex : (∑ q : Fin (d * n) × Fin (d * n), ‖(tensorEmbezzlementTarget (n := n) ξ - tensorEmbezzlementTarget (n := n) ζ) q‖ ^ 2) = ∑ q : (Fin d × Fin d) × (Fin n × Fin n), ‖(ξ.val q.1 - ζ.val q.1) * embezzlementState n q.2‖ ^ 2 := by calc (∑ q : Fin (d * n) × Fin (d * n), ‖(tensorEmbezzlementTarget (n := n) ξ - tensorEmbezzlementTarget (n := n) ζ) q‖ ^ 2) = ∑ q : (Fin d × Fin d) × (Fin n × Fin n), ‖(tensorEmbezzlementTarget (n := n) ξ - tensorEmbezzlementTarget (n := n) ζ) (e q)‖ ^ 2 := (Equiv.sum_comp e (fun q : Fin (d * n) × Fin (d * n) => ‖(tensorEmbezzlementTarget (n := n) ξ - tensorEmbezzlementTarget (n := n) ζ) q‖ ^ 2)).symm _ = _ := by apply Finset.sum_congr rfl intro q _ rw [point q] have factor : (∑ q : (Fin d × Fin d) × (Fin n × Fin n), ‖(ξ.val q.1 - ζ.val q.1) * embezzlementState n q.2‖ ^ 2) = (∑ q : Fin d × Fin d, ‖(ξ.val - ζ.val) q‖ ^ 2) * (∑ q : Fin n × Fin n, ‖embezzlementState n q‖ ^ 2) := by rw [Fintype.sum_prod_type] simp_rw [norm_mul, mul_pow] exact (Fintype.sum_mul_sum (fun q : Fin d × Fin d => ‖(ξ.val - ζ.val) q‖ ^ 2) (fun q : Fin n × Fin n => ‖embezzlementState n q‖ ^ 2)).symm have squares : ‖tensorEmbezzlementTarget (n := n) ξ - tensorEmbezzlementTarget (n := n) ζ‖ ^ 2 = ‖ξ.val - ζ.val‖ ^ 2 := by rw [EuclideanSpace.norm_sq_eq, reindex, factor, ← EuclideanSpace.norm_sq_eq, ← EuclideanSpace.norm_sq_eq, embezzlementState_norm n positive] ring nlinarith [norm_nonneg (tensorEmbezzlementTarget (n := n) ξ - tensorEmbezzlementTarget (n := n) ζ), norm_nonneg (ξ.val - ζ.val)] end noncomputable section open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem dSVBobTargetLocalHarmonicCleanup_stable {d n : ℕ} (hn : 0 < n) (U V : Matrix.unitaryGroup (Fin (d * n)) ℂ) (ξ ζ : BipartiteUnitVector d) (ε : ℝ) (clean : ‖localUnitaryAction U V (tensorEmbezzlementTarget (n := n) ζ) - embezzlementState (d * n)‖ ≤ ε) : ‖localUnitaryAction U V (tensorEmbezzlementTarget (n := n) ξ) - embezzlementState (d * n)‖ ≤ ‖ξ.val - ζ.val‖ + ε := by let source := localUnitaryAction U V (tensorEmbezzlementTarget (n := n) ξ) let reference := localUnitaryAction U V (tensorEmbezzlementTarget (n := n) ζ) let residual := embezzlementState (d * n) have preserved : ‖source - reference‖ = ‖ξ.val - ζ.val‖ := by dsimp [source, reference] rw [← localUnitaryAction_sub, localUnitaryAction_norm, tensorEmbezzlementTarget_sub_norm hn] have triangle : ‖source - residual‖ ≤ ‖source - reference‖ + ‖reference - residual‖ := by simpa [dist_eq_norm] using dist_triangle source reference residual change ‖source - residual‖ ≤ ‖ξ.val - ζ.val‖ + ε calc ‖source - residual‖ ≤ ‖source - reference‖ + ‖reference - residual‖ := triangle _ ≤ ‖ξ.val - ζ.val‖ + ε := by rw [preserved] simpa [add_comm] using add_le_add_left (show ‖reference - residual‖ ≤ ε by simpa [reference, residual] using clean) ‖ξ.val - ζ.val‖ theorem dSVBobTargetLocalUniformHarmonicWorkCleanup {T : Type*} (d : ℕ) (dimension : 0 < d) (work : T → BipartiteUnitVector d) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ (A B : T → Matrix.unitaryGroup (Fin (d * n)) ℂ), (∀ ζ : T, ‖localUnitaryAction (A ζ) (B ζ) (tensorEmbezzlementTarget (n := n) (work ζ)) - embezzlementState (d * n)‖ ≤ ε) ∧ (∀ ξ ζ : T, ‖localUnitaryAction (A ζ) (B ζ) (tensorEmbezzlementTarget (n := n) (work ξ)) - embezzlementState (d * n)‖ ≤ ‖(work ξ).val - (work ζ).val‖ + ε) := by classical obtain ⟨n, positive, universal⟩ := exists_proofUniversalHarmonicCatalyst d dimension ε precision have each (ζ : T) : ∃ U V : Matrix.unitaryGroup (Fin (d * n)) ℂ, ‖localUnitaryAction U V (embezzlementState (d * n)) - tensorEmbezzlementTarget (n := n) (work ζ)‖ ≤ ε := universal (work ζ) choose U V prepared using each refine ⟨n, positive, (fun ζ => (U ζ)⁻¹), (fun ζ => (V ζ)⁻¹), ?_, ?_⟩ · intro ζ rw [harmonicCoherentSharedResource_inverseAbsorption_distance] exact prepared ζ · intro ξ ζ apply dSVBobTargetLocalHarmonicCleanup_stable positive ((U ζ)⁻¹) ((V ζ)⁻¹) (work ξ) (work ζ) ε rw [harmonicCoherentSharedResource_inverseAbsorption_distance] exact prepared ζ theorem dSVDensityRationalCanonicalUnitPrefix_relative_distance_sq {N : ℕ} (grid : 0 < N) (r s : Fin (N + 1)) : ‖(dSVCanonicalFailureUnitRankFamily N grid r).val - (dSVCanonicalFailureUnitRankFamily N grid s).val‖ ^ 2 ≤ 4 * |(r.val : ℝ) - (s.val : ℝ)| / (max 1 (min r.val s.val) : ℕ) := by classical let x : ℝ := ‖(dSVCanonicalFailureUnitRankFamily N grid r).val - (dSVCanonicalFailureUnitRankFamily N grid s).val‖ let y : ℝ := ‖dSVCanonicalFailurePrefix r - dSVCanonicalFailurePrefix s‖ have x_nonnegative : 0 ≤ x := norm_nonneg _ have y_nonnegative : 0 ≤ y := norm_nonneg _ have y_squared : y ^ 2 = |(r.val : ℝ) - (s.val : ℝ)| := dSVCanonicalFailurePrefix_sub_norm_sq r s by_cases zero : r.val = 0 · by_cases zero_s : s.val = 0 · have same : r = s := Fin.ext (zero.trans zero_s.symm) subst s simp · have s_positive : 0 < s.val := Nat.pos_of_ne_zero zero_s have s_one : (1 : ℝ) ≤ (s.val : ℝ) := by exact_mod_cast (Nat.one_le_iff_ne_zero.mpr zero_s) have x_two : x ≤ 2 := by dsimp [x] calc _ ≤ ‖(dSVCanonicalFailureUnitRankFamily N grid r).val‖ + ‖(dSVCanonicalFailureUnitRankFamily N grid s).val‖ := norm_sub_le _ _ _ = 2 := by rw [(dSVCanonicalFailureUnitRankFamily N grid r).property, (dSVCanonicalFailureUnitRankFamily N grid s).property] norm_num have magnitude : |(r.val : ℝ) - (s.val : ℝ)| = (s.val : ℝ) := by simp [zero] have denominator : max 1 (min r.val s.val) = 1 := by simp [zero] change x ^ 2 ≤ _ rw [magnitude, denominator] norm_num only [Nat.cast_one, div_one] nlinarith [sq_nonneg x] · have r_positive_nat : 0 < r.val := Nat.pos_of_ne_zero zero have r_positive : (0 : ℝ) < r.val := by exact_mod_cast r_positive_nat have root_positive : 0 < Real.sqrt (r.val : ℝ) := Real.sqrt_pos.mpr r_positive have raw_nonzero : dSVCanonicalFailurePrefix r ≠ 0 := by intro vanished have mass := dSVCanonicalFailurePrefix_norm_sq r rw [vanished] at mass norm_num at mass exact zero (by exact_mod_cast mass.symm) have normalized := normalizeOrDefault_sub_le (embezzlementState N) (dSVCanonicalFailurePrefix r) (dSVCanonicalFailurePrefix s) (embezzlementState_norm N grid) raw_nonzero change x ≤ 2 * y / ‖dSVCanonicalFailurePrefix r‖ at normalized rw [dSVCanonicalFailurePrefix_norm_eq_sqrt] at normalized have linear : x * Real.sqrt (r.val : ℝ) ≤ 2 * y := (le_div_iff₀ root_positive).mp normalized have square := mul_self_le_mul_self (mul_nonneg x_nonnegative root_positive.le) linear have weighted : x ^ 2 * (r.val : ℝ) ≤ 4 * |(r.val : ℝ) - (s.val : ℝ)| := by have root_square := Real.sq_sqrt r_positive.le nlinarith [y_squared] have rank_relative : x ^ 2 ≤ 4 * |(r.val : ℝ) - (s.val : ℝ)| / (r.val : ℝ) := (le_div_iff₀ r_positive).mpr weighted have denominator_positive : (0 : ℝ) < (max 1 (min r.val s.val) : ℕ) := by exact_mod_cast (show 0 < max 1 (min r.val s.val) by omega) have denominator_le : ((max 1 (min r.val s.val) : ℕ) : ℝ) ≤ (r.val : ℝ) := by exact_mod_cast (max_le (Nat.one_le_iff_ne_zero.mpr zero) (min_le_left r.val s.val)) change x ^ 2 ≤ _ calc x ^ 2 ≤ 4 * |(r.val : ℝ) - (s.val : ℝ)| / (r.val : ℝ) := rank_relative _ ≤ 4 * |(r.val : ℝ) - (s.val : ℝ)| / (max 1 (min r.val s.val) : ℕ) := by apply (div_le_div_iff₀ r_positive denominator_positive).mpr exact mul_le_mul_of_nonneg_left denominator_le (mul_nonneg (by norm_num) (abs_nonneg _)) theorem dSVDensityRationalPublicBucketLocalHarmonicCleanup_sq {Ω I : Type*} [DecidableEq I] {N D : ℕ} (dimension : 0 < N) (work : Fin D → BipartiteUnitVector N) (bucket : Ω → Fin D → I) (representative : Ω → I → Fin D) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ A B : Ω → I → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ (phase : Ω) (r s : Fin D), ‖localUnitaryAction (A phase (bucket phase r)) (B phase (bucket phase s)) (tensorEmbezzlementTarget (n := n) (work r)) - embezzlementState (N * n)‖ ^ 2 ≤ 2 * ε ^ 2 + 2 * ‖(work r).val - (work (representative phase (bucket phase r))).val‖ ^ 2 + 4 * (if bucket phase r = bucket phase s then (0 : ℝ) else 1) := by classical obtain ⟨n, positive, A, B, diagonal, _stable⟩ := dSVBobTargetLocalUniformHarmonicWorkCleanup N dimension (fun q : Ω × I => work (representative q.1 q.2)) ε precision refine ⟨n, positive, fun phase label => A (phase, label), fun phase label => B (phase, label), ?_⟩ intro phase r s by_cases same : bucket phase r = bucket phase s · have clean := diagonal (phase, bucket phase r) have stable := dSVBobTargetLocalHarmonicCleanup_stable positive (A (phase, bucket phase r)) (B (phase, bucket phase r)) (work r) (work (representative phase (bucket phase r))) ε clean have actual : ‖localUnitaryAction (A (phase, bucket phase r)) (B (phase, bucket phase s)) (tensorEmbezzlementTarget (n := n) (work r)) - embezzlementState (N * n)‖ ≤ ‖(work r).val - (work (representative phase (bucket phase r))).val‖ + ε := by simpa only [same] using stable simp only [if_pos same, mul_zero, add_zero] nlinarith [ norm_nonneg (localUnitaryAction (A (phase, bucket phase r)) (B (phase, bucket phase s)) (tensorEmbezzlementTarget (n := n) (work r)) - embezzlementState (N * n)), norm_nonneg ((work r).val - (work (representative phase (bucket phase r))).val), sq_nonneg (‖(work r).val - (work (representative phase (bucket phase r))).val‖ - ε)] · have bound : ‖localUnitaryAction (A (phase, bucket phase r)) (B (phase, bucket phase s)) (tensorEmbezzlementTarget (n := n) (work r)) - embezzlementState (N * n)‖ ≤ 2 := by calc _ ≤ ‖localUnitaryAction (A (phase, bucket phase r)) (B (phase, bucket phase s)) (tensorEmbezzlementTarget (n := n) (work r))‖ + ‖embezzlementState (N * n)‖ := norm_sub_le _ _ _ = 2 := by rw [localUnitaryAction_norm, tensorEmbezzlementTarget_norm positive, embezzlementState_norm (N * n) (Nat.mul_pos dimension positive)] norm_num simp only [if_neg same, mul_one] nlinarith [ norm_nonneg (localUnitaryAction (A (phase, bucket phase r)) (B (phase, bucket phase s)) (tensorEmbezzlementTarget (n := n) (work r)) - embezzlementState (N * n)), sq_nonneg ε, sq_nonneg ‖(work r).val - (work (representative phase (bucket phase r))).val‖] theorem dSVDensityRationalPublicBucketCanonicalPrefixCleanup_sq {Ω I : Type*} [DecidableEq I] {N : ℕ} (grid : 0 < N) (bucket : Ω → Fin (N + 1) → I) (representative : Ω → I → Fin (N + 1)) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ A B : Ω → I → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ (phase : Ω) (r s : Fin (N + 1)), ‖localUnitaryAction (A phase (bucket phase r)) (B phase (bucket phase s)) (tensorEmbezzlementTarget (n := n) (dSVCanonicalFailureUnitRankFamily N grid r)) - embezzlementState (N * n)‖ ^ 2 ≤ 2 * ε ^ 2 + 8 * |(r.val : ℝ) - ((representative phase (bucket phase r)).val : ℝ)| / (max 1 (min r.val (representative phase (bucket phase r)).val) : ℕ) + 4 * (if bucket phase r = bucket phase s then (0 : ℝ) else 1) := by obtain ⟨n, positive, A, B, accurate⟩ := dSVDensityRationalPublicBucketLocalHarmonicCleanup_sq grid (dSVCanonicalFailureUnitRankFamily N grid) bucket representative ε precision refine ⟨n, positive, A, B, ?_⟩ intro phase r s have actual := accurate phase r s have relative := dSVDensityRationalCanonicalUnitPrefix_relative_distance_sq grid r (representative phase (bucket phase r)) calc _ ≤ 2 * ε ^ 2 + 2 * ‖(dSVCanonicalFailureUnitRankFamily N grid r).val - (dSVCanonicalFailureUnitRankFamily N grid (representative phase (bucket phase r))).val‖ ^ 2 + 4 * (if bucket phase r = bucket phase s then (0 : ℝ) else 1) := actual _ ≤ 2 * ε ^ 2 + 2 * (4 * |(r.val : ℝ) - ((representative phase (bucket phase r)).val : ℝ)| / (max 1 (min r.val (representative phase (bucket phase r)).val) : ℕ)) + 4 * (if bucket phase r = bucket phase s then (0 : ℝ) else 1) := by gcongr _ = _ := by ring end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVDensityRationalPublicBucketCoherentPhaseHistory {H : Type*} [Fintype H] (B : ℕ) (history : EuclideanSpace ℂ (H × H)) : EuclideanSpace ℂ ((Fin B × H) × (Fin B × H)) := toLp 2 fun q : (Fin B × H) × (Fin B × H) => ePRState B (q.1.1, q.2.1) * history (q.1.2, q.2.2) theorem dSVDensityRationalPublicBucketCoherentPhaseHistory_apply {H : Type*} [Fintype H] (B : ℕ) (history : EuclideanSpace ℂ (H × H)) (φ ψ : Fin B) (a b : H) : dSVDensityRationalPublicBucketCoherentPhaseHistory B history ((φ, a), (ψ, b)) = ePRState B (φ, ψ) * history (a, b) := by rfl theorem dSVDensityRationalPublicBucketCoherentPhaseHistory_apply_norm_sq {H : Type*} [Fintype H] {B : ℕ} (positive : 0 < B) (history : EuclideanSpace ℂ (H × H)) (φ ψ : Fin B) (a b : H) : ‖dSVDensityRationalPublicBucketCoherentPhaseHistory B history ((φ, a), (ψ, b))‖ ^ 2 = (if φ = ψ then (B : ℝ)⁻¹ else 0) * ‖history (a, b)‖ ^ 2 := by rw [dSVDensityRationalPublicBucketCoherentPhaseHistory_apply, norm_mul, mul_pow] by_cases same : φ = ψ · subst ψ simp only [ePRState, ↓reduceIte] rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (inv_nonneg.mpr (Real.sqrt_nonneg _)), inv_pow, Real.sq_sqrt (by positivity : (0 : ℝ) ≤ B)] · simp [ePRState, same] def dSVDensityRationalPublicBucketCoherentPhaseSigmaState {H : Type*} [Fintype H] {m : ℕ} (B : ℕ) (history : EuclideanSpace ℂ (H × H)) (work : Fin B → H → H → EuclideanSpace ℂ (Fin m × Fin m)) : EuclideanSpace ℂ ((Σ _ : Fin B × H, Fin m) × (Σ _ : Fin B × H, Fin m)) := dSVUniformDensityCorrectedMatchedSigmaWeightedResidual (dSVDensityRationalPublicBucketCoherentPhaseHistory B history) (fun a b => work a.1 a.2 b.2) def dSVDensityRationalPublicBucketCoherentPhaseLocalUnitary {H I : Type*} [Fintype H] [DecidableEq H] [DecidableEq I] {B D m : ℕ} (rank : H → Fin D) (bucket : Fin B → Fin D → I) (A : Fin B → I → Matrix.unitaryGroup (Fin m) ℂ) : Matrix.unitaryGroup (Σ _ : Fin B × H, Fin m) ℂ := coherentSharedRandomControlledUnitary (fun q : Fin B × H => A q.1 (bucket q.1 (rank q.2))) theorem dSVDensityRationalPublicBucketCoherentPhaseSigmaReset_distance_sq {H I : Type*} [Fintype H] [DecidableEq H] [DecidableEq I] {B D m : ℕ} (phase_positive : 0 < B) (history : EuclideanSpace ℂ (H × H)) (rankA rankB : H → Fin D) (bucket : Fin B → Fin D → I) (A C : Fin B → I → Matrix.unitaryGroup (Fin m) ℂ) (work target : Fin B → H → H → EuclideanSpace ℂ (Fin m × Fin m)) : ‖dSVUniformDensityPhysicalAsyncSigmaContinuation (fun q : Fin B × H => A q.1 (bucket q.1 (rankA q.2))) (fun q : Fin B × H => C q.1 (bucket q.1 (rankB q.2))) (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B history work) - dSVDensityRationalPublicBucketCoherentPhaseSigmaState B history target‖ ^ 2 = (∑ φ : Fin B, ∑ a : H, ∑ b : H, ‖history (a, b)‖ ^ 2 * ‖localUnitaryAction (A φ (bucket φ (rankA a))) (C φ (bucket φ (rankB b))) (work φ a b) - target φ a b‖ ^ 2) / (B : ℝ) := by classical unfold dSVDensityRationalPublicBucketCoherentPhaseSigmaState rw [dSVUniformDensityCorrectedMatchedSigmaControlledReset_distance_sq] simp_rw [Fintype.sum_prod_type] change (∑ φ : Fin B, ∑ a : H, ∑ ψ : Fin B, ∑ b : H, ‖dSVDensityRationalPublicBucketCoherentPhaseHistory B history ((φ, a), (ψ, b))‖ ^ 2 * ‖localUnitaryAction (A φ (bucket φ (rankA a))) (C ψ (bucket ψ (rankB b))) (work φ a b) - target φ a b‖ ^ 2) = _ simp_rw [ dSVDensityRationalPublicBucketCoherentPhaseHistory_apply_norm_sq phase_positive] calc (∑ φ : Fin B, ∑ a : H, ∑ ψ : Fin B, ∑ b : H, ((if φ = ψ then (B : ℝ)⁻¹ else 0) * ‖history (a, b)‖ ^ 2) * ‖localUnitaryAction (A φ (bucket φ (rankA a))) (C ψ (bucket ψ (rankB b))) (work φ a b) - target φ a b‖ ^ 2) = ∑ φ : Fin B, ∑ a : H, ∑ b : H, (B : ℝ)⁻¹ * (‖history (a, b)‖ ^ 2 * ‖localUnitaryAction (A φ (bucket φ (rankA a))) (C φ (bucket φ (rankB b))) (work φ a b) - target φ a b‖ ^ 2) := by apply Finset.sum_congr rfl intro φ _ apply Finset.sum_congr rfl intro a _ simp [mul_assoc] _ = (B : ℝ)⁻¹ * (∑ φ : Fin B, ∑ a : H, ∑ b : H, ‖history (a, b)‖ ^ 2 * ‖localUnitaryAction (A φ (bucket φ (rankA a))) (C φ (bucket φ (rankB b))) (work φ a b) - target φ a b‖ ^ 2) := by simp_rw [Finset.mul_sum] _ = _ := by ring end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder theorem dSVDensityRationalPublicLogRank_real_log_bound {r s : ℝ} (positive_r : 0 < r) (positive_s : 0 < s) : min r s * |Real.log r - Real.log s| ≤ |r - s| := by have in_order : ∀ {x y : ℝ}, 0 < x → 0 < y → x ≤ y → min x y * |Real.log x - Real.log y| ≤ |x - y| := by intro x y positive_x positive_y ordered have logarithmic := Real.log_le_sub_one_of_pos (div_pos positive_y positive_x) have monotone := Real.log_le_log positive_x ordered have bound : x * (Real.log y - Real.log x) ≤ y - x := by calc x * (Real.log y - Real.log x) = x * Real.log (y / x) := by rw [Real.log_div positive_y.ne' positive_x.ne'] _ ≤ x * (y / x - 1) := mul_le_mul_of_nonneg_left logarithmic positive_x.le _ = y - x := by field_simp calc min x y * |Real.log x - Real.log y| = x * (Real.log y - Real.log x) := by rw [min_eq_left ordered, abs_of_nonpos (sub_nonpos.mpr monotone)] ring _ ≤ y - x := bound _ = |x - y| := by rw [abs_of_nonpos (sub_nonpos.mpr ordered)] ring rcases le_total r s with ordered | ordered · exact in_order positive_r positive_s ordered · simpa [min_comm, abs_sub_comm] using in_order positive_s positive_r ordered theorem dSVDensityRationalPublicLogRank_zeroSafe_nat_bound (r s : ℕ) : min (r : ℝ) (s : ℝ) * |Real.log ((max 1 r : ℕ) : ℝ) - Real.log ((max 1 s : ℕ) : ℝ)| ≤ |(r : ℝ) - (s : ℝ)| := by by_cases zero_r : r = 0 · simp [zero_r] by_cases zero_s : s = 0 · simp [zero_s] have positive_r : 0 < r := Nat.pos_of_ne_zero zero_r have positive_s : 0 < s := Nat.pos_of_ne_zero zero_s have one_r : 1 ≤ r := positive_r have one_s : 1 ≤ s := positive_s simpa [max_eq_right one_r, max_eq_right one_s] using (dSVDensityRationalPublicLogRank_real_log_bound (by exact_mod_cast positive_r : (0 : ℝ) < r) (by exact_mod_cast positive_s : (0 : ℝ) < s)) theorem dSVDensityRationalPublicLogRank_zeroSafe_fin_bound {N : ℕ} (r s : Fin (N + 1)) : min (r.val : ℝ) (s.val : ℝ) * |Real.log ((max 1 r.val : ℕ) : ℝ) - Real.log ((max 1 s.val : ℕ) : ℝ)| ≤ |(r.val : ℝ) - (s.val : ℝ)| := dSVDensityRationalPublicLogRank_zeroSafe_nat_bound r.val s.val def dSVDensityRationalPublicLogRankFineLabel {N : ℕ} (Q : ℕ) (r : Fin (N + 1)) : ℕ := Nat.floor ((Q : ℝ) * Real.log ((max 1 r.val : ℕ) : ℝ)) def dSVDensityRationalPublicLogRankPhaseWeight (B : ℕ) (_ : Fin B) : ℝ := 1 / (B : ℝ) theorem dSVDensityRationalPublicLogRankPhaseWeight_sum {B : ℕ} (positive : 0 < B) : (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase) = 1 := by have real_positive : (0 : ℝ) < (B : ℝ) := by exact_mod_cast positive simp [dSVDensityRationalPublicLogRankPhaseWeight, real_positive.ne'] def dSVDensityRationalPublicLogRankBucket {N B : ℕ} (Q : ℕ) (phase : Fin B) (r : Fin (N + 1)) : Option ℕ := if r.val = 0 then none else some ((dSVDensityRationalPublicLogRankFineLabel Q r + phase.val) / B) theorem dSVDensityRationalPublicLogRankBucket_fineLabel_sub_lt {N B : ℕ} (Q : ℕ) (phase : Fin B) (r s : Fin (N + 1)) (nonzero_r : r.val ≠ 0) (nonzero_s : s.val ≠ 0) (same : dSVDensityRationalPublicLogRankBucket Q phase r = dSVDensityRationalPublicLogRankBucket Q phase s) : |(dSVDensityRationalPublicLogRankFineLabel Q r : ℝ) - (dSVDensityRationalPublicLogRankFineLabel Q s : ℝ)| < (B : ℝ) := by have positive : 0 < B := by have bound := phase.isLt omega have quotient : (dSVDensityRationalPublicLogRankFineLabel Q r + phase.val) / B = (dSVDensityRationalPublicLogRankFineLabel Q s + phase.val) / B := by simpa [dSVDensityRationalPublicLogRankBucket, nonzero_r, nonzero_s] using same have remainder_r := Nat.mod_lt (dSVDensityRationalPublicLogRankFineLabel Q r + phase.val) positive have remainder_s := Nat.mod_lt (dSVDensityRationalPublicLogRankFineLabel Q s + phase.val) positive have reconstruction_r := Nat.mod_add_div (dSVDensityRationalPublicLogRankFineLabel Q r + phase.val) B have reconstruction_s := Nat.mod_add_div (dSVDensityRationalPublicLogRankFineLabel Q s + phase.val) B rw [quotient] at reconstruction_r rcases le_total (dSVDensityRationalPublicLogRankFineLabel Q r) (dSVDensityRationalPublicLogRankFineLabel Q s) with ordered | ordered · have difference : dSVDensityRationalPublicLogRankFineLabel Q s - dSVDensityRationalPublicLogRankFineLabel Q r < B := by omega have real_difference : (dSVDensityRationalPublicLogRankFineLabel Q s : ℝ) - (dSVDensityRationalPublicLogRankFineLabel Q r : ℝ) < (B : ℝ) := by exact_mod_cast difference rw [abs_of_nonpos (sub_nonpos.mpr (by exact_mod_cast ordered))] linarith · have difference : dSVDensityRationalPublicLogRankFineLabel Q r - dSVDensityRationalPublicLogRankFineLabel Q s < B := by omega have real_difference : (dSVDensityRationalPublicLogRankFineLabel Q r : ℝ) - (dSVDensityRationalPublicLogRankFineLabel Q s : ℝ) < (B : ℝ) := by exact_mod_cast difference rw [abs_of_nonneg (sub_nonneg.mpr (by exact_mod_cast ordered))] exact real_difference theorem dSVDensityRationalPublicLogRank_logCoordinate_nonneg {N : ℕ} (Q : ℕ) (r : Fin (N + 1)) : 0 ≤ (Q : ℝ) * Real.log ((max 1 r.val : ℕ) : ℝ) := by apply mul_nonneg (Nat.cast_nonneg Q) apply Real.log_nonneg exact_mod_cast (le_max_left 1 r.val) theorem dSVDensityRationalPublicLogRankFineLabel_bounds {N : ℕ} (Q : ℕ) (r : Fin (N + 1)) : (dSVDensityRationalPublicLogRankFineLabel Q r : ℝ) ≤ (Q : ℝ) * Real.log ((max 1 r.val : ℕ) : ℝ) ∧ (Q : ℝ) * Real.log ((max 1 r.val : ℕ) : ℝ) < (dSVDensityRationalPublicLogRankFineLabel Q r : ℝ) + 1 := by constructor · exact Nat.floor_le (dSVDensityRationalPublicLogRank_logCoordinate_nonneg Q r) · exact Nat.lt_floor_add_one _ theorem dSVDensityRationalPublicLogRankBucket_log_sub_lt {N B : ℕ} {Q : ℕ} (positive_Q : 0 < Q) (phase : Fin B) (r s : Fin (N + 1)) (nonzero_r : r.val ≠ 0) (nonzero_s : s.val ≠ 0) (same : dSVDensityRationalPublicLogRankBucket Q phase r = dSVDensityRationalPublicLogRankBucket Q phase s) : |Real.log ((max 1 r.val : ℕ) : ℝ) - Real.log ((max 1 s.val : ℕ) : ℝ)| < ((B : ℝ) + 1) / (Q : ℝ) := by have real_Q : (0 : ℝ) < (Q : ℝ) := by exact_mod_cast positive_Q have rank_bounds := dSVDensityRationalPublicLogRankFineLabel_bounds Q r have other_bounds := dSVDensityRationalPublicLogRankFineLabel_bounds Q s have bucket_bounds := dSVDensityRationalPublicLogRankBucket_fineLabel_sub_lt Q phase r s nonzero_r nonzero_s same apply (lt_div_iff₀ real_Q).2 rcases le_total (Real.log ((max 1 r.val : ℕ) : ℝ)) (Real.log ((max 1 s.val : ℕ) : ℝ)) with ordered | ordered · rw [abs_of_nonpos (sub_nonpos.mpr ordered)] have integer_order := (abs_lt.mp bucket_bounds).1 nlinarith [rank_bounds.1, other_bounds.2] · rw [abs_of_nonneg (sub_nonneg.mpr ordered)] have integer_order := (abs_lt.mp bucket_bounds).2 nlinarith [rank_bounds.2, other_bounds.1] def dSVDensityRationalPublicLogRankBucketFiber {N B : ℕ} (Q : ℕ) (phase : Fin B) (label : Option ℕ) : Finset (Fin (N + 1)) := Finset.univ.filter fun r : Fin (N + 1) => r.val ≠ 0 ∧ dSVDensityRationalPublicLogRankBucket Q phase r = label theorem dSVDensityRationalPublicLogRankBucketFiber_mem {N B : ℕ} (Q : ℕ) (phase : Fin B) (label : Option ℕ) (r : Fin (N + 1)) : r ∈ dSVDensityRationalPublicLogRankBucketFiber Q phase label ↔ r.val ≠ 0 ∧ dSVDensityRationalPublicLogRankBucket Q phase r = label := by simp [dSVDensityRationalPublicLogRankBucketFiber] def dSVDensityRationalPublicLogRankBucketRepresentative {N B : ℕ} (Q : ℕ) (phase : Fin B) (label : Option ℕ) : Fin (N + 1) := if present : (dSVDensityRationalPublicLogRankBucketFiber Q phase label).Nonempty then (dSVDensityRationalPublicLogRankBucketFiber Q phase label).min' present else 0 theorem dSVDensityRationalPublicLogRankBucketRepresentative_mem {N B : ℕ} (Q : ℕ) (phase : Fin B) (label : Option ℕ) (present : (dSVDensityRationalPublicLogRankBucketFiber (N := N) Q phase label).Nonempty) : dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase label ∈ dSVDensityRationalPublicLogRankBucketFiber (N := N) Q phase label := by simpa [dSVDensityRationalPublicLogRankBucketRepresentative, present] using (Finset.min'_mem (dSVDensityRationalPublicLogRankBucketFiber (N := N) Q phase label) present) theorem dSVDensityRationalPublicLogRankBucketRepresentative_same {N B : ℕ} (Q : ℕ) (phase : Fin B) (r : Fin (N + 1)) (nonzero : r.val ≠ 0) : (dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val ≠ 0 ∧ dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)) = dSVDensityRationalPublicLogRankBucket Q phase r := by have member : r ∈ dSVDensityRationalPublicLogRankBucketFiber Q phase (dSVDensityRationalPublicLogRankBucket Q phase r) := (dSVDensityRationalPublicLogRankBucketFiber_mem Q phase _ r).mpr ⟨nonzero, rfl⟩ have present : (dSVDensityRationalPublicLogRankBucketFiber Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).Nonempty := ⟨r, member⟩ exact (dSVDensityRationalPublicLogRankBucketFiber_mem Q phase _ _).mp (dSVDensityRationalPublicLogRankBucketRepresentative_mem (N := N) Q phase _ present) theorem dSVDensityRationalPublicLogRankBucketRepresentative_le {N B : ℕ} (Q : ℕ) (phase : Fin B) (r : Fin (N + 1)) (nonzero : r.val ≠ 0) : dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r) ≤ r := by have member : r ∈ dSVDensityRationalPublicLogRankBucketFiber Q phase (dSVDensityRationalPublicLogRankBucket Q phase r) := (dSVDensityRationalPublicLogRankBucketFiber_mem Q phase _ r).mpr ⟨nonzero, rfl⟩ have present : (dSVDensityRationalPublicLogRankBucketFiber Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).Nonempty := ⟨r, member⟩ simp only [dSVDensityRationalPublicLogRankBucketRepresentative, dif_pos present] exact Finset.min'_le _ r member theorem dSVDensityRationalPublicLogRankBucketRepresentative_log_sub_lt {N B : ℕ} {Q : ℕ} (positive_Q : 0 < Q) (phase : Fin B) (r : Fin (N + 1)) (nonzero : r.val ≠ 0) : |Real.log ((max 1 r.val : ℕ) : ℝ) - Real.log ((max 1 (dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val : ℕ) : ℝ)| < ((B : ℝ) + 1) / (Q : ℝ) := by have same := dSVDensityRationalPublicLogRankBucketRepresentative_same Q phase r nonzero exact dSVDensityRationalPublicLogRankBucket_log_sub_lt positive_Q phase r _ nonzero same.1 same.2.symm end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder abbrev DSVDensityRationalPublicMultiscalePhase (S B : ℕ) := Fin S → Fin B abbrev DSVDensityRationalPublicMultiscalePhaseIndex (S B : ℕ) := Fin (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) theorem dSVDensityRationalPublicMultiscalePhase_card (S B : ℕ) : Fintype.card (DSVDensityRationalPublicMultiscalePhase S B) = B ^ S := by simp [DSVDensityRationalPublicMultiscalePhase] theorem dSVDensityRationalPublicMultiscalePhase_card_pos {S B : ℕ} (positive : 0 < B) : 0 < Fintype.card (DSVDensityRationalPublicMultiscalePhase S B) := by rw [dSVDensityRationalPublicMultiscalePhase_card] exact pow_pos positive S def dSVDensityRationalPrefixHarmonicSpectralOverlap {d : ℕ} (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : ℝ := spectralAtomOverlap (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) i j theorem dSVDensityRationalPrefixHarmonicSpectralOverlap_nonneg {d : ℕ} (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : 0 ≤ dSVDensityRationalPrefixHarmonicSpectralOverlap ξ ζ i j := spectralAtomOverlap_nonneg _ _ _ _ i j def dSVDensityRationalLocalSpectralPairBasisOverlap {d : ℕ} (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : ℂ := unitaryBasisOverlap (dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvectorUnitary (dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvectorUnitary i j theorem dSVDensityRationalLocalSpectralPairBasisOverlap_norm_sq {d : ℕ} (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : ‖dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ i j‖ ^ 2 = dSVDensityRationalPrefixHarmonicSpectralOverlap ξ ζ i j := by unfold dSVDensityRationalLocalSpectralPairBasisOverlap dSVDensityRationalPrefixHarmonicSpectralOverlap exact (targetSpectralAtomOverlap_eq_basis_norm_sq (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) i j).symm def dSVDensityRationalLocalSpectralPairHistory {d : ℕ} (N : ℕ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (Fin d × Fin d) := toLp 2 fun q : Fin d × Fin d => ((‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) : ℂ) * dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ q.1 q.2 theorem dSVDensityRationalLocalSpectralPairHistory_apply_norm_sq {d : ℕ} (N : ℕ) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : ‖dSVDensityRationalLocalSpectralPairHistory N ξ ζ (i, j)‖ ^ 2 = dSVDensityRationalPrefixHarmonicSpectralOverlap ξ ζ i j / ((d : ℝ) * (N : ℝ)) := by unfold dSVDensityRationalLocalSpectralPairHistory change ‖((‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) : ℂ) * dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ i j‖ ^ 2 = _ rw [norm_mul, mul_pow, Complex.norm_real, Real.norm_eq_abs, sq_abs, dSVDensityRationalLocalSpectralPairBasisOverlap_norm_sq, inv_pow, dSVUniformDensityThresholdRaw_norm_sq] ring def dSVDensityRationalMixedCanonicalCrossMatrix {d : ℕ} (N : ℕ) (ξ ζ : BipartiteUnitVector d) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := (Matrix.blockDiagonal' fun _ : Fin N => (unitaryBasisOverlap (dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvectorUnitary (dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvectorUnitary : Matrix (Fin d) (Fin d) ℂ)).transpose theorem dSVDensityRationalMixedCanonicalCrossGauge_eq {d : ℕ} (N : ℕ) (ξ ζ : BipartiteUnitVector d) : (((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) * (dSVUniformDensityBobHistoryCopyBasis (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) = dSVDensityRationalMixedCanonicalCrossMatrix N ξ ζ := by rw [← dSVUniformDensityPhysicalSpectralAliceCopy_inv_transpose ζ, ← dSVUniformDensityPhysicalSpectralAliceCopy_transpose ξ, ← Matrix.transpose_mul] unfold dSVDensityRationalMixedCanonicalCrossMatrix congr 1 rw [dSVUniformDensityPhysicalSpectralAliceCopy_inv] change Matrix.blockDiagonal' (fun _ : Fin N => (((dSVUniformDensityThresholdLeftBobBasis ξ)⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ)) * Matrix.blockDiagonal' (fun _ : Fin N => (dSVUniformDensityThresholdLeftBobBasis ζ : Matrix (Fin d) (Fin d) ℂ)) = Matrix.blockDiagonal' (fun _ : Fin N => (unitaryBasisOverlap (dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvectorUnitary (dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvectorUnitary : Matrix (Fin d) (Fin d) ℂ)) rw [← Matrix.blockDiagonal'_mul] rfl theorem dSVDensityRationalCanonicalPrefixMask_eq_diagonal {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) : dSVDensityRationalCanonicalPrefixMask w N ξ = Matrix.diagonal (fun q : DSVUniformDensityThresholdLocalIndex N d => if dSVDensityRationalProjectiveThresholdBin w N q.1 ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues q.2) = true then (1 : ℂ) else 0) := by unfold dSVDensityRationalCanonicalPrefixMask rw [Matrix.blockDiagonal'_diagonal] def dSVDensityRationalMixedCanonicalRawSource {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := toLp 2 (Matrix.vec (dSVDensityRationalCanonicalPrefixMask w N ζ * dSVDensityRationalMixedCanonicalCrossMatrix N ξ ζ * dSVDensityRationalCanonicalPrefixMask w N ξ)) theorem dSVDensityRationalMixedCanonicalRawSource_apply {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (k l : Fin N) (i j : Fin d) : dSVDensityRationalMixedCanonicalRawSource w N ξ ζ (⟨k, i⟩, ⟨l, j⟩) = if k = l ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N l ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true then dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ i j else 0 := by classical unfold dSVDensityRationalMixedCanonicalRawSource rw [dSVDensityRationalCanonicalPrefixMask_eq_diagonal w N ζ, dSVDensityRationalCanonicalPrefixMask_eq_diagonal w N ξ] change (Matrix.diagonal (fun q : DSVUniformDensityThresholdLocalIndex N d => if dSVDensityRationalProjectiveThresholdBin w N q.1 ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues q.2) = true then (1 : ℂ) else 0) * dSVDensityRationalMixedCanonicalCrossMatrix N ξ ζ * Matrix.diagonal (fun q : DSVUniformDensityThresholdLocalIndex N d => if dSVDensityRationalProjectiveThresholdBin w N q.1 ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues q.2) = true then (1 : ℂ) else 0)) ⟨l, j⟩ ⟨k, i⟩ = _ rw [Matrix.mul_diagonal, Matrix.diagonal_mul] by_cases flags : k = l · subst l by_cases alice : dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true · by_cases bob : dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true · simp [dSVDensityRationalMixedCanonicalCrossMatrix, dSVDensityRationalLocalSpectralPairBasisOverlap, Matrix.blockDiagonal'_apply, alice, bob] · simp [bob] · simp [alice] · simp [dSVDensityRationalMixedCanonicalCrossMatrix, Matrix.blockDiagonal'_apply, flags] theorem dSVDensityRationalMixedCanonicalProjectorMatrix_eq {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : (((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) * ((Matrix.blockDiagonal' (fun k : Fin N => dSVDensityRationalPhysicalProjector w ξ k) * Matrix.blockDiagonal' (fun k : Fin N => dSVDensityRationalPhysicalProjector w ζ k)).transpose) * (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ).transpose = dSVDensityRationalCanonicalPrefixMask w N ζ * dSVDensityRationalMixedCanonicalCrossMatrix N ξ ζ * dSVDensityRationalCanonicalPrefixMask w N ξ := by let S : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ let X : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVUniformDensityBobHistoryCopyBasis (N := N) ξ let Z : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVUniformDensityBobHistoryCopyBasis (N := N) ζ let XI : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := ((X⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) let ZI : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := ((Z⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) let M : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVDensityRationalCanonicalPrefixMask w N ξ let R : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVDensityRationalCanonicalPrefixMask w N ζ have physical_x : Matrix.blockDiagonal' (fun k : Fin N => dSVDensityRationalPhysicalProjector w ξ k) = (((S⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)) * M * (S : Matrix _ _ ℂ) := dSVDensityRationalPhysicalAcceptedProjector_eq_spectralMask w N ξ have physical_z : Matrix.blockDiagonal' (fun k : Fin N => dSVDensityRationalPhysicalProjector w ζ k) = ((((dSVUniformDensityAliceHistorySpectralCopy (N := N) ζ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)) * R * (dSVUniformDensityAliceHistorySpectralCopy (N := N) ζ : Matrix _ _ ℂ) := dSVDensityRationalPhysicalAcceptedProjector_eq_spectralMask w N ζ have transpose_x : (S : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ).transpose = (X : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) := dSVUniformDensityPhysicalSpectralAliceCopy_transpose (N := N) ξ have transpose_z : (dSVUniformDensityAliceHistorySpectralCopy (N := N) ζ : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ).transpose = (Z : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) := dSVUniformDensityPhysicalSpectralAliceCopy_transpose (N := N) ζ have inverse_x : (((S⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)).transpose = (((X⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)) := dSVUniformDensityPhysicalSpectralAliceCopy_inv_transpose (N := N) ξ have inverse_z : ((((dSVUniformDensityAliceHistorySpectralCopy (N := N) ζ)⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)).transpose = (((Z⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)) := dSVUniformDensityPhysicalSpectralAliceCopy_inv_transpose (N := N) ζ have cancel_x : XI * (X : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) = 1 := by change star (X : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) * (X : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) = 1 exact (Matrix.mem_unitaryGroup_iff').mp X.property have cancel_z : ZI * (Z : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) = 1 := by change star (Z : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) * (Z : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) = 1 exact (Matrix.mem_unitaryGroup_iff').mp Z.property change ZI * ((Matrix.blockDiagonal' (fun k : Fin N => dSVDensityRationalPhysicalProjector w ξ k) * Matrix.blockDiagonal' (fun k : Fin N => dSVDensityRationalPhysicalProjector w ζ k)).transpose) * (S : Matrix _ _ ℂ).transpose = R * dSVDensityRationalMixedCanonicalCrossMatrix N ξ ζ * M calc _ = ((ZI * (Z : Matrix _ _ ℂ)) * R) * (ZI * (X : Matrix _ _ ℂ)) * (M * (XI * (X : Matrix _ _ ℂ))) := by rw [physical_x, physical_z] dsimp only [XI, ZI] simp only [Matrix.transpose_mul, dSVDensityRationalCanonicalPrefixMask_transpose, transpose_x, transpose_z, inverse_x, inverse_z, Matrix.mul_assoc, M, R] _ = R * (ZI * (X : Matrix _ _ ℂ)) * M := by rw [cancel_x, cancel_z] simp _ = _ := by dsimp only [ZI] rw [dSVDensityRationalMixedCanonicalCrossGauge_eq N ξ ζ] theorem dSVDensityRationalMixedCanonicalSpectralOutcome_eq {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalCanonicalPrefixSpectralOutcome w N ξ ζ = (‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) • dSVDensityRationalMixedCanonicalRawSource w N ξ ζ := by classical let S : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ let T : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVUniformDensityBobHistoryCopyBasis (N := N) ζ let c : ℝ := ‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ let K : Matrix (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) ℂ := (S : Matrix _ _ ℂ) ⊗ₖ (((T⁻¹ : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ)) unfold dSVDensityRationalCanonicalPrefixSpectralOutcome dSVDensityRationalPhysicalAcceptedOutcome rw [dSVDensityRationalCompleteProjectiveOutcome_eq_blockVector] unfold dSVDensityRationalMixedCanonicalRawSource change Matrix.toEuclideanLin K (c • toLp 2 (Matrix.vec ((Matrix.blockDiagonal' fun k : Fin N => dSVDensityRationalPhysicalProjector w ξ k * dSVDensityRationalPhysicalProjector w ζ k).transpose))) = c • toLp 2 (Matrix.vec (dSVDensityRationalCanonicalPrefixMask w N ζ * dSVDensityRationalMixedCanonicalCrossMatrix N ξ ζ * dSVDensityRationalCanonicalPrefixMask w N ξ)) rw [(Matrix.toEuclideanLin K).map_smul_of_tower] congr 1 apply WithLp.ofLp_injective change K.mulVec (Matrix.vec ((Matrix.blockDiagonal' fun k : Fin N => dSVDensityRationalPhysicalProjector w ξ k * dSVDensityRationalPhysicalProjector w ζ k).transpose)) = Matrix.vec (dSVDensityRationalCanonicalPrefixMask w N ζ * dSVDensityRationalMixedCanonicalCrossMatrix N ξ ζ * dSVDensityRationalCanonicalPrefixMask w N ξ) dsimp [K] rw [Matrix.kronecker_mulVec_vec] apply congrArg Matrix.vec rw [Matrix.blockDiagonal'_mul] exact dSVDensityRationalMixedCanonicalProjectorMatrix_eq w N ξ ζ def dSVDensityRationalPublicLogBilateralPureTensor {ι κ : Type*} [Fintype ι] [Fintype κ] (v : EuclideanSpace ℂ (ι × ι)) (u : EuclideanSpace ℂ (κ × κ)) : EuclideanSpace ℂ ((ι × κ) × (ι × κ)) := toLp 2 fun q : (ι × κ) × (ι × κ) => v (q.1.1, q.2.1) * u (q.1.2, q.2.2) theorem dSVDensityRationalPublicLogBilateralPureTensor_norm_sq {ι κ : Type*} [Fintype ι] [Fintype κ] (v : EuclideanSpace ℂ (ι × ι)) (u : EuclideanSpace ℂ (κ × κ)) : ‖dSVDensityRationalPublicLogBilateralPureTensor v u‖ ^ 2 = ‖v‖ ^ 2 * ‖u‖ ^ 2 := by classical rw [EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq, EuclideanSpace.norm_sq_eq] change (∑ q : (ι × κ) × (ι × κ), ‖v (q.1.1, q.2.1) * u (q.1.2, q.2.2)‖ ^ 2) = (∑ q : ι × ι, ‖v q‖ ^ 2) * (∑ q : κ × κ, ‖u q‖ ^ 2) simp only [Fintype.sum_prod_type, norm_mul, mul_pow] calc (∑ a : ι, ∑ x : κ, ∑ b : ι, ∑ y : κ, ‖v (a, b)‖ ^ 2 * ‖u (x, y)‖ ^ 2) = ∑ a : ι, ∑ b : ι, ∑ x : κ, ∑ y : κ, ‖v (a, b)‖ ^ 2 * ‖u (x, y)‖ ^ 2 := by apply Finset.sum_congr rfl intro a _ rw [Finset.sum_comm] _ = (∑ a : ι, ∑ b : ι, ‖v (a, b)‖ ^ 2) * (∑ x : κ, ∑ y : κ, ‖u (x, y)‖ ^ 2) := by symm rw [Finset.sum_mul] apply Finset.sum_congr rfl intro a _ rw [Finset.sum_mul] apply Finset.sum_congr rfl intro b _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro x _ rw [Finset.mul_sum] abbrev DSVDensityRationalPublicLogPhaseHistoryLocalIndex (B N d L : ℕ) := Fin B × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L def dSVDensityRationalPublicLogPhasePureSource (B N d L : ℕ) : EuclideanSpace ℂ (DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L × DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L) := dSVDensityRationalPublicLogBilateralPureTensor (ePRState B) (dSVUniformDensityThresholdWholeHistorySharedState N d L) theorem dSVDensityRationalPublicLogPhasePureSource_apply (B N d L : ℕ) (φ ψ : Fin B) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) : dSVDensityRationalPublicLogPhasePureSource B N d L ((φ, a), (ψ, b)) = (if φ = ψ then (((Real.sqrt (B : ℝ))⁻¹ : ℝ) : ℂ) else 0) * dSVUniformDensityThresholdWholeHistorySharedState N d L (a, b) := by simp [dSVDensityRationalPublicLogPhasePureSource, dSVDensityRationalPublicLogBilateralPureTensor, ePRState] theorem dSVDensityRationalPublicLogPhasePureSource_norm {B N d L : ℕ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) : ‖dSVDensityRationalPublicLogPhasePureSource B N d L‖ = 1 := by have squared : ‖dSVDensityRationalPublicLogPhasePureSource B N d L‖ ^ 2 = 1 := by unfold dSVDensityRationalPublicLogPhasePureSource rw [dSVDensityRationalPublicLogBilateralPureTensor_norm_sq, ePRState_norm B phases, dSVUniformDensityThresholdWholeHistorySharedState_norm grid dimension L] norm_num nlinarith [norm_nonneg (dSVDensityRationalPublicLogPhasePureSource B N d L)] def dSVDensityRationalPublicLogPhaseHarmonicPureSource (B N d L m : ℕ) : EuclideanSpace ℂ ((DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L × Fin m) × (DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L × Fin m)) := dSVDensityRationalPublicLogBilateralPureTensor (dSVDensityRationalPublicLogPhasePureSource B N d L) (embezzlementState m) theorem dSVDensityRationalPublicLogPhaseHarmonicPureSource_apply (B N d L m : ℕ) (φ ψ : Fin B) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (i j : Fin m) : dSVDensityRationalPublicLogPhaseHarmonicPureSource B N d L m (((φ, a), i), ((ψ, b), j)) = (if φ = ψ then (((Real.sqrt (B : ℝ))⁻¹ : ℝ) : ℂ) else 0) * dSVUniformDensityThresholdWholeHistorySharedState N d L (a, b) * embezzlementState m (i, j) := by change dSVDensityRationalPublicLogPhasePureSource B N d L ((φ, a), (ψ, b)) * embezzlementState m (i, j) = _ rw [dSVDensityRationalPublicLogPhasePureSource_apply] theorem dSVDensityRationalPublicLogPhaseHarmonicPureSource_norm {B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) : ‖dSVDensityRationalPublicLogPhaseHarmonicPureSource B N d L m‖ = 1 := by have squared : ‖dSVDensityRationalPublicLogPhaseHarmonicPureSource B N d L m‖ ^ 2 = 1 := by unfold dSVDensityRationalPublicLogPhaseHarmonicPureSource rw [dSVDensityRationalPublicLogBilateralPureTensor_norm_sq, dSVDensityRationalPublicLogPhasePureSource_norm phases grid dimension, embezzlementState_norm m harmonic] norm_num nlinarith [norm_nonneg (dSVDensityRationalPublicLogPhaseHarmonicPureSource B N d L m)] abbrev DSVDensityRationalPublicLogPhaseCatalystIndex (B N d L : ℕ) := Fin B × DSVUniformDensityThresholdWholeHistoryCatalystIndex N d L def dSVDensityRationalPublicLogPhaseTargetSplitEquiv (B N d L : ℕ) : DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L ≃ (Fin d × DSVDensityRationalPublicLogPhaseCatalystIndex B N d L) where toFun q := let actual := dSVUniformDensityThresholdWholeHistoryTargetSplitEquiv N d L q.2 (actual.1, (q.1, actual.2)) invFun q := (q.2.1, (dSVUniformDensityThresholdWholeHistoryTargetSplitEquiv N d L).symm (q.1, q.2.2)) left_inv := by rintro ⟨phase, history⟩ simp right_inv := by rintro ⟨target, phase, catalyst⟩ simp def dSVDensityRationalPublicLogPhaseResidual (B N d L m : ℕ) : ℕ := Fintype.card (DSVDensityRationalPublicLogPhaseCatalystIndex B N d L) * m def dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv (B N d L m : ℕ) : (DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L × Fin m) ≃ Fin (d * dSVDensityRationalPublicLogPhaseResidual B N d L m) := (Equiv.prodCongr (dSVDensityRationalPublicLogPhaseTargetSplitEquiv B N d L) (Equiv.refl (Fin m))).trans (dSVRankControlledTargetCatalystIndexEquiv (ι := DSVDensityRationalPublicLogPhaseCatalystIndex B N d L) d m) def dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource (B N d L m : ℕ) : EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicLogPhaseResidual B N d L m) × Fin (d * dSVDensityRationalPublicLogPhaseResidual B N d L m)) := LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m) (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m)) (dSVDensityRationalPublicLogPhaseHarmonicPureSource B N d L m) theorem dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource_apply (B N d L m : ℕ) (φ ψ : Fin B) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (i j : Fin m) : dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource B N d L m (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m ((φ, a), i), dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m ((ψ, b), j)) = (if φ = ψ then (((Real.sqrt (B : ℝ))⁻¹ : ℝ) : ℂ) else 0) * dSVUniformDensityThresholdWholeHistorySharedState N d L (a, b) * embezzlementState m (i, j) := by unfold dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource simpa [LinearIsometryEquiv.piLpCongrLeft_apply, Equiv.piCongrLeft'] using (dSVDensityRationalPublicLogPhaseHarmonicPureSource_apply B N d L m φ ψ a b i j) theorem dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource_norm {B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) : ‖dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource B N d L m‖ = 1 := by unfold dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource rw [LinearIsometryEquiv.norm_map] exact dSVDensityRationalPublicLogPhaseHarmonicPureSource_norm phases grid dimension harmonic abbrev DSVDensityRationalPublicMultiscalePhaseHistoryLocalIndex (S B N d L : ℕ) := DSVDensityRationalPublicMultiscalePhaseIndex S B × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L def dSVDensityRationalPublicMultiscalePhaseResidual (S B N d L m : ℕ) : ℕ := dSVDensityRationalPublicLogPhaseResidual (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) N d L m def dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv (S B N d L m : ℕ) : (DSVDensityRationalPublicMultiscalePhaseHistoryLocalIndex S B N d L × Fin m) ≃ Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) := dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) N d L m def dSVDensityRationalPublicMultiscalePhaseTargetFirstPreparedSource (S B N d L m : ℕ) : EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) × Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) := dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) N d L m theorem dSVDensityRationalPublicMultiscalePhaseTargetFirstPreparedSource_norm {S B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) : ‖dSVDensityRationalPublicMultiscalePhaseTargetFirstPreparedSource S B N d L m‖ = 1 := by unfold dSVDensityRationalPublicMultiscalePhaseTargetFirstPreparedSource exact dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource_norm (dSVDensityRationalPublicMultiscalePhase_card_pos phases) grid dimension harmonic end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder def dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift (B N d L m : ℕ) (U : Matrix.unitaryGroup (DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L) ℂ) : Matrix.unitaryGroup (Fin (d * dSVDensityRationalPublicLogPhaseResidual B N d L m)) ℂ := by classical let whole : Matrix.unitaryGroup (DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L × Fin m) ℂ := ⟨U.val ⊗ₖ (1 : Matrix (Fin m) (Fin m) ℂ), Matrix.kronecker_mem_unitary U.property (Matrix.unitaryGroup (Fin m) ℂ).one_mem⟩ exact dSVOriginalComputationalReindexedUnitary (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m) whole theorem dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift_apply (B N d L m : ℕ) (U : Matrix.unitaryGroup (DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L) ℂ) (a b : DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L) (i j : Fin m) : dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift B N d L m U (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m (a, i)) (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m (b, j)) = if i = j then U a b else 0 := by classical change (Matrix.reindex (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m) (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m) (U.val ⊗ₖ (1 : Matrix (Fin m) (Fin m) ℂ))) (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m (a, i)) (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m (b, j)) = _ simp [Matrix.reindex_apply, Matrix.kroneckerMap_apply, Matrix.one_apply] def dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary (B : ℕ) {N d L : ℕ} (U : Matrix.unitaryGroup (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) : Matrix.unitaryGroup (DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L) ℂ := by classical exact ⟨(1 : Matrix (Fin B) (Fin B) ℂ) ⊗ₖ U.val, Matrix.kronecker_mem_unitary (Matrix.unitaryGroup (Fin B) ℂ).one_mem U.property⟩ theorem dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary_apply (B : ℕ) {N d L : ℕ} (U : Matrix.unitaryGroup (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) (φ ψ : Fin B) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) : dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary B U (φ, a) (ψ, b) = if φ = ψ then U a b else 0 := by classical change ((1 : Matrix (Fin B) (Fin B) ℂ) ⊗ₖ U.val) (φ, a) (ψ, b) = _ simp [Matrix.kroneckerMap_apply, Matrix.one_apply] end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalHeterogeneousActualAcceptSet {β : Type*} {L : ℕ} (accepted : Fin L → β → Prop) (history : Fin (L + 1) → β) : Finset (Fin L) := by classical exact Finset.univ.filter fun j : Fin L => accepted j (history j.castSucc) def dSVDensityRationalHeterogeneousActualFirstAccepted {β : Type*} {L : ℕ} (accepted : Fin L → β → Prop) (history : Fin (L + 1) → β) : Fin (L + 1) := by classical let hits := dSVDensityRationalHeterogeneousActualAcceptSet accepted history exact if nonempty : hits.Nonempty then (hits.min' nonempty).succ else 0 theorem dSVDensityRationalHeterogeneousActualFirstAccepted_prefix_iff {β : Type*} {L : ℕ} (accepted : Fin L → β → Prop) (history : Fin (L + 1) → β) (j : Fin L) : dSVDensityRationalHeterogeneousActualFirstAccepted accepted history = j.succ ↔ accepted j (history j.castSucc) ∧ ∀ i : Fin L, i < j → ¬ accepted i (history i.castSucc) := by classical unfold dSVDensityRationalHeterogeneousActualFirstAccepted simpa [dSVDensityRationalHeterogeneousActualAcceptSet] using dSVUniformDensityFirstAcceptFinitePrefix (dSVDensityRationalHeterogeneousActualAcceptSet accepted history) j theorem dSVDensityRationalHeterogeneousActualFirstAccepted_zero_iff {β : Type*} {L : ℕ} (accepted : Fin L → β → Prop) (history : Fin (L + 1) → β) : dSVDensityRationalHeterogeneousActualFirstAccepted accepted history = 0 ↔ ∀ i : Fin L, ¬ accepted i (history i.castSucc) := by classical unfold dSVDensityRationalHeterogeneousActualFirstAccepted let hits := dSVDensityRationalHeterogeneousActualAcceptSet accepted history change (if h : hits.Nonempty then (hits.min' h).succ else 0) = 0 ↔ _ by_cases nonempty : hits.Nonempty · rw [dif_pos nonempty] constructor · intro impossible exact (Fin.succ_ne_zero _ impossible).elim · intro none obtain ⟨j, member⟩ := nonempty have hit : accepted j (history j.castSucc) := by simpa [hits, dSVDensityRationalHeterogeneousActualAcceptSet] using member exact (none j hit).elim · rw [dif_neg nonempty] simp only [true_iff] intro j hit apply nonempty refine ⟨j, ?_⟩ simpa [hits, dSVDensityRationalHeterogeneousActualAcceptSet] using hit def dSVDensityRationalHeterogeneousActualFirstAcceptEquiv {β : Type*} {L : ℕ} (accepted : Fin L → β → Prop) : Equiv.Perm (Σ _ : Fin (L + 1), Fin (L + 1) → β) where toFun q := ⟨(Equiv.swap (0 : Fin (L + 1)) (dSVDensityRationalHeterogeneousActualFirstAccepted accepted q.2)) q.1, q.2⟩ invFun q := ⟨(Equiv.swap (0 : Fin (L + 1)) (dSVDensityRationalHeterogeneousActualFirstAccepted accepted q.2)) q.1, q.2⟩ left_inv := by rintro ⟨flag, history⟩ simp right_inv := by rintro ⟨flag, history⟩ simp def dSVDensityRationalHeterogeneousActualFirstAcceptUnitary {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) : Matrix.unitaryGroup (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ := permutationUnitary (dSVDensityRationalHeterogeneousActualFirstAcceptEquiv accepted) theorem dSVDensityRationalHeterogeneousActualFirstAcceptUnitary_mulVec {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) (v : (Σ _ : Fin (L + 1), Fin (L + 1) → β) → ℂ) (flag : Fin (L + 1)) (history : Fin (L + 1) → β) : ((dSVDensityRationalHeterogeneousActualFirstAcceptUnitary accepted : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ)).mulVec v ⟨flag, history⟩ = v ⟨(Equiv.swap (0 : Fin (L + 1)) (dSVDensityRationalHeterogeneousActualFirstAccepted accepted history)) flag, history⟩ := by rw [dSVDensityRationalHeterogeneousActualFirstAcceptUnitary, permutationUnitary_val, Matrix.permMatrix_mulVec] rfl theorem dSVDensityRationalHeterogeneousActualFirstAcceptUnitary_zeroFlag {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) (v : (Fin (L + 1) → β) → ℂ) (flag : Fin (L + 1)) (history : Fin (L + 1) → β) : ((dSVDensityRationalHeterogeneousActualFirstAcceptUnitary accepted : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ)).mulVec (fun q => if q.1 = 0 then v q.2 else 0) ⟨flag, history⟩ = if flag = dSVDensityRationalHeterogeneousActualFirstAccepted accepted history then v history else 0 := by rw [dSVDensityRationalHeterogeneousActualFirstAcceptUnitary_mulVec] let selected := dSVDensityRationalHeterogeneousActualFirstAccepted accepted history change (if (Equiv.swap (0 : Fin (L + 1)) selected) flag = 0 then v history else 0) = if flag = selected then v history else 0 congr 1 apply propext constructor · intro zero have injective := (Equiv.swap (0 : Fin (L + 1)) selected).injective apply injective simpa using zero · intro same subst flag simp def dSVDensityRationalHeterogeneousActualCopyAccepted {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (j : Fin L) (atom : DSVUniformDensityThresholdLocalIndex N d) : Prop := dSVDensityRationalCompletePhysicalStoppingCopyAccepted (width (schedule j)) ξ atom def dSVDensityRationalHeterogeneousActualCopyCondition {β : Type*} {L : ℕ} (accepted : Fin L → β → Prop) (flag : Fin (L + 1)) (i : Fin (L + 1)) (atom : β) : Prop := if active : i.val < L then if flag = 0 then ¬ accepted ⟨i.val, active⟩ atom else if i.val + 1 < flag.val then ¬ accepted ⟨i.val, active⟩ atom else if i.val + 1 = flag.val then accepted ⟨i.val, active⟩ atom else True else True theorem dSVDensityRationalHeterogeneousActualFirstAccepted_allFlags_iff {β : Type*} {L : ℕ} (accepted : Fin L → β → Prop) (history : Fin (L + 1) → β) (flag : Fin (L + 1)) : dSVDensityRationalHeterogeneousActualFirstAccepted accepted history = flag ↔ ∀ i : Fin (L + 1), dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i (history i) := by induction flag using Fin.cases with | zero => rw [dSVDensityRationalHeterogeneousActualFirstAccepted_zero_iff] constructor · intro failed i by_cases active : i.val < L · have actual := failed (⟨i.val, active⟩ : Fin L) simpa [dSVDensityRationalHeterogeneousActualCopyCondition, active] using actual · simp [dSVDensityRationalHeterogeneousActualCopyCondition, active] · intro all i have actual := all i.castSucc simpa [dSVDensityRationalHeterogeneousActualCopyCondition, i.isLt] using actual | succ j => rw [dSVDensityRationalHeterogeneousActualFirstAccepted_prefix_iff] constructor · rintro ⟨hit, earlier⟩ i by_cases active : i.val < L · by_cases before : i.val < j.val · have failure := earlier (⟨i.val, active⟩ : Fin L) (by exact before) simpa [dSVDensityRationalHeterogeneousActualCopyCondition, active, Fin.succ_ne_zero, before] using failure · by_cases equal : i.val = j.val · have same : i = j.castSucc := Fin.ext equal subst i simpa [dSVDensityRationalHeterogeneousActualCopyCondition, j.isLt, Fin.succ_ne_zero] using hit · simp [dSVDensityRationalHeterogeneousActualCopyCondition, active, Fin.succ_ne_zero, before, equal] · simp [dSVDensityRationalHeterogeneousActualCopyCondition, active] · intro all constructor · have actual := all j.castSucc simpa [dSVDensityRationalHeterogeneousActualCopyCondition, j.isLt, Fin.succ_ne_zero] using actual · intro i before have actual := all i.castSucc simpa [dSVDensityRationalHeterogeneousActualCopyCondition, i.isLt, Fin.succ_ne_zero, before] using actual theorem dSVDensityRationalHeterogeneousActualFirstAccepted_sourceProduct {β : Type*} [Fintype β] {L : ℕ} (accepted : Fin L → β → Prop) (flag : Fin (L + 1)) (A D : Fin (L + 1) → β → ℂ) : (∑ history : Fin (L + 1) → β, (∏ i : Fin (L + 1), A i (history i)) * (if flag = dSVDensityRationalHeterogeneousActualFirstAccepted accepted history then ∏ i : Fin (L + 1), D i (history i) else 0)) = ∏ i : Fin (L + 1), ∑ atom : β, A i atom * (if dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i atom then D i atom else 0) := by classical have single (history : Fin (L + 1) → β) : (∏ i : Fin (L + 1), A i (history i)) * (if flag = dSVDensityRationalHeterogeneousActualFirstAccepted accepted history then ∏ i : Fin (L + 1), D i (history i) else 0) = ∏ i : Fin (L + 1), (A i (history i) * (if dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i (history i) then D i (history i) else 0)) := by by_cases selected : dSVDensityRationalHeterogeneousActualFirstAccepted accepted history = flag · have all := (dSVDensityRationalHeterogeneousActualFirstAccepted_allFlags_iff accepted history flag).mp selected rw [if_pos selected.symm, ← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro i _ rw [if_pos (all i)] · have absent : ¬ ∀ i : Fin (L + 1), dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i (history i) := by intro all exact selected ((dSVDensityRationalHeterogeneousActualFirstAccepted_allFlags_iff accepted history flag).mpr all) push Not at absent obtain ⟨i, rejected⟩ := absent have zero : (∏ k : Fin (L + 1), A k (history k) * (if dSVDensityRationalHeterogeneousActualCopyCondition accepted flag k (history k) then D k (history k) else 0)) = 0 := by apply Finset.prod_eq_zero (Finset.mem_univ i) simp [rejected] rw [if_neg (Ne.symm selected), mul_zero, zero] calc _ = ∑ history : Fin (L + 1) → β, ∏ i : Fin (L + 1), (A i (history i) * (if dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i (history i) then D i (history i) else 0)) := by apply Finset.sum_congr rfl intro history _ exact single history _ = _ := (Fintype.prod_sum fun i : Fin (L + 1) => fun atom : β => A i atom * (if dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i atom then D i atom else 0)).symm def dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) (U : Matrix.unitaryGroup β ℂ) : Matrix.unitaryGroup (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ := (dSVDensityRationalFirstAcceptActualTensorBasis (L := L) U)⁻¹ * dSVDensityRationalHeterogeneousActualFirstAcceptUnitary accepted * dSVDensityRationalFirstAcceptActualTensorBasis (L := L) U def dSVDensityRationalHeterogeneousActualAliceUnitary (N : ℕ) {S d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) : Matrix.unitaryGroup (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ := dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ξ) (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) def dSVDensityRationalHeterogeneousActualBobUnitary (N : ℕ) {S d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ζ : BipartiteUnitVector d) : Matrix.unitaryGroup (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ := dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ζ) ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) def dSVDensityRationalHeterogeneousActualPhysicalState (N : ℕ) {S d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) := toLp 2 ((((dSVDensityRationalHeterogeneousActualAliceUnitary N width schedule ξ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) ⊗ₖ (dSVDensityRationalHeterogeneousActualBobUnitary N width schedule ζ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ)).mulVec (ofLp (dSVUniformDensityThresholdWholeHistorySharedState N d L)))) theorem dSVDensityRationalHeterogeneousActualPhysicalState_norm {S N d L : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : ‖dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ‖ = 1 := by unfold dSVDensityRationalHeterogeneousActualPhysicalState rw [dSVUniformDensityMixedProtocolLocalAction_norm] exact dSVUniformDensityThresholdWholeHistorySharedState_norm grid dimension L end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder def dSVDensityRationalHeterogeneousPhysicalStageOutcome {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) (alice bob : Bool) : ℝ := if active : k < L then ‖dSVDensityRationalCompleteProjectiveOutcome (width (schedule ⟨k, active⟩)) N ξ ζ alice bob‖ ^ 2 else if alice = false ∧ bob = false then 1 else 0 def dSVDensityRationalHeterogeneousPhysicalStageContinue {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) : ℝ := dSVDensityRationalHeterogeneousPhysicalStageOutcome N width schedule ξ ζ k false false def dSVDensityRationalHeterogeneousPhysicalStageSuccess {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) : ℝ := dSVDensityRationalHeterogeneousPhysicalStageOutcome N width schedule ξ ζ k true true def dSVDensityRationalHeterogeneousPhysicalStageAsynchronous {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) : ℝ := dSVDensityRationalHeterogeneousPhysicalStageOutcome N width schedule ξ ζ k true false + dSVDensityRationalHeterogeneousPhysicalStageOutcome N width schedule ξ ζ k false true theorem dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) (alice bob : Bool) : 0 ≤ dSVDensityRationalHeterogeneousPhysicalStageOutcome N width schedule ξ ζ k alice bob := by unfold dSVDensityRationalHeterogeneousPhysicalStageOutcome split_ifs <;> positivity theorem dSVDensityRationalHeterogeneousPhysicalStage_partition {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) : dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k = 1 := by by_cases active : k < L · simpa [ dSVDensityRationalHeterogeneousPhysicalStageContinue, dSVDensityRationalHeterogeneousPhysicalStageSuccess, dSVDensityRationalHeterogeneousPhysicalStageAsynchronous, dSVDensityRationalHeterogeneousPhysicalStageOutcome, active, dSVDensityRationalActualMixedContinueMass, dSVDensityRationalActualMixedSuccessMass, dSVDensityRationalActualMixedAsynchronousMass] using (dSVDensityRationalActualMixed_mass_partition grid dimension (width (schedule ⟨k, active⟩)) ξ ζ) · simp [ dSVDensityRationalHeterogeneousPhysicalStageContinue, dSVDensityRationalHeterogeneousPhysicalStageSuccess, dSVDensityRationalHeterogeneousPhysicalStageAsynchronous, dSVDensityRationalHeterogeneousPhysicalStageOutcome, active] theorem dSVDensityRationalHeterogeneousPhysicalStageAsynchronous_eq_hazard {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : Fin L) : dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k.val = dSVDensityRationalPhysicalProjectorCrossHazard N (width (schedule k)) ξ ζ := by simpa [ dSVDensityRationalHeterogeneousPhysicalStageAsynchronous, dSVDensityRationalHeterogeneousPhysicalStageOutcome, k.isLt, dSVDensityRationalActualMixedAsynchronousMass] using (dSVDensityRationalActualMixedAsynchronousMass_eq_crossHazard (width (schedule k)) N ξ ζ) def dSVDensityRationalHeterogeneousPhysicalSurvival {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) : ℝ := dSVHeterogeneousRealPrefix (dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ) k theorem dSVDensityRationalHeterogeneousPhysicalSurvival_nonneg {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) : 0 ≤ dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k := by unfold dSVDensityRationalHeterogeneousPhysicalSurvival apply dSVHeterogeneousRealPrefix_nonneg intro j exact dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ j false false def dSVDensityRationalHeterogeneousPhysicalStoppedSuccessMass {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : ℝ := ∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k def dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : ℝ := ∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k def dSVDensityRationalHeterogeneousPhysicalTerminalMass {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : ℝ := dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ L theorem dSVDensityRationalHeterogeneousPhysicalStopped_mass_partition {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousPhysicalStoppedSuccessMass N width schedule ξ ζ + dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ + dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule ξ ζ = 1 := by let continuation := dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ let success := dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ let asynchronous := dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ have stage (k : ℕ) : success k + asynchronous k = 1 - continuation k := by dsimp [continuation, success, asynchronous] linarith [ dSVDensityRationalHeterogeneousPhysicalStage_partition grid dimension width schedule ξ ζ k] have escape := dSVHeterogeneousRealStopping_escape_identity continuation L change (∑ k ∈ Finset.range L, dSVHeterogeneousRealPrefix continuation k * success k) + (∑ k ∈ Finset.range L, dSVHeterogeneousRealPrefix continuation k * asynchronous k) + dSVHeterogeneousRealPrefix continuation L = 1 have combined : (∑ k ∈ Finset.range L, dSVHeterogeneousRealPrefix continuation k * success k) + (∑ k ∈ Finset.range L, dSVHeterogeneousRealPrefix continuation k * asynchronous k) = ∑ k ∈ Finset.range L, dSVHeterogeneousRealPrefix continuation k * (1 - continuation k) := by rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro k _ rw [← mul_add, stage k] rw [combined, escape] ring theorem dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass_eq_hazard {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ = ∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * dSVDensityRationalPhysicalProjectorCrossHazard N (width (schedule k)) ξ ζ := by classical unfold dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass calc (∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) = ∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k.val := by simpa using (Fin.sum_univ_eq_sum_range (fun k : ℕ => dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) L).symm _ = _ := by apply Finset.sum_congr rfl intro k _ rw [ dSVDensityRationalHeterogeneousPhysicalStageAsynchronous_eq_hazard N width schedule ξ ζ k] theorem dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass_nonneg {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : 0 ≤ dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ := by unfold dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass apply Finset.sum_nonneg intro k _ apply mul_nonneg (dSVDensityRationalHeterogeneousPhysicalSurvival_nonneg N width schedule ξ ζ k) exact add_nonneg (dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k true false) (dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k false true) theorem dSVDensityRationalHeterogeneousPhysicalTerminalMass_nonneg {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : 0 ≤ dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule ξ ζ := dSVDensityRationalHeterogeneousPhysicalSurvival_nonneg N width schedule ξ ζ L def dSVDensityRationalHeterogeneousPhysicalStageHazardRatio {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) : ℝ := dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k / (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) theorem dSVDensityRationalHeterogeneousPhysicalStageAsynchronous_eq_escape_mul_ratio {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : ℕ) : dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k = (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) * dSVDensityRationalHeterogeneousPhysicalStageHazardRatio N width schedule ξ ζ k := by let p := dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k let h := dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k have p_nonnegative : 0 ≤ p := dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k true true have h_nonnegative : 0 ≤ h := add_nonneg (dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k true false) (dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k false true) change h = (p + h) * (h / (p + h)) by_cases vanished : p + h = 0 · have h_zero : h = 0 := by linarith simp [h_zero] · field_simp theorem dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass_eq_ratioLedger {d S L : ℕ} (N : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ = ∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) * dSVDensityRationalHeterogeneousPhysicalStageHazardRatio N width schedule ξ ζ k := by unfold dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass apply Finset.sum_congr rfl intro k _ calc dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * ((dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) * dSVDensityRationalHeterogeneousPhysicalStageHazardRatio N width schedule ξ ζ k) := congrArg (fun x : ℝ => dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * x) (dSVDensityRationalHeterogeneousPhysicalStageAsynchronous_eq_escape_mul_ratio N width schedule ξ ζ k) _ = _ := by ring theorem dSVDensityRationalHeterogeneousPhysicalStageDiagonalSuccess_lower {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (k : Fin L) : 1 / (2 * (width (schedule k) + 1) * (d : ℝ)) ≤ dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ := by have width_positive : 0 < width (schedule k) := lt_of_lt_of_le (by norm_num) (large (schedule k)) have mass := dSVDensityRationalLargeWidthDiagonalMass_half width_positive grid (fine (schedule k)) ξ have dimension_real : 0 < (d : ℝ) := by exact_mod_cast dimension calc 1 / (2 * (width (schedule k) + 1) * (d : ℝ)) = (1 / (2 * (width (schedule k) + 1))) / (d : ℝ) := by rw [div_div] _ ≤ dSVDensityRationalLeftProjectiveDiagonalMass (width (schedule k)) N ξ / (d : ℝ) := (div_le_div_iff_of_pos_right dimension_real).mpr mass _ = dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ := by rw [dSVDensityRationalPhysicalDiagonalBornSuccess_eq] theorem dSVDensityRationalHeterogeneousPhysicalStage_escape_ge_diagonal {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : Fin L) : dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ ≤ dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k.val + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k.val := by simpa [ dSVDensityRationalHeterogeneousPhysicalStageSuccess, dSVDensityRationalHeterogeneousPhysicalStageAsynchronous, dSVDensityRationalHeterogeneousPhysicalStageOutcome, k.isLt, dSVDensityRationalActualMixedSuccessMass, dSVDensityRationalActualMixedAsynchronousMass] using dSVDensityRationalActualMixed_escape_ge_diagonal grid dimension (width (schedule k)) ξ ζ theorem dSVDensityRationalHeterogeneousPhysicalStageAsynchronous_relative_diagonal_le {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : Fin L) : dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k.val / dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (width (schedule k) + 1) * ((d : ℝ) / N) := by rw [ dSVDensityRationalHeterogeneousPhysicalStageAsynchronous_eq_hazard N width schedule ξ ζ k] exact dSVDensityRationalLargeWidthPhysicalRelativeHazard_le dimension (large (schedule k)) grid (fine (schedule k)) ξ ζ theorem dSVDensityRationalHeterogeneousPhysicalStageHazardRatio_le_relative_diagonal {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : Fin L) : dSVDensityRationalHeterogeneousPhysicalStageHazardRatio N width schedule ξ ζ k.val ≤ dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k.val / dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ := by have width_positive : 0 < width (schedule k) := lt_of_lt_of_le (by norm_num) (large (schedule k)) have self_positive := dSVDensityRationalLargeWidthPhysicalDiagonalBornSuccess_pos dimension width_positive grid (fine (schedule k)) ξ have self_lower := dSVDensityRationalHeterogeneousPhysicalStage_escape_ge_diagonal grid dimension width schedule ξ ζ k have asynchronous_nonnegative : 0 ≤ dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k.val := by exact add_nonneg (dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k.val true false) (dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k.val false true) unfold dSVDensityRationalHeterogeneousPhysicalStageHazardRatio exact div_le_div_of_nonneg_left asynchronous_nonnegative self_positive self_lower theorem dSVDensityRationalHeterogeneousPhysicalStageHazardRatio_le_targetDistance {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) {W : ℝ} (upper : ∀ s, width s ≤ W) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : Fin L) : dSVDensityRationalHeterogeneousPhysicalStageHazardRatio N width schedule ξ ζ k.val ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (W + 1) * ((d : ℝ) / N) := by calc _ ≤ dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k.val / dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ := dSVDensityRationalHeterogeneousPhysicalStageHazardRatio_le_relative_diagonal grid dimension width large fine schedule ξ ζ k _ ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (width (schedule k) + 1) * ((d : ℝ) / N) := dSVDensityRationalHeterogeneousPhysicalStageAsynchronous_relative_diagonal_le grid dimension width large fine schedule ξ ζ k _ ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (W + 1) * ((d : ℝ) / N) := by have scale := upper (schedule k) have grid_cost : 0 ≤ (d : ℝ) / N := by positivity nlinarith [mul_nonneg grid_cost (sub_nonneg.mpr scale)] theorem dSVDensityRationalHeterogeneousPhysicalStoppedEscape_budget {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : (∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k)) ≤ 1 := by let continuation := dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ let escape : ℕ → ℝ := fun k => dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k have continuation_nonnegative : ∀ k, 0 ≤ continuation k := by intro k exact dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k false false have stage : ∀ k, continuation k + escape k ≤ 1 := by intro k have actual := dSVDensityRationalHeterogeneousPhysicalStage_partition grid dimension width schedule ξ ζ k dsimp [continuation, escape] linarith simpa [continuation, escape, dSVDensityRationalHeterogeneousPhysicalSurvival] using dSVHeterogeneousRealStopping_escape_budget continuation escape continuation_nonnegative stage L theorem dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass_le_targetDistance {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) {W : ℝ} (upper : ∀ s, width s ≤ W) (W_nonnegative : 0 ≤ W) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (W + 1) * ((d : ℝ) / N) := by let bound : ℝ := 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + 2 * (W + 1) * ((d : ℝ) / N) have bound_nonnegative : 0 ≤ bound := by dsimp [bound] positivity have escape_budget := dSVDensityRationalHeterogeneousPhysicalStoppedEscape_budget grid dimension width schedule ξ ζ rw [ dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass_eq_ratioLedger] change (∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) * dSVDensityRationalHeterogeneousPhysicalStageHazardRatio N width schedule ξ ζ k) ≤ bound calc _ ≤ ∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) * bound := by apply Finset.sum_le_sum intro k member have active : k < L := Finset.mem_range.mp member let stage : Fin L := ⟨k, active⟩ have ratio := dSVDensityRationalHeterogeneousPhysicalStageHazardRatio_le_targetDistance grid dimension width large fine upper schedule ξ ζ stage have survival_nonnegative := dSVDensityRationalHeterogeneousPhysicalSurvival_nonneg N width schedule ξ ζ k have success_nonnegative := dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k true true have asynchronous_nonnegative : 0 ≤ dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k := by exact add_nonneg (dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k true false) (dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k false true) have coefficient_nonnegative : 0 ≤ dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) := mul_nonneg survival_nonnegative (add_nonneg success_nonnegative asynchronous_nonnegative) apply mul_le_mul_of_nonneg_left _ coefficient_nonnegative simpa [stage, bound] using ratio _ = (∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k)) * bound := by rw [Finset.sum_mul] _ ≤ bound := by nlinarith [mul_nonneg bound_nonnegative (sub_nonneg.mpr escape_budget)] def dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate (d : ℕ) (W : ℝ) : ℝ := 1 / (2 * (W + 1) * (d : ℝ)) theorem dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate_pos {d : ℕ} (dimension : 0 < d) {W : ℝ} (W_nonnegative : 0 ≤ W) : 0 < dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W := by unfold dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate positivity theorem dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate_le_half {d : ℕ} (dimension : 0 < d) {W : ℝ} (W_nonnegative : 0 ≤ W) : dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W ≤ (1 / 2 : ℝ) := by have real_dimension : 0 < (d : ℝ) := by exact_mod_cast dimension have dimension_one : (1 : ℝ) ≤ (d : ℝ) := by exact_mod_cast (Nat.one_le_iff_ne_zero.mpr (Nat.ne_of_gt dimension)) have denominator : 0 < 2 * (W + 1) * (d : ℝ) := by positivity unfold dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate apply (div_le_div_iff₀ denominator (by norm_num : (0 : ℝ) < 2)).mpr nlinarith [mul_nonneg W_nonnegative real_dimension.le] theorem dSVDensityRationalHeterogeneousPhysicalStageDiagonalSuccess_ge_uniform {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) {W : ℝ} (W_nonnegative : 0 ≤ W) (upper : ∀ s, width s ≤ W) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (k : Fin L) : dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W ≤ dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ := by have real_dimension : 0 < (d : ℝ) := by exact_mod_cast dimension have width_positive : 0 < width (schedule k) := lt_of_lt_of_le (by norm_num) (large (schedule k)) have wide_positive : 0 < 2 * (W + 1) * (d : ℝ) := by positivity have stage_positive : 0 < 2 * (width (schedule k) + 1) * (d : ℝ) := by positivity have width_bound := upper (schedule k) calc dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W = 1 / (2 * (W + 1) * (d : ℝ)) := rfl _ ≤ 1 / (2 * (width (schedule k) + 1) * (d : ℝ)) := by apply (div_le_div_iff₀ wide_positive stage_positive).mpr nlinarith [mul_nonneg real_dimension.le (sub_nonneg.mpr width_bound)] _ ≤ dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ := dSVDensityRationalHeterogeneousPhysicalStageDiagonalSuccess_lower grid dimension width large fine schedule ξ k theorem dSVDensityRationalHeterogeneousPhysicalStageContinue_le_uniform {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) {W : ℝ} (W_nonnegative : 0 ≤ W) (upper : ∀ s, width s ≤ W) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : Fin L) : dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ k.val ≤ 1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W := by have floor := dSVDensityRationalHeterogeneousPhysicalStageDiagonalSuccess_ge_uniform grid dimension width large fine W_nonnegative upper schedule ξ k have escape := dSVDensityRationalHeterogeneousPhysicalStage_escape_ge_diagonal grid dimension width schedule ξ ζ k have partition := dSVDensityRationalHeterogeneousPhysicalStage_partition grid dimension width schedule ξ ζ k.val linarith theorem dSVDensityRationalHeterogeneousPhysicalTerminalMass_le_pow {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) {W : ℝ} (W_nonnegative : 0 ≤ W) (upper : ∀ s, width s ≤ W) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule ξ ζ ≤ (1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W) ^ L := by let continuation := dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ let c : ℝ := 1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W have rate_bounded := dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate_le_half dimension W_nonnegative have c_nonnegative : 0 ≤ c := by dsimp [c] linarith have continuation_nonnegative : ∀ k, 0 ≤ continuation k := by intro k exact dSVDensityRationalHeterogeneousPhysicalStageOutcome_nonneg N width schedule ξ ζ k false false have prefix_bound : ∀ k : ℕ, k ≤ L → dSVHeterogeneousRealPrefix continuation k ≤ c ^ k := by intro k induction k with | zero => intro _ simp [dSVHeterogeneousRealPrefix] | succ k induction => intro within have active : k < L := by omega have previous := induction (by omega : k ≤ L) let stage : Fin L := ⟨k, active⟩ have next := dSVDensityRationalHeterogeneousPhysicalStageContinue_le_uniform grid dimension width large fine W_nonnegative upper schedule ξ ζ stage change continuation k ≤ c at next rw [dSVHeterogeneousRealPrefix_succ, pow_succ] exact mul_le_mul previous next (continuation_nonnegative k) (pow_nonneg c_nonnegative k) change dSVHeterogeneousRealPrefix continuation L ≤ c ^ L exact prefix_bound L (le_refl L) theorem dSVDensityRationalHeterogeneousPhysical_exists_positive_horizon {d : ℕ} (dimension : 0 < d) {W ε : ℝ} (W_nonnegative : 0 ≤ W) (precision : 0 < ε) : ∃ L : ℕ, 0 < L ∧ (1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W) ^ L ≤ ε ^ 2 := by have rate := dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate_pos dimension W_nonnegative have bounded := dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate_le_half dimension W_nonnegative have continuation : 0 ≤ 1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W := by linarith have square : 0 < ε ^ 2 := sq_pos_of_pos precision obtain ⟨k, tail⟩ := exists_pow_lt_of_lt_one square (show 1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W < 1 by linarith) refine ⟨k + 1, by omega, ?_⟩ calc (1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W) ^ (k + 1) ≤ (1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W) ^ k := by rw [pow_succ] nlinarith [pow_nonneg continuation k] _ ≤ ε ^ 2 := tail.le theorem dSVDensityRationalHeterogeneousPhysicalTerminalMass_le_horizon {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (large : ∀ s, 1 ≤ width s) (fine : ∀ s : Fin S, (d : ℝ) / N ≤ 1 / (2 * (width s + 1))) {W ε : ℝ} (W_nonnegative : 0 ≤ W) (upper : ∀ s, width s ≤ W) (tail : (1 - dSVDensityRationalHeterogeneousPhysicalUniformEscapeRate d W) ^ L ≤ ε ^ 2) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule ξ ζ ≤ ε ^ 2 := (dSVDensityRationalHeterogeneousPhysicalTerminalMass_le_pow grid dimension width large fine W_nonnegative upper schedule ξ ζ).trans tail end noncomputable section open scoped BigOperators variable {α : Type*} [Fintype α] [DecidableEq α] def fairPartitionWeight (α : Type*) [Fintype α] : ℝ := ((2 : ℝ) ^ Fintype.card α)⁻¹ def reversePartitionWeight (s : Finset α) : ℝ := fairPartitionWeight α * (2 * (s.card : ℝ) / (Fintype.card α : ℝ)) def forwardMarkedPartitionWeight (α : Type*) [Fintype α] : ℝ := 2 * fairPartitionWeight α / (Fintype.card α : ℝ) def reverseMarkedPartitionWeight (s : Finset α) (i : α) : ℝ := if i ∈ s then reversePartitionWeight s / (s.card : ℝ) else 0 omit [DecidableEq α] in theorem fairPartitionWeight_pos : 0 < fairPartitionWeight α := by unfold fairPartitionWeight positivity omit [DecidableEq α] in theorem fairPartitionWeight_nonneg : 0 ≤ fairPartitionWeight α := fairPartitionWeight_pos.le omit [DecidableEq α] in theorem fairPartitionWeight_sum : (∑ _s : Finset α, fairPartitionWeight α) = 1 := by simp [fairPartitionWeight, Fintype.card_finset] omit [DecidableEq α] in theorem reversePartitionWeight_nonneg (s : Finset α) : 0 ≤ reversePartitionWeight s := by unfold reversePartitionWeight exact mul_nonneg fairPartitionWeight_nonneg (div_nonneg (mul_nonneg (by norm_num) (by exact_mod_cast Nat.zero_le s.card)) (by exact_mod_cast Nat.zero_le (Fintype.card α))) omit [DecidableEq α] in @[simp] theorem reversePartitionWeight_empty : reversePartitionWeight (α := α) ∅ = 0 := by simp [reversePartitionWeight] omit [DecidableEq α] in theorem reversePartitionWeight_pos_iff (hα : 0 < Fintype.card α) (s : Finset α) : 0 < reversePartitionWeight s ↔ s.Nonempty := by constructor · intro hs apply Finset.card_pos.mp by_contra hcard have hzero : s.card = 0 := Nat.eq_zero_of_not_pos hcard simp [reversePartitionWeight, hzero] at hs · intro hs unfold reversePartitionWeight have hcard : 0 < s.card := Finset.card_pos.mpr hs exact mul_pos fairPartitionWeight_pos (div_pos (mul_pos (by norm_num) (by exact_mod_cast hcard)) (by exact_mod_cast hα)) theorem reverseMarkedPartitionWeight_eq_forward {s : Finset α} {i : α} (hi : i ∈ s) : reverseMarkedPartitionWeight s i = forwardMarkedPartitionWeight α := by have hs : (s.card : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (Finset.card_pos.mpr ⟨i, hi⟩)) simp only [reverseMarkedPartitionWeight, if_pos hi, reversePartitionWeight, forwardMarkedPartitionWeight] field_simp end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 800000 def rightSpectralBornWeight {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) (i : dB) : ℝ := bornTracePairing ρ.matrix F (positiveMatrixSpectralAtom G hG i) theorem rightSpectralBornWeight_nonneg {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) (i : dB) : 0 ≤ rightSpectralBornWeight ρ F G hG i := by exact trace_mul_posSemidef_nonneg ρ.positive (hF.kronecker (positiveMatrixSpectralAtom_posSemidef G hG i)) theorem rightSpectralBornWeight_sum {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) : (∑ i : dB, rightSpectralBornWeight ρ F G hG i) = bornTracePairing ρ.matrix F (1 : Matrix dB dB ℂ) := by unfold rightSpectralBornWeight calc (∑ i : dB, bornTracePairing ρ.matrix F (positiveMatrixSpectralAtom G hG i)) = bornTracePairing ρ.matrix F (∑ i : dB, positiveMatrixSpectralAtom G hG i) := by simp [map_sum] _ = bornTracePairing ρ.matrix F (1 : Matrix dB dB ℂ) := by rw [positiveMatrixSpectralAtom_sum] theorem rightSpectralBornWeight_moment {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) : (∑ i : dB, rightSpectralBornWeight ρ F G hG i * hG.isHermitian.eigenvalues i) = bornTracePairing ρ.matrix F G := by have hspectral : G = ∑ i : dB, hG.isHermitian.eigenvalues i • positiveMatrixSpectralAtom G hG i := by calc G = cfc (fun z : ℝ => z) G := (cfc_id' ℝ G hG.isHermitian).symm _ = _ := positiveMatrix_cfc_spectral_sum G hG (fun z : ℝ => z) have h := congrArg (bornTracePairing ρ.matrix F) hspectral simp only [map_sum, map_smul, smul_eq_mul] at h calc (∑ i : dB, rightSpectralBornWeight ρ F G hG i * hG.isHermitian.eigenvalues i) = ∑ i : dB, hG.isHermitian.eigenvalues i * bornTracePairing ρ.matrix F (positiveMatrixSpectralAtom G hG i) := by apply Finset.sum_congr rfl intro i _ unfold rightSpectralBornWeight ring _ = bornTracePairing ρ.matrix F G := h.symm theorem rightSpectralBornWeight_entropy {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) : bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) = ∑ i : dB, rightSpectralBornWeight ρ F G hG i * (hG.isHermitian.eigenvalues i * Real.log (hG.isHermitian.eigenvalues i)) := by have hspectral := positiveMatrix_cfc_spectral_sum G hG (fun z : ℝ => z * Real.log z) have h := congrArg (bornTracePairing ρ.matrix F) hspectral simp only [map_sum, map_smul, smul_eq_mul] at h calc bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) = ∑ i : dB, (hG.isHermitian.eigenvalues i * Real.log (hG.isHermitian.eigenvalues i)) * bornTracePairing ρ.matrix F (positiveMatrixSpectralAtom G hG i) := h _ = _ := by apply Finset.sum_congr rfl intro i _ unfold rightSpectralBornWeight ring theorem rightSpectralBornWeight_negEntropy {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) : -bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) = ∑ i : dB, rightSpectralBornWeight ρ F G hG i * Real.negMulLog (hG.isHermitian.eigenvalues i) := by rw [rightSpectralBornWeight_entropy ρ F G hG, ← Finset.sum_neg_distrib] apply Finset.sum_congr rfl intro i _ simp [Real.negMulLog] theorem bornTracePairing_le_one_one {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hFcomplement : (1 - F).PosSemidef) : bornTracePairing ρ.matrix F (1 : Matrix dB dB ℂ) ≤ 1 := by have hpositive : 0 ≤ bornTracePairing ρ.matrix (1 - F) (1 : Matrix dB dB ℂ) := trace_mul_posSemidef_nonneg ρ.positive (hFcomplement.kronecker Matrix.PosSemidef.one) have hdiff : bornTracePairing ρ.matrix (1 - F) (1 : Matrix dB dB ℂ) = bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) (1 : Matrix dB dB ℂ) - bornTracePairing ρ.matrix F (1 : Matrix dB dB ℂ) := by simp rw [hdiff, bornTracePairing_one_one] at hpositive linarith theorem matrixLogEntropy_born_lower_bound_right {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (hFcomplement : (1 - F).PosSemidef) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) (hGcomplement : (1 - G).PosSemidef) : -bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) ≤ Real.negMulLog (bornTracePairing ρ.matrix F G) := by classical have hp_nonneg : 0 ≤ bornTracePairing ρ.matrix F G := trace_mul_posSemidef_nonneg ρ.positive (hF.kronecker hG) have hmass_le : bornTracePairing ρ.matrix F G ≤ bornTracePairing ρ.matrix F (1 : Matrix dB dB ℂ) := by calc bornTracePairing ρ.matrix F G = ∑ i : dB, rightSpectralBornWeight ρ F G hG i * hG.isHermitian.eigenvalues i := (rightSpectralBornWeight_moment ρ F G hG).symm _ ≤ ∑ i : dB, rightSpectralBornWeight ρ F G hG i := by apply Finset.sum_le_sum intro i _ exact mul_le_of_le_one_right (rightSpectralBornWeight_nonneg ρ F hF G hG i) (positiveContraction_eigenvalue_le_one G hG hGcomplement i) _ = bornTracePairing ρ.matrix F (1 : Matrix dB dB ℂ) := rightSpectralBornWeight_sum ρ F G hG by_cases hp : bornTracePairing ρ.matrix F G = 0 · have hzero : (∑ i : dB, rightSpectralBornWeight ρ F G hG i * hG.isHermitian.eigenvalues i) = 0 := by rw [rightSpectralBornWeight_moment, hp] have hterm (i : dB) : rightSpectralBornWeight ρ F G hG i * hG.isHermitian.eigenvalues i = 0 := (Finset.sum_eq_zero_iff_of_nonneg (fun j _ => mul_nonneg (rightSpectralBornWeight_nonneg ρ F hF G hG j) (hG.eigenvalues_nonneg j))).mp hzero i (Finset.mem_univ i) have hentropy : (∑ i : dB, rightSpectralBornWeight ρ F G hG i * Real.negMulLog (hG.isHermitian.eigenvalues i)) = 0 := by apply Finset.sum_eq_zero intro i _ rcases mul_eq_zero.mp (hterm i) with hw | he · simp [hw] · simp [he] calc -bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) = ∑ i : dB, rightSpectralBornWeight ρ F G hG i * Real.negMulLog (hG.isHermitian.eigenvalues i) := rightSpectralBornWeight_negEntropy ρ F G hG _ = 0 := hentropy _ ≤ Real.negMulLog (bornTracePairing ρ.matrix F G) := by rw [hp] simp · have hp_pos : 0 < bornTracePairing ρ.matrix F G := lt_of_le_of_ne hp_nonneg (Ne.symm hp) have hW_pos : 0 < bornTracePairing ρ.matrix F (1 : Matrix dB dB ℂ) := lt_of_lt_of_le hp_pos hmass_le have hscalar := finite_weighted_entropy_le_of_weight_bound (Finset.univ : Finset dB) (rightSpectralBornWeight ρ F G hG) hG.isHermitian.eigenvalues (W := bornTracePairing ρ.matrix F (1 : Matrix dB dB ℂ)) (N := (1 : ℝ)) (p := bornTracePairing ρ.matrix F G) (fun i _ => rightSpectralBornWeight_nonneg ρ F hF G hG i) (fun i _ => hG.eigenvalues_nonneg i) hW_pos hp_pos (rightSpectralBornWeight_sum ρ F G hG) (rightSpectralBornWeight_moment ρ F G hG) (bornTracePairing_le_one_one ρ F hFcomplement) calc -bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) = ∑ i : dB, rightSpectralBornWeight ρ F G hG i * Real.negMulLog (hG.isHermitian.eigenvalues i) := rightSpectralBornWeight_negEntropy ρ F G hG _ ≤ bornTracePairing ρ.matrix F G * Real.log (1 / bornTracePairing ρ.matrix F G) := hscalar _ = Real.negMulLog (bornTracePairing ρ.matrix F G) := by rw [one_div, Real.log_inv] simp [Real.negMulLog] section HistoryNormalization variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def fullSubsetHistoryFieldEquiv {n : ℕ} (D L : Finset (Fin n)) : FullSubsetHistory X Y n D L ≃ (({i : Fin n // i ∈ D} → X × Y) × ({i : Fin n // i ∈ L} → X) × ({i : Fin n // i ∈ fullHistoryRemaining n D L} → Y)) where toFun h := (fun i => (h.aliceConditioned i, h.bobConditioned i), h.aliceRevealed, h.bobRemaining) invFun t := ⟨fun i => (t.1 i).1, fun i => (t.1 i).2, t.2.1, t.2.2⟩ left_inv h := by apply FullSubsetHistory.ext <;> rfl right_inv t := by rcases t with ⟨q, x, y⟩ simp theorem fullHistoryWeight_sum (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) : (∑ h : FullSubsetHistory X Y n D L, fullHistoryWeight G h) = 1 := by classical let Dsub := {i : Fin n // i ∈ D} let Lsub := {i : Fin n // i ∈ L} let Rsub := {i : Fin n // i ∈ fullHistoryRemaining n D L} have hD : (∑ q : Dsub → X × Y, ∏ i : Dsub, G.questionWeight (q i).1 (q i).2) = 1 := by calc (∑ q : Dsub → X × Y, ∏ i : Dsub, G.questionWeight (q i).1 (q i).2) = ∏ _i : Dsub, ∑ z : X × Y, G.questionWeight z.1 z.2 := by exact (Fintype.prod_sum (fun _i : Dsub => fun z : X × Y => G.questionWeight z.1 z.2)).symm _ = ∏ _i : Dsub, (1 : ℝ) := by apply Finset.prod_congr rfl intro i _ rw [Fintype.sum_prod_type] exact G.weight_normalized _ = 1 := by simp have hL : (∑ x : Lsub → X, ∏ i : Lsub, G.marginalX (x i)) = 1 := by calc (∑ x : Lsub → X, ∏ i : Lsub, G.marginalX (x i)) = ∏ _i : Lsub, ∑ z : X, G.marginalX z := by exact (Fintype.prod_sum (fun _i : Lsub => fun z : X => G.marginalX z)).symm _ = 1 := by simp [G.marginalX_normalized] have hR : (∑ y : Rsub → Y, ∏ i : Rsub, G.marginalY (y i)) = 1 := by calc (∑ y : Rsub → Y, ∏ i : Rsub, G.marginalY (y i)) = ∏ _i : Rsub, ∑ z : Y, G.marginalY z := by exact (Fintype.prod_sum (fun _i : Rsub => fun z : Y => G.marginalY z)).symm _ = 1 := by simp [G.marginalY_normalized] let f : (Dsub → X × Y) × (Lsub → X) × (Rsub → Y) → ℝ := fun t => (∏ i : Dsub, G.questionWeight (t.1 i).1 (t.1 i).2) * (∏ i : Lsub, G.marginalX (t.2.1 i)) * (∏ i : Rsub, G.marginalY (t.2.2 i)) calc (∑ h : FullSubsetHistory X Y n D L, fullHistoryWeight G h) = ∑ q : Dsub → X × Y, ∑ x : Lsub → X, ∑ y : Rsub → Y, (∏ i : Dsub, G.questionWeight (q i).1 (q i).2) * (∏ i : Lsub, G.marginalX (x i)) * (∏ i : Rsub, G.marginalY (y i)) := by simpa only [fullHistoryWeight, fullSubsetHistoryFieldEquiv, Equiv.coe_fn_mk, Fintype.sum_prod_type, f, Dsub, Lsub, Rsub] using (fullSubsetHistoryFieldEquiv (X := X) (Y := Y) D L).sum_comp f _ = (∑ q : Dsub → X × Y, ∏ i : Dsub, G.questionWeight (q i).1 (q i).2) * (∑ x : Lsub → X, ∏ i : Lsub, G.marginalX (x i)) * (∑ y : Rsub → Y, ∏ i : Rsub, G.marginalY (y i)) := by simp_rw [← Finset.mul_sum, ← Finset.sum_mul] congr 1 simp_rw [← Finset.mul_sum] rw [← Finset.sum_mul] _ = 1 := by rw [hD, hL, hR]; norm_num theorem fullHistoryWinIndicator_le_one (G : Game X Y A B) {n : ℕ} {D L : Finset (Fin n)} (h : FullSubsetHistory X Y n D L) (α : {i : Fin n // i ∈ D} → A) (β : {i : Fin n // i ∈ D} → B) : fullHistoryWinIndicator G h α β ≤ 1 := by classical unfold fullHistoryWinIndicator split <;> norm_num end HistoryNormalization end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 800000 variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def fullHistoryAnswerCount {A B : Type*} [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) : ℝ := (Fintype.card ({i : Fin n // i ∈ D} → A) : ℝ) * (Fintype.card ({i : Fin n // i ∈ D} → B) : ℝ) theorem fullHistoryAnswerCount_eq {A B : Type*} [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) : fullHistoryAnswerCount (A := A) (B := B) D = (Fintype.card A : ℝ) ^ D.card * (Fintype.card B : ℝ) ^ D.card := by classical simp [fullHistoryAnswerCount] abbrev FullHistoryEntropyAtom (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (n : ℕ) (D L : Finset (Fin n)) := FullSubsetHistory X Y n D L × ({i : Fin n // i ∈ D} → A) × ({i : Fin n // i ∈ D} → B) def fullHistoryAtomCountingWeight (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (t : FullHistoryEntropyAtom X Y A B n D L) : ℝ := fullHistoryWeight G t.1 * fullHistoryWinIndicator G t.1 t.2.1 t.2.2 def fullHistoryAtomBornMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (t : FullHistoryEntropyAtom X Y A B n D L) : ℝ := bornTracePairing S.state.matrix (fullHistoryAliceFilter G n S D L t.1 t.2.1) (fullHistoryBobFilter G n S D L t.1 t.2.2) theorem fullHistoryAtomCountingWeight_nonneg (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (t : FullHistoryEntropyAtom X Y A B n D L) : 0 ≤ fullHistoryAtomCountingWeight G D L t := by exact mul_nonneg (fullHistoryWeight_nonneg G t.1) (fullHistoryWinIndicator_nonneg G t.1 t.2.1 t.2.2) theorem fullHistoryAtomBornMass_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (t : FullHistoryEntropyAtom X Y A B n D L) : 0 ≤ fullHistoryAtomBornMass G n S D L t := by exact trace_mul_posSemidef_nonneg S.state.positive ((fullHistoryAliceFilter_posSemidef G n S D L t.1 t.2.1).kronecker (fullHistoryBobFilter_posSemidef G n S D L t.1 t.2.2)) theorem bornTracePairing_contractions_le_one {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hFcomplement : (1 - F).PosSemidef) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) (hGcomplement : (1 - G).PosSemidef) : bornTracePairing ρ.matrix F G ≤ 1 := by have hpositive : 0 ≤ bornTracePairing ρ.matrix (1 - F) G := trace_mul_posSemidef_nonneg ρ.positive (hFcomplement.kronecker hG) have hdiff : bornTracePairing ρ.matrix (1 - F) G = bornTracePairing ρ.matrix (1 : Matrix dA dA ℂ) G - bornTracePairing ρ.matrix F G := by simp rw [hdiff] at hpositive have hone := bornTracePairing_one_le_one ρ G hGcomplement linarith theorem fullHistoryAtomBornMass_le_one (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (t : FullHistoryEntropyAtom X Y A B n D L) : fullHistoryAtomBornMass G n S D L t ≤ 1 := by exact bornTracePairing_contractions_le_one S.state (fullHistoryAliceFilter G n S D L t.1 t.2.1) (fullHistoryAliceFilter_complement_posSemidef G n S D L t.1 t.2.1) (fullHistoryBobFilter G n S D L t.1 t.2.2) (fullHistoryBobFilter_posSemidef G n S D L t.1 t.2.2) (fullHistoryBobFilter_complement_posSemidef G n S D L t.1 t.2.2) theorem fullHistoryAtomCountingWeight_sum_le (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) : (∑ t : FullHistoryEntropyAtom X Y A B n D L, fullHistoryAtomCountingWeight G D L t) ≤ fullHistoryAnswerCount (A := A) (B := B) D := by classical calc (∑ t : FullHistoryEntropyAtom X Y A B n D L, fullHistoryAtomCountingWeight G D L t) = ∑ h : FullSubsetHistory X Y n D L, ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β := by simp [fullHistoryAtomCountingWeight, Fintype.sum_prod_type] _ ≤ ∑ h : FullSubsetHistory X Y n D L, ∑ _α : {i : Fin n // i ∈ D} → A, ∑ _β : {i : Fin n // i ∈ D} → B, fullHistoryWeight G h := by apply Finset.sum_le_sum intro h _ apply Finset.sum_le_sum intro α _ apply Finset.sum_le_sum intro β _ exact mul_le_of_le_one_right (fullHistoryWeight_nonneg G h) (fullHistoryWinIndicator_le_one G h α β) _ = fullHistoryAnswerCount (A := A) (B := B) D * (∑ h : FullSubsetHistory X Y n D L, fullHistoryWeight G h) := by simp [fullHistoryAnswerCount, Finset.mul_sum, mul_assoc] _ = fullHistoryAnswerCount (A := A) (B := B) D := by rw [fullHistoryWeight_sum G D L] ring theorem fullHistoryAtomBornMass_sum [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (hL : L ⊆ Finset.univ \ D) : (∑ t : FullHistoryEntropyAtom X Y A B n D L, fullHistoryAtomCountingWeight G D L t * fullHistoryAtomBornMass G n S D L t) = (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) := by classical simpa [fullHistoryAtomCountingWeight, fullHistoryAtomBornMass, Fintype.sum_prod_type] using fullSubsetHistory_mass_eq_postselection G n S D L hL theorem fullHistoryAtomEntropy_le [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (hL : L ⊆ Finset.univ \ D) (hp : 0 < (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) : (∑ t : FullHistoryEntropyAtom X Y A B n D L, fullHistoryAtomCountingWeight G D L t * Real.negMulLog (fullHistoryAtomBornMass G n S D L t)) ≤ (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) := by classical let p := (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) let w := fullHistoryAtomCountingWeight G D L let q := fullHistoryAtomBornMass G n S D L let W : ℝ := ∑ t : FullHistoryEntropyAtom X Y A B n D L, w t have hmass : (∑ t : FullHistoryEntropyAtom X Y A B n D L, w t * q t) = p := fullHistoryAtomBornMass_sum G n S D L hL have hpW : p ≤ W := by calc p = ∑ t : FullHistoryEntropyAtom X Y A B n D L, w t * q t := hmass.symm _ ≤ ∑ t : FullHistoryEntropyAtom X Y A B n D L, w t := by apply Finset.sum_le_sum intro t _ exact mul_le_of_le_one_right (fullHistoryAtomCountingWeight_nonneg G D L t) (fullHistoryAtomBornMass_le_one G n S D L t) _ = W := rfl have hW : 0 < W := lt_of_lt_of_le hp hpW have hbound : W ≤ fullHistoryAnswerCount (A := A) (B := B) D := fullHistoryAtomCountingWeight_sum_le G D L exact finite_weighted_entropy_le_of_weight_bound (Finset.univ : Finset (FullHistoryEntropyAtom X Y A B n D L)) w q (fun t _ => fullHistoryAtomCountingWeight_nonneg G D L t) (fun t _ => fullHistoryAtomBornMass_nonneg G n S D L t) hW hp rfl hmass hbound theorem fullHistoryAliceEntropyPotential_lower_bound [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (hL : L ⊆ Finset.univ \ D) (hp : 0 < (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) : -((strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D))) ≤ fullHistoryAliceEntropyPotential G n S D L := by classical have hpoint : -fullHistoryAliceEntropyPotential G n S D L ≤ ∑ t : FullHistoryEntropyAtom X Y A B n D L, fullHistoryAtomCountingWeight G D L t * Real.negMulLog (fullHistoryAtomBornMass G n S D L t) := by simp only [fullHistoryAliceEntropyPotential, fullHistoryAtomCountingWeight, fullHistoryAtomBornMass, Fintype.sum_prod_type, ← Finset.sum_neg_distrib] apply Finset.sum_le_sum intro h _ apply Finset.sum_le_sum intro α _ apply Finset.sum_le_sum intro β _ have hw := mul_nonneg (fullHistoryWeight_nonneg G h) (fullHistoryWinIndicator_nonneg G h α β) have hlocal := matrixLogEntropy_born_lower_bound_left S.state (fullHistoryAliceFilter G n S D L h α) (fullHistoryAliceFilter_posSemidef G n S D L h α) (fullHistoryAliceFilter_complement_posSemidef G n S D L h α) (fullHistoryBobFilter G n S D L h β) (fullHistoryBobFilter_posSemidef G n S D L h β) (fullHistoryBobFilter_complement_posSemidef G n S D L h β) nlinarith [mul_le_mul_of_nonneg_left hlocal hw] have hscalar := fullHistoryAtomEntropy_le G n S D L hL hp linarith end noncomputable section open scoped BigOperators @[ext (iff := false)] structure FullCoordinateRevealHistory (X Y : Type*) [Fintype X] [Fintype Y] (n : ℕ) (D L : Finset (Fin n)) (i : Fin n) where aliceConditioned : {j : Fin n // j ∈ D} → X bobConditioned : {j : Fin n // j ∈ D} → Y aliceRevealed : {j : Fin n // j ∈ L} → X bobRemaining : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → Y deriving Fintype theorem fullHistoryRemaining_insert_subset {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) : fullHistoryRemaining n D (insert i L) ⊆ fullHistoryRemaining n D L := by intro j hj simp only [fullHistoryRemaining, Finset.mem_sdiff, Finset.mem_univ, true_and, Finset.mem_insert] at hj ⊢ exact ⟨hj.1, fun h => hj.2 (Or.inr h)⟩ def fullCoordinateBaseOfOldHistory {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (h : FullSubsetHistory X Y n D L) : FullCoordinateRevealHistory X Y n D L i where aliceConditioned := h.aliceConditioned bobConditioned := h.bobConditioned aliceRevealed := h.aliceRevealed bobRemaining := fun j => h.bobRemaining ⟨j, fullHistoryRemaining_insert_subset D L i j.property⟩ def fullCoordinateOldHistory {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (h : FullCoordinateRevealHistory X Y n D L i) (y : Y) : FullSubsetHistory X Y n D L := by classical refine ⟨h.aliceConditioned, h.bobConditioned, h.aliceRevealed, fun j => if hj : (j : Fin n) = i then y else h.bobRemaining ⟨j, ?_⟩⟩ have hjD : (j : Fin n) ∉ D := (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp j.property).1).2 have hjL : (j : Fin n) ∉ L := (Finset.mem_sdiff.mp j.property).2 simp [fullHistoryRemaining, hjD, hjL, hj] def fullCoordinateBaseOfNewHistory {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (h : FullSubsetHistory X Y n D (insert i L)) : FullCoordinateRevealHistory X Y n D L i where aliceConditioned := h.aliceConditioned bobConditioned := h.bobConditioned aliceRevealed := fun j => h.aliceRevealed ⟨j, Finset.mem_insert_of_mem j.property⟩ bobRemaining := h.bobRemaining def fullCoordinateNewHistory {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (h : FullCoordinateRevealHistory X Y n D L i) (x : X) : FullSubsetHistory X Y n D (insert i L) := by classical refine ⟨h.aliceConditioned, h.bobConditioned, fun j => if hj : (j : Fin n) = i then x else h.aliceRevealed ⟨j, ?_⟩, h.bobRemaining⟩ exact (Finset.mem_insert.mp j.property).resolve_left hj def fullCoordinateOldHistoryEquiv {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) : FullSubsetHistory X Y n D L ≃ FullCoordinateRevealHistory X Y n D L i × Y where toFun h := (fullCoordinateBaseOfOldHistory D L i h, h.bobRemaining ⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩) invFun t := fullCoordinateOldHistory D L i t.1 t.2 left_inv h := by apply FullSubsetHistory.ext · rfl · rfl · rfl · funext j by_cases hj : (j : Fin n) = i · subst i simp [fullCoordinateOldHistory, fullCoordinateBaseOfOldHistory] · simp [fullCoordinateOldHistory, fullCoordinateBaseOfOldHistory, hj] right_inv t := by rcases t with ⟨h, y⟩ apply Prod.ext · apply FullCoordinateRevealHistory.ext · rfl · rfl · rfl · funext j have hj : (j : Fin n) ≠ i := by intro he have hnot : (j : Fin n) ∉ insert i L := (Finset.mem_sdiff.mp j.property).2 apply hnot simp [he] simp [fullCoordinateBaseOfOldHistory, fullCoordinateOldHistory, hj] · simp [fullCoordinateOldHistory] def fullCoordinateNewHistoryEquiv {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiL : i ∉ L) : FullSubsetHistory X Y n D (insert i L) ≃ FullCoordinateRevealHistory X Y n D L i × X where toFun h := (fullCoordinateBaseOfNewHistory D L i h, h.aliceRevealed ⟨i, Finset.mem_insert_self i L⟩) invFun t := fullCoordinateNewHistory D L i t.1 t.2 left_inv h := by apply FullSubsetHistory.ext · rfl · rfl · funext j by_cases hj : (j : Fin n) = i · have hjsub : j = (⟨i, Finset.mem_insert_self i L⟩ : {j : Fin n // j ∈ insert i L}) := Subtype.ext hj subst j simp [fullCoordinateNewHistory, fullCoordinateBaseOfNewHistory] · simp [fullCoordinateNewHistory, fullCoordinateBaseOfNewHistory, hj] · rfl right_inv t := by rcases t with ⟨h, x⟩ apply Prod.ext · apply FullCoordinateRevealHistory.ext · rfl · rfl · funext j have hj : (j : Fin n) ≠ i := by intro he exact hiL (he ▸ j.property) simp [fullCoordinateBaseOfNewHistory, fullCoordinateNewHistory, hj] · rfl · simp [fullCoordinateNewHistory] end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1000000 theorem finsetSubtype_prod_insert {ι T : Type*} [DecidableEq ι] [CommMonoid T] (s : Finset ι) (i : ι) (hi : i ∉ s) (f : {j : ι // j ∈ insert i s} → T) : (∏ j : {j : ι // j ∈ insert i s}, f j) = f ⟨i, Finset.mem_insert_self i s⟩ * ∏ j : {j : ι // j ∈ s}, f ⟨j, Finset.mem_insert_of_mem j.property⟩ := by classical let e := Finset.subtypeInsertEquivOption hi let g : Option {j : ι // j ∈ s} → T | none => f ⟨i, Finset.mem_insert_self i s⟩ | some j => f ⟨j, Finset.mem_insert_of_mem j.property⟩ have hcomp (j : {j : ι // j ∈ insert i s}) : g (e j) = f j := by rcases j with ⟨j, hj⟩ by_cases hji : j = i · subst j simp [e, g, Finset.subtypeInsertEquivOption] · simp [e, g, Finset.subtypeInsertEquivOption, hji] calc (∏ j : {j : ι // j ∈ insert i s}, f j) = ∏ j : {j : ι // j ∈ insert i s}, g (e j) := by apply Finset.prod_congr rfl intro j _ exact (hcomp j).symm _ = ∏ j : Option {j : ι // j ∈ s}, g j := e.prod_comp g _ = g none * ∏ j : {j : ι // j ∈ s}, g (some j) := Fintype.prod_option g _ = _ := rfl def fullHistoryRemainingCoordinateEquiv {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) : {j : Fin n // j ∈ fullHistoryRemaining n D L} ≃ Option {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} where toFun j := if hj : (j : Fin n) = i then none else some ⟨j, by have hjD : (j : Fin n) ∉ D := (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp j.property).1).2 have hjL : (j : Fin n) ∉ L := (Finset.mem_sdiff.mp j.property).2 simp [fullHistoryRemaining, hjD, hjL, hj]⟩ invFun | none => ⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩ | some j => ⟨j, fullHistoryRemaining_insert_subset D L i j.property⟩ left_inv j := by apply Subtype.ext by_cases hj : (j : Fin n) = i · simp [hj] · simp [hj] right_inv j := by cases j with | none => simp | some j => have hj : (j : Fin n) ≠ i := by intro he have hnot : (j : Fin n) ∉ insert i L := (Finset.mem_sdiff.mp j.property).2 apply hnot simp [he] simp [hj] theorem fullHistoryRemaining_prod_split {n : ℕ} {T : Type*} [CommMonoid T] (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (f : {j : Fin n // j ∈ fullHistoryRemaining n D L} → T) : (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D L}, f j) = f ⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩ * ∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)}, f ⟨j, fullHistoryRemaining_insert_subset D L i j.property⟩ := by classical let e := fullHistoryRemainingCoordinateEquiv D L i hiD hiL let g : Option {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → T | none => f ⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩ | some j => f ⟨j, fullHistoryRemaining_insert_subset D L i j.property⟩ have hcomp (j : {j : Fin n // j ∈ fullHistoryRemaining n D L}) : g (e j) = f j := by by_cases hj : (j : Fin n) = i · have hjsub : j = (⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩ : {j : Fin n // j ∈ fullHistoryRemaining n D L}) := Subtype.ext hj subst j simp [e, g, fullHistoryRemainingCoordinateEquiv] · simp [e, g, fullHistoryRemainingCoordinateEquiv, hj] calc (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D L}, f j) = ∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D L}, g (e j) := by apply Finset.prod_congr rfl intro j _ exact (hcomp j).symm _ = ∏ j : Option {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)}, g j := e.prod_comp g _ = g none * ∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)}, g (some j) := Fintype.prod_option g _ = _ := rfl section CoordinateWeights variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def fullCoordinateBaseWeight (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (h : FullCoordinateRevealHistory X Y n D L i) : ℝ := (∏ j : {j : Fin n // j ∈ D}, G.questionWeight (h.aliceConditioned j) (h.bobConditioned j)) * (∏ j : {j : Fin n // j ∈ L}, G.marginalX (h.aliceRevealed j)) * (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)}, G.marginalY (h.bobRemaining j)) theorem fullCoordinateBaseWeight_nonneg (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (h : FullCoordinateRevealHistory X Y n D L i) : 0 ≤ fullCoordinateBaseWeight G D L i h := by unfold fullCoordinateBaseWeight exact mul_nonneg (mul_nonneg (Finset.prod_nonneg fun j _ => G.weight_nonneg (h.aliceConditioned j) (h.bobConditioned j)) (Finset.prod_nonneg fun j _ => G.marginalX_nonneg (h.aliceRevealed j))) (Finset.prod_nonneg fun j _ => G.marginalY_nonneg (h.bobRemaining j)) theorem fullCoordinateOldHistory_weight (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (h : FullCoordinateRevealHistory X Y n D L i) (y : Y) : fullHistoryWeight G (fullCoordinateOldHistory D L i h y) = fullCoordinateBaseWeight G D L i h * G.marginalY y := by classical have hold (j : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)}) : (fullCoordinateOldHistory D L i h y).bobRemaining ⟨j, fullHistoryRemaining_insert_subset D L i j.property⟩ = h.bobRemaining j := by have hj : (j : Fin n) ≠ i := by intro he have hnot : (j : Fin n) ∉ insert i L := (Finset.mem_sdiff.mp j.property).2 apply hnot simp [he] simp [fullCoordinateOldHistory, hj] unfold fullHistoryWeight fullCoordinateBaseWeight change (∏ j : {j : Fin n // j ∈ D}, G.questionWeight (h.aliceConditioned j) (h.bobConditioned j)) * (∏ j : {j : Fin n // j ∈ L}, G.marginalX (h.aliceRevealed j)) * (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D L}, G.marginalY ((fullCoordinateOldHistory D L i h y).bobRemaining j)) = _ rw [fullHistoryRemaining_prod_split D L i hiD hiL] simp_rw [hold] simp [fullCoordinateOldHistory] ring theorem fullCoordinateNewHistory_weight (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiL : i ∉ L) (h : FullCoordinateRevealHistory X Y n D L i) (x : X) : fullHistoryWeight G (fullCoordinateNewHistory D L i h x) = fullCoordinateBaseWeight G D L i h * G.marginalX x := by classical have hnew (j : {j : Fin n // j ∈ L}) : (fullCoordinateNewHistory D L i h x).aliceRevealed ⟨j, Finset.mem_insert_of_mem j.property⟩ = h.aliceRevealed j := by have hj : (j : Fin n) ≠ i := by intro he exact hiL (he ▸ j.property) simp [fullCoordinateNewHistory, hj] unfold fullHistoryWeight fullCoordinateBaseWeight change (∏ j : {j : Fin n // j ∈ D}, G.questionWeight (h.aliceConditioned j) (h.bobConditioned j)) * (∏ j : {j : Fin n // j ∈ insert i L}, G.marginalX ((fullCoordinateNewHistory D L i h x).aliceRevealed j)) * (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)}, G.marginalY (h.bobRemaining j)) = _ rw [finsetSubtype_prod_insert L i hiL] simp_rw [hnew] simp [fullCoordinateNewHistory] ring end CoordinateWeights end noncomputable section open MeasureTheory Filter Set open scoped BigOperators Topology ComplexOrder MatrixOrder Matrix.Norms.Elementwise InnerProductSpace set_option backward.isDefEq.respectTransparency false attribute [local instance] Matrix.normedAddCommGroup Matrix.normedSpace theorem finitePurificationMatrix_pair_difference_gram_apply {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a b : ι) (i j : d) : ((finitePurificationMatrix F M positive hM a - finitePurificationMatrix F M positive hM b).conjTranspose * (finitePurificationMatrix F M positive hM a - finitePurificationMatrix F M positive hM b)) i j = ∑ r : d, inner ℂ (ensemblePurificationSubspaceEntry F M positive hM a r i - ensemblePurificationSubspaceEntry F M positive hM b r i) (ensemblePurificationSubspaceEntry F M positive hM a r j - ensemblePurificationSubspaceEntry F M positive hM b r j) := by classical simp only [Matrix.mul_apply, Matrix.conjTranspose_apply, Matrix.sub_apply, finitePurificationMatrix, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro r _ let basis := commonPurificationOrthonormalBasis F M positive hM let u := ensemblePurificationSubspaceEntry F M positive hM a r i let u₀ := ensemblePurificationSubspaceEntry F M positive hM b r i let v := ensemblePurificationSubspaceEntry F M positive hM a r j let v₀ := ensemblePurificationSubspaceEntry F M positive hM b r j have hisometry := basis.repr.inner_map_map (u - u₀) (v - v₀) change (∑ k, star (basis.repr u k - basis.repr u₀ k) * (basis.repr v k - basis.repr v₀ k)) = inner ℂ (u - u₀) (v - v₀) rw [← hisometry, EuclideanSpace.inner_eq_star_dotProduct] simp [dotProduct, map_sub, mul_comm] theorem ensemblePurificationSubspaceEntry_pair_difference_inner_eq_integral {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a b : ι) (r i j : d) : inner ℂ (ensemblePurificationSubspaceEntry F M positive hM a r i - ensemblePurificationSubspaceEntry F M positive hM b r i) (ensemblePurificationSubspaceEntry F M positive hM a r j - ensemblePurificationSubspaceEntry F M positive hM b r j) = ∫ s in Ioi (0 : ℝ), star (spectralPurificationFilter (F a) (positive a) s r i - spectralPurificationFilter (F b) (positive b) s r i) * (spectralPurificationFilter (F a) (positive a) s r j - spectralPurificationFilter (F b) (positive b) s r j) := by rw [Submodule.coe_inner, MeasureTheory.L2.inner_def] apply integral_congr_ae let fi := spectralPurificationFilterEntryLp (F a) (positive a) r i let gi := spectralPurificationFilterEntryLp (F b) (positive b) r i let fj := spectralPurificationFilterEntryLp (F a) (positive a) r j let gj := spectralPurificationFilterEntryLp (F b) (positive b) r j have hsubi := Lp.coeFn_sub fi gi have hsubj := Lp.coeFn_sub fj gj have hfi := spectralPurificationFilterEntryLp_coeFn (F a) (positive a) r i have hgi := spectralPurificationFilterEntryLp_coeFn (F b) (positive b) r i have hfj := spectralPurificationFilterEntryLp_coeFn (F a) (positive a) r j have hgj := spectralPurificationFilterEntryLp_coeFn (F b) (positive b) r j filter_upwards [hsubi, hsubj, hfi, hgi, hfj, hgj] with s hi hj hfi' hgi' hfj' hgj' change inner ℂ ((fi - gi) s) ((fj - gj) s) = _ rw [hi, hj] change inner ℂ (fi s - gi s) (fj s - gj s) = _ change inner ℂ ((spectralPurificationFilterEntryLp (F a) (positive a) r i : ℝ → ℂ) s - (spectralPurificationFilterEntryLp (F b) (positive b) r i : ℝ → ℂ) s) ((spectralPurificationFilterEntryLp (F a) (positive a) r j : ℝ → ℂ) s - (spectralPurificationFilterEntryLp (F b) (positive b) r j : ℝ → ℂ) s) = _ rw [hfi', hgi', hfj', hgj'] simp [RCLike.inner_apply, mul_comm] theorem finitePurificationMatrix_pair_difference_gram_eq_integral {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (positive : ∀ i, (F i).PosSemidef) (hM : M.PosSemidef) (a b : ι) : (finitePurificationMatrix F M positive hM a - finitePurificationMatrix F M positive hM b).conjTranspose * (finitePurificationMatrix F M positive hM a - finitePurificationMatrix F M positive hM b) = ∫ s in Ioi (0 : ℝ), star (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter (F b) (positive b) s) * (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter (F b) (positive b) s) := by classical have hdelta : MemLp (fun s : ℝ => spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter (F b) (positive b) s) 2 (volume.restrict (Ioi 0)) := (spectralPurificationFilter_memLp_two (F a) (positive a)).sub (spectralPurificationFilter_memLp_two (F b) (positive b)) have hmatrix := spectralPurificationFilter_difference_gram_integrable (F a) (F b) (positive a) (positive b) have hrows : ∀ i : d, Integrable (fun s : ℝ => (star (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter (F b) (positive b) s) * (spectralPurificationFilter (F a) (positive a) s - spectralPurificationFilter (F b) (positive b) s)) i) (volume.restrict (Ioi 0)) := fun i => hmatrix.eval i ext i j rw [finitePurificationMatrix_pair_difference_gram_apply] rw [MeasureTheory.eval_integral hrows i, MeasureTheory.eval_integral (fun k => (hrows i).eval k) j] simp_rw [ensemblePurificationSubspaceEntry_pair_difference_inner_eq_integral] have hproduct (r : d) : Integrable (fun s : ℝ => star (spectralPurificationFilter (F a) (positive a) s r i - spectralPurificationFilter (F b) (positive b) s r i) * (spectralPurificationFilter (F a) (positive a) s r j - spectralPurificationFilter (F b) (positive b) s r j)) (volume.restrict (Ioi 0)) := (((hdelta.eval r).eval i).star).integrable_mul ((hdelta.eval r).eval j) rw [← integral_finsetSum Finset.univ (fun r _ => hproduct r)] apply integral_congr_ae filter_upwards with s simp [Matrix.mul_apply, Matrix.star_apply] end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem finiteLocalPurificationVector_sub_left {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (KA KA' : Matrix eA S.Alice ℂ) (KB : Matrix eB S.Bob ℂ) : finiteLocalPurificationVector S KA KB - finiteLocalPurificationVector S KA' KB = finiteLocalPurificationVector S (KA - KA') KB := by have hmatrix : finiteLocalPurificationJointMatrix S KA KB - finiteLocalPurificationJointMatrix S KA' KB = finiteLocalPurificationJointMatrix S (KA - KA') KB := by ext ⟨⟨a, k⟩, b⟩ ⟨⟨a', k'⟩, b'⟩ simp [finiteLocalPurificationJointMatrix, Matrix.kroneckerMap_apply, sub_mul] unfold finiteLocalPurificationVector rw [← WithLp.toLp_sub, ← Matrix.sub_mulVec, hmatrix] theorem finiteLocalPurificationVector_sub_right {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (KA : Matrix eA S.Alice ℂ) (KB KB' : Matrix eB S.Bob ℂ) : finiteLocalPurificationVector S KA KB - finiteLocalPurificationVector S KA KB' = finiteLocalPurificationVector S KA (KB - KB') := by have hmatrix : finiteLocalPurificationJointMatrix S KA KB - finiteLocalPurificationJointMatrix S KA KB' = finiteLocalPurificationJointMatrix S KA (KB - KB') := by ext ⟨⟨a, k⟩, b⟩ ⟨⟨a', k'⟩, b'⟩ simp [finiteLocalPurificationJointMatrix, Matrix.kroneckerMap_apply, mul_sub] unfold finiteLocalPurificationVector rw [← WithLp.toLp_sub, ← Matrix.sub_mulVec, hmatrix] theorem finiteLocalPurificationVector_sub_left_norm_sq {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (KA KA' : Matrix eA S.Alice ℂ) (KB : Matrix eB S.Bob ℂ) : ‖finiteLocalPurificationVector S KA KB - finiteLocalPurificationVector S KA' KB‖ ^ 2 = bornTracePairing S.state.matrix ((KA - KA').conjTranspose * (KA - KA')) (KB.conjTranspose * KB) := by rw [finiteLocalPurificationVector_sub_left, finiteLocalPurificationVector_norm_sq] rfl theorem finiteLocalPurificationVector_sub_right_norm_sq {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (KA : Matrix eA S.Alice ℂ) (KB KB' : Matrix eB S.Bob ℂ) : ‖finiteLocalPurificationVector S KA KB - finiteLocalPurificationVector S KA KB'‖ ^ 2 = bornTracePairing S.state.matrix (KA.conjTranspose * KA) ((KB - KB').conjTranspose * (KB - KB')) := by rw [finiteLocalPurificationVector_sub_right, finiteLocalPurificationVector_norm_sq] rfl end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def fullCoordinateAliceQuestionFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (x : X) : Matrix S.Alice S.Alice ℂ := fullHistoryAliceFilter G n S D (insert i L) (fullCoordinateNewHistory D L i r x) α def fullCoordinateAliceMeanFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (y : Y) : Matrix S.Alice S.Alice ℂ := fullHistoryAliceFilter G n S D L (fullCoordinateOldHistory D L i r y) α def fullCoordinateBobQuestionFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (β : {j : Fin n // j ∈ D} → B) (y : Y) : Matrix S.Bob S.Bob ℂ := fullHistoryBobFilter G n S D L (fullCoordinateOldHistory D L i r y) β def fullCoordinateBobMeanFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (β : {j : Fin n // j ∈ D} → B) (x : X) : Matrix S.Bob S.Bob ℂ := fullHistoryBobFilter G n S D (insert i L) (fullCoordinateNewHistory D L i r x) β end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1200000 def fullCoordinateAssembleHiddenAlice {X : Type*} {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (x : X) (hidden : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X) : {j : Fin n // j ∈ fullHistoryRemaining n D L} → X := by classical intro j by_cases hj : (j : Fin n) = i · exact x · exact hidden ⟨j, by have hjD : (j : Fin n) ∉ D := (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp j.property).1).2 have hjL : (j : Fin n) ∉ L := (Finset.mem_sdiff.mp j.property).2 simp [fullHistoryRemaining, hjD, hjL, hj]⟩ def fullCoordinateHiddenAliceEquiv {X : Type*} [Fintype X] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) : ({j : Fin n // j ∈ fullHistoryRemaining n D L} → X) ≃ X × ({j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X) where toFun hidden := (hidden ⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩, fun j => hidden ⟨j, fullHistoryRemaining_insert_subset D L i j.property⟩) invFun t := fullCoordinateAssembleHiddenAlice D L i t.1 t.2 left_inv hidden := by funext j by_cases hj : (j : Fin n) = i · have hjsub : j = (⟨i, by simp [fullHistoryRemaining, hiD, hiL]⟩ : {j : Fin n // j ∈ fullHistoryRemaining n D L}) := Subtype.ext hj subst j simp [fullCoordinateAssembleHiddenAlice] · simp [fullCoordinateAssembleHiddenAlice, hj] right_inv t := by rcases t with ⟨x, hidden⟩ apply Prod.ext · simp [fullCoordinateAssembleHiddenAlice] · funext j have hj : (j : Fin n) ≠ i := by intro he have hnot : (j : Fin n) ∉ insert i L := (Finset.mem_sdiff.mp j.property).2 apply hnot simp [he] simp [fullCoordinateAssembleHiddenAlice, hj] def fullCoordinateAssembleHiddenBob {Y : Type*} {n : ℕ} (L : Finset (Fin n)) (i : Fin n) (y : Y) (hidden : {j : Fin n // j ∈ L} → Y) : {j : Fin n // j ∈ insert i L} → Y := by classical intro j by_cases hj : (j : Fin n) = i · exact y · exact hidden ⟨j, (Finset.mem_insert.mp j.property).resolve_left hj⟩ def fullCoordinateHiddenBobEquiv {Y : Type*} [Fintype Y] {n : ℕ} (L : Finset (Fin n)) (i : Fin n) (hiL : i ∉ L) : ({j : Fin n // j ∈ insert i L} → Y) ≃ Y × ({j : Fin n // j ∈ L} → Y) where toFun hidden := (hidden ⟨i, Finset.mem_insert_self i L⟩, fun j => hidden ⟨j, Finset.mem_insert_of_mem j.property⟩) invFun t := fullCoordinateAssembleHiddenBob L i t.1 t.2 left_inv hidden := by funext j by_cases hj : (j : Fin n) = i · have hjsub : j = (⟨i, Finset.mem_insert_self i L⟩ : {j : Fin n // j ∈ insert i L}) := Subtype.ext hj subst j simp [fullCoordinateAssembleHiddenBob] · simp [fullCoordinateAssembleHiddenBob, hj] right_inv t := by rcases t with ⟨y, hidden⟩ apply Prod.ext · simp [fullCoordinateAssembleHiddenBob] · funext j have hj : (j : Fin n) ≠ i := by intro he exact hiL (he ▸ j.property) simp [fullCoordinateAssembleHiddenBob, hj] section CoordinateFilters variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem fullCoordinateAliceQuestion_eq {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (hidden : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X) : fullHistoryAliceQuestion (fullCoordinateOldHistory D L i r y) (fullCoordinateAssembleHiddenAlice D L i x hidden) = fullHistoryAliceQuestion (fullCoordinateNewHistory D L i r x) hidden := by classical funext j by_cases hjD : j ∈ D · simp [fullHistoryAliceQuestion, fullCoordinateOldHistory, fullCoordinateNewHistory, hjD] · by_cases hjL : j ∈ L · have hji : j ≠ i := by intro he exact hiL (he ▸ hjL) simp [fullHistoryAliceQuestion, fullCoordinateOldHistory, fullCoordinateNewHistory, hjD, hjL, hji] · by_cases hji : j = i · subst j simp [fullHistoryAliceQuestion, fullCoordinateAssembleHiddenAlice, fullCoordinateNewHistory, hiD, hiL] · simp [fullHistoryAliceQuestion, fullCoordinateAssembleHiddenAlice, hjD, hjL, hji] theorem fullCoordinateBobQuestion_eq {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (hidden : {j : Fin n // j ∈ L} → Y) : fullHistoryBobQuestion (fullCoordinateNewHistory D L i r x) (fullCoordinateAssembleHiddenBob L i y hidden) = fullHistoryBobQuestion (fullCoordinateOldHistory D L i r y) hidden := by classical funext j by_cases hjD : j ∈ D · simp [fullHistoryBobQuestion, fullCoordinateOldHistory, fullCoordinateNewHistory, hjD] · by_cases hjL : j ∈ L · have hji : j ≠ i := by intro he exact hiL (he ▸ hjL) simp [fullHistoryBobQuestion, fullCoordinateAssembleHiddenBob, hjD, hjL, hji] · by_cases hji : j = i · subst j simp [fullHistoryBobQuestion, fullCoordinateAssembleHiddenBob, fullCoordinateOldHistory, hiD, hiL] · simp [fullHistoryBobQuestion, fullCoordinateOldHistory, fullCoordinateNewHistory, hjD, hjL, hji] theorem fullCoordinateHiddenAliceWeight_split (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (hidden : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X) : fullHistoryHiddenAliceWeight G (fullCoordinateOldHistory D L i r y) (fullCoordinateAssembleHiddenAlice D L i x hidden) = G.conditionalXGivenY y x * fullHistoryHiddenAliceWeight G (fullCoordinateNewHistory D L i r x) hidden := by classical unfold fullHistoryHiddenAliceWeight rw [fullHistoryRemaining_prod_split D L i hiD hiL] simp only [fullCoordinateOldHistory, fullCoordinateAssembleHiddenAlice, dite_true] congr 1 apply Finset.prod_congr rfl intro j _ have hj : (j : Fin n) ≠ i := by intro he have hnot : (j : Fin n) ∉ insert i L := (Finset.mem_sdiff.mp j.property).2 apply hnot simp [he] simp [fullCoordinateNewHistory, hj] theorem fullCoordinateHiddenBobWeight_split (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (hidden : {j : Fin n // j ∈ L} → Y) : fullHistoryHiddenBobWeight G (fullCoordinateNewHistory D L i r x) (fullCoordinateAssembleHiddenBob L i y hidden) = G.conditionalYGivenX x y * fullHistoryHiddenBobWeight G (fullCoordinateOldHistory D L i r y) hidden := by classical unfold fullHistoryHiddenBobWeight rw [finsetSubtype_prod_insert L i hiL] simp only [fullCoordinateNewHistory, fullCoordinateAssembleHiddenBob, dite_true] congr 1 apply Finset.prod_congr rfl intro j _ have hj : (j : Fin n) ≠ i := by intro he exact hiL (he ▸ j.property) simp [fullCoordinateOldHistory, hj] theorem fullCoordinateAliceFilter_conditional_mean (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (y : Y) : fullCoordinateAliceMeanFilter G n S D L i r α y = conditionalAliceAverage G (fullCoordinateAliceQuestionFilter G n S D L i r α) y := by classical let e := fullCoordinateHiddenAliceEquiv (X := X) D L i hiD hiL let f : X × ({j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X) → Matrix S.Alice S.Alice ℂ := fun t => (G.conditionalXGivenY y t.1 * fullHistoryHiddenAliceWeight G (fullCoordinateNewHistory D L i r t.1) t.2) • conditionedAliceEffect G n S D α (fullHistoryAliceQuestion (fullCoordinateNewHistory D L i r t.1) t.2) unfold fullCoordinateAliceMeanFilter fullCoordinateAliceQuestionFilter calc fullHistoryAliceFilter G n S D L (fullCoordinateOldHistory D L i r y) α = ∑ hidden : ({j : Fin n // j ∈ fullHistoryRemaining n D L} → X), f (e hidden) := by unfold fullHistoryAliceFilter apply Finset.sum_congr rfl intro hidden _ have he := e.symm_apply_apply hidden change fullCoordinateAssembleHiddenAlice D L i (e hidden).1 (e hidden).2 = hidden at he conv_lhs => rw [← he] rw [fullCoordinateHiddenAliceWeight_split G D L i hiD hiL r (e hidden).1 y (e hidden).2] rw [fullCoordinateAliceQuestion_eq D L i hiD hiL r (e hidden).1 y (e hidden).2] _ = ∑ t : X × ({j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X), f t := e.sum_comp f _ = conditionalAliceAverage G (fun x => fullHistoryAliceFilter G n S D (insert i L) (fullCoordinateNewHistory D L i r x) α) y := by simp [f, conditionalAliceAverage, fullHistoryAliceFilter, Fintype.sum_prod_type, Finset.smul_sum, smul_smul] theorem fullCoordinateBobFilter_conditional_mean (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (β : {j : Fin n // j ∈ D} → B) (x : X) : fullCoordinateBobMeanFilter G n S D L i r β x = conditionalBobAverage G (fullCoordinateBobQuestionFilter G n S D L i r β) x := by classical let e := fullCoordinateHiddenBobEquiv (Y := Y) L i hiL let f : Y × ({j : Fin n // j ∈ L} → Y) → Matrix S.Bob S.Bob ℂ := fun t => (G.conditionalYGivenX x t.1 * fullHistoryHiddenBobWeight G (fullCoordinateOldHistory D L i r t.1) t.2) • conditionedBobEffect G n S D β (fullHistoryBobQuestion (fullCoordinateOldHistory D L i r t.1) t.2) unfold fullCoordinateBobMeanFilter fullCoordinateBobQuestionFilter calc fullHistoryBobFilter G n S D (insert i L) (fullCoordinateNewHistory D L i r x) β = ∑ hidden : ({j : Fin n // j ∈ insert i L} → Y), f (e hidden) := by unfold fullHistoryBobFilter apply Finset.sum_congr rfl intro hidden _ have he := e.symm_apply_apply hidden change fullCoordinateAssembleHiddenBob L i (e hidden).1 (e hidden).2 = hidden at he conv_lhs => rw [← he] rw [fullCoordinateHiddenBobWeight_split G D L i hiL r x (e hidden).1 (e hidden).2] rw [fullCoordinateBobQuestion_eq D L i hiD hiL r x (e hidden).1 (e hidden).2] _ = ∑ t : Y × ({j : Fin n // j ∈ L} → Y), f t := e.sum_comp f _ = conditionalBobAverage G (fun y => fullHistoryBobFilter G n S D L (fullCoordinateOldHistory D L i r y) β) x := by simp [f, conditionalBobAverage, fullHistoryBobFilter, Fintype.sum_prod_type, Finset.smul_sum, smul_smul] end CoordinateFilters theorem matrixLogEntropy_weighted_jensen_posSemidef {ι d : Type*} [Fintype ι] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : ι → Matrix d d ℂ) (M : Matrix d d ℂ) (nonnegative : ∀ i, 0 ≤ weight i) (normalized : (∑ i : ι, weight i) = 1) (mean : (∑ i : ι, weight i • F i) = M) (positive : ∀ i, (F i).PosSemidef) : ((∑ i : ι, weight i • cfc (fun z : ℝ => z * Real.log z) (F i)) - cfc (fun z : ℝ => z * Real.log z) M).PosSemidef := by classical let hM : M.PosSemidef := by rw [← mean] exact weighted_positive_matrix_mean weight F nonnegative positive have hgap := finite_purification_log_entropy_jensen weight F M nonnegative normalized mean positive change ((∑ i : ι, weight i • cfc (fun z : ℝ => z * Real.log z) (F i)) - cfc (fun z : ℝ => z * Real.log z) M - (∑ i : ι, weight i • ((finitePurificationMatrix F M positive hM i - meanFinitePurificationMatrix F M positive hM).conjTranspose * (finitePurificationMatrix F M positive hM i - meanFinitePurificationMatrix F M positive hM)))).PosSemidef at hgap have hvariance : (∑ i : ι, weight i • ((finitePurificationMatrix F M positive hM i - meanFinitePurificationMatrix F M positive hM).conjTranspose * (finitePurificationMatrix F M positive hM i - meanFinitePurificationMatrix F M positive hM))).PosSemidef := by apply Matrix.posSemidef_sum Finset.univ intro i _ exact (Matrix.posSemidef_conjTranspose_mul_self (finitePurificationMatrix F M positive hM i - meanFinitePurificationMatrix F M positive hM)).smul (nonnegative i) convert hgap.add hvariance using 1 ; module section ConditionalJensen variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem conditionalAlice_matrixLogEntropy_gap_posSemidef {d : Type*} [Fintype d] [DecidableEq d] (G : Game X Y A B) (H : X → Matrix d d ℂ) (hH : ∀ x, (H x).PosSemidef) (y : Y) (hy : 0 < G.marginalY y) : (conditionalAliceAverage G (fun x => cfc (fun z : ℝ => z * Real.log z) (H x)) y - cfc (fun z : ℝ => z * Real.log z) (conditionalAliceAverage G H y)).PosSemidef := by exact matrixLogEntropy_weighted_jensen_posSemidef (G.conditionalXGivenY y) H (conditionalAliceAverage G H y) (fun x => G.conditionalXGivenY_nonneg y x) (G.conditionalXGivenY_sum y hy) rfl hH def fullCoordinateAliceEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (β : {j : Fin n // j ∈ D} → B) : ℝ := ∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (conditionalAliceAverage G (fun x => cfc (fun z : ℝ => z * Real.log z) (fullCoordinateAliceQuestionFilter G n S D L i r α x)) y - cfc (fun z : ℝ => z * Real.log z) (fullCoordinateAliceMeanFilter G n S D L i r α y)) (fullCoordinateBobQuestionFilter G n S D L i r β y) theorem fullCoordinateAliceEntropyIncrement_eq (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (β : {j : Fin n // j ∈ D} → B) : (∑ x : X, G.marginalX x * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (fullCoordinateAliceQuestionFilter G n S D L i r α x)) (fullCoordinateBobMeanFilter G n S D L i r β x)) - (∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (fullCoordinateAliceMeanFilter G n S D L i r α y)) (fullCoordinateBobQuestionFilter G n S D L i r β y)) = fullCoordinateAliceEntropyIncrement G n S D L i r α β := by have h := alice_reveal_increment G (bornTracePairing S.state.matrix) (fullCoordinateAliceQuestionFilter G n S D L i r α) (fullCoordinateAliceMeanFilter G n S D L i r α) (fullCoordinateBobQuestionFilter G n S D L i r β) (fun F => cfc (fun z : ℝ => z * Real.log z) F) simp_rw [← fullCoordinateBobFilter_conditional_mean G n S D L i hiD hiL r β] at h exact h theorem fullCoordinateAliceEntropyIncrement_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (β : {j : Fin n // j ∈ D} → B) : 0 ≤ fullCoordinateAliceEntropyIncrement G n S D L i r α β := by unfold fullCoordinateAliceEntropyIncrement apply Finset.sum_nonneg intro y _ by_cases hy : G.marginalY y = 0 · simp [hy] · have hypos : 0 < G.marginalY y := lt_of_le_of_ne (G.marginalY_nonneg y) (Ne.symm hy) have hmean := fullCoordinateAliceFilter_conditional_mean G n S D L i hiD hiL r α y have hgap : (conditionalAliceAverage G (fun x => cfc (fun z : ℝ => z * Real.log z) (fullCoordinateAliceQuestionFilter G n S D L i r α x)) y - cfc (fun z : ℝ => z * Real.log z) (fullCoordinateAliceMeanFilter G n S D L i r α y)).PosSemidef := by rw [hmean] exact conditionalAlice_matrixLogEntropy_gap_posSemidef G (fullCoordinateAliceQuestionFilter G n S D L i r α) (fun x => fullHistoryAliceFilter_posSemidef G n S D (insert i L) (fullCoordinateNewHistory D L i r x) α) y hypos exact mul_nonneg (G.marginalY_nonneg y) (trace_mul_posSemidef_nonneg S.state.positive (hgap.kronecker (fullHistoryBobFilter_posSemidef G n S D L (fullCoordinateOldHistory D L i r y) β))) end ConditionalJensen end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1500000 variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def fullCoordinateBaseWinIndicator (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (β : {j : Fin n // j ∈ D} → B) : ℝ := by classical exact if ∀ j : {j : Fin n // j ∈ D}, G.predicate (r.aliceConditioned j) (r.bobConditioned j) (α j) (β j) = true then 1 else 0 theorem fullCoordinateBaseWinIndicator_nonneg (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (β : {j : Fin n // j ∈ D} → B) : 0 ≤ fullCoordinateBaseWinIndicator G D L i r α β := by classical unfold fullCoordinateBaseWinIndicator split <;> norm_num theorem fullCoordinateOldHistory_winIndicator_eq (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (y : Y) (α : {j : Fin n // j ∈ D} → A) (β : {j : Fin n // j ∈ D} → B) : fullHistoryWinIndicator G (fullCoordinateOldHistory D L i r y) α β = fullCoordinateBaseWinIndicator G D L i r α β := by classical simp [fullHistoryWinIndicator, fullCoordinateBaseWinIndicator, fullCoordinateOldHistory] theorem fullCoordinateNewHistory_winIndicator_eq (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (α : {j : Fin n // j ∈ D} → A) (β : {j : Fin n // j ∈ D} → B) : fullHistoryWinIndicator G (fullCoordinateNewHistory D L i r x) α β = fullCoordinateBaseWinIndicator G D L i r α β := by classical simp [fullHistoryWinIndicator, fullCoordinateBaseWinIndicator, fullCoordinateNewHistory] theorem fullCoordinate_three_sum_rotate {I J K T : Type*} [Fintype I] [Fintype J] [Fintype K] [AddCommMonoid T] (f : I → J → K → T) : (∑ i : I, ∑ j : J, ∑ k : K, f i j k) = ∑ j : J, ∑ k : K, ∑ i : I, f i j k := by calc (∑ i : I, ∑ j : J, ∑ k : K, f i j k) = ∑ j : J, ∑ i : I, ∑ k : K, f i j k := by rw [Finset.sum_comm] _ = ∑ j : J, ∑ k : K, ∑ i : I, f i j k := by apply Finset.sum_congr rfl intro j _ rw [Finset.sum_comm] theorem fullCoordinateOldHistory_sum {T : Type*} [AddCommMonoid T] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (f : FullSubsetHistory X Y n D L → T) : (∑ h : FullSubsetHistory X Y n D L, f h) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ y : Y, f (fullCoordinateOldHistory D L i r y) := by classical simpa [fullCoordinateOldHistoryEquiv, Fintype.sum_prod_type] using ((fullCoordinateOldHistoryEquiv (X := X) (Y := Y) D L i hiD hiL).symm.sum_comp f).symm theorem fullCoordinateNewHistory_sum {T : Type*} [AddCommMonoid T] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiL : i ∉ L) (f : FullSubsetHistory X Y n D (insert i L) → T) : (∑ h : FullSubsetHistory X Y n D (insert i L), f h) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ x : X, f (fullCoordinateNewHistory D L i r x) := by classical simpa [fullCoordinateNewHistoryEquiv, Fintype.sum_prod_type] using ((fullCoordinateNewHistoryEquiv (X := X) (Y := Y) D L i hiL).symm.sum_comp f).symm theorem fullCoordinateWeightedOldSum (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (value : (h : FullSubsetHistory X Y n D L) → ({j : Fin n // j ∈ D} → A) → ({j : Fin n // j ∈ D} → B) → ℝ) : (∑ h : FullSubsetHistory X Y n D L, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullCoordinateBaseWeight G D L i r * fullCoordinateBaseWinIndicator G D L i r α β * (∑ y : Y, G.marginalY y * value (fullCoordinateOldHistory D L i r y) α β) := by classical calc (∑ h : FullSubsetHistory X Y n D L, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ y : Y, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullHistoryWeight G (fullCoordinateOldHistory D L i r y) * fullHistoryWinIndicator G (fullCoordinateOldHistory D L i r y) α β * value (fullCoordinateOldHistory D L i r y) α β := fullCoordinateOldHistory_sum D L i hiD hiL (fun h => ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) _ = _ := by apply Finset.sum_congr rfl intro r _ rw [fullCoordinate_three_sum_rotate] apply Finset.sum_congr rfl intro α _ apply Finset.sum_congr rfl intro β _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro y _ rw [fullCoordinateOldHistory_weight G D L i hiD hiL r y, fullCoordinateOldHistory_winIndicator_eq G D L i r y α β] ring theorem fullCoordinateWeightedNewSum (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiL : i ∉ L) (value : (h : FullSubsetHistory X Y n D (insert i L)) → ({j : Fin n // j ∈ D} → A) → ({j : Fin n // j ∈ D} → B) → ℝ) : (∑ h : FullSubsetHistory X Y n D (insert i L), ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullCoordinateBaseWeight G D L i r * fullCoordinateBaseWinIndicator G D L i r α β * (∑ x : X, G.marginalX x * value (fullCoordinateNewHistory D L i r x) α β) := by classical calc (∑ h : FullSubsetHistory X Y n D (insert i L), ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ x : X, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullHistoryWeight G (fullCoordinateNewHistory D L i r x) * fullHistoryWinIndicator G (fullCoordinateNewHistory D L i r x) α β * value (fullCoordinateNewHistory D L i r x) α β := fullCoordinateNewHistory_sum D L i hiL (fun h => ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) _ = _ := by apply Finset.sum_congr rfl intro r _ rw [fullCoordinate_three_sum_rotate] apply Finset.sum_congr rfl intro α _ apply Finset.sum_congr rfl intro β _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro x _ rw [fullCoordinateNewHistory_weight G D L i hiL r x, fullCoordinateNewHistory_winIndicator_eq G D L i r x α β] ring def fullCoordinateAliceTotalEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) : ℝ := ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullCoordinateBaseWeight G D L i r * fullCoordinateBaseWinIndicator G D L i r α β * fullCoordinateAliceEntropyIncrement G n S D L i r α β theorem fullHistoryAliceEntropyPotential_increment (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) : fullHistoryAliceEntropyPotential G n S D (insert i L) - fullHistoryAliceEntropyPotential G n S D L = fullCoordinateAliceTotalEntropyIncrement G n S D L i := by classical unfold fullHistoryAliceEntropyPotential fullCoordinateAliceTotalEntropyIncrement rw [fullCoordinateWeightedNewSum G D L i hiL (fun h α β => bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (fullHistoryAliceFilter G n S D (insert i L) h α)) (fullHistoryBobFilter G n S D (insert i L) h β))] rw [fullCoordinateWeightedOldSum G D L i hiD hiL (fun h α β => bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (fullHistoryAliceFilter G n S D L h α)) (fullHistoryBobFilter G n S D L h β))] rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro r _ rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro α _ rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro β _ rw [← mul_sub] congr 1 exact fullCoordinateAliceEntropyIncrement_eq G n S D L i hiD hiL r α β theorem fullCoordinateAliceTotalEntropyIncrement_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) : 0 ≤ fullCoordinateAliceTotalEntropyIncrement G n S D L i := by unfold fullCoordinateAliceTotalEntropyIncrement exact Finset.sum_nonneg fun r _ => Finset.sum_nonneg fun α _ => Finset.sum_nonneg fun β _ => mul_nonneg (mul_nonneg (fullCoordinateBaseWeight_nonneg G D L i r) (fullCoordinateBaseWinIndicator_nonneg G D L i r α β)) (fullCoordinateAliceEntropyIncrement_nonneg G n S D L i hiD hiL r α β) end noncomputable section open scoped BigOperators abbrev SourceRemainingCoordinate {n : ℕ} (D : Finset (Fin n)) := ↥(Finset.univ \ D) abbrev SourceRemainingPermutation {n : ℕ} (D : Finset (Fin n)) := Equiv.Perm (SourceRemainingCoordinate D) def sourceRemainingPermutationRank {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) : SourceRemainingCoordinate D ≃ Fin (Finset.univ \ D).card := π.symm.trans (Finset.equivFin (Finset.univ \ D)) def sourceRemainingPermutationCoordinateSubtype {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : SourceRemainingCoordinate D := (sourceRemainingPermutationRank D π).symm k def sourceRemainingPermutationCoordinate {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : Fin n := (sourceRemainingPermutationCoordinateSubtype D π k).val @[simp] theorem sourceRemainingPermutationRank_coordinate {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : sourceRemainingPermutationRank D π (sourceRemainingPermutationCoordinateSubtype D π k) = k := by simp [sourceRemainingPermutationCoordinateSubtype] theorem sourceRemainingPermutationCoordinate_not_mem {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : sourceRemainingPermutationCoordinate D π k ∉ D := by have h := (sourceRemainingPermutationCoordinateSubtype D π k).property exact (Finset.mem_sdiff.mp h).2 def sourceRemainingPermutationPrefixSubtype {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin ((Finset.univ \ D).card + 1)) : Finset (SourceRemainingCoordinate D) := by classical exact Finset.univ.filter fun i => (sourceRemainingPermutationRank D π i).val < k.val def sourceRemainingPermutationPrefix {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin ((Finset.univ \ D).card + 1)) : Finset (Fin n) := by classical exact (sourceRemainingPermutationPrefixSubtype D π k).image (fun i : SourceRemainingCoordinate D => i.val) theorem sourceRemainingPermutationPrefix_subset {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin ((Finset.univ \ D).card + 1)) : sourceRemainingPermutationPrefix D π k ⊆ Finset.univ \ D := by classical intro i hi obtain ⟨j, _, hj⟩ := Finset.mem_image.mp hi simpa [hj] using j.property theorem sourceRemainingPermutationCoordinate_not_mem_prefix {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : sourceRemainingPermutationCoordinate D π k ∉ sourceRemainingPermutationPrefix D π k.castSucc := by classical intro hmem obtain ⟨j, hj, hval⟩ := Finset.mem_image.mp hmem have heq : j = sourceRemainingPermutationCoordinateSubtype D π k := by apply Subtype.ext exact hval subst j have hlt := (Finset.mem_filter.mp hj).2 simp at hlt theorem sourceRemainingPermutationPrefixSubtype_succ {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : sourceRemainingPermutationPrefixSubtype D π k.succ = insert (sourceRemainingPermutationCoordinateSubtype D π k) (sourceRemainingPermutationPrefixSubtype D π k.castSucc) := by classical ext i simp only [sourceRemainingPermutationPrefixSubtype, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert] change (sourceRemainingPermutationRank D π i).val < k.val + 1 ↔ i = sourceRemainingPermutationCoordinateSubtype D π k ∨ (sourceRemainingPermutationRank D π i).val < k.val constructor · intro hi by_cases hlt : (sourceRemainingPermutationRank D π i).val < k.val · exact Or.inr hlt · left apply (sourceRemainingPermutationRank D π).injective have heq : sourceRemainingPermutationRank D π i = k := by apply Fin.ext omega simpa using heq · intro hi rcases hi with hi | hi · subst i simp · omega theorem sourceRemainingPermutationPrefix_succ {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : sourceRemainingPermutationPrefix D π k.succ = insert (sourceRemainingPermutationCoordinate D π k) (sourceRemainingPermutationPrefix D π k.castSucc) := by classical unfold sourceRemainingPermutationPrefix rw [sourceRemainingPermutationPrefixSubtype_succ, Finset.image_insert] rfl @[simp] theorem sourceRemainingPermutationPrefix_zero {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) : sourceRemainingPermutationPrefix D π 0 = ∅ := by classical simp [sourceRemainingPermutationPrefix, sourceRemainingPermutationPrefixSubtype] @[simp] theorem sourceRemainingPermutationPrefix_last {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) : sourceRemainingPermutationPrefix D π (Fin.last (Finset.univ \ D).card) = Finset.univ \ D := by classical ext i constructor · intro hi exact sourceRemainingPermutationPrefix_subset D π _ hi · intro hi apply Finset.mem_image.mpr refine ⟨(⟨i, hi⟩ : SourceRemainingCoordinate D), ?_, rfl⟩ apply Finset.mem_filter.mpr exact ⟨Finset.mem_univ _, (sourceRemainingPermutationRank D π (⟨i, hi⟩ : SourceRemainingCoordinate D)).isLt⟩ theorem sourceRemainingPermutationCoordinate_sum {T : Type*} [AddCommMonoid T] {n : ℕ} (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (f : Fin n → T) : (∑ k : Fin (Finset.univ \ D).card, f (sourceRemainingPermutationCoordinate D π k)) = ∑ i : SourceRemainingCoordinate D, f i.val := by classical exact (sourceRemainingPermutationRank D π).symm.sum_comp (fun i : SourceRemainingCoordinate D => f i.val) theorem fin_sum_successive_sub {m : ℕ} (f : Fin (m + 1) → ℝ) : (∑ k : Fin m, (f k.succ - f k.castSucc)) = f (Fin.last m) - f 0 := by rw [Finset.sum_sub_distrib] have hfirst := Fin.sum_univ_succ f have hlast := Fin.sum_univ_castSucc f linarith section ActualEntropyBudgets variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def sourcePermutationAliceEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : ℝ := fullCoordinateAliceTotalEntropyIncrement G n S D (sourceRemainingPermutationPrefix D π k.castSucc) (sourceRemainingPermutationCoordinate D π k) theorem sourcePermutationAliceEntropyIncrement_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : 0 ≤ sourcePermutationAliceEntropyIncrement G n S D π k := by apply fullCoordinateAliceTotalEntropyIncrement_nonneg · exact sourceRemainingPermutationCoordinate_not_mem D π k · exact sourceRemainingPermutationCoordinate_not_mem_prefix D π k theorem sourcePermutationAliceEntropyPotential_step (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : fullHistoryAliceEntropyPotential G n S D (sourceRemainingPermutationPrefix D π k.succ) - fullHistoryAliceEntropyPotential G n S D (sourceRemainingPermutationPrefix D π k.castSucc) = sourcePermutationAliceEntropyIncrement G n S D π k := by rw [sourceRemainingPermutationPrefix_succ] exact fullHistoryAliceEntropyPotential_increment G n S D (sourceRemainingPermutationPrefix D π k.castSucc) (sourceRemainingPermutationCoordinate D π k) (sourceRemainingPermutationCoordinate_not_mem D π k) (sourceRemainingPermutationCoordinate_not_mem_prefix D π k) theorem sourcePermutationAliceEntropyIncrement_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (π : SourceRemainingPermutation D) : (∑ k : Fin (Finset.univ \ D).card, sourcePermutationAliceEntropyIncrement G n S D π k) = fullHistoryAliceEntropyPotential G n S D (Finset.univ \ D) - fullHistoryAliceEntropyPotential G n S D ∅ := by calc (∑ k : Fin (Finset.univ \ D).card, sourcePermutationAliceEntropyIncrement G n S D π k) = ∑ k : Fin (Finset.univ \ D).card, (fullHistoryAliceEntropyPotential G n S D (sourceRemainingPermutationPrefix D π k.succ) - fullHistoryAliceEntropyPotential G n S D (sourceRemainingPermutationPrefix D π k.castSucc)) := by apply Finset.sum_congr rfl intro k _ exact (sourcePermutationAliceEntropyPotential_step G n S D π k).symm _ = fullHistoryAliceEntropyPotential G n S D (sourceRemainingPermutationPrefix D π (Fin.last (Finset.univ \ D).card)) - fullHistoryAliceEntropyPotential G n S D (sourceRemainingPermutationPrefix D π 0) := fin_sum_successive_sub (fun k => fullHistoryAliceEntropyPotential G n S D (sourceRemainingPermutationPrefix D π k)) _ = _ := by simp theorem sourcePermutationAliceEntropyIncrement_sum_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hp : 0 < (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) (π : SourceRemainingPermutation D) : (∑ k : Fin (Finset.univ \ D).card, sourcePermutationAliceEntropyIncrement G n S D π k) ≤ (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) := by classical rw [sourcePermutationAliceEntropyIncrement_sum] have hlast := fullHistoryAliceEntropyPotential_nonpos G n S D (Finset.univ \ D) have hfirst := fullHistoryAliceEntropyPotential_lower_bound G n S D ∅ (Finset.empty_subset _) hp linarith def sourceUniformPermutationAverage {n : ℕ} (D : Finset (Fin n)) (f : SourceRemainingPermutation D → Fin (Finset.univ \ D).card → ℝ) : ℝ := (∑ π : SourceRemainingPermutation D, ∑ k : Fin (Finset.univ \ D).card, f π k) / ((Fintype.card (SourceRemainingPermutation D) : ℝ) * ((Finset.univ \ D).card : ℝ)) theorem sourceRemainingPermutation_card_pos {n : ℕ} (D : Finset (Fin n)) : 0 < (Fintype.card (SourceRemainingPermutation D) : ℝ) := by classical exact_mod_cast (Fintype.card_pos_iff.mpr ⟨Equiv.refl (SourceRemainingCoordinate D)⟩ : 0 < Fintype.card (SourceRemainingPermutation D)) theorem sourceUniformPermutationAverage_le {n : ℕ} (D : Finset (Fin n)) (hm : 0 < (Finset.univ \ D).card) (f : SourceRemainingPermutation D → Fin (Finset.univ \ D).card → ℝ) {C : ℝ} (hC : ∀ π : SourceRemainingPermutation D, (∑ k : Fin (Finset.univ \ D).card, f π k) ≤ C) : sourceUniformPermutationAverage D f ≤ C / ((Finset.univ \ D).card : ℝ) := by classical have hperm := sourceRemainingPermutation_card_pos D have hmreal : 0 < ((Finset.univ \ D).card : ℝ) := by exact_mod_cast hm have hden : 0 < (Fintype.card (SourceRemainingPermutation D) : ℝ) * ((Finset.univ \ D).card : ℝ) := mul_pos hperm hmreal have hsum : (∑ π : SourceRemainingPermutation D, ∑ k : Fin (Finset.univ \ D).card, f π k) ≤ (Fintype.card (SourceRemainingPermutation D) : ℝ) * C := by calc (∑ π : SourceRemainingPermutation D, ∑ k : Fin (Finset.univ \ D).card, f π k) ≤ ∑ _π : SourceRemainingPermutation D, C := by apply Finset.sum_le_sum intro π _ exact hC π _ = (Fintype.card (SourceRemainingPermutation D) : ℝ) * C := by simp unfold sourceUniformPermutationAverage calc (∑ π : SourceRemainingPermutation D, ∑ k : Fin (Finset.univ \ D).card, f π k) / ((Fintype.card (SourceRemainingPermutation D) : ℝ) * ((Finset.univ \ D).card : ℝ)) ≤ ((Fintype.card (SourceRemainingPermutation D) : ℝ) * C) / ((Fintype.card (SourceRemainingPermutation D) : ℝ) * ((Finset.univ \ D).card : ℝ)) := (div_le_div_iff_of_pos_right hden).mpr hsum _ = C / ((Finset.univ \ D).card : ℝ) := mul_div_mul_left C ((Finset.univ \ D).card : ℝ) hperm.ne' theorem sourceUniformPermutationAverage_nonneg {n : ℕ} (D : Finset (Fin n)) (f : SourceRemainingPermutation D → Fin (Finset.univ \ D).card → ℝ) (hf : ∀ π k, 0 ≤ f π k) : 0 ≤ sourceUniformPermutationAverage D f := by classical apply div_nonneg · exact Finset.sum_nonneg fun π _ => Finset.sum_nonneg fun k _ => hf π k · exact mul_nonneg (Nat.cast_nonneg (Fintype.card (SourceRemainingPermutation D))) (Nat.cast_nonneg (Finset.univ \ D).card) theorem sourceUniformPermutationAliceEntropyBudget (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hm : 0 < (Finset.univ \ D).card) (hp : 0 < (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) : sourceUniformPermutationAverage D (sourcePermutationAliceEntropyIncrement G n S D) ≤ (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) / ((Finset.univ \ D).card : ℝ) := by apply sourceUniformPermutationAverage_le D hm intro π exact sourcePermutationAliceEntropyIncrement_sum_le G n S D hp π end ActualEntropyBudgets end noncomputable section open scoped BigOperators attribute [local instance] Classical.propDecidable def exactLeft {M : Type*} [Fintype M] [DecidableEq M] (coordinate : M) (partition : M → Bool) : Finset M := Finset.univ.filter fun j => j ≠ coordinate ∧ partition j = false def exactRight {M : Type*} [Fintype M] [DecidableEq M] (coordinate : M) (partition : M → Bool) : Finset M := Finset.univ.filter fun j => j ≠ coordinate ∧ partition j = true theorem exactLeft_coordinate_not_mem {M : Type*} [Fintype M] [DecidableEq M] (coordinate : M) (partition : M → Bool) : coordinate ∉ exactLeft coordinate partition := by simp [exactLeft] theorem exactRight_coordinate_not_mem {M : Type*} [Fintype M] [DecidableEq M] (coordinate : M) (partition : M → Bool) : coordinate ∉ exactRight coordinate partition := by simp [exactRight] structure ExactForwardSeed (M : Type*) [Fintype M] [DecidableEq M] where coordinate : M partition : M → Bool leftOrder : Equiv.Perm {j : M // j ∈ exactLeft coordinate partition} rightOrder : Equiv.Perm {j : M // j ∈ exactRight coordinate partition} leftCut : Fin ((exactLeft coordinate partition).card + 1) rightCut : Fin ((exactRight coordinate partition).card + 1) deriving Fintype abbrev ExactRemainingSeed {n : ℕ} (D : Finset (Fin n)) := ExactForwardSeed (SourceRemainingCoordinate D) def exactLeftRank {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : {j : M // j ∈ exactLeft seed.coordinate seed.partition} ≃ Fin (exactLeft seed.coordinate seed.partition).card := seed.leftOrder.symm.trans (Finset.equivFin (exactLeft seed.coordinate seed.partition)) def exactRightRank {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : {j : M // j ∈ exactRight seed.coordinate seed.partition} ≃ Fin (exactRight seed.coordinate seed.partition).card := seed.rightOrder.symm.trans (Finset.equivFin (exactRight seed.coordinate seed.partition)) def exactLeftPrefix {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Finset M := (Finset.univ.filter (fun j : {j : M // j ∈ exactLeft seed.coordinate seed.partition} => (exactLeftRank seed j).val < seed.leftCut.val)).image Subtype.val def exactRightPrefix {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Finset M := (Finset.univ.filter (fun j : {j : M // j ∈ exactRight seed.coordinate seed.partition} => (exactRightRank seed j).val < seed.rightCut.val)).image Subtype.val theorem exactLeftPrefix_subset {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactLeftPrefix seed ⊆ exactLeft seed.coordinate seed.partition := by intro j hj obtain ⟨a, _, ha⟩ := Finset.mem_image.mp hj exact ha ▸ a.property theorem exactRightPrefix_subset {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactRightPrefix seed ⊆ exactRight seed.coordinate seed.partition := by intro j hj obtain ⟨a, _, ha⟩ := Finset.mem_image.mp hj exact ha ▸ a.property def exactSeedWeight {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : ℝ := (1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft seed.coordinate seed.partition}) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactRight seed.coordinate seed.partition}) : ℝ)) * (1 / ((exactLeft seed.coordinate seed.partition).card + 1 : ℝ)) * (1 / ((exactRight seed.coordinate seed.partition).card + 1 : ℝ)) theorem exactSeedWeight_nonneg {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : 0 ≤ exactSeedWeight seed := by unfold exactSeedWeight positivity abbrev ExactSeedTuple (M : Type*) [Fintype M] [DecidableEq M] := Σ i : M, Σ partition : M → Bool, (Equiv.Perm {j : M // j ∈ exactLeft i partition}) × (Equiv.Perm {j : M // j ∈ exactRight i partition}) × Fin ((exactLeft i partition).card + 1) × Fin ((exactRight i partition).card + 1) def exactSeedEquiv (M : Type*) [Fintype M] [DecidableEq M] : ExactForwardSeed M ≃ ExactSeedTuple M where toFun seed := ⟨seed.coordinate, seed.partition, seed.leftOrder, seed.rightOrder, seed.leftCut, seed.rightCut⟩ invFun t := ⟨t.1, t.2.1, t.2.2.1, t.2.2.2.1, t.2.2.2.2.1, t.2.2.2.2.2⟩ left_inv seed := by cases seed rfl right_inv t := by rcases t with ⟨i, partition, leftOrder, rightOrder, leftCut, rightCut⟩ rfl @[simp] theorem exactSeedEquiv_symm_apply {M : Type*} [Fintype M] [DecidableEq M] (t : ExactSeedTuple M) : (exactSeedEquiv M).symm t = ⟨t.1, t.2.1, t.2.2.1, t.2.2.2.1, t.2.2.2.2.1, t.2.2.2.2.2⟩ := by rfl theorem exactForwardSeed_sum {M : Type*} [Fintype M] [DecidableEq M] (f : ExactForwardSeed M → ℝ) : (∑ seed : ExactForwardSeed M, f seed) = ∑ i : M, ∑ partition : M → Bool, ∑ leftOrder : Equiv.Perm {j : M // j ∈ exactLeft i partition}, ∑ rightOrder : Equiv.Perm {j : M // j ∈ exactRight i partition}, ∑ leftCut : Fin ((exactLeft i partition).card + 1), ∑ rightCut : Fin ((exactRight i partition).card + 1), f ⟨i, partition, leftOrder, rightOrder, leftCut, rightCut⟩ := by classical calc (∑ seed : ExactForwardSeed M, f seed) = ∑ t : ExactSeedTuple M, f ((exactSeedEquiv M).symm t) := ((exactSeedEquiv M).symm.sum_comp f).symm _ = _ := by simp [Fintype.sum_sigma, Fintype.sum_prod_type, exactSeedEquiv_symm_apply] theorem exactUniform_sum {T : Type*} [Fintype T] (positive : 0 < Fintype.card T) : (∑ _t : T, (1 / (Fintype.card T : ℝ))) = 1 := by have hcard : (Fintype.card T : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt positive) simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] field_simp [hcard] theorem exactUniform_sum_mul {T : Type*} [Fintype T] (positive : 0 < Fintype.card T) (value : ℝ) : (∑ _t : T, value * (1 / (Fintype.card T : ℝ))) = value := by rw [← Finset.mul_sum, exactUniform_sum positive] ring theorem exactPrefixUniform_sum_mul (m : ℕ) (value : ℝ) : (∑ _k : Fin (m + 1), value * (1 / ((m : ℝ) + 1))) = value := by simpa only [Fintype.card_fin, Nat.cast_add, Nat.cast_one] using (exactUniform_sum_mul (T := Fin (m + 1)) (by simp) value) theorem exactPermutationUniform_sum_mul {T : Type*} [Fintype T] (value : ℝ) : (∑ _π : Equiv.Perm T, value * (1 / (Fintype.card (Equiv.Perm T) : ℝ))) = value := by exact exactUniform_sum_mul (Fintype.card_pos_iff.mpr ⟨Equiv.refl T⟩) value end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false theorem common_finite_purification_pair_jensen {ι κ d : Type*} [Fintype ι] [Fintype κ] [Fintype d] [DecidableEq d] (weight : ι → ℝ) (F : κ → Matrix d d ℂ) (anchor : Matrix d d ℂ) (positive : ∀ k, (F k).PosSemidef) (hanchor : anchor.PosSemidef) (choose : ι → κ) (meanIndex : κ) (nonnegative : ∀ a, 0 ≤ weight a) (normalized : (∑ a : ι, weight a) = 1) (mean : (∑ a : ι, weight a • F (choose a)) = F meanIndex) : ((∑ a : ι, weight a • cfc (fun z : ℝ => z * Real.log z) (F (choose a))) - cfc (fun z : ℝ => z * Real.log z) (F meanIndex) - (∑ a : ι, weight a • ((finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex).conjTranspose * (finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex)))).PosSemidef := by classical let H : ι → Matrix d d ℂ := fun a => F (choose a) let M : Matrix d d ℂ := F meanIndex have hH : ∀ a, (H a).PosSemidef := fun a => positive (choose a) have hM : M.PosSemidef := positive meanIndex have hmean : (∑ a : ι, weight a • H a) = M := mean have hlocal := finite_purification_log_entropy_jensen weight H M nonnegative normalized hmean hH change ((∑ a : ι, weight a • cfc (fun z : ℝ => z * Real.log z) (H a)) - cfc (fun z : ℝ => z * Real.log z) M - (∑ a : ι, weight a • ((finitePurificationMatrix H M hH hM a - meanFinitePurificationMatrix H M hH hM).conjTranspose * (finitePurificationMatrix H M hH hM a - meanFinitePurificationMatrix H M hH hM)))).PosSemidef at hlocal have hpair (a : ι) : (finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex).conjTranspose * (finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex) = (finitePurificationMatrix H M hH hM a - meanFinitePurificationMatrix H M hH hM).conjTranspose * (finitePurificationMatrix H M hH hM a - meanFinitePurificationMatrix H M hH hM) := by rw [finitePurificationMatrix_pair_difference_gram_eq_integral, finitePurificationMatrix_difference_gram_eq_integral] change ((∑ a : ι, weight a • cfc (fun z : ℝ => z * Real.log z) (H a)) - cfc (fun z : ℝ => z * Real.log z) M - (∑ a : ι, weight a • ((finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex).conjTranspose * (finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex)))).PosSemidef simp_rw [hpair] exact hlocal theorem commonFinitePurification_weighted_left_variation_le {X Y A B ι κ eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype ι] [Fintype κ] [Fintype eB] {G : Game X Y A B} (S : Strategy G) (weight : ι → ℝ) (F : κ → Matrix S.Alice S.Alice ℂ) (anchor : Matrix S.Alice S.Alice ℂ) (positive : ∀ k, (F k).PosSemidef) (hanchor : anchor.PosSemidef) (choose : ι → κ) (meanIndex : κ) (nonnegative : ∀ a, 0 ≤ weight a) (normalized : (∑ a : ι, weight a) = 1) (mean : (∑ a : ι, weight a • F (choose a)) = F meanIndex) (KB : Matrix eB S.Bob ℂ) : (∑ a : ι, weight a * ‖finiteLocalPurificationVector S (finitePurificationMatrix F anchor positive hanchor (choose a)) KB - finiteLocalPurificationVector S (finitePurificationMatrix F anchor positive hanchor meanIndex) KB‖ ^ 2) ≤ bornTracePairing S.state.matrix ((∑ a : ι, weight a • cfc (fun z : ℝ => z * Real.log z) (F (choose a))) - cfc (fun z : ℝ => z * Real.log z) (F meanIndex)) (KB.conjTranspose * KB) := by classical have hJ := common_finite_purification_pair_jensen weight F anchor positive hanchor choose meanIndex nonnegative normalized mean have hnonneg := trace_mul_posSemidef_nonneg S.state.positive (hJ.kronecker (Matrix.posSemidef_conjTranspose_mul_self KB)) change 0 ≤ bornTracePairing S.state.matrix (((∑ a : ι, weight a • cfc (fun z : ℝ => z * Real.log z) (F (choose a))) - cfc (fun z : ℝ => z * Real.log z) (F meanIndex)) - (∑ a : ι, weight a • ((finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex).conjTranspose * (finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex)))) (KB.conjTranspose * KB) at hnonneg have hsum : bornTracePairing S.state.matrix (∑ a : ι, weight a • ((finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex).conjTranspose * (finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex))) (KB.conjTranspose * KB) = ∑ a : ι, weight a * ‖finiteLocalPurificationVector S (finitePurificationMatrix F anchor positive hanchor (choose a)) KB - finiteLocalPurificationVector S (finitePurificationMatrix F anchor positive hanchor meanIndex) KB‖ ^ 2 := by simp only [map_sum, LinearMap.sum_apply, map_smul, LinearMap.smul_apply, smul_eq_mul] apply Finset.sum_congr rfl intro a _ rw [finiteLocalPurificationVector_sub_left_norm_sq] rw [map_sub] at hnonneg change 0 ≤ bornTracePairing S.state.matrix ((∑ a : ι, weight a • cfc (fun z : ℝ => z * Real.log z) (F (choose a))) - cfc (fun z : ℝ => z * Real.log z) (F meanIndex)) (KB.conjTranspose * KB) - bornTracePairing S.state.matrix (∑ a : ι, weight a • ((finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex).conjTranspose * (finitePurificationMatrix F anchor positive hanchor (choose a) - finitePurificationMatrix F anchor positive hanchor meanIndex))) (KB.conjTranspose * KB) at hnonneg rw [hsum] at hnonneg linarith theorem commonFinitePurification_weighted_right_variation_le {X Y A B ι κ eA : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype ι] [Fintype κ] [Fintype eA] {G : Game X Y A B} (S : Strategy G) (weight : ι → ℝ) (F : κ → Matrix S.Bob S.Bob ℂ) (anchor : Matrix S.Bob S.Bob ℂ) (positive : ∀ k, (F k).PosSemidef) (hanchor : anchor.PosSemidef) (choose : ι → κ) (meanIndex : κ) (nonnegative : ∀ b, 0 ≤ weight b) (normalized : (∑ b : ι, weight b) = 1) (mean : (∑ b : ι, weight b • F (choose b)) = F meanIndex) (KA : Matrix eA S.Alice ℂ) : (∑ b : ι, weight b * ‖finiteLocalPurificationVector S KA (finitePurificationMatrix F anchor positive hanchor (choose b)) - finiteLocalPurificationVector S KA (finitePurificationMatrix F anchor positive hanchor meanIndex)‖ ^ 2) ≤ bornTracePairing S.state.matrix (KA.conjTranspose * KA) ((∑ b : ι, weight b • cfc (fun z : ℝ => z * Real.log z) (F (choose b))) - cfc (fun z : ℝ => z * Real.log z) (F meanIndex)) := by classical have hJ := common_finite_purification_pair_jensen weight F anchor positive hanchor choose meanIndex nonnegative normalized mean have hnonneg := trace_mul_posSemidef_nonneg S.state.positive ((Matrix.posSemidef_conjTranspose_mul_self KA).kronecker hJ) change 0 ≤ bornTracePairing S.state.matrix (KA.conjTranspose * KA) (((∑ b : ι, weight b • cfc (fun z : ℝ => z * Real.log z) (F (choose b))) - cfc (fun z : ℝ => z * Real.log z) (F meanIndex)) - (∑ b : ι, weight b • ((finitePurificationMatrix F anchor positive hanchor (choose b) - finitePurificationMatrix F anchor positive hanchor meanIndex).conjTranspose * (finitePurificationMatrix F anchor positive hanchor (choose b) - finitePurificationMatrix F anchor positive hanchor meanIndex)))) at hnonneg have hsum : bornTracePairing S.state.matrix (KA.conjTranspose * KA) (∑ b : ι, weight b • ((finitePurificationMatrix F anchor positive hanchor (choose b) - finitePurificationMatrix F anchor positive hanchor meanIndex).conjTranspose * (finitePurificationMatrix F anchor positive hanchor (choose b) - finitePurificationMatrix F anchor positive hanchor meanIndex))) = ∑ b : ι, weight b * ‖finiteLocalPurificationVector S KA (finitePurificationMatrix F anchor positive hanchor (choose b)) - finiteLocalPurificationVector S KA (finitePurificationMatrix F anchor positive hanchor meanIndex)‖ ^ 2 := by simp only [map_sum, map_smul, smul_eq_mul] apply Finset.sum_congr rfl intro b _ rw [finiteLocalPurificationVector_sub_right_norm_sq] rw [map_sub, hsum] at hnonneg linarith end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem rectangular_matrix_quadratic_compression {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (K : Matrix e d ℂ) (E : Matrix e e ℂ) (z : EuclideanSpace ℂ d) : quadraticExpectation (Matrix.toEuclideanCLM (n := e) (𝕜 := ℂ) E) (toLp 2 (K.mulVec (ofLp z))) = quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) (K.conjTranspose * E * K)) z := by unfold quadraticExpectation rw [EuclideanSpace.inner_eq_star_dotProduct, EuclideanSpace.inner_eq_star_dotProduct] change (E.mulVec (K.mulVec (ofLp z)) ⬝ᵥ star (K.mulVec (ofLp z))).re = ((K.conjTranspose * E * K).mulVec (ofLp z) ⬝ᵥ star (ofLp z)).re rw [dotProduct_comm (E.mulVec (K.mulVec (ofLp z))), Matrix.star_mulVec, ← Matrix.dotProduct_mulVec, Matrix.mulVec_mulVec, Matrix.mulVec_mulVec] rw [dotProduct_comm] theorem finiteLocalPurificationJointMatrix_compression {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] [DecidableEq eA] [DecidableEq eB] {G : Game X Y A B} (S : Strategy G) (KA : Matrix eA S.Alice ℂ) (KB : Matrix eB S.Bob ℂ) (EA : Matrix eA eA ℂ) (EB : Matrix eB eB ℂ) : (finiteLocalPurificationJointMatrix S KA KB).conjTranspose * (((EA ⊗ₖ (1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ)) ⊗ₖ EB)) * finiteLocalPurificationJointMatrix S KA KB = (((KA.conjTranspose * EA * KA) ⊗ₖ (1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ)) ⊗ₖ (KB.conjTranspose * EB * KB)) := by unfold finiteLocalPurificationJointMatrix rw [Matrix.conjTranspose_kronecker, ← Matrix.mul_kronecker_mul, ← Matrix.mul_kronecker_mul, Matrix.conjTranspose_kronecker, ← Matrix.mul_kronecker_mul, ← Matrix.mul_kronecker_mul] simp theorem finiteLocalPurificationVector_quadratic {X Y A B eA eB : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype eA] [Fintype eB] [DecidableEq eA] [DecidableEq eB] {G : Game X Y A B} (S : Strategy G) (KA : Matrix eA S.Alice ℂ) (KB : Matrix eB S.Bob ℂ) (EA : Matrix eA eA ℂ) (EB : Matrix eB eB ℂ) : quadraticExpectation (Matrix.toEuclideanCLM (n := (eA × (S.Alice × S.Bob)) × eB) (𝕜 := ℂ) (((EA ⊗ₖ (1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ)) ⊗ₖ EB))) (finiteLocalPurificationVector S KA KB) = bornTracePairing S.state.matrix (KA.conjTranspose * EA * KA) (KB.conjTranspose * EB * KB) := by unfold finiteLocalPurificationVector rw [rectangular_matrix_quadratic_compression, finiteLocalPurificationJointMatrix_compression] exact strategyPurificationVector_quadratic S (KA.conjTranspose * EA * KA) (KB.conjTranspose * EB * KB) end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def conditionedAliceCoordinateEffect (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (α : {j : Fin n // j ∈ D} → A) (xs : Fin n → X) (i : Fin n) (a : A) : Matrix S.Alice S.Alice ℂ := by classical exact ∑ answers : Fin n → A, if (∀ (j : Fin n) (hj : j ∈ D), answers j = α ⟨j, hj⟩) ∧ answers i = a then (S.aliceMeasurement xs).effect answers else 0 def conditionedBobCoordinateEffect (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (β : {j : Fin n // j ∈ D} → B) (ys : Fin n → Y) (i : Fin n) (b : B) : Matrix S.Bob S.Bob ℂ := by classical exact ∑ answers : Fin n → B, if (∀ (j : Fin n) (hj : j ∈ D), answers j = β ⟨j, hj⟩) ∧ answers i = b then (S.bobMeasurement ys).effect answers else 0 theorem conditionedAliceCoordinateEffect_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (α : {j : Fin n // j ∈ D} → A) (xs : Fin n → X) (i : Fin n) (a : A) : (conditionedAliceCoordinateEffect G n S D α xs i a).PosSemidef := by classical unfold conditionedAliceCoordinateEffect apply Matrix.posSemidef_sum Finset.univ intro answers _ split_ifs · exact (S.aliceMeasurement xs).positive answers · exact Matrix.PosSemidef.zero theorem conditionedBobCoordinateEffect_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (β : {j : Fin n // j ∈ D} → B) (ys : Fin n → Y) (i : Fin n) (b : B) : (conditionedBobCoordinateEffect G n S D β ys i b).PosSemidef := by classical unfold conditionedBobCoordinateEffect apply Matrix.posSemidef_sum Finset.univ intro answers _ split_ifs · exact (S.bobMeasurement ys).positive answers · exact Matrix.PosSemidef.zero theorem conditionedAliceCoordinateEffect_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (α : {j : Fin n // j ∈ D} → A) (xs : Fin n → X) (i : Fin n) : (∑ a : A, conditionedAliceCoordinateEffect G n S D α xs i a) = conditionedAliceEffect G n S D α xs := by classical unfold conditionedAliceCoordinateEffect conditionedAliceEffect rw [Finset.sum_comm] apply Finset.sum_congr rfl intro answers _ calc (∑ a : A, if (∀ (j : Fin n) (hj : j ∈ D), answers j = α ⟨j, hj⟩) ∧ answers i = a then (S.aliceMeasurement xs).effect answers else 0) = if (∀ (j : Fin n) (hj : j ∈ D), answers j = α ⟨j, hj⟩) ∧ answers i = answers i then (S.aliceMeasurement xs).effect answers else 0 := by apply Fintype.sum_eq_single (answers i) intro a ha simp [ha.symm] _ = _ := by simp theorem conditionedBobCoordinateEffect_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (β : {j : Fin n // j ∈ D} → B) (ys : Fin n → Y) (i : Fin n) : (∑ b : B, conditionedBobCoordinateEffect G n S D β ys i b) = conditionedBobEffect G n S D β ys := by classical unfold conditionedBobCoordinateEffect conditionedBobEffect rw [Finset.sum_comm] apply Finset.sum_congr rfl intro answers _ calc (∑ b : B, if (∀ (j : Fin n) (hj : j ∈ D), answers j = β ⟨j, hj⟩) ∧ answers i = b then (S.bobMeasurement ys).effect answers else 0) = if (∀ (j : Fin n) (hj : j ∈ D), answers j = β ⟨j, hj⟩) ∧ answers i = answers i then (S.bobMeasurement ys).effect answers else 0 := by apply Fintype.sum_eq_single (answers i) intro b hb simp [hb.symm] _ = _ := by simp def fullHistoryAliceCoordinateEffect (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (α : {j : Fin n // j ∈ D} → A) (i : Fin n) (a : A) : Matrix S.Alice S.Alice ℂ := ∑ hidden : {j : Fin n // j ∈ fullHistoryRemaining n D L} → X, fullHistoryHiddenAliceWeight G h hidden • conditionedAliceCoordinateEffect G n S D α (fullHistoryAliceQuestion h hidden) i a def fullHistoryBobCoordinateEffect (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (h : FullSubsetHistory X Y n D L) (β : {j : Fin n // j ∈ D} → B) (i : Fin n) (b : B) : Matrix S.Bob S.Bob ℂ := ∑ hidden : {j : Fin n // j ∈ L} → Y, fullHistoryHiddenBobWeight G h hidden • conditionedBobCoordinateEffect G n S D β (fullHistoryBobQuestion h hidden) i b def fullCoordinateAliceRefinementEffect (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (α : {j : Fin n // j ∈ D} → A) (x : X) (a : A) : Matrix S.Alice S.Alice ℂ := fullHistoryAliceCoordinateEffect G n S D (insert i L) (fullCoordinateNewHistory D L i r x) α i a def fullCoordinateBobRefinementEffect (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (β : {j : Fin n // j ∈ D} → B) (y : Y) (b : B) : Matrix S.Bob S.Bob ℂ := fullHistoryBobCoordinateEffect G n S D L (fullCoordinateOldHistory D L i r y) β i b end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] structure ExactRevealHistory (X Y : Type*) [Fintype X] [Fintype Y] {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) where aliceConditioned : {j : Fin n // j ∈ D} → X bobConditioned : {j : Fin n // j ∈ D} → Y aliceLeft : {j : SourceRemainingCoordinate D // j ∈ exactLeft seed.coordinate seed.partition} → X bobRight : {j : SourceRemainingCoordinate D // j ∈ exactRight seed.coordinate seed.partition} → Y bobLeftPrefix : {j : SourceRemainingCoordinate D // j ∈ exactLeftPrefix seed} → Y aliceRightPrefix : {j : SourceRemainingCoordinate D // j ∈ exactRightPrefix seed} → X abbrev ExactRevealHistoryTuple (X Y : Type*) [Fintype X] [Fintype Y] {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) := ({j : Fin n // j ∈ D} → X) × ({j : Fin n // j ∈ D} → Y) × ({j : SourceRemainingCoordinate D // j ∈ exactLeft seed.coordinate seed.partition} → X) × ({j : SourceRemainingCoordinate D // j ∈ exactRight seed.coordinate seed.partition} → Y) × ({j : SourceRemainingCoordinate D // j ∈ exactLeftPrefix seed} → Y) × ({j : SourceRemainingCoordinate D // j ∈ exactRightPrefix seed} → X) def exactRevealHistoryEquiv {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : ExactRevealHistory X Y D seed ≃ ExactRevealHistoryTuple X Y D seed where toFun h := ⟨h.aliceConditioned, h.bobConditioned, h.aliceLeft, h.bobRight, h.bobLeftPrefix, h.aliceRightPrefix⟩ invFun t := ⟨t.1, t.2.1, t.2.2.1, t.2.2.2.1, t.2.2.2.2.1, t.2.2.2.2.2⟩ left_inv h := by cases h; rfl right_inv t := by rcases t with ⟨ac, bc, al, br, bl, ar⟩ rfl noncomputable instance exactRevealHistoryFintype {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : Fintype (ExactRevealHistory X Y D seed) := by classical exact Fintype.ofEquiv (ExactRevealHistoryTuple X Y D seed) (exactRevealHistoryEquiv (X := X) (Y := Y) D seed).symm abbrev ExactFullQuestion (X Y : Type*) (n : ℕ) := (Fin n → X) × (Fin n → Y) def exactRevealCode {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) : ExactRevealHistory X Y D seed where aliceConditioned j := q.1 j.val bobConditioned j := q.2 j.val aliceLeft j := q.1 j.val.val bobRight j := q.2 j.val.val bobLeftPrefix j := q.2 j.val.val aliceRightPrefix j := q.1 j.val.val def exactPriorQuestionWeight (G : Game X Y A B) (n : ℕ) (q : ExactFullQuestion X Y n) : ℝ := (G.repeat n).questionWeight q.1 q.2 theorem exactPriorQuestionWeight_nonneg (G : Game X Y A B) (n : ℕ) (q : ExactFullQuestion X Y n) : 0 ≤ exactPriorQuestionWeight G n q := (G.repeat n).weight_nonneg q.1 q.2 theorem exactPriorQuestionWeight_sum (G : Game X Y A B) (n : ℕ) : (∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q) = 1 := by simpa [exactPriorQuestionWeight, Fintype.sum_prod_type] using (G.repeat n).weight_normalized def exactRevealMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) : ℝ := ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history then exactPriorQuestionWeight G n q else 0 theorem exactRevealMass_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) : 0 ≤ exactRevealMass G n D seed history := by unfold exactRevealMass apply Finset.sum_nonneg intro q _ split · exact exactPriorQuestionWeight_nonneg G n q · exact le_rfl theorem exactRevealMass_sum (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : (∑ history : ExactRevealHistory X Y D seed, exactRevealMass G n D seed history) = 1 := by classical unfold exactRevealMass rw [Finset.sum_comm] simp_rw [Fintype.sum_ite_eq] exact exactPriorQuestionWeight_sum G n def exactAliceQuestionMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) : ℝ := ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then exactPriorQuestionWeight G n q else 0 def exactBobQuestionMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (y : Y) : ℝ := ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q else 0 def exactJointQuestionMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) : ℝ := ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q else 0 theorem exactAliceQuestionMass_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) : 0 ≤ exactAliceQuestionMass G n D seed history x := by unfold exactAliceQuestionMass apply Finset.sum_nonneg intro q _ split · exact exactPriorQuestionWeight_nonneg G n q · exact le_rfl theorem exactBobQuestionMass_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (y : Y) : 0 ≤ exactBobQuestionMass G n D seed history y := by unfold exactBobQuestionMass apply Finset.sum_nonneg intro q _ split · exact exactPriorQuestionWeight_nonneg G n q · exact le_rfl def exactAliceQuestionFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) : Matrix S.Alice S.Alice ℂ := ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then (exactPriorQuestionWeight G n q / exactAliceQuestionMass G n D seed history x) • conditionedAliceEffect G n S D answer q.1 else 0 def exactBobQuestionFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (y : Y) : Matrix S.Bob S.Bob ℂ := ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then (exactPriorQuestionWeight G n q / exactBobQuestionMass G n D seed history y) • conditionedBobEffect G n S D answer q.2 else 0 theorem exactAliceQuestionFilter_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) : (exactAliceQuestionFilter G n S D seed history answer x).PosSemidef := by unfold exactAliceQuestionFilter apply Matrix.posSemidef_sum Finset.univ intro q _ split · exact (conditionedAliceEffect_positive G n S D answer q.1).smul (div_nonneg (exactPriorQuestionWeight_nonneg G n q) (exactAliceQuestionMass_nonneg G n D seed history x)) · exact Matrix.PosSemidef.zero theorem exactBobQuestionFilter_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (y : Y) : (exactBobQuestionFilter G n S D seed history answer y).PosSemidef := by unfold exactBobQuestionFilter apply Matrix.posSemidef_sum Finset.univ intro q _ split · exact (conditionedBobEffect_positive G n S D answer q.2).smul (div_nonneg (exactPriorQuestionWeight_nonneg G n q) (exactBobQuestionMass_nonneg G n D seed history y)) · exact Matrix.PosSemidef.zero def exactAliceMeanFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (y : Y) : Matrix S.Alice S.Alice ℂ := ∑ x : X, G.conditionalXGivenY y x • exactAliceQuestionFilter G n S D seed history answer x def exactBobMeanFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (x : X) : Matrix S.Bob S.Bob ℂ := ∑ y : Y, G.conditionalYGivenX x y • exactBobQuestionFilter G n S D seed history answer y theorem exactAliceMeanFilter_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (y : Y) : (exactAliceMeanFilter G n S D seed history answer y).PosSemidef := by unfold exactAliceMeanFilter apply Matrix.posSemidef_sum Finset.univ intro x _ exact (exactAliceQuestionFilter_posSemidef G n S D seed history answer x).smul (G.conditionalXGivenY_nonneg y x) theorem exactBobMeanFilter_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (x : X) : (exactBobMeanFilter G n S D seed history answer x).PosSemidef := by unfold exactBobMeanFilter apply Matrix.posSemidef_sum Finset.univ intro y _ exact (exactBobQuestionFilter_posSemidef G n S D seed history answer y).smul (G.conditionalYGivenX_nonneg x y) def exactAliceCoordinateFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) (a : A) : Matrix S.Alice S.Alice ℂ := ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then (exactPriorQuestionWeight G n q / exactAliceQuestionMass G n D seed history x) • conditionedAliceCoordinateEffect G n S D answer q.1 seed.coordinate.val a else 0 def exactBobCoordinateFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (y : Y) (b : B) : Matrix S.Bob S.Bob ℂ := ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then (exactPriorQuestionWeight G n q / exactBobQuestionMass G n D seed history y) • conditionedBobCoordinateEffect G n S D answer q.2 seed.coordinate.val b else 0 theorem exactAliceCoordinateFilter_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) (a : A) : (exactAliceCoordinateFilter G n S D seed history answer x a).PosSemidef := by unfold exactAliceCoordinateFilter apply Matrix.posSemidef_sum Finset.univ intro q _ split · exact (conditionedAliceCoordinateEffect_posSemidef G n S D answer q.1 seed.coordinate.val a).smul (div_nonneg (exactPriorQuestionWeight_nonneg G n q) (exactAliceQuestionMass_nonneg G n D seed history x)) · exact Matrix.PosSemidef.zero theorem exactBobCoordinateFilter_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (y : Y) (b : B) : (exactBobCoordinateFilter G n S D seed history answer y b).PosSemidef := by unfold exactBobCoordinateFilter apply Matrix.posSemidef_sum Finset.univ intro q _ split · exact (conditionedBobCoordinateEffect_posSemidef G n S D answer q.2 seed.coordinate.val b).smul (div_nonneg (exactPriorQuestionWeight_nonneg G n q) (exactBobQuestionMass_nonneg G n D seed history y)) · exact Matrix.PosSemidef.zero theorem exactAliceCoordinateFilter_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) : (∑ a : A, exactAliceCoordinateFilter G n S D seed history answer x a) = exactAliceQuestionFilter G n S D seed history answer x := by classical unfold exactAliceCoordinateFilter exactAliceQuestionFilter rw [Finset.sum_comm] apply Finset.sum_congr rfl intro q _ by_cases hq : exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x · simp [hq, ← Finset.smul_sum, conditionedAliceCoordinateEffect_sum] · simp [hq] theorem exactBobCoordinateFilter_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (y : Y) : (∑ b : B, exactBobCoordinateFilter G n S D seed history answer y b) = exactBobQuestionFilter G n S D seed history answer y := by classical unfold exactBobCoordinateFilter exactBobQuestionFilter rw [Finset.sum_comm] apply Finset.sum_congr rfl intro q _ by_cases hq : exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y · simp [hq, ← Finset.smul_sum, conditionedBobCoordinateEffect_sum] · simp [hq] def exactAlicePurificationFamily (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) : Sum X Y → Matrix S.Alice S.Alice ℂ := Sum.elim (exactAliceQuestionFilter G n S D seed history answer) (exactAliceMeanFilter G n S D seed history answer) def exactBobPurificationFamily (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) : Sum Y X → Matrix S.Bob S.Bob ℂ := Sum.elim (exactBobQuestionFilter G n S D seed history answer) (exactBobMeanFilter G n S D seed history answer) theorem exactAlicePurificationFamily_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (q : Sum X Y) : (exactAlicePurificationFamily G n S D seed history answer q).PosSemidef := by cases q with | inl x => exact exactAliceQuestionFilter_posSemidef G n S D seed history answer x | inr y => exact exactAliceMeanFilter_posSemidef G n S D seed history answer y theorem exactBobPurificationFamily_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (q : Sum Y X) : (exactBobPurificationFamily G n S D seed history answer q).PosSemidef := by cases q with | inl y => exact exactBobQuestionFilter_posSemidef G n S D seed history answer y | inr x => exact exactBobMeanFilter_posSemidef G n S D seed history answer x abbrev ExactAliceLiftIndex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) := S.Alice × Fin (Module.finrank ℂ (commonPurificationSubspace (exactAlicePurificationFamily G n S D seed history answer) (0 : Matrix S.Alice S.Alice ℂ) (exactAlicePurificationFamily_posSemidef G n S D seed history answer) Matrix.PosSemidef.zero)) abbrev ExactBobLiftIndex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) := S.Bob × Fin (Module.finrank ℂ (commonPurificationSubspace (exactBobPurificationFamily G n S D seed history answer) (0 : Matrix S.Bob S.Bob ℂ) (exactBobPurificationFamily_posSemidef G n S D seed history answer) Matrix.PosSemidef.zero)) def exactAlicePurificationMatrix (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (q : Sum X Y) : Matrix (ExactAliceLiftIndex G n S D seed history answer) S.Alice ℂ := finitePurificationMatrix (exactAlicePurificationFamily G n S D seed history answer) 0 (exactAlicePurificationFamily_posSemidef G n S D seed history answer) Matrix.PosSemidef.zero q def exactBobPurificationMatrix (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (q : Sum Y X) : Matrix (ExactBobLiftIndex G n S D seed history answer) S.Bob ℂ := finitePurificationMatrix (exactBobPurificationFamily G n S D seed history answer) 0 (exactBobPurificationFamily_posSemidef G n S D seed history answer) Matrix.PosSemidef.zero q theorem exactAlicePurificationMatrix_gram (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (q : Sum X Y) : (exactAlicePurificationMatrix G n S D seed history answer q).conjTranspose * exactAlicePurificationMatrix G n S D seed history answer q = exactAlicePurificationFamily G n S D seed history answer q := finitePurificationMatrix_gram (exactAlicePurificationFamily G n S D seed history answer) 0 (exactAlicePurificationFamily_posSemidef G n S D seed history answer) Matrix.PosSemidef.zero q theorem exactBobPurificationMatrix_gram (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (q : Sum Y X) : (exactBobPurificationMatrix G n S D seed history answer q).conjTranspose * exactBobPurificationMatrix G n S D seed history answer q = exactBobPurificationFamily G n S D seed history answer q := finitePurificationMatrix_gram (exactBobPurificationFamily G n S D seed history answer) 0 (exactBobPurificationFamily_posSemidef G n S D seed history answer) Matrix.PosSemidef.zero q @[ext (iff := false)] structure ExactHistoryFlag (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) where seed : ExactRemainingSeed D history : ExactRevealHistory X Y D seed aliceAnswer : {j : Fin n // j ∈ D} → A bobAnswer : {j : Fin n // j ∈ D} → B abbrev ExactHistoryFlagTuple (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) := Σ seed : ExactRemainingSeed D, ExactRevealHistory X Y D seed × ({j : Fin n // j ∈ D} → A) × ({j : Fin n // j ∈ D} → B) def exactHistoryFlagEquiv {n : ℕ} (D : Finset (Fin n)) : ExactHistoryFlag X Y A B D ≃ ExactHistoryFlagTuple X Y A B D where toFun r := ⟨r.seed, r.history, r.aliceAnswer, r.bobAnswer⟩ invFun t := ⟨t.1, t.2.1, t.2.2.1, t.2.2.2⟩ left_inv r := by cases r; rfl right_inv t := by rcases t with ⟨seed, history, aliceAnswer, bobAnswer⟩ rfl noncomputable instance exactHistoryFlagFintype {n : ℕ} (D : Finset (Fin n)) : Fintype (ExactHistoryFlag X Y A B D) := by classical exact Fintype.ofEquiv (ExactHistoryFlagTuple X Y A B D) (exactHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm theorem exactHistoryFlag_sum {n : ℕ} (D : Finset (Fin n)) (f : ExactHistoryFlag X Y A B D → ℝ) : (∑ r : ExactHistoryFlag X Y A B D, f r) = ∑ seed : ExactRemainingSeed D, ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, f ⟨seed, history, aliceAnswer, bobAnswer⟩ := by classical calc (∑ r : ExactHistoryFlag X Y A B D, f r) = ∑ t : ExactHistoryFlagTuple X Y A B D, f ((exactHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) := ((exactHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm.sum_comp f).symm _ = _ := by simp [Fintype.sum_sigma, Fintype.sum_prod_type, exactHistoryFlagEquiv] abbrev ExactAliceLocalIndex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) := ExactAliceLiftIndex G n S D r.seed r.history r.aliceAnswer × (S.Alice × S.Bob) abbrev ExactBobLocalIndex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) := ExactBobLiftIndex G n S D r.seed r.history r.bobAnswer def exactUnnormalizedPsi (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) := finiteLocalPurificationVector S (exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x)) (exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y)) def exactUnnormalizedPhi (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (y : Y) : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) := finiteLocalPurificationVector S (exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inr y)) (exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y)) def exactUnnormalizedGamma (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) := finiteLocalPurificationVector S (exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x)) (exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inr x)) theorem exactUnnormalizedPsi_norm_sq (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 = bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by unfold exactUnnormalizedPsi rw [finiteLocalPurificationVector_norm_sq, exactAlicePurificationMatrix_gram, exactBobPurificationMatrix_gram] rfl theorem exactAliceQuestionPurificationMatrix_gram (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) : (exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x)).conjTranspose * exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x) = exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x := exactAlicePurificationMatrix_gram G n S D r.seed r.history r.aliceAnswer (.inl x) theorem exactBobQuestionPurificationMatrix_gram (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (y : Y) : (exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y)).conjTranspose * exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y) = exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y := exactBobPurificationMatrix_gram G n S D r.seed r.history r.bobAnswer (.inl y) def exactAliceRefinedPOVM [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (x : X) : POVM A (ExactAliceLiftIndex G n S D r.seed r.history r.aliceAnswer) := purifiedRefinedPOVM (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactAliceQuestionFilter_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x)) (exactAliceQuestionPurificationMatrix_gram G n S D r x) (exactAliceCoordinateFilter G n S D r.seed r.history r.aliceAnswer x) (exactAliceCoordinateFilter_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactAliceCoordinateFilter_sum G n S D r.seed r.history r.aliceAnswer x) a₀ def exactBobRefinedPOVM [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (b₀ : B) (y : Y) : POVM B (ExactBobLiftIndex G n S D r.seed r.history r.bobAnswer) := purifiedRefinedPOVM (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) (exactBobQuestionFilter_posSemidef G n S D r.seed r.history r.bobAnswer y) (exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y)) (exactBobQuestionPurificationMatrix_gram G n S D r y) (exactBobCoordinateFilter G n S D r.seed r.history r.bobAnswer y) (exactBobCoordinateFilter_posSemidef G n S D r.seed r.history r.bobAnswer y) (exactBobCoordinateFilter_sum G n S D r.seed r.history r.bobAnswer y) b₀ theorem exactAliceRefinedPOVM_compression [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (x : X) (a : A) : (exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x)).conjTranspose * (exactAliceRefinedPOVM G n S D r a₀ x).effect a * exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x) = exactAliceCoordinateFilter G n S D r.seed r.history r.aliceAnswer x a := by exact purifiedRefinedPOVM_compression (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactAliceQuestionFilter_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x)) (exactAliceQuestionPurificationMatrix_gram G n S D r x) (exactAliceCoordinateFilter G n S D r.seed r.history r.aliceAnswer x) (exactAliceCoordinateFilter_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactAliceCoordinateFilter_sum G n S D r.seed r.history r.aliceAnswer x) a₀ a theorem exactBobRefinedPOVM_compression [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (b₀ : B) (y : Y) (b : B) : (exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y)).conjTranspose * (exactBobRefinedPOVM G n S D r b₀ y).effect b * exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y) = exactBobCoordinateFilter G n S D r.seed r.history r.bobAnswer y b := by exact purifiedRefinedPOVM_compression (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) (exactBobQuestionFilter_posSemidef G n S D r.seed r.history r.bobAnswer y) (exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y)) (exactBobQuestionPurificationMatrix_gram G n S D r y) (exactBobCoordinateFilter G n S D r.seed r.history r.bobAnswer y) (exactBobCoordinateFilter_posSemidef G n S D r.seed r.history r.bobAnswer y) (exactBobCoordinateFilter_sum G n S D r.seed r.history r.bobAnswer y) b₀ b theorem exactRefinedPOVM_quadratic [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) (a : A) (b : B) : quadraticExpectation (Matrix.toEuclideanCLM (n := ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) (𝕜 := ℂ) (((exactAliceRefinedPOVM G n S D r a₀ x).effect a ⊗ₖ (1 : Matrix (S.Alice × S.Bob) (S.Alice × S.Bob) ℂ)) ⊗ₖ (exactBobRefinedPOVM G n S D r b₀ y).effect b)) (exactUnnormalizedPsi G n S D r x y) = bornTracePairing S.state.matrix (exactAliceCoordinateFilter G n S D r.seed r.history r.aliceAnswer x a) (exactBobCoordinateFilter G n S D r.seed r.history r.bobAnswer y b) := by unfold exactUnnormalizedPsi rw [finiteLocalPurificationVector_quadratic, exactAliceRefinedPOVM_compression, exactBobRefinedPOVM_compression] abbrev ExactPaddedLocalIndex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) := PUnit.{1} ⊕ (ExactAliceLocalIndex G n S D r ⊕ ExactBobLocalIndex G n S D r) def exactPaddedVector (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (z : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r)) : EuclideanSpace ℂ (ExactPaddedLocalIndex G n S D r × ExactPaddedLocalIndex G n S D r) := toLp 2 fun q => match q.1, q.2 with | .inr (.inl a), .inr (.inr b) => z (a, b) | _, _ => 0 theorem exactPaddedVector_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (z : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r)) : ‖exactPaddedVector G n S D r z‖ = ‖z‖ := by classical have hsquare : ‖exactPaddedVector G n S D r z‖ ^ 2 = ‖z‖ ^ 2 := by simp [EuclideanSpace.norm_sq_eq, exactPaddedVector, Fintype.sum_prod_type, Fintype.sum_sum_type] nlinarith [norm_nonneg (exactPaddedVector G n S D r z), norm_nonneg z] theorem exactPaddedVector_sub (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (u v : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r)) : exactPaddedVector G n S D r (u - v) = exactPaddedVector G n S D r u - exactPaddedVector G n S D r v := by classical ext q rcases q with ⟨a, b⟩ rcases a with a | (a | a) <;> rcases b with b | (b | b) <;> simp [exactPaddedVector] def exactPaddedDefault (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : EuclideanSpace ℂ (ExactPaddedLocalIndex G n S D r × ExactPaddedLocalIndex G n S D r) := by classical exact PiLp.single 2 (.inl PUnit.unit, .inl PUnit.unit) (1 : ℂ) theorem exactPaddedDefault_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ‖exactPaddedDefault G n S D r‖ = 1 := by classical simp [exactPaddedDefault] def exactPsi (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : EuclideanSpace ℂ (ExactPaddedLocalIndex G n S D r × ExactPaddedLocalIndex G n S D r) := normalizeOrDefault (exactPaddedDefault G n S D r) (exactPaddedVector G n S D r (exactUnnormalizedPsi G n S D r x y)) def exactPhi (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (y : Y) : EuclideanSpace ℂ (ExactPaddedLocalIndex G n S D r × ExactPaddedLocalIndex G n S D r) := normalizeOrDefault (exactPaddedDefault G n S D r) (exactPaddedVector G n S D r (exactUnnormalizedPhi G n S D r y)) def exactGamma (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) : EuclideanSpace ℂ (ExactPaddedLocalIndex G n S D r × ExactPaddedLocalIndex G n S D r) := normalizeOrDefault (exactPaddedDefault G n S D r) (exactPaddedVector G n S D r (exactUnnormalizedGamma G n S D r x)) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1200000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactAliceQuestionCompatible {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (xs : Fin n → X) : Prop := (∀ j : {j : Fin n // j ∈ D}, xs j.val = history.aliceConditioned j) ∧ (∀ j : {j : SourceRemainingCoordinate D // j ∈ exactLeft seed.coordinate seed.partition}, xs j.val.val = history.aliceLeft j) ∧ (∀ j : {j : SourceRemainingCoordinate D // j ∈ exactRightPrefix seed}, xs j.val.val = history.aliceRightPrefix j) ∧ xs seed.coordinate.val = x def exactBobQuestionCompatible {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (y : Y) (ys : Fin n → Y) : Prop := (∀ j : {j : Fin n // j ∈ D}, ys j.val = history.bobConditioned j) ∧ (∀ j : {j : SourceRemainingCoordinate D // j ∈ exactRight seed.coordinate seed.partition}, ys j.val.val = history.bobRight j) ∧ (∀ j : {j : SourceRemainingCoordinate D // j ∈ exactLeftPrefix seed}, ys j.val.val = history.bobLeftPrefix j) ∧ ys seed.coordinate.val = y theorem exactRevealCode_compatible_iff {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs : Fin n → X) (ys : Fin n → Y) : (exactRevealCode D seed (xs, ys) = history ∧ xs seed.coordinate.val = x ∧ ys seed.coordinate.val = y) ↔ exactAliceQuestionCompatible D seed history x xs ∧ exactBobQuestionCompatible D seed history y ys := by constructor · rintro ⟨h, hx, hy⟩ subst history exact ⟨⟨fun _ => rfl, fun _ => rfl, fun _ => rfl, hx⟩, ⟨fun _ => rfl, fun _ => rfl, fun _ => rfl, hy⟩⟩ · rintro ⟨⟨hxc, hxl, hxr, hx⟩, ⟨hyc, hyr, hyl, hy⟩⟩ refine ⟨?_, hx, hy⟩ cases history with | mk ac bc al br bl ar => have hac : (fun j : {j : Fin n // j ∈ D} => xs j.val) = ac := funext hxc have hbc : (fun j : {j : Fin n // j ∈ D} => ys j.val) = bc := funext hyc have hal : (fun j : {j : SourceRemainingCoordinate D // j ∈ exactLeft seed.coordinate seed.partition} => xs j.val.val) = al := funext hxl have hbr : (fun j : {j : SourceRemainingCoordinate D // j ∈ exactRight seed.coordinate seed.partition} => ys j.val.val) = br := funext hyr have hbl : (fun j : {j : SourceRemainingCoordinate D // j ∈ exactLeftPrefix seed} => ys j.val.val) = bl := funext hyl have har : (fun j : {j : SourceRemainingCoordinate D // j ∈ exactRightPrefix seed} => xs j.val.val) = ar := funext hxr cases hac cases hbc cases hal cases hbr cases hbl cases har rfl theorem exactCompatible_coordinate_eq_or {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) (ha : exactAliceQuestionCompatible D seed history x xs) (ha' : exactAliceQuestionCompatible D seed history x xs') (hb : exactBobQuestionCompatible D seed history y ys) (hb' : exactBobQuestionCompatible D seed history y ys') (j : Fin n) : xs j = xs' j ∨ ys j = ys' j := by by_cases hj : j ∈ D · left exact (ha.1 ⟨j, hj⟩).trans (ha'.1 ⟨j, hj⟩).symm · let jr : SourceRemainingCoordinate D := ⟨j, by simp [hj]⟩ by_cases hcoordinate : jr = seed.coordinate · left have hval : j = seed.coordinate.val := congrArg Subtype.val hcoordinate rw [hval] exact ha.2.2.2.trans ha'.2.2.2.symm · cases hbit : seed.partition jr with | false => left have hleft : jr ∈ exactLeft seed.coordinate seed.partition := by simp [exactLeft, hcoordinate, hbit] exact (ha.2.1 ⟨jr, hleft⟩).trans (ha'.2.1 ⟨jr, hleft⟩).symm | true => right have hright : jr ∈ exactRight seed.coordinate seed.partition := by simp [exactRight, hcoordinate, hbit] exact (hb.2.1 ⟨jr, hright⟩).trans (hb'.2.1 ⟨jr, hright⟩).symm theorem exactQuestionWeight_rectangle (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) (ha : exactAliceQuestionCompatible D seed history x xs) (ha' : exactAliceQuestionCompatible D seed history x xs') (hb : exactBobQuestionCompatible D seed history y ys) (hb' : exactBobQuestionCompatible D seed history y ys') : (G.repeat n).questionWeight xs ys * (G.repeat n).questionWeight xs' ys' = (G.repeat n).questionWeight xs ys' * (G.repeat n).questionWeight xs' ys := by simp only [Game.repeat_questionWeight] rw [← Finset.prod_mul_distrib, ← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro j _ rcases exactCompatible_coordinate_eq_or D seed history x y xs xs' ys ys' ha ha' hb hb' j with hAlice | hBob · simp [hAlice, mul_comm] · simp [hBob] def exactFiberQuestionWeight (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs : Fin n → X) (ys : Fin n → Y) : ℝ := if exactAliceQuestionCompatible D seed history x xs ∧ exactBobQuestionCompatible D seed history y ys then (G.repeat n).questionWeight xs ys else 0 theorem exactFiberQuestionWeight_rectangle (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) : exactFiberQuestionWeight G n D seed history x y xs ys * exactFiberQuestionWeight G n D seed history x y xs' ys' = exactFiberQuestionWeight G n D seed history x y xs ys' * exactFiberQuestionWeight G n D seed history x y xs' ys := by classical by_cases ha : exactAliceQuestionCompatible D seed history x xs <;> by_cases ha' : exactAliceQuestionCompatible D seed history x xs' <;> by_cases hb : exactBobQuestionCompatible D seed history y ys <;> by_cases hb' : exactBobQuestionCompatible D seed history y ys' <;> simp [exactFiberQuestionWeight, ha, ha', hb, hb'] simpa only [Game.repeat_questionWeight] using (exactQuestionWeight_rectangle G n D seed history x y xs xs' ys ys' ha ha' hb hb') def exactFiberAliceMarginal (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs : Fin n → X) : ℝ := ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xs ys def exactFiberBobMarginal (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (ys : Fin n → Y) : ℝ := ∑ xs : Fin n → X, exactFiberQuestionWeight G n D seed history x y xs ys def exactFiberQuestionMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) : ℝ := ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xs ys theorem exactFiberQuestionWeight_mul_mass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs : Fin n → X) (ys : Fin n → Y) : exactFiberQuestionWeight G n D seed history x y xs ys * exactFiberQuestionMass G n D seed history x y = exactFiberAliceMarginal G n D seed history x y xs * exactFiberBobMarginal G n D seed history x y ys := by classical symm calc exactFiberAliceMarginal G n D seed history x y xs * exactFiberBobMarginal G n D seed history x y ys = ∑ u : Fin n → Y, ∑ v : Fin n → X, exactFiberQuestionWeight G n D seed history x y xs u * exactFiberQuestionWeight G n D seed history x y v ys := by unfold exactFiberAliceMarginal exactFiberBobMarginal rw [Finset.sum_mul] apply Finset.sum_congr rfl intro u _ rw [Finset.mul_sum] _ = ∑ u : Fin n → Y, ∑ v : Fin n → X, exactFiberQuestionWeight G n D seed history x y xs ys * exactFiberQuestionWeight G n D seed history x y v u := by apply Finset.sum_congr rfl intro u _ apply Finset.sum_congr rfl intro v _ exact exactFiberQuestionWeight_rectangle G n D seed history x y xs v u ys _ = ∑ v : Fin n → X, ∑ u : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xs ys * exactFiberQuestionWeight G n D seed history x y v u := by rw [Finset.sum_comm] _ = exactFiberQuestionWeight G n D seed history x y xs ys * exactFiberQuestionMass G n D seed history x y := by unfold exactFiberQuestionMass simp only [Finset.mul_sum] end noncomputable section open scoped BigOperators set_option maxHeartbeats 1200000 attribute [local instance] Classical.propDecidable theorem exactFintypeCard_eq {T : Type*} (first second : Fintype T) : @Fintype.card T first = @Fintype.card T second := @Fintype.card_congr T T first second (Equiv.refl T) theorem exactSeedWeight_sum {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) : (∑ seed : ExactForwardSeed M, exactSeedWeight seed) = 1 := by classical have hbits : 0 < Fintype.card (M → Bool) := Fintype.card_pos_iff.mpr ⟨fun _ => false⟩ rw [exactForwardSeed_sum] conv_rhs => rw [← exactUniform_sum nonempty] apply Finset.sum_congr (by ext; simp) intro coordinate _ conv_rhs => rw [← exactUniform_sum_mul hbits (1 / (Fintype.card M : ℝ))] apply Finset.sum_congr (by ext; simp) intro partition _ letI : DecidableEq {j : M // j ∈ exactLeft coordinate partition} := fun a b => Classical.propDecidable (a = b) letI : DecidableEq {j : M // j ∈ exactRight coordinate partition} := fun a b => Classical.propDecidable (a = b) conv_rhs => rw [← exactPermutationUniform_sum_mul (T := {j : M // j ∈ exactLeft coordinate partition}) ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)))] apply Finset.sum_congr (by ext; simp) intro leftOrder _ conv_rhs => rw [← exactPermutationUniform_sum_mul (T := {j : M // j ∈ exactRight coordinate partition}) ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}) : ℝ)))] apply Finset.sum_congr (by ext; simp) intro rightOrder _ conv_rhs => rw [← exactPrefixUniform_sum_mul (exactLeft coordinate partition).card ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactRight coordinate partition}) : ℝ)))] apply Finset.sum_congr (by ext; simp) intro leftCut _ conv_rhs => rw [← exactPrefixUniform_sum_mul (exactRight coordinate partition).card ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactRight coordinate partition}) : ℝ)) * (1 / ((exactLeft coordinate partition).card + 1 : ℝ)))] apply Finset.sum_congr (by ext; simp) intro rightCut _ simp only [exactSeedWeight] congr 2 congr 3 · apply congrArg (fun k : ℕ => (k : ℝ)) exact exactFintypeCard_eq _ _ · exact exactFintypeCard_eq _ _ end noncomputable section open scoped BigOperators def HasExponentialBound (v : ℕ → ℝ) : Prop := ∃ c : ℝ, 0 < c ∧ ∃ C : ℝ, 0 < C ∧ ∀ n : ℕ, v n ≤ C * Real.exp (-c * (n : ℝ)) def HasSubexponentialWitness (v : ℕ → ℝ) : Prop := ∀ c : ℝ, 0 < c → ∀ C : ℝ, 0 < C → ∃ n : ℕ, C * Real.exp (-c * (n : ℝ)) < v n theorem not_hasExponentialBound_iff (v : ℕ → ℝ) : ¬ HasExponentialBound v ↔ HasSubexponentialWitness v := by simp [HasExponentialBound, HasSubexponentialWitness] theorem arbitrarily_large_witness_of_not_hasExponentialBound {v : ℕ → ℝ} (hv : ∀ n : ℕ, v n ≤ 1) (h_no_bound : ¬ HasExponentialBound v) {c : ℝ} (hc : 0 < c) (N : ℕ) : ∃ n : ℕ, N < n ∧ Real.exp (-c * (n : ℝ)) < v n := by have h_witness := (not_hasExponentialBound_iff v).mp h_no_bound obtain ⟨n, hn⟩ := h_witness c hc (Real.exp (c * (N : ℝ))) (Real.exp_pos _) have hN : N < n := by by_contra h_not have hnN : n ≤ N := Nat.le_of_not_gt h_not have hnN_real : (n : ℝ) ≤ (N : ℝ) := by exact_mod_cast hnN have h_nonneg : 0 ≤ c * ((N : ℝ) - (n : ℝ)) := mul_nonneg hc.le (sub_nonneg.mpr hnN_real) have h_lower : 1 ≤ Real.exp (c * (N : ℝ)) * Real.exp (-c * (n : ℝ)) := by calc 1 ≤ Real.exp (c * ((N : ℝ) - (n : ℝ))) := Real.one_le_exp h_nonneg _ = Real.exp (c * (N : ℝ)) * Real.exp (-c * (n : ℝ)) := by rw [← Real.exp_add] congr 1 ring linarith [hv n] refine ⟨n, hN, ?_⟩ have h_prefactor : 1 ≤ Real.exp (c * (N : ℝ)) := Real.one_le_exp (mul_nonneg hc.le (Nat.cast_nonneg _)) calc Real.exp (-c * (n : ℝ)) = 1 * Real.exp (-c * (n : ℝ)) := by rw [one_mul] _ ≤ Real.exp (c * (N : ℝ)) * Real.exp (-c * (n : ℝ)) := mul_le_mul_of_nonneg_right h_prefactor (Real.exp_pos _).le _ < v n := hn end noncomputable section open scoped BigOperators variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def StandardQuantumParallelRepetition (G : Game X Y A B) : Prop := entangledValue G < 1 → HasExponentialBound (repeatedEntangledValue G) end noncomputable section open scoped BigOperators open QuantumParallelRepetition.Pinsker theorem sum_positive_difference_eq_totalVariation {ι : Type*} [Fintype ι] (p q : ι → ℝ) (hp : (∑ i, p i) = 1) (hq : (∑ i, q i) = 1) : (∑ i, max (p i - q i) 0) = finiteTotalVariation p q := by classical have hpoint (x : ℝ) : max x 0 = (|x| + x) / 2 := by by_cases hx : 0 ≤ x · rw [max_eq_left hx, abs_of_nonneg hx] ring · have hxneg : x < 0 := lt_of_not_ge hx rw [max_eq_right hxneg.le, abs_of_neg hxneg] ring have hzero : (∑ i, (p i - q i)) = 0 := by rw [Finset.sum_sub_distrib, hp, hq, sub_self] unfold finiteTotalVariation simp_rw [hpoint] rw [← Finset.sum_div, Finset.sum_add_distrib, hzero, add_zero] theorem finiteTotalVariation_comm {ι : Type*} [Fintype ι] (p q : ι → ℝ) : finiteTotalVariation p q = finiteTotalVariation q p := by unfold finiteTotalVariation congr 1 apply Finset.sum_congr rfl intro i _ exact abs_sub_comm (p i) (q i) theorem expectation_le_add_totalVariation {ι : Type*} [Fintype ι] (p q f : ι → ℝ) (hp : (∑ i, p i) = 1) (hq : (∑ i, q i) = 1) (U : ℝ) (hfzero : ∀ i, 0 ≤ f i) (hfupper : ∀ i, f i ≤ U) : (∑ i, p i * f i) ≤ (∑ i, q i * f i) + U * finiteTotalVariation p q := by classical have hterm (i : ι) : (p i - q i) * f i ≤ U * max (p i - q i) 0 := by by_cases hi : 0 ≤ p i - q i · rw [max_eq_left hi] nlinarith [mul_nonneg hi (sub_nonneg.mpr (hfupper i))] · have hineg : p i - q i < 0 := lt_of_not_ge hi rw [max_eq_right hineg.le] simp only [mul_zero] exact mul_nonpos_of_nonpos_of_nonneg hineg.le (hfzero i) have hsum := Finset.sum_le_sum (fun i (_ : i ∈ Finset.univ) => hterm i) have hpositive := sum_positive_difference_eq_totalVariation p q hp hq calc (∑ i, p i * f i) = (∑ i, q i * f i) + ∑ i, (p i - q i) * f i := by rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i _ ring _ ≤ (∑ i, q i * f i) + ∑ i, U * max (p i - q i) 0 := by linarith _ = (∑ i, q i * f i) + U * finiteTotalVariation p q := by rw [← Finset.mul_sum, hpositive] theorem winning_expectation_transfer {ι : Type*} [Fintype ι] (p q win : ι → ℝ) (hp : (∑ i, p i) = 1) (hq : (∑ i, q i) = 1) (hzero : ∀ i, 0 ≤ win i) (hone : ∀ i, win i ≤ 1) : (∑ i, q i * win i) - finiteTotalVariation p q ≤ ∑ i, p i * win i := by have h := expectation_le_add_totalVariation q p win hq hp (1 : ℝ) hzero hone rw [← finiteTotalVariation_comm p q] at h norm_num at h ⊢ linarith end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace section ActualSharedFlag variable {X Y A B dA dB J : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] variable [Fintype J] [DecidableEq J] def pureVerifierEffect (G : Game X Y A B) (z : EuclideanSpace ℂ (dA × dB)) (hz : ‖z‖ = 1) (PA : X → POVM A dA) (PB : Y → POVM B dB) (x : X) (y : Y) : Matrix (dA × dB) (dA × dB) ℂ := (pureVectorStrategy G z hz PA PB).winningEffect x y theorem pureVectorWinningProbability_eq (G : Game X Y A B) (z : EuclideanSpace ℂ (dA × dB)) (hz : ‖z‖ = 1) (PA : X → POVM A dA) (PB : Y → POVM B dB) : (pureVectorStrategy G z hz PA PB).winProbability = ∑ x : X, ∑ y : Y, G.questionWeight x y * quadraticExpectation (Matrix.toEuclideanCLM (n := dA × dB) (𝕜 := ℂ) (pureVerifierEffect G z hz PA PB x y)) z := by classical rw [(pureVectorStrategy G z hz PA PB).winProbability_eq_winningEffect_born] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ congr 1 exact pureDensityMatrix_trace_mul z hz (pureVerifierEffect G z hz PA PB x y) def flaggedQuestionWeight (G : Game X Y A B) (flagWeight : J → ℝ) (ω : J × (X × Y)) : ℝ := flagWeight ω.1 * G.questionWeight ω.2.1 ω.2.2 omit [Fintype J] [DecidableEq J] in theorem flaggedQuestionWeight_nonneg (G : Game X Y A B) (flagWeight : J → ℝ) (nonnegative : ∀ j, 0 ≤ flagWeight j) (ω : J × (X × Y)) : 0 ≤ flaggedQuestionWeight G flagWeight ω := mul_nonneg (nonnegative ω.1) (G.weight_nonneg ω.2.1 ω.2.2) omit [DecidableEq J] in theorem flaggedQuestionWeight_sum (G : Game X Y A B) (flagWeight : J → ℝ) (normalized : (∑ j, flagWeight j) = 1) : (∑ ω : J × (X × Y), flaggedQuestionWeight G flagWeight ω) = 1 := by classical simp [flaggedQuestionWeight, Fintype.sum_prod_type, ← Finset.mul_sum, G.weight_normalized, normalized] end ActualSharedFlag end noncomputable section open Filter open scoped Topology def universalErrorCeiling (K₀ : ℝ) : ℝ := K₀ * (1 + (2 : ℝ) ^ (1 / 6 : ℝ)) + 2 def totalSamplingLoss (K₀ α η lam : ℝ) : ℝ := 5 * lam + 2 * (K₀ * (α ^ (1 / 12 : ℝ) + (32 * η) ^ (1 / 12 : ℝ)) + Real.sqrt (8 * η) + universalErrorCeiling K₀ * lam) def roundedWinningLowerBound (ε K₀ α η lam : ℝ) : ℝ := 1 - ε / 2 - totalSamplingLoss K₀ α η lam theorem totalSamplingLoss_tendsto_zero {ι : Type*} {l : Filter ι} (K₀ : ℝ) {α η lam : ι → ℝ} (hα : Tendsto α l (𝓝 0)) (hη : Tendsto η l (𝓝 0)) (hlam : Tendsto lam l (𝓝 0)) : Tendsto (fun i => totalSamplingLoss K₀ (α i) (η i) (lam i)) l (𝓝 0) := by have hαroot : Tendsto (fun i => (α i) ^ (1 / 12 : ℝ)) l (𝓝 0) := hα.rpow_const_nhds_zero (by norm_num) have hηscaled : Tendsto (fun i => 32 * η i) l (𝓝 0) := by simpa using hη.const_mul (32 : ℝ) have hηroot : Tendsto (fun i => (32 * η i) ^ (1 / 12 : ℝ)) l (𝓝 0) := hηscaled.rpow_const_nhds_zero (by norm_num) have hηeight : Tendsto (fun i => 8 * η i) l (𝓝 0) := by simpa using hη.const_mul (8 : ℝ) have hsqrt : Tendsto (fun i => Real.sqrt (8 * η i)) l (𝓝 0) := by simpa using hηeight.sqrt have hquantum : Tendsto (fun i => K₀ * ((α i) ^ (1 / 12 : ℝ) + (32 * η i) ^ (1 / 12 : ℝ))) l (𝓝 0) := by simpa using (hαroot.add hηroot).const_mul K₀ have hceiling : Tendsto (fun i => universalErrorCeiling K₀ * lam i) l (𝓝 0) := by simpa using hlam.const_mul (universalErrorCeiling K₀) have hinner : Tendsto (fun i => K₀ * ((α i) ^ (1 / 12 : ℝ) + (32 * η i) ^ (1 / 12 : ℝ)) + Real.sqrt (8 * η i) + universalErrorCeiling K₀ * lam i) l (𝓝 0) := by simpa using (hquantum.add hsqrt).add hceiling have hclassical : Tendsto (fun i => 5 * lam i) l (𝓝 0) := by simpa using hlam.const_mul (5 : ℝ) have hdouble : Tendsto (fun i => 2 * (K₀ * ((α i) ^ (1 / 12 : ℝ) + (32 * η i) ^ (1 / 12 : ℝ)) + Real.sqrt (8 * η i) + universalErrorCeiling K₀ * lam i)) l (𝓝 0) := by simpa using hinner.const_mul (2 : ℝ) simpa [totalSamplingLoss] using hclassical.add hdouble theorem totalSamplingLoss_eventually_lt {ι : Type*} {l : Filter ι} (K₀ : ℝ) {α η lam : ι → ℝ} (hα : Tendsto α l (𝓝 0)) (hη : Tendsto η l (𝓝 0)) (hlam : Tendsto lam l (𝓝 0)) {ε : ℝ} (hε : 0 < ε) : ∀ᶠ i in l, totalSamplingLoss K₀ (α i) (η i) (lam i) < ε := (totalSamplingLoss_tendsto_zero K₀ hα hη hlam).eventually (gt_mem_nhds hε) theorem source_equation_twenty_nine_contradiction {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (S : Strategy G) (K₀ α η lam : ℝ) (hbound : roundedWinningLowerBound (1 - entangledValue G) K₀ α η lam ≤ S.winProbability) (herror : totalSamplingLoss K₀ α η lam < (1 - entangledValue G) / 2) : False := by have hsup : S.winProbability ≤ entangledValue G := by unfold entangledValue exact le_csSup (winProbabilities_bddAbove G) ⟨S, rfl⟩ unfold roundedWinningLowerBound at hbound linarith end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem matched_payoff_discard_le {ι : Type*} [Fintype ι] (weight payoff : ι → ℝ) (nonnegative : ∀ i, 0 ≤ weight i) (payoff_le_one : ∀ i, payoff i ≤ 1) (matched : ι → Bool) : (∑ i, weight i * payoff i) - (∑ i, weight i * if matched i then 0 else 1) ≤ ∑ i, weight i * if matched i then payoff i else 0 := by classical rw [← Finset.sum_sub_distrib] apply Finset.sum_le_sum intro i _ by_cases hi : matched i = true · simp [hi] · have hone := payoff_le_one i simp only [Bool.not_eq_true] at hi simp [hi] nlinarith [mul_nonneg (nonnegative i) (sub_nonneg.mpr hone)] end noncomputable section open scoped BigOperators theorem squared_state_triangle {E : Type*} [NormedAddCommGroup E] (gamma psi phi : E) : ‖gamma - phi‖ ^ 2 ≤ 2 * (‖gamma - psi‖ ^ 2 + ‖psi - phi‖ ^ 2) := by have hsplit : gamma - phi = (gamma - psi) + (psi - phi) := by abel have htriangle : ‖gamma - phi‖ ≤ ‖gamma - psi‖ + ‖psi - phi‖ := by rw [hsplit] exact norm_add_le _ _ have hnonneg : 0 ≤ ‖gamma - phi‖ := norm_nonneg _ have ha : 0 ≤ ‖gamma - psi‖ := norm_nonneg _ have hb : 0 ≤ ‖psi - phi‖ := norm_nonneg _ nlinarith [sq_nonneg (‖gamma - psi‖ - ‖psi - phi‖)] theorem source_equation_twenty_one {ι E : Type*} [Fintype ι] [NormedAddCommGroup E] (weight : ι → ℝ) (nonnegative : ∀ i, 0 ≤ weight i) (gamma psi phi : ι → E) (η : ℝ) (hgamma : (∑ i, weight i * ‖gamma i - psi i‖ ^ 2) ≤ 8 * η) (hphi : (∑ i, weight i * ‖psi i - phi i‖ ^ 2) ≤ 8 * η) : (∑ i, weight i * ‖gamma i - phi i‖ ^ 2) ≤ 32 * η := by classical calc (∑ i, weight i * ‖gamma i - phi i‖ ^ 2) ≤ ∑ i, weight i * (2 * (‖gamma i - psi i‖ ^ 2 + ‖psi i - phi i‖ ^ 2)) := by apply Finset.sum_le_sum intro i _ exact mul_le_mul_of_nonneg_left (squared_state_triangle (gamma i) (psi i) (phi i)) (nonnegative i) _ = 2 * ((∑ i, weight i * ‖gamma i - psi i‖ ^ 2) + (∑ i, weight i * ‖psi i - phi i‖ ^ 2)) := by calc (∑ i, weight i * (2 * (‖gamma i - psi i‖ ^ 2 + ‖psi i - phi i‖ ^ 2))) = ∑ i, (2 * (weight i * ‖gamma i - psi i‖ ^ 2) + 2 * (weight i * ‖psi i - phi i‖ ^ 2)) := by apply Finset.sum_congr rfl intro i _ ring _ = _ := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] ring _ ≤ 32 * η := by linarith theorem weighted_rpow_mean_le {ι : Type*} [Fintype ι] (weight value : ι → ℝ) (nonnegative : ∀ i, 0 ≤ weight i) (normalized : (∑ i, weight i) = 1) (value_nonnegative : ∀ i, 0 ≤ value i) {r : ℝ} (hrzero : 0 ≤ r) (hrone : r ≤ 1) : (∑ i, weight i * value i ^ r) ≤ (∑ i, weight i * value i) ^ r := by classical simpa [smul_eq_mul] using (Real.concaveOn_rpow hrzero hrone).le_map_sum (t := Finset.univ) (w := weight) (p := value) (fun i _ => nonnegative i) normalized (fun i _ => value_nonnegative i) end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1500000 theorem fullHistoryRemaining_insert_conditioned {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) : fullHistoryRemaining n (insert i D) L = fullHistoryRemaining n D (insert i L) := by ext j simp only [fullHistoryRemaining, Finset.mem_sdiff, Finset.mem_univ, true_and, Finset.mem_insert] tauto def fullHistoryRemainingInsertedEquiv {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L} ≃ {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} := Equiv.subtypeEquivRight fun j => by rw [fullHistoryRemaining_insert_conditioned D L i] def fullCoordinateAnswerExtension {T : Type*} {n : ℕ} (D : Finset (Fin n)) (i : Fin n) (α : {j : Fin n // j ∈ D} → T) (a : T) : {j : Fin n // j ∈ insert i D} → T := by classical intro j by_cases hj : (j : Fin n) = i · exact a · exact α ⟨j, (Finset.mem_insert.mp j.property).resolve_left hj⟩ def fullCoordinateAnswerExtensionEquiv {T : Type*} [Fintype T] {n : ℕ} (D : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) : (({j : Fin n // j ∈ D} → T) × T) ≃ ({j : Fin n // j ∈ insert i D} → T) where toFun t := fullCoordinateAnswerExtension D i t.1 t.2 invFun α := (fun j => α ⟨j, Finset.mem_insert_of_mem j.property⟩, α ⟨i, Finset.mem_insert_self i D⟩) left_inv t := by rcases t with ⟨α, a⟩ apply Prod.ext · funext j have hj : (j : Fin n) ≠ i := by intro he exact hiD (he ▸ j.property) simp [fullCoordinateAnswerExtension, hj] · simp [fullCoordinateAnswerExtension] right_inv α := by funext j by_cases hj : (j : Fin n) = i · have hjsub : j = (⟨i, Finset.mem_insert_self i D⟩ : {j : Fin n // j ∈ insert i D}) := Subtype.ext hj subst j simp [fullCoordinateAnswerExtension] · simp [fullCoordinateAnswerExtension, hj] def fullCoordinateInsertedHistory {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) : FullSubsetHistory X Y n (insert i D) L := by classical refine ⟨ fullCoordinateAnswerExtension D i r.aliceConditioned x, fullCoordinateAnswerExtension D i r.bobConditioned y, r.aliceRevealed, fun j => r.bobRemaining ⟨j, ?_⟩⟩ rw [← fullHistoryRemaining_insert_conditioned D L i] exact j.property def fullCoordinateBaseOfInsertedHistory {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (h : FullSubsetHistory X Y n (insert i D) L) : FullCoordinateRevealHistory X Y n D L i := by refine ⟨ fun j => h.aliceConditioned ⟨j, Finset.mem_insert_of_mem j.property⟩, fun j => h.bobConditioned ⟨j, Finset.mem_insert_of_mem j.property⟩, h.aliceRevealed, fun j => h.bobRemaining ⟨j, ?_⟩⟩ rw [fullHistoryRemaining_insert_conditioned D L i] exact j.property def fullCoordinateInsertedHistoryEquiv {X Y : Type*} [Fintype X] [Fintype Y] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) : (FullCoordinateRevealHistory X Y n D L i × X × Y) ≃ FullSubsetHistory X Y n (insert i D) L where toFun t := fullCoordinateInsertedHistory D L i t.1 t.2.1 t.2.2 invFun h := (fullCoordinateBaseOfInsertedHistory D L i h, h.aliceConditioned ⟨i, Finset.mem_insert_self i D⟩, h.bobConditioned ⟨i, Finset.mem_insert_self i D⟩) left_inv t := by rcases t with ⟨r, x, y⟩ apply Prod.ext · apply FullCoordinateRevealHistory.ext · funext j have hj : (j : Fin n) ≠ i := by intro he exact hiD (he ▸ j.property) simp [fullCoordinateBaseOfInsertedHistory, fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, hj] · funext j have hj : (j : Fin n) ≠ i := by intro he exact hiD (he ▸ j.property) simp [fullCoordinateBaseOfInsertedHistory, fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, hj] · rfl · rfl · apply Prod.ext <;> simp [fullCoordinateInsertedHistory, fullCoordinateAnswerExtension] right_inv h := by apply FullSubsetHistory.ext · funext j by_cases hj : (j : Fin n) = i · have hjsub : j = (⟨i, Finset.mem_insert_self i D⟩ : {j : Fin n // j ∈ insert i D}) := Subtype.ext hj subst j simp [fullCoordinateInsertedHistory, fullCoordinateBaseOfInsertedHistory, fullCoordinateAnswerExtension] · simp [fullCoordinateInsertedHistory, fullCoordinateBaseOfInsertedHistory, fullCoordinateAnswerExtension, hj] · funext j by_cases hj : (j : Fin n) = i · have hjsub : j = (⟨i, Finset.mem_insert_self i D⟩ : {j : Fin n // j ∈ insert i D}) := Subtype.ext hj subst j simp [fullCoordinateInsertedHistory, fullCoordinateBaseOfInsertedHistory, fullCoordinateAnswerExtension] · simp [fullCoordinateInsertedHistory, fullCoordinateBaseOfInsertedHistory, fullCoordinateAnswerExtension, hj] · rfl · rfl section InsertedWeights variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem fullCoordinateInsertedHistory_weight (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) : fullHistoryWeight G (fullCoordinateInsertedHistory D L i r x y) = fullCoordinateBaseWeight G D L i r * G.questionWeight x y := by classical have hremaining : (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L}, G.marginalY ((fullCoordinateInsertedHistory D L i r x y).bobRemaining j)) = ∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)}, G.marginalY (r.bobRemaining j) := by let e := fullHistoryRemainingInsertedEquiv D L i calc (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L}, G.marginalY ((fullCoordinateInsertedHistory D L i r x y).bobRemaining j)) = ∏ j : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L}, G.marginalY (r.bobRemaining (e j)) := by apply Finset.prod_congr rfl intro j _ rfl _ = _ := e.prod_comp (fun j => G.marginalY (r.bobRemaining j)) have hpair (j : {j : Fin n // j ∈ D}) : G.questionWeight ((fullCoordinateInsertedHistory D L i r x y).aliceConditioned ⟨j, Finset.mem_insert_of_mem j.property⟩) ((fullCoordinateInsertedHistory D L i r x y).bobConditioned ⟨j, Finset.mem_insert_of_mem j.property⟩) = G.questionWeight (r.aliceConditioned j) (r.bobConditioned j) := by have hj : (j : Fin n) ≠ i := by intro he exact hiD (he ▸ j.property) simp [fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, hj] unfold fullHistoryWeight fullCoordinateBaseWeight change (∏ j : {j : Fin n // j ∈ insert i D}, G.questionWeight ((fullCoordinateInsertedHistory D L i r x y).aliceConditioned j) ((fullCoordinateInsertedHistory D L i r x y).bobConditioned j)) * (∏ j : {j : Fin n // j ∈ L}, G.marginalX (r.aliceRevealed j)) * (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L}, G.marginalY ((fullCoordinateInsertedHistory D L i r x y).bobRemaining j)) = _ rw [finsetSubtype_prod_insert D i hiD] rw [hremaining] simp_rw [hpair] simp [fullCoordinateInsertedHistory, fullCoordinateAnswerExtension] ring theorem conditionedAliceEffect_insert_eq_coordinate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (α : {j : Fin n // j ∈ D} → A) (a : A) (xs : Fin n → X) : conditionedAliceEffect G n S (insert i D) (fullCoordinateAnswerExtension D i α a) xs = conditionedAliceCoordinateEffect G n S D α xs i a := by classical unfold conditionedAliceEffect conditionedAliceCoordinateEffect apply Finset.sum_congr rfl intro answers _ have hiff : (∀ (j : Fin n) (hj : j ∈ insert i D), answers j = fullCoordinateAnswerExtension D i α a ⟨j, hj⟩) ↔ ((∀ (j : Fin n) (hj : j ∈ D), answers j = α ⟨j, hj⟩) ∧ answers i = a) := by constructor · intro h constructor · intro j hj have hji : j ≠ i := by intro he exact hiD (he ▸ hj) simpa [fullCoordinateAnswerExtension, hji] using h j (Finset.mem_insert_of_mem hj) · simpa [fullCoordinateAnswerExtension] using h i (Finset.mem_insert_self i D) · rintro ⟨hD, ha⟩ j hj by_cases hji : j = i · subst j simpa [fullCoordinateAnswerExtension] using ha · have hjD := (Finset.mem_insert.mp hj).resolve_left hji simpa [fullCoordinateAnswerExtension, hji] using hD j hjD by_cases h : ∀ (j : Fin n) (hj : j ∈ insert i D), answers j = fullCoordinateAnswerExtension D i α a ⟨j, hj⟩ · simp only [if_pos h, if_pos (hiff.mp h)] · have hnot := mt hiff.mpr h simp only [if_neg h, if_neg hnot] theorem conditionedBobEffect_insert_eq_coordinate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (β : {j : Fin n // j ∈ D} → B) (b : B) (ys : Fin n → Y) : conditionedBobEffect G n S (insert i D) (fullCoordinateAnswerExtension D i β b) ys = conditionedBobCoordinateEffect G n S D β ys i b := by classical unfold conditionedBobEffect conditionedBobCoordinateEffect apply Finset.sum_congr rfl intro answers _ have hiff : (∀ (j : Fin n) (hj : j ∈ insert i D), answers j = fullCoordinateAnswerExtension D i β b ⟨j, hj⟩) ↔ ((∀ (j : Fin n) (hj : j ∈ D), answers j = β ⟨j, hj⟩) ∧ answers i = b) := by constructor · intro h constructor · intro j hj have hji : j ≠ i := by intro he exact hiD (he ▸ hj) simpa [fullCoordinateAnswerExtension, hji] using h j (Finset.mem_insert_of_mem hj) · simpa [fullCoordinateAnswerExtension] using h i (Finset.mem_insert_self i D) · rintro ⟨hD, hb⟩ j hj by_cases hji : j = i · subst j simpa [fullCoordinateAnswerExtension] using hb · have hjD := (Finset.mem_insert.mp hj).resolve_left hji simpa [fullCoordinateAnswerExtension, hji] using hD j hjD by_cases h : ∀ (j : Fin n) (hj : j ∈ insert i D), answers j = fullCoordinateAnswerExtension D i β b ⟨j, hj⟩ · simp only [if_pos h, if_pos (hiff.mp h)] · have hnot := mt hiff.mpr h simp only [if_neg h, if_neg hnot] end InsertedWeights end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem conditionedCoordinateEffects_born_expansion [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (α : {j : Fin n // j ∈ D} → A) (β : {j : Fin n // j ∈ D} → B) (xs : Fin n → X) (ys : Fin n → Y) (i : Fin n) (a : A) (b : B) : bornTracePairing S.state.matrix (conditionedAliceCoordinateEffect G n S D α xs i a) (conditionedBobCoordinateEffect G n S D β ys i b) = ∑ aa : Fin n → A, ∑ bb : Fin n → B, if (∀ (j : Fin n) (hj : j ∈ D), aa j = α ⟨j, hj⟩) ∧ aa i = a then if (∀ (j : Fin n) (hj : j ∈ D), bb j = β ⟨j, hj⟩) ∧ bb i = b then S.outcomeProbability xs ys aa bb else 0 else 0 := by classical simp only [conditionedAliceCoordinateEffect, conditionedBobCoordinateEffect, map_sum, LinearMap.sum_apply] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro aa _ split_ifs with ha · apply Finset.sum_congr rfl intro bb _ split_ifs with hb · rfl · exact map_zero _ · simp end noncomputable section open scoped BigOperators ComplexConjugate ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace def normalizedPureVector {d : Type*} [Fintype d] (z : EuclideanSpace ℂ d) : EuclideanSpace ℂ d := ((‖z‖⁻¹ : ℝ) : ℂ) • z theorem quadraticExpectation_normalizedPureVector {d : Type*} [Fintype d] (W : EuclideanSpace ℂ d →L[ℂ] EuclideanSpace ℂ d) (z : EuclideanSpace ℂ d) : quadraticExpectation W (normalizedPureVector z) = quadraticExpectation W z / ‖z‖ ^ 2 := by unfold quadraticExpectation normalizedPureVector rw [map_smul, inner_smul_left, inner_smul_right] simp [Complex.mul_re, div_eq_mul_inv, pow_two] by_cases hz : ‖z‖ = 0 · simp [hz] · field_simp end noncomputable section open scoped BigOperators variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exists_repeatedStrategy_of_lt_entangledValue (G : Game X Y A B) {n : ℕ} {r : ℝ} (hr : 0 < r) (hvalue : r < repeatedEntangledValue G n) : ∃ S : Strategy (G.repeat n), r < S.winProbability := by let values : Set ℝ := Set.range (Strategy.winProbability (G := G.repeat n)) have hnonempty : values.Nonempty := by by_contra hempty have heq : values = ∅ := Set.not_nonempty_iff_eq_empty.mp hempty have hzero : repeatedEntangledValue G n = 0 := by change sSup values = 0 rw [heq, Real.sSup_empty] linarith have hs : r < sSup values := by exact hvalue obtain ⟨v, ⟨S, hS⟩, hv⟩ := exists_lt_of_lt_csSup hnonempty hs subst v exact ⟨S, hv⟩ theorem exists_purifiedRepeatedStrategy_of_lt_entangledValue (G : Game X Y A B) {n : ℕ} {r : ℝ} (hr : 0 < r) (hvalue : r < repeatedEntangledValue G n) : ∃ S : Strategy (G.repeat n), r < (purifiedStrategy S).winProbability := by obtain ⟨S, hS⟩ := exists_repeatedStrategy_of_lt_entangledValue G hr hvalue refine ⟨S, ?_⟩ rwa [purifiedStrategy_winProbability] theorem arbitrarily_large_purifiedRepeatedStrategy_of_subexponentialWitness (G : Game X Y A B) (hwitness : HasSubexponentialWitness (repeatedEntangledValue G)) {c : ℝ} (hc : 0 < c) (N : ℕ) : ∃ n : ℕ, N < n ∧ ∃ S : Strategy (G.repeat n), Real.exp (-c * (n : ℝ)) < (purifiedStrategy S).winProbability := by have hno : ¬ HasExponentialBound (repeatedEntangledValue G) := (not_hasExponentialBound_iff (repeatedEntangledValue G)).mpr hwitness have hbounded (n : ℕ) : repeatedEntangledValue G n ≤ 1 := entangledValue_le_one (G.repeat n) obtain ⟨n, hn, hvalue⟩ := arbitrarily_large_witness_of_not_hasExponentialBound hbounded hno hc N exact ⟨n, hn, exists_purifiedRepeatedStrategy_of_lt_entangledValue G (Real.exp_pos _) hvalue⟩ theorem postselection_log_cost_le {θ p : ℝ} (hθ : 0 < θ) (hθp : θ ≤ p) : Real.log (1 / p) ≤ Real.log (1 / θ) := by have hp : 0 < p := lt_of_lt_of_le hθ hθp have hinv : 1 / p ≤ 1 / θ := by exact one_div_le_one_div_of_le hθ hθp exact Real.log_le_log (by positivity : 0 < 1 / p) hinv theorem greedy_terminal_of_log_cost {θ η : ℝ} {T : ℕ} (hθ : 0 < θ) (hη_one : η ≤ 1) (hcost : Real.log (1 / θ) < η * (T : ℝ)) : (1 - η) ^ T < θ := by have hbase : 1 - η ≤ Real.exp (-η) := by have h := Real.add_one_le_exp (-η) linarith have hpow : (1 - η) ^ T ≤ Real.exp (-η) ^ T := pow_le_pow_left₀ (sub_nonneg.mpr hη_one) hbase T have hlog : -η * (T : ℝ) < Real.log θ := by rw [one_div, Real.log_inv] at hcost linarith calc (1 - η) ^ T ≤ Real.exp (-η) ^ T := hpow _ = Real.exp (-η * (T : ℝ)) := by rw [← Real.exp_nat_mul] congr 1 ring _ < θ := (Real.exp_lt_exp.mpr hlog).trans_eq (Real.exp_log hθ) theorem divisorStopping_nat_bound {n q : ℕ} (hq : 0 < q) (hqn : q ≤ n) : n < 2 * (n / q) * q := by have hT : 0 < n / q := by apply (Nat.le_div_iff_mul_le hq).2 simpa using hqn have hnext : n < (n / q + 1) * q := by exact (Nat.div_lt_iff_lt_mul hq).mp (Nat.lt_succ_self (n / q)) have hfactor : n / q + 1 ≤ 2 * (n / q) := by omega exact hnext.trans_le (Nat.mul_le_mul_right q hfactor) theorem sourceRate_mul_lt_divisorStopping {n q : ℕ} (hq : 0 < q) (hqn : q ≤ n) {η : ℝ} (hη : 0 < η) : (η / (4 * (q : ℝ))) * (n : ℝ) < η * ((n / q : ℕ) : ℝ) := by have hcast : (n : ℝ) < 2 * ((n / q : ℕ) : ℝ) * (q : ℝ) := by exact_mod_cast divisorStopping_nat_bound hq hqn have hqreal : 0 < (q : ℝ) := by exact_mod_cast hq have hT : 0 < ((n / q : ℕ) : ℝ) := by exact_mod_cast ((Nat.le_div_iff_mul_le hq).2 (by simpa using hqn) : 1 ≤ n / q) have hrate : 0 < η / (4 * (q : ℝ)) := by positivity calc (η / (4 * (q : ℝ))) * (n : ℝ) < (η / (4 * (q : ℝ))) * (2 * ((n / q : ℕ) : ℝ) * (q : ℝ)) := mul_lt_mul_of_pos_left hcast hrate _ = η * ((n / q : ℕ) : ℝ) / 2 := by field_simp ; ring _ < η * ((n / q : ℕ) : ℝ) := by have hpositive : 0 < η * ((n / q : ℕ) : ℝ) := mul_pos hη hT linarith theorem repeatedStrategy_exists_divisor_greedy_conditioning (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) {η : ℝ} {q : ℕ} (hη : 0 < η) (hη_one : η ≤ 1) (hq : 0 < q) (hqn : q ≤ n) (hwitness : Real.exp (-(η / (4 * (q : ℝ))) * (n : ℝ)) < S.winProbability) : ∃ D : Finset (Fin n), D.card < n / q ∧ S.winProbability ≤ (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) ∧ (∑ i ∈ Finset.univ \ D, FiniteEventLaw.failureMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D i) < ((Finset.univ \ D).card : ℝ) * (η * (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) := by have hθ : 0 < S.winProbability := lt_trans (Real.exp_pos _) hwitness have hlog : Real.log (1 / S.winProbability) < (η / (4 * (q : ℝ))) * (n : ℝ) := by have hlog' : -(η / (4 * (q : ℝ))) * (n : ℝ) < Real.log S.winProbability := (Real.lt_log_iff_exp_lt hθ).mpr hwitness rw [one_div, Real.log_inv] linarith have hterminal : (1 - η) ^ (n / q) < S.winProbability := by apply greedy_terminal_of_log_cost hθ hη_one exact hlog.trans (sourceRate_mul_lt_divisorStopping hq hqn hη) apply repeatedStrategy_exists_greedy_conditioning G n S hθ hη hη_one (Nat.div_le_self n q) (le_refl _) hterminal theorem divisor_greedy_card_mul_lt {n q : ℕ} (hq : 0 < q) {D : Finset (Fin n)} (hD : D.card < n / q) : D.card * q < n := by have hmul : D.card * q < (n / q) * q := Nat.mul_lt_mul_of_pos_right hD hq exact hmul.trans_le (Nat.div_mul_le_self n q) end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] structure SourceHistoryFlag (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) where permutation : SourceRemainingPermutation D position : Fin (Finset.univ \ D).card history : FullCoordinateRevealHistory X Y n D (sourceRemainingPermutationPrefix D permutation position.castSucc) (sourceRemainingPermutationCoordinate D permutation position) aliceAnswer : {i : Fin n // i ∈ D} → A bobAnswer : {i : Fin n // i ∈ D} → B abbrev SourceHistoryFlagTuple (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) := Σ π : SourceRemainingPermutation D, Σ k : Fin (Finset.univ \ D).card, FullCoordinateRevealHistory X Y n D (sourceRemainingPermutationPrefix D π k.castSucc) (sourceRemainingPermutationCoordinate D π k) × ({i : Fin n // i ∈ D} → A) × ({i : Fin n // i ∈ D} → B) def sourceHistoryFlagEquiv {n : ℕ} (D : Finset (Fin n)) : SourceHistoryFlag X Y A B D ≃ SourceHistoryFlagTuple X Y A B D where toFun r := ⟨r.permutation, r.position, r.history, r.aliceAnswer, r.bobAnswer⟩ invFun t := ⟨t.1, t.2.1, t.2.2.1, t.2.2.2.1, t.2.2.2.2⟩ left_inv r := by cases r; rfl right_inv t := by rcases t with ⟨π, k, r, α, β⟩ rfl noncomputable instance sourceHistoryFlagFintype {n : ℕ} (D : Finset (Fin n)) : Fintype (SourceHistoryFlag X Y A B D) := by classical exact Fintype.ofEquiv (SourceHistoryFlagTuple X Y A B D) (sourceHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm theorem sourceHistoryFlag_sum {n : ℕ} (D : Finset (Fin n)) (f : SourceHistoryFlag X Y A B D → ℝ) : (∑ r : SourceHistoryFlag X Y A B D, f r) = ∑ π : SourceRemainingPermutation D, ∑ k : Fin (Finset.univ \ D).card, ∑ r : FullCoordinateRevealHistory X Y n D (sourceRemainingPermutationPrefix D π k.castSucc) (sourceRemainingPermutationCoordinate D π k), ∑ α : {i : Fin n // i ∈ D} → A, ∑ β : {i : Fin n // i ∈ D} → B, f ⟨π, k, r, α, β⟩ := by classical calc (∑ r : SourceHistoryFlag X Y A B D, f r) = ∑ t : SourceHistoryFlagTuple X Y A B D, f ((sourceHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) := ((sourceHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm.sum_comp f).symm _ = _ := by simp [Fintype.sum_sigma, Fintype.sum_prod_type, sourceHistoryFlagEquiv] def sourceHistoryPermutationPositionWeight {n : ℕ} (D : Finset (Fin n)) : ℝ := 1 / ((Fintype.card (SourceRemainingPermutation D) : ℝ) * ((Finset.univ \ D).card : ℝ)) def sourceHistoryRaw (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (r : SourceHistoryFlag X Y A B D) : ℝ := sourceHistoryPermutationPositionWeight D * fullCoordinateBaseWeight G D (sourceRemainingPermutationPrefix D r.permutation r.position.castSucc) (sourceRemainingPermutationCoordinate D r.permutation r.position) r.history * fullCoordinateBaseWinIndicator G D (sourceRemainingPermutationPrefix D r.permutation r.position.castSucc) (sourceRemainingPermutationCoordinate D r.permutation r.position) r.history r.aliceAnswer r.bobAnswer end noncomputable section open scoped BigOperators section FiniteSamples variable {ι Ω : Type*} [Fintype ι] [DecidableEq ι] [Fintype Ω] def postselectionMass (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) (C : Finset ι) : ℝ := law.eventMass (FiniteEventLaw.winEvent wins C) omit [DecidableEq ι] in theorem allWinMass_le_postselectionMass (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) (C : Finset ι) : law.eventMass (FiniteEventLaw.winEvent wins Finset.univ) ≤ postselectionMass law wins C := law.allWinMass_le_partial wins C omit [DecidableEq ι] in theorem postselectionMass_le_one (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) (C : Finset ι) : postselectionMass law wins C ≤ 1 := by calc postselectionMass law wins C ≤ law.eventMass Finset.univ := law.eventMass_mono (Finset.subset_univ _) _ = 1 := law.eventMass_univ def conditionalCoordinateFailure (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) (C : Finset ι) (i : ι) : ℝ := FiniteEventLaw.failureMass law wins C i / postselectionMass law wins C def uniformRemainingFailure (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) (C : Finset ι) : ℝ := (∑ i ∈ Finset.univ \ C, conditionalCoordinateFailure law wins C i) / ((Finset.univ \ C).card : ℝ) theorem uniformRemainingFailure_lt_of_failure_sum (law : FiniteEventLaw Ω) (wins : ι → Ω → Bool) (C : Finset ι) {η : ℝ} (hp : 0 < postselectionMass law wins C) (hm : 0 < (Finset.univ \ C).card) (hfailure : (∑ i ∈ Finset.univ \ C, FiniteEventLaw.failureMass law wins C i) < ((Finset.univ \ C).card : ℝ) * (η * postselectionMass law wins C)) : uniformRemainingFailure law wins C < η := by have hmreal : 0 < ((Finset.univ \ C).card : ℝ) := by exact_mod_cast hm unfold uniformRemainingFailure conditionalCoordinateFailure rw [← Finset.sum_div] apply (div_lt_iff₀ hmreal).mpr apply (div_lt_iff₀ hp).mpr nlinarith end FiniteSamples section ActualRepeatedStrategy variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def repeatedPostselectionMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (C : Finset (Fin n)) : ℝ := postselectionMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) C theorem repeated_winProbability_le_postselectionMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (C : Finset (Fin n)) : S.winProbability ≤ repeatedPostselectionMass G n S C := by rw [← repeated_allWinMass_eq G n S] exact allWinMass_le_postselectionMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) C theorem repeatedPostselectionMass_pos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (C : Finset (Fin n)) (hwin : 0 < S.winProbability) : 0 < repeatedPostselectionMass G n S C := lt_of_lt_of_le hwin (repeated_winProbability_le_postselectionMass G n S C) theorem remainingCoordinates_card {n : ℕ} (C : Finset (Fin n)) : (Finset.univ \ C).card = n - C.card := by simp [Finset.card_sdiff_of_subset (Finset.subset_univ C)] theorem repeatedStrategy_exists_conditioning (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) {η : ℝ} {q : ℕ} (hwin : 0 < S.winProbability) (hη : 0 < η) (hη_one : η ≤ 1) (hq : q ≤ n) (hterminal : (1 - η) ^ q < S.winProbability) : ∃ C : Finset (Fin n), C.card < q ∧ S.winProbability ≤ repeatedPostselectionMass G n S C ∧ 0 < repeatedPostselectionMass G n S C ∧ 0 < (Finset.univ \ C).card ∧ uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) C < η := by obtain ⟨C, hC, hmass, hfailure⟩ := repeatedStrategy_exists_greedy_conditioning G n S hwin hη hη_one hq (le_refl _) hterminal have hremaining : 0 < (Finset.univ \ C).card := by rw [remainingCoordinates_card] omega have hp : 0 < repeatedPostselectionMass G n S C := repeatedPostselectionMass_pos G n S C hwin refine ⟨C, hC, ?_, hp, hremaining, ?_⟩ · simpa [repeatedPostselectionMass, postselectionMass] using hmass · apply uniformRemainingFailure_lt_of_failure_sum (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) C (by simpa [repeatedPostselectionMass] using hp) hremaining simpa [postselectionMass] using hfailure end ActualRepeatedStrategy end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder theorem source_equation_nineteen_alice {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (hFcomplement : (1 - F).PosSemidef) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) (hGcomplement : (1 - G).PosSemidef) : -bornTracePairing ρ.matrix (cfc (fun z : ℝ => z * Real.log z) F) G ≤ Real.negMulLog (bornTracePairing ρ.matrix F G) := matrixLogEntropy_born_lower_bound_left ρ F hF hFcomplement G hG hGcomplement theorem source_equation_nineteen_bob {dA dB : Type*} [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] (ρ : DensityMatrix (dA × dB)) (F : Matrix dA dA ℂ) (hF : F.PosSemidef) (hFcomplement : (1 - F).PosSemidef) (G : Matrix dB dB ℂ) (hG : G.PosSemidef) (hGcomplement : (1 - G).PosSemidef) : -bornTracePairing ρ.matrix F (cfc (fun z : ℝ => z * Real.log z) G) ≤ Real.negMulLog (bornTracePairing ρ.matrix F G) := matrixLogEntropy_born_lower_bound_right ρ F hF hFcomplement G hG hGcomplement end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1200000 set_option maxRecDepth 2048 section ActualFilters variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def postselectionLogCost (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := Real.log (1 / repeatedPostselectionMass G n S D) def answerLogCost {A B : Type*} [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) : ℝ := (D.card : ℝ) * Real.log ((Fintype.card A : ℝ) * (Fintype.card B : ℝ)) def martingaleRate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := (postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D) / ((Finset.univ \ D).card : ℝ) theorem answerCount_pos_of_postselection (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hp : 0 < repeatedPostselectionMass G n S D) : 0 < fullHistoryAnswerCount (A := A) (B := B) D := by classical have hmass := fullHistoryAtomBornMass_sum G n S D ∅ (Finset.empty_subset _) have hfirst : (∑ z : FullHistoryEntropyAtom X Y A B n D ∅, fullHistoryAtomCountingWeight G D ∅ z * fullHistoryAtomBornMass G n S D ∅ z) ≤ ∑ z : FullHistoryEntropyAtom X Y A B n D ∅, fullHistoryAtomCountingWeight G D ∅ z := by apply Finset.sum_le_sum intro z _ exact mul_le_of_le_one_right (fullHistoryAtomCountingWeight_nonneg G D ∅ z) (fullHistoryAtomBornMass_le_one G n S D ∅ z) have hsecond := fullHistoryAtomCountingWeight_sum_le G D ∅ change 0 < (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) at hp linarith theorem martingale_log_cost_eq (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hp : 0 < repeatedPostselectionMass G n S D) : Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) = postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D := by have hN := answerCount_pos_of_postselection G n S D hp calc Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) = Real.log (fullHistoryAnswerCount (A := A) (B := B) D) - Real.log (repeatedPostselectionMass G n S D) := Real.log_div hN.ne' hp.ne' _ = (D.card : ℝ) * Real.log ((Fintype.card A : ℝ) * (Fintype.card B : ℝ)) - Real.log (repeatedPostselectionMass G n S D) := by rw [fullHistoryAnswerCount_eq, ← mul_pow, Real.log_pow] _ = postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D := by simp only [postselectionLogCost, answerLogCost, one_div, Real.log_inv] ring theorem aliceMartingaleEntropyBudget (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hm : 0 < (Finset.univ \ D).card) (hp : 0 < repeatedPostselectionMass G n S D) : sourceUniformPermutationAverage D (sourcePermutationAliceEntropyIncrement G n S D) ≤ repeatedPostselectionMass G n S D * martingaleRate G n S D := by have hbudget := sourceUniformPermutationAliceEntropyBudget G n S D hm hp change sourceUniformPermutationAverage D (sourcePermutationAliceEntropyIncrement G n S D) ≤ repeatedPostselectionMass G n S D * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) / ((Finset.univ \ D).card : ℝ) at hbudget rw [martingale_log_cost_eq G n S D hp] at hbudget simpa [martingaleRate, mul_div_assoc] using hbudget end ActualFilters section ActualPurificationHistories variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem bornWeighted_normalized_distance {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] (fallback u v : E) (hfallback : ‖fallback‖ = 1) : ‖u‖ ^ 2 * ‖normalizeOrDefault fallback u - normalizeOrDefault fallback v‖ ^ 2 ≤ 4 * ‖u - v‖ ^ 2 := by by_cases hu : u = 0 · simp [hu] · have hu_pos : 0 < ‖u‖ := norm_pos_iff.mpr hu have hdist := normalizeOrDefault_sub_le fallback u v hfallback hu have hscaled : ‖normalizeOrDefault fallback u - normalizeOrDefault fallback v‖ * ‖u‖ ≤ 2 * ‖u - v‖ := (le_div_iff₀ hu_pos).mp hdist have hsquare := mul_self_le_mul_self (mul_nonneg (norm_nonneg _) (norm_nonneg u)) hscaled nlinarith [sq_nonneg (‖normalizeOrDefault fallback u - normalizeOrDefault fallback v‖ * ‖u‖), sq_nonneg (‖u - v‖)] end ActualPurificationHistories end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem fullCoordinateInsertedHistory_winIndicator_eq (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (α : {j : Fin n // j ∈ D} → A) (a : A) (β : {j : Fin n // j ∈ D} → B) (b : B) : fullHistoryWinIndicator G (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) = fullCoordinateBaseWinIndicator G D L i r α β * (if G.predicate x y a b = true then 1 else 0) := by classical have hiff : (∀ j : {j : Fin n // j ∈ insert i D}, G.predicate ((fullCoordinateInsertedHistory D L i r x y).aliceConditioned j) ((fullCoordinateInsertedHistory D L i r x y).bobConditioned j) (fullCoordinateAnswerExtension D i α a j) (fullCoordinateAnswerExtension D i β b j) = true) ↔ ((∀ j : {j : Fin n // j ∈ D}, G.predicate (r.aliceConditioned j) (r.bobConditioned j) (α j) (β j) = true) ∧ G.predicate x y a b = true) := by constructor · intro h constructor · intro j have hji : (j : Fin n) ≠ i := by intro he exact hiD (he ▸ j.property) simpa [fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, hji] using h ⟨j, Finset.mem_insert_of_mem j.property⟩ · simpa [fullCoordinateInsertedHistory, fullCoordinateAnswerExtension] using h ⟨i, Finset.mem_insert_self i D⟩ · rintro ⟨hD, hi⟩ j by_cases hji : (j : Fin n) = i · have hjsub : j = (⟨i, Finset.mem_insert_self i D⟩ : {j : Fin n // j ∈ insert i D}) := Subtype.ext hji subst j simpa [fullCoordinateInsertedHistory, fullCoordinateAnswerExtension] using hi · have hjD : (j : Fin n) ∈ D := (Finset.mem_insert.mp j.property).resolve_left hji simpa [fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, hji] using hD ⟨j, hjD⟩ change (if ∀ j : {j : Fin n // j ∈ insert i D}, G.predicate ((fullCoordinateInsertedHistory D L i r x y).aliceConditioned j) ((fullCoordinateInsertedHistory D L i r x y).bobConditioned j) (fullCoordinateAnswerExtension D i α a j) (fullCoordinateAnswerExtension D i β b j) = true then (1 : ℝ) else 0) = (if ∀ j : {j : Fin n // j ∈ D}, G.predicate (r.aliceConditioned j) (r.bobConditioned j) (α j) (β j) = true then (1 : ℝ) else 0) * (if G.predicate x y a b = true then (1 : ℝ) else 0) split_ifs with hall hD hi <;> aesop def fullCoordinateInsertedHiddenAliceEquiv {X : Type*} {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) : ({j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L} → X) ≃ ({j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X) where toFun hidden j := hidden ((fullHistoryRemainingInsertedEquiv D L i).symm j) invFun hidden j := hidden (fullHistoryRemainingInsertedEquiv D L i j) left_inv hidden := by funext j simp right_inv hidden := by funext j simp theorem fullCoordinateInsertedAliceQuestion_eq {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (hidden : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X) : fullHistoryAliceQuestion (fullCoordinateInsertedHistory D L i r x y) ((fullCoordinateInsertedHiddenAliceEquiv (X := X) D L i).symm hidden) = fullHistoryAliceQuestion (fullCoordinateNewHistory D L i r x) hidden := by classical funext j by_cases hjD : j ∈ D · have hji : j ≠ i := by intro he exact hiD (he ▸ hjD) simp [fullHistoryAliceQuestion, fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, fullCoordinateNewHistory, hjD, hji] · by_cases hji : j = i · subst j simp [fullHistoryAliceQuestion, fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, fullCoordinateNewHistory, hiD, hiL] · by_cases hjL : j ∈ L · simp [fullHistoryAliceQuestion, fullCoordinateInsertedHistory, fullCoordinateNewHistory, hjD, hji, hjL] · simp [fullHistoryAliceQuestion, fullCoordinateInsertedHiddenAliceEquiv, fullHistoryRemainingInsertedEquiv, hjD, hji, hjL] congr 1 theorem fullCoordinateInsertedHiddenAliceWeight_eq (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (hidden : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X) : fullHistoryHiddenAliceWeight G (fullCoordinateInsertedHistory D L i r x y) ((fullCoordinateInsertedHiddenAliceEquiv (X := X) D L i).symm hidden) = fullHistoryHiddenAliceWeight G (fullCoordinateNewHistory D L i r x) hidden := by classical let e := fullHistoryRemainingInsertedEquiv D L i unfold fullHistoryHiddenAliceWeight calc (∏ j : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L}, G.conditionalXGivenY ((fullCoordinateInsertedHistory D L i r x y).bobRemaining j) (((fullCoordinateInsertedHiddenAliceEquiv (X := X) D L i).symm hidden) j)) = ∏ j : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L}, G.conditionalXGivenY (r.bobRemaining (e j)) (hidden (e j)) := by apply Finset.prod_congr rfl intro j _ rfl _ = ∏ j : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)}, G.conditionalXGivenY (r.bobRemaining j) (hidden j) := e.prod_comp (fun j => G.conditionalXGivenY (r.bobRemaining j) (hidden j)) _ = _ := rfl theorem fullCoordinateInsertedBobQuestion_eq {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (hidden : {j : Fin n // j ∈ L} → Y) : fullHistoryBobQuestion (fullCoordinateInsertedHistory D L i r x y) hidden = fullHistoryBobQuestion (fullCoordinateOldHistory D L i r y) hidden := by classical funext j by_cases hjD : j ∈ D · have hji : j ≠ i := by intro he exact hiD (he ▸ hjD) simp [fullHistoryBobQuestion, fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, fullCoordinateOldHistory, hjD, hji] · by_cases hji : j = i · subst j simp [fullHistoryBobQuestion, fullCoordinateInsertedHistory, fullCoordinateAnswerExtension, fullCoordinateOldHistory, hiD, hiL] · by_cases hjL : j ∈ L · simp [fullHistoryBobQuestion, hjD, hji, hjL] · simp [fullHistoryBobQuestion, fullCoordinateInsertedHistory, fullCoordinateOldHistory, hjD, hji, hjL] theorem fullCoordinateInsertedHiddenBobWeight_eq (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (hidden : {j : Fin n // j ∈ L} → Y) : fullHistoryHiddenBobWeight G (fullCoordinateInsertedHistory D L i r x y) hidden = fullHistoryHiddenBobWeight G (fullCoordinateOldHistory D L i r y) hidden := by rfl theorem fullCoordinateInsertedHistory_aliceFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (α : {j : Fin n // j ∈ D} → A) (a : A) : fullHistoryAliceFilter G n S (insert i D) L (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) = fullCoordinateAliceRefinementEffect G n S D L i r α x a := by classical change (∑ hidden : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L} → X, fullHistoryHiddenAliceWeight G (fullCoordinateInsertedHistory D L i r x y) hidden • conditionedAliceEffect G n S (insert i D) (fullCoordinateAnswerExtension D i α a) (fullHistoryAliceQuestion (fullCoordinateInsertedHistory D L i r x y) hidden)) = ∑ hidden : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X, fullHistoryHiddenAliceWeight G (fullCoordinateNewHistory D L i r x) hidden • conditionedAliceCoordinateEffect G n S D α (fullHistoryAliceQuestion (fullCoordinateNewHistory D L i r x) hidden) i a calc (∑ hidden : {j : Fin n // j ∈ fullHistoryRemaining n (insert i D) L} → X, fullHistoryHiddenAliceWeight G (fullCoordinateInsertedHistory D L i r x y) hidden • conditionedAliceEffect G n S (insert i D) (fullCoordinateAnswerExtension D i α a) (fullHistoryAliceQuestion (fullCoordinateInsertedHistory D L i r x y) hidden)) = ∑ hidden : {j : Fin n // j ∈ fullHistoryRemaining n D (insert i L)} → X, fullHistoryHiddenAliceWeight G (fullCoordinateInsertedHistory D L i r x y) ((fullCoordinateInsertedHiddenAliceEquiv (X := X) D L i).symm hidden) • conditionedAliceEffect G n S (insert i D) (fullCoordinateAnswerExtension D i α a) (fullHistoryAliceQuestion (fullCoordinateInsertedHistory D L i r x y) ((fullCoordinateInsertedHiddenAliceEquiv (X := X) D L i).symm hidden)) := by exact ((fullCoordinateInsertedHiddenAliceEquiv (X := X) D L i).symm.sum_comp (fun hidden => fullHistoryHiddenAliceWeight G (fullCoordinateInsertedHistory D L i r x y) hidden • conditionedAliceEffect G n S (insert i D) (fullCoordinateAnswerExtension D i α a) (fullHistoryAliceQuestion (fullCoordinateInsertedHistory D L i r x y) hidden))).symm _ = _ := by apply Finset.sum_congr rfl intro hidden _ rw [fullCoordinateInsertedHiddenAliceWeight_eq G D L i r x y hidden] rw [fullCoordinateInsertedAliceQuestion_eq D L i hiD hiL r x y hidden] rw [conditionedAliceEffect_insert_eq_coordinate G n S D i hiD α a] theorem fullCoordinateInsertedHistory_bobFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (r : FullCoordinateRevealHistory X Y n D L i) (x : X) (y : Y) (β : {j : Fin n // j ∈ D} → B) (b : B) : fullHistoryBobFilter G n S (insert i D) L (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i β b) = fullCoordinateBobRefinementEffect G n S D L i r β y b := by classical change (∑ hidden : {j : Fin n // j ∈ L} → Y, fullHistoryHiddenBobWeight G (fullCoordinateInsertedHistory D L i r x y) hidden • conditionedBobEffect G n S (insert i D) (fullCoordinateAnswerExtension D i β b) (fullHistoryBobQuestion (fullCoordinateInsertedHistory D L i r x y) hidden)) = ∑ hidden : {j : Fin n // j ∈ L} → Y, fullHistoryHiddenBobWeight G (fullCoordinateOldHistory D L i r y) hidden • conditionedBobCoordinateEffect G n S D β (fullHistoryBobQuestion (fullCoordinateOldHistory D L i r y) hidden) i b apply Finset.sum_congr rfl intro hidden _ rw [fullCoordinateInsertedHiddenBobWeight_eq G D L i r x y hidden] rw [fullCoordinateInsertedBobQuestion_eq D L i hiD hiL r x y hidden] rw [conditionedBobEffect_insert_eq_coordinate G n S D i hiD β b] theorem fullCoordinateInsertedHistory_sum {T : Type*} [AddCommMonoid T] {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (f : FullSubsetHistory X Y n (insert i D) L → T) : (∑ h : FullSubsetHistory X Y n (insert i D) L, f h) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ x : X, ∑ y : Y, f (fullCoordinateInsertedHistory D L i r x y) := by classical simpa [fullCoordinateInsertedHistoryEquiv, Fintype.sum_prod_type] using ((fullCoordinateInsertedHistoryEquiv (X := X) (Y := Y) D L i hiD).sum_comp f).symm theorem fullCoordinateAnswerExtension_sum {T R : Type*} [Fintype T] [AddCommMonoid R] {n : ℕ} (D : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (f : ({j : Fin n // j ∈ insert i D} → T) → R) : (∑ α : {j : Fin n // j ∈ insert i D} → T, f α) = ∑ α : {j : Fin n // j ∈ D} → T, ∑ a : T, f (fullCoordinateAnswerExtension D i α a) := by classical simpa [fullCoordinateAnswerExtensionEquiv, Fintype.sum_prod_type] using ((fullCoordinateAnswerExtensionEquiv (T := T) D i hiD).sum_comp f).symm theorem fullCoordinateWeightedInsertedSum (G : Game X Y A B) {n : ℕ} (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (value : (h : FullSubsetHistory X Y n (insert i D) L) → ({j : Fin n // j ∈ insert i D} → A) → ({j : Fin n // j ∈ insert i D} → B) → ℝ) : (∑ h : FullSubsetHistory X Y n (insert i D) L, ∑ α : {j : Fin n // j ∈ insert i D} → A, ∑ β : {j : Fin n // j ∈ insert i D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullCoordinateBaseWeight G D L i r * fullCoordinateBaseWinIndicator G D L i r α β * (∑ x : X, ∑ y : Y, G.questionWeight x y * (∑ a : A, ∑ b : B, (if G.predicate x y a b = true then 1 else 0) * value (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b))) := by classical calc (∑ h : FullSubsetHistory X Y n (insert i D) L, ∑ α : {j : Fin n // j ∈ insert i D} → A, ∑ β : {j : Fin n // j ∈ insert i D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ x : X, ∑ y : Y, ∑ α : {j : Fin n // j ∈ insert i D} → A, ∑ β : {j : Fin n // j ∈ insert i D} → B, fullHistoryWeight G (fullCoordinateInsertedHistory D L i r x y) * fullHistoryWinIndicator G (fullCoordinateInsertedHistory D L i r x y) α β * value (fullCoordinateInsertedHistory D L i r x y) α β := fullCoordinateInsertedHistory_sum D L i hiD (fun h => ∑ α : {j : Fin n // j ∈ insert i D} → A, ∑ β : {j : Fin n // j ∈ insert i D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * value h α β) _ = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ x : X, ∑ y : Y, ∑ α : {j : Fin n // j ∈ D} → A, ∑ a : A, ∑ β : {j : Fin n // j ∈ D} → B, ∑ b : B, fullHistoryWeight G (fullCoordinateInsertedHistory D L i r x y) * fullHistoryWinIndicator G (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) * value (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) := by apply Finset.sum_congr rfl intro r _ apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [fullCoordinateAnswerExtension_sum (T := A) D i hiD] apply Finset.sum_congr rfl intro α _ apply Finset.sum_congr rfl intro a _ rw [fullCoordinateAnswerExtension_sum (T := B) D i hiD] _ = ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, ∑ x : X, ∑ y : Y, ∑ a : A, ∑ b : B, fullHistoryWeight G (fullCoordinateInsertedHistory D L i r x y) * fullHistoryWinIndicator G (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) * value (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) := by apply Finset.sum_congr rfl intro r _ calc (∑ x : X, ∑ y : Y, ∑ α : {j : Fin n // j ∈ D} → A, ∑ a : A, ∑ β : {j : Fin n // j ∈ D} → B, ∑ b : B, fullHistoryWeight G (fullCoordinateInsertedHistory D L i r x y) * fullHistoryWinIndicator G (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) * value (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b)) = ∑ x : X, ∑ y : Y, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, ∑ a : A, ∑ b : B, fullHistoryWeight G (fullCoordinateInsertedHistory D L i r x y) * fullHistoryWinIndicator G (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) * value (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ apply Finset.sum_congr rfl intro α _ rw [Finset.sum_comm] _ = _ := finite_sum_four_swap (fun x y α β => ∑ a : A, ∑ b : B, fullHistoryWeight G (fullCoordinateInsertedHistory D L i r x y) * fullHistoryWinIndicator G (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b) * value (fullCoordinateInsertedHistory D L i r x y) (fullCoordinateAnswerExtension D i α a) (fullCoordinateAnswerExtension D i β b)) _ = _ := by apply Finset.sum_congr rfl intro r _ apply Finset.sum_congr rfl intro α _ apply Finset.sum_congr rfl intro β _ simp only [Finset.mul_sum] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ rw [fullCoordinateInsertedHistory_weight G D L i hiD r x y] rw [fullCoordinateInsertedHistory_winIndicator_eq G D L i hiD r x y α a β b] ring def fullCoordinateAcceptedPostselectedMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) : ℝ := ∑ r : FullCoordinateRevealHistory X Y n D L i, ∑ α : {j : Fin n // j ∈ D} → A, ∑ β : {j : Fin n // j ∈ D} → B, fullCoordinateBaseWeight G D L i r * fullCoordinateBaseWinIndicator G D L i r α β * (∑ x : X, ∑ y : Y, G.questionWeight x y * (∑ a : A, ∑ b : B, (if G.predicate x y a b = true then 1 else 0) * bornTracePairing S.state.matrix (fullCoordinateAliceRefinementEffect G n S D L i r α x a) (fullCoordinateBobRefinementEffect G n S D L i r β y b))) theorem fullCoordinateAcceptedPostselectedMass_eq [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (i : Fin n) (hiD : i ∉ D) (hiL : i ∉ L) (hL : L ⊆ Finset.univ \ D) : fullCoordinateAcceptedPostselectedMass G n S D L i = (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i D)) := by classical have hLinsert : L ⊆ Finset.univ \ insert i D := by intro j hj have hjD : j ∉ D := (Finset.mem_sdiff.mp (hL hj)).2 have hji : j ≠ i := by intro he exact hiL (he ▸ hj) simp [hjD, hji] calc fullCoordinateAcceptedPostselectedMass G n S D L i = ∑ h : FullSubsetHistory X Y n (insert i D) L, ∑ α : {j : Fin n // j ∈ insert i D} → A, ∑ β : {j : Fin n // j ∈ insert i D} → B, fullHistoryWeight G h * fullHistoryWinIndicator G h α β * bornTracePairing S.state.matrix (fullHistoryAliceFilter G n S (insert i D) L h α) (fullHistoryBobFilter G n S (insert i D) L h β) := by have hweighted := fullCoordinateWeightedInsertedSum G D L i hiD (fun h α β => bornTracePairing S.state.matrix (fullHistoryAliceFilter G n S (insert i D) L h α) (fullHistoryBobFilter G n S (insert i D) L h β)) simp_rw [fullCoordinateInsertedHistory_aliceFilter G n S D L i hiD hiL, fullCoordinateInsertedHistory_bobFilter G n S D L i hiD hiL] at hweighted simpa [fullCoordinateAcceptedPostselectedMass] using hweighted.symm _ = _ := fullSubsetHistory_mass_eq_postselection G n S (insert i D) L hLinsert end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def sourceHistoryAcceptedQuestionMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : SourceHistoryFlag X Y A B D) (x : X) (y : Y) : ℝ := ∑ a : A, ∑ b : B, (if G.predicate x y a b = true then 1 else 0) * bornTracePairing S.state.matrix (fullCoordinateAliceRefinementEffect G n S D (sourceRemainingPermutationPrefix D r.permutation r.position.castSucc) (sourceRemainingPermutationCoordinate D r.permutation r.position) r.history r.aliceAnswer x a) (fullCoordinateBobRefinementEffect G n S D (sourceRemainingPermutationPrefix D r.permutation r.position.castSucc) (sourceRemainingPermutationCoordinate D r.permutation r.position) r.history r.bobAnswer y b) def sourceHistoryAcceptedMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := ∑ r : SourceHistoryFlag X Y A B D, sourceHistoryRaw G n D r * (∑ x : X, ∑ y : Y, G.questionWeight x y * sourceHistoryAcceptedQuestionMass G n S D r x y) theorem sourceHistoryQuadraticExpectation_matrix_sum {I d : Type*} [Fintype I] [Fintype d] [DecidableEq d] (M : I → Matrix d d ℂ) (z : EuclideanSpace ℂ d) : quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) (∑ i : I, M i)) z = ∑ i : I, quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) (M i)) z := by simp [quadraticExpectation] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem sourceHistoryAcceptedMass_eq_uniform (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : sourceHistoryAcceptedMass G n S D = sourceUniformPermutationAverage D (fun π k => (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert (sourceRemainingPermutationCoordinate D π k) D))) := by classical have hlocal (π : SourceRemainingPermutation D) (k : Fin (Finset.univ \ D).card) : fullCoordinateAcceptedPostselectedMass G n S D (sourceRemainingPermutationPrefix D π k.castSucc) (sourceRemainingPermutationCoordinate D π k) = (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert (sourceRemainingPermutationCoordinate D π k) D)) := by apply fullCoordinateAcceptedPostselectedMass_eq · exact sourceRemainingPermutationCoordinate_not_mem D π k · exact sourceRemainingPermutationCoordinate_not_mem_prefix D π k · exact sourceRemainingPermutationPrefix_subset D π k.castSucc calc sourceHistoryAcceptedMass G n S D = ∑ π : SourceRemainingPermutation D, ∑ k : Fin (Finset.univ \ D).card, sourceHistoryPermutationPositionWeight D * fullCoordinateAcceptedPostselectedMass G n S D (sourceRemainingPermutationPrefix D π k.castSucc) (sourceRemainingPermutationCoordinate D π k) := by unfold sourceHistoryAcceptedMass rw [sourceHistoryFlag_sum] apply Finset.sum_congr rfl intro π _ apply Finset.sum_congr rfl intro k _ unfold fullCoordinateAcceptedPostselectedMass simp only [Finset.mul_sum] apply Finset.sum_congr rfl intro r _ apply Finset.sum_congr rfl intro α _ apply Finset.sum_congr rfl intro β _ simp only [sourceHistoryRaw, sourceHistoryAcceptedQuestionMass, Finset.mul_sum] ring_nf _ = ∑ π : SourceRemainingPermutation D, ∑ k : Fin (Finset.univ \ D).card, sourceHistoryPermutationPositionWeight D * (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert (sourceRemainingPermutationCoordinate D π k) D)) := by apply Finset.sum_congr rfl intro π _ apply Finset.sum_congr rfl intro k _ rw [hlocal π k] _ = _ := by unfold sourceHistoryPermutationPositionWeight sourceUniformPermutationAverage simp_rw [one_div, div_eq_mul_inv] rw [Finset.sum_mul] apply Finset.sum_congr rfl intro π _ rw [Finset.sum_mul] apply Finset.sum_congr rfl intro k _ ring theorem sourceHistoryAcceptedMass_eq_remaining_average (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : sourceHistoryAcceptedMass G n S D = (∑ i : SourceRemainingCoordinate D, (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i.val D))) / ((Finset.univ \ D).card : ℝ) := by classical rw [sourceHistoryAcceptedMass_eq_uniform] have hperm := sourceRemainingPermutation_card_pos D unfold sourceUniformPermutationAverage simp_rw [sourceRemainingPermutationCoordinate_sum D _ (fun i : Fin n => (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i D)))] have hsum : (∑ _π : SourceRemainingPermutation D, ∑ i : SourceRemainingCoordinate D, (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i.val D))) = (Fintype.card (SourceRemainingPermutation D) : ℝ) * (∑ i : SourceRemainingCoordinate D, (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i.val D))) := by simp rw [hsum] exact mul_div_mul_left _ _ hperm.ne' theorem sourceHistoryAcceptedMass_gt_of_greedy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hm : 0 < (Finset.univ \ D).card) {η : ℝ} (hgreedy : (∑ i ∈ Finset.univ \ D, FiniteEventLaw.failureMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D i) < ((Finset.univ \ D).card : ℝ) * (η * (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D))) : (1 - η) * (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) < sourceHistoryAcceptedMass G n S D := by classical let p : ℝ := (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) have hmreal : 0 < ((Finset.univ \ D).card : ℝ) := by exact_mod_cast hm have hsub := Finset.sum_subtype (F := inferInstance) (Finset.univ \ D) (fun i : Fin n => Iff.rfl) (fun i : Fin n => (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i D))) have hfails : (∑ i ∈ Finset.univ \ D, FiniteEventLaw.failureMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D i) = ((Finset.univ \ D).card : ℝ) * p - (∑ i ∈ Finset.univ \ D, (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i D))) := by simp [FiniteEventLaw.failureMass, p, Finset.sum_sub_distrib] rw [sourceHistoryAcceptedMass_eq_remaining_average] rw [← hsub] apply (lt_div_iff₀ hmreal).mpr change (1 - η) * p * ((Finset.univ \ D).card : ℝ) < _ change (∑ i ∈ Finset.univ \ D, FiniteEventLaw.failureMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D i) < ((Finset.univ \ D).card : ℝ) * (η * p) at hgreedy nlinarith [hgreedy, hfails] end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 section TaggedTensorBlocks variable {R : Type*} [Fintype R] variable {ι : R → Type*} [∀ r, Fintype (ι r)] def taggedTensorVector (r : R) (z : EuclideanSpace ℂ (ι r × ι r)) : EuclideanSpace ℂ ((PUnit.{1} ⊕ (Σ r : R, ι r)) × (PUnit.{1} ⊕ (Σ r : R, ι r))) := by classical exact toLp 2 fun q => match q.1, q.2 with | .inr ⟨rA, a⟩, .inr ⟨rB, b⟩ => if hA : rA = r then if hB : rB = r then z (hA ▸ a, hB ▸ b) else 0 else 0 | _, _ => 0 theorem taggedTensorVector_norm (r : R) (z : EuclideanSpace ℂ (ι r × ι r)) : ‖taggedTensorVector r z‖ = ‖z‖ := by classical have hsquare : ‖taggedTensorVector r z‖ ^ 2 = ‖z‖ ^ 2 := by simp [EuclideanSpace.norm_sq_eq, taggedTensorVector, Fintype.sum_prod_type, Fintype.sum_sum_type, Fintype.sum_sigma] calc _ = ∑ a : ι r, ∑ rB : R, ∑ b : ι rB, ‖if hA : (r : R) = r then if hB : rB = r then z (hA ▸ a, hB ▸ b) else 0 else 0‖ ^ 2 := by apply Fintype.sum_eq_single r intro rA hA simp [hA] _ = ∑ a : ι r, ∑ rB : R, ∑ b : ι rB, ‖if hB : rB = r then z (a, hB ▸ b) else 0‖ ^ 2 := by simp _ = ∑ a : ι r, ∑ b : ι r, ‖if hB : (r : R) = r then z (a, hB ▸ b) else 0‖ ^ 2 := by apply Finset.sum_congr rfl intro a _ apply Fintype.sum_eq_single r intro rB hB simp [hB] _ = _ := by simp nlinarith [norm_nonneg (taggedTensorVector r z), norm_nonneg z] omit [Fintype R] [∀ r, Fintype (ι r)] in theorem taggedTensorVector_sub (r : R) (u v : EuclideanSpace ℂ (ι r × ι r)) : taggedTensorVector r (u - v) = taggedTensorVector r u - taggedTensorVector r v := by classical ext q rcases q with ⟨a, b⟩ rcases a with a | ⟨rA, a⟩ · rcases b with b | ⟨rB, b⟩ <;> simp [taggedTensorVector] · rcases b with b | ⟨rB, b⟩ · simp [taggedTensorVector] · by_cases hA : rA = r · subst rA by_cases hB : rB = r · subst rB simp [taggedTensorVector] · simp [taggedTensorVector, hB] · simp [taggedTensorVector, hA] end TaggedTensorBlocks variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem martingaleRate_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hm : 0 < (Finset.univ \ D).card) (hp : 0 < repeatedPostselectionMass G n S D) : 0 ≤ martingaleRate G n S D := by have hnonnegative := sourceUniformPermutationAverage_nonneg D (sourcePermutationAliceEntropyIncrement G n S D) (fun π k => sourcePermutationAliceEntropyIncrement_nonneg G n S D π k) have hbudget := aliceMartingaleEntropyBudget G n S D hm hp nlinarith end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem remainingCoordinate_card_pos {n : ℕ} (D : Finset (Fin n)) (hm : 0 < (Finset.univ \ D).card) : 0 < Fintype.card (SourceRemainingCoordinate D) := by simpa using hm theorem finiteTotalVariation_triangle {ι : Type*} [Fintype ι] (p q r : ι → ℝ) : finiteTotalVariation p r ≤ finiteTotalVariation p q + finiteTotalVariation q r := by unfold finiteTotalVariation calc (∑ i, |p i - r i|) / 2 ≤ ((∑ i, |p i - q i|) + (∑ i, |q i - r i|)) / 2 := by apply div_le_div_of_nonneg_right _ (by norm_num) rw [← Finset.sum_add_distrib] apply Finset.sum_le_sum intro i _ exact abs_sub_le (p i) (q i) (r i) _ = (∑ i, |p i - q i|) / 2 + (∑ i, |q i - r i|) / 2 := by ring def weightedConditionalJoint {κ ι : Type*} [Fintype κ] [Fintype ι] (weight : κ → ℝ) (conditional : κ → ι → ℝ) : κ × ι → ℝ := fun t => weight t.1 * conditional t.1 t.2 theorem weightedConditionalJoint_totalVariation {κ ι : Type*} [Fintype κ] [Fintype ι] (weight : κ → ℝ) (hweight : ∀ k, 0 ≤ weight k) (left right : κ → ι → ℝ) : finiteTotalVariation (weightedConditionalJoint weight left) (weightedConditionalJoint weight right) = ∑ k : κ, weight k * finiteTotalVariation (left k) (right k) := by unfold finiteTotalVariation weightedConditionalJoint rw [Fintype.sum_prod_type] calc (∑ k : κ, ∑ i : ι, |weight k * left k i - weight k * right k i|) / 2 = (∑ k : κ, weight k * (∑ i : ι, |left k i - right k i|)) / 2 := by congr 1 apply Finset.sum_congr rfl intro k _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ rw [← mul_sub, abs_mul, abs_of_nonneg (hweight k)] _ = ∑ k : κ, weight k * ((∑ i : ι, |left k i - right k i|) / 2) := by rw [Finset.sum_div] apply Finset.sum_congr rfl intro k _ ring theorem finiteTotalVariation_equiv {ι κ : Type*} [Fintype ι] [Fintype κ] (e : ι ≃ κ) (p q : κ → ℝ) : finiteTotalVariation (p ∘ e) (q ∘ e) = finiteTotalVariation p q := by unfold finiteTotalVariation congr 1 exact e.sum_comp (fun i => |p i - q i|) abbrev LocalQuestionContext (X Y : Type*) [Fintype X] [Fintype Y] {n : ℕ} (D : Finset (Fin n)) := SourceRemainingCoordinate D × (X × Y) def localQuestionWeight (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (c : LocalQuestionContext X Y D) : ℝ := G.questionWeight c.2.1 c.2.2 / (Fintype.card (SourceRemainingCoordinate D) : ℝ) theorem localQuestionWeight_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (c : LocalQuestionContext X Y D) : 0 ≤ localQuestionWeight G n D c := by exact div_nonneg (G.weight_nonneg c.2.1 c.2.2) (Nat.cast_nonneg _) theorem localQuestionWeight_sum (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (hm : 0 < (Finset.univ \ D).card) : (∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c) = 1 := by have hcard : (Fintype.card (SourceRemainingCoordinate D) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (remainingCoordinate_card_pos D hm)) calc (∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c) = (∑ i : SourceRemainingCoordinate D, ∑ x : X, ∑ y : Y, G.questionWeight x y) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) := by simp only [localQuestionWeight, Fintype.sum_prod_type] simp_rw [← Finset.sum_div] _ = 1 := by simp_rw [G.weight_normalized] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] exact div_self hcard def conditionedEventDistribution {Ω : Type*} [Fintype Ω] (law : FiniteEventLaw Ω) (event : Finset Ω) : Ω → ℝ := fun ω => if ω ∈ event then law.weight ω / law.eventMass event else 0 theorem conditionedEventDistribution_nonneg {Ω : Type*} [Fintype Ω] (law : FiniteEventLaw Ω) (event : Finset Ω) (positive : 0 < law.eventMass event) (ω : Ω) : 0 ≤ conditionedEventDistribution law event ω := by unfold conditionedEventDistribution split_ifs · exact div_nonneg (law.weight_nonneg ω) positive.le · exact le_rfl theorem conditionedEventDistribution_sum {Ω : Type*} [Fintype Ω] (law : FiniteEventLaw Ω) (event : Finset Ω) (positive : 0 < law.eventMass event) : (∑ ω : Ω, conditionedEventDistribution law event ω) = 1 := by classical unfold conditionedEventDistribution calc (∑ ω : Ω, if ω ∈ event then law.weight ω / law.eventMass event else 0) = (∑ ω ∈ event, law.weight ω) / law.eventMass event := by rw [Finset.sum_div] simp _ = 1 := by change law.eventMass event / law.eventMass event = 1 exact div_self positive.ne' theorem conditionedEventDistribution_absolute_continuity {Ω : Type*} [Fintype Ω] (law : FiniteEventLaw Ω) (event : Finset Ω) (ω : Ω) : law.weight ω = 0 → conditionedEventDistribution law event ω = 0 := by intro hzero simp [conditionedEventDistribution, hzero] theorem conditionedEventDistribution_relativeEntropy {Ω : Type*} [Fintype Ω] (law : FiniteEventLaw Ω) (event : Finset Ω) (positive : 0 < law.eventMass event) : finiteRelativeEntropy (conditionedEventDistribution law event) law.weight = Real.log (1 / law.eventMass event) := by rw [finiteRelativeEntropy_eq_log_sum_of_absolute_continuity (conditionedEventDistribution law event) law.weight law.weight_nonneg (conditionedEventDistribution_absolute_continuity law event) (conditionedEventDistribution_sum law event positive) law.weight_sum] calc (∑ ω : Ω, conditionedEventDistribution law event ω * Real.log (conditionedEventDistribution law event ω / law.weight ω)) = ∑ ω : Ω, conditionedEventDistribution law event ω * Real.log (1 / law.eventMass event) := by apply Finset.sum_congr rfl intro ω _ by_cases hmem : ω ∈ event · by_cases hweight : law.weight ω = 0 · simp [conditionedEventDistribution, hmem, hweight] · have hratio : (law.weight ω / law.eventMass event) / law.weight ω = 1 / law.eventMass event := by field_simp [hweight, positive.ne'] simp only [conditionedEventDistribution, if_pos hmem, hratio] · simp [conditionedEventDistribution, hmem] _ = Real.log (1 / law.eventMass event) := by rw [← Finset.sum_mul, conditionedEventDistribution_sum law event positive] ring theorem conditionedEventDistribution_projection_relativeEntropy_le {Ω κ : Type*} [Fintype Ω] [Fintype κ] (law : FiniteEventLaw Ω) (event : Finset Ω) (positive : 0 < law.eventMass event) (projection : Ω → κ) : finiteRelativeEntropy (groupedMass projection (conditionedEventDistribution law event)) (groupedMass projection law.weight) ≤ Real.log (1 / law.eventMass event) := by calc finiteRelativeEntropy (groupedMass projection (conditionedEventDistribution law event)) (groupedMass projection law.weight) ≤ finiteRelativeEntropy (conditionedEventDistribution law event) law.weight := finite_relative_entropy_data_processing projection (conditionedEventDistribution law event) law.weight (conditionedEventDistribution_nonneg law event positive) law.weight_nonneg (conditionedEventDistribution_absolute_continuity law event) _ = Real.log (1 / law.eventMass event) := conditionedEventDistribution_relativeEntropy law event positive def repeatedConditionedOutcomeLaw (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : StrategyOutcome (Fin n → X) (Fin n → Y) (Fin n → A) (Fin n → B) → ℝ := conditionedEventDistribution (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) theorem repeatedConditionedOutcomeLaw_relativeEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hp : 0 < repeatedPostselectionMass G n S D) : finiteRelativeEntropy (repeatedConditionedOutcomeLaw G n S D) (strategyEventLaw (G.repeat n) S).weight = postselectionLogCost G n S D := by exact conditionedEventDistribution_relativeEntropy (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) hp end noncomputable section open scoped BigOperators open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def finiteUniformWeight (Z : Type*) [Fintype Z] : ℝ := 1 / (Fintype.card Z : ℝ) theorem finiteUniformWeight_pos {Z : Type*} [Fintype Z] (positive : 0 < Fintype.card Z) : 0 < finiteUniformWeight Z := by unfold finiteUniformWeight exact one_div_pos.mpr (by exact_mod_cast positive) theorem finiteUniformWeight_sum {Z : Type*} [Fintype Z] (positive : 0 < Fintype.card Z) : (∑ _z : Z, finiteUniformWeight Z) = 1 := by have hcard : (Fintype.card Z : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt positive) unfold finiteUniformWeight simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] field_simp [hcard] theorem finiteProbability_le_one {Z : Type*} [Fintype Z] (p : Z → ℝ) (nonnegative : ∀ z, 0 ≤ p z) (normalized : (∑ z, p z) = 1) (z : Z) : p z ≤ 1 := by calc p z ≤ ∑ a : Z, p a := Finset.single_le_sum (fun a _ => nonnegative a) (Finset.mem_univ z) _ = 1 := normalized theorem finiteRelativeEntropy_uniform_le_log_card {Z : Type*} [Fintype Z] (p : Z → ℝ) (nonnegative : ∀ z, 0 ≤ p z) (normalized : (∑ z, p z) = 1) (positive : 0 < Fintype.card Z) : finiteRelativeEntropy p (fun _ : Z => finiteUniformWeight Z) ≤ Real.log (Fintype.card Z : ℝ) := by have hcardpos : 0 < (Fintype.card Z : ℝ) := by exact_mod_cast positive have hcardne : (Fintype.card Z : ℝ) ≠ 0 := hcardpos.ne' rw [finiteRelativeEntropy_eq_log_sum p (fun _ : Z => finiteUniformWeight Z) (fun _ => finiteUniformWeight_pos positive) normalized (finiteUniformWeight_sum positive)] calc (∑ z : Z, p z * Real.log (p z / finiteUniformWeight Z)) ≤ ∑ z : Z, p z * Real.log (Fintype.card Z : ℝ) := by apply Finset.sum_le_sum intro z _ by_cases hzero : p z = 0 · simp [hzero] · have hp : 0 < p z := lt_of_le_of_ne (nonnegative z) (Ne.symm hzero) have hpone : p z ≤ 1 := finiteProbability_le_one p nonnegative normalized z have hratio : p z / finiteUniformWeight Z = p z * (Fintype.card Z : ℝ) := by unfold finiteUniformWeight field_simp [hcardne] rw [hratio] apply mul_le_mul_of_nonneg_left _ (nonnegative z) apply Real.log_le_log (mul_pos hp hcardpos) nlinarith _ = Real.log (Fintype.card Z : ℝ) := by rw [← Finset.sum_mul, normalized] ring def uniformFlagReference {Ω Z : Type*} [Fintype Ω] [Fintype Z] (prior : Ω → ℝ) : Ω × Z → ℝ := fun t => prior t.1 * finiteUniformWeight Z theorem uniformFlagReference_nonneg {Ω Z : Type*} [Fintype Ω] [Fintype Z] (prior : Ω → ℝ) (nonnegative : ∀ ω, 0 ≤ prior ω) (positive : 0 < Fintype.card Z) (t : Ω × Z) : 0 ≤ uniformFlagReference (Z := Z) prior t := by exact mul_nonneg (nonnegative t.1) (finiteUniformWeight_pos positive).le theorem uniformFlagReference_sum {Ω Z : Type*} [Fintype Ω] [Fintype Z] (prior : Ω → ℝ) (normalized : (∑ ω, prior ω) = 1) (positive : 0 < Fintype.card Z) : (∑ t : Ω × Z, uniformFlagReference (Z := Z) prior t) = 1 := by rw [Fintype.sum_prod_type] unfold uniformFlagReference simp_rw [← Finset.mul_sum, finiteUniformWeight_sum positive, mul_one] exact normalized theorem uniformFlagReference_firstMarginal {Ω Z : Type*} [Fintype Ω] [Fintype Z] (prior : Ω → ℝ) (positive : 0 < Fintype.card Z) : jointFirstMarginal (uniformFlagReference (Z := Z) prior) = prior := by funext ω change (∑ z : Z, prior ω * finiteUniformWeight Z) = prior ω rw [← Finset.mul_sum, finiteUniformWeight_sum positive] ring theorem uniformFlagReference_conditional {Ω Z : Type*} [Fintype Ω] [Fintype Z] (prior : Ω → ℝ) (positive : 0 < Fintype.card Z) (ω : Ω) (hprior : prior ω ≠ 0) : jointConditional (uniformFlagReference (Z := Z) prior) ω = fun _ : Z => finiteUniformWeight Z := by funext z unfold jointConditional rw [uniformFlagReference_firstMarginal prior positive] change prior ω * finiteUniformWeight Z / prior ω = finiteUniformWeight Z field_simp [hprior] theorem uniformFlagReference_absolute_continuity {Ω Z : Type*} [Fintype Ω] [Fintype Z] (joint : Ω × Z → ℝ) (prior : Ω → ℝ) (hjoint : ∀ t, 0 ≤ joint t) (absolute_continuity : ∀ ω, prior ω = 0 → jointFirstMarginal joint ω = 0) (positive : 0 < Fintype.card Z) (t : Ω × Z) : uniformFlagReference (Z := Z) prior t = 0 → joint t = 0 := by rcases t with ⟨ω, z⟩ intro hzero change prior ω * finiteUniformWeight Z = 0 at hzero have hflag : finiteUniformWeight Z ≠ 0 := (finiteUniformWeight_pos positive).ne' have hprior : prior ω = 0 := (mul_eq_zero.mp hzero).resolve_right hflag have hmarginal := absolute_continuity ω hprior change (∑ a : Z, joint (ω, a)) = 0 at hmarginal exact (Finset.sum_eq_zero_iff_of_nonneg (fun a _ => hjoint (ω, a))).mp hmarginal z (Finset.mem_univ z) theorem uniformFlagRelativeEntropy_le {Ω Z : Type*} [Fintype Ω] [Fintype Z] (joint : Ω × Z → ℝ) (prior : Ω → ℝ) (hjoint : ∀ t, 0 ≤ joint t) (hprior : ∀ ω, 0 ≤ prior ω) (joint_normalized : (∑ t, joint t) = 1) (prior_normalized : (∑ ω, prior ω) = 1) (absolute_continuity : ∀ ω, prior ω = 0 → jointFirstMarginal joint ω = 0) (positive : 0 < Fintype.card Z) : finiteRelativeEntropy joint (uniformFlagReference (Z := Z) prior) ≤ finiteRelativeEntropy (jointFirstMarginal joint) prior + Real.log (Fintype.card Z : ℝ) := by have hreference_nonneg := uniformFlagReference_nonneg prior hprior positive have hreference_normalized := uniformFlagReference_sum prior prior_normalized positive have hreference_absolute := uniformFlagReference_absolute_continuity joint prior hjoint absolute_continuity positive have hmarginal_normalized : (∑ ω : Ω, jointFirstMarginal joint ω) = 1 := (jointFirstMarginal_sum joint).trans joint_normalized have hmarginal_nonnegative : ∀ ω : Ω, 0 ≤ jointFirstMarginal joint ω := jointFirstMarginal_nonneg joint hjoint rw [finite_relative_entropy_joint_chain_rule joint (uniformFlagReference (Z := Z) prior) hjoint hreference_nonneg hreference_absolute joint_normalized hreference_normalized, uniformFlagReference_firstMarginal prior positive] gcongr calc (∑ ω : Ω, jointFirstMarginal joint ω * finiteRelativeEntropy (jointConditional joint ω) (jointConditional (uniformFlagReference (Z := Z) prior) ω)) ≤ ∑ ω : Ω, jointFirstMarginal joint ω * Real.log (Fintype.card Z : ℝ) := by apply Finset.sum_le_sum intro ω _ by_cases hmass : jointFirstMarginal joint ω = 0 · simp [hmass] · have hprior_ne : prior ω ≠ 0 := by intro hzero exact hmass (absolute_continuity ω hzero) rw [uniformFlagReference_conditional prior positive ω hprior_ne] apply mul_le_mul_of_nonneg_left _ (hmarginal_nonnegative ω) apply finiteRelativeEntropy_uniform_le_log_card · intro z exact div_nonneg (hjoint (ω, z)) (hmarginal_nonnegative ω) · exact jointConditional_sum joint ω hmass · exact positive _ = Real.log (Fintype.card Z : ℝ) := by rw [← Finset.sum_mul, hmarginal_normalized] ring theorem finiteRelativeEntropy_nonneg {Ω : Type*} [Fintype Ω] (p q : Ω → ℝ) (hp : ∀ ω, 0 ≤ p ω) (hq : ∀ ω, 0 ≤ q ω) : 0 ≤ finiteRelativeEntropy p q := by unfold finiteRelativeEntropy apply Finset.sum_nonneg intro ω _ exact mul_nonneg (hq ω) (InformationTheory.klFun_nonneg (div_nonneg (hp ω) (hq ω))) theorem groupedMass_nonneg {Ω κ : Type*} [Fintype Ω] [Fintype κ] [DecidableEq κ] (f : Ω → κ) (p : Ω → ℝ) (hp : ∀ ω, 0 ≤ p ω) (a : κ) : 0 ≤ groupedMass f p a := by unfold groupedMass exact Finset.sum_nonneg (fun ω _ => hp ω) theorem groupedMass_absolute_continuity {Ω κ : Type*} [Fintype Ω] [Fintype κ] [DecidableEq κ] (f : Ω → κ) (p q : Ω → ℝ) (hq : ∀ ω, 0 ≤ q ω) (absolute_continuity : ∀ ω, q ω = 0 → p ω = 0) (a : κ) : groupedMass f q a = 0 → groupedMass f p a = 0 := by intro hzero change (∑ ω ∈ (Finset.univ.filter fun ω => f ω = a), q ω) = 0 at hzero change (∑ ω ∈ (Finset.univ.filter fun ω => f ω = a), p ω) = 0 apply Finset.sum_eq_zero intro ω hω have hqzero : q ω = 0 := (Finset.sum_eq_zero_iff_of_nonneg (fun ω _ => hq ω)).mp hzero ω hω exact absolute_continuity ω hqzero theorem groupedMass_comp {Ω κ θ : Type*} [Fintype Ω] [Fintype κ] [Fintype θ] [DecidableEq κ] [DecidableEq θ] (f : Ω → κ) (g : κ → θ) (p : Ω → ℝ) : groupedMass g (groupedMass f p) = groupedMass (g ∘ f) p := by funext a unfold groupedMass simpa only [Finset.mem_filter, Finset.mem_univ, true_and, Function.comp_apply] using (Finset.sum_fiberwise_eq_sum_filter (Finset.univ : Finset Ω) (Finset.univ.filter fun b : κ => g b = a) f p) theorem groupedMass_id {Ω : Type*} [Fintype Ω] [DecidableEq Ω] (p : Ω → ℝ) : groupedMass id p = p := by funext ω have hfilter : (Finset.univ.filter fun a : Ω => a = ω) = {ω} := by ext a simp unfold groupedMass change (∑ a ∈ (Finset.univ.filter fun a : Ω => a = ω), p a) = p ω rw [hfilter] simp def finitePrefixMask {Ω Y : Type*} {h : ℕ} (base : Y) (k : Fin (h + 1)) : (Ω × (Fin h → Y)) → (Ω × (Fin h → Y)) := fun t => (t.1, fun j => if j.val < k.val then t.2 j else base) theorem finitePrefixMask_comp {Ω Y : Type*} {h : ℕ} (base : Y) (k : Fin h) : finitePrefixMask (Ω := Ω) base k.castSucc ∘ finitePrefixMask (Ω := Ω) base k.succ = finitePrefixMask (Ω := Ω) base k.castSucc := by funext t rcases t with ⟨ω, values⟩ apply Prod.ext · rfl · funext j by_cases hj : j.val < k.val · have hjfin : j < k := hj have hjle : j ≤ k := le_of_lt hjfin simp [finitePrefixMask, Function.comp_apply, hjfin, hjle] · have hjfin : ¬ j < k := hj simp [finitePrefixMask, Function.comp_apply, hjfin] theorem finitePrefixMask_last {Ω Y : Type*} {h : ℕ} (base : Y) : finitePrefixMask (Ω := Ω) base (Fin.last h) = id := by funext t rcases t with ⟨ω, values⟩ apply Prod.ext · rfl · funext j simp [finitePrefixMask] def finitePrefixRelativeEntropy {Ω Y : Type*} [Fintype Ω] [Fintype Y] {h : ℕ} (joint prior : Ω × (Fin h → Y) → ℝ) (base : Y) (k : Fin (h + 1)) : ℝ := finiteRelativeEntropy (groupedMass (finitePrefixMask base k) joint) (groupedMass (finitePrefixMask base k) prior) theorem finitePrefixRelativeEntropy_telescope {Ω Y : Type*} [Fintype Ω] [Fintype Y] {h : ℕ} (joint prior : Ω × (Fin h → Y) → ℝ) (base : Y) : (∑ k : Fin h, (finitePrefixRelativeEntropy joint prior base k.succ - finitePrefixRelativeEntropy joint prior base k.castSucc)) = finiteRelativeEntropy joint prior - finitePrefixRelativeEntropy joint prior base 0 := by have hfirst := Fin.sum_univ_succ (fun k : Fin (h + 1) => finitePrefixRelativeEntropy joint prior base k) have hlast := Fin.sum_univ_castSucc (fun k : Fin (h + 1) => finitePrefixRelativeEntropy joint prior base k) have hendpoint : finitePrefixRelativeEntropy joint prior base (Fin.last h) = finiteRelativeEntropy joint prior := by simp only [finitePrefixRelativeEntropy, finitePrefixMask_last, groupedMass_id] rw [Finset.sum_sub_distrib] linarith theorem finitePrefixRelativeEntropy_budget {Ω Y : Type*} [Fintype Ω] [Fintype Y] {h : ℕ} (joint prior : Ω × (Fin h → Y) → ℝ) (hjoint : ∀ t, 0 ≤ joint t) (hprior : ∀ t, 0 ≤ prior t) (base : Y) : (∑ k : Fin h, (finitePrefixRelativeEntropy joint prior base k.succ - finitePrefixRelativeEntropy joint prior base k.castSucc)) ≤ finiteRelativeEntropy joint prior := by rw [finitePrefixRelativeEntropy_telescope] have hzero : 0 ≤ finitePrefixRelativeEntropy joint prior base 0 := finiteRelativeEntropy_nonneg (groupedMass (finitePrefixMask base 0) joint) (groupedMass (finitePrefixMask base 0) prior) (groupedMass_nonneg (finitePrefixMask base 0) joint hjoint) (groupedMass_nonneg (finitePrefixMask base 0) prior hprior) linarith theorem reversePartition_relativeEntropy_budget {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (increment : (s : Finset M) → Fin s.card → ℝ) {cost : ℝ} (hcost : 0 ≤ cost) (hbudget : ∀ s : Finset M, (∑ k : Fin s.card, increment s k) ≤ cost) : (∑ s : Finset M, reversePartitionWeight s * ((∑ k : Fin s.card, increment s k) / (s.card : ℝ))) ≤ 2 * cost / (Fintype.card M : ℝ) := by have hcard : 0 < (Fintype.card M : ℝ) := by exact_mod_cast nonempty calc (∑ s : Finset M, reversePartitionWeight s * ((∑ k : Fin s.card, increment s k) / (s.card : ℝ))) ≤ ∑ s : Finset M, fairPartitionWeight M * (2 * cost / (Fintype.card M : ℝ)) := by apply Finset.sum_le_sum intro s _ by_cases hs : s.card = 0 · have hempty : s = ∅ := Finset.card_eq_zero.mp hs subst s simp only [reversePartitionWeight_empty, zero_mul] exact mul_nonneg (fairPartitionWeight_nonneg (α := M)) (div_nonneg (mul_nonneg (by norm_num) hcost) hcard.le) · have hsreal : (s.card : ℝ) ≠ 0 := by exact_mod_cast hs calc reversePartitionWeight s * ((∑ k : Fin s.card, increment s k) / (s.card : ℝ)) = (fairPartitionWeight M * (2 / (Fintype.card M : ℝ))) * (∑ k : Fin s.card, increment s k) := by unfold reversePartitionWeight field_simp [hsreal, hcard.ne'] _ ≤ (fairPartitionWeight M * (2 / (Fintype.card M : ℝ))) * cost := by apply mul_le_mul_of_nonneg_left (hbudget s) exact mul_nonneg (fairPartitionWeight_nonneg (α := M)) (div_nonneg (by norm_num) hcard.le) _ = fairPartitionWeight M * (2 * cost / (Fintype.card M : ℝ)) := by ring _ = 2 * cost / (Fintype.card M : ℝ) := by rw [← Finset.sum_mul, fairPartitionWeight_sum (α := M)] ring end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem groupedMass_sum {Ω κ : Type*} [Fintype Ω] [Fintype κ] [DecidableEq κ] (projection : Ω → κ) (mass : Ω → ℝ) : (∑ a : κ, groupedMass projection mass a) = ∑ ω : Ω, mass ω := by unfold groupedMass exact Finset.sum_fiberwise Finset.univ projection mass theorem groupedMass_first {Ω Z : Type*} [Fintype Ω] [Fintype Z] [DecidableEq Ω] (joint : Ω × Z → ℝ) : groupedMass Prod.fst joint = jointFirstMarginal joint := by funext ω classical simp only [groupedMass, jointFirstMarginal, Finset.sum_filter, Fintype.sum_prod_type] rw [Finset.sum_comm] simp abbrev ConditionedAnswerFlag (A B : Type*) [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) := ({i : Fin n // i ∈ D} → A) × ({i : Fin n // i ∈ D} → B) def repeatedConditionedAnswerFlag (G : Game X Y A B) (n : ℕ) (_S : Strategy (G.repeat n)) (D : Finset (Fin n)) (ω : StrategyOutcome (Fin n → X) (Fin n → Y) (Fin n → A) (Fin n → B)) : ConditionedAnswerFlag A B D := (fun i => ω.2.2.1 i, fun i => ω.2.2.2 i) theorem conditionedAnswerFlag_card {n : ℕ} (D : Finset (Fin n)) : (Fintype.card (ConditionedAnswerFlag A B D) : ℝ) = fullHistoryAnswerCount (A := A) (B := B) D := by simp [fullHistoryAnswerCount] theorem conditionedAnswerFlag_card_pos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hp : 0 < repeatedPostselectionMass G n S D) : 0 < Fintype.card (ConditionedAnswerFlag A B D) := by have hreal : 0 < (Fintype.card (ConditionedAnswerFlag A B D) : ℝ) := by rw [conditionedAnswerFlag_card] exact answerCount_pos_of_postselection G n S D hp exact_mod_cast hreal theorem conditionedAnswerFlag_log_card (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (hp : 0 < repeatedPostselectionMass G n S D) : Real.log (Fintype.card (ConditionedAnswerFlag A B D) : ℝ) = answerLogCost (A := A) (B := B) D := by rw [conditionedAnswerFlag_card] have hanswer := answerCount_pos_of_postselection G n S D hp have hcost := martingale_log_cost_eq G n S D hp have hsplit := Real.log_div hanswer.ne' hp.ne' have hpost : postselectionLogCost G n S D = -Real.log (repeatedPostselectionMass G n S D) := by simp [postselectionLogCost, one_div, Real.log_inv] linarith end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactOutcome (X Y A B : Type*) (n : ℕ) := StrategyOutcome (Fin n → X) (Fin n → Y) (Fin n → A) (Fin n → B) abbrev ExactJointOutcome (X Y A B : Type*) {n : ℕ} (D : Finset (Fin n)) := ExactRemainingSeed D × ExactOutcome X Y A B n theorem exactRemainingSeedWeight_sum {n : ℕ} (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) : (∑ seed : ExactRemainingSeed D, exactSeedWeight seed) = 1 := by apply exactSeedWeight_sum simpa using remaining def exactPostselectedJointLaw (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (q : ExactJointOutcome X Y A B D) : ℝ := exactSeedWeight q.1 * repeatedConditionedOutcomeLaw G n S D q.2 theorem exactPostselectedJointLaw_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (q : ExactJointOutcome X Y A B D) : 0 ≤ exactPostselectedJointLaw G n S D q := by apply mul_nonneg (exactSeedWeight_nonneg q.1) exact conditionedEventDistribution_nonneg (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive q.2 theorem exactPostselectedJointLaw_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ q : ExactJointOutcome X Y A B D, exactPostselectedJointLaw G n S D q) = 1 := by have hconditional_sum : (∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome) = 1 := by exact conditionedEventDistribution_sum (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive unfold exactPostselectedJointLaw rw [Fintype.sum_prod_type] calc (∑ seed : ExactRemainingSeed D, ∑ outcome : ExactOutcome X Y A B n, exactSeedWeight seed * repeatedConditionedOutcomeLaw G n S D outcome) = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * (∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome) := by simp_rw [Finset.mul_sum] _ = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed := by rw [hconditional_sum] simp _ = 1 := exactRemainingSeedWeight_sum D remaining def exactSourcePushforward {K : Type*} [Fintype K] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : ExactJointOutcome X Y A B D → K) : K → ℝ := groupedMass projection (exactPostselectedJointLaw G n S D) theorem exactSourcePushforward_nonneg {K : Type*} [Fintype K] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : ExactJointOutcome X Y A B D → K) (k : K) : 0 ≤ exactSourcePushforward G n S D projection k := by exact groupedMass_nonneg projection (exactPostselectedJointLaw G n S D) (exactPostselectedJointLaw_nonneg G n S D positive) k theorem exactSourcePushforward_sum {K : Type*} [Fintype K] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (projection : ExactJointOutcome X Y A B D → K) : (∑ k : K, exactSourcePushforward G n S D projection k) = 1 := by unfold exactSourcePushforward rw [groupedMass_sum] exact exactPostselectedJointLaw_sum G n S D remaining positive end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactLocallySampleableTuple (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) := SourceRemainingCoordinate D × (X × (Y × ExactHistoryFlag X Y A B D)) def exactHistoryCode {n : ℕ} (D : Finset (Fin n)) (q : ExactJointOutcome X Y A B D) : ExactHistoryFlag X Y A B D where seed := q.1 history := exactRevealCode D q.1 (q.2.1, q.2.2.1) aliceAnswer := fun j => q.2.2.2.1 j.val bobAnswer := fun j => q.2.2.2.2 j.val def exactLocallySampleableCode {n : ℕ} (D : Finset (Fin n)) (q : ExactJointOutcome X Y A B D) : ExactLocallySampleableTuple X Y A B D := (q.1.coordinate, q.2.1 q.1.coordinate.val, q.2.2.1 q.1.coordinate.val, exactHistoryCode D q) def exactLocallySampleableLaw (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ExactLocallySampleableTuple X Y A B D → ℝ := exactSourcePushforward G n S D (exactLocallySampleableCode D) theorem exactLocallySampleableLaw_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (t : ExactLocallySampleableTuple X Y A B D) : 0 ≤ exactLocallySampleableLaw G n S D t := exactSourcePushforward_nonneg G n S D positive (exactLocallySampleableCode D) t theorem exactLocallySampleableLaw_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t) = 1 := exactSourcePushforward_sum G n S D remaining positive (exactLocallySampleableCode D) theorem exactLocallySampleableLaw_eq_zero_of_question_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (x : X) (y : Y) (r : ExactHistoryFlag X Y A B D) (zero : G.questionWeight x y = 0) : exactLocallySampleableLaw G n S D (i, x, y, r) = 0 := by classical unfold exactLocallySampleableLaw exactSourcePushforward groupedMass apply Finset.sum_eq_zero intro q hq have hcode : exactLocallySampleableCode D q = (i, x, y, r) := by exact ((@Finset.mem_filter (ExactJointOutcome X Y A B D) (fun a => exactLocallySampleableCode D a = (i, x, y, r)) (fun _ => Classical.propDecidable _) Finset.univ q).mp hq).2 have hx : q.2.1 q.1.coordinate.val = x := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.1) hcode have hy : q.2.2.1 q.1.coordinate.val = y := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.1) hcode have hproduct : (G.repeat n).questionWeight q.2.1 q.2.2.1 = 0 := by rw [Game.repeat_questionWeight] apply Finset.prod_eq_zero (Finset.mem_univ q.1.coordinate.val) simpa [hx, hy] using zero have hprod : (∏ j : Fin n, G.questionWeight (q.2.1 j) (q.2.2.1 j)) = 0 := by simpa only [Game.repeat_questionWeight] using hproduct simp [exactPostselectedJointLaw, repeatedConditionedOutcomeLaw, conditionedEventDistribution, strategyEventLaw, hprod] def exactAliceLocalMass {n : ℕ} (D : Finset (Fin n)) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (i : SourceRemainingCoordinate D) (x : X) : ℝ := ∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, Q (i, x, y, r) def exactBobLocalMass {n : ℕ} (D : Finset (Fin n)) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (i : SourceRemainingCoordinate D) (y : Y) : ℝ := ∑ r : ExactHistoryFlag X Y A B D, ∑ x : X, Q (i, x, y, r) theorem exactAliceLocalMass_nonneg {n : ℕ} (D : Finset (Fin n)) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (i : SourceRemainingCoordinate D) (x : X) : 0 ≤ exactAliceLocalMass D Q i x := by unfold exactAliceLocalMass exact Finset.sum_nonneg (fun r _ => Finset.sum_nonneg (fun y _ => nonnegative (i, x, y, r))) theorem exactBobLocalMass_nonneg {n : ℕ} (D : Finset (Fin n)) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (i : SourceRemainingCoordinate D) (y : Y) : 0 ≤ exactBobLocalMass D Q i y := by unfold exactBobLocalMass exact Finset.sum_nonneg (fun r _ => Finset.sum_nonneg (fun x _ => nonnegative (i, x, y, r))) def exactAliceLocalConditional {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (i : SourceRemainingCoordinate D) (x : X) (r : ExactHistoryFlag X Y A B D) : ℝ := if exactAliceLocalMass D Q i x = 0 then if r = base then 1 else 0 else (∑ y : Y, Q (i, x, y, r)) / exactAliceLocalMass D Q i x def exactBobLocalConditional {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (i : SourceRemainingCoordinate D) (y : Y) (r : ExactHistoryFlag X Y A B D) : ℝ := if exactBobLocalMass D Q i y = 0 then if r = base then 1 else 0 else (∑ x : X, Q (i, x, y, r)) / exactBobLocalMass D Q i y theorem exactAliceLocalConditional_nonneg {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (i : SourceRemainingCoordinate D) (x : X) (r : ExactHistoryFlag X Y A B D) : 0 ≤ exactAliceLocalConditional D base Q i x r := by unfold exactAliceLocalConditional split_ifs with hmass hbase · exact zero_le_one · exact le_rfl · exact div_nonneg (Finset.sum_nonneg (fun y _ => nonnegative (i, x, y, r))) (exactAliceLocalMass_nonneg D Q nonnegative i x) theorem exactBobLocalConditional_nonneg {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (i : SourceRemainingCoordinate D) (y : Y) (r : ExactHistoryFlag X Y A B D) : 0 ≤ exactBobLocalConditional D base Q i y r := by unfold exactBobLocalConditional split_ifs with hmass hbase · exact zero_le_one · exact le_rfl · exact div_nonneg (Finset.sum_nonneg (fun x _ => nonnegative (i, x, y, r))) (exactBobLocalMass_nonneg D Q nonnegative i y) theorem exactAliceLocalMass_zero_apply {n : ℕ} (D : Finset (Fin n)) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (i : SourceRemainingCoordinate D) (x : X) (y : Y) (r : ExactHistoryFlag X Y A B D) (zero : exactAliceLocalMass D Q i x = 0) : Q (i, x, y, r) = 0 := by change (∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, Q (i, x, y, r)) = 0 at zero have hr : (∑ y : Y, Q (i, x, y, r)) = 0 := (Finset.sum_eq_zero_iff_of_nonneg (fun r _ => Finset.sum_nonneg (fun y _ => nonnegative (i, x, y, r)))).mp zero r (Finset.mem_univ r) exact (Finset.sum_eq_zero_iff_of_nonneg (fun y _ => nonnegative (i, x, y, r))).mp hr y (Finset.mem_univ y) theorem exactBobLocalMass_zero_apply {n : ℕ} (D : Finset (Fin n)) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (i : SourceRemainingCoordinate D) (x : X) (y : Y) (r : ExactHistoryFlag X Y A B D) (zero : exactBobLocalMass D Q i y = 0) : Q (i, x, y, r) = 0 := by change (∑ r : ExactHistoryFlag X Y A B D, ∑ x : X, Q (i, x, y, r)) = 0 at zero have hr : (∑ x : X, Q (i, x, y, r)) = 0 := (Finset.sum_eq_zero_iff_of_nonneg (fun r _ => Finset.sum_nonneg (fun x _ => nonnegative (i, x, y, r)))).mp zero r (Finset.mem_univ r) exact (Finset.sum_eq_zero_iff_of_nonneg (fun x _ => nonnegative (i, x, y, r))).mp hr x (Finset.mem_univ x) theorem exactAliceLocalConditional_zero_apply {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (i : SourceRemainingCoordinate D) (x : X) (y : Y) (r : ExactHistoryFlag X Y A B D) (zero : exactAliceLocalConditional D base Q i x r = 0) : Q (i, x, y, r) = 0 := by by_cases hmass : exactAliceLocalMass D Q i x = 0 · exact exactAliceLocalMass_zero_apply D Q nonnegative i x y r hmass · unfold exactAliceLocalConditional at zero rw [if_neg hmass] at zero have hfiber : (∑ y : Y, Q (i, x, y, r)) = 0 := (div_eq_zero_iff.mp zero).resolve_right hmass exact (Finset.sum_eq_zero_iff_of_nonneg (fun y _ => nonnegative (i, x, y, r))).mp hfiber y (Finset.mem_univ y) theorem exactBobLocalConditional_zero_apply {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (i : SourceRemainingCoordinate D) (x : X) (y : Y) (r : ExactHistoryFlag X Y A B D) (zero : exactBobLocalConditional D base Q i y r = 0) : Q (i, x, y, r) = 0 := by by_cases hmass : exactBobLocalMass D Q i y = 0 · exact exactBobLocalMass_zero_apply D Q nonnegative i x y r hmass · unfold exactBobLocalConditional at zero rw [if_neg hmass] at zero have hfiber : (∑ x : X, Q (i, x, y, r)) = 0 := (div_eq_zero_iff.mp zero).resolve_right hmass exact (Finset.sum_eq_zero_iff_of_nonneg (fun x _ => nonnegative (i, x, y, r))).mp hfiber x (Finset.mem_univ x) theorem exactAliceLocalConditional_sum {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (i : SourceRemainingCoordinate D) (x : X) : (∑ r : ExactHistoryFlag X Y A B D, exactAliceLocalConditional D base Q i x r) = 1 := by unfold exactAliceLocalConditional split_ifs with hmass · simp · rw [← Finset.sum_div] exact div_self hmass theorem exactBobLocalConditional_sum {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (i : SourceRemainingCoordinate D) (y : Y) : (∑ r : ExactHistoryFlag X Y A B D, exactBobLocalConditional D base Q i y r) = 1 := by unfold exactBobLocalConditional split_ifs with hmass · simp · rw [← Finset.sum_div] exact div_self hmass def exactLocallySampleableJA (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (t : ExactLocallySampleableTuple X Y A B D) : ℝ := G.questionWeight t.2.1 t.2.2.1 * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) t.1 t.2.1 t.2.2.2 / (Fintype.card (SourceRemainingCoordinate D) : ℝ) def exactLocallySampleableJB (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (t : ExactLocallySampleableTuple X Y A B D) : ℝ := G.questionWeight t.2.1 t.2.2.1 * exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) t.1 t.2.2.1 t.2.2.2 / (Fintype.card (SourceRemainingCoordinate D) : ℝ) theorem exactLocallySampleableJA_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (t : ExactLocallySampleableTuple X Y A B D) : 0 ≤ exactLocallySampleableJA G n S D base t := by unfold exactLocallySampleableJA exact div_nonneg (mul_nonneg (G.weight_nonneg t.2.1 t.2.2.1) (exactAliceLocalConditional_nonneg D base (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive) t.1 t.2.1 t.2.2.2)) (Nat.cast_nonneg _) theorem exactLocallySampleableJB_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (t : ExactLocallySampleableTuple X Y A B D) : 0 ≤ exactLocallySampleableJB G n S D base t := by unfold exactLocallySampleableJB exact div_nonneg (mul_nonneg (G.weight_nonneg t.2.1 t.2.2.1) (exactBobLocalConditional_nonneg D base (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive) t.1 t.2.2.1 t.2.2.2)) (Nat.cast_nonneg _) theorem exactRemainingCoordinate_card_pos {n : ℕ} (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) : 0 < Fintype.card (SourceRemainingCoordinate D) := by simpa using remaining theorem exactLocallySampleableJA_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (base : ExactHistoryFlag X Y A B D) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableJA G n S D base t) = 1 := by have hcard : (Fintype.card (SourceRemainingCoordinate D) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (exactRemainingCoordinate_card_pos D remaining)) calc (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableJA G n S D base t) = (∑ i : SourceRemainingCoordinate D, ∑ x : X, ∑ y : Y, G.questionWeight x y * (∑ r : ExactHistoryFlag X Y A B D, exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r)) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) := by simp only [exactLocallySampleableJA, Fintype.sum_prod_type] simp_rw [← Finset.sum_div] congr 1 apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [Finset.mul_sum] _ = (∑ i : SourceRemainingCoordinate D, ∑ x : X, ∑ y : Y, G.questionWeight x y) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) := by simp_rw [exactAliceLocalConditional_sum, mul_one] _ = 1 := by simp_rw [G.weight_normalized] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] exact div_self hcard theorem exactLocallySampleableJB_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (base : ExactHistoryFlag X Y A B D) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableJB G n S D base t) = 1 := by have hcard : (Fintype.card (SourceRemainingCoordinate D) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (exactRemainingCoordinate_card_pos D remaining)) calc (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableJB G n S D base t) = (∑ i : SourceRemainingCoordinate D, ∑ x : X, ∑ y : Y, G.questionWeight x y * (∑ r : ExactHistoryFlag X Y A B D, exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r)) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) := by simp only [exactLocallySampleableJB, Fintype.sum_prod_type] simp_rw [← Finset.sum_div] congr 1 apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [Finset.mul_sum] _ = (∑ i : SourceRemainingCoordinate D, ∑ x : X, ∑ y : Y, G.questionWeight x y) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) := by simp_rw [exactBobLocalConditional_sum, mul_one] _ = 1 := by simp_rw [G.weight_normalized] simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] exact div_self hcard theorem exactLocallySampleableLaw_absolute_continuous_JA (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (t : ExactLocallySampleableTuple X Y A B D) : exactLocallySampleableJA G n S D base t = 0 → exactLocallySampleableLaw G n S D t = 0 := by rcases t with ⟨i, x, y, r⟩ intro zero have hcard : (Fintype.card (SourceRemainingCoordinate D) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (exactRemainingCoordinate_card_pos D remaining)) change G.questionWeight x y * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = 0 at zero have hproduct : G.questionWeight x y * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r = 0 := (div_eq_zero_iff.mp zero).resolve_right hcard rcases mul_eq_zero.mp hproduct with hquestion | hconditional · exact exactLocallySampleableLaw_eq_zero_of_question_zero G n S D i x y r hquestion · exact exactAliceLocalConditional_zero_apply D base (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive) i x y r hconditional theorem exactLocallySampleableLaw_absolute_continuous_JB (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (t : ExactLocallySampleableTuple X Y A B D) : exactLocallySampleableJB G n S D base t = 0 → exactLocallySampleableLaw G n S D t = 0 := by rcases t with ⟨i, x, y, r⟩ intro zero have hcard : (Fintype.card (SourceRemainingCoordinate D) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (exactRemainingCoordinate_card_pos D remaining)) change G.questionWeight x y * exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = 0 at zero have hproduct : G.questionWeight x y * exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r = 0 := (div_eq_zero_iff.mp zero).resolve_right hcard rcases mul_eq_zero.mp hproduct with hquestion | hconditional · exact exactLocallySampleableLaw_eq_zero_of_question_zero G n S D i x y r hquestion · exact exactBobLocalConditional_zero_apply D base (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive) i x y r hconditional theorem exactLocallySampleableJA_pinsker (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) ≤ Real.sqrt (finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) / 2) := by exact finite_pinsker_sqrt_of_absolute_continuity (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) (exactLocallySampleableLaw_nonneg G n S D positive) (exactLocallySampleableJA_nonneg G n S D positive base) (exactLocallySampleableLaw_absolute_continuous_JA G n S D remaining positive base) (exactLocallySampleableLaw_sum G n S D remaining positive) (exactLocallySampleableJA_sum G n S D remaining base) theorem exactLocallySampleableJB_pinsker (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) ≤ Real.sqrt (finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) / 2) := by exact finite_pinsker_sqrt_of_absolute_continuity (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) (exactLocallySampleableLaw_nonneg G n S D positive) (exactLocallySampleableJB_nonneg G n S D positive base) (exactLocallySampleableLaw_absolute_continuous_JB G n S D remaining positive base) (exactLocallySampleableLaw_sum G n S D remaining positive) (exactLocallySampleableJB_sum G n S D remaining base) abbrev ExactLocalSamplerIndex (X Y : Type*) [Fintype X] [Fintype Y] {n : ℕ} (D : Finset (Fin n)) := (SourceRemainingCoordinate D × X) ⊕ (SourceRemainingCoordinate D × Y) def exactLocalConditionalFamily {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (k : ExactLocalSamplerIndex X Y D) (r : ExactHistoryFlag X Y A B D) : ℝ := match k with | .inl (i, x) => exactAliceLocalConditional D base Q i x r | .inr (i, y) => exactBobLocalConditional D base Q i y r theorem exactLocalConditionalFamily_nonneg {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (nonnegative : ∀ t, 0 ≤ Q t) (k : ExactLocalSamplerIndex X Y D) (r : ExactHistoryFlag X Y A B D) : 0 ≤ exactLocalConditionalFamily D base Q k r := by rcases k with ⟨i, x⟩ | ⟨i, y⟩ · exact exactAliceLocalConditional_nonneg D base Q nonnegative i x r · exact exactBobLocalConditional_nonneg D base Q nonnegative i y r theorem exactLocalConditionalFamily_sum {n : ℕ} (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (Q : ExactLocallySampleableTuple X Y A B D → ℝ) (k : ExactLocalSamplerIndex X Y D) : (∑ r : ExactHistoryFlag X Y A B D, exactLocalConditionalFamily D base Q k r) = 1 := by rcases k with ⟨i, x⟩ | ⟨i, y⟩ · exact exactAliceLocalConditional_sum D base Q i x · exact exactBobLocalConditional_sum D base Q i y end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactConditionalQuestionWeight (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs : Fin n → X) (ys : Fin n → Y) : ℝ := exactFiberQuestionWeight G n D seed history x y xs ys / exactFiberQuestionMass G n D seed history x y theorem exactFiberQuestionMass_eq_jointQuestionMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) : exactFiberQuestionMass G n D seed history x y = exactJointQuestionMass G n D seed history x y := by classical unfold exactFiberQuestionMass exactFiberQuestionWeight exactJointQuestionMass rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ simp [exactPriorQuestionWeight, exactRevealCode_compatible_iff] def exactJointAliceQuestionFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) (y : Y) : Matrix S.Alice S.Alice ℂ := ∑ xs : Fin n → X, (exactFiberAliceMarginal G n D seed history x y xs / exactFiberQuestionMass G n D seed history x y) • conditionedAliceEffect G n S D answer xs def exactJointBobQuestionFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) : Matrix S.Bob S.Bob ℂ := ∑ ys : Fin n → Y, (exactFiberBobMarginal G n D seed history x y ys / exactFiberQuestionMass G n D seed history x y) • conditionedBobEffect G n S D answer ys def exactJointAliceCoordinateFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) (y : Y) (a : A) : Matrix S.Alice S.Alice ℂ := ∑ xs : Fin n → X, (exactFiberAliceMarginal G n D seed history x y xs / exactFiberQuestionMass G n D seed history x y) • conditionedAliceCoordinateEffect G n S D answer xs seed.coordinate.val a def exactJointBobCoordinateFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) (b : B) : Matrix S.Bob S.Bob ℂ := ∑ ys : Fin n → Y, (exactFiberBobMarginal G n D seed history x y ys / exactFiberQuestionMass G n D seed history x y) • conditionedBobCoordinateEffect G n S D answer ys seed.coordinate.val b theorem exactFiber_born_of_rank_one (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) (EA : (Fin n → X) → Matrix S.Alice S.Alice ℂ) (EB : (Fin n → Y) → Matrix S.Bob S.Bob ℂ) : bornTracePairing S.state.matrix (∑ xs : Fin n → X, (exactFiberAliceMarginal G n D seed history x y xs / exactFiberQuestionMass G n D seed history x y) • EA xs) (∑ ys : Fin n → Y, (exactFiberBobMarginal G n D seed history x y ys / exactFiberQuestionMass G n D seed history x y) • EB ys) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactConditionalQuestionWeight G n D seed history x y xs ys * bornTracePairing S.state.matrix (EA xs) (EB ys) := by classical simp only [map_sum, LinearMap.sum_apply, map_smul, LinearMap.smul_apply, smul_eq_mul, exactConditionalQuestionWeight] simp_rw [Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ have hrank := exactFiberQuestionWeight_mul_mass G n D seed history x y xs ys have hborn := congrArg (fun z : ℝ => z * bornTracePairing S.state.matrix (EA xs) (EB ys)) hrank field_simp [nonzero] nlinarith [hborn] theorem exactJointQuestionFilter_born (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (aliceAnswer : {j : Fin n // j ∈ D} → A) (bobAnswer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : bornTracePairing S.state.matrix (exactJointAliceQuestionFilter G n S D seed history aliceAnswer x y) (exactJointBobQuestionFilter G n S D seed history bobAnswer x y) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactConditionalQuestionWeight G n D seed history x y xs ys * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D aliceAnswer xs) (conditionedBobEffect G n S D bobAnswer ys) := by exact exactFiber_born_of_rank_one G n S D seed history x y nonzero (conditionedAliceEffect G n S D aliceAnswer) (conditionedBobEffect G n S D bobAnswer) theorem exactJointCoordinateFilter_born (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (aliceAnswer : {j : Fin n // j ∈ D} → A) (bobAnswer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) (a : A) (b : B) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : bornTracePairing S.state.matrix (exactJointAliceCoordinateFilter G n S D seed history aliceAnswer x y a) (exactJointBobCoordinateFilter G n S D seed history bobAnswer x y b) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactConditionalQuestionWeight G n D seed history x y xs ys * bornTracePairing S.state.matrix (conditionedAliceCoordinateEffect G n S D aliceAnswer xs seed.coordinate.val a) (conditionedBobCoordinateEffect G n S D bobAnswer ys seed.coordinate.val b) := by exact exactFiber_born_of_rank_one G n S D seed history x y nonzero (fun xs => conditionedAliceCoordinateEffect G n S D aliceAnswer xs seed.coordinate.val a) (fun ys => conditionedBobCoordinateEffect G n S D bobAnswer ys seed.coordinate.val b) def exactJointConditionalWinningMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (aliceAnswer : {j : Fin n // j ∈ D} → A) (bobAnswer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) : ℝ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then bornTracePairing S.state.matrix (exactJointAliceCoordinateFilter G n S D seed history aliceAnswer x y a) (exactJointBobCoordinateFilter G n S D seed history bobAnswer x y b) else 0 theorem exactJointConditionalWinningMass_born (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (aliceAnswer : {j : Fin n // j ∈ D} → A) (bobAnswer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : exactJointConditionalWinningMass G n S D seed history aliceAnswer bobAnswer x y = ∑ a : A, ∑ b : B, if G.predicate x y a b = true then ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactConditionalQuestionWeight G n D seed history x y xs ys * bornTracePairing S.state.matrix (conditionedAliceCoordinateEffect G n S D aliceAnswer xs seed.coordinate.val a) (conditionedBobCoordinateEffect G n S D bobAnswer ys seed.coordinate.val b) else 0 := by classical unfold exactJointConditionalWinningMass apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ split_ifs · exact exactJointCoordinateFilter_born G n S D seed history aliceAnswer bobAnswer x y a b nonzero · rfl end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactFiberQuestionWeight_sum_bobQuestion (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (xs : Fin n → X) (ys : Fin n → Y) : (∑ y : Y, exactFiberQuestionWeight G n D seed history x y xs ys) = if exactRevealCode D seed (xs, ys) = history ∧ xs seed.coordinate.val = x then exactPriorQuestionWeight G n (xs, ys) else 0 := by classical let y := ys seed.coordinate.val calc (∑ yy : Y, exactFiberQuestionWeight G n D seed history x yy xs ys) = exactFiberQuestionWeight G n D seed history x y xs ys := by apply Fintype.sum_eq_single y intro yy hyy unfold exactFiberQuestionWeight split_ifs with h · exact (hyy (show yy = y from h.2.2.2.2.symm)).elim · rfl _ = _ := by have hcompatible : (exactAliceQuestionCompatible D seed history x xs ∧ exactBobQuestionCompatible D seed history y ys) ↔ (exactRevealCode D seed (xs, ys) = history ∧ xs seed.coordinate.val = x) := by simpa [y] using (exactRevealCode_compatible_iff D seed history x y xs ys).symm simp [exactFiberQuestionWeight, exactPriorQuestionWeight, hcompatible] theorem exactFiberQuestionWeight_sum_aliceQuestion (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (y : Y) (xs : Fin n → X) (ys : Fin n → Y) : (∑ x : X, exactFiberQuestionWeight G n D seed history x y xs ys) = if exactRevealCode D seed (xs, ys) = history ∧ ys seed.coordinate.val = y then exactPriorQuestionWeight G n (xs, ys) else 0 := by classical let x := xs seed.coordinate.val calc (∑ xx : X, exactFiberQuestionWeight G n D seed history xx y xs ys) = exactFiberQuestionWeight G n D seed history x y xs ys := by apply Fintype.sum_eq_single x intro xx hxx unfold exactFiberQuestionWeight split_ifs with h · exact (hxx (show xx = x from h.1.2.2.2.symm)).elim · rfl _ = _ := by have hcompatible : (exactAliceQuestionCompatible D seed history x xs ∧ exactBobQuestionCompatible D seed history y ys) ↔ (exactRevealCode D seed (xs, ys) = history ∧ ys seed.coordinate.val = y) := by simpa [x] using (exactRevealCode_compatible_iff D seed history x y xs ys).symm simp [exactFiberQuestionWeight, exactPriorQuestionWeight, hcompatible] theorem exactAliceQuestionMass_eq_sum_fiberMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) : exactAliceQuestionMass G n D seed history x = ∑ y : Y, exactFiberQuestionMass G n D seed history x y := by classical unfold exactAliceQuestionMass rw [Fintype.sum_prod_type] calc (∑ xs : Fin n → X, ∑ ys : Fin n → Y, if exactRevealCode D seed (xs, ys) = history ∧ xs seed.coordinate.val = x then exactPriorQuestionWeight G n (xs, ys) else 0) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ y : Y, exactFiberQuestionWeight G n D seed history x y xs ys := by apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ exact (exactFiberQuestionWeight_sum_bobQuestion G n D seed history x xs ys).symm _ = ∑ xs : Fin n → X, ∑ y : Y, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xs ys := by apply Finset.sum_congr rfl intro xs _ rw [Finset.sum_comm] _ = ∑ y : Y, ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xs ys := by rw [Finset.sum_comm] _ = _ := by rfl theorem exactBobQuestionMass_eq_sum_fiberMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (y : Y) : exactBobQuestionMass G n D seed history y = ∑ x : X, exactFiberQuestionMass G n D seed history x y := by classical unfold exactBobQuestionMass rw [Fintype.sum_prod_type] calc (∑ xs : Fin n → X, ∑ ys : Fin n → Y, if exactRevealCode D seed (xs, ys) = history ∧ ys seed.coordinate.val = y then exactPriorQuestionWeight G n (xs, ys) else 0) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ x : X, exactFiberQuestionWeight G n D seed history x y xs ys := by apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ exact (exactFiberQuestionWeight_sum_aliceQuestion G n D seed history y xs ys).symm _ = ∑ xs : Fin n → X, ∑ x : X, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xs ys := by apply Finset.sum_congr rfl intro xs _ rw [Finset.sum_comm] _ = ∑ x : X, ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xs ys := by rw [Finset.sum_comm] _ = _ := by rfl theorem exactCompatible_aliceMixed_coordinate_eq_or {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y y' : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) (ha : exactAliceQuestionCompatible D seed history x xs) (ha' : exactAliceQuestionCompatible D seed history x xs') (hb : exactBobQuestionCompatible D seed history y ys) (hb' : exactBobQuestionCompatible D seed history y' ys') (j : Fin n) : xs j = xs' j ∨ ys j = ys' j := by by_cases hj : j ∈ D · left exact (ha.1 ⟨j, hj⟩).trans (ha'.1 ⟨j, hj⟩).symm · let jr : SourceRemainingCoordinate D := ⟨j, by simp [hj]⟩ by_cases hcoordinate : jr = seed.coordinate · left have hval : j = seed.coordinate.val := congrArg Subtype.val hcoordinate rw [hval] exact ha.2.2.2.trans ha'.2.2.2.symm · cases hbit : seed.partition jr with | false => left have hleft : jr ∈ exactLeft seed.coordinate seed.partition := by simp [exactLeft, hcoordinate, hbit] exact (ha.2.1 ⟨jr, hleft⟩).trans (ha'.2.1 ⟨jr, hleft⟩).symm | true => right have hright : jr ∈ exactRight seed.coordinate seed.partition := by simp [exactRight, hcoordinate, hbit] exact (hb.2.1 ⟨jr, hright⟩).trans (hb'.2.1 ⟨jr, hright⟩).symm theorem exactQuestionWeight_aliceMixed_rectangle (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y y' : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) (ha : exactAliceQuestionCompatible D seed history x xs) (ha' : exactAliceQuestionCompatible D seed history x xs') (hb : exactBobQuestionCompatible D seed history y ys) (hb' : exactBobQuestionCompatible D seed history y' ys') : (G.repeat n).questionWeight xs ys * (G.repeat n).questionWeight xs' ys' = (G.repeat n).questionWeight xs ys' * (G.repeat n).questionWeight xs' ys := by simp only [Game.repeat_questionWeight] rw [← Finset.prod_mul_distrib, ← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro j _ rcases exactCompatible_aliceMixed_coordinate_eq_or D seed history x y y' xs xs' ys ys' ha ha' hb hb' j with hAlice | hBob · simp [hAlice, mul_comm] · simp [hBob] theorem exactFiberQuestionWeight_aliceMixed_rectangle (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y y' : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) : exactFiberQuestionWeight G n D seed history x y xs ys * exactFiberQuestionWeight G n D seed history x y' xs' ys' = exactFiberQuestionWeight G n D seed history x y' xs ys' * exactFiberQuestionWeight G n D seed history x y xs' ys := by classical by_cases ha : exactAliceQuestionCompatible D seed history x xs <;> by_cases ha' : exactAliceQuestionCompatible D seed history x xs' <;> by_cases hb : exactBobQuestionCompatible D seed history y ys <;> by_cases hb' : exactBobQuestionCompatible D seed history y' ys' <;> simp [exactFiberQuestionWeight, ha, ha', hb, hb'] simpa only [Game.repeat_questionWeight] using (exactQuestionWeight_aliceMixed_rectangle G n D seed history x y y' xs xs' ys ys' ha ha' hb hb') theorem exactCompatible_bobMixed_coordinate_eq_or {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x x' : X) (y : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) (ha : exactAliceQuestionCompatible D seed history x xs) (ha' : exactAliceQuestionCompatible D seed history x' xs') (hb : exactBobQuestionCompatible D seed history y ys) (hb' : exactBobQuestionCompatible D seed history y ys') (j : Fin n) : xs j = xs' j ∨ ys j = ys' j := by by_cases hj : j ∈ D · left exact (ha.1 ⟨j, hj⟩).trans (ha'.1 ⟨j, hj⟩).symm · let jr : SourceRemainingCoordinate D := ⟨j, by simp [hj]⟩ by_cases hcoordinate : jr = seed.coordinate · right have hval : j = seed.coordinate.val := congrArg Subtype.val hcoordinate rw [hval] exact hb.2.2.2.trans hb'.2.2.2.symm · cases hbit : seed.partition jr with | false => left have hleft : jr ∈ exactLeft seed.coordinate seed.partition := by simp [exactLeft, hcoordinate, hbit] exact (ha.2.1 ⟨jr, hleft⟩).trans (ha'.2.1 ⟨jr, hleft⟩).symm | true => right have hright : jr ∈ exactRight seed.coordinate seed.partition := by simp [exactRight, hcoordinate, hbit] exact (hb.2.1 ⟨jr, hright⟩).trans (hb'.2.1 ⟨jr, hright⟩).symm theorem exactQuestionWeight_bobMixed_rectangle (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x x' : X) (y : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) (ha : exactAliceQuestionCompatible D seed history x xs) (ha' : exactAliceQuestionCompatible D seed history x' xs') (hb : exactBobQuestionCompatible D seed history y ys) (hb' : exactBobQuestionCompatible D seed history y ys') : (G.repeat n).questionWeight xs ys * (G.repeat n).questionWeight xs' ys' = (G.repeat n).questionWeight xs ys' * (G.repeat n).questionWeight xs' ys := by simp only [Game.repeat_questionWeight] rw [← Finset.prod_mul_distrib, ← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro j _ rcases exactCompatible_bobMixed_coordinate_eq_or D seed history x x' y xs xs' ys ys' ha ha' hb hb' j with hAlice | hBob · simp [hAlice, mul_comm] · simp [hBob] theorem exactFiberQuestionWeight_bobMixed_rectangle (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x x' : X) (y : Y) (xs xs' : Fin n → X) (ys ys' : Fin n → Y) : exactFiberQuestionWeight G n D seed history x y xs ys * exactFiberQuestionWeight G n D seed history x' y xs' ys' = exactFiberQuestionWeight G n D seed history x y xs ys' * exactFiberQuestionWeight G n D seed history x' y xs' ys := by classical by_cases ha : exactAliceQuestionCompatible D seed history x xs <;> by_cases ha' : exactAliceQuestionCompatible D seed history x' xs' <;> by_cases hb : exactBobQuestionCompatible D seed history y ys <;> by_cases hb' : exactBobQuestionCompatible D seed history y ys' <;> simp [exactFiberQuestionWeight, ha, ha', hb, hb'] simpa only [Game.repeat_questionWeight] using (exactQuestionWeight_bobMixed_rectangle G n D seed history x x' y xs xs' ys ys' ha ha' hb hb') theorem exactMixedRowMarginal_mul_total {ι κ : Type*} [Fintype ι] [Fintype κ] (left right : ι → κ → ℝ) (rectangle : ∀ i i' j j', left i j * right i' j' = right i j' * left i' j) (i : ι) : (∑ j : κ, left i j) * (∑ i' : ι, ∑ j' : κ, right i' j') = (∑ j' : κ, right i j') * (∑ i' : ι, ∑ j : κ, left i' j) := by classical calc (∑ j : κ, left i j) * (∑ i' : ι, ∑ j' : κ, right i' j') = ∑ j : κ, ∑ i' : ι, ∑ j' : κ, left i j * right i' j' := by rw [Finset.sum_mul] apply Finset.sum_congr rfl intro j _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i' _ rw [Finset.mul_sum] _ = ∑ j : κ, ∑ i' : ι, ∑ j' : κ, right i j' * left i' j := by apply Finset.sum_congr rfl intro j _ apply Finset.sum_congr rfl intro i' _ apply Finset.sum_congr rfl intro j' _ exact rectangle i i' j j' _ = ∑ j : κ, ∑ i' : ι, (∑ j' : κ, right i j') * left i' j := by apply Finset.sum_congr rfl intro j _ apply Finset.sum_congr rfl intro i' _ rw [Finset.sum_mul] _ = ∑ i' : ι, ∑ j : κ, (∑ j' : κ, right i j') * left i' j := by rw [Finset.sum_comm] _ = (∑ j' : κ, right i j') * (∑ i' : ι, ∑ j : κ, left i' j) := by simp only [Finset.mul_sum] theorem exactFiberAliceMarginal_mul_cross_mass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y y' : Y) (xs : Fin n → X) : exactFiberAliceMarginal G n D seed history x y xs * exactFiberQuestionMass G n D seed history x y' = exactFiberAliceMarginal G n D seed history x y' xs * exactFiberQuestionMass G n D seed history x y := by apply exactMixedRowMarginal_mul_total (exactFiberQuestionWeight G n D seed history x y) (exactFiberQuestionWeight G n D seed history x y') intro u v s t exact exactFiberQuestionWeight_aliceMixed_rectangle G n D seed history x y y' u v s t theorem exactFiberBobMarginal_mul_cross_mass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x x' : X) (y : Y) (ys : Fin n → Y) : exactFiberBobMarginal G n D seed history x y ys * exactFiberQuestionMass G n D seed history x' y = exactFiberBobMarginal G n D seed history x' y ys * exactFiberQuestionMass G n D seed history x y := by classical have hcross := exactMixedRowMarginal_mul_total (fun yy xx => exactFiberQuestionWeight G n D seed history x y xx yy) (fun yy xx => exactFiberQuestionWeight G n D seed history x' y xx yy) (by intro u v s t simpa [mul_comm] using (exactFiberQuestionWeight_bobMixed_rectangle G n D seed history x x' y s t u v)) ys change (∑ xs : Fin n → X, exactFiberQuestionWeight G n D seed history x y xs ys) * (∑ xx : Fin n → X, ∑ yy : Fin n → Y, exactFiberQuestionWeight G n D seed history x' y xx yy) = (∑ xs : Fin n → X, exactFiberQuestionWeight G n D seed history x' y xs ys) * (∑ xx : Fin n → X, ∑ yy : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xx yy) calc _ = (∑ xs : Fin n → X, exactFiberQuestionWeight G n D seed history x y xs ys) * (∑ yy : Fin n → Y, ∑ xx : Fin n → X, exactFiberQuestionWeight G n D seed history x' y xx yy) := by rw [Finset.sum_comm] _ = (∑ xs : Fin n → X, exactFiberQuestionWeight G n D seed history x' y xs ys) * (∑ yy : Fin n → Y, ∑ xx : Fin n → X, exactFiberQuestionWeight G n D seed history x y xx yy) := hcross _ = _ := by rw [Finset.sum_comm] theorem exactFiberQuestionWeight_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs : Fin n → X) (ys : Fin n → Y) : 0 ≤ exactFiberQuestionWeight G n D seed history x y xs ys := by unfold exactFiberQuestionWeight split · exact (G.repeat n).weight_nonneg xs ys · exact le_rfl theorem exactFiberQuestionMass_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) : 0 ≤ exactFiberQuestionMass G n D seed history x y := by unfold exactFiberQuestionMass exact Finset.sum_nonneg (fun xs _ => Finset.sum_nonneg (fun ys _ => exactFiberQuestionWeight_nonneg G n D seed history x y xs ys)) theorem exactAliceFiberNormalizedRow (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (xs : Fin n → X) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : exactFiberAliceMarginal G n D seed history x y xs / exactFiberQuestionMass G n D seed history x y = (∑ yy : Y, exactFiberAliceMarginal G n D seed history x yy xs) / exactAliceQuestionMass G n D seed history x := by classical rw [exactAliceQuestionMass_eq_sum_fiberMass] have hypos : 0 < exactFiberQuestionMass G n D seed history x y := lt_of_le_of_ne (exactFiberQuestionMass_nonneg G n D seed history x y) (Ne.symm nonzero) have hsum : (∑ yy : Y, exactFiberQuestionMass G n D seed history x yy) ≠ 0 := by apply ne_of_gt exact lt_of_lt_of_le hypos (Finset.single_le_sum (fun yy _ => exactFiberQuestionMass_nonneg G n D seed history x yy) (Finset.mem_univ y)) apply (div_eq_div_iff nonzero hsum).mpr calc exactFiberAliceMarginal G n D seed history x y xs * (∑ yy : Y, exactFiberQuestionMass G n D seed history x yy) = ∑ yy : Y, exactFiberAliceMarginal G n D seed history x y xs * exactFiberQuestionMass G n D seed history x yy := by rw [Finset.mul_sum] _ = ∑ yy : Y, exactFiberAliceMarginal G n D seed history x yy xs * exactFiberQuestionMass G n D seed history x y := by apply Finset.sum_congr rfl intro yy _ exact exactFiberAliceMarginal_mul_cross_mass G n D seed history x y yy xs _ = (∑ yy : Y, exactFiberAliceMarginal G n D seed history x yy xs) * exactFiberQuestionMass G n D seed history x y := by rw [Finset.sum_mul] theorem exactBobFiberNormalizedColumn (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (ys : Fin n → Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : exactFiberBobMarginal G n D seed history x y ys / exactFiberQuestionMass G n D seed history x y = (∑ xx : X, exactFiberBobMarginal G n D seed history xx y ys) / exactBobQuestionMass G n D seed history y := by classical rw [exactBobQuestionMass_eq_sum_fiberMass] have hxpos : 0 < exactFiberQuestionMass G n D seed history x y := lt_of_le_of_ne (exactFiberQuestionMass_nonneg G n D seed history x y) (Ne.symm nonzero) have hsum : (∑ xx : X, exactFiberQuestionMass G n D seed history xx y) ≠ 0 := by apply ne_of_gt exact lt_of_lt_of_le hxpos (Finset.single_le_sum (fun xx _ => exactFiberQuestionMass_nonneg G n D seed history xx y) (Finset.mem_univ x)) apply (div_eq_div_iff nonzero hsum).mpr calc exactFiberBobMarginal G n D seed history x y ys * (∑ xx : X, exactFiberQuestionMass G n D seed history xx y) = ∑ xx : X, exactFiberBobMarginal G n D seed history x y ys * exactFiberQuestionMass G n D seed history xx y := by rw [Finset.mul_sum] _ = ∑ xx : X, exactFiberBobMarginal G n D seed history xx y ys * exactFiberQuestionMass G n D seed history x y := by apply Finset.sum_congr rfl intro xx _ exact exactFiberBobMarginal_mul_cross_mass G n D seed history x xx y ys _ = (∑ xx : X, exactFiberBobMarginal G n D seed history xx y ys) * exactFiberQuestionMass G n D seed history x y := by rw [Finset.sum_mul] theorem exactAliceConditionalMatrix_eq_joint {d : Type*} [Fintype d] (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) (E : (Fin n → X) → Matrix d d ℂ) : (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then (exactPriorQuestionWeight G n q / exactAliceQuestionMass G n D seed history x) • E q.1 else 0) = ∑ xs : Fin n → X, (exactFiberAliceMarginal G n D seed history x y xs / exactFiberQuestionMass G n D seed history x y) • E xs := by classical rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro xs _ calc (∑ ys : Fin n → Y, if exactRevealCode D seed (xs, ys) = history ∧ xs seed.coordinate.val = x then (exactPriorQuestionWeight G n (xs, ys) / exactAliceQuestionMass G n D seed history x) • E xs else 0) = (∑ ys : Fin n → Y, ((if exactRevealCode D seed (xs, ys) = history ∧ xs seed.coordinate.val = x then exactPriorQuestionWeight G n (xs, ys) else 0) / exactAliceQuestionMass G n D seed history x) • E xs) := by apply Finset.sum_congr rfl intro ys _ split_ifs <;> simp _ = ((∑ ys : Fin n → Y, if exactRevealCode D seed (xs, ys) = history ∧ xs seed.coordinate.val = x then exactPriorQuestionWeight G n (xs, ys) else 0) / exactAliceQuestionMass G n D seed history x) • E xs := by rw [Finset.sum_div, Finset.sum_smul] _ = ((∑ yy : Y, exactFiberAliceMarginal G n D seed history x yy xs) / exactAliceQuestionMass G n D seed history x) • E xs := by congr 2 calc (∑ ys : Fin n → Y, if exactRevealCode D seed (xs, ys) = history ∧ xs seed.coordinate.val = x then exactPriorQuestionWeight G n (xs, ys) else 0) = ∑ ys : Fin n → Y, ∑ yy : Y, exactFiberQuestionWeight G n D seed history x yy xs ys := by apply Finset.sum_congr rfl intro ys _ exact (exactFiberQuestionWeight_sum_bobQuestion G n D seed history x xs ys).symm _ = ∑ yy : Y, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D seed history x yy xs ys := by rw [Finset.sum_comm] _ = _ := by rfl _ = _ := by rw [← exactAliceFiberNormalizedRow G n D seed history x y xs nonzero] theorem exactBobConditionalMatrix_eq_joint {d : Type*} [Fintype d] (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) (E : (Fin n → Y) → Matrix d d ℂ) : (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then (exactPriorQuestionWeight G n q / exactBobQuestionMass G n D seed history y) • E q.2 else 0) = ∑ ys : Fin n → Y, (exactFiberBobMarginal G n D seed history x y ys / exactFiberQuestionMass G n D seed history x y) • E ys := by classical rw [Fintype.sum_prod_type, Finset.sum_comm] apply Finset.sum_congr rfl intro ys _ calc (∑ xs : Fin n → X, if exactRevealCode D seed (xs, ys) = history ∧ ys seed.coordinate.val = y then (exactPriorQuestionWeight G n (xs, ys) / exactBobQuestionMass G n D seed history y) • E ys else 0) = (∑ xs : Fin n → X, ((if exactRevealCode D seed (xs, ys) = history ∧ ys seed.coordinate.val = y then exactPriorQuestionWeight G n (xs, ys) else 0) / exactBobQuestionMass G n D seed history y) • E ys) := by apply Finset.sum_congr rfl intro xs _ split_ifs <;> simp _ = ((∑ xs : Fin n → X, if exactRevealCode D seed (xs, ys) = history ∧ ys seed.coordinate.val = y then exactPriorQuestionWeight G n (xs, ys) else 0) / exactBobQuestionMass G n D seed history y) • E ys := by rw [Finset.sum_div, Finset.sum_smul] _ = ((∑ xx : X, exactFiberBobMarginal G n D seed history xx y ys) / exactBobQuestionMass G n D seed history y) • E ys := by congr 2 calc (∑ xs : Fin n → X, if exactRevealCode D seed (xs, ys) = history ∧ ys seed.coordinate.val = y then exactPriorQuestionWeight G n (xs, ys) else 0) = ∑ xs : Fin n → X, ∑ xx : X, exactFiberQuestionWeight G n D seed history xx y xs ys := by apply Finset.sum_congr rfl intro xs _ exact (exactFiberQuestionWeight_sum_aliceQuestion G n D seed history y xs ys).symm _ = ∑ xx : X, ∑ xs : Fin n → X, exactFiberQuestionWeight G n D seed history xx y xs ys := by rw [Finset.sum_comm] _ = _ := by rfl _ = _ := by rw [← exactBobFiberNormalizedColumn G n D seed history x y ys nonzero] theorem exactAliceQuestionFilter_eq_joint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) (y : Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : exactAliceQuestionFilter G n S D seed history answer x = exactJointAliceQuestionFilter G n S D seed history answer x y := by exact exactAliceConditionalMatrix_eq_joint G n D seed history x y nonzero (conditionedAliceEffect G n S D answer) theorem exactBobQuestionFilter_eq_joint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : exactBobQuestionFilter G n S D seed history answer y = exactJointBobQuestionFilter G n S D seed history answer x y := by exact exactBobConditionalMatrix_eq_joint G n D seed history x y nonzero (conditionedBobEffect G n S D answer) theorem exactAliceCoordinateFilter_eq_joint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → A) (x : X) (y : Y) (a : A) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : exactAliceCoordinateFilter G n S D seed history answer x a = exactJointAliceCoordinateFilter G n S D seed history answer x y a := by exact exactAliceConditionalMatrix_eq_joint G n D seed history x y nonzero (fun xs => conditionedAliceCoordinateEffect G n S D answer xs seed.coordinate.val a) theorem exactBobCoordinateFilter_eq_joint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) (b : B) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : exactBobCoordinateFilter G n S D seed history answer y b = exactJointBobCoordinateFilter G n S D seed history answer x y b := by exact exactBobConditionalMatrix_eq_joint G n D seed history x y nonzero (fun ys => conditionedBobCoordinateEffect G n S D answer ys seed.coordinate.val b) theorem exactSourceEquationTen (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (aliceAnswer : {j : Fin n // j ∈ D} → A) (bobAnswer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) (nonzero : exactFiberQuestionMass G n D seed history x y ≠ 0) : bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D seed history aliceAnswer x) (exactBobQuestionFilter G n S D seed history bobAnswer y) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactConditionalQuestionWeight G n D seed history x y xs ys * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D aliceAnswer xs) (conditionedBobEffect G n S D bobAnswer ys) := by rw [exactAliceQuestionFilter_eq_joint G n S D seed history aliceAnswer x y nonzero, exactBobQuestionFilter_eq_joint G n S D seed history bobAnswer x y nonzero] exact exactJointQuestionFilter_born G n S D seed history aliceAnswer bobAnswer x y nonzero end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactFixedBobQuestionMass (G : Game X Y A B) (n : ℕ) (fixed : Finset (Fin n)) (xs : Fin n → X) (known : Fin n → Y) : ℝ := ∑ ys : Fin n → Y, if ∀ j : Fin n, j ∈ fixed → ys j = known j then (G.repeat n).questionWeight xs ys else 0 def exactFixedAliceQuestionMass (G : Game X Y A B) (n : ℕ) (fixed : Finset (Fin n)) (known : Fin n → X) (ys : Fin n → Y) : ℝ := ∑ xs : Fin n → X, if ∀ j : Fin n, j ∈ fixed → xs j = known j then (G.repeat n).questionWeight xs ys else 0 theorem exactFixedBobQuestionMass_eq_product (G : Game X Y A B) (n : ℕ) (fixed : Finset (Fin n)) (xs : Fin n → X) (known : Fin n → Y) : exactFixedBobQuestionMass G n fixed xs known = ∏ j : Fin n, if j ∈ fixed then G.questionWeight (xs j) (known j) else G.marginalX (xs j) := by classical unfold exactFixedBobQuestionMass simp only [Game.repeat_questionWeight] calc (∑ ys : Fin n → Y, if ∀ j : Fin n, j ∈ fixed → ys j = known j then ∏ j : Fin n, G.questionWeight (xs j) (ys j) else 0) = ∑ ys : Fin n → Y, ∏ j : Fin n, if j ∈ fixed then if ys j = known j then G.questionWeight (xs j) (ys j) else 0 else G.questionWeight (xs j) (ys j) := by apply Finset.sum_congr rfl intro ys _ calc (if ∀ j : Fin n, j ∈ fixed → ys j = known j then ∏ j : Fin n, G.questionWeight (xs j) (ys j) else 0) = ∏ j : Fin n, if j ∈ fixed → ys j = known j then G.questionWeight (xs j) (ys j) else 0 := by simp only [Fintype.prod_ite_zero] split <;> simp_all _ = _ := by apply Finset.prod_congr rfl intro j _ by_cases hj : j ∈ fixed <;> by_cases he : ys j = known j <;> simp [hj, he] _ = ∏ j : Fin n, ∑ y : Y, if j ∈ fixed then if y = known j then G.questionWeight (xs j) y else 0 else G.questionWeight (xs j) y := (Fintype.prod_sum (fun (j : Fin n) (y : Y) => if j ∈ fixed then if y = known j then G.questionWeight (xs j) y else 0 else G.questionWeight (xs j) y)).symm _ = _ := by apply Finset.prod_congr rfl intro j _ by_cases hj : j ∈ fixed · simp [hj] · simp [hj, Game.marginalX] theorem exactFixedAliceQuestionMass_eq_product (G : Game X Y A B) (n : ℕ) (fixed : Finset (Fin n)) (known : Fin n → X) (ys : Fin n → Y) : exactFixedAliceQuestionMass G n fixed known ys = ∏ j : Fin n, if j ∈ fixed then G.questionWeight (known j) (ys j) else G.marginalY (ys j) := by classical unfold exactFixedAliceQuestionMass simp only [Game.repeat_questionWeight] calc (∑ xs : Fin n → X, if ∀ j : Fin n, j ∈ fixed → xs j = known j then ∏ j : Fin n, G.questionWeight (xs j) (ys j) else 0) = ∑ xs : Fin n → X, ∏ j : Fin n, if j ∈ fixed then if xs j = known j then G.questionWeight (xs j) (ys j) else 0 else G.questionWeight (xs j) (ys j) := by apply Finset.sum_congr rfl intro xs _ calc (if ∀ j : Fin n, j ∈ fixed → xs j = known j then ∏ j : Fin n, G.questionWeight (xs j) (ys j) else 0) = ∏ j : Fin n, if j ∈ fixed → xs j = known j then G.questionWeight (xs j) (ys j) else 0 := by simp only [Fintype.prod_ite_zero] split <;> simp_all _ = _ := by apply Finset.prod_congr rfl intro j _ by_cases hj : j ∈ fixed <;> by_cases he : xs j = known j <;> simp [hj, he] _ = ∏ j : Fin n, ∑ x : X, if j ∈ fixed then if x = known j then G.questionWeight x (ys j) else 0 else G.questionWeight x (ys j) := (Fintype.prod_sum (fun (j : Fin n) (x : X) => if j ∈ fixed then if x = known j then G.questionWeight x (ys j) else 0 else G.questionWeight x (ys j))).symm _ = _ := by apply Finset.prod_congr rfl intro j _ by_cases hj : j ∈ fixed · simp [hj] · simp [hj, Game.marginalY] theorem exactFixedBobQuestionMass_insert (G : Game X Y A B) (n : ℕ) (fixed : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixed) (xs : Fin n → X) (known : Fin n → Y) (y : Y) : exactFixedBobQuestionMass G n (insert j fixed) xs (Function.update known j y) = G.conditionalYGivenX (xs j) y * exactFixedBobQuestionMass G n fixed xs known := by classical rw [exactFixedBobQuestionMass_eq_product, exactFixedBobQuestionMass_eq_product] have tails : (∏ k ∈ (Finset.univ : Finset (Fin n)).erase j, if k ∈ insert j fixed then G.questionWeight (xs k) (Function.update known j y k) else G.marginalX (xs k)) = ∏ k ∈ (Finset.univ : Finset (Fin n)).erase j, if k ∈ fixed then G.questionWeight (xs k) (known k) else G.marginalX (xs k) := by apply Finset.prod_congr rfl intro k hk have hkj : k ≠ j := (Finset.mem_erase.mp hk).1 simp [hkj] rw [← Finset.mul_prod_erase Finset.univ (fun k : Fin n => if k ∈ insert j fixed then G.questionWeight (xs k) (Function.update known j y k) else G.marginalX (xs k)) (Finset.mem_univ j), ← Finset.mul_prod_erase Finset.univ (fun k : Fin n => if k ∈ fixed then G.questionWeight (xs k) (known k) else G.marginalX (xs k)) (Finset.mem_univ j), tails] simp only [Finset.mem_insert_self, ↓reduceIte, Function.update_self, fresh] rw [← G.marginalX_mul_conditionalYGivenX (xs j) y] ring theorem exactFixedAliceQuestionMass_insert (G : Game X Y A B) (n : ℕ) (fixed : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixed) (known : Fin n → X) (ys : Fin n → Y) (x : X) : exactFixedAliceQuestionMass G n (insert j fixed) (Function.update known j x) ys = G.conditionalXGivenY (ys j) x * exactFixedAliceQuestionMass G n fixed known ys := by classical rw [exactFixedAliceQuestionMass_eq_product, exactFixedAliceQuestionMass_eq_product] have tails : (∏ k ∈ (Finset.univ : Finset (Fin n)).erase j, if k ∈ insert j fixed then G.questionWeight (Function.update known j x k) (ys k) else G.marginalY (ys k)) = ∏ k ∈ (Finset.univ : Finset (Fin n)).erase j, if k ∈ fixed then G.questionWeight (known k) (ys k) else G.marginalY (ys k) := by apply Finset.prod_congr rfl intro k hk have hkj : k ≠ j := (Finset.mem_erase.mp hk).1 simp [hkj] rw [← Finset.mul_prod_erase Finset.univ (fun k : Fin n => if k ∈ insert j fixed then G.questionWeight (Function.update known j x k) (ys k) else G.marginalY (ys k)) (Finset.mem_univ j), ← Finset.mul_prod_erase Finset.univ (fun k : Fin n => if k ∈ fixed then G.questionWeight (known k) (ys k) else G.marginalY (ys k)) (Finset.mem_univ j), tails] simp only [Finset.mem_insert_self, ↓reduceIte, Function.update_self, fresh] rw [← G.marginalY_mul_conditionalXGivenY x (ys j)] ring end noncomputable section open scoped BigOperators attribute [local instance] Classical.propDecidable def exactReverseLeftSide {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Finset M := insert seed.coordinate (exactLeft seed.coordinate seed.partition) def exactReverseRightSide {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Finset M := insert seed.coordinate (exactRight seed.coordinate seed.partition) @[simp] theorem exactReverseLeftSide_coordinate_mem {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : seed.coordinate ∈ exactReverseLeftSide seed := by simp [exactReverseLeftSide] @[simp] theorem exactReverseRightSide_coordinate_mem {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : seed.coordinate ∈ exactReverseRightSide seed := by simp [exactReverseRightSide] theorem exactReverseLeftSide_card {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : (exactReverseLeftSide seed).card = (exactLeft seed.coordinate seed.partition).card + 1 := by simp [exactReverseLeftSide, exactLeft_coordinate_not_mem, Nat.add_comm] theorem exactReverseRightSide_card {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : (exactReverseRightSide seed).card = (exactRight seed.coordinate seed.partition).card + 1 := by simp [exactReverseRightSide, exactRight_coordinate_not_mem, Nat.add_comm] theorem exactReverseLeftSide_markedWeight {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : reverseMarkedPartitionWeight (exactReverseLeftSide seed) seed.coordinate = forwardMarkedPartitionWeight M := reverseMarkedPartitionWeight_eq_forward (exactReverseLeftSide_coordinate_mem seed) theorem exactReverseRightSide_markedWeight {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : reverseMarkedPartitionWeight (exactReverseRightSide seed) seed.coordinate = forwardMarkedPartitionWeight M := reverseMarkedPartitionWeight_eq_forward (exactReverseRightSide_coordinate_mem seed) theorem exactRemainingReverse_relativeEntropy_budget {n : ℕ} (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (increment : (s : Finset (SourceRemainingCoordinate D)) → Fin s.card → ℝ) {cost : ℝ} (nonnegative_cost : 0 ≤ cost) (budget : ∀ s : Finset (SourceRemainingCoordinate D), (∑ k : Fin s.card, increment s k) ≤ cost) : (∑ s : Finset (SourceRemainingCoordinate D), reversePartitionWeight s * ((∑ k : Fin s.card, increment s k) / (s.card : ℝ))) ≤ 2 * cost / ((Finset.univ \ D).card : ℝ) := by have hcard : 0 < Fintype.card (SourceRemainingCoordinate D) := by simpa using remaining simpa using (reversePartition_relativeEntropy_budget hcard increment nonnegative_cost budget) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def exactReverseLeftSeedWeight {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : ℝ := (1 / (2 : ℝ)) * reverseMarkedPartitionWeight (exactReverseLeftSide seed) seed.coordinate * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactReverseLeftSide seed}) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactRight seed.coordinate seed.partition}) : ℝ)) * (1 / ((exactRight seed.coordinate seed.partition).card + 1 : ℝ)) def exactReverseRightSeedWeight {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : ℝ := (1 / (2 : ℝ)) * reverseMarkedPartitionWeight (exactReverseRightSide seed) seed.coordinate * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactReverseRightSide seed}) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft seed.coordinate seed.partition}) : ℝ)) * (1 / ((exactLeft seed.coordinate seed.partition).card + 1 : ℝ)) theorem exactReverseLeftPermutation_card {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Fintype.card (Equiv.Perm {j : M // j ∈ exactReverseLeftSide seed}) = Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft seed.coordinate seed.partition}) * ((exactLeft seed.coordinate seed.partition).card + 1) := by rw [Fintype.card_perm, Fintype.card_perm] simp [exactReverseLeftSide_card, Nat.factorial_succ, Nat.mul_comm] theorem exactReverseRightPermutation_card {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Fintype.card (Equiv.Perm {j : M // j ∈ exactReverseRightSide seed}) = Fintype.card (Equiv.Perm {j : M // j ∈ exactRight seed.coordinate seed.partition}) * ((exactRight seed.coordinate seed.partition).card + 1) := by rw [Fintype.card_perm, Fintype.card_perm] simp [exactReverseRightSide_card, Nat.factorial_succ, Nat.mul_comm] theorem exactReverseLeftSeedWeight_eq_forward {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseLeftSeedWeight seed = exactSeedWeight seed := by rw [exactReverseLeftSeedWeight, exactReverseLeftSide_markedWeight, exactReverseLeftPermutation_card] simp only [exactSeedWeight, forwardMarkedPartitionWeight, fairPartitionWeight, Fintype.card_fun, Fintype.card_bool, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_pow] field_simp ring theorem exactReverseRightSeedWeight_eq_forward {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseRightSeedWeight seed = exactSeedWeight seed := by rw [exactReverseRightSeedWeight, exactReverseRightSide_markedWeight, exactReverseRightPermutation_card] simp only [exactSeedWeight, forwardMarkedPartitionWeight, fairPartitionWeight, Fintype.card_fun, Fintype.card_bool, Nat.cast_mul, Nat.cast_add, Nat.cast_one, Nat.cast_pow] field_simp ring variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactHistoryAccepted (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : Prop := ∀ j : {j : Fin n // j ∈ D}, G.predicate (r.history.aliceConditioned j) (r.history.bobConditioned j) (r.aliceAnswer j) (r.bobAnswer j) = true theorem exactHistoryCode_accepted_iff (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (q : ExactJointOutcome X Y A B D) : exactHistoryAccepted G n D (exactHistoryCode D q) ↔ q.2 ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D := by classical simp only [FiniteEventLaw.winEvent, Finset.mem_filter, Finset.mem_univ, true_and, repeatedCoordinateWin, exactHistoryAccepted, exactHistoryCode, exactRevealCode] constructor · intro h j hj exact h ⟨j, hj⟩ · intro h j exact h j.val j.property theorem exactLocallySampleableLaw_zero_of_not_accepted (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (x : X) (y : Y) (r : ExactHistoryFlag X Y A B D) (not_accepted : ¬ exactHistoryAccepted G n D r) : exactLocallySampleableLaw G n S D (i, x, y, r) = 0 := by classical unfold exactLocallySampleableLaw exactSourcePushforward groupedMass apply Finset.sum_eq_zero intro q hq have hcode : exactLocallySampleableCode D q = (i, x, y, r) := by exact ((@Finset.mem_filter (ExactJointOutcome X Y A B D) (fun a => exactLocallySampleableCode D a = (i, x, y, r)) (fun _ => Classical.propDecidable _) Finset.univ q).mp hq).2 have hhistory : exactHistoryCode D q = r := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.2) hcode have hnot : q.2 ∉ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D := by intro hw apply not_accepted rw [← hhistory] exact (exactHistoryCode_accepted_iff G n D q).mpr hw simp [exactPostselectedJointLaw, repeatedConditionedOutcomeLaw, conditionedEventDistribution, hnot] end noncomputable section open scoped BigOperators Kronecker ComplexOrder MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactGlobalHistoryLocalIndex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) := PUnit.{1} ⊕ (Σ r : ExactHistoryFlag X Y A B D, ExactPaddedLocalIndex G n S D r) def exactGlobalHistoryVector (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (z : EuclideanSpace ℂ (ExactPaddedLocalIndex G n S D r × ExactPaddedLocalIndex G n S D r)) : EuclideanSpace ℂ (ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) := taggedTensorVector r z theorem exactGlobalHistoryVector_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (z : EuclideanSpace ℂ (ExactPaddedLocalIndex G n S D r × ExactPaddedLocalIndex G n S D r)) : ‖exactGlobalHistoryVector G n S D r z‖ = ‖z‖ := taggedTensorVector_norm r z theorem exactGlobalHistoryVector_sub (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (u v : EuclideanSpace ℂ (ExactPaddedLocalIndex G n S D r × ExactPaddedLocalIndex G n S D r)) : exactGlobalHistoryVector G n S D r (u - v) = exactGlobalHistoryVector G n S D r u - exactGlobalHistoryVector G n S D r v := taggedTensorVector_sub r u v theorem exactGlobalHistoryLocalIndex_card_pos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : 0 < Fintype.card (ExactGlobalHistoryLocalIndex G n S D) := by exact Fintype.card_pos_iff.mpr ⟨Sum.inl PUnit.unit⟩ def exactGlobalHistoryFinReindex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : EuclideanSpace ℂ (ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) ≃ₗᵢ[ℂ] EuclideanSpace ℂ (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))) := by classical exact LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D))) def exactGlobalHistoryFinGamma (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) : BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) := ⟨exactGlobalHistoryFinReindex G n S D (exactGlobalHistoryVector G n S D r (exactGamma G n S D r x)), by rw [LinearIsometryEquiv.norm_map, exactGlobalHistoryVector_norm] exact normalizeOrDefault_norm _ _ (exactPaddedDefault_norm G n S D r)⟩ def exactGlobalHistoryFinPhi (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (y : Y) : BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) := ⟨exactGlobalHistoryFinReindex G n S D (exactGlobalHistoryVector G n S D r (exactPhi G n S D r y)), by rw [LinearIsometryEquiv.norm_map, exactGlobalHistoryVector_norm] exact normalizeOrDefault_norm _ _ (exactPaddedDefault_norm G n S D r)⟩ def exactGlobalHistoryFinPsi (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) := ⟨exactGlobalHistoryFinReindex G n S D (exactGlobalHistoryVector G n S D r (exactPsi G n S D r x y)), by rw [LinearIsometryEquiv.norm_map, exactGlobalHistoryVector_norm] exact normalizeOrDefault_norm _ _ (exactPaddedDefault_norm G n S D r)⟩ theorem exactGlobalHistoryFinGamma_sub_Psi_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ‖(exactGlobalHistoryFinGamma G n S D r x).val - (exactGlobalHistoryFinPsi G n S D r x y).val‖ = ‖exactGamma G n S D r x - exactPsi G n S D r x y‖ := by change ‖exactGlobalHistoryFinReindex G n S D (exactGlobalHistoryVector G n S D r (exactGamma G n S D r x)) - exactGlobalHistoryFinReindex G n S D (exactGlobalHistoryVector G n S D r (exactPsi G n S D r x y))‖ = _ rw [← map_sub, ← exactGlobalHistoryVector_sub, LinearIsometryEquiv.norm_map, exactGlobalHistoryVector_norm] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactSourceGlobalState (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) := EuclideanSpace ℂ (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))) def exactSourceTuplePsi (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) : ExactSourceGlobalState G n S D := (exactGlobalHistoryFinPsi G n S D t.2.2.2 t.2.1 t.2.2.1).val def exactSourceTupleGamma (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) : ExactSourceGlobalState G n S D := (exactGlobalHistoryFinGamma G n S D t.2.2.2 t.2.1).val def exactSourceTuplePhi (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) : ExactSourceGlobalState G n S D := (exactGlobalHistoryFinPhi G n S D t.2.2.2 t.2.2.1).val theorem exactSourceTuplePsi_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) : ‖exactSourceTuplePsi G n S D t‖ = 1 := (exactGlobalHistoryFinPsi G n S D t.2.2.2 t.2.1 t.2.2.1).property theorem exactSourceTupleGamma_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) : ‖exactSourceTupleGamma G n S D t‖ = 1 := (exactGlobalHistoryFinGamma G n S D t.2.2.2 t.2.1).property def ExactSourceStateDistanceBound (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (η : ℝ) : Prop := (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * ‖exactSourceTupleGamma G n S D t - exactSourceTuplePsi G n S D t‖ ^ 2) ≤ 8 * η ∧ (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * ‖exactSourceTuplePsi G n S D t - exactSourceTuplePhi G n S D t‖ ^ 2) ≤ 8 * η theorem exactPsiPhi_BornWeighted_normalized_distance (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 * ‖exactPsi G n S D r x y - exactPhi G n S D r y‖ ^ 2 ≤ 4 * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedPhi G n S D r y‖ ^ 2 := by let fallback := exactPaddedDefault G n S D r let u := exactUnnormalizedPsi G n S D r x y let v := exactUnnormalizedPhi G n S D r y have h := bornWeighted_normalized_distance fallback (exactPaddedVector G n S D r u) (exactPaddedVector G n S D r v) (exactPaddedDefault_norm G n S D r) rw [exactPaddedVector_norm, ← exactPaddedVector_sub, exactPaddedVector_norm] at h exact h theorem exactGammaPsi_BornWeighted_normalized_distance (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 * ‖exactGamma G n S D r x - exactPsi G n S D r x y‖ ^ 2 ≤ 4 * ‖exactUnnormalizedGamma G n S D r x - exactUnnormalizedPsi G n S D r x y‖ ^ 2 := by let fallback := exactPaddedDefault G n S D r let u := exactUnnormalizedPsi G n S D r x y let v := exactUnnormalizedGamma G n S D r x have h := bornWeighted_normalized_distance fallback (exactPaddedVector G n S D r u) (exactPaddedVector G n S D r v) (exactPaddedDefault_norm G n S D r) rw [exactPaddedVector_norm, ← exactPaddedVector_sub, exactPaddedVector_norm] at h have hforward : ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 * ‖exactPsi G n S D r x y - exactGamma G n S D r x‖ ^ 2 ≤ 4 * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedGamma G n S D r x‖ ^ 2 := by exact h calc ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 * ‖exactGamma G n S D r x - exactPsi G n S D r x y‖ ^ 2 = ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 * ‖exactPsi G n S D r x y - exactGamma G n S D r x‖ ^ 2 := by rw [norm_sub_rev] _ ≤ 4 * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedGamma G n S D r x‖ ^ 2 := hforward _ = 4 * ‖exactUnnormalizedGamma G n S D r x - exactUnnormalizedPsi G n S D r x y‖ ^ 2 := by rw [norm_sub_rev] theorem exactSourceEquationTwentyOne_of_fifteen (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (η : ℝ) (distance : ExactSourceStateDistanceBound G n S D η) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * ‖exactSourceTupleGamma G n S D t - exactSourceTuplePhi G n S D t‖ ^ 2) ≤ 32 * η := by exact source_equation_twenty_one (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive) (exactSourceTupleGamma G n S D) (exactSourceTuplePsi G n S D) (exactSourceTuplePhi G n S D) η distance.1 distance.2 end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactFairAliceQuestionEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (y : Y) : ℝ := bornTracePairing S.state.matrix ((∑ x : X, G.conditionalXGivenY y x • cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x)) - cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) def exactFairBobQuestionEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) : ℝ := bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) ((∑ y : Y, G.conditionalYGivenX x y • cfc (fun z : ℝ => z * Real.log z) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) - cfc (fun z : ℝ => z * Real.log z) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x)) theorem exactFairAlice_conditional_variation_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (y : Y) (hy : 0 < G.marginalY y) : (∑ x : X, G.conditionalXGivenY y x * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedPhi G n S D r y‖ ^ 2) ≤ exactFairAliceQuestionEntropyIncrement G n S D r y := by let F := exactAlicePurificationFamily G n S D r.seed r.history r.aliceAnswer let hF := exactAlicePurificationFamily_posSemidef G n S D r.seed r.history r.aliceAnswer have hmean : (∑ x : X, G.conditionalXGivenY y x • F (.inl x)) = F (.inr y) := by exact rfl have h := commonFinitePurification_weighted_left_variation_le S (G.conditionalXGivenY y) F 0 hF Matrix.PosSemidef.zero (fun x : X => Sum.inl x) (Sum.inr y) (fun x => G.conditionalXGivenY_nonneg y x) (G.conditionalXGivenY_sum y hy) hmean (exactBobPurificationMatrix G n S D r.seed r.history r.bobAnswer (.inl y)) rw [exactBobPurificationMatrix_gram] at h exact h theorem exactFairBob_conditional_variation_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (hx : 0 < G.marginalX x) : (∑ y : Y, G.conditionalYGivenX x y * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedGamma G n S D r x‖ ^ 2) ≤ exactFairBobQuestionEntropyIncrement G n S D r x := by let F := exactBobPurificationFamily G n S D r.seed r.history r.bobAnswer let hF := exactBobPurificationFamily_posSemidef G n S D r.seed r.history r.bobAnswer have hmean : (∑ y : Y, G.conditionalYGivenX x y • F (.inl y)) = F (.inr x) := by exact rfl have h := commonFinitePurification_weighted_right_variation_le S (G.conditionalYGivenX x) F 0 hF Matrix.PosSemidef.zero (fun y : Y => Sum.inl y) (Sum.inr x) (fun y => G.conditionalYGivenX_nonneg x y) (G.conditionalYGivenX_sum x hx) hmean (exactAlicePurificationMatrix G n S D r.seed r.history r.aliceAnswer (.inl x)) rw [exactAlicePurificationMatrix_gram] at h exact h def exactFairAliceHistoryVariation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := ∑ y : Y, ∑ x : X, G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedPhi G n S D r y‖ ^ 2 def exactFairBobHistoryVariation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := ∑ x : X, ∑ y : Y, G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedGamma G n S D r x‖ ^ 2 def exactFairAliceHistoryEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := ∑ y : Y, G.marginalY y * exactFairAliceQuestionEntropyIncrement G n S D r y def exactFairBobHistoryEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := ∑ x : X, G.marginalX x * exactFairBobQuestionEntropyIncrement G n S D r x theorem exactFairAliceHistoryVariation_le_entropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairAliceHistoryVariation G n S D r ≤ exactFairAliceHistoryEntropyIncrement G n S D r := by unfold exactFairAliceHistoryVariation exactFairAliceHistoryEntropyIncrement apply Finset.sum_le_sum intro y _ by_cases hy : G.marginalY y = 0 · have hzero (x : X) : G.questionWeight x y = 0 := by have hle := G.questionWeight_le_marginalY x y have hnonneg := G.weight_nonneg x y rw [hy] at hle linarith simp [hy, hzero] · have hypos : 0 < G.marginalY y := lt_of_le_of_ne (G.marginalY_nonneg y) (Ne.symm hy) have hlocal := exactFairAlice_conditional_variation_le G n S D r y hypos calc (∑ x : X, G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedPhi G n S D r y‖ ^ 2) = G.marginalY y * (∑ x : X, G.conditionalXGivenY y x * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedPhi G n S D r y‖ ^ 2) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro x _ rw [← G.marginalY_mul_conditionalXGivenY x y] ring _ ≤ _ := mul_le_mul_of_nonneg_left hlocal (G.marginalY_nonneg y) theorem exactFairBobHistoryVariation_le_entropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairBobHistoryVariation G n S D r ≤ exactFairBobHistoryEntropyIncrement G n S D r := by unfold exactFairBobHistoryVariation exactFairBobHistoryEntropyIncrement apply Finset.sum_le_sum intro x _ by_cases hx : G.marginalX x = 0 · have hzero (y : Y) : G.questionWeight x y = 0 := by have hle := G.questionWeight_le_marginalX x y have hnonneg := G.weight_nonneg x y rw [hx] at hle linarith simp [hx, hzero] · have hxpos : 0 < G.marginalX x := lt_of_le_of_ne (G.marginalX_nonneg x) (Ne.symm hx) have hlocal := exactFairBob_conditional_variation_le G n S D r x hxpos calc (∑ y : Y, G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedGamma G n S D r x‖ ^ 2) = G.marginalX x * (∑ y : Y, G.conditionalYGivenX x y * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedGamma G n S D r x‖ ^ 2) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro y _ rw [← G.marginalX_mul_conditionalYGivenX x y] ring _ ≤ _ := mul_le_mul_of_nonneg_left hlocal (G.marginalX_nonneg x) def exactFairHistoryPriorWeight (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := exactSeedWeight r.seed * exactRevealMass G n D r.seed r.history theorem exactFairHistoryPriorWeight_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : 0 ≤ exactFairHistoryPriorWeight G n D r := by exact mul_nonneg (exactSeedWeight_nonneg r.seed) (exactRevealMass_nonneg G n D r.seed r.history) theorem exactAcceptedFairAliceVariation_le_entropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairAliceHistoryVariation G n S D r else 0) ≤ (∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairAliceHistoryEntropyIncrement G n S D r else 0) := by apply Finset.sum_le_sum intro r _ split · exact mul_le_mul_of_nonneg_left (exactFairAliceHistoryVariation_le_entropy G n S D r) (exactFairHistoryPriorWeight_nonneg G n D r) · exact le_rfl theorem exactAcceptedFairBobVariation_le_entropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairBobHistoryVariation G n S D r else 0) ≤ (∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairBobHistoryEntropyIncrement G n S D r else 0) := by apply Finset.sum_le_sum intro r _ split · exact mul_le_mul_of_nonneg_left (exactFairBobHistoryVariation_le_entropy G n S D r) (exactFairHistoryPriorWeight_nonneg G n D r) · exact le_rfl end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactSourceClassicalInformationRate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := (3 * postselectionLogCost G n S D + 2 * answerLogCost (A := A) (B := B) D) / ((Finset.univ \ D).card : ℝ) def ExactSourceClassicalInformationBound (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : Prop := finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) ≤ exactSourceClassicalInformationRate G n S D ∧ finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) ≤ exactSourceClassicalInformationRate G n S D theorem exactFiniteRelativeEntropy_equiv {ι κ : Type*} [Fintype ι] [Fintype κ] (e : ι ≃ κ) (p q : ι → ℝ) : finiteRelativeEntropy (fun k : κ => p (e.symm k)) (fun k : κ => q (e.symm k)) = finiteRelativeEntropy p q := by unfold finiteRelativeEntropy exact e.symm.sum_comp (fun i => q i * InformationTheory.klFun (p i / q i)) def exactAliceInformationEquiv {n : ℕ} (D : Finset (Fin n)) : ExactLocallySampleableTuple X Y A B D ≃ (SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y) where toFun t := ((t.1, t.2.1), (t.2.2.2, t.2.2.1)) invFun t := (t.1.1, t.1.2, t.2.2, t.2.1) left_inv t := by rcases t with ⟨i, x, y, r⟩ rfl right_inv t := by rcases t with ⟨⟨i, x⟩, ⟨r, y⟩⟩ rfl def exactBobInformationEquiv {n : ℕ} (D : Finset (Fin n)) : ExactLocallySampleableTuple X Y A B D ≃ (SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X) where toFun t := ((t.1, t.2.2.1), (t.2.2.2, t.2.1)) invFun t := (t.1.1, t.2.2, t.1.2, t.2.1) left_inv t := by rcases t with ⟨i, x, y, r⟩ rfl right_inv t := by rcases t with ⟨⟨i, y⟩, ⟨r, x⟩⟩ rfl def exactAliceInformationPosterior (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y) → ℝ := fun t => exactLocallySampleableLaw G n S D ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) def exactAliceInformationReference (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : (SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y) → ℝ := fun t => exactLocallySampleableJA G n S D base ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) def exactBobInformationPosterior (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X) → ℝ := fun t => exactLocallySampleableLaw G n S D ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) def exactBobInformationReference (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : (SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X) → ℝ := fun t => exactLocallySampleableJB G n S D base ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) theorem exact_source_equation_twenty_four_alice (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) = finiteRelativeEntropy (jointFirstMarginal (exactAliceInformationPosterior G n S D)) (jointFirstMarginal (exactAliceInformationReference G n S D base)) + ∑ ix : SourceRemainingCoordinate D × X, jointFirstMarginal (exactAliceInformationPosterior G n S D) ix * finiteRelativeEntropy (jointConditional (exactAliceInformationPosterior G n S D) ix) (jointConditional (exactAliceInformationReference G n S D base) ix) := by let e := exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D let p := exactAliceInformationPosterior G n S D let q := exactAliceInformationReference G n S D base have hp : ∀ t, 0 ≤ p t := by intro t exact exactLocallySampleableLaw_nonneg G n S D positive (e.symm t) have hq : ∀ t, 0 ≤ q t := by intro t exact exactLocallySampleableJA_nonneg G n S D positive base (e.symm t) have hac : ∀ t, q t = 0 → p t = 0 := by intro t ht exact exactLocallySampleableLaw_absolute_continuous_JA G n S D remaining positive base (e.symm t) ht have hpnorm : (∑ t, p t) = 1 := by change (∑ t, exactLocallySampleableLaw G n S D (e.symm t)) = 1 rw [e.symm.sum_comp] exact exactLocallySampleableLaw_sum G n S D remaining positive have hqnorm : (∑ t, q t) = 1 := by change (∑ t, exactLocallySampleableJA G n S D base (e.symm t)) = 1 rw [e.symm.sum_comp] exact exactLocallySampleableJA_sum G n S D remaining base calc finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) = finiteRelativeEntropy p q := by exact (exactFiniteRelativeEntropy_equiv e (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base)).symm _ = _ := finite_relative_entropy_joint_chain_rule p q hp hq hac hpnorm hqnorm theorem exact_source_equation_twenty_four_bob (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) = finiteRelativeEntropy (jointFirstMarginal (exactBobInformationPosterior G n S D)) (jointFirstMarginal (exactBobInformationReference G n S D base)) + ∑ iy : SourceRemainingCoordinate D × Y, jointFirstMarginal (exactBobInformationPosterior G n S D) iy * finiteRelativeEntropy (jointConditional (exactBobInformationPosterior G n S D) iy) (jointConditional (exactBobInformationReference G n S D base) iy) := by let e := exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D let p := exactBobInformationPosterior G n S D let q := exactBobInformationReference G n S D base have hp : ∀ t, 0 ≤ p t := by intro t exact exactLocallySampleableLaw_nonneg G n S D positive (e.symm t) have hq : ∀ t, 0 ≤ q t := by intro t exact exactLocallySampleableJB_nonneg G n S D positive base (e.symm t) have hac : ∀ t, q t = 0 → p t = 0 := by intro t ht exact exactLocallySampleableLaw_absolute_continuous_JB G n S D remaining positive base (e.symm t) ht have hpnorm : (∑ t, p t) = 1 := by change (∑ t, exactLocallySampleableLaw G n S D (e.symm t)) = 1 rw [e.symm.sum_comp] exact exactLocallySampleableLaw_sum G n S D remaining positive have hqnorm : (∑ t, q t) = 1 := by change (∑ t, exactLocallySampleableJB G n S D base (e.symm t)) = 1 rw [e.symm.sum_comp] exact exactLocallySampleableJB_sum G n S D remaining base calc finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) = finiteRelativeEntropy p q := by exact (exactFiniteRelativeEntropy_equiv e (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base)).symm _ = _ := finite_relative_entropy_joint_chain_rule p q hp hq hac hpnorm hqnorm def exactSourcePinskerRate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := Real.sqrt (exactSourceClassicalInformationRate G n S D / 2) theorem exact_source_alice_pinsker_of_classical_information (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (information : ExactSourceClassicalInformationBound G n S D base) : finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) ≤ exactSourcePinskerRate G n S D := by calc _ ≤ Real.sqrt (finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) / 2) := exactLocallySampleableJA_pinsker G n S D remaining positive base _ ≤ exactSourcePinskerRate G n S D := by unfold exactSourcePinskerRate apply Real.sqrt_le_sqrt exact div_le_div_of_nonneg_right information.1 (by norm_num) theorem exact_source_bob_pinsker_of_classical_information (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (information : ExactSourceClassicalInformationBound G n S D base) : finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) ≤ exactSourcePinskerRate G n S D := by calc _ ≤ Real.sqrt (finiteRelativeEntropy (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) / 2) := exactLocallySampleableJB_pinsker G n S D remaining positive base _ ≤ exactSourcePinskerRate G n S D := by unfold exactSourcePinskerRate apply Real.sqrt_le_sqrt exact div_le_div_of_nonneg_right information.2 (by norm_num) end noncomputable section open scoped BigOperators set_option maxHeartbeats 1600000 attribute [local instance] Classical.propDecidable theorem exactSeedCoordinateFiber_sum {M : Type*} [Fintype M] [DecidableEq M] (coordinate : M) : (∑ partition : M → Bool, ∑ leftOrder : Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}, ∑ rightOrder : Equiv.Perm {j : M // j ∈ exactRight coordinate partition}, ∑ leftCut : Fin ((exactLeft coordinate partition).card + 1), ∑ rightCut : Fin ((exactRight coordinate partition).card + 1), exactSeedWeight ⟨coordinate, partition, leftOrder, rightOrder, leftCut, rightCut⟩) = 1 / (Fintype.card M : ℝ) := by classical have hbits : 0 < Fintype.card (M → Bool) := Fintype.card_pos_iff.mpr ⟨fun _ => false⟩ conv_rhs => rw [← exactUniform_sum_mul hbits (1 / (Fintype.card M : ℝ))] apply Finset.sum_congr (by ext; simp) intro partition _ letI : DecidableEq {j : M // j ∈ exactLeft coordinate partition} := fun a b => Classical.propDecidable (a = b) letI : DecidableEq {j : M // j ∈ exactRight coordinate partition} := fun a b => Classical.propDecidable (a = b) conv_rhs => rw [← exactPermutationUniform_sum_mul (T := {j : M // j ∈ exactLeft coordinate partition}) ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)))] apply Finset.sum_congr (by ext; simp) intro leftOrder _ conv_rhs => rw [← exactPermutationUniform_sum_mul (T := {j : M // j ∈ exactRight coordinate partition}) ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}) : ℝ)))] apply Finset.sum_congr (by ext; simp) intro rightOrder _ conv_rhs => rw [← exactPrefixUniform_sum_mul (exactLeft coordinate partition).card ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactRight coordinate partition}) : ℝ)))] apply Finset.sum_congr (by ext; simp) intro leftCut _ conv_rhs => rw [← exactPrefixUniform_sum_mul (exactRight coordinate partition).card ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ exactRight coordinate partition}) : ℝ)) * (1 / ((exactLeft coordinate partition).card + 1 : ℝ)))] apply Finset.sum_congr (by ext; simp) intro rightCut _ simp only [exactSeedWeight] congr 2 congr 3 · apply congrArg (fun k : ℕ => (k : ℝ)) exact exactFintypeCard_eq _ _ · exact exactFintypeCard_eq _ _ theorem exactSeedWeight_coordinate_sum {M : Type*} [Fintype M] [DecidableEq M] (f : M → ℝ) : (∑ seed : ExactForwardSeed M, exactSeedWeight seed * f seed.coordinate) = ∑ i : M, (1 / (Fintype.card M : ℝ)) * f i := by classical rw [exactForwardSeed_sum] apply Finset.sum_congr (by ext; simp) intro i _ simp_rw [← Finset.sum_mul] rw [exactSeedCoordinateFiber_sum i] theorem exactSeedWeight_coordinate_marginal {M : Type*} [Fintype M] [DecidableEq M] (i : M) : (∑ seed : ExactForwardSeed M, if seed.coordinate = i then exactSeedWeight seed else 0) = 1 / (Fintype.card M : ℝ) := by have h := exactSeedWeight_coordinate_sum (M := M) (fun j => if j = i then (1 : ℝ) else 0) simpa only [mul_ite, mul_one, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] using h end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactSourcePrefixFlagEquiv {Ω V Z : Type*} {h : ℕ} : ((Ω × (Fin h → V)) × Z) ≃ ((Ω × Z) × (Fin h → V)) where toFun t := ((t.1.1, t.2), t.1.2) invFun t := ((t.1.1, t.2), t.1.2) left_inv t := by rcases t with ⟨⟨u, values⟩, z⟩ rfl right_inv t := by rcases t with ⟨⟨u, z⟩, values⟩ rfl end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactAliceQuestionPriorMarginal (G : Game X Y A B) (x : X) : ℝ := ∑ y : Y, G.questionWeight x y def exactBobQuestionPriorMarginal (G : Game X Y A B) (y : Y) : ℝ := ∑ x : X, G.questionWeight x y theorem exactAliceInformationReference_firstMarginal (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (i : SourceRemainingCoordinate D) (x : X) : jointFirstMarginal (exactAliceInformationReference G n S D base) (i, x) = exactAliceQuestionPriorMarginal G x / (Fintype.card (SourceRemainingCoordinate D) : ℝ) := by unfold jointFirstMarginal rw [Fintype.sum_prod_type] change (∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, G.questionWeight x y * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) = (∑ y : Y, G.questionWeight x y) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) rw [Finset.sum_comm] simp_rw [← Finset.sum_div, ← Finset.mul_sum, exactAliceLocalConditional_sum, mul_one] theorem exactBobInformationReference_firstMarginal (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (i : SourceRemainingCoordinate D) (y : Y) : jointFirstMarginal (exactBobInformationReference G n S D base) (i, y) = exactBobQuestionPriorMarginal G y / (Fintype.card (SourceRemainingCoordinate D) : ℝ) := by unfold jointFirstMarginal rw [Fintype.sum_prod_type] change (∑ r : ExactHistoryFlag X Y A B D, ∑ x : X, G.questionWeight x y * exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) = (∑ x : X, G.questionWeight x y) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) rw [Finset.sum_comm] simp_rw [← Finset.sum_div, ← Finset.mul_sum, exactBobLocalConditional_sum, mul_one] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactGroupedMass_decidableEq_irrel {Ω κ : Type*} [Fintype Ω] (first second : DecidableEq κ) (projection : Ω → κ) (mass : Ω → ℝ) : @groupedMass Ω _ κ first projection mass = @groupedMass Ω _ κ second projection mass := by have h : first = second := Subsingleton.elim first second subst second rfl end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactAliceSourceMarginalInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : ℝ := finiteRelativeEntropy (jointFirstMarginal (exactAliceInformationPosterior G n S D)) (jointFirstMarginal (exactAliceInformationReference G n S D base)) def exactBobSourceMarginalInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : ℝ := finiteRelativeEntropy (jointFirstMarginal (exactBobInformationPosterior G n S D)) (jointFirstMarginal (exactBobInformationReference G n S D base)) def exactAliceSourceConditionalInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : ℝ := ∑ ix : SourceRemainingCoordinate D × X, jointFirstMarginal (exactAliceInformationPosterior G n S D) ix * finiteRelativeEntropy (jointConditional (exactAliceInformationPosterior G n S D) ix) (jointConditional (exactAliceInformationReference G n S D base) ix) def exactBobSourceConditionalInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : ℝ := ∑ iy : SourceRemainingCoordinate D × Y, jointFirstMarginal (exactBobInformationPosterior G n S D) iy * finiteRelativeEntropy (jointConditional (exactBobInformationPosterior G n S D) iy) (jointConditional (exactBobInformationReference G n S D base) iy) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1200000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable def exactInsertedRank {M : Type*} [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) (rank : {j : M // j ∈ side} ≃ Fin side.card) (cut : Fin (side.card + 1)) : {j : M // j ∈ insert i side} ≃ Fin (side.card + 1) := (Finset.subtypeInsertEquivOption not_mem).trans ((Equiv.optionCongr rank).trans (finSuccEquiv' cut).symm) @[simp] theorem exactInsertedRank_marker {M : Type*} [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) (rank : {j : M // j ∈ side} ≃ Fin side.card) (cut : Fin (side.card + 1)) : exactInsertedRank i side not_mem rank cut ⟨i, Finset.mem_insert_self i side⟩ = cut := by simp [exactInsertedRank, Finset.subtypeInsertEquivOption] theorem exactInsertedRank_old {M : Type*} [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) (rank : {j : M // j ∈ side} ≃ Fin side.card) (cut : Fin (side.card + 1)) (j : {j : M // j ∈ side}) : exactInsertedRank i side not_mem rank cut ⟨j.val, Finset.mem_insert_of_mem j.property⟩ = cut.succAbove (rank j) := by have hne : j.val ≠ i := by intro h exact not_mem (h ▸ j.property) simp [exactInsertedRank, Finset.subtypeInsertEquivOption, hne] def exactReverseLeftRank {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : {j : M // j ∈ exactReverseLeftSide seed} ≃ Fin ((exactLeft seed.coordinate seed.partition).card + 1) := exactInsertedRank seed.coordinate (exactLeft seed.coordinate seed.partition) (exactLeft_coordinate_not_mem seed.coordinate seed.partition) (exactLeftRank seed) seed.leftCut def exactReverseRightRank {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : {j : M // j ∈ exactReverseRightSide seed} ≃ Fin ((exactRight seed.coordinate seed.partition).card + 1) := exactInsertedRank seed.coordinate (exactRight seed.coordinate seed.partition) (exactRight_coordinate_not_mem seed.coordinate seed.partition) (exactRightRank seed) seed.rightCut @[simp] theorem exactReverseLeftRank_coordinate {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseLeftRank seed ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ = seed.leftCut := by exact exactInsertedRank_marker seed.coordinate (exactLeft seed.coordinate seed.partition) (exactLeft_coordinate_not_mem seed.coordinate seed.partition) (exactLeftRank seed) seed.leftCut @[simp] theorem exactReverseRightRank_coordinate {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseRightRank seed ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ = seed.rightCut := by exact exactInsertedRank_marker seed.coordinate (exactRight seed.coordinate seed.partition) (exactRight_coordinate_not_mem seed.coordinate seed.partition) (exactRightRank seed) seed.rightCut theorem exactReverseLeftRank_old {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) (j : {j : M // j ∈ exactLeft seed.coordinate seed.partition}) : exactReverseLeftRank seed ⟨j.val, Finset.mem_insert_of_mem j.property⟩ = seed.leftCut.succAbove (exactLeftRank seed j) := by exact exactInsertedRank_old seed.coordinate (exactLeft seed.coordinate seed.partition) (exactLeft_coordinate_not_mem seed.coordinate seed.partition) (exactLeftRank seed) seed.leftCut j theorem exactReverseRightRank_old {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) (j : {j : M // j ∈ exactRight seed.coordinate seed.partition}) : exactReverseRightRank seed ⟨j.val, Finset.mem_insert_of_mem j.property⟩ = seed.rightCut.succAbove (exactRightRank seed j) := by exact exactInsertedRank_old seed.coordinate (exactRight seed.coordinate seed.partition) (exactRight_coordinate_not_mem seed.coordinate seed.partition) (exactRightRank seed) seed.rightCut j def exactInsertedPrefixBefore {M : Type*} [Fintype M] [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) (rank : {j : M // j ∈ side} ≃ Fin side.card) (cut : Fin (side.card + 1)) : Finset M := (Finset.univ.filter (fun j : {j : M // j ∈ insert i side} => (exactInsertedRank i side not_mem rank cut j).val < cut.val)).image Subtype.val theorem exactInsertedPrefixBefore_marker_eq {M : Type*} [Fintype M] [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) (rank : {j : M // j ∈ side} ≃ Fin side.card) (cut : Fin (side.card + 1)) : exactInsertedPrefixBefore i side not_mem rank cut = (Finset.univ.filter (fun j : {j : M // j ∈ side} => (rank j).val < cut.val)).image Subtype.val := by ext j constructor · intro hj obtain ⟨a, ha, haval⟩ := Finset.mem_image.mp hj have hlt : (exactInsertedRank i side not_mem rank cut a).val < cut.val := (Finset.mem_filter.mp ha).2 have hne : a.val ≠ i := by intro heq have hsub : a = ⟨i, Finset.mem_insert_self i side⟩ := Subtype.ext heq rw [hsub, exactInsertedRank_marker] at hlt exact (Nat.lt_irrefl cut.val) hlt have hside : a.val ∈ side := (Finset.mem_insert.mp a.property).resolve_left hne let b : {j : M // j ∈ side} := ⟨a.val, hside⟩ refine Finset.mem_image.mpr ⟨b, ?_, haval⟩ apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ b, ?_⟩ have hbefore : cut.succAbove (rank b) < cut := by change (cut.succAbove (rank b)).val < cut.val rw [← exactInsertedRank_old i side not_mem rank cut b] exact hlt have hcast : (rank b).castSucc < cut := (Fin.succAbove_lt_iff_castSucc_lt cut (rank b)).mp hbefore exact hcast · intro hj obtain ⟨b, hb, hbval⟩ := Finset.mem_image.mp hj have hlt : (rank b).val < cut.val := (Finset.mem_filter.mp hb).2 let a : {j : M // j ∈ insert i side} := ⟨b.val, Finset.mem_insert_of_mem b.property⟩ refine Finset.mem_image.mpr ⟨a, ?_, hbval⟩ apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ a, ?_⟩ have hcast : (rank b).castSucc < cut := hlt have hbefore : cut.succAbove (rank b) < cut := (Fin.succAbove_lt_iff_castSucc_lt cut (rank b)).mpr hcast rw [exactInsertedRank_old i side not_mem rank cut b] exact hbefore def exactReverseLeftPrefixBeforeMarked {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Finset M := exactInsertedPrefixBefore seed.coordinate (exactLeft seed.coordinate seed.partition) (exactLeft_coordinate_not_mem seed.coordinate seed.partition) (exactLeftRank seed) seed.leftCut def exactReverseRightPrefixBeforeMarked {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Finset M := exactInsertedPrefixBefore seed.coordinate (exactRight seed.coordinate seed.partition) (exactRight_coordinate_not_mem seed.coordinate seed.partition) (exactRightRank seed) seed.rightCut theorem exactReverseLeftPrefixBeforeMarked_eq {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseLeftPrefixBeforeMarked seed = exactLeftPrefix seed := by exact exactInsertedPrefixBefore_marker_eq seed.coordinate (exactLeft seed.coordinate seed.partition) (exactLeft_coordinate_not_mem seed.coordinate seed.partition) (exactLeftRank seed) seed.leftCut theorem exactReverseRightPrefixBeforeMarked_eq {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseRightPrefixBeforeMarked seed = exactRightPrefix seed := by exact exactInsertedPrefixBefore_marker_eq seed.coordinate (exactRight seed.coordinate seed.partition) (exactRight_coordinate_not_mem seed.coordinate seed.partition) (exactRightRank seed) seed.rightCut end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable def exactOrderedSidePrefix {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (rank : {j : M // j ∈ side} ≃ Fin side.card) (cut : Fin (side.card + 1)) : Finset M := (Finset.univ.filter (fun j : {j : M // j ∈ side} => (rank j).val < cut.val)).image Subtype.val theorem exactOrderedSidePrefix_mem_iff {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (rank : {j : M // j ∈ side} ≃ Fin side.card) (cut : Fin (side.card + 1)) (j : M) : j ∈ exactOrderedSidePrefix side rank cut ↔ ∃ hj : j ∈ side, (rank ⟨j, hj⟩).val < cut.val := by constructor · intro hj obtain ⟨a, ha, haval⟩ := Finset.mem_image.mp hj have hside : j ∈ side := haval ▸ a.property refine ⟨hside, ?_⟩ have hsub : (⟨j, hside⟩ : {j : M // j ∈ side}) = a := Subtype.ext haval.symm rw [hsub] exact (Finset.mem_filter.mp ha).2 · rintro ⟨hj, hlt⟩ exact Finset.mem_image.mpr ⟨⟨j, hj⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hlt⟩, rfl⟩ theorem exactInsertedPrefixBefore_mem_iff {M : Type*} [Fintype M] [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) (rank : {j : M // j ∈ side} ≃ Fin side.card) (cut : Fin (side.card + 1)) (j : M) : j ∈ exactInsertedPrefixBefore i side not_mem rank cut ↔ ∃ hj : j ∈ insert i side, (exactInsertedRank i side not_mem rank cut ⟨j, hj⟩).val < cut.val := by constructor · intro hj obtain ⟨a, ha, haval⟩ := Finset.mem_image.mp hj have hside : j ∈ insert i side := haval ▸ a.property refine ⟨hside, ?_⟩ have hsub : (⟨j, hside⟩ : {j : M // j ∈ insert i side}) = a := Subtype.ext haval.symm rw [hsub] exact (Finset.mem_filter.mp ha).2 · rintro ⟨hj, hlt⟩ exact Finset.mem_image.mpr ⟨⟨j, hj⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hlt⟩, rfl⟩ structure ExactReverseSideContext (M : Type*) [Fintype M] [DecidableEq M] (side : Finset M) where otherSide : Finset M sideRank : {j : M // j ∈ side} ≃ Fin side.card otherRank : {j : M // j ∈ otherSide} ≃ Fin otherSide.card otherCut : Fin (otherSide.card + 1) ignoredBit : Bool otherSide_eq_complement : otherSide = Finset.univ \ side deriving Fintype def exactReverseContextOtherPrefix {M : Type*} [Fintype M] [DecidableEq M] {side : Finset M} (context : ExactReverseSideContext M side) : Finset M := exactOrderedSidePrefix context.otherSide context.otherRank context.otherCut theorem exactReverseLeftSide_complement {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactRight seed.coordinate seed.partition = Finset.univ \ exactReverseLeftSide seed := by ext j by_cases hcoordinate : j = seed.coordinate · subst j simp [exactRight, exactReverseLeftSide] · cases hbit : seed.partition j <;> simp [exactRight, exactLeft, exactReverseLeftSide, hcoordinate, hbit] theorem exactReverseRightSide_complement {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactLeft seed.coordinate seed.partition = Finset.univ \ exactReverseRightSide seed := by ext j by_cases hcoordinate : j = seed.coordinate · subst j simp [exactLeft, exactReverseRightSide] · cases hbit : seed.partition j <;> simp [exactRight, exactLeft, exactReverseRightSide, hcoordinate, hbit] def exactReverseAliceContext {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : ExactReverseSideContext M (exactReverseLeftSide seed) where otherSide := exactRight seed.coordinate seed.partition sideRank := (exactReverseLeftRank seed).trans (finCongr (exactReverseLeftSide_card seed).symm) otherRank := exactRightRank seed otherCut := seed.rightCut ignoredBit := seed.partition seed.coordinate otherSide_eq_complement := exactReverseLeftSide_complement seed def exactReverseBobContext {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : ExactReverseSideContext M (exactReverseRightSide seed) where otherSide := exactLeft seed.coordinate seed.partition sideRank := (exactReverseRightRank seed).trans (finCongr (exactReverseRightSide_card seed).symm) otherRank := exactLeftRank seed otherCut := seed.leftCut ignoredBit := seed.partition seed.coordinate otherSide_eq_complement := exactReverseRightSide_complement seed def exactDefaultReverseSideContext {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) : ExactReverseSideContext M side where otherSide := Finset.univ \ side sideRank := Finset.equivFin side otherRank := Finset.equivFin (Finset.univ \ side) otherCut := 0 ignoredBit := false otherSide_eq_complement := rfl def exactReverseAliceContextAt {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (seed : ExactForwardSeed M) : ExactReverseSideContext M side := if h : exactReverseLeftSide seed = side then h ▸ exactReverseAliceContext seed else exactDefaultReverseSideContext side def exactReverseBobContextAt {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (seed : ExactForwardSeed M) : ExactReverseSideContext M side := if h : exactReverseRightSide seed = side then h ▸ exactReverseBobContext seed else exactDefaultReverseSideContext side @[simp] theorem exactReverseAliceContextAt_actual {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseAliceContextAt (exactReverseLeftSide seed) seed = exactReverseAliceContext seed := by simp [exactReverseAliceContextAt] @[simp] theorem exactReverseBobContextAt_actual {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseBobContextAt (exactReverseRightSide seed) seed = exactReverseBobContext seed := by simp [exactReverseBobContextAt] @[simp] theorem exactReverseAliceContext_otherPrefix {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseContextOtherPrefix (exactReverseAliceContext seed) = exactRightPrefix seed := by rfl @[simp] theorem exactReverseBobContext_otherPrefix {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseContextOtherPrefix (exactReverseBobContext seed) = exactLeftPrefix seed := by rfl variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactReverseAliceFixedInformation (X Y : Type*) [Fintype X] [Fintype Y] {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) := Σ context : ExactReverseSideContext (SourceRemainingCoordinate D) side, ({j : Fin n // j ∈ D} → X) × ({j : Fin n // j ∈ D} → Y) × ({j : SourceRemainingCoordinate D // j ∈ side} → X) × ({j : SourceRemainingCoordinate D // j ∈ context.otherSide} → Y) × ({j : SourceRemainingCoordinate D // j ∈ exactReverseContextOtherPrefix context} → X) abbrev ExactReverseBobFixedInformation (X Y : Type*) [Fintype X] [Fintype Y] {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) := Σ context : ExactReverseSideContext (SourceRemainingCoordinate D) side, ({j : Fin n // j ∈ D} → X) × ({j : Fin n // j ∈ D} → Y) × ({j : SourceRemainingCoordinate D // j ∈ side} → Y) × ({j : SourceRemainingCoordinate D // j ∈ context.otherSide} → X) × ({j : SourceRemainingCoordinate D // j ∈ exactReverseContextOtherPrefix context} → Y) def exactReverseAliceSourceProjection {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) : ExactJointOutcome X Y A B D → ExactReverseAliceFixedInformation X Y D side × (Fin side.card → Y) := fun q => let context := exactReverseAliceContextAt side q.1 (⟨context, (fun j => q.2.1 j.val), (fun j => q.2.2.1 j.val), (fun j => q.2.1 j.val.val), (fun j => q.2.2.1 j.val.val), (fun j => q.2.1 j.val.val)⟩, fun k => q.2.2.1 (context.sideRank.symm k).val.val) def exactReverseBobSourceProjection {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) : ExactJointOutcome X Y A B D → ExactReverseBobFixedInformation X Y D side × (Fin side.card → X) := fun q => let context := exactReverseBobContextAt side q.1 (⟨context, (fun j => q.2.1 j.val), (fun j => q.2.2.1 j.val), (fun j => q.2.2.1 j.val.val), (fun j => q.2.1 j.val.val), (fun j => q.2.2.1 j.val.val)⟩, fun k => q.2.1 (context.sideRank.symm k).val.val) @[simp] theorem exactReverseAliceContext_marked_rank {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩).val = seed.leftCut.val := by simp [exactReverseAliceContext, Equiv.trans_apply, exactReverseLeftRank_coordinate] @[simp] theorem exactReverseBobContext_marked_rank {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩).val = seed.rightCut.val := by simp [exactReverseBobContext, Equiv.trans_apply, exactReverseRightRank_coordinate] def exactReverseContextPrefixBefore {M : Type*} [Fintype M] [DecidableEq M] {side : Finset M} (context : ExactReverseSideContext M side) (position : Fin side.card) : Finset M := exactOrderedSidePrefix side context.sideRank position.castSucc theorem exactReverseAliceContext_prefix_before_marked {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseContextPrefixBefore (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) = exactLeftPrefix seed := by calc exactReverseContextPrefixBefore (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) = exactReverseLeftPrefixBeforeMarked seed := by change exactOrderedSidePrefix (exactReverseLeftSide seed) (exactReverseAliceContext seed).sideRank ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩).castSucc = exactInsertedPrefixBefore seed.coordinate (exactLeft seed.coordinate seed.partition) (exactLeft_coordinate_not_mem seed.coordinate seed.partition) (exactLeftRank seed) seed.leftCut ext j simp only [exactOrderedSidePrefix_mem_iff, exactInsertedPrefixBefore_mem_iff] constructor · rintro ⟨hj, hlt⟩ change j ∈ insert seed.coordinate (exactLeft seed.coordinate seed.partition) at hj refine ⟨hj, ?_⟩ have hlt' : ((exactReverseAliceContext seed).sideRank ⟨j, hj⟩).val < seed.leftCut.val := by simpa only [Fin.val_castSucc, exactReverseAliceContext_marked_rank] using hlt convert hlt' using 1 ; simp [exactReverseAliceContext, exactReverseLeftRank, Equiv.trans_apply] ; congr 2 · rintro ⟨hj, hlt⟩ change j ∈ exactReverseLeftSide seed at hj refine ⟨hj, ?_⟩ have hlt' : ((exactReverseAliceContext seed).sideRank ⟨j, hj⟩).val < seed.leftCut.val := by convert hlt using 1 ; simp [exactReverseAliceContext, exactReverseLeftRank, Equiv.trans_apply] ; congr 2 simpa only [Fin.val_castSucc, exactReverseAliceContext_marked_rank] using hlt' _ = exactLeftPrefix seed := exactReverseLeftPrefixBeforeMarked_eq seed theorem exactReverseBobContext_prefix_before_marked {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : exactReverseContextPrefixBefore (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) = exactRightPrefix seed := by calc exactReverseContextPrefixBefore (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) = exactReverseRightPrefixBeforeMarked seed := by change exactOrderedSidePrefix (exactReverseRightSide seed) (exactReverseBobContext seed).sideRank ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩).castSucc = exactInsertedPrefixBefore seed.coordinate (exactRight seed.coordinate seed.partition) (exactRight_coordinate_not_mem seed.coordinate seed.partition) (exactRightRank seed) seed.rightCut ext j simp only [exactOrderedSidePrefix_mem_iff, exactInsertedPrefixBefore_mem_iff] constructor · rintro ⟨hj, hlt⟩ change j ∈ insert seed.coordinate (exactRight seed.coordinate seed.partition) at hj refine ⟨hj, ?_⟩ have hlt' : ((exactReverseBobContext seed).sideRank ⟨j, hj⟩).val < seed.rightCut.val := by simpa only [Fin.val_castSucc, exactReverseBobContext_marked_rank] using hlt convert hlt' using 1 ; simp [exactReverseBobContext, exactReverseRightRank, Equiv.trans_apply] ; congr 2 · rintro ⟨hj, hlt⟩ change j ∈ exactReverseRightSide seed at hj refine ⟨hj, ?_⟩ have hlt' : ((exactReverseBobContext seed).sideRank ⟨j, hj⟩).val < seed.rightCut.val := by convert hlt using 1 ; simp [exactReverseBobContext, exactReverseRightRank, Equiv.trans_apply] ; congr 2 simpa only [Fin.val_castSucc, exactReverseBobContext_marked_rank] using hlt' _ = exactRightPrefix seed := exactReverseRightPrefixBeforeMarked_eq seed end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def exactPrefixNextCode {Ω V : Type*} {h : ℕ} (default : V) (k : Fin h) : (Ω × (Fin h → V)) → ((Ω × (Fin h → V)) × V) := fun t => (finitePrefixMask default k.castSucc t, t.2 k) def exactPrefixNextDecode {Ω V : Type*} {h : ℕ} (k : Fin h) : ((Ω × (Fin h → V)) × V) → (Ω × (Fin h → V)) := fun t => (t.1.1, Function.update t.1.2 k t.2) theorem exactPrefixNextDecode_comp {Ω V : Type*} {h : ℕ} (default : V) (k : Fin h) : exactPrefixNextDecode (Ω := Ω) (V := V) k ∘ exactPrefixNextCode default k = finitePrefixMask default k.succ := by funext t apply Prod.ext · rfl · funext j by_cases heq : j = k · subst j simp [exactPrefixNextDecode, exactPrefixNextCode, finitePrefixMask, Function.comp_apply] · by_cases hlt : j.val < k.val · have hfin : j < k := hlt have hnotgt : ¬ k < j := not_lt_of_ge (le_of_lt hfin) simp [exactPrefixNextDecode, exactPrefixNextCode, finitePrefixMask, Function.comp_apply, Function.update_of_ne heq, hfin, hnotgt] · have hfin : ¬ j < k := hlt have hnotle : ¬ j ≤ k := by intro hle have heqval : j.val = k.val := by omega exact heq (Fin.ext heqval) simp [exactPrefixNextDecode, exactPrefixNextCode, finitePrefixMask, Function.comp_apply, Function.update_of_ne heq, hfin, hnotle] theorem exactPrefixNextCode_comp {Ω V : Type*} {h : ℕ} (default : V) (k : Fin h) : exactPrefixNextCode default k ∘ finitePrefixMask (Ω := Ω) default k.succ = exactPrefixNextCode default k := by funext t apply Prod.ext · exact congrFun (finitePrefixMask_comp (Ω := Ω) default k) t · simp [exactPrefixNextCode, finitePrefixMask, Function.comp_apply] theorem exactPrefixNext_relativeEntropy_eq {Ω V : Type*} [Fintype Ω] [Fintype V] {h : ℕ} (joint prior : Ω × (Fin h → V) → ℝ) (joint_nonnegative : ∀ t, 0 ≤ joint t) (prior_nonnegative : ∀ t, 0 ≤ prior t) (absolute_continuity : ∀ t, prior t = 0 → joint t = 0) (default : V) (k : Fin h) : finiteRelativeEntropy (groupedMass (exactPrefixNextCode default k) joint) (groupedMass (exactPrefixNextCode default k) prior) = finitePrefixRelativeEntropy joint prior default k.succ := by change finiteRelativeEntropy (groupedMass (exactPrefixNextCode default k) joint) (groupedMass (exactPrefixNextCode default k) prior) = finiteRelativeEntropy (groupedMass (finitePrefixMask default k.succ) joint) (groupedMass (finitePrefixMask default k.succ) prior) apply le_antisymm · have hdp := finite_relative_entropy_data_processing (exactPrefixNextCode default k) (groupedMass (finitePrefixMask default k.succ) joint) (groupedMass (finitePrefixMask default k.succ) prior) (groupedMass_nonneg (finitePrefixMask default k.succ) joint joint_nonnegative) (groupedMass_nonneg (finitePrefixMask default k.succ) prior prior_nonnegative) (groupedMass_absolute_continuity (finitePrefixMask default k.succ) joint prior prior_nonnegative absolute_continuity) rw [groupedMass_comp, exactPrefixNextCode_comp, groupedMass_comp, exactPrefixNextCode_comp] at hdp exact hdp · have hdp := finite_relative_entropy_data_processing (exactPrefixNextDecode (Ω := Ω) (V := V) k) (groupedMass (exactPrefixNextCode default k) joint) (groupedMass (exactPrefixNextCode default k) prior) (groupedMass_nonneg (exactPrefixNextCode default k) joint joint_nonnegative) (groupedMass_nonneg (exactPrefixNextCode default k) prior prior_nonnegative) (groupedMass_absolute_continuity (exactPrefixNextCode default k) joint prior prior_nonnegative absolute_continuity) rw [groupedMass_comp, exactPrefixNextDecode_comp, groupedMass_comp, exactPrefixNextDecode_comp] at hdp exact hdp theorem exactPrefixNext_firstMarginal {Ω V : Type*} [Fintype Ω] [Fintype V] {h : ℕ} (mass : Ω × (Fin h → V) → ℝ) (default : V) (k : Fin h) : jointFirstMarginal (groupedMass (exactPrefixNextCode default k) mass) = groupedMass (finitePrefixMask default k.castSucc) mass := by calc jointFirstMarginal (groupedMass (exactPrefixNextCode default k) mass) = groupedMass Prod.fst (groupedMass (exactPrefixNextCode default k) mass) := (groupedMass_first (groupedMass (exactPrefixNextCode default k) mass)).symm _ = groupedMass (Prod.fst ∘ exactPrefixNextCode default k) mass := groupedMass_comp (exactPrefixNextCode default k) Prod.fst mass _ = groupedMass (finitePrefixMask default k.castSucc) mass := by rfl theorem exactPrefixEntropyIncrement_eq_conditional {Ω V : Type*} [Fintype Ω] [Fintype V] {h : ℕ} (joint prior : Ω × (Fin h → V) → ℝ) (joint_nonnegative : ∀ t, 0 ≤ joint t) (prior_nonnegative : ∀ t, 0 ≤ prior t) (absolute_continuity : ∀ t, prior t = 0 → joint t = 0) (joint_normalized : (∑ t, joint t) = 1) (prior_normalized : (∑ t, prior t) = 1) (default : V) (k : Fin h) : finitePrefixRelativeEntropy joint prior default k.succ - finitePrefixRelativeEntropy joint prior default k.castSucc = ∑ context : Ω × (Fin h → V), groupedMass (finitePrefixMask default k.castSucc) joint context * finiteRelativeEntropy (jointConditional (groupedMass (exactPrefixNextCode default k) joint) context) (jointConditional (groupedMass (exactPrefixNextCode default k) prior) context) := by let next := exactPrefixNextCode (Ω := Ω) (V := V) default k let nextJoint := groupedMass next joint let nextPrior := groupedMass next prior have hnext_joint : ∀ t, 0 ≤ nextJoint t := groupedMass_nonneg next joint joint_nonnegative have hnext_prior : ∀ t, 0 ≤ nextPrior t := groupedMass_nonneg next prior prior_nonnegative have hnext_absolute : ∀ t, nextPrior t = 0 → nextJoint t = 0 := groupedMass_absolute_continuity next joint prior prior_nonnegative absolute_continuity have hnext_joint_normalized : (∑ t, nextJoint t) = 1 := by rw [groupedMass_sum] exact joint_normalized have hnext_prior_normalized : (∑ t, nextPrior t) = 1 := by rw [groupedMass_sum] exact prior_normalized have hchain := finite_relative_entropy_joint_chain_rule nextJoint nextPrior hnext_joint hnext_prior hnext_absolute hnext_joint_normalized hnext_prior_normalized have hnext_entropy := exactPrefixNext_relativeEntropy_eq joint prior joint_nonnegative prior_nonnegative absolute_continuity default k change finitePrefixRelativeEntropy joint prior default k.succ - finitePrefixRelativeEntropy joint prior default k.castSucc = _ change finiteRelativeEntropy nextJoint nextPrior = finitePrefixRelativeEntropy joint prior default k.succ at hnext_entropy change finiteRelativeEntropy nextJoint nextPrior = finiteRelativeEntropy (jointFirstMarginal nextJoint) (jointFirstMarginal nextPrior) + ∑ context : Ω × (Fin h → V), jointFirstMarginal nextJoint context * finiteRelativeEntropy (jointConditional nextJoint context) (jointConditional nextPrior context) at hchain have hfirst_joint : jointFirstMarginal nextJoint = groupedMass (finitePrefixMask default k.castSucc) joint := exactPrefixNext_firstMarginal joint default k have hfirst_prior : jointFirstMarginal nextPrior = groupedMass (finitePrefixMask default k.castSucc) prior := exactPrefixNext_firstMarginal prior default k rw [hfirst_joint, hfirst_prior] at hchain change finitePrefixRelativeEntropy joint prior default k.succ - finitePrefixRelativeEntropy joint prior default k.castSucc = ∑ context : Ω × (Fin h → V), groupedMass (finitePrefixMask default k.castSucc) joint context * finiteRelativeEntropy (jointConditional nextJoint context) (jointConditional nextPrior context) change finiteRelativeEntropy nextJoint nextPrior = finitePrefixRelativeEntropy joint prior default k.castSucc + ∑ context : Ω × (Fin h → V), groupedMass (finitePrefixMask default k.castSucc) joint context * finiteRelativeEntropy (jointConditional nextJoint context) (jointConditional nextPrior context) at hchain linarith end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def exactReverseAliceCanonicalPartition {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (ignored : Bool) : M → Bool := fun j => if j = coordinate then ignored else if j ∈ side then false else true theorem exactReverseAliceCanonicalPartition_side {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) (ignored : Bool) : insert coordinate (exactLeft coordinate (exactReverseAliceCanonicalPartition side coordinate ignored)) = side := by ext j by_cases hj : j = coordinate · subst j simp [member] · by_cases hs : j ∈ side <;> simp [exactLeft, exactReverseAliceCanonicalPartition, hj, hs] theorem exactReverseAliceCanonicalPartition_unique {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (partition : M → Bool) (fiber : insert coordinate (exactLeft coordinate partition) = side) : partition = exactReverseAliceCanonicalPartition side coordinate (partition coordinate) := by funext j by_cases hj : j = coordinate · subst j simp [exactReverseAliceCanonicalPartition] · cases hb : partition j · have hs : j ∈ side := by rw [← fiber] simp [exactLeft, hj, hb] simp [exactReverseAliceCanonicalPartition, hj, hs] · have hs : j ∉ side := by rw [← fiber] simp [exactLeft, hj, hb] simp [exactReverseAliceCanonicalPartition, hj, hs] def exactReverseAlicePartitionFiberEquiv {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) : {partition : M → Bool // insert coordinate (exactLeft coordinate partition) = side} ≃ Bool where toFun partition := partition.val coordinate invFun ignored := ⟨exactReverseAliceCanonicalPartition side coordinate ignored, exactReverseAliceCanonicalPartition_side side coordinate member ignored⟩ left_inv partition := by apply Subtype.ext exact (exactReverseAliceCanonicalPartition_unique side coordinate partition.val partition.property).symm right_inv ignored := by simp [exactReverseAliceCanonicalPartition] def exactReverseBobCanonicalPartition {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (ignored : Bool) : M → Bool := fun j => if j = coordinate then ignored else if j ∈ side then true else false theorem exactReverseBobCanonicalPartition_side {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) (ignored : Bool) : insert coordinate (exactRight coordinate (exactReverseBobCanonicalPartition side coordinate ignored)) = side := by ext j by_cases hj : j = coordinate · subst j simp [member] · by_cases hs : j ∈ side <;> simp [exactRight, exactReverseBobCanonicalPartition, hj, hs] theorem exactReverseBobCanonicalPartition_unique {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (partition : M → Bool) (fiber : insert coordinate (exactRight coordinate partition) = side) : partition = exactReverseBobCanonicalPartition side coordinate (partition coordinate) := by funext j by_cases hj : j = coordinate · subst j simp [exactReverseBobCanonicalPartition] · cases hb : partition j · have hs : j ∉ side := by rw [← fiber] simp [exactRight, hj, hb] simp [exactReverseBobCanonicalPartition, hj, hs] · have hs : j ∈ side := by rw [← fiber] simp [exactRight, hj, hb] simp [exactReverseBobCanonicalPartition, hj, hs] def exactReverseBobPartitionFiberEquiv {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) : {partition : M → Bool // insert coordinate (exactRight coordinate partition) = side} ≃ Bool where toFun partition := partition.val coordinate invFun ignored := ⟨exactReverseBobCanonicalPartition side coordinate ignored, exactReverseBobCanonicalPartition_side side coordinate member ignored⟩ left_inv partition := by apply Subtype.ext exact (exactReverseBobCanonicalPartition_unique side coordinate partition.val partition.property).symm right_inv ignored := by simp [exactReverseBobCanonicalPartition] theorem exactReverseAlicePartitionFiber_card {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) : Fintype.card {partition : M → Bool // insert coordinate (exactLeft coordinate partition) = side} = 2 := by simpa using Fintype.card_congr (exactReverseAlicePartitionFiberEquiv side coordinate member) theorem exactReverseBobPartitionFiber_card {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) : Fintype.card {partition : M → Bool // insert coordinate (exactRight coordinate partition) = side} = 2 := by simpa using Fintype.card_congr (exactReverseBobPartitionFiberEquiv side coordinate member) theorem exactFiniteIndicator_sum {T : Type*} [Fintype T] (predicate : T → Prop) [DecidablePred predicate] (weight : ℝ) : (∑ t : T, if predicate t then weight else 0) = (Fintype.card {t : T // predicate t} : ℝ) * weight := by classical calc (∑ t : T, if predicate t then weight else 0) = (∑ t : T, if predicate t then (1 : ℝ) else 0) * weight := by rw [Finset.sum_mul] apply Finset.sum_congr rfl intro t _ split_ifs <;> simp _ = (Fintype.card {t : T // predicate t} : ℝ) * weight := by simp [Fintype.card_subtype] theorem exactReverseAlicePartitionFiber_sum {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) (weight : ℝ) : (∑ partition : M → Bool, if insert coordinate (exactLeft coordinate partition) = side then weight else 0) = 2 * weight := by rw [exactFiniteIndicator_sum] rw [exactReverseAlicePartitionFiber_card side coordinate member] norm_num theorem exactReverseBobPartitionFiber_sum {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) (weight : ℝ) : (∑ partition : M → Bool, if insert coordinate (exactRight coordinate partition) = side then weight else 0) = 2 * weight := by rw [exactFiniteIndicator_sum] rw [exactReverseBobPartitionFiber_card side coordinate member] norm_num theorem exactReversePartition_orderCut_sum {M : Type*} [Fintype M] [DecidableEq M] (coordinate : M) (partition : M → Bool) : (∑ leftOrder : Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}, ∑ rightOrder : Equiv.Perm {j : M // j ∈ exactRight coordinate partition}, ∑ leftCut : Fin ((exactLeft coordinate partition).card + 1), ∑ rightCut : Fin ((exactRight coordinate partition).card + 1), exactSeedWeight ⟨coordinate, partition, leftOrder, rightOrder, leftCut, rightCut⟩) = (1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) := by simp only [exactSeedWeight, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, Fintype.card_perm, Fintype.card_coe, Fintype.card_fin, Nat.cast_add, Nat.cast_one] have hleft : (0 : ℝ) < ((exactLeft coordinate partition).card + 1) := by exact_mod_cast Nat.zero_lt_succ _ have hright : (0 : ℝ) < ((exactRight coordinate partition).card + 1) := by exact_mod_cast Nat.zero_lt_succ _ have hleft_factorial : (0 : ℝ) < ((exactLeft coordinate partition).card.factorial : ℝ) := by exact_mod_cast Nat.factorial_pos _ have hright_factorial : (0 : ℝ) < ((exactRight coordinate partition).card.factorial : ℝ) := by exact_mod_cast Nat.factorial_pos _ field_simp [hleft.ne', hright.ne', hleft_factorial.ne', hright_factorial.ne'] theorem exactReverseAlicePartition_orderCut_fiber_sum {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (partition : M → Bool) : (∑ leftOrder : Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}, ∑ rightOrder : Equiv.Perm {j : M // j ∈ exactRight coordinate partition}, ∑ leftCut : Fin ((exactLeft coordinate partition).card + 1), ∑ rightCut : Fin ((exactRight coordinate partition).card + 1), if exactReverseLeftSide (⟨coordinate, partition, leftOrder, rightOrder, leftCut, rightCut⟩ : ExactForwardSeed M) = side then exactSeedWeight ⟨coordinate, partition, leftOrder, rightOrder, leftCut, rightCut⟩ else 0) = if insert coordinate (exactLeft coordinate partition) = side then (1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) else 0 := by by_cases hside : insert coordinate (exactLeft coordinate partition) = side · simpa [exactReverseLeftSide, hside] using exactReversePartition_orderCut_sum coordinate partition · simp [exactReverseLeftSide, hside] theorem exactReverseBobPartition_orderCut_fiber_sum {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (partition : M → Bool) : (∑ leftOrder : Equiv.Perm {j : M // j ∈ exactLeft coordinate partition}, ∑ rightOrder : Equiv.Perm {j : M // j ∈ exactRight coordinate partition}, ∑ leftCut : Fin ((exactLeft coordinate partition).card + 1), ∑ rightCut : Fin ((exactRight coordinate partition).card + 1), if exactReverseRightSide (⟨coordinate, partition, leftOrder, rightOrder, leftCut, rightCut⟩ : ExactForwardSeed M) = side then exactSeedWeight ⟨coordinate, partition, leftOrder, rightOrder, leftCut, rightCut⟩ else 0) = if insert coordinate (exactRight coordinate partition) = side then (1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) else 0 := by by_cases hside : insert coordinate (exactRight coordinate partition) = side · simpa [exactReverseRightSide, hside] using exactReversePartition_orderCut_sum coordinate partition · simp [exactReverseRightSide, hside] theorem exactReverseAliceSide_marginal {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) : groupedMass exactReverseLeftSide exactSeedWeight side = reversePartitionWeight side := by classical unfold groupedMass rw [Finset.sum_filter, exactForwardSeed_sum] simp_rw [exactReverseAlicePartition_orderCut_fiber_sum] have hcoordinate (coordinate : M) : (∑ partition : M → Bool, if insert coordinate (exactLeft coordinate partition) = side then (1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) else 0) = if coordinate ∈ side then 2 * ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ))) else 0 := by by_cases hmember : coordinate ∈ side · simp only [hmember, ↓reduceIte] exact exactReverseAlicePartitionFiber_sum side coordinate hmember ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ))) · simp only [hmember, ↓reduceIte] apply Finset.sum_eq_zero intro partition _ have hnot : insert coordinate (exactLeft coordinate partition) ≠ side := by intro h apply hmember rw [← h] exact Finset.mem_insert_self _ _ simp [hnot] simp_rw [hcoordinate] rw [exactFiniteIndicator_sum] simp only [Fintype.card_coe, Fintype.card_fun, Fintype.card_bool, reversePartitionWeight, fairPartitionWeight, Nat.cast_pow] ring theorem exactReverseBobSide_marginal {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) : groupedMass exactReverseRightSide exactSeedWeight side = reversePartitionWeight side := by classical unfold groupedMass rw [Finset.sum_filter, exactForwardSeed_sum] simp_rw [exactReverseBobPartition_orderCut_fiber_sum] have hcoordinate (coordinate : M) : (∑ partition : M → Bool, if insert coordinate (exactRight coordinate partition) = side then (1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ)) else 0) = if coordinate ∈ side then 2 * ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ))) else 0 := by by_cases hmember : coordinate ∈ side · simp only [hmember, ↓reduceIte] exact exactReverseBobPartitionFiber_sum side coordinate hmember ((1 / (Fintype.card M : ℝ)) * (1 / (Fintype.card (M → Bool) : ℝ))) · simp only [hmember, ↓reduceIte] apply Finset.sum_eq_zero intro partition _ have hnot : insert coordinate (exactRight coordinate partition) ≠ side := by intro h apply hmember rw [← h] exact Finset.mem_insert_self _ _ simp [hnot] simp_rw [hcoordinate] rw [exactFiniteIndicator_sum] simp only [Fintype.card_coe, Fintype.card_fun, Fintype.card_bool, reversePartitionWeight, fairPartitionWeight, Nat.cast_pow] ring def exactReverseAliceConditionalSeedWeight {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (seed : ExactForwardSeed M) : ℝ := if exactReverseLeftSide seed = side then exactSeedWeight seed / reversePartitionWeight side else 0 def exactReverseBobConditionalSeedWeight {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (seed : ExactForwardSeed M) : ℝ := if exactReverseRightSide seed = side then exactSeedWeight seed / reversePartitionWeight side else 0 theorem exactReverseAliceConditionalSeedWeight_nonneg {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (seed : ExactForwardSeed M) : 0 ≤ exactReverseAliceConditionalSeedWeight side seed := by unfold exactReverseAliceConditionalSeedWeight split_ifs · exact div_nonneg (exactSeedWeight_nonneg seed) (reversePartitionWeight_nonneg side) · exact le_rfl theorem exactReverseBobConditionalSeedWeight_nonneg {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (seed : ExactForwardSeed M) : 0 ≤ exactReverseBobConditionalSeedWeight side seed := by unfold exactReverseBobConditionalSeedWeight split_ifs · exact div_nonneg (exactSeedWeight_nonneg seed) (reversePartitionWeight_nonneg side) · exact le_rfl theorem exactReverseAliceConditionalSeedWeight_cancel {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (side : Finset M) (seed : ExactForwardSeed M) : reversePartitionWeight side * exactReverseAliceConditionalSeedWeight side seed = if exactReverseLeftSide seed = side then exactSeedWeight seed else 0 := by by_cases hs : exactReverseLeftSide seed = side · subst side have hpositive : 0 < reversePartitionWeight (exactReverseLeftSide seed) := (reversePartitionWeight_pos_iff nonempty (exactReverseLeftSide seed)).mpr ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ simp only [exactReverseAliceConditionalSeedWeight, ↓reduceIte] field_simp [hpositive.ne'] · simp [exactReverseAliceConditionalSeedWeight, hs] theorem exactReverseBobConditionalSeedWeight_cancel {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (side : Finset M) (seed : ExactForwardSeed M) : reversePartitionWeight side * exactReverseBobConditionalSeedWeight side seed = if exactReverseRightSide seed = side then exactSeedWeight seed else 0 := by by_cases hs : exactReverseRightSide seed = side · subst side have hpositive : 0 < reversePartitionWeight (exactReverseRightSide seed) := (reversePartitionWeight_pos_iff nonempty (exactReverseRightSide seed)).mpr ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ simp only [exactReverseBobConditionalSeedWeight, ↓reduceIte] field_simp [hpositive.ne'] · simp [exactReverseBobConditionalSeedWeight, hs] theorem exactReverseAliceConditionalSeedWeight_sum {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (nonempty : side.Nonempty) : (∑ seed : ExactForwardSeed M, exactReverseAliceConditionalSeedWeight side seed) = 1 := by have hM : 0 < Fintype.card M := Fintype.card_pos_iff.mpr ⟨nonempty.choose⟩ have hside : 0 < reversePartitionWeight side := (reversePartitionWeight_pos_iff hM side).mpr nonempty calc (∑ seed : ExactForwardSeed M, exactReverseAliceConditionalSeedWeight side seed) = (∑ seed : ExactForwardSeed M, if exactReverseLeftSide seed = side then exactSeedWeight seed else 0) / reversePartitionWeight side := by rw [Finset.sum_div] apply Finset.sum_congr rfl intro seed _ unfold exactReverseAliceConditionalSeedWeight split_ifs <;> simp _ = groupedMass exactReverseLeftSide exactSeedWeight side / reversePartitionWeight side := by unfold groupedMass rw [Finset.sum_filter] _ = 1 := by rw [exactReverseAliceSide_marginal] exact div_self hside.ne' theorem exactReverseBobConditionalSeedWeight_sum {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (nonempty : side.Nonempty) : (∑ seed : ExactForwardSeed M, exactReverseBobConditionalSeedWeight side seed) = 1 := by have hM : 0 < Fintype.card M := Fintype.card_pos_iff.mpr ⟨nonempty.choose⟩ have hside : 0 < reversePartitionWeight side := (reversePartitionWeight_pos_iff hM side).mpr nonempty calc (∑ seed : ExactForwardSeed M, exactReverseBobConditionalSeedWeight side seed) = (∑ seed : ExactForwardSeed M, if exactReverseRightSide seed = side then exactSeedWeight seed else 0) / reversePartitionWeight side := by rw [Finset.sum_div] apply Finset.sum_congr rfl intro seed _ unfold exactReverseBobConditionalSeedWeight split_ifs <;> simp _ = groupedMass exactReverseRightSide exactSeedWeight side / reversePartitionWeight side := by unfold groupedMass rw [Finset.sum_filter] _ = 1 := by rw [exactReverseBobSide_marginal] exact div_self hside.ne' def exactForwardSeedLaw {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) : FiniteEventLaw (ExactForwardSeed M) where weight := exactSeedWeight weight_nonneg := exactSeedWeight_nonneg weight_sum := exactSeedWeight_sum nonempty def exactReverseAliceConditionalSeedLaw {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (side : Finset M) : FiniteEventLaw (ExactForwardSeed M) := if hside : side.Nonempty then { weight := exactReverseAliceConditionalSeedWeight side weight_nonneg := exactReverseAliceConditionalSeedWeight_nonneg side weight_sum := exactReverseAliceConditionalSeedWeight_sum side hside } else exactForwardSeedLaw nonempty def exactReverseBobConditionalSeedLaw {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (side : Finset M) : FiniteEventLaw (ExactForwardSeed M) := if hside : side.Nonempty then { weight := exactReverseBobConditionalSeedWeight side weight_nonneg := exactReverseBobConditionalSeedWeight_nonneg side weight_sum := exactReverseBobConditionalSeedWeight_sum side hside } else exactForwardSeedLaw nonempty @[simp] theorem exactReverseAliceConditionalSeedLaw_weight {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (side : Finset M) (hside : side.Nonempty) (seed : ExactForwardSeed M) : (exactReverseAliceConditionalSeedLaw nonempty side).weight seed = exactReverseAliceConditionalSeedWeight side seed := by simp [exactReverseAliceConditionalSeedLaw, hside] @[simp] theorem exactReverseBobConditionalSeedLaw_weight {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (side : Finset M) (hside : side.Nonempty) (seed : ExactForwardSeed M) : (exactReverseBobConditionalSeedLaw nonempty side).weight seed = exactReverseBobConditionalSeedWeight side seed := by simp [exactReverseBobConditionalSeedLaw, hside] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def reweightedSeedPriorEventLaw {K : Type*} [Fintype K] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) : FiniteEventLaw (K × ExactOutcome X Y A B n) where weight q := seedLaw.weight q.1 * (strategyEventLaw (G.repeat n) S).weight q.2 weight_nonneg q := mul_nonneg (seedLaw.weight_nonneg q.1) ((strategyEventLaw (G.repeat n) S).weight_nonneg q.2) weight_sum := by rw [Fintype.sum_prod_type] simp_rw [← Finset.mul_sum, (strategyEventLaw (G.repeat n) S).weight_sum, mul_one] exact seedLaw.weight_sum def reweightedSeedWinEvent {K : Type*} [Fintype K] (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) : Finset (K × ExactOutcome X Y A B n) := Finset.univ.filter (fun q : K × ExactOutcome X Y A B n => q.2 ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) theorem reweightedSeedWinEventMass {K : Type*} [Fintype K] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (reweightedSeedPriorEventLaw seedLaw G n S).eventMass (reweightedSeedWinEvent (K := K) G n D) = repeatedPostselectionMass G n S D := by classical let event := FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D let original := strategyEventLaw (G.repeat n) S change (∑ q ∈ (Finset.univ.filter (fun q : K × ExactOutcome X Y A B n => q.2 ∈ event)), seedLaw.weight q.1 * original.weight q.2) = ∑ outcome ∈ event, original.weight outcome simp only [Finset.sum_filter] rw [Fintype.sum_prod_type] have hinner (k : K) : (∑ outcome : ExactOutcome X Y A B n, if outcome ∈ event then seedLaw.weight k * original.weight outcome else 0) = seedLaw.weight k * (∑ outcome : ExactOutcome X Y A B n, if outcome ∈ event then original.weight outcome else 0) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro outcome _ split_ifs <;> simp simp_rw [hinner] rw [← Finset.sum_mul, seedLaw.weight_sum] simp def reweightedSeedPosterior {K : Type*} [Fintype K] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : K × ExactOutcome X Y A B n → ℝ := conditionedEventDistribution (reweightedSeedPriorEventLaw seedLaw G n S) (reweightedSeedWinEvent (K := K) G n D) theorem reweightedSeedPosterior_eq_product {K : Type*} [Fintype K] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (q : K × ExactOutcome X Y A B n) : reweightedSeedPosterior seedLaw G n S D q = seedLaw.weight q.1 * repeatedConditionedOutcomeLaw G n S D q.2 := by classical let event := FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D have hmass := reweightedSeedWinEventMass seedLaw G n S D by_cases hq : q.2 ∈ event · have hlift : q ∈ reweightedSeedWinEvent (K := K) G n D := by simpa [reweightedSeedWinEvent] using hq unfold reweightedSeedPosterior repeatedConditionedOutcomeLaw conditionedEventDistribution rw [if_pos hlift, if_pos hq] change (seedLaw.weight q.1 * (strategyEventLaw (G.repeat n) S).weight q.2) / (reweightedSeedPriorEventLaw seedLaw G n S).eventMass (reweightedSeedWinEvent (K := K) G n D) = seedLaw.weight q.1 * ((strategyEventLaw (G.repeat n) S).weight q.2 / repeatedPostselectionMass G n S D) rw [hmass] ring · have hlift : q ∉ reweightedSeedWinEvent (K := K) G n D := by simpa [reweightedSeedWinEvent] using hq change q.2 ∉ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D at hq simp [reweightedSeedPosterior, repeatedConditionedOutcomeLaw, conditionedEventDistribution, hlift, hq] theorem reweightedSeedProjection_relativeEntropy_le {K U : Type*} [Fintype K] [Fintype U] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → U) : finiteRelativeEntropy (groupedMass projection (reweightedSeedPosterior seedLaw G n S D)) (groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight) ≤ postselectionLogCost G n S D := by let law := reweightedSeedPriorEventLaw seedLaw G n S let event := reweightedSeedWinEvent (K := K) G n D have hpositive : 0 < law.eventMass event := by change 0 < (reweightedSeedPriorEventLaw seedLaw G n S).eventMass (reweightedSeedWinEvent (K := K) G n D) rw [reweightedSeedWinEventMass] exact positive change finiteRelativeEntropy (groupedMass projection (conditionedEventDistribution law event)) (groupedMass projection law.weight) ≤ _ calc finiteRelativeEntropy (groupedMass projection (conditionedEventDistribution law event)) (groupedMass projection law.weight) ≤ Real.log (1 / law.eventMass event) := conditionedEventDistribution_projection_relativeEntropy_le law event hpositive projection _ = postselectionLogCost G n S D := by change Real.log (1 / (reweightedSeedPriorEventLaw seedLaw G n S).eventMass (reweightedSeedWinEvent (K := K) G n D)) = _ rw [reweightedSeedWinEventMass] rfl def reweightedSeedFlaggedProjectionLaw {K U Z : Type*} [Fintype K] [Fintype U] [Fintype Z] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → U) (flag : K × ExactOutcome X Y A B n → Z) : U × Z → ℝ := groupedMass (fun q => (projection q, flag q)) (reweightedSeedPosterior seedLaw G n S D) theorem reweightedSeedFlaggedProjectionLaw_firstMarginal {K U Z : Type*} [Fintype K] [Fintype U] [Fintype Z] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → U) (flag : K × ExactOutcome X Y A B n → Z) : jointFirstMarginal (reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection flag) = groupedMass projection (reweightedSeedPosterior seedLaw G n S D) := by rw [← groupedMass_first] unfold reweightedSeedFlaggedProjectionLaw rw [groupedMass_comp] rfl theorem reweightedSeed_flagged_projection_relativeEntropy_le {K U Z : Type*} [Fintype K] [Fintype U] [Fintype Z] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (flag_positive : 0 < Fintype.card Z) (projection : K × ExactOutcome X Y A B n → U) (flag : K × ExactOutcome X Y A B n → Z) : finiteRelativeEntropy (reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection flag) (uniformFlagReference (Z := Z) (groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight)) ≤ postselectionLogCost G n S D + Real.log (Fintype.card Z : ℝ) := by let law := reweightedSeedPriorEventLaw seedLaw G n S let event := reweightedSeedWinEvent (K := K) G n D let posterior := reweightedSeedPosterior seedLaw G n S D let joint := reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection flag let projectedPrior := groupedMass projection law.weight have hevent : 0 < law.eventMass event := by change 0 < (reweightedSeedPriorEventLaw seedLaw G n S).eventMass (reweightedSeedWinEvent (K := K) G n D) rw [reweightedSeedWinEventMass] exact positive have hposterior : ∀ q, 0 ≤ posterior q := conditionedEventDistribution_nonneg law event hevent have hjoint : ∀ t, 0 ≤ joint t := groupedMass_nonneg (fun q => (projection q, flag q)) posterior hposterior have hprojectedPrior : ∀ u, 0 ≤ projectedPrior u := groupedMass_nonneg projection law.weight law.weight_nonneg have hjointnorm : (∑ t, joint t) = 1 := by change (∑ t, groupedMass (fun q => (projection q, flag q)) (conditionedEventDistribution law event) t) = 1 rw [groupedMass_sum] exact conditionedEventDistribution_sum law event hevent have hpriornorm : (∑ u, projectedPrior u) = 1 := by change (∑ u, groupedMass projection law.weight u) = 1 rw [groupedMass_sum] exact law.weight_sum have hac : ∀ u, projectedPrior u = 0 → jointFirstMarginal joint u = 0 := by intro u hzero change jointFirstMarginal (reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection flag) u = 0 rw [reweightedSeedFlaggedProjectionLaw_firstMarginal] exact groupedMass_absolute_continuity projection (conditionedEventDistribution law event) law.weight law.weight_nonneg (conditionedEventDistribution_absolute_continuity law event) u hzero calc finiteRelativeEntropy (reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection flag) (uniformFlagReference (Z := Z) (groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight)) ≤ finiteRelativeEntropy (jointFirstMarginal joint) projectedPrior + Real.log (Fintype.card Z : ℝ) := uniformFlagRelativeEntropy_le joint projectedPrior hjoint hprojectedPrior hjointnorm hpriornorm hac flag_positive _ = finiteRelativeEntropy (groupedMass projection (reweightedSeedPosterior seedLaw G n S D)) (groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight) + Real.log (Fintype.card Z : ℝ) := by rw [reweightedSeedFlaggedProjectionLaw_firstMarginal] _ ≤ postselectionLogCost G n S D + Real.log (Fintype.card Z : ℝ) := by gcongr exact reweightedSeedProjection_relativeEntropy_le seedLaw G n S D positive projection theorem reweightedSeed_source_equation_twenty_five {K U : Type*} [Fintype K] [Fintype U] (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → U) : finiteRelativeEntropy (reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection (fun q => repeatedConditionedAnswerFlag G n S D q.2)) (uniformFlagReference (Z := ConditionedAnswerFlag A B D) (groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight)) ≤ postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D := by have h := reweightedSeed_flagged_projection_relativeEntropy_le seedLaw G n S D positive (conditionedAnswerFlag_card_pos G n S D positive) projection (fun q => repeatedConditionedAnswerFlag G n S D q.2) rw [conditionedAnswerFlag_log_card G n S D positive] at h exact h def reweightedSeedPrefixJoint {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) : ((Ω × ConditionedAnswerFlag A B D) × (Fin h → V)) → ℝ := fun t => reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection (fun q => repeatedConditionedAnswerFlag G n S D q.2) ((exactSourcePrefixFlagEquiv (Ω := Ω) (V := V) (Z := ConditionedAnswerFlag A B D)).symm t) def reweightedSeedPrefixPrior {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) : ((Ω × ConditionedAnswerFlag A B D) × (Fin h → V)) → ℝ := fun t => uniformFlagReference (Z := ConditionedAnswerFlag A B D) (groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight) ((exactSourcePrefixFlagEquiv (Ω := Ω) (V := V) (Z := ConditionedAnswerFlag A B D)).symm t) theorem reweightedSeedPrefixJoint_nonneg {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (t : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V)) : 0 ≤ reweightedSeedPrefixJoint seedLaw G n S D projection t := by unfold reweightedSeedPrefixJoint reweightedSeedFlaggedProjectionLaw groupedMass apply Finset.sum_nonneg intro q _ unfold reweightedSeedPosterior apply conditionedEventDistribution_nonneg rw [reweightedSeedWinEventMass] exact positive theorem reweightedSeedPrefixPrior_nonneg {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (t : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V)) : 0 ≤ reweightedSeedPrefixPrior seedLaw G n S D projection t := by unfold reweightedSeedPrefixPrior apply uniformFlagReference_nonneg · exact groupedMass_nonneg projection (reweightedSeedPriorEventLaw seedLaw G n S).weight (reweightedSeedPriorEventLaw seedLaw G n S).weight_nonneg · exact conditionedAnswerFlag_card_pos G n S D positive def reweightedSeedPrefixEntropyIncrement {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (default : V) (k : Fin h) : ℝ := finitePrefixRelativeEntropy (reweightedSeedPrefixJoint seedLaw G n S D projection) (reweightedSeedPrefixPrior seedLaw G n S D projection) default k.succ - finitePrefixRelativeEntropy (reweightedSeedPrefixJoint seedLaw G n S D projection) (reweightedSeedPrefixPrior seedLaw G n S D projection) default k.castSucc theorem reweightedSeed_source_equation_twenty_six {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (default : V) : (∑ k : Fin h, reweightedSeedPrefixEntropyIncrement seedLaw G n S D projection default k) ≤ postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D := by let e := exactSourcePrefixFlagEquiv (Ω := Ω) (V := V) (h := h) (Z := ConditionedAnswerFlag A B D) let joint := reweightedSeedPrefixJoint seedLaw G n S D projection let prior := reweightedSeedPrefixPrior seedLaw G n S D projection calc (∑ k : Fin h, reweightedSeedPrefixEntropyIncrement seedLaw G n S D projection default k) ≤ finiteRelativeEntropy joint prior := by exact finitePrefixRelativeEntropy_budget joint prior (reweightedSeedPrefixJoint_nonneg seedLaw G n S D positive projection) (reweightedSeedPrefixPrior_nonneg seedLaw G n S D positive projection) default _ = finiteRelativeEntropy (reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection (fun q => repeatedConditionedAnswerFlag G n S D q.2)) (uniformFlagReference (Z := ConditionedAnswerFlag A B D) (groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight)) := by exact exactFiniteRelativeEntropy_equiv e (reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection (fun q => repeatedConditionedAnswerFlag G n S D q.2)) (uniformFlagReference (Z := ConditionedAnswerFlag A B D) (groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight)) _ ≤ postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D := by convert reweightedSeed_source_equation_twenty_five seedLaw G n S D positive projection using 1 congr 1 congr 1 exact exactGroupedMass_decidableEq_irrel _ _ projection (reweightedSeedPriorEventLaw seedLaw G n S).weight end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem reweightedSeedPrefixJoint_sum {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) : (∑ t, reweightedSeedPrefixJoint seedLaw G n S D projection t) = 1 := by let e := exactSourcePrefixFlagEquiv (Ω := Ω) (V := V) (h := h) (Z := ConditionedAnswerFlag A B D) let law := reweightedSeedPriorEventLaw seedLaw G n S let event := reweightedSeedWinEvent (K := K) G n D have hevent : 0 < law.eventMass event := by change 0 < (reweightedSeedPriorEventLaw seedLaw G n S).eventMass (reweightedSeedWinEvent (K := K) G n D) rw [reweightedSeedWinEventMass] exact positive change (∑ t, reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection (fun q => repeatedConditionedAnswerFlag G n S D q.2) (e.symm t)) = 1 rw [e.symm.sum_comp] unfold reweightedSeedFlaggedProjectionLaw convert (groupedMass_sum (fun q : K × ExactOutcome X Y A B n => (projection q, repeatedConditionedAnswerFlag G n S D q.2)) (conditionedEventDistribution law event)).trans (conditionedEventDistribution_sum law event hevent) using 1 apply Finset.sum_congr (by ext; simp) intro t _ exact congrFun (exactGroupedMass_decidableEq_irrel _ _ (fun q : K × ExactOutcome X Y A B n => (projection q, repeatedConditionedAnswerFlag G n S D q.2)) (conditionedEventDistribution law event)) t theorem reweightedSeedPrefixPrior_sum {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) : (∑ t, reweightedSeedPrefixPrior seedLaw G n S D projection t) = 1 := by let e := exactSourcePrefixFlagEquiv (Ω := Ω) (V := V) (h := h) (Z := ConditionedAnswerFlag A B D) let law := reweightedSeedPriorEventLaw seedLaw G n S change (∑ t, uniformFlagReference (Z := ConditionedAnswerFlag A B D) (groupedMass projection law.weight) (e.symm t)) = 1 rw [e.symm.sum_comp] apply uniformFlagReference_sum · rw [groupedMass_sum] exact law.weight_sum · exact conditionedAnswerFlag_card_pos G n S D positive theorem reweightedSeedPrefix_absolute_continuity {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (t : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V)) : reweightedSeedPrefixPrior seedLaw G n S D projection t = 0 → reweightedSeedPrefixJoint seedLaw G n S D projection t = 0 := by let e := exactSourcePrefixFlagEquiv (Ω := Ω) (V := V) (h := h) (Z := ConditionedAnswerFlag A B D) let law := reweightedSeedPriorEventLaw seedLaw G n S let event := reweightedSeedWinEvent (K := K) G n D have hevent : 0 < law.eventMass event := by change 0 < (reweightedSeedPriorEventLaw seedLaw G n S).eventMass (reweightedSeedWinEvent (K := K) G n D) rw [reweightedSeedWinEventMass] exact positive change uniformFlagReference (Z := ConditionedAnswerFlag A B D) (groupedMass projection law.weight) (e.symm t) = 0 → reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection (fun q => repeatedConditionedAnswerFlag G n S D q.2) (e.symm t) = 0 apply uniformFlagReference_absolute_continuity (reweightedSeedFlaggedProjectionLaw seedLaw G n S D projection (fun q => repeatedConditionedAnswerFlag G n S D q.2)) (groupedMass projection law.weight) · intro a unfold reweightedSeedFlaggedProjectionLaw groupedMass apply Finset.sum_nonneg intro q _ exact conditionedEventDistribution_nonneg law event hevent q · intro u hzero rw [reweightedSeedFlaggedProjectionLaw_firstMarginal] convert groupedMass_absolute_continuity projection (conditionedEventDistribution law event) law.weight law.weight_nonneg (conditionedEventDistribution_absolute_continuity law event) u hzero using 1 exact congrFun (exactGroupedMass_decidableEq_irrel _ _ projection (conditionedEventDistribution law event)) u · exact conditionedAnswerFlag_card_pos G n S D positive theorem reweightedSeedPrefixEntropyIncrement_eq_conditional {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (default : V) (k : Fin h) : reweightedSeedPrefixEntropyIncrement seedLaw G n S D projection default k = ∑ context : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V), groupedMass (finitePrefixMask default k.castSucc) (reweightedSeedPrefixJoint seedLaw G n S D projection) context * finiteRelativeEntropy (jointConditional (groupedMass (exactPrefixNextCode default k) (reweightedSeedPrefixJoint seedLaw G n S D projection)) context) (jointConditional (groupedMass (exactPrefixNextCode default k) (reweightedSeedPrefixPrior seedLaw G n S D projection)) context) := by change finitePrefixRelativeEntropy (reweightedSeedPrefixJoint seedLaw G n S D projection) (reweightedSeedPrefixPrior seedLaw G n S D projection) default k.succ - finitePrefixRelativeEntropy (reweightedSeedPrefixJoint seedLaw G n S D projection) (reweightedSeedPrefixPrior seedLaw G n S D projection) default k.castSucc = _ convert exactPrefixEntropyIncrement_eq_conditional (reweightedSeedPrefixJoint seedLaw G n S D projection) (reweightedSeedPrefixPrior seedLaw G n S D projection) (reweightedSeedPrefixJoint_nonneg seedLaw G n S D positive projection) (reweightedSeedPrefixPrior_nonneg seedLaw G n S D positive projection) (reweightedSeedPrefix_absolute_continuity seedLaw G n S D positive projection) (reweightedSeedPrefixJoint_sum seedLaw G n S D positive projection) (reweightedSeedPrefixPrior_sum seedLaw G n S D positive projection) default k using 1 apply Finset.sum_congr rfl intro context _ congr 1 · exact congrFun (exactGroupedMass_decidableEq_irrel _ _ (finitePrefixMask default k.castSucc) (reweightedSeedPrefixJoint seedLaw G n S D projection)) context · congr 1 · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ (exactPrefixNextCode default k) (reweightedSeedPrefixJoint seedLaw G n S D projection) · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ (exactPrefixNextCode default k) (reweightedSeedPrefixPrior seedLaw G n S D projection) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem exactReverseAliceConditionalSeedLaw_weight_cancel {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (side : Finset M) (seed : ExactForwardSeed M) : reversePartitionWeight side * (exactReverseAliceConditionalSeedLaw nonempty side).weight seed = if exactReverseLeftSide seed = side then exactSeedWeight seed else 0 := by by_cases hside : side.Nonempty · rw [exactReverseAliceConditionalSeedLaw_weight nonempty side hside seed] exact exactReverseAliceConditionalSeedWeight_cancel nonempty side seed · have hempty : side = ∅ := Finset.not_nonempty_iff_eq_empty.mp hside subst side simp [exactReverseAliceConditionalSeedLaw, exactReverseLeftSide] theorem exactReverseBobConditionalSeedLaw_weight_cancel {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (side : Finset M) (seed : ExactForwardSeed M) : reversePartitionWeight side * (exactReverseBobConditionalSeedLaw nonempty side).weight seed = if exactReverseRightSide seed = side then exactSeedWeight seed else 0 := by by_cases hside : side.Nonempty · rw [exactReverseBobConditionalSeedLaw_weight nonempty side hside seed] exact exactReverseBobConditionalSeedWeight_cancel nonempty side seed · have hempty : side = ∅ := Finset.not_nonempty_iff_eq_empty.mp hside subst side simp [exactReverseBobConditionalSeedLaw, exactReverseRightSide] def exactReverseSideContextWeight {M : Type*} [Fintype M] [DecidableEq M] {side : Finset M} (context : ExactReverseSideContext M side) : ℝ := (1 / (2 : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ side}) : ℝ)) * (1 / (Fintype.card (Equiv.Perm {j : M // j ∈ context.otherSide}) : ℝ)) * (1 / (context.otherSide.card + 1 : ℝ)) theorem exactReverseAliceConditionalSeedWeight_eq_context_div_card {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (seed : ExactForwardSeed M) : exactReverseAliceConditionalSeedWeight (exactReverseLeftSide seed) seed = exactReverseSideContextWeight (exactReverseAliceContext seed) / ((exactReverseLeftSide seed).card : ℝ) := by have hside : 0 < reversePartitionWeight (exactReverseLeftSide seed) := (reversePartitionWeight_pos_iff nonempty (exactReverseLeftSide seed)).mpr ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ unfold exactReverseAliceConditionalSeedWeight rw [if_pos rfl] rw [← exactReverseLeftSeedWeight_eq_forward seed] unfold exactReverseLeftSeedWeight exactReverseSideContextWeight exactReverseAliceContext reverseMarkedPartitionWeight rw [if_pos (exactReverseLeftSide_coordinate_mem seed)] field_simp [hside.ne'] theorem exactReverseBobConditionalSeedWeight_eq_context_div_card {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (seed : ExactForwardSeed M) : exactReverseBobConditionalSeedWeight (exactReverseRightSide seed) seed = exactReverseSideContextWeight (exactReverseBobContext seed) / ((exactReverseRightSide seed).card : ℝ) := by have hside : 0 < reversePartitionWeight (exactReverseRightSide seed) := (reversePartitionWeight_pos_iff nonempty (exactReverseRightSide seed)).mpr ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ unfold exactReverseBobConditionalSeedWeight rw [if_pos rfl] rw [← exactReverseRightSeedWeight_eq_forward seed] unfold exactReverseRightSeedWeight exactReverseSideContextWeight exactReverseBobContext reverseMarkedPartitionWeight rw [if_pos (exactReverseRightSide_coordinate_mem seed)] field_simp [hside.ne'] variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def exactReverseAliceMarkerCode {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card := ⟨exactReverseLeftSide seed, exactReverseAliceContext seed, (exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩⟩ def exactReverseBobMarkerCode {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card := ⟨exactReverseRightSide seed, exactReverseBobContext seed, (exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩⟩ @[simp] theorem exactReverseAliceMarkerCode_coordinate {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : (((exactReverseAliceMarkerCode seed).2.1.sideRank).symm (exactReverseAliceMarkerCode seed).2.2).val = seed.coordinate := by simp [exactReverseAliceMarkerCode] @[simp] theorem exactReverseBobMarkerCode_coordinate {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : (((exactReverseBobMarkerCode seed).2.1.sideRank).symm (exactReverseBobMarkerCode seed).2.2).val = seed.coordinate := by simp [exactReverseBobMarkerCode] theorem exactReverseAliceMarkerCode_coordinate_injective {M : Type*} [Fintype M] [DecidableEq M] {a b : ExactForwardSeed M} (same : exactReverseAliceMarkerCode a = exactReverseAliceMarkerCode b) : a.coordinate = b.coordinate := by have h := congrArg (fun t : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card => (t.2.1.sideRank.symm t.2.2).val) same simpa only [exactReverseAliceMarkerCode_coordinate] using h theorem exactReverseBobMarkerCode_coordinate_injective {M : Type*} [Fintype M] [DecidableEq M] {a b : ExactForwardSeed M} (same : exactReverseBobMarkerCode a = exactReverseBobMarkerCode b) : a.coordinate = b.coordinate := by have h := congrArg (fun t : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card => (t.2.1.sideRank.symm t.2.2).val) same simpa only [exactReverseBobMarkerCode_coordinate] using h theorem exactReverseAliceMarkerCode_partition_injective {M : Type*} [Fintype M] [DecidableEq M] {a b : ExactForwardSeed M} (same : exactReverseAliceMarkerCode a = exactReverseAliceMarkerCode b) : a.partition = b.partition := by have hcoordinate := exactReverseAliceMarkerCode_coordinate_injective same have hside : exactReverseLeftSide a = exactReverseLeftSide b := congrArg Sigma.fst same have hbit : a.partition a.coordinate = b.partition b.coordinate := by have h := congrArg (fun t : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card => t.2.1.ignoredBit) same exact h funext j by_cases hj : j = a.coordinate · subst j simpa [hcoordinate] using hbit · have hbj : j ≠ b.coordinate := by simpa [hcoordinate] using hj have hm : (a.partition j = false) ↔ (b.partition j = false) := by have := Finset.ext_iff.mp hside j simpa [exactReverseLeftSide, exactLeft, hj, hbj] using this cases ha : a.partition j <;> cases hb : b.partition j <;> simp_all theorem exactReverseBobMarkerCode_partition_injective {M : Type*} [Fintype M] [DecidableEq M] {a b : ExactForwardSeed M} (same : exactReverseBobMarkerCode a = exactReverseBobMarkerCode b) : a.partition = b.partition := by have hcoordinate := exactReverseBobMarkerCode_coordinate_injective same have hside : exactReverseRightSide a = exactReverseRightSide b := congrArg Sigma.fst same have hbit : a.partition a.coordinate = b.partition b.coordinate := by have h := congrArg (fun t : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card => t.2.1.ignoredBit) same exact h funext j by_cases hj : j = a.coordinate · subst j simpa [hcoordinate] using hbit · have hbj : j ≠ b.coordinate := by simpa [hcoordinate] using hj have hm : (a.partition j = true) ↔ (b.partition j = true) := by have := Finset.ext_iff.mp hside j simpa [exactReverseRightSide, exactRight, hj, hbj] using this cases ha : a.partition j <;> cases hb : b.partition j <;> simp_all theorem exactReverseAliceMarkerCode_injective {M : Type*} [Fintype M] [DecidableEq M] : Function.Injective (exactReverseAliceMarkerCode (M := M)) := by intro a b same have hcoordinate := exactReverseAliceMarkerCode_coordinate_injective same have hpartition := exactReverseAliceMarkerCode_partition_injective same rcases a with ⟨i, p, l, r, lc, rc⟩ rcases b with ⟨j, q, l', r', lc', rc'⟩ dsimp at hcoordinate hpartition subst j subst q simp only [exactReverseAliceMarkerCode, Sigma.mk.inj_iff] at same have hpair := eq_of_heq same.2 have hctx := congrArg Prod.fst hpair have hmarked := congrArg Prod.snd hpair have hleftCut : lc = lc' := by apply Fin.ext have hv := congrArg Fin.val hmarked exact (exactReverseAliceContext_marked_rank ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M)).symm.trans (hv.trans (exactReverseAliceContext_marked_rank ({ coordinate := i, partition := p, leftOrder := l', rightOrder := r', leftCut := lc', rightCut := rc' } : ExactForwardSeed M))) have hrightCut : rc = rc' := by apply Fin.ext have hv := congrArg (fun c : ExactReverseSideContext M (exactReverseLeftSide ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M)) => c.otherCut.val) hctx exact hv subst lc' subst rc' change exactReverseAliceContext ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) = exactReverseAliceContext ({ coordinate := i, partition := p, leftOrder := l', rightOrder := r', leftCut := lc, rightCut := rc } : ExactForwardSeed M) at hctx have hsideRank := congrArg (fun c : ExactReverseSideContext M (exactReverseLeftSide ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M)) => c.sideRank) hctx have hotherRankSigma := congrArg (fun c : ExactReverseSideContext M (exactReverseLeftSide ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M)) => (⟨c.otherSide, c.otherRank⟩ : Σ other : Finset M, ({j : M // j ∈ other} ≃ Fin other.card))) hctx simp only [exactReverseAliceContext, Sigma.mk.inj_iff] at hotherRankSigma have hotherRank := eq_of_heq hotherRankSigma.2 have hrightSymm : r.symm = r'.symm := by have h := congrArg (fun e : ({j : M // j ∈ exactRight i p} ≃ Fin (exactRight i p).card) => e.trans (Finset.equivFin (exactRight i p)).symm) hotherRank simpa [exactRightRank, Equiv.trans_assoc] using h have hright : r = r' := Equiv.symm_bijective.injective hrightSymm subst r' have hreverseLeftRank : exactReverseLeftRank ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) = exactReverseLeftRank ({ coordinate := i, partition := p, leftOrder := l', rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) := by apply Equiv.ext intro j apply Fin.ext have hsideVal (seed : ExactForwardSeed M) (k : {k : M // k ∈ exactReverseLeftSide seed}) : ((exactReverseAliceContext seed).sideRank k).val = (exactReverseLeftRank seed k).val := by simp only [exactReverseAliceContext, Equiv.trans_apply, finCongr_apply, Fin.val_cast] have h := congrArg (fun e => (e j).val) hsideRank exact (hsideVal ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) j).symm.trans (h.trans (hsideVal ({ coordinate := i, partition := p, leftOrder := l', rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) j)) have hleftRank : exactLeftRank ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) = exactLeftRank ({ coordinate := i, partition := p, leftOrder := l', rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) := by apply Equiv.ext intro j let j' : {j : M // j ∈ exactLeft i p} := ⟨j.val, j.property⟩ have h := congrArg (fun e => e ⟨j.val, Finset.mem_insert_of_mem j.property⟩) hreverseLeftRank apply Fin.succAbove_right_injective exact (exactReverseLeftRank_old ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) j).symm.trans (h.trans (exactReverseLeftRank_old ({ coordinate := i, partition := p, leftOrder := l', rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) j')) have hleftSymm : l.symm = l'.symm := by have h := congrArg (fun e : ({j : M // j ∈ exactLeft i p} ≃ Fin (exactLeft i p).card) => e.trans (Finset.equivFin (exactLeft i p)).symm) hleftRank simpa [exactLeftRank, Equiv.trans_assoc] using h have hleft : l = l' := Equiv.symm_bijective.injective hleftSymm subst l' rfl end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem exactReverseBobMarkerCode_injective {M : Type*} [Fintype M] [DecidableEq M] : Function.Injective (exactReverseBobMarkerCode (M := M)) := by intro a b same have hcoordinate := exactReverseBobMarkerCode_coordinate_injective same have hpartition := exactReverseBobMarkerCode_partition_injective same rcases a with ⟨i, p, l, r, lc, rc⟩ rcases b with ⟨j, q, l', r', lc', rc'⟩ dsimp at hcoordinate hpartition subst j subst q simp only [exactReverseBobMarkerCode, Sigma.mk.inj_iff] at same have hpair := eq_of_heq same.2 have hctx := congrArg Prod.fst hpair have hmarked := congrArg Prod.snd hpair have hrightCut : rc = rc' := by apply Fin.ext have hv := congrArg Fin.val hmarked exact (exactReverseBobContext_marked_rank ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M)).symm.trans (hv.trans (exactReverseBobContext_marked_rank ({ coordinate := i, partition := p, leftOrder := l', rightOrder := r', leftCut := lc', rightCut := rc' } : ExactForwardSeed M))) have hleftCut : lc = lc' := by apply Fin.ext have hv := congrArg (fun c : ExactReverseSideContext M (exactReverseRightSide ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M)) => c.otherCut.val) hctx exact hv subst rc' subst lc' change exactReverseBobContext ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) = exactReverseBobContext ({ coordinate := i, partition := p, leftOrder := l', rightOrder := r', leftCut := lc, rightCut := rc } : ExactForwardSeed M) at hctx have hsideRank := congrArg (fun c : ExactReverseSideContext M (exactReverseRightSide ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M)) => c.sideRank) hctx have hotherRankSigma := congrArg (fun c : ExactReverseSideContext M (exactReverseRightSide ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M)) => (⟨c.otherSide, c.otherRank⟩ : Σ other : Finset M, ({j : M // j ∈ other} ≃ Fin other.card))) hctx simp only [exactReverseBobContext, Sigma.mk.inj_iff] at hotherRankSigma have hotherRank := eq_of_heq hotherRankSigma.2 have hleftSymm : l.symm = l'.symm := by have h := congrArg (fun e : ({j : M // j ∈ exactLeft i p} ≃ Fin (exactLeft i p).card) => e.trans (Finset.equivFin (exactLeft i p)).symm) hotherRank simpa [exactLeftRank, Equiv.trans_assoc] using h have hleft : l = l' := Equiv.symm_bijective.injective hleftSymm subst l' have hreverseRightRank : exactReverseRightRank ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) = exactReverseRightRank ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r', leftCut := lc, rightCut := rc } : ExactForwardSeed M) := by apply Equiv.ext intro j apply Fin.ext have hsideVal (seed : ExactForwardSeed M) (k : {k : M // k ∈ exactReverseRightSide seed}) : ((exactReverseBobContext seed).sideRank k).val = (exactReverseRightRank seed k).val := by simp only [exactReverseBobContext, Equiv.trans_apply, finCongr_apply, Fin.val_cast] have h := congrArg (fun e => (e j).val) hsideRank exact (hsideVal ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) j).symm.trans (h.trans (hsideVal ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r', leftCut := lc, rightCut := rc } : ExactForwardSeed M) j)) have hrightRank : exactRightRank ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) = exactRightRank ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r', leftCut := lc, rightCut := rc } : ExactForwardSeed M) := by apply Equiv.ext intro j let j' : {j : M // j ∈ exactRight i p} := ⟨j.val, j.property⟩ have h := congrArg (fun e => e ⟨j.val, Finset.mem_insert_of_mem j.property⟩) hreverseRightRank apply Fin.succAbove_right_injective exact (exactReverseRightRank_old ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r, leftCut := lc, rightCut := rc } : ExactForwardSeed M) j).symm.trans (h.trans (exactReverseRightRank_old ({ coordinate := i, partition := p, leftOrder := l, rightOrder := r', leftCut := lc, rightCut := rc } : ExactForwardSeed M) j')) have hrightSymm : r.symm = r'.symm := by have h := congrArg (fun e : ({j : M // j ∈ exactRight i p} ≃ Fin (exactRight i p).card) => e.trans (Finset.equivFin (exactRight i p)).symm) hrightRank simpa [exactRightRank, Equiv.trans_assoc] using h have hright : r = r' := Equiv.symm_bijective.injective hrightSymm subst r' rfl end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def exactInsertedOldSubtypeEquiv {M : Type*} [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) : {j : M // j ∈ side} ≃ {j : {j : M // j ∈ insert i side} // j.val ≠ i} where toFun j := ⟨⟨j.val, Finset.mem_insert_of_mem j.property⟩, fun same => not_mem (same ▸ j.property)⟩ invFun j := ⟨j.val.val, (Finset.mem_insert.mp j.val.property).resolve_left j.property⟩ left_inv j := by apply Subtype.ext rfl right_inv j := by apply Subtype.ext apply Subtype.ext rfl def exactDeleteMarkedRank {M : Type*} [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) (rank : {j : M // j ∈ insert i side} ≃ Fin (side.card + 1)) (cut : Fin (side.card + 1)) (marked : rank ⟨i, Finset.mem_insert_self i side⟩ = cut) : {j : M // j ∈ side} ≃ Fin side.card := (exactInsertedOldSubtypeEquiv i side not_mem).trans ((rank.subtypeEquiv (p := fun j => j.val ≠ i) (q := fun k => k ≠ cut) (by intro j constructor · intro distinct same apply distinct have hrank : rank j = rank ⟨i, Finset.mem_insert_self i side⟩ := by rw [marked] exact same exact congrArg Subtype.val (rank.injective hrank) · intro distinct same apply distinct have hj : j = ⟨i, Finset.mem_insert_self i side⟩ := Subtype.ext same rw [hj, marked])).trans (finSuccAboveEquiv cut).symm) theorem exactInsertedRank_deleteMarked {M : Type*} [DecidableEq M] (i : M) (side : Finset M) (not_mem : i ∉ side) (rank : {j : M // j ∈ insert i side} ≃ Fin (side.card + 1)) (cut : Fin (side.card + 1)) (marked : rank ⟨i, Finset.mem_insert_self i side⟩ = cut) : exactInsertedRank i side not_mem (exactDeleteMarkedRank i side not_mem rank cut marked) cut = rank := by apply Equiv.ext intro j by_cases is_marker : j.val = i · have hj : j = ⟨i, Finset.mem_insert_self i side⟩ := Subtype.ext is_marker rw [hj, exactInsertedRank_marker, marked] · have old_member : j.val ∈ side := (Finset.mem_insert.mp j.property).resolve_left is_marker let old : {j : M // j ∈ side} := ⟨j.val, old_member⟩ have hj : (⟨old.val, Finset.mem_insert_of_mem old.property⟩ : {j : M // j ∈ insert i side}) = j := by apply Subtype.ext rfl rw [← hj, exactInsertedRank_old] have distinct : rank ⟨old.val, Finset.mem_insert_of_mem old.property⟩ ≠ cut := by intro same apply is_marker have hrank : rank ⟨old.val, Finset.mem_insert_of_mem old.property⟩ = rank ⟨i, Finset.mem_insert_self i side⟩ := by rw [marked] exact same exact congrArg Subtype.val (rank.injective hrank) let deleted : {k : Fin (side.card + 1) // k ≠ cut} := ⟨rank ⟨old.val, Finset.mem_insert_of_mem old.property⟩, distinct⟩ have hdelete : exactDeleteMarkedRank i side not_mem rank cut marked old = (finSuccAboveEquiv cut).symm deleted := by rfl rw [hdelete] have h := (finSuccAboveEquiv cut).apply_symm_apply deleted exact congrArg Subtype.val h end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 4200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def exactPermutationOfSideRank {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (rank : {j : M // j ∈ side} ≃ Fin side.card) : Equiv.Perm {j : M // j ∈ side} := (rank.trans (Finset.equivFin side).symm).symm theorem exactPermutationOfSideRank_rank {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (rank : {j : M // j ∈ side} ≃ Fin side.card) : (exactPermutationOfSideRank side rank).symm.trans (Finset.equivFin side) = rank := by apply Equiv.ext intro j simp [exactPermutationOfSideRank, Equiv.trans_apply] theorem exactReverseAliceCanonicalPartition_otherSide {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) (ignored : Bool) : exactRight coordinate (exactReverseAliceCanonicalPartition side coordinate ignored) = Finset.univ \ side := by ext j by_cases marked : j = coordinate · subst j simp [exactRight, member] · by_cases belongs : j ∈ side <;> simp [exactRight, exactReverseAliceCanonicalPartition, marked, belongs] theorem exactReverseBobCanonicalPartition_otherSide {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) (ignored : Bool) : exactLeft coordinate (exactReverseBobCanonicalPartition side coordinate ignored) = Finset.univ \ side := by ext j by_cases marked : j = coordinate · subst j simp [exactLeft, member] · by_cases belongs : j ∈ side <;> simp [exactLeft, exactReverseBobCanonicalPartition, marked, belongs] theorem exactReverseAliceCanonicalPartition_card {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) (ignored : Bool) : (exactLeft coordinate (exactReverseAliceCanonicalPartition side coordinate ignored)).card + 1 = side.card := by have h := congrArg Finset.card (exactReverseAliceCanonicalPartition_side side coordinate member ignored) simpa [exactLeft_coordinate_not_mem] using h theorem exactReverseBobCanonicalPartition_card {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (coordinate : M) (member : coordinate ∈ side) (ignored : Bool) : (exactRight coordinate (exactReverseBobCanonicalPartition side coordinate ignored)).card + 1 = side.card := by have h := congrArg Finset.card (exactReverseBobCanonicalPartition_side side coordinate member ignored) simpa [exactRight_coordinate_not_mem] using h def exactReverseAliceMarkerDecode {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : ExactForwardSeed M := by classical let coordinate : M := (context.sideRank.symm marker).val have member : coordinate ∈ side := (context.sideRank.symm marker).property let partition : M → Bool := exactReverseAliceCanonicalPartition side coordinate context.ignoredBit have hside : insert coordinate (exactLeft coordinate partition) = side := exactReverseAliceCanonicalPartition_side side coordinate member context.ignoredBit have hcard : (exactLeft coordinate partition).card + 1 = side.card := exactReverseAliceCanonicalPartition_card side coordinate member context.ignoredBit let transportedSide : {j : M // j ∈ insert coordinate (exactLeft coordinate partition)} ≃ {j : M // j ∈ side} := Equiv.subtypeEquivRight (fun j => by rw [hside]) let insertedRank : {j : M // j ∈ insert coordinate (exactLeft coordinate partition)} ≃ Fin ((exactLeft coordinate partition).card + 1) := transportedSide.trans (context.sideRank.trans (finCongr hcard.symm)) let leftCut : Fin ((exactLeft coordinate partition).card + 1) := (finCongr hcard.symm) marker have marked : insertedRank ⟨coordinate, Finset.mem_insert_self coordinate (exactLeft coordinate partition)⟩ = leftCut := by have transported : transportedSide ⟨coordinate, Finset.mem_insert_self coordinate (exactLeft coordinate partition)⟩ = context.sideRank.symm marker := by apply Subtype.ext rfl change (finCongr hcard.symm) (context.sideRank (transportedSide ⟨coordinate, Finset.mem_insert_self coordinate (exactLeft coordinate partition)⟩)) = (finCongr hcard.symm) marker rw [transported, Equiv.apply_symm_apply] let leftRank : {j : M // j ∈ exactLeft coordinate partition} ≃ Fin (exactLeft coordinate partition).card := exactDeleteMarkedRank coordinate (exactLeft coordinate partition) (exactLeft_coordinate_not_mem coordinate partition) insertedRank leftCut marked have hother : exactRight coordinate partition = context.otherSide := by calc exactRight coordinate partition = Finset.univ \ side := exactReverseAliceCanonicalPartition_otherSide side coordinate member context.ignoredBit _ = context.otherSide := context.otherSide_eq_complement.symm let transportedOther : {j : M // j ∈ exactRight coordinate partition} ≃ {j : M // j ∈ context.otherSide} := Equiv.subtypeEquivRight (fun j => by rw [hother]) let rightRank : {j : M // j ∈ exactRight coordinate partition} ≃ Fin (exactRight coordinate partition).card := transportedOther.trans (context.otherRank.trans (finCongr (congrArg Finset.card hother).symm)) exact { coordinate := coordinate partition := partition leftOrder := exactPermutationOfSideRank (exactLeft coordinate partition) leftRank rightOrder := exactPermutationOfSideRank (exactRight coordinate partition) rightRank leftCut := leftCut rightCut := (finCongr (congrArg (fun s : Finset M => s.card + 1) hother).symm) context.otherCut } def exactReverseBobMarkerDecode {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : ExactForwardSeed M := by classical let coordinate : M := (context.sideRank.symm marker).val have member : coordinate ∈ side := (context.sideRank.symm marker).property let partition : M → Bool := exactReverseBobCanonicalPartition side coordinate context.ignoredBit have hside : insert coordinate (exactRight coordinate partition) = side := exactReverseBobCanonicalPartition_side side coordinate member context.ignoredBit have hcard : (exactRight coordinate partition).card + 1 = side.card := exactReverseBobCanonicalPartition_card side coordinate member context.ignoredBit let transportedSide : {j : M // j ∈ insert coordinate (exactRight coordinate partition)} ≃ {j : M // j ∈ side} := Equiv.subtypeEquivRight (fun j => by rw [hside]) let insertedRank : {j : M // j ∈ insert coordinate (exactRight coordinate partition)} ≃ Fin ((exactRight coordinate partition).card + 1) := transportedSide.trans (context.sideRank.trans (finCongr hcard.symm)) let rightCut : Fin ((exactRight coordinate partition).card + 1) := (finCongr hcard.symm) marker have marked : insertedRank ⟨coordinate, Finset.mem_insert_self coordinate (exactRight coordinate partition)⟩ = rightCut := by have transported : transportedSide ⟨coordinate, Finset.mem_insert_self coordinate (exactRight coordinate partition)⟩ = context.sideRank.symm marker := by apply Subtype.ext rfl change (finCongr hcard.symm) (context.sideRank (transportedSide ⟨coordinate, Finset.mem_insert_self coordinate (exactRight coordinate partition)⟩)) = (finCongr hcard.symm) marker rw [transported, Equiv.apply_symm_apply] let rightRank : {j : M // j ∈ exactRight coordinate partition} ≃ Fin (exactRight coordinate partition).card := exactDeleteMarkedRank coordinate (exactRight coordinate partition) (exactRight_coordinate_not_mem coordinate partition) insertedRank rightCut marked have hother : exactLeft coordinate partition = context.otherSide := by calc exactLeft coordinate partition = Finset.univ \ side := exactReverseBobCanonicalPartition_otherSide side coordinate member context.ignoredBit _ = context.otherSide := context.otherSide_eq_complement.symm let transportedOther : {j : M // j ∈ exactLeft coordinate partition} ≃ {j : M // j ∈ context.otherSide} := Equiv.subtypeEquivRight (fun j => by rw [hother]) let leftRank : {j : M // j ∈ exactLeft coordinate partition} ≃ Fin (exactLeft coordinate partition).card := transportedOther.trans (context.otherRank.trans (finCongr (congrArg Finset.card hother).symm)) exact { coordinate := coordinate partition := partition leftOrder := exactPermutationOfSideRank (exactLeft coordinate partition) leftRank rightOrder := exactPermutationOfSideRank (exactRight coordinate partition) rightRank leftCut := (finCongr (congrArg (fun s : Finset M => s.card + 1) hother).symm) context.otherCut rightCut := rightCut } end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable @[simp] theorem exactReverseAliceMarkerDecode_coordinate {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (exactReverseAliceMarkerDecode side context marker).coordinate = (context.sideRank.symm marker).val := by rfl @[simp] theorem exactReverseBobMarkerDecode_coordinate {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (exactReverseBobMarkerDecode side context marker).coordinate = (context.sideRank.symm marker).val := by rfl @[simp] theorem exactReverseAliceMarkerDecode_side {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : exactReverseLeftSide (exactReverseAliceMarkerDecode side context marker) = side := by change insert (context.sideRank.symm marker).val (exactLeft (context.sideRank.symm marker).val (exactReverseAliceCanonicalPartition side (context.sideRank.symm marker).val context.ignoredBit)) = side exact exactReverseAliceCanonicalPartition_side side (context.sideRank.symm marker).val (context.sideRank.symm marker).property context.ignoredBit @[simp] theorem exactReverseBobMarkerDecode_side {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : exactReverseRightSide (exactReverseBobMarkerDecode side context marker) = side := by change insert (context.sideRank.symm marker).val (exactRight (context.sideRank.symm marker).val (exactReverseBobCanonicalPartition side (context.sideRank.symm marker).val context.ignoredBit)) = side exact exactReverseBobCanonicalPartition_side side (context.sideRank.symm marker).val (context.sideRank.symm marker).property context.ignoredBit @[simp] theorem exactReverseAliceMarkerDecode_ignoredBit {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (exactReverseAliceMarkerDecode side context marker).partition (exactReverseAliceMarkerDecode side context marker).coordinate = context.ignoredBit := by simp [exactReverseAliceMarkerDecode, exactReverseAliceCanonicalPartition] @[simp] theorem exactReverseBobMarkerDecode_ignoredBit {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (exactReverseBobMarkerDecode side context marker).partition (exactReverseBobMarkerDecode side context marker).coordinate = context.ignoredBit := by simp [exactReverseBobMarkerDecode, exactReverseBobCanonicalPartition] theorem exactSigmaFinCutTransport {M : Type*} [DecidableEq M] (source target : Finset M) (same : source = target) (cut : Fin (target.card + 1)) : (⟨source, (finCongr (congrArg (fun side : Finset M => side.card + 1) same).symm) cut⟩ : Σ side : Finset M, Fin (side.card + 1)) = ⟨target, cut⟩ := by subst target simp theorem exactSigmaSideRankTransport {M : Type*} [DecidableEq M] (source target : Finset M) (same : source = target) (rank : {j : M // j ∈ target} ≃ Fin target.card) : (⟨source, (Equiv.subtypeEquivRight (fun j => by rw [same])).trans (rank.trans (finCongr (congrArg Finset.card same).symm))⟩ : Σ side : Finset M, ({j : M // j ∈ side} ≃ Fin side.card)) = ⟨target, rank⟩ := by subst target apply Sigma.ext · rfl · apply heq_of_eq apply Equiv.ext intro j simp [Equiv.trans_apply] apply Subtype.ext rfl theorem exactReverseAliceMarkerDecode_otherRank {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (⟨exactRight (exactReverseAliceMarkerDecode side context marker).coordinate (exactReverseAliceMarkerDecode side context marker).partition, exactRightRank (exactReverseAliceMarkerDecode side context marker)⟩ : Σ other : Finset M, ({j : M // j ∈ other} ≃ Fin other.card)) = ⟨context.otherSide, context.otherRank⟩ := by classical let coordinate := (context.sideRank.symm marker).val let partition := exactReverseAliceCanonicalPartition side coordinate context.ignoredBit have other : exactRight coordinate partition = context.otherSide := by exact (exactReverseAliceCanonicalPartition_otherSide side coordinate (context.sideRank.symm marker).property context.ignoredBit).trans context.otherSide_eq_complement.symm have transported := exactSigmaSideRankTransport (exactRight coordinate partition) context.otherSide other context.otherRank simpa only [exactReverseAliceMarkerDecode, exactRightRank, exactPermutationOfSideRank_rank] using transported theorem exactReverseAliceMarkerDecode_otherCut {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (⟨exactRight (exactReverseAliceMarkerDecode side context marker).coordinate (exactReverseAliceMarkerDecode side context marker).partition, (exactReverseAliceMarkerDecode side context marker).rightCut⟩ : Σ other : Finset M, Fin (other.card + 1)) = ⟨context.otherSide, context.otherCut⟩ := by classical let coordinate := (context.sideRank.symm marker).val let partition := exactReverseAliceCanonicalPartition side coordinate context.ignoredBit have other : exactRight coordinate partition = context.otherSide := by exact (exactReverseAliceCanonicalPartition_otherSide side coordinate (context.sideRank.symm marker).property context.ignoredBit).trans context.otherSide_eq_complement.symm have transported := exactSigmaFinCutTransport (exactRight coordinate partition) context.otherSide other context.otherCut simpa only [exactReverseAliceMarkerDecode] using transported theorem exactReverseAliceMarkerDecode_sideRank {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (⟨exactReverseLeftSide (exactReverseAliceMarkerDecode side context marker), (exactReverseAliceContext (exactReverseAliceMarkerDecode side context marker)).sideRank⟩ : Σ actualSide : Finset M, ({j : M // j ∈ actualSide} ≃ Fin actualSide.card)) = ⟨side, context.sideRank⟩ := by classical let coordinate := (context.sideRank.symm marker).val let partition := exactReverseAliceCanonicalPartition side coordinate context.ignoredBit have actual : insert coordinate (exactLeft coordinate partition) = side := exactReverseAliceCanonicalPartition_side side coordinate (context.sideRank.symm marker).property context.ignoredBit let transportedRank : {j : M // j ∈ insert coordinate (exactLeft coordinate partition)} ≃ Fin (insert coordinate (exactLeft coordinate partition)).card := (Equiv.subtypeEquivRight (fun j => by rw [actual])).trans (context.sideRank.trans (finCongr (congrArg Finset.card actual).symm)) have transported : (⟨insert coordinate (exactLeft coordinate partition), transportedRank⟩ : Σ actualSide : Finset M, ({j : M // j ∈ actualSide} ≃ Fin actualSide.card)) = ⟨side, context.sideRank⟩ := exactSigmaSideRankTransport (insert coordinate (exactLeft coordinate partition)) side actual context.sideRank calc (⟨exactReverseLeftSide (exactReverseAliceMarkerDecode side context marker), (exactReverseAliceContext (exactReverseAliceMarkerDecode side context marker)).sideRank⟩ : Σ actualSide : Finset M, ({j : M // j ∈ actualSide} ≃ Fin actualSide.card)) = ⟨insert coordinate (exactLeft coordinate partition), transportedRank⟩ := by apply Sigma.ext · change insert (context.sideRank.symm marker).val (exactLeft (context.sideRank.symm marker).val (exactReverseAliceCanonicalPartition side (context.sideRank.symm marker).val context.ignoredBit)) = insert coordinate (exactLeft coordinate partition) rfl · apply heq_of_eq apply Equiv.ext intro j apply Fin.ext simp [coordinate, partition, transportedRank, exactReverseAliceMarkerDecode, exactReverseAliceContext, exactReverseLeftSide, exactReverseLeftRank, exactLeftRank, exactPermutationOfSideRank_rank, exactInsertedRank_deleteMarked, Equiv.trans_assoc, Equiv.trans_apply, finCongr_apply, Fin.val_cast] _ = ⟨side, context.sideRank⟩ := transported theorem exactReverseAliceMarkerDecode_rightInverse {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : exactReverseAliceMarkerCode (exactReverseAliceMarkerDecode side context marker) = ⟨side, context, marker⟩ := by classical generalize decoded : exactReverseAliceMarkerDecode side context marker = seed have sameSide : exactReverseLeftSide seed = side := by rw [← decoded] exact exactReverseAliceMarkerDecode_side side context marker subst side apply Sigma.ext · rfl · apply heq_of_eq change (exactReverseAliceContext seed, (exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) = (context, marker) have sameContext : exactReverseAliceContext seed = context := by cases context with | mk otherSide sideRank otherRank otherCut ignored complement => simp only [exactReverseAliceContext, ExactReverseSideContext.mk.injEq] let reverseContext : ExactReverseSideContext M (exactReverseLeftSide seed) := { otherSide := otherSide sideRank := sideRank otherRank := otherRank otherCut := otherCut ignoredBit := ignored otherSide_eq_complement := complement } have exactSideRank := exactReverseAliceMarkerDecode_sideRank (exactReverseLeftSide seed) reverseContext marker have exactOtherRank := exactReverseAliceMarkerDecode_otherRank (exactReverseLeftSide seed) reverseContext marker have exactOtherCut := exactReverseAliceMarkerDecode_otherCut (exactReverseLeftSide seed) reverseContext marker change exactReverseAliceMarkerDecode (exactReverseLeftSide seed) reverseContext marker = seed at decoded rw [decoded] at exactSideRank exactOtherRank exactOtherCut refine ⟨(exactReverseLeftSide_complement seed).trans complement.symm, ?_, ?_, ?_, ?_⟩ · exact eq_of_heq (Sigma.mk.inj exactSideRank).2 · exact (Sigma.mk.inj exactOtherRank).2 · exact (Sigma.mk.inj exactOtherCut).2 · have exactIgnored := congrArg (fun original : ExactForwardSeed M => original.partition original.coordinate) decoded simpa only [exactReverseAliceMarkerDecode_ignoredBit] using exactIgnored.symm apply Prod.ext · exact sameContext · rw [sameContext] apply context.sideRank.symm.injective change context.sideRank.symm (context.sideRank ⟨seed.coordinate, _⟩) = context.sideRank.symm marker rw [Equiv.symm_apply_apply] apply Subtype.ext have coordinate := congrArg (fun original : ExactForwardSeed M => original.coordinate) decoded simpa only [exactReverseAliceMarkerDecode_coordinate] using coordinate.symm end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem exactReverseBobMarkerDecode_otherRank {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (⟨exactLeft (exactReverseBobMarkerDecode side context marker).coordinate (exactReverseBobMarkerDecode side context marker).partition, exactLeftRank (exactReverseBobMarkerDecode side context marker)⟩ : Σ other : Finset M, ({j : M // j ∈ other} ≃ Fin other.card)) = ⟨context.otherSide, context.otherRank⟩ := by classical let coordinate := (context.sideRank.symm marker).val let partition := exactReverseBobCanonicalPartition side coordinate context.ignoredBit have other : exactLeft coordinate partition = context.otherSide := by exact (exactReverseBobCanonicalPartition_otherSide side coordinate (context.sideRank.symm marker).property context.ignoredBit).trans context.otherSide_eq_complement.symm have transported := exactSigmaSideRankTransport (exactLeft coordinate partition) context.otherSide other context.otherRank simpa only [exactReverseBobMarkerDecode, exactLeftRank, exactPermutationOfSideRank_rank] using transported theorem exactReverseBobMarkerDecode_otherCut {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (⟨exactLeft (exactReverseBobMarkerDecode side context marker).coordinate (exactReverseBobMarkerDecode side context marker).partition, (exactReverseBobMarkerDecode side context marker).leftCut⟩ : Σ other : Finset M, Fin (other.card + 1)) = ⟨context.otherSide, context.otherCut⟩ := by classical let coordinate := (context.sideRank.symm marker).val let partition := exactReverseBobCanonicalPartition side coordinate context.ignoredBit have other : exactLeft coordinate partition = context.otherSide := by exact (exactReverseBobCanonicalPartition_otherSide side coordinate (context.sideRank.symm marker).property context.ignoredBit).trans context.otherSide_eq_complement.symm have transported := exactSigmaFinCutTransport (exactLeft coordinate partition) context.otherSide other context.otherCut simpa only [exactReverseBobMarkerDecode] using transported theorem exactReverseBobMarkerDecode_sideRank {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : (⟨exactReverseRightSide (exactReverseBobMarkerDecode side context marker), (exactReverseBobContext (exactReverseBobMarkerDecode side context marker)).sideRank⟩ : Σ actualSide : Finset M, ({j : M // j ∈ actualSide} ≃ Fin actualSide.card)) = ⟨side, context.sideRank⟩ := by classical let coordinate := (context.sideRank.symm marker).val let partition := exactReverseBobCanonicalPartition side coordinate context.ignoredBit have actual : insert coordinate (exactRight coordinate partition) = side := exactReverseBobCanonicalPartition_side side coordinate (context.sideRank.symm marker).property context.ignoredBit let transportedRank : {j : M // j ∈ insert coordinate (exactRight coordinate partition)} ≃ Fin (insert coordinate (exactRight coordinate partition)).card := (Equiv.subtypeEquivRight (fun j => by rw [actual])).trans (context.sideRank.trans (finCongr (congrArg Finset.card actual).symm)) have transported : (⟨insert coordinate (exactRight coordinate partition), transportedRank⟩ : Σ actualSide : Finset M, ({j : M // j ∈ actualSide} ≃ Fin actualSide.card)) = ⟨side, context.sideRank⟩ := exactSigmaSideRankTransport (insert coordinate (exactRight coordinate partition)) side actual context.sideRank calc (⟨exactReverseRightSide (exactReverseBobMarkerDecode side context marker), (exactReverseBobContext (exactReverseBobMarkerDecode side context marker)).sideRank⟩ : Σ actualSide : Finset M, ({j : M // j ∈ actualSide} ≃ Fin actualSide.card)) = ⟨insert coordinate (exactRight coordinate partition), transportedRank⟩ := by apply Sigma.ext · change insert (context.sideRank.symm marker).val (exactRight (context.sideRank.symm marker).val (exactReverseBobCanonicalPartition side (context.sideRank.symm marker).val context.ignoredBit)) = insert coordinate (exactRight coordinate partition) rfl · apply heq_of_eq apply Equiv.ext intro j apply Fin.ext simp [coordinate, partition, transportedRank, exactReverseBobMarkerDecode, exactReverseBobContext, exactReverseRightSide, exactReverseRightRank, exactRightRank, exactPermutationOfSideRank_rank, exactInsertedRank_deleteMarked, Equiv.trans_assoc, Equiv.trans_apply, finCongr_apply, Fin.val_cast] _ = ⟨side, context.sideRank⟩ := transported theorem exactReverseBobMarkerDecode_rightInverse {M : Type*} [Fintype M] [DecidableEq M] (side : Finset M) (context : ExactReverseSideContext M side) (marker : Fin side.card) : exactReverseBobMarkerCode (exactReverseBobMarkerDecode side context marker) = ⟨side, context, marker⟩ := by classical generalize decoded : exactReverseBobMarkerDecode side context marker = seed have sameSide : exactReverseRightSide seed = side := by rw [← decoded] exact exactReverseBobMarkerDecode_side side context marker subst side apply Sigma.ext · rfl · apply heq_of_eq change (exactReverseBobContext seed, (exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) = (context, marker) have sameContext : exactReverseBobContext seed = context := by cases context with | mk otherSide sideRank otherRank otherCut ignored complement => simp only [exactReverseBobContext, ExactReverseSideContext.mk.injEq] let reverseContext : ExactReverseSideContext M (exactReverseRightSide seed) := { otherSide := otherSide sideRank := sideRank otherRank := otherRank otherCut := otherCut ignoredBit := ignored otherSide_eq_complement := complement } have exactSideRank := exactReverseBobMarkerDecode_sideRank (exactReverseRightSide seed) reverseContext marker have exactOtherRank := exactReverseBobMarkerDecode_otherRank (exactReverseRightSide seed) reverseContext marker have exactOtherCut := exactReverseBobMarkerDecode_otherCut (exactReverseRightSide seed) reverseContext marker change exactReverseBobMarkerDecode (exactReverseRightSide seed) reverseContext marker = seed at decoded rw [decoded] at exactSideRank exactOtherRank exactOtherCut refine ⟨(exactReverseRightSide_complement seed).trans complement.symm, ?_, ?_, ?_, ?_⟩ · exact eq_of_heq (Sigma.mk.inj exactSideRank).2 · exact (Sigma.mk.inj exactOtherRank).2 · exact (Sigma.mk.inj exactOtherCut).2 · have exactIgnored := congrArg (fun original : ExactForwardSeed M => original.partition original.coordinate) decoded simpa only [exactReverseBobMarkerDecode_ignoredBit] using exactIgnored.symm apply Prod.ext · exact sameContext · rw [sameContext] apply context.sideRank.symm.injective change context.sideRank.symm (context.sideRank ⟨seed.coordinate, _⟩) = context.sideRank.symm marker rw [Equiv.symm_apply_apply] apply Subtype.ext have coordinate := congrArg (fun original : ExactForwardSeed M => original.coordinate) decoded simpa only [exactReverseBobMarkerDecode_coordinate] using coordinate.symm end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def exactReverseAliceWeightedMarkerEquiv {M : Type*} [Fintype M] [DecidableEq M] : ExactForwardSeed M ≃ (Σ side : Finset M, ExactReverseSideContext M side × Fin side.card) where toFun := exactReverseAliceMarkerCode invFun marker := exactReverseAliceMarkerDecode marker.1 marker.2.1 marker.2.2 left_inv seed := by apply exactReverseAliceMarkerCode_injective exact exactReverseAliceMarkerDecode_rightInverse (exactReverseAliceMarkerCode seed).1 (exactReverseAliceMarkerCode seed).2.1 (exactReverseAliceMarkerCode seed).2.2 right_inv marker := by rcases marker with ⟨side, context, position⟩ exact exactReverseAliceMarkerDecode_rightInverse side context position def exactReverseBobWeightedMarkerEquiv {M : Type*} [Fintype M] [DecidableEq M] : ExactForwardSeed M ≃ (Σ side : Finset M, ExactReverseSideContext M side × Fin side.card) where toFun := exactReverseBobMarkerCode invFun marker := exactReverseBobMarkerDecode marker.1 marker.2.1 marker.2.2 left_inv seed := by apply exactReverseBobMarkerCode_injective exact exactReverseBobMarkerDecode_rightInverse (exactReverseBobMarkerCode seed).1 (exactReverseBobMarkerCode seed).2.1 (exactReverseBobMarkerCode seed).2.2 right_inv marker := by rcases marker with ⟨side, context, position⟩ exact exactReverseBobMarkerDecode_rightInverse side context position theorem exactReverseAliceOriginalSeedWeight_factor {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (seed : ExactForwardSeed M) : exactSeedWeight seed = reversePartitionWeight (exactReverseLeftSide seed) * (exactReverseSideContextWeight (exactReverseAliceContext seed) / ((exactReverseLeftSide seed).card : ℝ)) := by calc exactSeedWeight seed = reversePartitionWeight (exactReverseLeftSide seed) * exactReverseAliceConditionalSeedWeight (exactReverseLeftSide seed) seed := by symm simpa using (exactReverseAliceConditionalSeedWeight_cancel nonempty (exactReverseLeftSide seed) seed) _ = _ := by rw [exactReverseAliceConditionalSeedWeight_eq_context_div_card nonempty seed] theorem exactReverseBobOriginalSeedWeight_factor {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (seed : ExactForwardSeed M) : exactSeedWeight seed = reversePartitionWeight (exactReverseRightSide seed) * (exactReverseSideContextWeight (exactReverseBobContext seed) / ((exactReverseRightSide seed).card : ℝ)) := by calc exactSeedWeight seed = reversePartitionWeight (exactReverseRightSide seed) * exactReverseBobConditionalSeedWeight (exactReverseRightSide seed) seed := by symm simpa using (exactReverseBobConditionalSeedWeight_cancel nonempty (exactReverseRightSide seed) seed) _ = _ := by rw [exactReverseBobConditionalSeedWeight_eq_context_div_card nonempty seed] theorem exactUniformFiniteMarkedAverage_sum (n : ℕ) (weight : ℝ) (statistic : Fin n → ℝ) : (∑ _marker : Fin n, weight * ((∑ position : Fin n, statistic position) / (n : ℝ))) = ∑ marker : Fin n, weight * statistic marker := by by_cases empty : n = 0 · subst n simp · have nonzero : (n : ℝ) ≠ 0 := by exact_mod_cast empty simp [Finset.mul_sum, nonzero, div_eq_mul_inv, mul_left_comm] theorem exactReverseAliceUniformMarkedSeed_sum {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (statistic : (side : Finset M) → ExactReverseSideContext M side → Fin side.card → ℝ) : (∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, statistic (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) / ((exactReverseLeftSide seed).card : ℝ))) = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * statistic (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) := by classical let markerWeight : (Σ side : Finset M, ExactReverseSideContext M side × Fin side.card) → ℝ := fun marker => reversePartitionWeight marker.1 * (exactReverseSideContextWeight marker.2.1 / (marker.1.card : ℝ)) let markerAverage : (Σ side : Finset M, ExactReverseSideContext M side × Fin side.card) → ℝ := fun marker => (∑ position : Fin marker.1.card, statistic marker.1 marker.2.1 position) / (marker.1.card : ℝ) let markerValue : (Σ side : Finset M, ExactReverseSideContext M side × Fin side.card) → ℝ := fun marker => statistic marker.1 marker.2.1 marker.2.2 calc (∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, statistic (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) / ((exactReverseLeftSide seed).card : ℝ))) = ∑ marker : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card, markerWeight marker * markerAverage marker := by apply Fintype.sum_equiv (exactReverseAliceWeightedMarkerEquiv (M := M)) intro seed change exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, statistic (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) / ((exactReverseLeftSide seed).card : ℝ)) = (reversePartitionWeight (exactReverseLeftSide seed) * (exactReverseSideContextWeight (exactReverseAliceContext seed) / ((exactReverseLeftSide seed).card : ℝ))) * ((∑ marker : Fin (exactReverseLeftSide seed).card, statistic (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) / ((exactReverseLeftSide seed).card : ℝ)) rw [exactReverseAliceOriginalSeedWeight_factor nonempty] _ = ∑ marker : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card, markerWeight marker * markerValue marker := by simp only [Fintype.sum_sigma, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro side _ apply Finset.sum_congr rfl intro context _ exact exactUniformFiniteMarkedAverage_sum side.card (reversePartitionWeight side * (exactReverseSideContextWeight context / (side.card : ℝ))) (statistic side context) _ = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * statistic (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) := by symm apply Fintype.sum_equiv (exactReverseAliceWeightedMarkerEquiv (M := M)) intro seed change exactSeedWeight seed * statistic (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) = (reversePartitionWeight (exactReverseLeftSide seed) * (exactReverseSideContextWeight (exactReverseAliceContext seed) / ((exactReverseLeftSide seed).card : ℝ))) * statistic (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) rw [exactReverseAliceOriginalSeedWeight_factor nonempty] theorem exactReverseBobUniformMarkedSeed_sum {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (statistic : (side : Finset M) → ExactReverseSideContext M side → Fin side.card → ℝ) : (∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, statistic (exactReverseRightSide seed) (exactReverseBobContext seed) marker) / ((exactReverseRightSide seed).card : ℝ))) = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * statistic (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) := by classical let markerWeight : (Σ side : Finset M, ExactReverseSideContext M side × Fin side.card) → ℝ := fun marker => reversePartitionWeight marker.1 * (exactReverseSideContextWeight marker.2.1 / (marker.1.card : ℝ)) let markerAverage : (Σ side : Finset M, ExactReverseSideContext M side × Fin side.card) → ℝ := fun marker => (∑ position : Fin marker.1.card, statistic marker.1 marker.2.1 position) / (marker.1.card : ℝ) let markerValue : (Σ side : Finset M, ExactReverseSideContext M side × Fin side.card) → ℝ := fun marker => statistic marker.1 marker.2.1 marker.2.2 calc (∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, statistic (exactReverseRightSide seed) (exactReverseBobContext seed) marker) / ((exactReverseRightSide seed).card : ℝ))) = ∑ marker : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card, markerWeight marker * markerAverage marker := by apply Fintype.sum_equiv (exactReverseBobWeightedMarkerEquiv (M := M)) intro seed change exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, statistic (exactReverseRightSide seed) (exactReverseBobContext seed) marker) / ((exactReverseRightSide seed).card : ℝ)) = (reversePartitionWeight (exactReverseRightSide seed) * (exactReverseSideContextWeight (exactReverseBobContext seed) / ((exactReverseRightSide seed).card : ℝ))) * ((∑ marker : Fin (exactReverseRightSide seed).card, statistic (exactReverseRightSide seed) (exactReverseBobContext seed) marker) / ((exactReverseRightSide seed).card : ℝ)) rw [exactReverseBobOriginalSeedWeight_factor nonempty] _ = ∑ marker : Σ side : Finset M, ExactReverseSideContext M side × Fin side.card, markerWeight marker * markerValue marker := by simp only [Fintype.sum_sigma, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro side _ apply Finset.sum_congr rfl intro context _ exact exactUniformFiniteMarkedAverage_sum side.card (reversePartitionWeight side * (exactReverseSideContextWeight context / (side.card : ℝ))) (statistic side context) _ = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * statistic (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) := by symm apply Fintype.sum_equiv (exactReverseBobWeightedMarkerEquiv (M := M)) intro seed change exactSeedWeight seed * statistic (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) = (reversePartitionWeight (exactReverseRightSide seed) * (exactReverseSideContextWeight (exactReverseBobContext seed) / ((exactReverseRightSide seed).card : ℝ))) * statistic (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) rw [exactReverseBobOriginalSeedWeight_factor nonempty] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2600000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseAliceFilterOperatorMarkerEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseBobMarkerDecode side context marker ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * exactFairAliceHistoryEntropyIncrement G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ else 0 def exactReverseBobFilterOperatorMarkerEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseAliceMarkerDecode side context marker ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * exactFairBobHistoryEntropyIncrement G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ else 0 theorem exactFairAliceOperatorEntropy_reverse_marked_average (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < Fintype.card (SourceRemainingCoordinate D)) : (∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairAliceHistoryEntropyIncrement G n S D r else 0) = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, exactReverseAliceFilterOperatorMarkerEntropy G n S D (exactReverseRightSide seed) (exactReverseBobContext seed) marker) / ((exactReverseRightSide seed).card : ℝ)) := by classical have uniform := exactReverseBobUniformMarkedSeed_sum remaining (exactReverseAliceFilterOperatorMarkerEntropy G n S D) symm calc (∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, exactReverseAliceFilterOperatorMarkerEntropy G n S D (exactReverseRightSide seed) (exactReverseBobContext seed) marker) / ((exactReverseRightSide seed).card : ℝ))) = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * exactReverseAliceFilterOperatorMarkerEntropy G n S D (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) := uniform _ = _ := by rw [exactHistoryFlag_sum] apply Finset.sum_congr rfl intro seed _ have decode := (exactReverseBobWeightedMarkerEquiv (M := SourceRemainingCoordinate D)).left_inv seed change exactReverseBobMarkerDecode (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) = seed at decode unfold exactReverseAliceFilterOperatorMarkerEntropy rw [decode] simp only [exactFairHistoryPriorWeight, Finset.mul_sum, mul_ite, mul_zero, mul_assoc] theorem exactFairBobOperatorEntropy_reverse_marked_average (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < Fintype.card (SourceRemainingCoordinate D)) : (∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairBobHistoryEntropyIncrement G n S D r else 0) = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, exactReverseBobFilterOperatorMarkerEntropy G n S D (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) / ((exactReverseLeftSide seed).card : ℝ)) := by classical have uniform := exactReverseAliceUniformMarkedSeed_sum remaining (exactReverseBobFilterOperatorMarkerEntropy G n S D) symm calc (∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, exactReverseBobFilterOperatorMarkerEntropy G n S D (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) / ((exactReverseLeftSide seed).card : ℝ))) = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * exactReverseBobFilterOperatorMarkerEntropy G n S D (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) := uniform _ = _ := by rw [exactHistoryFlag_sum] apply Finset.sum_congr rfl intro seed _ have decode := (exactReverseAliceWeightedMarkerEquiv (M := SourceRemainingCoordinate D)).left_inv seed change exactReverseAliceMarkerDecode (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) = seed at decode unfold exactReverseBobFilterOperatorMarkerEntropy rw [decode] simp only [exactFairHistoryPriorWeight, Finset.mul_sum, mul_ite, mul_zero, mul_assoc] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2200000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactFairAliceHistoryHighOperatorPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := ∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (∑ x : X, G.conditionalXGivenY y x • cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) def exactFairAliceHistoryLowOperatorPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := ∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) def exactFairBobHistoryHighOperatorPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := ∑ x : X, G.marginalX x * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (∑ y : Y, G.conditionalYGivenX x y • cfc (fun z : ℝ => z * Real.log z) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) def exactFairBobHistoryLowOperatorPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : ℝ := ∑ x : X, G.marginalX x * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x)) theorem exactFairAliceHistoryEntropy_eq_operatorPotential_sub (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairAliceHistoryEntropyIncrement G n S D r = exactFairAliceHistoryHighOperatorPotential G n S D r - exactFairAliceHistoryLowOperatorPotential G n S D r := by unfold exactFairAliceHistoryEntropyIncrement exactFairAliceQuestionEntropyIncrement exactFairAliceHistoryHighOperatorPotential exactFairAliceHistoryLowOperatorPotential rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro y _ rw [← mul_sub, map_sub] rfl theorem exactFairBobHistoryEntropy_eq_operatorPotential_sub (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairBobHistoryEntropyIncrement G n S D r = exactFairBobHistoryHighOperatorPotential G n S D r - exactFairBobHistoryLowOperatorPotential G n S D r := by unfold exactFairBobHistoryEntropyIncrement exactFairBobQuestionEntropyIncrement exactFairBobHistoryHighOperatorPotential exactFairBobHistoryLowOperatorPotential rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro x _ rw [← mul_sub, map_sub] def exactReverseAliceFilterHighOperatorPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseBobMarkerDecode side context marker ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * exactFairAliceHistoryHighOperatorPotential G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ else 0 def exactReverseAliceFilterLowOperatorPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseBobMarkerDecode side context marker ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * exactFairAliceHistoryLowOperatorPotential G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ else 0 def exactReverseBobFilterHighOperatorPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseAliceMarkerDecode side context marker ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * exactFairBobHistoryHighOperatorPotential G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ else 0 def exactReverseBobFilterLowOperatorPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseAliceMarkerDecode side context marker ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * exactFairBobHistoryLowOperatorPotential G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ else 0 theorem exactReverseAliceFilterOperatorMarkerEntropy_eq_sub (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceFilterOperatorMarkerEntropy G n S D side context marker = exactReverseAliceFilterHighOperatorPotential G n S D side context marker - exactReverseAliceFilterLowOperatorPotential G n S D side context marker := by unfold exactReverseAliceFilterOperatorMarkerEntropy exactReverseAliceFilterHighOperatorPotential exactReverseAliceFilterLowOperatorPotential simp only [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ · simp only [if_pos accepted] rw [exactFairAliceHistoryEntropy_eq_operatorPotential_sub] ring · simp [accepted] theorem exactReverseBobFilterOperatorMarkerEntropy_eq_sub (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobFilterOperatorMarkerEntropy G n S D side context marker = exactReverseBobFilterHighOperatorPotential G n S D side context marker - exactReverseBobFilterLowOperatorPotential G n S D side context marker := by unfold exactReverseBobFilterOperatorMarkerEntropy exactReverseBobFilterHighOperatorPotential exactReverseBobFilterLowOperatorPotential simp only [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ · simp only [if_pos accepted] rw [exactFairBobHistoryEntropy_eq_operatorPotential_sub] ring · simp [accepted] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2600000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactFixedQuestionPrefix_insert_iff {T : Type*} [DecidableEq T] {n : ℕ} (fixed : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixed) (candidate known : Fin n → T) (value : T) : (∀ k : Fin n, k ∈ insert j fixed → candidate k = (Function.update known j value) k) ↔ candidate j = value ∧ ∀ k : Fin n, k ∈ fixed → candidate k = known k := by constructor · intro h refine ⟨?_, ?_⟩ · simpa using h j (Finset.mem_insert_self j fixed) · intro k hk have different : k ≠ j := by intro same exact fresh (same ▸ hk) simpa [Function.update_of_ne different] using h k (Finset.mem_insert_of_mem hk) · rintro ⟨hvalue, hfixed⟩ k hk rcases Finset.mem_insert.mp hk with same | hk · subst k simpa using hvalue · have different : k ≠ j := by intro same exact fresh (same ▸ hk) simpa [Function.update_of_ne different] using hfixed k hk end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactRevealCode_splitAt_independent {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (x x' : X) (y y' : Y) (tailX : {j : Fin n // j ≠ seed.coordinate.val} → X) (tailY : {j : Fin n // j ≠ seed.coordinate.val} → Y) : exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (x, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (y, tailY)) = exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (x', tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (y', tailY)) := by unfold exactRevealCode congr 1 · funext j have hiD : seed.coordinate.val ∉ D := (Finset.mem_sdiff.mp seed.coordinate.property).2 have different : j.val ≠ seed.coordinate.val := by intro h exact hiD (h ▸ j.property) simp [Equiv.funSplitAt, Equiv.piSplitAt, different] · funext j have hiD : seed.coordinate.val ∉ D := (Finset.mem_sdiff.mp seed.coordinate.property).2 have different : j.val ≠ seed.coordinate.val := by intro h exact hiD (h ▸ j.property) simp [Equiv.funSplitAt, Equiv.piSplitAt, different] · funext j have different : j.val.val ≠ seed.coordinate.val := by intro h have same : j.val = seed.coordinate := Subtype.ext h have mem : seed.coordinate ∈ exactLeft seed.coordinate seed.partition := by simpa [same] using j.property exact exactLeft_coordinate_not_mem seed.coordinate seed.partition mem simp [Equiv.funSplitAt, Equiv.piSplitAt, different] · funext j have different : j.val.val ≠ seed.coordinate.val := by intro h have same : j.val = seed.coordinate := Subtype.ext h have mem : seed.coordinate ∈ exactRight seed.coordinate seed.partition := by simpa [same] using j.property exact exactRight_coordinate_not_mem seed.coordinate seed.partition mem simp [Equiv.funSplitAt, Equiv.piSplitAt, different] · funext j have different : j.val.val ≠ seed.coordinate.val := by intro h have same : j.val = seed.coordinate := Subtype.ext h have hleft := exactLeftPrefix_subset seed j.property exact exactLeft_coordinate_not_mem seed.coordinate seed.partition (same ▸ hleft) simp [Equiv.funSplitAt, Equiv.piSplitAt, different] · funext j have different : j.val.val ≠ seed.coordinate.val := by intro h have same : j.val = seed.coordinate := Subtype.ext h have hright := exactRightPrefix_subset seed j.property exact exactRight_coordinate_not_mem seed.coordinate seed.partition (same ▸ hright) simp [Equiv.funSplitAt, Equiv.piSplitAt, different] theorem exactRepeatedQuestionWeight_splitAt_joint (G : Game X Y A B) (n : ℕ) (i : Fin n) (x : X) (y : Y) (tailX : {j : Fin n // j ≠ i} → X) (tailY : {j : Fin n // j ≠ i} → Y) : (G.repeat n).questionWeight ((Equiv.funSplitAt i X).symm (x, tailX)) ((Equiv.funSplitAt i Y).symm (y, tailY)) = G.questionWeight x y * ∏ j : {j : Fin n // j ≠ i}, G.questionWeight (tailX j) (tailY j) := by classical rw [Game.repeat_questionWeight] rw [← Finset.mul_prod_erase (Finset.univ : Finset (Fin n)) (fun j : Fin n => G.questionWeight ((Equiv.funSplitAt i X).symm (x, tailX) j) ((Equiv.funSplitAt i Y).symm (y, tailY) j)) (Finset.mem_univ i)] simp only [Equiv.funSplitAt, Equiv.piSplitAt, Equiv.coe_fn_symm_mk, dite_true] congr 1 let e : {j : Fin n // j ∈ (Finset.univ : Finset (Fin n)).erase i} ≃ {j : Fin n // j ≠ i} := { toFun := fun j => ⟨j.val, (Finset.mem_erase.mp j.property).1⟩ invFun := fun j => ⟨j.val, Finset.mem_erase.mpr ⟨j.property, Finset.mem_univ _⟩⟩ left_inv := fun _ => rfl right_inv := fun _ => rfl } rw [← Finset.prod_coe_sort, ← e.prod_comp] apply Finset.prod_congr rfl intro j _ have different : j.val ≠ i := (Finset.mem_erase.mp j.property).1 simp [different, e] def exactFairQuestionTailWeight (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) : ℝ := ∑ tailX : {j : Fin n // j ≠ seed.coordinate.val} → X, ∑ tailY : {j : Fin n // j ≠ seed.coordinate.val} → Y, if exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (x, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (y, tailY)) = history then ∏ j : {j : Fin n // j ≠ seed.coordinate.val}, G.questionWeight (tailX j) (tailY j) else 0 theorem exactFairQuestionTailWeight_independent (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x x' : X) (y y' : Y) : exactFairQuestionTailWeight G n D seed history x y = exactFairQuestionTailWeight G n D seed history x' y' := by unfold exactFairQuestionTailWeight apply Finset.sum_congr rfl intro tailX _ apply Finset.sum_congr rfl intro tailY _ rw [exactRevealCode_splitAt_independent D seed x x' y y' tailX tailY] theorem exactJointQuestionMass_eq_question_mul_tail (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) : exactJointQuestionMass G n D seed history x y = G.questionWeight x y * exactFairQuestionTailWeight G n D seed history x y := by classical let e := Equiv.prodCongr (Equiv.funSplitAt seed.coordinate.val X) (Equiv.funSplitAt seed.coordinate.val Y) calc exactJointQuestionMass G n D seed history x y = ∑ t : (X × ({j : Fin n // j ≠ seed.coordinate.val} → X)) × (Y × ({j : Fin n // j ≠ seed.coordinate.val} → Y)), if exactRevealCode D seed (e.symm t) = history ∧ (e.symm t).1 seed.coordinate.val = x ∧ (e.symm t).2 seed.coordinate.val = y then exactPriorQuestionWeight G n (e.symm t) else 0 := by unfold exactJointQuestionMass exact (e.symm.sum_comp (fun q => if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q else 0)).symm _ = ∑ tailX : {j : Fin n // j ≠ seed.coordinate.val} → X, ∑ tailY : {j : Fin n // j ≠ seed.coordinate.val} → Y, if exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (x, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (y, tailY)) = history then exactPriorQuestionWeight G n ((Equiv.funSplitAt seed.coordinate.val X).symm (x, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (y, tailY)) else 0 := by simp only [Fintype.sum_prod_type, e, Equiv.prodCongr, Equiv.coe_fn_symm_mk, Prod.map, Equiv.funSplitAt, Equiv.piSplitAt, dite_true] change (∑ xx : X, ∑ tailX : {j : Fin n // j ≠ seed.coordinate.val} → X, ∑ yy : Y, ∑ tailY : {j : Fin n // j ≠ seed.coordinate.val} → Y, if exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) = history ∧ xx = x ∧ yy = y then exactPriorQuestionWeight G n ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) else 0) = _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro tailX _ calc (∑ xx : X, ∑ yy : Y, ∑ tailY : {j : Fin n // j ≠ seed.coordinate.val} → Y, if exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) = history ∧ xx = x ∧ yy = y then exactPriorQuestionWeight G n ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) else 0) = ∑ xx : X, ∑ tailY : {j : Fin n // j ≠ seed.coordinate.val} → Y, ∑ yy : Y, if exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) = history ∧ xx = x ∧ yy = y then exactPriorQuestionWeight G n ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) else 0 := by apply Finset.sum_congr rfl intro xx _ rw [Finset.sum_comm] _ = ∑ tailY : {j : Fin n // j ≠ seed.coordinate.val} → Y, ∑ xx : X, ∑ yy : Y, if exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) = history ∧ xx = x ∧ yy = y then exactPriorQuestionWeight G n ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) else 0 := by rw [Finset.sum_comm] _ = _ := by apply Finset.sum_congr rfl intro tailY _ have hcondition (xx : X) (yy : Y) : (exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) = history ∧ xx = x ∧ yy = y) = (xx = x ∧ yy = y ∧ exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (xx, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (yy, tailY)) = history) := by apply propext tauto simp_rw [hcondition, ite_and] simp [Equiv.funSplitAt, Equiv.piSplitAt] _ = G.questionWeight x y * exactFairQuestionTailWeight G n D seed history x y := by unfold exactFairQuestionTailWeight rw [Finset.mul_sum] apply Finset.sum_congr rfl intro tailX _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro tailY _ by_cases h : exactRevealCode D seed ((Equiv.funSplitAt seed.coordinate.val X).symm (x, tailX), (Equiv.funSplitAt seed.coordinate.val Y).symm (y, tailY)) = history · rw [if_pos h, if_pos h] exact exactRepeatedQuestionWeight_splitAt_joint G n seed.coordinate.val x y tailX tailY · simp [h] theorem exactJointQuestionMass_sum (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) : (∑ x : X, ∑ y : Y, exactJointQuestionMass G n D seed history x y) = exactRevealMass G n D seed history := by classical unfold exactJointQuestionMass exactRevealMass calc (∑ x : X, ∑ y : Y, ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q else 0) = ∑ q : ExactFullQuestion X Y n, ∑ x : X, ∑ y : Y, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q else 0 := by calc (∑ x : X, ∑ y : Y, ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q else 0) = ∑ y : Y, ∑ q : ExactFullQuestion X Y n, ∑ x : X, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q else 0 := fullCoordinate_three_sum_rotate _ _ = _ := fullCoordinate_three_sum_rotate _ _ = ∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history then exactPriorQuestionWeight G n q else 0 := by apply Finset.sum_congr rfl intro q _ by_cases h : exactRevealCode D seed q = history · have hsum : (∑ xx : X, ∑ yy : Y, if q.1 seed.coordinate.val = xx ∧ q.2 seed.coordinate.val = yy then exactPriorQuestionWeight G n q else 0) = exactPriorQuestionWeight G n q := by calc (∑ xx : X, ∑ yy : Y, if q.1 seed.coordinate.val = xx ∧ q.2 seed.coordinate.val = yy then exactPriorQuestionWeight G n q else 0) = ∑ xx : X, if q.1 seed.coordinate.val = xx then exactPriorQuestionWeight G n q else 0 := by apply Finset.sum_congr rfl intro xx _ by_cases hx : q.1 seed.coordinate.val = xx · simp [hx] · simp [hx] _ = _ := by simp simpa [h] using hsum · simp [h] theorem exactJointQuestionMass_eq_reveal_mul_question (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) : exactJointQuestionMass G n D seed history x y = exactRevealMass G n D seed history * G.questionWeight x y := by have htotal := exactJointQuestionMass_sum G n D seed history have htail : exactRevealMass G n D seed history = exactFairQuestionTailWeight G n D seed history x y := by calc exactRevealMass G n D seed history = ∑ xx : X, ∑ yy : Y, exactJointQuestionMass G n D seed history xx yy := htotal.symm _ = ∑ xx : X, ∑ yy : Y, G.questionWeight xx yy * exactFairQuestionTailWeight G n D seed history x y := by apply Finset.sum_congr rfl intro xx _ apply Finset.sum_congr rfl intro yy _ rw [exactJointQuestionMass_eq_question_mul_tail] rw [exactFairQuestionTailWeight_independent G n D seed history xx x yy y] _ = (∑ xx : X, ∑ yy : Y, G.questionWeight xx yy) * exactFairQuestionTailWeight G n D seed history x y := by simp [Finset.sum_mul] _ = exactFairQuestionTailWeight G n D seed history x y := by rw [G.weight_normalized] simp rw [exactJointQuestionMass_eq_question_mul_tail, ← htail] ring end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactFairConditionedAnswerBornMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ℝ := ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D r.seed r.history x y xs ys * bornTracePairing S.state.matrix (conditionedAliceEffect G n S D r.aliceAnswer xs) (conditionedBobEffect G n S D r.bobAnswer ys) theorem exactFiberQuestionWeight_eq_zero_of_mass_zero (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) (zero : exactFiberQuestionMass G n D seed history x y = 0) (xs : Fin n → X) (ys : Fin n → Y) : exactFiberQuestionWeight G n D seed history x y xs ys = 0 := by have rows : (∑ xx : Fin n → X, ∑ yy : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xx yy) = 0 := by exact zero have row_zero : (∑ yy : Fin n → Y, exactFiberQuestionWeight G n D seed history x y xs yy) = 0 := (Finset.sum_eq_zero_iff_of_nonneg (fun xx _ => Finset.sum_nonneg fun yy _ => exactFiberQuestionWeight_nonneg G n D seed history x y xx yy)).mp rows xs (Finset.mem_univ xs) exact (Finset.sum_eq_zero_iff_of_nonneg (fun yy _ => exactFiberQuestionWeight_nonneg G n D seed history x y xs yy)).mp row_zero ys (Finset.mem_univ ys) theorem exactFairConditionedAnswerBornMass_eq_fiber_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : exactFairConditionedAnswerBornMass G n S D r x y = exactFiberQuestionMass G n D r.seed r.history x y * ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 := by classical by_cases hmass : exactFiberQuestionMass G n D r.seed r.history x y = 0 · have hz (xs : Fin n → X) (ys : Fin n → Y) := exactFiberQuestionWeight_eq_zero_of_mass_zero G n D r.seed r.history x y hmass xs ys simp [exactFairConditionedAnswerBornMass, hz, hmass] · rw [exactUnnormalizedPsi_norm_sq] have hborn := exactSourceEquationTen G n S D r.seed r.history r.aliceAnswer r.bobAnswer x y hmass unfold exactFairConditionedAnswerBornMass rw [hborn, Finset.mul_sum] apply Finset.sum_congr rfl intro xs _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro ys _ unfold exactConditionalQuestionWeight field_simp [hmass] theorem exactFairConditionedAnswerBornMass_eq_reveal_question_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : exactFairConditionedAnswerBornMass G n S D r x y = exactRevealMass G n D r.seed r.history * G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 := by rw [exactFairConditionedAnswerBornMass_eq_fiber_norm, exactFiberQuestionMass_eq_jointQuestionMass, exactJointQuestionMass_eq_reveal_mul_question] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactLocallySampleableCode_fixedSeed_fiber_iff {n : ℕ} (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) (o : ExactOutcome X Y A B n) : exactLocallySampleableCode D (r.seed, o) = (r.seed.coordinate, x, y, r) ↔ exactRevealCode D r.seed (o.1, o.2.1) = r.history ∧ o.1 r.seed.coordinate.val = x ∧ o.2.1 r.seed.coordinate.val = y ∧ (∀ j : {j : Fin n // j ∈ D}, o.2.2.1 j.val = r.aliceAnswer j) ∧ (∀ j : {j : Fin n // j ∈ D}, o.2.2.2 j.val = r.bobAnswer j) := by constructor · intro h have hx := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.1) h have hy := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.1) h have hr := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.2) h have hh0 := congrArg (fun z : ExactHistoryFlag X Y A B D => if hs : z.seed = r.seed then hs ▸ z.history else r.history) hr have hh : exactRevealCode D r.seed (o.1, o.2.1) = r.history := by simpa [exactLocallySampleableCode, exactHistoryCode] using hh0 refine ⟨hh, hx, hy, ?_, ?_⟩ · have ha := congrArg ExactHistoryFlag.aliceAnswer hr intro j exact congrFun ha j · have hb := congrArg ExactHistoryFlag.bobAnswer hr intro j exact congrFun hb j · rintro ⟨hh, hx, hy, ha, hb⟩ have hr : exactHistoryCode D (r.seed, o) = r := by apply ExactHistoryFlag.ext · rfl · exact heq_of_eq hh · funext j exact ha j · funext j exact hb j change (r.seed.coordinate, o.1 r.seed.coordinate.val, o.2.1 r.seed.coordinate.val, exactHistoryCode D (r.seed, o)) = (r.seed.coordinate, x, y, r) rw [hx, hy, hr] def exactFairFullOutcomeBornMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ℝ := ∑ o : ExactOutcome X Y A B n, if exactLocallySampleableCode D (r.seed, o) = (r.seed.coordinate, x, y, r) then (strategyEventLaw (G.repeat n) S).weight o else 0 theorem exactFairFullOutcomeBornMass_eq_conditioned (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : exactFairFullOutcomeBornMass G n S D r x y = exactFairConditionedAnswerBornMass G n S D r x y := by classical unfold exactFairFullOutcomeBornMass exactFairConditionedAnswerBornMass simp only [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ have hq : (exactAliceQuestionCompatible D r.seed r.history x xs ∧ exactBobQuestionCompatible D r.seed r.history y ys) ↔ exactRevealCode D r.seed (xs, ys) = r.history ∧ xs r.seed.coordinate.val = x ∧ ys r.seed.coordinate.val = y := (exactRevealCode_compatible_iff D r.seed r.history x y xs ys).symm by_cases compatible : exactAliceQuestionCompatible D r.seed r.history x xs ∧ exactBobQuestionCompatible D r.seed r.history y ys · have hc := hq.mp compatible rw [exactFiberQuestionWeight] simp only [if_pos compatible] rw [conditionedEffects_born_expansion] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro aa _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro bb _ have hf := exactLocallySampleableCode_fixedSeed_fiber_iff D r x y (xs, ys, aa, bb) have ha : (∀ (j : Fin n) (hj : j ∈ D), aa j = r.aliceAnswer ⟨j, hj⟩) ↔ (∀ j : {j : Fin n // j ∈ D}, aa j.val = r.aliceAnswer j) := by constructor · intro h j exact h j.val j.property · intro h j hj exact h ⟨j, hj⟩ have hb : (∀ (j : Fin n) (hj : j ∈ D), bb j = r.bobAnswer ⟨j, hj⟩) ↔ (∀ j : {j : Fin n // j ∈ D}, bb j.val = r.bobAnswer j) := by constructor · intro h j exact h j.val j.property · intro h j hj exact h ⟨j, hj⟩ by_cases aok : ∀ (j : Fin n) (hj : j ∈ D), aa j = r.aliceAnswer ⟨j, hj⟩ · by_cases bok : ∀ (j : Fin n) (hj : j ∈ D), bb j = r.bobAnswer ⟨j, hj⟩ · have code : exactLocallySampleableCode D (r.seed, (xs, ys, aa, bb)) = (r.seed.coordinate, x, y, r) := hf.mpr ⟨hc.1, hc.2.1, hc.2.2, ha.mp aok, hb.mp bok⟩ simp only [if_pos code, if_pos aok, if_pos bok] rfl · have notcode : exactLocallySampleableCode D (r.seed, (xs, ys, aa, bb)) ≠ (r.seed.coordinate, x, y, r) := by intro code exact bok (hb.mpr (hf.mp code).2.2.2.2) simp [notcode, bok] · have notcode : exactLocallySampleableCode D (r.seed, (xs, ys, aa, bb)) ≠ (r.seed.coordinate, x, y, r) := by intro code exact aok (ha.mpr (hf.mp code).2.2.2.1) simp [notcode, aok] · have notfiber : ¬ (exactRevealCode D r.seed (xs, ys) = r.history ∧ xs r.seed.coordinate.val = x ∧ ys r.seed.coordinate.val = y) := by intro h exact compatible (hq.mpr h) rw [exactFiberQuestionWeight] simp only [if_neg compatible, zero_mul] apply Finset.sum_eq_zero intro aa _ apply Finset.sum_eq_zero intro bb _ have notcode : exactLocallySampleableCode D (r.seed, (xs, ys, aa, bb)) ≠ (r.seed.coordinate, x, y, r) := by intro code have h := (exactLocallySampleableCode_fixedSeed_fiber_iff D r x y (xs, ys, aa, bb)).mp code exact notfiber ⟨h.1, h.2.1, h.2.2.1⟩ simp [notcode] theorem exactFairFullOutcomeBornMass_eq_reveal_question_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : exactFairFullOutcomeBornMass G n S D r x y = exactRevealMass G n D r.seed r.history * G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2 := by rw [exactFairFullOutcomeBornMass_eq_conditioned, exactFairConditionedAnswerBornMass_eq_reveal_question_norm] theorem exactLocallySampleableLaw_eq_fair_born (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : exactLocallySampleableLaw G n S D (r.seed.coordinate, x, y, r) = if exactHistoryAccepted G n D r then (exactSeedWeight r.seed * exactRevealMass G n D r.seed r.history * G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2) / repeatedPostselectionMass G n S D else 0 := by classical by_cases accepted : exactHistoryAccepted G n D r · rw [if_pos accepted] unfold exactLocallySampleableLaw exactSourcePushforward groupedMass rw [Finset.sum_filter, Fintype.sum_prod_type] rw [Finset.sum_eq_single r.seed] · have hcalc : (∑ o : ExactOutcome X Y A B n, if exactLocallySampleableCode D (r.seed, o) = (r.seed.coordinate, x, y, r) then exactPostselectedJointLaw G n S D (r.seed, o) else 0) = (exactSeedWeight r.seed * exactRevealMass G n D r.seed r.history * G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y‖ ^ 2) / repeatedPostselectionMass G n S D := by calc (∑ o : ExactOutcome X Y A B n, if exactLocallySampleableCode D (r.seed, o) = (r.seed.coordinate, x, y, r) then exactPostselectedJointLaw G n S D (r.seed, o) else 0) = (exactSeedWeight r.seed * exactFairFullOutcomeBornMass G n S D r x y) / repeatedPostselectionMass G n S D := by unfold exactFairFullOutcomeBornMass rw [Finset.mul_sum, Finset.sum_div] apply Finset.sum_congr rfl intro o _ by_cases code : exactLocallySampleableCode D (r.seed, o) = (r.seed.coordinate, x, y, r) · have same_history : exactHistoryCode D (r.seed, o) = r := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.2) code have won : o ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D := by apply (exactHistoryCode_accepted_iff G n D (r.seed, o)).mp rw [same_history] exact accepted simp [code, exactPostselectedJointLaw, repeatedConditionedOutcomeLaw, conditionedEventDistribution, repeatedPostselectionMass, postselectionMass, won] ring · simp [code] _ = _ := by rw [exactFairFullOutcomeBornMass_eq_reveal_question_norm] ring convert hcalc using 1 apply Finset.sum_congr rfl intro o _ split <;> rfl · intro seed _ different apply Finset.sum_eq_zero intro o _ have notcode : exactLocallySampleableCode D (seed, o) ≠ (r.seed.coordinate, x, y, r) := by intro code have same := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.2.seed) code exact different same simp [notcode] · simp · rw [if_neg accepted] exact exactLocallySampleableLaw_zero_of_not_accepted G n S D r.seed.coordinate x y r accepted end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactGlobalHistoryFinPsi_sub_Phi_norm (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ‖(exactGlobalHistoryFinPsi G n S D r x y).val - (exactGlobalHistoryFinPhi G n S D r y).val‖ = ‖exactPsi G n S D r x y - exactPhi G n S D r y‖ := by change ‖exactGlobalHistoryFinReindex G n S D (exactGlobalHistoryVector G n S D r (exactPsi G n S D r x y)) - exactGlobalHistoryFinReindex G n S D (exactGlobalHistoryVector G n S D r (exactPhi G n S D r y))‖ = _ rw [← map_sub, ← exactGlobalHistoryVector_sub, LinearIsometryEquiv.norm_map, exactGlobalHistoryVector_norm] theorem exactLocallySampleableLaw_zero_of_coordinate_mismatch (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (x : X) (y : Y) (r : ExactHistoryFlag X Y A B D) (different : i ≠ r.seed.coordinate) : exactLocallySampleableLaw G n S D (i, x, y, r) = 0 := by classical unfold exactLocallySampleableLaw exactSourcePushforward groupedMass apply Finset.sum_eq_zero intro q hq have code : exactLocallySampleableCode D q = (i, x, y, r) := ((@Finset.mem_filter (ExactJointOutcome X Y A B D) (fun a => exactLocallySampleableCode D a = (i, x, y, r)) (fun _ => Classical.propDecidable _) Finset.univ q).mp hq).2 have coordinate : q.1.coordinate = i := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.1) code have history : exactHistoryCode D q = r := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.2) code have seed : q.1 = r.seed := congrArg ExactHistoryFlag.seed history exact (different (coordinate.symm.trans (congrArg ExactForwardSeed.coordinate seed))).elim theorem exactFairPosteriorExpectation_reindex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (f : ExactLocallySampleableTuple X Y A B D → ℝ) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * f t) = ∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, ∑ x : X, exactLocallySampleableLaw G n S D (r.seed.coordinate, x, y, r) * f (r.seed.coordinate, x, y, r) := by classical calc (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * f t) = ∑ i : SourceRemainingCoordinate D, ∑ x : X, ∑ y : Y, ∑ r : ExactHistoryFlag X Y A B D, exactLocallySampleableLaw G n S D (i, x, y, r) * f (i, x, y, r) := by simp [Fintype.sum_prod_type] _ = ∑ y : Y, ∑ r : ExactHistoryFlag X Y A B D, ∑ i : SourceRemainingCoordinate D, ∑ x : X, exactLocallySampleableLaw G n S D (i, x, y, r) * f (i, x, y, r) := finite_sum_four_swap _ _ = ∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, ∑ i : SourceRemainingCoordinate D, ∑ x : X, exactLocallySampleableLaw G n S D (i, x, y, r) * f (i, x, y, r) := by rw [Finset.sum_comm] _ = ∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, ∑ x : X, ∑ i : SourceRemainingCoordinate D, exactLocallySampleableLaw G n S D (i, x, y, r) * f (i, x, y, r) := by apply Finset.sum_congr rfl intro r _ apply Finset.sum_congr rfl intro y _ rw [Finset.sum_comm] _ = _ := by apply Finset.sum_congr rfl intro r _ apply Finset.sum_congr rfl intro y _ apply Finset.sum_congr rfl intro x _ rw [Finset.sum_eq_single r.seed.coordinate] · intro i _ different simp [exactLocallySampleableLaw_zero_of_coordinate_mismatch G n S D i x y r different] · simp def exactFairAcceptedAliceEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := ∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairAliceHistoryEntropyIncrement G n S D r else 0 def exactFairAcceptedBobEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := ∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairBobHistoryEntropyIncrement G n S D r else 0 def exactFairAcceptedAliceVariation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := ∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairAliceHistoryVariation G n S D r else 0 def exactFairAcceptedBobVariation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : ℝ := ∑ r : ExactHistoryFlag X Y A B D, if exactHistoryAccepted G n D r then exactFairHistoryPriorWeight G n D r * exactFairBobHistoryVariation G n S D r else 0 theorem exactFairPsiPhiDistance_mul_postselection_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * ‖exactSourceTuplePsi G n S D t - exactSourceTuplePhi G n S D t‖ ^ 2) * repeatedPostselectionMass G n S D ≤ 4 * exactFairAcceptedAliceVariation G n S D := by classical rw [exactFairPosteriorExpectation_reindex] simp_rw [Finset.sum_mul] calc (∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, ∑ x : X, (exactLocallySampleableLaw G n S D (r.seed.coordinate, x, y, r) * ‖exactSourceTuplePsi G n S D (r.seed.coordinate, x, y, r) - exactSourceTuplePhi G n S D (r.seed.coordinate, x, y, r)‖ ^ 2) * repeatedPostselectionMass G n S D) ≤ ∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, ∑ x : X, if exactHistoryAccepted G n D r then 4 * (exactFairHistoryPriorWeight G n D r * G.questionWeight x y * ‖exactUnnormalizedPsi G n S D r x y - exactUnnormalizedPhi G n S D r y‖ ^ 2) else 0 := by apply Finset.sum_le_sum intro r _ apply Finset.sum_le_sum intro y _ apply Finset.sum_le_sum intro x _ by_cases accepted : exactHistoryAccepted G n D r · rw [if_pos accepted, exactLocallySampleableLaw_eq_fair_born, if_pos accepted] change ((_ / repeatedPostselectionMass G n S D) * ‖(exactGlobalHistoryFinPsi G n S D r x y).val - (exactGlobalHistoryFinPhi G n S D r y).val‖ ^ 2) * repeatedPostselectionMass G n S D ≤ _ rw [exactGlobalHistoryFinPsi_sub_Phi_norm] have hnorm := exactPsiPhi_BornWeighted_normalized_distance G n S D r x y have hw : 0 ≤ exactFairHistoryPriorWeight G n D r * G.questionWeight x y := mul_nonneg (exactFairHistoryPriorWeight_nonneg G n D r) (G.weight_nonneg x y) have hscaled := mul_le_mul_of_nonneg_left hnorm hw unfold exactFairHistoryPriorWeight at hscaled ⊢ field_simp [positive.ne'] nlinarith · rw [if_neg accepted, exactLocallySampleableLaw_eq_fair_born, if_neg accepted] simp _ = 4 * exactFairAcceptedAliceVariation G n S D := by unfold exactFairAcceptedAliceVariation exactFairAliceHistoryVariation rw [Finset.mul_sum] apply Finset.sum_congr rfl intro r _ by_cases accepted : exactHistoryAccepted G n D r · simp only [if_pos accepted, Finset.mul_sum] apply Finset.sum_congr rfl intro y _ apply Finset.sum_congr rfl intro x _ ring · simp [accepted] theorem exactFairGammaPsiDistance_mul_postselection_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * ‖exactSourceTupleGamma G n S D t - exactSourceTuplePsi G n S D t‖ ^ 2) * repeatedPostselectionMass G n S D ≤ 4 * exactFairAcceptedBobVariation G n S D := by classical rw [exactFairPosteriorExpectation_reindex] simp_rw [Finset.sum_mul] calc (∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, ∑ x : X, (exactLocallySampleableLaw G n S D (r.seed.coordinate, x, y, r) * ‖exactSourceTupleGamma G n S D (r.seed.coordinate, x, y, r) - exactSourceTuplePsi G n S D (r.seed.coordinate, x, y, r)‖ ^ 2) * repeatedPostselectionMass G n S D) ≤ ∑ r : ExactHistoryFlag X Y A B D, ∑ y : Y, ∑ x : X, if exactHistoryAccepted G n D r then 4 * (exactFairHistoryPriorWeight G n D r * G.questionWeight x y * ‖exactUnnormalizedGamma G n S D r x - exactUnnormalizedPsi G n S D r x y‖ ^ 2) else 0 := by apply Finset.sum_le_sum intro r _ apply Finset.sum_le_sum intro y _ apply Finset.sum_le_sum intro x _ by_cases accepted : exactHistoryAccepted G n D r · rw [if_pos accepted, exactLocallySampleableLaw_eq_fair_born, if_pos accepted] change ((_ / repeatedPostselectionMass G n S D) * ‖(exactGlobalHistoryFinGamma G n S D r x).val - (exactGlobalHistoryFinPsi G n S D r x y).val‖ ^ 2) * repeatedPostselectionMass G n S D ≤ _ rw [exactGlobalHistoryFinGamma_sub_Psi_norm] have hnorm := exactGammaPsi_BornWeighted_normalized_distance G n S D r x y have hw : 0 ≤ exactFairHistoryPriorWeight G n D r * G.questionWeight x y := mul_nonneg (exactFairHistoryPriorWeight_nonneg G n D r) (G.weight_nonneg x y) have hscaled := mul_le_mul_of_nonneg_left hnorm hw unfold exactFairHistoryPriorWeight at hscaled ⊢ field_simp [positive.ne'] nlinarith · rw [if_neg accepted, exactLocallySampleableLaw_eq_fair_born, if_neg accepted] simp _ = 4 * exactFairAcceptedBobVariation G n S D := by unfold exactFairAcceptedBobVariation exactFairBobHistoryVariation rw [Finset.mul_sum] apply Finset.sum_congr rfl intro r _ by_cases accepted : exactHistoryAccepted G n D r · simp only [if_pos accepted, Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [norm_sub_rev] ring · simp [accepted] def ExactFairOperatorEntropyBound (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (η : ℝ) : Prop := exactFairAcceptedAliceEntropy G n S D ≤ 2 * (repeatedPostselectionMass G n S D * η) ∧ exactFairAcceptedBobEntropy G n S D ≤ 2 * (repeatedPostselectionMass G n S D * η) theorem exactSourceStateDistanceBound_of_fair_operator_entropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (η : ℝ) (positive : 0 < repeatedPostselectionMass G n S D) (entropy : ExactFairOperatorEntropyBound G n S D η) : ExactSourceStateDistanceBound G n S D η := by constructor · have hv := exactFairGammaPsiDistance_mul_postselection_le G n S D positive have hj := exactAcceptedFairBobVariation_le_entropy G n S D change exactFairAcceptedBobVariation G n S D ≤ exactFairAcceptedBobEntropy G n S D at hj have hb := entropy.2 have hscaled := mul_le_mul_of_nonneg_left hj (by norm_num : (0 : ℝ) ≤ 4) have hbudget := mul_le_mul_of_nonneg_left hb (by norm_num : (0 : ℝ) ≤ 4) change (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * ‖exactSourceTupleGamma G n S D t - exactSourceTuplePsi G n S D t‖ ^ 2) ≤ 8 * η nlinarith · have hv := exactFairPsiPhiDistance_mul_postselection_le G n S D positive have hj := exactAcceptedFairAliceVariation_le_entropy G n S D change exactFairAcceptedAliceVariation G n S D ≤ exactFairAcceptedAliceEntropy G n S D at hj have ha := entropy.1 have hscaled := mul_le_mul_of_nonneg_left hj (by norm_num : (0 : ℝ) ≤ 4) have hbudget := mul_le_mul_of_nonneg_left ha (by norm_num : (0 : ℝ) ≤ 4) change (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * ‖exactSourceTuplePsi G n S D t - exactSourceTuplePhi G n S D t‖ ^ 2) ≤ 8 * η nlinarith end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactAliceQuestionConditionalWeight_sum (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) : (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then exactPriorQuestionWeight G n q / exactAliceQuestionMass G n D seed history x else 0) = if exactAliceQuestionMass G n D seed history x = 0 then 0 else 1 := by classical calc (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then exactPriorQuestionWeight G n q / exactAliceQuestionMass G n D seed history x else 0) = (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then exactPriorQuestionWeight G n q else 0) / exactAliceQuestionMass G n D seed history x := by rw [Finset.sum_div] apply Finset.sum_congr rfl intro q _ split <;> simp_all _ = exactAliceQuestionMass G n D seed history x / exactAliceQuestionMass G n D seed history x := by rfl _ = _ := by split_ifs with zero · simp [zero] · exact div_self zero theorem exactBobQuestionConditionalWeight_sum (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (y : Y) : (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q / exactBobQuestionMass G n D seed history y else 0) = if exactBobQuestionMass G n D seed history y = 0 then 0 else 1 := by classical calc (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q / exactBobQuestionMass G n D seed history y else 0) = (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q else 0) / exactBobQuestionMass G n D seed history y := by rw [Finset.sum_div] apply Finset.sum_congr rfl intro q _ split <;> simp_all _ = exactBobQuestionMass G n D seed history y / exactBobQuestionMass G n D seed history y := by rfl _ = _ := by split_ifs with zero · simp [zero] · exact div_self zero theorem exactAliceQuestionFilter_complement_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {i : Fin n // i ∈ D} → A) (x : X) : (1 - exactAliceQuestionFilter G n S D seed history answer x).PosSemidef := by classical let w : ExactFullQuestion X Y n → ℝ := fun q => if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then exactPriorQuestionWeight G n q / exactAliceQuestionMass G n D seed history x else 0 let E : ExactFullQuestion X Y n → Matrix S.Alice S.Alice ℂ := fun q => conditionedAliceEffect G n S D answer q.1 have weights_nonnegative (q : ExactFullQuestion X Y n) : 0 ≤ w q := by dsimp [w] split · exact div_nonneg (exactPriorQuestionWeight_nonneg G n q) (exactAliceQuestionMass_nonneg G n D seed history x) · exact le_rfl have weights_sum : (∑ q, w q) ≤ 1 := by change (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x then exactPriorQuestionWeight G n q / exactAliceQuestionMass G n D seed history x else 0) ≤ 1 rw [exactAliceQuestionConditionalWeight_sum G n D seed history x] split <;> norm_num have filter_eq : exactAliceQuestionFilter G n S D seed history answer x = ∑ q, w q • E q := by unfold exactAliceQuestionFilter apply Finset.sum_congr rfl intro q _ dsimp [w, E] split <;> simp_all have split : 1 - (∑ q, w q • E q) = (1 - (∑ q, w q)) • (1 : Matrix S.Alice S.Alice ℂ) + ∑ q, w q • (1 - E q) := by simp_rw [smul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_smul] module rw [filter_eq, split] apply Matrix.PosSemidef.add · exact Matrix.PosSemidef.one.smul (sub_nonneg.mpr weights_sum) · apply Matrix.posSemidef_sum Finset.univ intro q _ exact (conditionedAliceEffect_complement_positive G n S D answer q.1).smul (weights_nonnegative q) theorem exactBobQuestionFilter_complement_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {i : Fin n // i ∈ D} → B) (y : Y) : (1 - exactBobQuestionFilter G n S D seed history answer y).PosSemidef := by classical let w : ExactFullQuestion X Y n → ℝ := fun q => if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q / exactBobQuestionMass G n D seed history y else 0 let E : ExactFullQuestion X Y n → Matrix S.Bob S.Bob ℂ := fun q => conditionedBobEffect G n S D answer q.2 have weights_nonnegative (q : ExactFullQuestion X Y n) : 0 ≤ w q := by dsimp [w] split · exact div_nonneg (exactPriorQuestionWeight_nonneg G n q) (exactBobQuestionMass_nonneg G n D seed history y) · exact le_rfl have weights_sum : (∑ q, w q) ≤ 1 := by change (∑ q : ExactFullQuestion X Y n, if exactRevealCode D seed q = history ∧ q.2 seed.coordinate.val = y then exactPriorQuestionWeight G n q / exactBobQuestionMass G n D seed history y else 0) ≤ 1 rw [exactBobQuestionConditionalWeight_sum G n D seed history y] split <;> norm_num have filter_eq : exactBobQuestionFilter G n S D seed history answer y = ∑ q, w q • E q := by unfold exactBobQuestionFilter apply Finset.sum_congr rfl intro q _ dsimp [w, E] split <;> simp_all have split : 1 - (∑ q, w q • E q) = (1 - (∑ q, w q)) • (1 : Matrix S.Bob S.Bob ℂ) + ∑ q, w q • (1 - E q) := by simp_rw [smul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_smul] module rw [filter_eq, split] apply Matrix.PosSemidef.add · exact Matrix.PosSemidef.one.smul (sub_nonneg.mpr weights_sum) · apply Matrix.posSemidef_sum Finset.univ intro q _ exact (conditionedBobEffect_complement_positive G n S D answer q.2).smul (weights_nonnegative q) theorem exactAliceMeanFilter_complement_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {i : Fin n // i ∈ D} → A) (y : Y) : (1 - exactAliceMeanFilter G n S D seed history answer y).PosSemidef := by classical let w : X → ℝ := G.conditionalXGivenY y let E : X → Matrix S.Alice S.Alice ℂ := fun x => exactAliceQuestionFilter G n S D seed history answer x have weights_sum : (∑ x, w x) ≤ 1 := G.conditionalXGivenY_sum_le_one y have split : 1 - (∑ x, w x • E x) = (1 - (∑ x, w x)) • (1 : Matrix S.Alice S.Alice ℂ) + ∑ x, w x • (1 - E x) := by simp_rw [smul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_smul] module change (1 - ∑ x, w x • E x).PosSemidef rw [split] apply Matrix.PosSemidef.add · exact Matrix.PosSemidef.one.smul (sub_nonneg.mpr weights_sum) · apply Matrix.posSemidef_sum Finset.univ intro x _ exact (exactAliceQuestionFilter_complement_posSemidef G n S D seed history answer x).smul (G.conditionalXGivenY_nonneg y x) theorem exactBobMeanFilter_complement_posSemidef (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (answer : {i : Fin n // i ∈ D} → B) (x : X) : (1 - exactBobMeanFilter G n S D seed history answer x).PosSemidef := by classical let w : Y → ℝ := G.conditionalYGivenX x let E : Y → Matrix S.Bob S.Bob ℂ := fun y => exactBobQuestionFilter G n S D seed history answer y have weights_sum : (∑ y, w y) ≤ 1 := G.conditionalYGivenX_sum_le_one x have split : 1 - (∑ y, w y • E y) = (1 - (∑ y, w y)) • (1 : Matrix S.Bob S.Bob ℂ) + ∑ y, w y • (1 - E y) := by simp_rw [smul_sub] rw [Finset.sum_sub_distrib, ← Finset.sum_smul] module change (1 - ∑ y, w y • E y).PosSemidef rw [split] apply Matrix.PosSemidef.add · exact Matrix.PosSemidef.one.smul (sub_nonneg.mpr weights_sum) · apply Matrix.posSemidef_sum Finset.univ intro y _ exact (exactBobQuestionFilter_complement_posSemidef G n S D seed history answer y).smul (G.conditionalYGivenX_nonneg x y) theorem exactFairAliceMean_spectral_entropy_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (y : Y) : -bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) ≤ Real.negMulLog (bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) := by classical exact source_equation_nineteen_alice S.state (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y) (exactAliceMeanFilter_posSemidef G n S D r.seed r.history r.aliceAnswer y) (exactAliceMeanFilter_complement_posSemidef G n S D r.seed r.history r.aliceAnswer y) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) (exactBobQuestionFilter_posSemidef G n S D r.seed r.history r.bobAnswer y) (exactBobQuestionFilter_complement_posSemidef G n S D r.seed r.history r.bobAnswer y) theorem exactFairBobMean_spectral_entropy_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) : -bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x)) ≤ Real.negMulLog (bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x)) := by classical exact source_equation_nineteen_bob S.state (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactAliceQuestionFilter_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactAliceQuestionFilter_complement_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x) (exactBobMeanFilter_posSemidef G n S D r.seed r.history r.bobAnswer x) (exactBobMeanFilter_complement_posSemidef G n S D r.seed r.history r.bobAnswer x) theorem exactFairAliceHistoryHighOperatorPotential_nonpos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairAliceHistoryHighOperatorPotential G n S D r ≤ 0 := by classical unfold exactFairAliceHistoryHighOperatorPotential apply Finset.sum_nonpos intro y _ apply mul_nonpos_of_nonneg_of_nonpos (G.marginalY_nonneg y) calc bornTracePairing S.state.matrix (∑ x : X, G.conditionalXGivenY y x • cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) = ∑ x : X, G.conditionalXGivenY y x * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by simp only [map_sum, map_smul, LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul] _ ≤ 0 := by apply Finset.sum_nonpos intro x _ exact mul_nonpos_of_nonneg_of_nonpos (G.conditionalXGivenY_nonneg y x) (matrixLogEntropy_born_nonpos_left S.state (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) (exactAliceQuestionFilter_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactAliceQuestionFilter_complement_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter_posSemidef G n S D r.seed r.history r.bobAnswer y)) theorem exactFairBobHistoryHighOperatorPotential_nonpos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairBobHistoryHighOperatorPotential G n S D r ≤ 0 := by classical unfold exactFairBobHistoryHighOperatorPotential apply Finset.sum_nonpos intro x _ apply mul_nonpos_of_nonneg_of_nonpos (G.marginalX_nonneg x) calc bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (∑ y : Y, G.conditionalYGivenX x y • cfc (fun z : ℝ => z * Real.log z) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) = ∑ y : Y, G.conditionalYGivenX x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) := by simp only [map_sum, map_smul, smul_eq_mul] _ ≤ 0 := by apply Finset.sum_nonpos intro y _ exact mul_nonpos_of_nonneg_of_nonpos (G.conditionalYGivenX_nonneg x y) (matrixLogEntropy_born_nonpos_right S.state (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) (exactAliceQuestionFilter_posSemidef G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter_posSemidef G n S D r.seed r.history r.bobAnswer y) (exactBobQuestionFilter_complement_posSemidef G n S D r.seed r.history r.bobAnswer y)) theorem exactFairAliceHistoryLowOperatorPotential_neg_le_entropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : -exactFairAliceHistoryLowOperatorPotential G n S D r ≤ ∑ y : Y, G.marginalY y * Real.negMulLog (bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) := by classical unfold exactFairAliceHistoryLowOperatorPotential rw [← Finset.sum_neg_distrib] apply Finset.sum_le_sum intro y _ have bound := mul_le_mul_of_nonneg_left (exactFairAliceMean_spectral_entropy_le G n S D r y) (G.marginalY_nonneg y) nlinarith theorem exactFairBobHistoryLowOperatorPotential_neg_le_entropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : -exactFairBobHistoryLowOperatorPotential G n S D r ≤ ∑ x : X, G.marginalX x * Real.negMulLog (bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x)) := by classical unfold exactFairBobHistoryLowOperatorPotential rw [← Finset.sum_neg_distrib] apply Finset.sum_le_sum intro x _ have bound := mul_le_mul_of_nonneg_left (exactFairBobMean_spectral_entropy_le G n S D r x) (G.marginalX_nonneg x) nlinarith theorem exactReverseAliceFilterHighOperatorPotential_nonpos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceFilterHighOperatorPotential G n S D side context marker ≤ 0 := by classical unfold exactReverseAliceFilterHighOperatorPotential dsimp only apply Finset.sum_nonpos intro history _ apply Finset.sum_nonpos intro aliceAnswer _ apply Finset.sum_nonpos intro bobAnswer _ split · exact mul_nonpos_of_nonneg_of_nonpos (exactRevealMass_nonneg G n D (exactReverseBobMarkerDecode side context marker) history) (exactFairAliceHistoryHighOperatorPotential_nonpos G n S D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩) · exact le_rfl theorem exactReverseBobFilterHighOperatorPotential_nonpos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobFilterHighOperatorPotential G n S D side context marker ≤ 0 := by classical unfold exactReverseBobFilterHighOperatorPotential dsimp only apply Finset.sum_nonpos intro history _ apply Finset.sum_nonpos intro aliceAnswer _ apply Finset.sum_nonpos intro bobAnswer _ split · exact mul_nonpos_of_nonneg_of_nonpos (exactRevealMass_nonneg G n D (exactReverseAliceMarkerDecode side context marker) history) (exactFairBobHistoryHighOperatorPotential_nonpos G n S D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩) · exact le_rfl end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactJointPrefixQuestionMass (G : Game X Y A B) (n : ℕ) (fixedX fixedY : Finset (Fin n)) (knownX : Fin n → X) (knownY : Fin n → Y) : ℝ := ∑ xs : Fin n → X, ∑ ys : Fin n → Y, if (∀ j : Fin n, j ∈ fixedX → xs j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) then (G.repeat n).questionWeight xs ys else 0 def exactJointPrefixAliceOperatorMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (answer : {j : Fin n // j ∈ D} → A) (knownX : Fin n → X) (knownY : Fin n → Y) : Matrix S.Alice S.Alice ℂ := ∑ xs : Fin n → X, ∑ ys : Fin n → Y, if (∀ j : Fin n, j ∈ fixedX → xs j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) then (G.repeat n).questionWeight xs ys • conditionedAliceEffect G n S D answer xs else 0 def exactJointPrefixBobOperatorMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (answer : {j : Fin n // j ∈ D} → B) (knownX : Fin n → X) (knownY : Fin n → Y) : Matrix S.Bob S.Bob ℂ := ∑ xs : Fin n → X, ∑ ys : Fin n → Y, if (∀ j : Fin n, j ∈ fixedX → xs j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) then (G.repeat n).questionWeight xs ys • conditionedBobEffect G n S D answer ys else 0 theorem exactJointPrefixQuestionMass_eq_sum_alice (G : Game X Y A B) (n : ℕ) (fixedX fixedY : Finset (Fin n)) (knownX : Fin n → X) (knownY : Fin n → Y) : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = ∑ ys : Fin n → Y, if ∀ j : Fin n, j ∈ fixedY → ys j = knownY j then exactFixedAliceQuestionMass G n fixedX knownX ys else 0 := by classical unfold exactJointPrefixQuestionMass rw [Finset.sum_comm] apply Finset.sum_congr rfl intro ys _ unfold exactFixedAliceQuestionMass by_cases compatible : ∀ j : Fin n, j ∈ fixedY → ys j = knownY j · rw [if_pos compatible] apply Finset.sum_congr rfl intro xs _ by_cases alice_compatible : ∀ j : Fin n, j ∈ fixedX → xs j = knownX j · rw [if_pos ⟨alice_compatible, compatible⟩, if_pos alice_compatible] · rw [if_neg (fun h => alice_compatible h.1), if_neg alice_compatible] · rw [if_neg compatible] apply Finset.sum_eq_zero intro xs _ rw [if_neg] exact fun h => compatible h.2 theorem exactJointPrefixQuestionMass_eq_sum_bob (G : Game X Y A B) (n : ℕ) (fixedX fixedY : Finset (Fin n)) (knownX : Fin n → X) (knownY : Fin n → Y) : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = ∑ xs : Fin n → X, if ∀ j : Fin n, j ∈ fixedX → xs j = knownX j then exactFixedBobQuestionMass G n fixedY xs knownY else 0 := by classical unfold exactJointPrefixQuestionMass apply Finset.sum_congr rfl intro xs _ unfold exactFixedBobQuestionMass by_cases compatible : ∀ j : Fin n, j ∈ fixedX → xs j = knownX j · rw [if_pos compatible] apply Finset.sum_congr rfl intro ys _ by_cases bob_compatible : ∀ j : Fin n, j ∈ fixedY → ys j = knownY j · rw [if_pos ⟨compatible, bob_compatible⟩, if_pos bob_compatible] · rw [if_neg (fun h => bob_compatible h.2), if_neg bob_compatible] · rw [if_neg compatible] apply Finset.sum_eq_zero intro ys _ rw [if_neg] exact fun h => compatible h.1 theorem exactJointPrefixQuestionMass_insert_alice (G : Game X Y A B) (n : ℕ) (fixedX fixedY : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixedX) (opposite_fixed : j ∈ fixedY) (knownX : Fin n → X) (knownY : Fin n → Y) (x : X) : exactJointPrefixQuestionMass G n (insert j fixedX) fixedY (Function.update knownX j x) knownY = G.conditionalXGivenY (knownY j) x * exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY := by classical rw [exactJointPrefixQuestionMass_eq_sum_alice, exactJointPrefixQuestionMass_eq_sum_alice, Finset.mul_sum] apply Finset.sum_congr rfl intro ys _ by_cases compatible : ∀ k : Fin n, k ∈ fixedY → ys k = knownY k · rw [if_pos compatible, if_pos compatible, exactFixedAliceQuestionMass_insert G n fixedX j fresh knownX ys x, compatible j opposite_fixed] · simp [compatible] theorem exactJointPrefixQuestionMass_insert_bob (G : Game X Y A B) (n : ℕ) (fixedX fixedY : Finset (Fin n)) (j : Fin n) (opposite_fixed : j ∈ fixedX) (fresh : j ∉ fixedY) (knownX : Fin n → X) (knownY : Fin n → Y) (y : Y) : exactJointPrefixQuestionMass G n fixedX (insert j fixedY) knownX (Function.update knownY j y) = G.conditionalYGivenX (knownX j) y * exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY := by classical rw [exactJointPrefixQuestionMass_eq_sum_bob, exactJointPrefixQuestionMass_eq_sum_bob, Finset.mul_sum] apply Finset.sum_congr rfl intro xs _ by_cases compatible : ∀ k : Fin n, k ∈ fixedX → xs k = knownX k · rw [if_pos compatible, if_pos compatible, exactFixedBobQuestionMass_insert G n fixedY j fresh xs knownY y, compatible j opposite_fixed] · simp [compatible] theorem exactJointPrefixQuestionAtom_zero_of_mass_zero (G : Game X Y A B) (n : ℕ) (fixedX fixedY : Finset (Fin n)) (knownX : Fin n → X) (knownY : Fin n → Y) (zero : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = 0) (xs : Fin n → X) (ys : Fin n → Y) : (if (∀ j : Fin n, j ∈ fixedX → xs j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) then (G.repeat n).questionWeight xs ys else 0) = 0 := by unfold exactJointPrefixQuestionMass at zero have row_nonnegative (xx : Fin n → X) : 0 ≤ ∑ yy : Fin n → Y, if (∀ j : Fin n, j ∈ fixedX → xx j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → yy j = knownY j) then (G.repeat n).questionWeight xx yy else 0 := by apply Finset.sum_nonneg intro yy _ split · exact (G.repeat n).weight_nonneg xx yy · exact le_rfl have row_zero := (Finset.sum_eq_zero_iff_of_nonneg (fun xx _ => row_nonnegative xx)).mp zero xs (Finset.mem_univ xs) exact (Finset.sum_eq_zero_iff_of_nonneg (fun yy _ => by split · exact (G.repeat n).weight_nonneg xs yy · exact le_rfl)).mp row_zero ys (Finset.mem_univ ys) theorem exactJointPrefixAliceOperatorMass_zero_of_mass_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (answer : {j : Fin n // j ∈ D} → A) (knownX : Fin n → X) (knownY : Fin n → Y) (zero : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = 0) : exactJointPrefixAliceOperatorMass G n S D fixedX fixedY answer knownX knownY = 0 := by unfold exactJointPrefixAliceOperatorMass apply Finset.sum_eq_zero intro xs _ apply Finset.sum_eq_zero intro ys _ have atom := exactJointPrefixQuestionAtom_zero_of_mass_zero G n fixedX fixedY knownX knownY zero xs ys by_cases compatible : (∀ j : Fin n, j ∈ fixedX → xs j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) · have weight_zero : (G.repeat n).questionWeight xs ys = 0 := by simpa only [if_pos compatible] using atom rw [if_pos compatible, weight_zero] exact zero_smul ℝ (conditionedAliceEffect G n S D answer xs) · rw [if_neg compatible] theorem exactJointPrefixBobOperatorMass_zero_of_mass_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (answer : {j : Fin n // j ∈ D} → B) (knownX : Fin n → X) (knownY : Fin n → Y) (zero : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = 0) : exactJointPrefixBobOperatorMass G n S D fixedX fixedY answer knownX knownY = 0 := by unfold exactJointPrefixBobOperatorMass apply Finset.sum_eq_zero intro xs _ apply Finset.sum_eq_zero intro ys _ have atom := exactJointPrefixQuestionAtom_zero_of_mass_zero G n fixedX fixedY knownX knownY zero xs ys by_cases compatible : (∀ j : Fin n, j ∈ fixedX → xs j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) · have weight_zero : (G.repeat n).questionWeight xs ys = 0 := by simpa only [if_pos compatible] using atom rw [if_pos compatible, weight_zero] exact zero_smul ℝ (conditionedBobEffect G n S D answer ys) · rw [if_neg compatible] theorem exactJointPrefixAliceOperatorMass_sum_insert (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixedX) (answer : {k : Fin n // k ∈ D} → A) (knownX : Fin n → X) (knownY : Fin n → Y) : (∑ x : X, exactJointPrefixAliceOperatorMass G n S D (insert j fixedX) fixedY answer (Function.update knownX j x) knownY) = exactJointPrefixAliceOperatorMass G n S D fixedX fixedY answer knownX knownY := by classical unfold exactJointPrefixAliceOperatorMass calc (∑ x : X, ∑ xs : Fin n → X, ∑ ys : Fin n → Y, if (∀ k : Fin n, k ∈ insert j fixedX → xs k = (Function.update knownX j x) k) ∧ (∀ k : Fin n, k ∈ fixedY → ys k = knownY k) then (G.repeat n).questionWeight xs ys • conditionedAliceEffect G n S D answer xs else 0) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ x : X, if (∀ k : Fin n, k ∈ insert j fixedX → xs k = (Function.update knownX j x) k) ∧ (∀ k : Fin n, k ∈ fixedY → ys k = knownY k) then (G.repeat n).questionWeight xs ys • conditionedAliceEffect G n S D answer xs else 0 := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro xs _ rw [Finset.sum_comm] _ = _ := by apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ simp_rw [exactFixedQuestionPrefix_insert_iff fixedX j fresh xs knownX] by_cases compatible : (∀ k : Fin n, k ∈ fixedX → xs k = knownX k) ∧ (∀ k : Fin n, k ∈ fixedY → ys k = knownY k) · rw [if_pos compatible] calc _ = (if (xs j = xs j ∧ (∀ k : Fin n, k ∈ fixedX → xs k = knownX k)) ∧ (∀ k : Fin n, k ∈ fixedY → ys k = knownY k) then (G.repeat n).questionWeight xs ys • conditionedAliceEffect G n S D answer xs else 0) := by apply Finset.sum_eq_single (xs j) · intro x _ different rw [if_neg] exact fun h => different h.1.1.symm · intro absent exact (absent (Finset.mem_univ (xs j))).elim _ = _ := if_pos ⟨⟨rfl, compatible.1⟩, compatible.2⟩ · rw [if_neg compatible] apply Finset.sum_eq_zero intro x _ rw [if_neg] exact fun h => compatible ⟨h.1.2, h.2⟩ theorem exactJointPrefixBobOperatorMass_sum_insert (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixedY) (answer : {k : Fin n // k ∈ D} → B) (knownX : Fin n → X) (knownY : Fin n → Y) : (∑ y : Y, exactJointPrefixBobOperatorMass G n S D fixedX (insert j fixedY) answer knownX (Function.update knownY j y)) = exactJointPrefixBobOperatorMass G n S D fixedX fixedY answer knownX knownY := by classical unfold exactJointPrefixBobOperatorMass calc (∑ y : Y, ∑ xs : Fin n → X, ∑ ys : Fin n → Y, if (∀ k : Fin n, k ∈ fixedX → xs k = knownX k) ∧ (∀ k : Fin n, k ∈ insert j fixedY → ys k = (Function.update knownY j y) k) then (G.repeat n).questionWeight xs ys • conditionedBobEffect G n S D answer ys else 0) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ y : Y, if (∀ k : Fin n, k ∈ fixedX → xs k = knownX k) ∧ (∀ k : Fin n, k ∈ insert j fixedY → ys k = (Function.update knownY j y) k) then (G.repeat n).questionWeight xs ys • conditionedBobEffect G n S D answer ys else 0 := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro xs _ rw [Finset.sum_comm] _ = _ := by apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ simp_rw [exactFixedQuestionPrefix_insert_iff fixedY j fresh ys knownY] by_cases compatible : (∀ k : Fin n, k ∈ fixedX → xs k = knownX k) ∧ (∀ k : Fin n, k ∈ fixedY → ys k = knownY k) · rw [if_pos compatible] calc _ = (if (∀ k : Fin n, k ∈ fixedX → xs k = knownX k) ∧ (ys j = ys j ∧ (∀ k : Fin n, k ∈ fixedY → ys k = knownY k)) then (G.repeat n).questionWeight xs ys • conditionedBobEffect G n S D answer ys else 0) := by apply Finset.sum_eq_single (ys j) · intro y _ different rw [if_neg] exact fun h => different h.2.1.symm · intro absent exact (absent (Finset.mem_univ (ys j))).elim _ = _ := if_pos ⟨compatible.1, ⟨rfl, compatible.2⟩⟩ · rw [if_neg compatible] apply Finset.sum_eq_zero intro y _ rw [if_neg] exact fun h => compatible ⟨h.1, h.2.2⟩ def exactJointPrefixAliceOperatorFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (answer : {j : Fin n // j ∈ D} → A) (knownX : Fin n → X) (knownY : Fin n → Y) : Matrix S.Alice S.Alice ℂ := (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ • exactJointPrefixAliceOperatorMass G n S D fixedX fixedY answer knownX knownY def exactJointPrefixBobOperatorFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (answer : {j : Fin n // j ∈ D} → B) (knownX : Fin n → X) (knownY : Fin n → Y) : Matrix S.Bob S.Bob ℂ := (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ • exactJointPrefixBobOperatorMass G n S D fixedX fixedY answer knownX knownY theorem exactJointPrefixAliceOperatorFilter_martingale (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixedX) (opposite_fixed : j ∈ fixedY) (answer : {k : Fin n // k ∈ D} → A) (knownX : Fin n → X) (knownY : Fin n → Y) (supported : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY ≠ 0) : (∑ x : X, G.conditionalXGivenY (knownY j) x • exactJointPrefixAliceOperatorFilter G n S D (insert j fixedX) fixedY answer (Function.update knownX j x) knownY) = exactJointPrefixAliceOperatorFilter G n S D fixedX fixedY answer knownX knownY := by classical unfold exactJointPrefixAliceOperatorFilter calc (∑ x : X, G.conditionalXGivenY (knownY j) x • ((exactJointPrefixQuestionMass G n (insert j fixedX) fixedY (Function.update knownX j x) knownY)⁻¹ • exactJointPrefixAliceOperatorMass G n S D (insert j fixedX) fixedY answer (Function.update knownX j x) knownY)) = ∑ x : X, (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ • exactJointPrefixAliceOperatorMass G n S D (insert j fixedX) fixedY answer (Function.update knownX j x) knownY := by apply Finset.sum_congr rfl intro x _ by_cases child_zero : exactJointPrefixQuestionMass G n (insert j fixedX) fixedY (Function.update knownX j x) knownY = 0 · have matrix_zero := exactJointPrefixAliceOperatorMass_zero_of_mass_zero G n S D (insert j fixedX) fixedY answer (Function.update knownX j x) knownY child_zero rw [matrix_zero] simp · have insertion := exactJointPrefixQuestionMass_insert_alice G n fixedX fixedY j fresh opposite_fixed knownX knownY x have conditional : exactJointPrefixQuestionMass G n (insert j fixedX) fixedY (Function.update knownX j x) knownY / exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = G.conditionalXGivenY (knownY j) x := by rw [insertion] field_simp have coefficient : G.conditionalXGivenY (knownY j) x * (exactJointPrefixQuestionMass G n (insert j fixedX) fixedY (Function.update knownX j x) knownY)⁻¹ = (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ := by rw [← conditional] field_simp rw [smul_smul, coefficient] _ = (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ • (∑ x : X, exactJointPrefixAliceOperatorMass G n S D (insert j fixedX) fixedY answer (Function.update knownX j x) knownY) := by rw [Finset.smul_sum] _ = (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ • exactJointPrefixAliceOperatorMass G n S D fixedX fixedY answer knownX knownY := by rw [exactJointPrefixAliceOperatorMass_sum_insert G n S D fixedX fixedY j fresh answer knownX knownY] theorem exactJointPrefixBobOperatorFilter_martingale (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (j : Fin n) (opposite_fixed : j ∈ fixedX) (fresh : j ∉ fixedY) (answer : {k : Fin n // k ∈ D} → B) (knownX : Fin n → X) (knownY : Fin n → Y) (supported : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY ≠ 0) : (∑ y : Y, G.conditionalYGivenX (knownX j) y • exactJointPrefixBobOperatorFilter G n S D fixedX (insert j fixedY) answer knownX (Function.update knownY j y)) = exactJointPrefixBobOperatorFilter G n S D fixedX fixedY answer knownX knownY := by classical unfold exactJointPrefixBobOperatorFilter calc (∑ y : Y, G.conditionalYGivenX (knownX j) y • ((exactJointPrefixQuestionMass G n fixedX (insert j fixedY) knownX (Function.update knownY j y))⁻¹ • exactJointPrefixBobOperatorMass G n S D fixedX (insert j fixedY) answer knownX (Function.update knownY j y))) = ∑ y : Y, (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ • exactJointPrefixBobOperatorMass G n S D fixedX (insert j fixedY) answer knownX (Function.update knownY j y) := by apply Finset.sum_congr rfl intro y _ by_cases child_zero : exactJointPrefixQuestionMass G n fixedX (insert j fixedY) knownX (Function.update knownY j y) = 0 · have matrix_zero := exactJointPrefixBobOperatorMass_zero_of_mass_zero G n S D fixedX (insert j fixedY) answer knownX (Function.update knownY j y) child_zero rw [matrix_zero] simp · have insertion := exactJointPrefixQuestionMass_insert_bob G n fixedX fixedY j opposite_fixed fresh knownX knownY y have conditional : exactJointPrefixQuestionMass G n fixedX (insert j fixedY) knownX (Function.update knownY j y) / exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = G.conditionalYGivenX (knownX j) y := by rw [insertion] field_simp have coefficient : G.conditionalYGivenX (knownX j) y * (exactJointPrefixQuestionMass G n fixedX (insert j fixedY) knownX (Function.update knownY j y))⁻¹ = (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ := by rw [← conditional] field_simp rw [smul_smul, coefficient] _ = (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ • (∑ y : Y, exactJointPrefixBobOperatorMass G n S D fixedX (insert j fixedY) answer knownX (Function.update knownY j y)) := by rw [Finset.smul_sum] _ = (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ • exactJointPrefixBobOperatorMass G n S D fixedX fixedY answer knownX knownY := by rw [exactJointPrefixBobOperatorMass_sum_insert G n S D fixedX fixedY j fresh answer knownX knownY] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactFairAliceQuestionMask {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : Finset (Fin n) := (D ∪ (exactLeft seed.coordinate seed.partition).image Subtype.val) ∪ (exactRightPrefix seed).image Subtype.val def exactFairBobQuestionMask {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : Finset (Fin n) := (D ∪ (exactRight seed.coordinate seed.partition).image Subtype.val) ∪ (exactLeftPrefix seed).image Subtype.val theorem exactRevealCode_eq_iff_fair_question_masks {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q q' : ExactFullQuestion X Y n) : exactRevealCode D seed q' = exactRevealCode D seed q ↔ (∀ j : Fin n, j ∈ exactFairAliceQuestionMask D seed → q'.1 j = q.1 j) ∧ (∀ j : Fin n, j ∈ exactFairBobQuestionMask D seed → q'.2 j = q.2 j) := by classical constructor · intro same have aliceD := congrArg (fun h : ExactRevealHistory X Y D seed => h.aliceConditioned) same have bobD := congrArg (fun h : ExactRevealHistory X Y D seed => h.bobConditioned) same have aliceL := congrArg (fun h : ExactRevealHistory X Y D seed => h.aliceLeft) same have bobR := congrArg (fun h : ExactRevealHistory X Y D seed => h.bobRight) same have bobLP := congrArg (fun h : ExactRevealHistory X Y D seed => h.bobLeftPrefix) same have aliceRP := congrArg (fun h : ExactRevealHistory X Y D seed => h.aliceRightPrefix) same constructor · intro j hj change j ∈ (D ∪ (exactLeft seed.coordinate seed.partition).image Subtype.val) ∪ (exactRightPrefix seed).image Subtype.val at hj rcases Finset.mem_union.mp hj with hmain | hprefix · rcases Finset.mem_union.mp hmain with hD | hleft · exact congrFun aliceD ⟨j, hD⟩ · obtain ⟨k, hk, samej⟩ := Finset.mem_image.mp hleft subst j exact congrFun aliceL ⟨k, hk⟩ · obtain ⟨k, hk, samej⟩ := Finset.mem_image.mp hprefix subst j exact congrFun aliceRP ⟨k, hk⟩ · intro j hj change j ∈ (D ∪ (exactRight seed.coordinate seed.partition).image Subtype.val) ∪ (exactLeftPrefix seed).image Subtype.val at hj rcases Finset.mem_union.mp hj with hmain | hprefix · rcases Finset.mem_union.mp hmain with hD | hright · exact congrFun bobD ⟨j, hD⟩ · obtain ⟨k, hk, samej⟩ := Finset.mem_image.mp hright subst j exact congrFun bobR ⟨k, hk⟩ · obtain ⟨k, hk, samej⟩ := Finset.mem_image.mp hprefix subst j exact congrFun bobLP ⟨k, hk⟩ · rintro ⟨alice, bob⟩ unfold exactRevealCode congr 1 · funext j exact alice j.val <| Finset.mem_union_left _ <| Finset.mem_union_left _ j.property · funext j exact bob j.val <| Finset.mem_union_left _ <| Finset.mem_union_left _ j.property · funext j exact alice j.val.val <| Finset.mem_union_left _ <| Finset.mem_union_right _ <| Finset.mem_image.mpr ⟨j.val, j.property, rfl⟩ · funext j exact bob j.val.val <| Finset.mem_union_left _ <| Finset.mem_union_right _ <| Finset.mem_image.mpr ⟨j.val, j.property, rfl⟩ · funext j exact bob j.val.val <| Finset.mem_union_right _ <| Finset.mem_image.mpr ⟨j.val, j.property, rfl⟩ · funext j exact alice j.val.val <| Finset.mem_union_right _ <| Finset.mem_image.mpr ⟨j.val, j.property, rfl⟩ theorem exactAliceQuestionMass_eq_jointPrefixQuestionMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) : exactAliceQuestionMass G n D seed (exactRevealCode D seed q) (q.1 seed.coordinate.val) = exactJointPrefixQuestionMass G n (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (exactFairBobQuestionMask D seed) q.1 q.2 := by classical unfold exactAliceQuestionMass exactJointPrefixQuestionMass rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ have same : (exactRevealCode D seed (xs, ys) = exactRevealCode D seed q ∧ xs seed.coordinate.val = q.1 seed.coordinate.val) ↔ ((∀ j : Fin n, j ∈ insert seed.coordinate.val (exactFairAliceQuestionMask D seed) → xs j = q.1 j) ∧ (∀ j : Fin n, j ∈ exactFairBobQuestionMask D seed → ys j = q.2 j)) := by constructor · rintro ⟨history, distinguished⟩ obtain ⟨alice, bob⟩ := (exactRevealCode_eq_iff_fair_question_masks D seed q (xs, ys)).mp history refine ⟨?_, bob⟩ intro j hj rcases Finset.mem_insert.mp hj with samej | hj · subst j exact distinguished · exact alice j hj · rintro ⟨alice, bob⟩ refine ⟨(exactRevealCode_eq_iff_fair_question_masks D seed q (xs, ys)).mpr ⟨?_, bob⟩, ?_⟩ · intro j hj exact alice j (Finset.mem_insert_of_mem hj) · exact alice seed.coordinate.val (Finset.mem_insert_self _ _) by_cases compatible : (∀ j : Fin n, j ∈ insert seed.coordinate.val (exactFairAliceQuestionMask D seed) → xs j = q.1 j) ∧ (∀ j : Fin n, j ∈ exactFairBobQuestionMask D seed → ys j = q.2 j) · rw [if_pos (same.mpr compatible), if_pos compatible] rfl · rw [if_neg (fun h => compatible (same.mp h)), if_neg compatible] theorem exactBobQuestionMass_eq_jointPrefixQuestionMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) : exactBobQuestionMass G n D seed (exactRevealCode D seed q) (q.2 seed.coordinate.val) = exactJointPrefixQuestionMass G n (exactFairAliceQuestionMask D seed) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) q.1 q.2 := by classical unfold exactBobQuestionMass exactJointPrefixQuestionMass rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ have same : (exactRevealCode D seed (xs, ys) = exactRevealCode D seed q ∧ ys seed.coordinate.val = q.2 seed.coordinate.val) ↔ ((∀ j : Fin n, j ∈ exactFairAliceQuestionMask D seed → xs j = q.1 j) ∧ (∀ j : Fin n, j ∈ insert seed.coordinate.val (exactFairBobQuestionMask D seed) → ys j = q.2 j)) := by constructor · rintro ⟨history, distinguished⟩ obtain ⟨alice, bob⟩ := (exactRevealCode_eq_iff_fair_question_masks D seed q (xs, ys)).mp history refine ⟨alice, ?_⟩ intro j hj rcases Finset.mem_insert.mp hj with samej | hj · subst j exact distinguished · exact bob j hj · rintro ⟨alice, bob⟩ refine ⟨(exactRevealCode_eq_iff_fair_question_masks D seed q (xs, ys)).mpr ⟨alice, ?_⟩, ?_⟩ · intro j hj exact bob j (Finset.mem_insert_of_mem hj) · exact bob seed.coordinate.val (Finset.mem_insert_self _ _) by_cases compatible : (∀ j : Fin n, j ∈ exactFairAliceQuestionMask D seed → xs j = q.1 j) ∧ (∀ j : Fin n, j ∈ insert seed.coordinate.val (exactFairBobQuestionMask D seed) → ys j = q.2 j) · rw [if_pos (same.mpr compatible), if_pos compatible] rfl · rw [if_neg (fun h => compatible (same.mp h)), if_neg compatible] theorem exactAliceQuestionFilter_eq_jointPrefixOperatorFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) (answer : {j : Fin n // j ∈ D} → A) : exactAliceQuestionFilter G n S D seed (exactRevealCode D seed q) answer (q.1 seed.coordinate.val) = exactJointPrefixAliceOperatorFilter G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (exactFairBobQuestionMask D seed) answer q.1 q.2 := by classical unfold exactAliceQuestionFilter rw [exactAliceQuestionMass_eq_jointPrefixQuestionMass G n D seed q] unfold exactJointPrefixAliceOperatorFilter exactJointPrefixAliceOperatorMass rw [Fintype.sum_prod_type] simp only [Finset.smul_sum] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ have same : (exactRevealCode D seed (xs, ys) = exactRevealCode D seed q ∧ xs seed.coordinate.val = q.1 seed.coordinate.val) ↔ ((∀ j : Fin n, j ∈ insert seed.coordinate.val (exactFairAliceQuestionMask D seed) → xs j = q.1 j) ∧ (∀ j : Fin n, j ∈ exactFairBobQuestionMask D seed → ys j = q.2 j)) := by constructor · rintro ⟨history, distinguished⟩ obtain ⟨alice, bob⟩ := (exactRevealCode_eq_iff_fair_question_masks D seed q (xs, ys)).mp history refine ⟨?_, bob⟩ intro j hj rcases Finset.mem_insert.mp hj with samej | hj · subst j exact distinguished · exact alice j hj · rintro ⟨alice, bob⟩ refine ⟨(exactRevealCode_eq_iff_fair_question_masks D seed q (xs, ys)).mpr ⟨?_, bob⟩, ?_⟩ · intro j hj exact alice j (Finset.mem_insert_of_mem hj) · exact alice seed.coordinate.val (Finset.mem_insert_self _ _) by_cases compatible : (∀ j : Fin n, j ∈ insert seed.coordinate.val (exactFairAliceQuestionMask D seed) → xs j = q.1 j) ∧ (∀ j : Fin n, j ∈ exactFairBobQuestionMask D seed → ys j = q.2 j) · rw [if_pos (same.mpr compatible), if_pos compatible, smul_smul] unfold exactPriorQuestionWeight rw [div_eq_mul_inv] congr 1 ring · rw [if_neg (fun h => compatible (same.mp h)), if_neg compatible, smul_zero] theorem exactBobQuestionFilter_eq_jointPrefixOperatorFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) (answer : {j : Fin n // j ∈ D} → B) : exactBobQuestionFilter G n S D seed (exactRevealCode D seed q) answer (q.2 seed.coordinate.val) = exactJointPrefixBobOperatorFilter G n S D (exactFairAliceQuestionMask D seed) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) answer q.1 q.2 := by classical unfold exactBobQuestionFilter rw [exactBobQuestionMass_eq_jointPrefixQuestionMass G n D seed q] unfold exactJointPrefixBobOperatorFilter exactJointPrefixBobOperatorMass rw [Fintype.sum_prod_type] simp only [Finset.smul_sum] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ have same : (exactRevealCode D seed (xs, ys) = exactRevealCode D seed q ∧ ys seed.coordinate.val = q.2 seed.coordinate.val) ↔ ((∀ j : Fin n, j ∈ exactFairAliceQuestionMask D seed → xs j = q.1 j) ∧ (∀ j : Fin n, j ∈ insert seed.coordinate.val (exactFairBobQuestionMask D seed) → ys j = q.2 j)) := by constructor · rintro ⟨history, distinguished⟩ obtain ⟨alice, bob⟩ := (exactRevealCode_eq_iff_fair_question_masks D seed q (xs, ys)).mp history refine ⟨alice, ?_⟩ intro j hj rcases Finset.mem_insert.mp hj with samej | hj · subst j exact distinguished · exact bob j hj · rintro ⟨alice, bob⟩ refine ⟨(exactRevealCode_eq_iff_fair_question_masks D seed q (xs, ys)).mpr ⟨alice, ?_⟩, ?_⟩ · intro j hj exact bob j (Finset.mem_insert_of_mem hj) · exact bob seed.coordinate.val (Finset.mem_insert_self _ _) by_cases compatible : (∀ j : Fin n, j ∈ exactFairAliceQuestionMask D seed → xs j = q.1 j) ∧ (∀ j : Fin n, j ∈ insert seed.coordinate.val (exactFairBobQuestionMask D seed) → ys j = q.2 j) · rw [if_pos (same.mpr compatible), if_pos compatible, smul_smul] unfold exactPriorQuestionWeight rw [div_eq_mul_inv] congr 1 ring · rw [if_neg (fun h => compatible (same.mp h)), if_neg compatible, smul_zero] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2600000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactJointPrefixAliceOperatorMass_eq_sum_bobMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (answer : {j : Fin n // j ∈ D} → A) (knownX : Fin n → X) (knownY : Fin n → Y) : exactJointPrefixAliceOperatorMass G n S D fixedX fixedY answer knownX knownY = ∑ xs : Fin n → X, if ∀ j : Fin n, j ∈ fixedX → xs j = knownX j then exactFixedBobQuestionMass G n fixedY xs knownY • conditionedAliceEffect G n S D answer xs else 0 := by classical unfold exactJointPrefixAliceOperatorMass apply Finset.sum_congr rfl intro xs _ by_cases compatible : ∀ j : Fin n, j ∈ fixedX → xs j = knownX j · rw [if_pos compatible] unfold exactFixedBobQuestionMass rw [Finset.sum_smul] apply Finset.sum_congr rfl intro ys _ by_cases bob_compatible : ∀ j : Fin n, j ∈ fixedY → ys j = knownY j · rw [if_pos ⟨compatible, bob_compatible⟩, if_pos bob_compatible] · rw [if_neg (fun h => bob_compatible h.2), if_neg bob_compatible, zero_smul] · rw [if_neg compatible] apply Finset.sum_eq_zero intro ys _ rw [if_neg] exact fun h => compatible h.1 theorem exactJointPrefixBobOperatorMass_eq_sum_aliceMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (answer : {j : Fin n // j ∈ D} → B) (knownX : Fin n → X) (knownY : Fin n → Y) : exactJointPrefixBobOperatorMass G n S D fixedX fixedY answer knownX knownY = ∑ ys : Fin n → Y, if ∀ j : Fin n, j ∈ fixedY → ys j = knownY j then exactFixedAliceQuestionMass G n fixedX knownX ys • conditionedBobEffect G n S D answer ys else 0 := by classical unfold exactJointPrefixBobOperatorMass rw [Finset.sum_comm] apply Finset.sum_congr rfl intro ys _ by_cases compatible : ∀ j : Fin n, j ∈ fixedY → ys j = knownY j · rw [if_pos compatible] unfold exactFixedAliceQuestionMass rw [Finset.sum_smul] apply Finset.sum_congr rfl intro xs _ by_cases alice_compatible : ∀ j : Fin n, j ∈ fixedX → xs j = knownX j · rw [if_pos ⟨alice_compatible, compatible⟩, if_pos alice_compatible] · rw [if_neg (fun h => alice_compatible h.1), if_neg alice_compatible, zero_smul] · rw [if_neg compatible] apply Finset.sum_eq_zero intro xs _ rw [if_neg] exact fun h => compatible h.2 theorem exactJointPrefixAliceOperatorMass_insert_bob (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (j : Fin n) (opposite_fixed : j ∈ fixedX) (fresh : j ∉ fixedY) (answer : {k : Fin n // k ∈ D} → A) (knownX : Fin n → X) (knownY : Fin n → Y) (y : Y) : exactJointPrefixAliceOperatorMass G n S D fixedX (insert j fixedY) answer knownX (Function.update knownY j y) = G.conditionalYGivenX (knownX j) y • exactJointPrefixAliceOperatorMass G n S D fixedX fixedY answer knownX knownY := by classical rw [exactJointPrefixAliceOperatorMass_eq_sum_bobMass, exactJointPrefixAliceOperatorMass_eq_sum_bobMass, Finset.smul_sum] apply Finset.sum_congr rfl intro xs _ by_cases compatible : ∀ k : Fin n, k ∈ fixedX → xs k = knownX k · rw [if_pos compatible, if_pos compatible, exactFixedBobQuestionMass_insert G n fixedY j fresh xs knownY y, compatible j opposite_fixed, smul_smul] · rw [if_neg compatible, if_neg compatible, smul_zero] theorem exactJointPrefixBobOperatorMass_insert_alice (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixedX) (opposite_fixed : j ∈ fixedY) (answer : {k : Fin n // k ∈ D} → B) (knownX : Fin n → X) (knownY : Fin n → Y) (x : X) : exactJointPrefixBobOperatorMass G n S D (insert j fixedX) fixedY answer (Function.update knownX j x) knownY = G.conditionalXGivenY (knownY j) x • exactJointPrefixBobOperatorMass G n S D fixedX fixedY answer knownX knownY := by classical rw [exactJointPrefixBobOperatorMass_eq_sum_aliceMass, exactJointPrefixBobOperatorMass_eq_sum_aliceMass, Finset.smul_sum] apply Finset.sum_congr rfl intro ys _ by_cases compatible : ∀ k : Fin n, k ∈ fixedY → ys k = knownY k · rw [if_pos compatible, if_pos compatible, exactFixedAliceQuestionMass_insert G n fixedX j fresh knownX ys x, compatible j opposite_fixed, smul_smul] · rw [if_neg compatible, if_neg compatible, smul_zero] theorem exactJointPrefixAliceOperatorFilter_insert_bob (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (j : Fin n) (opposite_fixed : j ∈ fixedX) (fresh : j ∉ fixedY) (answer : {k : Fin n // k ∈ D} → A) (knownX : Fin n → X) (knownY : Fin n → Y) (y : Y) (edge : G.conditionalYGivenX (knownX j) y ≠ 0) : exactJointPrefixAliceOperatorFilter G n S D fixedX (insert j fixedY) answer knownX (Function.update knownY j y) = exactJointPrefixAliceOperatorFilter G n S D fixedX fixedY answer knownX knownY := by unfold exactJointPrefixAliceOperatorFilter rw [exactJointPrefixQuestionMass_insert_bob G n fixedX fixedY j opposite_fixed fresh knownX knownY y, exactJointPrefixAliceOperatorMass_insert_bob G n S D fixedX fixedY j opposite_fixed fresh answer knownX knownY y, smul_smul] have coefficient : (G.conditionalYGivenX (knownX j) y * exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ * G.conditionalYGivenX (knownX j) y = (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ := by by_cases zero : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = 0 · simp [zero] · field_simp rw [coefficient] theorem exactJointPrefixBobOperatorFilter_insert_alice (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D fixedX fixedY : Finset (Fin n)) (j : Fin n) (fresh : j ∉ fixedX) (opposite_fixed : j ∈ fixedY) (answer : {k : Fin n // k ∈ D} → B) (knownX : Fin n → X) (knownY : Fin n → Y) (x : X) (edge : G.conditionalXGivenY (knownY j) x ≠ 0) : exactJointPrefixBobOperatorFilter G n S D (insert j fixedX) fixedY answer (Function.update knownX j x) knownY = exactJointPrefixBobOperatorFilter G n S D fixedX fixedY answer knownX knownY := by unfold exactJointPrefixBobOperatorFilter rw [exactJointPrefixQuestionMass_insert_alice G n fixedX fixedY j fresh opposite_fixed knownX knownY x, exactJointPrefixBobOperatorMass_insert_alice G n S D fixedX fixedY j fresh opposite_fixed answer knownX knownY x, smul_smul] have coefficient : (G.conditionalXGivenY (knownY j) x * exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ * G.conditionalXGivenY (knownY j) x = (exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY)⁻¹ := by by_cases zero : exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY = 0 · simp [zero] · field_simp rw [coefficient] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem groupedMass_expectation {Ω T : Type*} [Fintype Ω] [Fintype T] [DecidableEq T] (code : Ω → T) (weight : Ω → ℝ) (f : T → ℝ) : (∑ t : T, groupedMass code weight t * f t) = ∑ outcome : Ω, weight outcome * f (code outcome) := by classical unfold groupedMass simp only [Finset.sum_filter, Finset.sum_mul] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro outcome _ rw [Finset.sum_eq_single (code outcome)] · simp · intro t _ different simp [different.symm] · simp theorem exactJointQuestionMass_eq_groupedMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (x : X) (y : Y) : exactJointQuestionMass G n D seed history x y = groupedMass (fun q : ExactFullQuestion X Y n => (exactRevealCode D seed q, q.1 seed.coordinate.val, q.2 seed.coordinate.val)) (exactPriorQuestionWeight G n) (history, x, y) := by classical unfold exactJointQuestionMass groupedMass rw [Finset.sum_filter] apply Finset.sum_congr rfl intro q _ by_cases compatible : exactRevealCode D seed q = history ∧ q.1 seed.coordinate.val = x ∧ q.2 seed.coordinate.val = y · rw [if_pos compatible, if_pos] exact Prod.ext compatible.1 (Prod.ext compatible.2.1 compatible.2.2) · rw [if_neg compatible, if_neg] intro h exact compatible ⟨congrArg (fun t => t.1) h, congrArg (fun t => t.2.1) h, congrArg (fun t => t.2.2) h⟩ theorem exactFairJointQuestionExpectation_reindex (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (f : ExactRevealHistory X Y D seed → X → Y → ℝ) : (∑ history : ExactRevealHistory X Y D seed, ∑ x : X, ∑ y : Y, exactRevealMass G n D seed history * G.questionWeight x y * f history x y) = ∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q * f (exactRevealCode D seed q) (q.1 seed.coordinate.val) (q.2 seed.coordinate.val) := by classical let code : ExactFullQuestion X Y n → ExactRevealHistory X Y D seed × X × Y := fun q => (exactRevealCode D seed q, q.1 seed.coordinate.val, q.2 seed.coordinate.val) have expectation := groupedMass_expectation code (exactPriorQuestionWeight G n) (fun t : ExactRevealHistory X Y D seed × X × Y => f t.1 t.2.1 t.2.2) simp only [Fintype.sum_prod_type] at expectation calc (∑ history : ExactRevealHistory X Y D seed, ∑ x : X, ∑ y : Y, exactRevealMass G n D seed history * G.questionWeight x y * f history x y) = ∑ history : ExactRevealHistory X Y D seed, ∑ x : X, ∑ y : Y, groupedMass code (exactPriorQuestionWeight G n) (history, x, y) * f history x y := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [← exactJointQuestionMass_eq_groupedMass] rw [exactJointQuestionMass_eq_reveal_mul_question] _ = _ := by simpa only [Fintype.sum_prod_type, code] using expectation end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactFairAliceHistoryHighOperatorPotential_eq_joint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairAliceHistoryHighOperatorPotential G n S D r = ∑ x : X, ∑ y : Y, G.questionWeight x y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by classical unfold exactFairAliceHistoryHighOperatorPotential simp only [map_sum, map_smul, LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul] calc (∑ y : Y, G.marginalY y * (∑ x : X, G.conditionalXGivenY y x * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y))) = ∑ y : Y, ∑ x : X, (G.marginalY y * G.conditionalXGivenY y x) * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by simp only [Finset.mul_sum] apply Finset.sum_congr rfl intro y _ apply Finset.sum_congr rfl intro x _ ring _ = ∑ y : Y, ∑ x : X, G.questionWeight x y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by apply Finset.sum_congr rfl intro y _ apply Finset.sum_congr rfl intro x _ rw [← G.marginalY_mul_conditionalXGivenY x y] _ = _ := Finset.sum_comm theorem exactFairBobHistoryHighOperatorPotential_eq_joint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairBobHistoryHighOperatorPotential G n S D r = ∑ x : X, ∑ y : Y, G.questionWeight x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) := by classical unfold exactFairBobHistoryHighOperatorPotential simp only [map_sum, map_smul, smul_eq_mul] apply Finset.sum_congr rfl intro x _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro y _ rw [← G.marginalX_mul_conditionalYGivenX x y] ring theorem exactFairAliceHistoryLowOperatorPotential_eq_joint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairAliceHistoryLowOperatorPotential G n S D r = ∑ x : X, ∑ y : Y, G.questionWeight x y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by classical unfold exactFairAliceHistoryLowOperatorPotential calc (∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) = ∑ y : Y, ∑ x : X, G.questionWeight x y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y)) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by apply Finset.sum_congr rfl intro y _ unfold Game.marginalY rw [Finset.sum_mul] _ = _ := Finset.sum_comm theorem exactFairBobHistoryLowOperatorPotential_eq_joint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactFairBobHistoryLowOperatorPotential G n S D r = ∑ x : X, ∑ y : Y, G.questionWeight x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x)) := by classical unfold exactFairBobHistoryLowOperatorPotential apply Finset.sum_congr rfl intro x _ unfold Game.marginalX rw [Finset.sum_mul] theorem exactFairAcceptedJointStatistic_reindex (G : Game X Y A B) (n : ℕ) (_ : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (f : ExactRevealHistory X Y D seed → ({j : Fin n // j ∈ D} → A) → ({j : Fin n // j ∈ D} → B) → X → Y → ℝ) : (∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ x : X, ∑ y : Y, G.questionWeight x y * f history aliceAnswer bobAnswer x y) else 0) = ∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q * (∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ then f (exactRevealCode D seed q) aliceAnswer bobAnswer (q.1 seed.coordinate.val) (q.2 seed.coordinate.val) else 0) := by classical have expectation := exactFairJointQuestionExpectation_reindex G n D seed (fun history x y => ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then f history aliceAnswer bobAnswer x y else 0) calc (∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ x : X, ∑ y : Y, G.questionWeight x y * f history aliceAnswer bobAnswer x y) else 0) = ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, ∑ x : X, ∑ y : Y, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * G.questionWeight x y * f history aliceAnswer bobAnswer x y else 0 := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ · simp only [if_pos accepted, Finset.mul_sum] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ ring · simp [accepted] _ = ∑ history : ExactRevealHistory X Y D seed, ∑ x : X, ∑ y : Y, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * G.questionWeight x y * f history aliceAnswer bobAnswer x y else 0 := by apply Finset.sum_congr rfl intro history _ exact finite_sum_four_swap _ _ = ∑ history : ExactRevealHistory X Y D seed, ∑ x : X, ∑ y : Y, exactRevealMass G n D seed history * G.questionWeight x y * (∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then f history aliceAnswer bobAnswer x y else 0) := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro aliceAnswer _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro bobAnswer _ split <;> simp_all _ = _ := expectation end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3400000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseAliceHighQuestionPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseBobMarkerDecode side context marker ∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q * (∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ then bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D seed (exactRevealCode D seed q) aliceAnswer (q.1 seed.coordinate.val))) (exactBobQuestionFilter G n S D seed (exactRevealCode D seed q) bobAnswer (q.2 seed.coordinate.val)) else 0) def exactReverseAliceLowQuestionPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseBobMarkerDecode side context marker ∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q * (∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ then bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D seed (exactRevealCode D seed q) aliceAnswer (q.2 seed.coordinate.val))) (exactBobQuestionFilter G n S D seed (exactRevealCode D seed q) bobAnswer (q.2 seed.coordinate.val)) else 0) def exactReverseBobHighQuestionPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseAliceMarkerDecode side context marker ∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q * (∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ then bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D seed (exactRevealCode D seed q) aliceAnswer (q.1 seed.coordinate.val)) (cfc (fun z : ℝ => z * Real.log z) (exactBobQuestionFilter G n S D seed (exactRevealCode D seed q) bobAnswer (q.2 seed.coordinate.val))) else 0) def exactReverseBobLowQuestionPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseAliceMarkerDecode side context marker ∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q * (∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ then bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D seed (exactRevealCode D seed q) aliceAnswer (q.1 seed.coordinate.val)) (cfc (fun z : ℝ => z * Real.log z) (exactBobMeanFilter G n S D seed (exactRevealCode D seed q) bobAnswer (q.1 seed.coordinate.val))) else 0) theorem exactReverseAliceHighOperatorPotential_eq_question (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceFilterHighOperatorPotential G n S D side context marker = exactReverseAliceHighQuestionPotential G n S D side context marker := by classical unfold exactReverseAliceFilterHighOperatorPotential exactReverseAliceHighQuestionPotential dsimp only calc (∑ history : ExactRevealHistory X Y D (exactReverseBobMarkerDecode side context marker), ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D (exactReverseBobMarkerDecode side context marker) history * exactFairAliceHistoryHighOperatorPotential G n S D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ else 0) = ∑ history : ExactRevealHistory X Y D (exactReverseBobMarkerDecode side context marker), ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D (exactReverseBobMarkerDecode side context marker) history * (∑ x : X, ∑ y : Y, G.questionWeight x y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D (exactReverseBobMarkerDecode side context marker) history aliceAnswer x)) (exactBobQuestionFilter G n S D (exactReverseBobMarkerDecode side context marker) history bobAnswer y)) else 0 := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ split · rw [exactFairAliceHistoryHighOperatorPotential_eq_joint] · rfl _ = _ := exactFairAcceptedJointStatistic_reindex G n S D (exactReverseBobMarkerDecode side context marker) (fun history aliceAnswer bobAnswer x y => bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceQuestionFilter G n S D (exactReverseBobMarkerDecode side context marker) history aliceAnswer x)) (exactBobQuestionFilter G n S D (exactReverseBobMarkerDecode side context marker) history bobAnswer y)) theorem exactReverseAliceLowOperatorPotential_eq_question (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceFilterLowOperatorPotential G n S D side context marker = exactReverseAliceLowQuestionPotential G n S D side context marker := by classical unfold exactReverseAliceFilterLowOperatorPotential exactReverseAliceLowQuestionPotential dsimp only calc (∑ history : ExactRevealHistory X Y D (exactReverseBobMarkerDecode side context marker), ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D (exactReverseBobMarkerDecode side context marker) history * exactFairAliceHistoryLowOperatorPotential G n S D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ else 0) = ∑ history : ExactRevealHistory X Y D (exactReverseBobMarkerDecode side context marker), ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D (exactReverseBobMarkerDecode side context marker) history * (∑ x : X, ∑ y : Y, G.questionWeight x y * bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D (exactReverseBobMarkerDecode side context marker) history aliceAnswer y)) (exactBobQuestionFilter G n S D (exactReverseBobMarkerDecode side context marker) history bobAnswer y)) else 0 := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ split · rw [exactFairAliceHistoryLowOperatorPotential_eq_joint] · rfl _ = _ := exactFairAcceptedJointStatistic_reindex G n S D (exactReverseBobMarkerDecode side context marker) (fun history aliceAnswer bobAnswer x y => bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactAliceMeanFilter G n S D (exactReverseBobMarkerDecode side context marker) history aliceAnswer y)) (exactBobQuestionFilter G n S D (exactReverseBobMarkerDecode side context marker) history bobAnswer y)) theorem exactReverseBobHighOperatorPotential_eq_question (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobFilterHighOperatorPotential G n S D side context marker = exactReverseBobHighQuestionPotential G n S D side context marker := by classical unfold exactReverseBobFilterHighOperatorPotential exactReverseBobHighQuestionPotential dsimp only calc (∑ history : ExactRevealHistory X Y D (exactReverseAliceMarkerDecode side context marker), ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D (exactReverseAliceMarkerDecode side context marker) history * exactFairBobHistoryHighOperatorPotential G n S D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ else 0) = ∑ history : ExactRevealHistory X Y D (exactReverseAliceMarkerDecode side context marker), ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D (exactReverseAliceMarkerDecode side context marker) history * (∑ x : X, ∑ y : Y, G.questionWeight x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D (exactReverseAliceMarkerDecode side context marker) history aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobQuestionFilter G n S D (exactReverseAliceMarkerDecode side context marker) history bobAnswer y))) else 0 := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ split · rw [exactFairBobHistoryHighOperatorPotential_eq_joint] · rfl _ = _ := exactFairAcceptedJointStatistic_reindex G n S D (exactReverseAliceMarkerDecode side context marker) (fun history aliceAnswer bobAnswer x y => bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D (exactReverseAliceMarkerDecode side context marker) history aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobQuestionFilter G n S D (exactReverseAliceMarkerDecode side context marker) history bobAnswer y))) theorem exactReverseBobLowOperatorPotential_eq_question (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobFilterLowOperatorPotential G n S D side context marker = exactReverseBobLowQuestionPotential G n S D side context marker := by classical unfold exactReverseBobFilterLowOperatorPotential exactReverseBobLowQuestionPotential dsimp only calc (∑ history : ExactRevealHistory X Y D (exactReverseAliceMarkerDecode side context marker), ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D (exactReverseAliceMarkerDecode side context marker) history * exactFairBobHistoryLowOperatorPotential G n S D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ else 0) = ∑ history : ExactRevealHistory X Y D (exactReverseAliceMarkerDecode side context marker), ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D (exactReverseAliceMarkerDecode side context marker) history * (∑ x : X, ∑ y : Y, G.questionWeight x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D (exactReverseAliceMarkerDecode side context marker) history aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobMeanFilter G n S D (exactReverseAliceMarkerDecode side context marker) history bobAnswer x))) else 0 := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ split · rw [exactFairBobHistoryLowOperatorPotential_eq_joint] · rfl _ = _ := exactFairAcceptedJointStatistic_reindex G n S D (exactReverseAliceMarkerDecode side context marker) (fun history aliceAnswer bobAnswer x y => bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D (exactReverseAliceMarkerDecode side context marker) history aliceAnswer x) (cfc (fun z : ℝ => z * Real.log z) (exactBobMeanFilter G n S D (exactReverseAliceMarkerDecode side context marker) history bobAnswer x))) theorem exactReverseAliceFilterOperatorMarkerEntropy_eq_question_sub (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceFilterOperatorMarkerEntropy G n S D side context marker = exactReverseAliceHighQuestionPotential G n S D side context marker - exactReverseAliceLowQuestionPotential G n S D side context marker := by rw [exactReverseAliceFilterOperatorMarkerEntropy_eq_sub, exactReverseAliceHighOperatorPotential_eq_question, exactReverseAliceLowOperatorPotential_eq_question] theorem exactReverseBobFilterOperatorMarkerEntropy_eq_question_sub (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobFilterOperatorMarkerEntropy G n S D side context marker = exactReverseBobHighQuestionPotential G n S D side context marker - exactReverseBobLowQuestionPotential G n S D side context marker := by rw [exactReverseBobFilterOperatorMarkerEntropy_eq_sub, exactReverseBobHighOperatorPotential_eq_question, exactReverseBobLowOperatorPotential_eq_question] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseContextQuestionPrefix {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (k : ℕ) : Finset (Fin n) := (Finset.univ.filter (fun j : {j : SourceRemainingCoordinate D // j ∈ side} => (context.sideRank j).val < k)).image (fun j => j.val.val) def exactReverseAlicePrefixXMask {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (k : ℕ) : Finset (Fin n) := (D ∪ context.otherSide.image Subtype.val) ∪ exactReverseContextQuestionPrefix D side context k def exactReverseAliceFixedYMask {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) : Finset (Fin n) := (D ∪ side.image Subtype.val) ∪ (exactReverseContextOtherPrefix context).image Subtype.val def exactReverseBobFixedXMask {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) : Finset (Fin n) := (D ∪ side.image Subtype.val) ∪ (exactReverseContextOtherPrefix context).image Subtype.val def exactReverseBobPrefixYMask {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (k : ℕ) : Finset (Fin n) := (D ∪ context.otherSide.image Subtype.val) ∪ exactReverseContextQuestionPrefix D side context k end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactReverseContextQuestionPrefix_eq_image {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseContextQuestionPrefix D side context marker.val = (exactReverseContextPrefixBefore context marker).image Subtype.val := by classical unfold exactReverseContextQuestionPrefix exactReverseContextPrefixBefore exactOrderedSidePrefix rw [Finset.image_image] rfl theorem exactReverseAlicePrefixXMask_eq_fair {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : exactReverseAlicePrefixXMask D (exactReverseRightSide seed) (exactReverseBobContext seed) (((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩).val) = exactFairAliceQuestionMask D seed := by classical unfold exactReverseAlicePrefixXMask exactFairAliceQuestionMask rw [exactReverseContextQuestionPrefix_eq_image, exactReverseBobContext_prefix_before_marked] rfl theorem exactReverseAliceFixedYMask_eq_insert_fair {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : exactReverseAliceFixedYMask D (exactReverseRightSide seed) (exactReverseBobContext seed) = insert seed.coordinate.val (exactFairBobQuestionMask D seed) := by classical unfold exactReverseAliceFixedYMask exactFairBobQuestionMask rw [exactReverseBobContext_otherPrefix] unfold exactReverseRightSide rw [Finset.image_insert] ext j simp only [Finset.mem_union, Finset.mem_insert] tauto theorem exactReverseBobFixedXMask_eq_insert_fair {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : exactReverseBobFixedXMask D (exactReverseLeftSide seed) (exactReverseAliceContext seed) = insert seed.coordinate.val (exactFairAliceQuestionMask D seed) := by classical unfold exactReverseBobFixedXMask exactFairAliceQuestionMask rw [exactReverseAliceContext_otherPrefix] unfold exactReverseLeftSide rw [Finset.image_insert] ext j simp only [Finset.mem_union, Finset.mem_insert] tauto theorem exactReverseBobPrefixYMask_eq_fair {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : exactReverseBobPrefixYMask D (exactReverseLeftSide seed) (exactReverseAliceContext seed) (((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩).val) = exactFairBobQuestionMask D seed := by classical unfold exactReverseBobPrefixYMask exactFairBobQuestionMask rw [exactReverseContextQuestionPrefix_eq_image, exactReverseAliceContext_prefix_before_marked] rfl end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactReverseContextQuestionPrefix_succ {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseContextQuestionPrefix D side context (marker.val + 1) = insert (context.sideRank.symm marker).val.val (exactReverseContextQuestionPrefix D side context marker.val) := by classical ext j constructor · intro member obtain ⟨a, ha, equation⟩ := Finset.mem_image.mp member have lower := (Finset.mem_filter.mp ha).2 have below : (context.sideRank a).val ≤ marker.val := Nat.lt_succ_iff.mp (by simpa [Nat.succ_eq_add_one] using lower) rcases Nat.lt_or_eq_of_le below with earlier | same_rank · apply Finset.mem_insert_of_mem exact Finset.mem_image.mpr ⟨a, Finset.mem_filter.mpr ⟨Finset.mem_univ a, earlier⟩, equation⟩ · have same : context.sideRank a = marker := Fin.ext same_rank have position : a = context.sideRank.symm marker := by apply context.sideRank.injective simpa using same subst a exact Finset.mem_insert.mpr (Or.inl equation.symm) · intro member rcases Finset.mem_insert.mp member with marked | earlier · subst j apply Finset.mem_image.mpr refine ⟨context.sideRank.symm marker, ?_, rfl⟩ apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _, ?_⟩ simp · obtain ⟨a, ha, equation⟩ := Finset.mem_image.mp earlier apply Finset.mem_image.mpr refine ⟨a, ?_, equation⟩ apply Finset.mem_filter.mpr exact ⟨Finset.mem_univ a, Nat.lt_trans (Finset.mem_filter.mp ha).2 (Nat.lt_succ_self marker.val)⟩ theorem exactFairAliceQuestionMask_coordinate_not_mem {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : seed.coordinate.val ∉ exactFairAliceQuestionMask D seed := by classical intro member change seed.coordinate.val ∈ (D ∪ (exactLeft seed.coordinate seed.partition).image Subtype.val) ∪ (exactRightPrefix seed).image Subtype.val at member rcases Finset.mem_union.mp member with main | exposed · rcases Finset.mem_union.mp main with conditioned | left · exact (Finset.mem_sdiff.mp seed.coordinate.property).2 conditioned · obtain ⟨a, ha, same⟩ := Finset.mem_image.mp left have equal : a = seed.coordinate := Subtype.ext same exact exactLeft_coordinate_not_mem seed.coordinate seed.partition (equal ▸ ha) · obtain ⟨a, ha, same⟩ := Finset.mem_image.mp exposed have equal : a = seed.coordinate := Subtype.ext same have belongs := exactRightPrefix_subset seed ha exact exactRight_coordinate_not_mem seed.coordinate seed.partition (equal ▸ belongs) theorem exactFairBobQuestionMask_coordinate_not_mem {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : seed.coordinate.val ∉ exactFairBobQuestionMask D seed := by classical intro member change seed.coordinate.val ∈ (D ∪ (exactRight seed.coordinate seed.partition).image Subtype.val) ∪ (exactLeftPrefix seed).image Subtype.val at member rcases Finset.mem_union.mp member with main | exposed · rcases Finset.mem_union.mp main with conditioned | right · exact (Finset.mem_sdiff.mp seed.coordinate.property).2 conditioned · obtain ⟨a, ha, same⟩ := Finset.mem_image.mp right have equal : a = seed.coordinate := Subtype.ext same exact exactRight_coordinate_not_mem seed.coordinate seed.partition (equal ▸ ha) · obtain ⟨a, ha, same⟩ := Finset.mem_image.mp exposed have equal : a = seed.coordinate := Subtype.ext same have belongs := exactLeftPrefix_subset seed ha exact exactLeft_coordinate_not_mem seed.coordinate seed.partition (equal ▸ belongs) def exactReverseAliceAlignedCfcPrefixPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (k : ℕ) : ℝ := ∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q * (∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if ∀ j : {j : Fin n // j ∈ D}, G.predicate (q.1 j.val) (q.2 j.val) (aliceAnswer j) (bobAnswer j) = true then bornTracePairing S.state.matrix (cfc (fun z : ℝ => z * Real.log z) (exactJointPrefixAliceOperatorFilter G n S D (exactReverseAlicePrefixXMask D side context k) (exactReverseAliceFixedYMask D side context) aliceAnswer q.1 q.2)) (exactJointPrefixBobOperatorFilter G n S D (exactReverseAlicePrefixXMask D side context k) (exactReverseAliceFixedYMask D side context) bobAnswer q.1 q.2) else 0) def exactReverseBobAlignedCfcPrefixPotential (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (k : ℕ) : ℝ := ∑ q : ExactFullQuestion X Y n, exactPriorQuestionWeight G n q * (∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if ∀ j : {j : Fin n // j ∈ D}, G.predicate (q.1 j.val) (q.2 j.val) (aliceAnswer j) (bobAnswer j) = true then bornTracePairing S.state.matrix (exactJointPrefixAliceOperatorFilter G n S D (exactReverseBobFixedXMask D side context) (exactReverseBobPrefixYMask D side context k) aliceAnswer q.1 q.2) (cfc (fun z : ℝ => z * Real.log z) (exactJointPrefixBobOperatorFilter G n S D (exactReverseBobFixedXMask D side context) (exactReverseBobPrefixYMask D side context k) bobAnswer q.1 q.2)) else 0) theorem exactReverseAliceAlignedCfcPrefixPotential_telescope (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) : (∑ k ∈ Finset.range side.card, (exactReverseAliceAlignedCfcPrefixPotential G n S D side context (k + 1) - exactReverseAliceAlignedCfcPrefixPotential G n S D side context k)) = exactReverseAliceAlignedCfcPrefixPotential G n S D side context side.card - exactReverseAliceAlignedCfcPrefixPotential G n S D side context 0 := history_forward_telescope (exactReverseAliceAlignedCfcPrefixPotential G n S D side context) side.card theorem exactReverseBobAlignedCfcPrefixPotential_telescope (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) : (∑ k ∈ Finset.range side.card, (exactReverseBobAlignedCfcPrefixPotential G n S D side context (k + 1) - exactReverseBobAlignedCfcPrefixPotential G n S D side context k)) = exactReverseBobAlignedCfcPrefixPotential G n S D side context side.card - exactReverseBobAlignedCfcPrefixPotential G n S D side context 0 := history_forward_telescope (exactReverseBobAlignedCfcPrefixPotential G n S D side context) side.card end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3400000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactPriorQuestion_coordinate_weight_ne_zero (G : Game X Y A B) (n : ℕ) (q : ExactFullQuestion X Y n) (supported : exactPriorQuestionWeight G n q ≠ 0) (j : Fin n) : G.questionWeight (q.1 j) (q.2 j) ≠ 0 := by intro zero apply supported unfold exactPriorQuestionWeight rw [Game.repeat_questionWeight] exact Finset.prod_eq_zero (Finset.mem_univ j) zero theorem exactJointPrefixQuestionMass_pos_of_question (G : Game X Y A B) (n : ℕ) (fixedX fixedY : Finset (Fin n)) (knownX : Fin n → X) (knownY : Fin n → Y) (positive : 0 < (G.repeat n).questionWeight knownX knownY) : 0 < exactJointPrefixQuestionMass G n fixedX fixedY knownX knownY := by classical unfold exactJointPrefixQuestionMass have term_nonnegative (xs : Fin n → X) (ys : Fin n → Y) : 0 ≤ if (∀ j : Fin n, j ∈ fixedX → xs j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) then (G.repeat n).questionWeight xs ys else 0 := by split · exact (G.repeat n).weight_nonneg xs ys · exact le_rfl have row_nonnegative (xs : Fin n → X) : 0 ≤ ∑ ys : Fin n → Y, if (∀ j : Fin n, j ∈ fixedX → xs j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) then (G.repeat n).questionWeight xs ys else 0 := Finset.sum_nonneg (fun ys _ => term_nonnegative xs ys) have own_compatible : (∀ j : Fin n, j ∈ fixedX → knownX j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → knownY j = knownY j) := ⟨fun _ _ => rfl, fun _ _ => rfl⟩ calc 0 < (G.repeat n).questionWeight knownX knownY := positive _ = (if (∀ j : Fin n, j ∈ fixedX → knownX j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → knownY j = knownY j) then (G.repeat n).questionWeight knownX knownY else 0) := (if_pos own_compatible).symm _ ≤ (∑ ys : Fin n → Y, if (∀ j : Fin n, j ∈ fixedX → knownX j = knownX j) ∧ (∀ j : Fin n, j ∈ fixedY → ys j = knownY j) then (G.repeat n).questionWeight knownX ys else 0) := Finset.single_le_sum (fun ys _ => term_nonnegative knownX ys) (Finset.mem_univ knownY) _ ≤ _ := Finset.single_le_sum (fun xs _ => row_nonnegative xs) (Finset.mem_univ knownX) theorem exactRevealCode_update_distinguished_alice {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) (x : X) : exactRevealCode D seed (Function.update q.1 seed.coordinate.val x, q.2) = exactRevealCode D seed q := by apply (exactRevealCode_eq_iff_fair_question_masks D seed q (Function.update q.1 seed.coordinate.val x, q.2)).mpr constructor · intro j hj have different : j ≠ seed.coordinate.val := by intro same exact exactFairAliceQuestionMask_coordinate_not_mem D seed (same ▸ hj) exact Function.update_of_ne different x q.1 · intro j _ rfl theorem exactRevealCode_update_distinguished_bob {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) (y : Y) : exactRevealCode D seed (q.1, Function.update q.2 seed.coordinate.val y) = exactRevealCode D seed q := by apply (exactRevealCode_eq_iff_fair_question_masks D seed q (q.1, Function.update q.2 seed.coordinate.val y)).mpr constructor · intro j _ rfl · intro j hj have different : j ≠ seed.coordinate.val := by intro same exact exactFairBobQuestionMask_coordinate_not_mem D seed (same ▸ hj) exact Function.update_of_ne different y q.2 theorem exactFairAliceMeanFilter_eq_jointPrefixOperatorFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) (answer : {j : Fin n // j ∈ D} → A) (supported : exactPriorQuestionWeight G n q ≠ 0) : exactAliceMeanFilter G n S D seed (exactRevealCode D seed q) answer (q.2 seed.coordinate.val) = exactJointPrefixAliceOperatorFilter G n S D (exactFairAliceQuestionMask D seed) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) answer q.1 q.2 := by classical have question_nonzero : (G.repeat n).questionWeight q.1 q.2 ≠ 0 := by simpa [exactPriorQuestionWeight] using supported have question_positive : 0 < (G.repeat n).questionWeight q.1 q.2 := lt_of_le_of_ne ((G.repeat n).weight_nonneg q.1 q.2) (Ne.symm question_nonzero) have register_positive := exactJointPrefixQuestionMass_pos_of_question G n (exactFairAliceQuestionMask D seed) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) q.1 q.2 question_positive have tower := exactJointPrefixAliceOperatorFilter_martingale G n S D (exactFairAliceQuestionMask D seed) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) seed.coordinate.val (exactFairAliceQuestionMask_coordinate_not_mem D seed) (Finset.mem_insert_self _ _) answer q.1 q.2 register_positive.ne' unfold exactAliceMeanFilter rw [← tower] apply Finset.sum_congr rfl intro x _ by_cases missing : G.conditionalXGivenY (q.2 seed.coordinate.val) x = 0 · simp [missing] · have edge : G.questionWeight x (q.2 seed.coordinate.val) ≠ 0 := by intro zero apply missing simp [Game.conditionalXGivenY, zero] have mirror_edge : G.conditionalYGivenX x (q.2 seed.coordinate.val) ≠ 0 := by intro zero have factor := G.marginalX_mul_conditionalYGivenX x (q.2 seed.coordinate.val) rw [zero, mul_zero] at factor exact edge factor.symm have source := exactAliceQuestionFilter_eq_jointPrefixOperatorFilter G n S D seed (Function.update q.1 seed.coordinate.val x, q.2) answer have source_filter : exactAliceQuestionFilter G n S D seed (exactRevealCode D seed q) answer x = exactJointPrefixAliceOperatorFilter G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (exactFairBobQuestionMask D seed) answer (Function.update q.1 seed.coordinate.val x) q.2 := by simpa only [ exactRevealCode_update_distinguished_alice, Function.update_self] using source have stable := exactJointPrefixAliceOperatorFilter_insert_bob G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (exactFairBobQuestionMask D seed) seed.coordinate.val (Finset.mem_insert_self _ _) (exactFairBobQuestionMask_coordinate_not_mem D seed) answer (Function.update q.1 seed.coordinate.val x) q.2 (q.2 seed.coordinate.val) (by simpa only [Function.update_self] using mirror_edge) have equal : exactAliceQuestionFilter G n S D seed (exactRevealCode D seed q) answer x = exactJointPrefixAliceOperatorFilter G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) answer (Function.update q.1 seed.coordinate.val x) q.2 := by rw [source_filter] simpa only [Function.update_eq_self] using stable.symm rw [equal] theorem exactFairBobMeanFilter_eq_jointPrefixOperatorFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) (answer : {j : Fin n // j ∈ D} → B) (supported : exactPriorQuestionWeight G n q ≠ 0) : exactBobMeanFilter G n S D seed (exactRevealCode D seed q) answer (q.1 seed.coordinate.val) = exactJointPrefixBobOperatorFilter G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (exactFairBobQuestionMask D seed) answer q.1 q.2 := by classical have question_nonzero : (G.repeat n).questionWeight q.1 q.2 ≠ 0 := by simpa [exactPriorQuestionWeight] using supported have question_positive : 0 < (G.repeat n).questionWeight q.1 q.2 := lt_of_le_of_ne ((G.repeat n).weight_nonneg q.1 q.2) (Ne.symm question_nonzero) have register_positive := exactJointPrefixQuestionMass_pos_of_question G n (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (exactFairBobQuestionMask D seed) q.1 q.2 question_positive have tower := exactJointPrefixBobOperatorFilter_martingale G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (exactFairBobQuestionMask D seed) seed.coordinate.val (Finset.mem_insert_self _ _) (exactFairBobQuestionMask_coordinate_not_mem D seed) answer q.1 q.2 register_positive.ne' unfold exactBobMeanFilter rw [← tower] apply Finset.sum_congr rfl intro y _ by_cases missing : G.conditionalYGivenX (q.1 seed.coordinate.val) y = 0 · simp [missing] · have edge : G.questionWeight (q.1 seed.coordinate.val) y ≠ 0 := by intro zero apply missing simp [Game.conditionalYGivenX, zero] have mirror_edge : G.conditionalXGivenY y (q.1 seed.coordinate.val) ≠ 0 := by intro zero have factor := G.marginalY_mul_conditionalXGivenY (q.1 seed.coordinate.val) y rw [zero, mul_zero] at factor exact edge factor.symm have source := exactBobQuestionFilter_eq_jointPrefixOperatorFilter G n S D seed (q.1, Function.update q.2 seed.coordinate.val y) answer have source_filter : exactBobQuestionFilter G n S D seed (exactRevealCode D seed q) answer y = exactJointPrefixBobOperatorFilter G n S D (exactFairAliceQuestionMask D seed) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) answer q.1 (Function.update q.2 seed.coordinate.val y) := by simpa only [ exactRevealCode_update_distinguished_bob, Function.update_self] using source have stable := exactJointPrefixBobOperatorFilter_insert_alice G n S D (exactFairAliceQuestionMask D seed) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) seed.coordinate.val (exactFairAliceQuestionMask_coordinate_not_mem D seed) (Finset.mem_insert_self _ _) answer q.1 (Function.update q.2 seed.coordinate.val y) (q.1 seed.coordinate.val) (by simpa only [Function.update_self] using mirror_edge) have equal : exactBobQuestionFilter G n S D seed (exactRevealCode D seed q) answer y = exactJointPrefixBobOperatorFilter G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) answer q.1 (Function.update q.2 seed.coordinate.val y) := by rw [source_filter] simpa only [Function.update_eq_self] using stable.symm rw [equal] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactReverseBobMarker_induction {n : ℕ} (D : Finset (Fin n)) (P : (side : Finset (SourceRemainingCoordinate D)) → ExactReverseSideContext (SourceRemainingCoordinate D) side → Fin side.card → Prop) (allSeeds : ∀ seed : ExactRemainingSeed D, P (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩)) : ∀ (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card), P side context marker := by intro side context marker let seed := exactReverseBobMarkerDecode side context marker let motive : (Σ side : Finset (SourceRemainingCoordinate D), ExactReverseSideContext (SourceRemainingCoordinate D) side × Fin side.card) → Prop := fun code => P code.1 code.2.1 code.2.2 have actual : motive (exactReverseBobMarkerCode seed) := allSeeds seed have inverse : exactReverseBobMarkerCode seed = ⟨side, context, marker⟩ := by exact exactReverseBobMarkerDecode_rightInverse side context marker rw [inverse] at actual exact actual theorem exactReverseAliceMarker_induction {n : ℕ} (D : Finset (Fin n)) (P : (side : Finset (SourceRemainingCoordinate D)) → ExactReverseSideContext (SourceRemainingCoordinate D) side → Fin side.card → Prop) (allSeeds : ∀ seed : ExactRemainingSeed D, P (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩)) : ∀ (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card), P side context marker := by intro side context marker let seed := exactReverseAliceMarkerDecode side context marker let motive : (Σ side : Finset (SourceRemainingCoordinate D), ExactReverseSideContext (SourceRemainingCoordinate D) side × Fin side.card) → Prop := fun code => P code.1 code.2.1 code.2.2 have actual : motive (exactReverseAliceMarkerCode seed) := allSeeds seed have inverse : exactReverseAliceMarkerCode seed = ⟨side, context, marker⟩ := by exact exactReverseAliceMarkerDecode_rightInverse side context marker rw [inverse] at actual exact actual theorem exactReverseAlicePrefixXMask_succ {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAlicePrefixXMask D side context (marker.val + 1) = insert (context.sideRank.symm marker).val.val (exactReverseAlicePrefixXMask D side context marker.val) := by classical unfold exactReverseAlicePrefixXMask rw [exactReverseContextQuestionPrefix_succ] ext j simp only [Finset.mem_union, Finset.mem_insert] tauto theorem exactReverseBobPrefixYMask_succ {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobPrefixYMask D side context (marker.val + 1) = insert (context.sideRank.symm marker).val.val (exactReverseBobPrefixYMask D side context marker.val) := by classical unfold exactReverseBobPrefixYMask rw [exactReverseContextQuestionPrefix_succ] ext j simp only [Finset.mem_union, Finset.mem_insert] tauto theorem exactReverseAliceLowQuestionPotential_eq_alignedPrefix (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceLowQuestionPotential G n S D side context marker = exactReverseAliceAlignedCfcPrefixPotential G n S D side context marker.val := by classical apply exactReverseBobMarker_induction D (fun side context marker => exactReverseAliceLowQuestionPotential G n S D side context marker = exactReverseAliceAlignedCfcPrefixPotential G n S D side context marker.val) intro seed have decoded := (exactReverseBobWeightedMarkerEquiv (M := SourceRemainingCoordinate D)).left_inv seed change exactReverseBobMarkerDecode (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) = seed at decoded unfold exactReverseAliceLowQuestionPotential exactReverseAliceAlignedCfcPrefixPotential dsimp only rw [decoded, exactReverseAlicePrefixXMask_eq_fair, exactReverseAliceFixedYMask_eq_insert_fair] apply Finset.sum_congr rfl intro q _ by_cases supported : exactPriorQuestionWeight G n q = 0 · simp [supported] · congr 1 apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : ∀ j : {j : Fin n // j ∈ D}, G.predicate (q.1 j.val) (q.2 j.val) (aliceAnswer j) (bobAnswer j) = true · have sourceAccepted : exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ := by exact accepted simp only [if_pos sourceAccepted, if_pos accepted] rw [exactFairAliceMeanFilter_eq_jointPrefixOperatorFilter G n S D seed q aliceAnswer supported, exactBobQuestionFilter_eq_jointPrefixOperatorFilter G n S D seed q bobAnswer] · have sourceRejected : ¬ exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ := by exact accepted simp only [if_neg sourceRejected, if_neg accepted] theorem exactReverseBobLowQuestionPotential_eq_alignedPrefix (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobLowQuestionPotential G n S D side context marker = exactReverseBobAlignedCfcPrefixPotential G n S D side context marker.val := by classical apply exactReverseAliceMarker_induction D (fun side context marker => exactReverseBobLowQuestionPotential G n S D side context marker = exactReverseBobAlignedCfcPrefixPotential G n S D side context marker.val) intro seed have decoded := (exactReverseAliceWeightedMarkerEquiv (M := SourceRemainingCoordinate D)).left_inv seed change exactReverseAliceMarkerDecode (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) = seed at decoded unfold exactReverseBobLowQuestionPotential exactReverseBobAlignedCfcPrefixPotential dsimp only rw [decoded, exactReverseBobFixedXMask_eq_insert_fair, exactReverseBobPrefixYMask_eq_fair] apply Finset.sum_congr rfl intro q _ by_cases supported : exactPriorQuestionWeight G n q = 0 · simp [supported] · congr 1 apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : ∀ j : {j : Fin n // j ∈ D}, G.predicate (q.1 j.val) (q.2 j.val) (aliceAnswer j) (bobAnswer j) = true · have sourceAccepted : exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ := by exact accepted simp only [if_pos sourceAccepted, if_pos accepted] rw [exactAliceQuestionFilter_eq_jointPrefixOperatorFilter G n S D seed q aliceAnswer, exactFairBobMeanFilter_eq_jointPrefixOperatorFilter G n S D seed q bobAnswer supported] · have sourceRejected : ¬ exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ := by exact accepted simp only [if_neg sourceRejected, if_neg accepted] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 6000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactAliceQuestionFilter_eq_fullJointPrefixOperatorFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) (answer : {j : Fin n // j ∈ D} → A) (supported : exactPriorQuestionWeight G n q ≠ 0) : exactAliceQuestionFilter G n S D seed (exactRevealCode D seed q) answer (q.1 seed.coordinate.val) = exactJointPrefixAliceOperatorFilter G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) answer q.1 q.2 := by classical have edge := exactPriorQuestion_coordinate_weight_ne_zero G n q supported seed.coordinate.val have conditional : G.conditionalYGivenX (q.1 seed.coordinate.val) (q.2 seed.coordinate.val) ≠ 0 := by intro zero have factor := G.marginalX_mul_conditionalYGivenX (q.1 seed.coordinate.val) (q.2 seed.coordinate.val) rw [zero, mul_zero] at factor exact edge factor.symm rw [exactAliceQuestionFilter_eq_jointPrefixOperatorFilter G n S D seed q answer] have stable := exactJointPrefixAliceOperatorFilter_insert_bob G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (exactFairBobQuestionMask D seed) seed.coordinate.val (Finset.mem_insert_self _ _) (exactFairBobQuestionMask_coordinate_not_mem D seed) answer q.1 q.2 (q.2 seed.coordinate.val) conditional simpa only [Function.update_eq_self] using stable.symm theorem exactBobQuestionFilter_eq_fullJointPrefixOperatorFilter (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (q : ExactFullQuestion X Y n) (answer : {j : Fin n // j ∈ D} → B) (supported : exactPriorQuestionWeight G n q ≠ 0) : exactBobQuestionFilter G n S D seed (exactRevealCode D seed q) answer (q.2 seed.coordinate.val) = exactJointPrefixBobOperatorFilter G n S D (insert seed.coordinate.val (exactFairAliceQuestionMask D seed)) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) answer q.1 q.2 := by classical have edge := exactPriorQuestion_coordinate_weight_ne_zero G n q supported seed.coordinate.val have conditional : G.conditionalXGivenY (q.2 seed.coordinate.val) (q.1 seed.coordinate.val) ≠ 0 := by intro zero have factor := G.marginalY_mul_conditionalXGivenY (q.1 seed.coordinate.val) (q.2 seed.coordinate.val) rw [zero, mul_zero] at factor exact edge factor.symm rw [exactBobQuestionFilter_eq_jointPrefixOperatorFilter G n S D seed q answer] have stable := exactJointPrefixBobOperatorFilter_insert_alice G n S D (exactFairAliceQuestionMask D seed) (insert seed.coordinate.val (exactFairBobQuestionMask D seed)) seed.coordinate.val (exactFairAliceQuestionMask_coordinate_not_mem D seed) (Finset.mem_insert_self _ _) answer q.1 q.2 (q.1 seed.coordinate.val) conditional simpa only [Function.update_eq_self] using stable.symm theorem exactReverseAliceHighQuestionPotential_eq_alignedPrefix (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceHighQuestionPotential G n S D side context marker = exactReverseAliceAlignedCfcPrefixPotential G n S D side context (marker.val + 1) := by classical apply exactReverseBobMarker_induction D (fun side context marker => exactReverseAliceHighQuestionPotential G n S D side context marker = exactReverseAliceAlignedCfcPrefixPotential G n S D side context (marker.val + 1)) intro seed have decoded := (exactReverseBobWeightedMarkerEquiv (M := SourceRemainingCoordinate D)).left_inv seed change exactReverseBobMarkerDecode (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) = seed at decoded unfold exactReverseAliceHighQuestionPotential exactReverseAliceAlignedCfcPrefixPotential dsimp only rw [decoded, exactReverseAlicePrefixXMask_succ, Equiv.symm_apply_apply, exactReverseAlicePrefixXMask_eq_fair, exactReverseAliceFixedYMask_eq_insert_fair] apply Finset.sum_congr rfl intro q _ by_cases supported : exactPriorQuestionWeight G n q = 0 · simp [supported] · congr 1 apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : ∀ j : {j : Fin n // j ∈ D}, G.predicate (q.1 j.val) (q.2 j.val) (aliceAnswer j) (bobAnswer j) = true · have sourceAccepted : exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ := by exact accepted simp only [if_pos sourceAccepted, if_pos accepted] rw [exactAliceQuestionFilter_eq_fullJointPrefixOperatorFilter G n S D seed q aliceAnswer supported, exactBobQuestionFilter_eq_fullJointPrefixOperatorFilter G n S D seed q bobAnswer supported] · have sourceRejected : ¬ exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ := by exact accepted simp only [if_neg sourceRejected, if_neg accepted] theorem exactReverseBobHighQuestionPotential_eq_alignedPrefix (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobHighQuestionPotential G n S D side context marker = exactReverseBobAlignedCfcPrefixPotential G n S D side context (marker.val + 1) := by classical apply exactReverseAliceMarker_induction D (fun side context marker => exactReverseBobHighQuestionPotential G n S D side context marker = exactReverseBobAlignedCfcPrefixPotential G n S D side context (marker.val + 1)) intro seed have decoded := (exactReverseAliceWeightedMarkerEquiv (M := SourceRemainingCoordinate D)).left_inv seed change exactReverseAliceMarkerDecode (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) = seed at decoded unfold exactReverseBobHighQuestionPotential exactReverseBobAlignedCfcPrefixPotential dsimp only rw [decoded, exactReverseBobPrefixYMask_succ, Equiv.symm_apply_apply, exactReverseBobFixedXMask_eq_insert_fair, exactReverseBobPrefixYMask_eq_fair] apply Finset.sum_congr rfl intro q _ by_cases supported : exactPriorQuestionWeight G n q = 0 · simp [supported] · congr 1 apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : ∀ j : {j : Fin n // j ∈ D}, G.predicate (q.1 j.val) (q.2 j.val) (aliceAnswer j) (bobAnswer j) = true · have sourceAccepted : exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ := by exact accepted simp only [if_pos sourceAccepted, if_pos accepted] rw [exactAliceQuestionFilter_eq_fullJointPrefixOperatorFilter G n S D seed q aliceAnswer supported, exactBobQuestionFilter_eq_fullJointPrefixOperatorFilter G n S D seed q bobAnswer supported] · have sourceRejected : ¬ exactHistoryAccepted G n D ⟨seed, exactRevealCode D seed q, aliceAnswer, bobAnswer⟩ := by exact accepted simp only [if_neg sourceRejected, if_neg accepted] theorem exactReverseAliceFilterOperatorMarkerEntropy_eq_aligned_step (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceFilterOperatorMarkerEntropy G n S D side context marker = exactReverseAliceAlignedCfcPrefixPotential G n S D side context (marker.val + 1) - exactReverseAliceAlignedCfcPrefixPotential G n S D side context marker.val := by rw [exactReverseAliceFilterOperatorMarkerEntropy_eq_question_sub, exactReverseAliceHighQuestionPotential_eq_alignedPrefix, exactReverseAliceLowQuestionPotential_eq_alignedPrefix] theorem exactReverseBobFilterOperatorMarkerEntropy_eq_aligned_step (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobFilterOperatorMarkerEntropy G n S D side context marker = exactReverseBobAlignedCfcPrefixPotential G n S D side context (marker.val + 1) - exactReverseBobAlignedCfcPrefixPotential G n S D side context marker.val := by rw [exactReverseBobFilterOperatorMarkerEntropy_eq_question_sub, exactReverseBobHighQuestionPotential_eq_alignedPrefix, exactReverseBobLowQuestionPotential_eq_alignedPrefix] theorem exactReverseAliceFilterOperatorMarkerEntropy_sum_telescope (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) : (∑ marker : Fin side.card, exactReverseAliceFilterOperatorMarkerEntropy G n S D side context marker) = exactReverseAliceAlignedCfcPrefixPotential G n S D side context side.card - exactReverseAliceAlignedCfcPrefixPotential G n S D side context 0 := by classical calc (∑ marker : Fin side.card, exactReverseAliceFilterOperatorMarkerEntropy G n S D side context marker) = ∑ marker : Fin side.card, (exactReverseAliceAlignedCfcPrefixPotential G n S D side context (marker.val + 1) - exactReverseAliceAlignedCfcPrefixPotential G n S D side context marker.val) := by apply Finset.sum_congr rfl intro marker _ exact exactReverseAliceFilterOperatorMarkerEntropy_eq_aligned_step G n S D side context marker _ = ∑ k ∈ Finset.range side.card, (exactReverseAliceAlignedCfcPrefixPotential G n S D side context (k + 1) - exactReverseAliceAlignedCfcPrefixPotential G n S D side context k) := by rw [Finset.sum_fin_eq_sum_range] apply Finset.sum_congr rfl intro k hk simp [Finset.mem_range.mp hk] _ = _ := exactReverseAliceAlignedCfcPrefixPotential_telescope G n S D side context theorem exactReverseBobFilterOperatorMarkerEntropy_sum_telescope (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) : (∑ marker : Fin side.card, exactReverseBobFilterOperatorMarkerEntropy G n S D side context marker) = exactReverseBobAlignedCfcPrefixPotential G n S D side context side.card - exactReverseBobAlignedCfcPrefixPotential G n S D side context 0 := by classical calc (∑ marker : Fin side.card, exactReverseBobFilterOperatorMarkerEntropy G n S D side context marker) = ∑ marker : Fin side.card, (exactReverseBobAlignedCfcPrefixPotential G n S D side context (marker.val + 1) - exactReverseBobAlignedCfcPrefixPotential G n S D side context marker.val) := by apply Finset.sum_congr rfl intro marker _ exact exactReverseBobFilterOperatorMarkerEntropy_eq_aligned_step G n S D side context marker _ = ∑ k ∈ Finset.range side.card, (exactReverseBobAlignedCfcPrefixPotential G n S D side context (k + 1) - exactReverseBobAlignedCfcPrefixPotential G n S D side context k) := by rw [Finset.sum_fin_eq_sum_range] apply Finset.sum_congr rfl intro k hk simp [Finset.mem_range.mp hk] _ = _ := exactReverseBobAlignedCfcPrefixPotential_telescope G n S D side context end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 6000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactFixedSeedOutcomeTuple (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) := ExactRevealHistory X Y D seed × ({j : Fin n // j ∈ D} → A) × ({j : Fin n // j ∈ D} → B) × X × Y def exactFixedSeedOutcomeCode {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) : ExactFixedSeedOutcomeTuple X Y A B D seed := (exactRevealCode D seed (outcome.1, outcome.2.1), (fun j => outcome.2.2.1 j.val), (fun j => outcome.2.2.2 j.val), outcome.1 seed.coordinate.val, outcome.2.1 seed.coordinate.val) theorem exactFixedSeedOutcomeCode_fiber_iff {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (aliceAnswer : {j : Fin n // j ∈ D} → A) (bobAnswer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) (outcome : ExactOutcome X Y A B n) : exactFixedSeedOutcomeCode D seed outcome = (history, aliceAnswer, bobAnswer, x, y) ↔ exactLocallySampleableCode D (seed, outcome) = (seed.coordinate, x, y, (⟨seed, history, aliceAnswer, bobAnswer⟩ : ExactHistoryFlag X Y A B D)) := by rw [exactLocallySampleableCode_fixedSeed_fiber_iff D (⟨seed, history, aliceAnswer, bobAnswer⟩ : ExactHistoryFlag X Y A B D) x y outcome] constructor · intro same have hh := congrArg (fun t : ExactFixedSeedOutcomeTuple X Y A B D seed => t.1) same have ha := congrArg (fun t : ExactFixedSeedOutcomeTuple X Y A B D seed => t.2.1) same have hb := congrArg (fun t : ExactFixedSeedOutcomeTuple X Y A B D seed => t.2.2.1) same have hx := congrArg (fun t : ExactFixedSeedOutcomeTuple X Y A B D seed => t.2.2.2.1) same have hy := congrArg (fun t : ExactFixedSeedOutcomeTuple X Y A B D seed => t.2.2.2.2) same refine ⟨hh, hx, hy, ?_, ?_⟩ · intro j exact congrFun ha j · intro j exact congrFun hb j · rintro ⟨hh, hx, hy, ha, hb⟩ apply Prod.ext · exact hh · apply Prod.ext · exact funext ha · apply Prod.ext · exact funext hb · exact Prod.ext hx hy theorem exactFixedSeedGroupedBornMass_eq (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (history : ExactRevealHistory X Y D seed) (aliceAnswer : {j : Fin n // j ∈ D} → A) (bobAnswer : {j : Fin n // j ∈ D} → B) (x : X) (y : Y) : groupedMass (exactFixedSeedOutcomeCode (X := X) (Y := Y) (A := A) (B := B) D seed) (strategyEventLaw (G.repeat n) S).weight (history, aliceAnswer, bobAnswer, x, y) = exactFairFullOutcomeBornMass G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ x y := by classical unfold groupedMass exactFairFullOutcomeBornMass rw [Finset.sum_filter] apply Finset.sum_congr rfl intro outcome _ by_cases compatible : exactFixedSeedOutcomeCode D seed outcome = (history, aliceAnswer, bobAnswer, x, y) · rw [if_pos compatible, if_pos ((exactFixedSeedOutcomeCode_fiber_iff D seed history aliceAnswer bobAnswer x y outcome).mp compatible)] · rw [if_neg compatible, if_neg] intro incompatible exact compatible ((exactFixedSeedOutcomeCode_fiber_iff D seed history aliceAnswer bobAnswer x y outcome).mpr incompatible) theorem exactFixedSeedOutcomeCode_accepted_iff (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) : exactHistoryAccepted G n D ⟨seed, (exactFixedSeedOutcomeCode (X := X) (Y := Y) (A := A) (B := B) D seed outcome).1, (exactFixedSeedOutcomeCode (X := X) (Y := Y) (A := A) (B := B) D seed outcome).2.1, (exactFixedSeedOutcomeCode (X := X) (Y := Y) (A := A) (B := B) D seed outcome).2.2.1⟩ ↔ outcome ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D := by classical simp only [exactHistoryAccepted, exactFixedSeedOutcomeCode, exactRevealCode, FiniteEventLaw.winEvent, Finset.mem_filter, Finset.mem_univ, true_and, repeatedCoordinateWin] constructor · intro accepted j member exact accepted ⟨j, member⟩ · intro accepted j exact accepted j.val j.property theorem exactFairFullOutcomeBornMass_accepted_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : (∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then ∑ x : X, ∑ y : Y, exactFairFullOutcomeBornMass G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ x y else 0) = repeatedPostselectionMass G n S D := by classical let code := exactFixedSeedOutcomeCode (X := X) (Y := Y) (A := A) (B := B) D seed let payoff : ExactFixedSeedOutcomeTuple X Y A B D seed → ℝ := fun t => if exactHistoryAccepted G n D ⟨seed, t.1, t.2.1, t.2.2.1⟩ then 1 else 0 have push := groupedMass_expectation code (strategyEventLaw (G.repeat n) S).weight payoff simp only [Fintype.sum_prod_type] at push calc (∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then ∑ x : X, ∑ y : Y, exactFairFullOutcomeBornMass G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ x y else 0) = ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, ∑ x : X, ∑ y : Y, groupedMass code (strategyEventLaw (G.repeat n) S).weight (history, aliceAnswer, bobAnswer, x, y) * payoff (history, aliceAnswer, bobAnswer, x, y) := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ · simp only [if_pos accepted, payoff, mul_one] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ exact (exactFixedSeedGroupedBornMass_eq G n S D seed history aliceAnswer bobAnswer x y).symm · simp [accepted, payoff] _ = ∑ outcome : ExactOutcome X Y A B n, (strategyEventLaw (G.repeat n) S).weight outcome * payoff (code outcome) := by simpa only [Fintype.sum_prod_type] using push _ = ∑ outcome : ExactOutcome X Y A B n, if outcome ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D then (strategyEventLaw (G.repeat n) S).weight outcome else 0 := by apply Finset.sum_congr rfl intro outcome _ have acceptance := exactFixedSeedOutcomeCode_accepted_iff G n D seed outcome by_cases winning : outcome ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D · have accepted := acceptance.mpr winning simp [payoff, code, accepted, winning] · have rejected : ¬ exactHistoryAccepted G n D ⟨seed, (exactFixedSeedOutcomeCode (X := X) (Y := Y) (A := A) (B := B) D seed outcome).1, (exactFixedSeedOutcomeCode (X := X) (Y := Y) (A := A) (B := B) D seed outcome).2.1, (exactFixedSeedOutcomeCode (X := X) (Y := Y) (A := A) (B := B) D seed outcome).2.2.1⟩ := by intro accepted exact winning (acceptance.mp accepted) simp [payoff, code, rejected, winning] _ = repeatedPostselectionMass G n S D := by change (∑ outcome : ExactOutcome X Y A B n, if outcome ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D then (strategyEventLaw (G.repeat n) S).weight outcome else 0) = (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) simp [FiniteEventLaw.eventMass] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 4000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseAliceAcceptedScalarEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseBobMarkerDecode side context marker ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ y : Y, G.marginalY y * Real.negMulLog (bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D seed history aliceAnswer y) (exactBobQuestionFilter G n S D seed history bobAnswer y))) else 0 theorem exactReverseAliceLowOperatorPotential_neg_le_scalarEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : -exactReverseAliceFilterLowOperatorPotential G n S D side context marker ≤ exactReverseAliceAcceptedScalarEntropy G n S D side context marker := by classical unfold exactReverseAliceFilterLowOperatorPotential exactReverseAliceAcceptedScalarEntropy dsimp only rw [← Finset.sum_neg_distrib] apply Finset.sum_le_sum intro history _ rw [← Finset.sum_neg_distrib] apply Finset.sum_le_sum intro aliceAnswer _ rw [← Finset.sum_neg_distrib] apply Finset.sum_le_sum intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ · simp only [if_pos accepted] have spectral := exactFairAliceHistoryLowOperatorPotential_neg_le_entropy G n S D ⟨exactReverseBobMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ have weighted := mul_le_mul_of_nonneg_left spectral (exactRevealMass_nonneg G n D (exactReverseBobMarkerDecode side context marker) history) nlinarith · simp [accepted] theorem exactReverseAliceAlignedCfcPrefixPotential_last_nonpos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (nonempty : 0 < side.card) : exactReverseAliceAlignedCfcPrefixPotential G n S D side context side.card ≤ 0 := by classical let marker : Fin side.card := ⟨side.card - 1, Nat.sub_lt nonempty Nat.one_pos⟩ have last : marker.val + 1 = side.card := by dsimp [marker] omega have high := exactReverseAliceFilterHighOperatorPotential_nonpos G n S D side context marker rw [exactReverseAliceHighOperatorPotential_eq_question, exactReverseAliceHighQuestionPotential_eq_alignedPrefix, last] at high exact high theorem exactReverseAliceFilterOperatorMarkerEntropy_sum_le_scalarEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (nonempty : 0 < side.card) : (∑ marker : Fin side.card, exactReverseAliceFilterOperatorMarkerEntropy G n S D side context marker) ≤ exactReverseAliceAcceptedScalarEntropy G n S D side context ⟨0, nonempty⟩ := by classical have last := exactReverseAliceAlignedCfcPrefixPotential_last_nonpos G n S D side context nonempty have low := exactReverseAliceLowOperatorPotential_neg_le_scalarEntropy G n S D side context ⟨0, nonempty⟩ rw [exactReverseAliceFilterOperatorMarkerEntropy_sum_telescope] rw [exactReverseAliceLowOperatorPotential_eq_question, exactReverseAliceLowQuestionPotential_eq_alignedPrefix] at low dsimp only at low linarith end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseBobAcceptedScalarEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := let seed := exactReverseAliceMarkerDecode side context marker ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ x : X, G.marginalX x * Real.negMulLog (bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D seed history aliceAnswer x) (exactBobMeanFilter G n S D seed history bobAnswer x))) else 0 theorem exactReverseBobFilterLowOperatorPotential_neg_le_scalarEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : -exactReverseBobFilterLowOperatorPotential G n S D side context marker ≤ exactReverseBobAcceptedScalarEntropy G n S D side context marker := by classical unfold exactReverseBobFilterLowOperatorPotential exactReverseBobAcceptedScalarEntropy dsimp only simp_rw [← Finset.sum_neg_distrib] apply Finset.sum_le_sum intro history _ apply Finset.sum_le_sum intro aliceAnswer _ apply Finset.sum_le_sum intro bobAnswer _ split · rename_i accepted have bound := exactFairBobHistoryLowOperatorPotential_neg_le_entropy G n S D ⟨exactReverseAliceMarkerDecode side context marker, history, aliceAnswer, bobAnswer⟩ have scaled := mul_le_mul_of_nonneg_left bound (exactRevealMass_nonneg G n D (exactReverseAliceMarkerDecode side context marker) history) simpa only [mul_neg] using scaled · simp theorem exactReverseBobAlignedCfcPrefixPotential_terminal_nonpos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (sideNonempty : 0 < side.card) : exactReverseBobAlignedCfcPrefixPotential G n S D side context side.card ≤ 0 := by let marker : Fin side.card := ⟨side.card - 1, Nat.sub_lt sideNonempty (by decide)⟩ have step : marker.val + 1 = side.card := by dsimp [marker] omega have high := exactReverseBobFilterHighOperatorPotential_nonpos G n S D side context marker rw [exactReverseBobHighOperatorPotential_eq_question, exactReverseBobHighQuestionPotential_eq_alignedPrefix, step] at high exact high theorem exactReverseBobFilterOperatorMarkerEntropy_sum_le_scalarEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (sideNonempty : 0 < side.card) : (∑ marker : Fin side.card, exactReverseBobFilterOperatorMarkerEntropy G n S D side context marker) ≤ exactReverseBobAcceptedScalarEntropy G n S D side context ⟨0, sideNonempty⟩ := by let initial : Fin side.card := ⟨0, sideNonempty⟩ have terminal := exactReverseBobAlignedCfcPrefixPotential_terminal_nonpos G n S D side context sideNonempty have scalar := exactReverseBobFilterLowOperatorPotential_neg_le_scalarEntropy G n S D side context initial have initialPotential : exactReverseBobFilterLowOperatorPotential G n S D side context initial = exactReverseBobAlignedCfcPrefixPotential G n S D side context 0 := by rw [exactReverseBobLowOperatorPotential_eq_question, exactReverseBobLowQuestionPotential_eq_alignedPrefix] rw [exactReverseBobFilterOperatorMarkerEntropy_sum_telescope] rw [initialPotential] at scalar change exactReverseBobAlignedCfcPrefixPotential G n S D side context side.card - exactReverseBobAlignedCfcPrefixPotential G n S D side context 0 ≤ exactReverseBobAcceptedScalarEntropy G n S D side context initial linarith end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 6000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactFairFullOutcomeBornMass_eq_reveal_question_born (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : exactFairFullOutcomeBornMass G n S D r x y = exactRevealMass G n D r.seed r.history * G.questionWeight x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by rw [exactFairFullOutcomeBornMass_eq_reveal_question_norm, exactUnnormalizedPsi_norm_sq] theorem exactFairAliceMeanBorn_eq_conditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (y : Y) : bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) = ∑ x : X, G.conditionalXGivenY y x * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by unfold exactAliceMeanFilter simp only [map_sum, map_smul, LinearMap.sum_apply, LinearMap.smul_apply, smul_eq_mul] theorem exactFairBobMeanBorn_eq_conditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) : bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x) = ∑ y : Y, G.conditionalYGivenX x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by unfold exactBobMeanFilter simp only [map_sum, map_smul, smul_eq_mul] theorem exactFairAliceMeanBornMass_eq_fullOutcome_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactRevealMass G n D r.seed r.history * (∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) = ∑ x : X, ∑ y : Y, exactFairFullOutcomeBornMass G n S D r x y := by classical calc exactRevealMass G n D r.seed r.history * (∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D r.seed r.history r.aliceAnswer y) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y)) = ∑ y : Y, ∑ x : X, exactRevealMass G n D r.seed r.history * (G.marginalY y * G.conditionalXGivenY y x) * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro y _ rw [exactFairAliceMeanBorn_eq_conditional, Finset.mul_sum, Finset.mul_sum] apply Finset.sum_congr rfl intro x _ ring _ = ∑ x : X, ∑ y : Y, exactRevealMass G n D r.seed r.history * G.questionWeight x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [G.marginalY_mul_conditionalXGivenY] _ = _ := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ exact (exactFairFullOutcomeBornMass_eq_reveal_question_born G n S D r x y).symm theorem exactFairBobMeanBornMass_eq_fullOutcome_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : exactRevealMass G n D r.seed r.history * (∑ x : X, G.marginalX x * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x)) = ∑ x : X, ∑ y : Y, exactFairFullOutcomeBornMass G n S D r x y := by classical calc exactRevealMass G n D r.seed r.history * (∑ x : X, G.marginalX x * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobMeanFilter G n S D r.seed r.history r.bobAnswer x)) = ∑ x : X, ∑ y : Y, exactRevealMass G n D r.seed r.history * (G.marginalX x * G.conditionalYGivenX x y) * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro x _ rw [exactFairBobMeanBorn_eq_conditional, Finset.mul_sum, Finset.mul_sum] apply Finset.sum_congr rfl intro y _ ring _ = ∑ x : X, ∑ y : Y, exactRevealMass G n D r.seed r.history * G.questionWeight x y * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rw [G.marginalX_mul_conditionalYGivenX] _ = _ := by apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ exact (exactFairFullOutcomeBornMass_eq_reveal_question_born G n S D r x y).symm theorem exactFairAliceMeanAcceptedBornMass_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : (∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D seed history aliceAnswer y) (exactBobQuestionFilter G n S D seed history bobAnswer y)) else 0) = repeatedPostselectionMass G n S D := by classical calc _ = ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then ∑ x : X, ∑ y : Y, exactFairFullOutcomeBornMass G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ x y else 0 := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ split · exact exactFairAliceMeanBornMass_eq_fullOutcome_sum G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ · rfl _ = _ := exactFairFullOutcomeBornMass_accepted_sum G n S D seed theorem exactFairBobMeanAcceptedBornMass_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : (∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ x : X, G.marginalX x * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D seed history aliceAnswer x) (exactBobMeanFilter G n S D seed history bobAnswer x)) else 0) = repeatedPostselectionMass G n S D := by classical calc _ = ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then ∑ x : X, ∑ y : Y, exactFairFullOutcomeBornMass G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ x y else 0 := by apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ split · exact exactFairBobMeanBornMass_eq_fullOutcome_sum G n S D ⟨seed, history, aliceAnswer, bobAnswer⟩ · rfl _ = _ := exactFairFullOutcomeBornMass_accepted_sum G n S D seed end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 7000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactFairAliceScalarAtom (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) := ExactRevealHistory X Y D seed × ({j : Fin n // j ∈ D} → A) × ({j : Fin n // j ∈ D} → B) × Y def exactFairAliceScalarCountingWeight (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairAliceScalarAtom X Y A B D seed) : ℝ := if exactHistoryAccepted G n D ⟨seed, atom.1, atom.2.1, atom.2.2.1⟩ then exactRevealMass G n D seed atom.1 * G.marginalY atom.2.2.2 else 0 def exactFairAliceScalarBornMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairAliceScalarAtom X Y A B D seed) : ℝ := bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D seed atom.1 atom.2.1 atom.2.2.2) (exactBobQuestionFilter G n S D seed atom.1 atom.2.2.1 atom.2.2.2) abbrev ExactFairBobScalarAtom (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) (seed : ExactRemainingSeed D) := ExactRevealHistory X Y D seed × ({j : Fin n // j ∈ D} → A) × ({j : Fin n // j ∈ D} → B) × X def exactFairBobScalarCountingWeight (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairBobScalarAtom X Y A B D seed) : ℝ := if exactHistoryAccepted G n D ⟨seed, atom.1, atom.2.1, atom.2.2.1⟩ then exactRevealMass G n D seed atom.1 * G.marginalX atom.2.2.2 else 0 def exactFairBobScalarBornMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairBobScalarAtom X Y A B D seed) : ℝ := bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D seed atom.1 atom.2.1 atom.2.2.2) (exactBobMeanFilter G n S D seed atom.1 atom.2.2.1 atom.2.2.2) theorem exactFairAliceScalarCountingWeight_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairAliceScalarAtom X Y A B D seed) : 0 ≤ exactFairAliceScalarCountingWeight G n D seed atom := by unfold exactFairAliceScalarCountingWeight split · exact mul_nonneg (exactRevealMass_nonneg G n D seed atom.1) (G.marginalY_nonneg atom.2.2.2) · exact le_rfl theorem exactFairBobScalarCountingWeight_nonneg (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairBobScalarAtom X Y A B D seed) : 0 ≤ exactFairBobScalarCountingWeight G n D seed atom := by unfold exactFairBobScalarCountingWeight split · exact mul_nonneg (exactRevealMass_nonneg G n D seed atom.1) (G.marginalX_nonneg atom.2.2.2) · exact le_rfl theorem exactFairAliceScalarBornMass_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairAliceScalarAtom X Y A B D seed) : 0 ≤ exactFairAliceScalarBornMass G n S D seed atom := by exact trace_mul_posSemidef_nonneg S.state.positive ((exactAliceMeanFilter_posSemidef G n S D seed atom.1 atom.2.1 atom.2.2.2).kronecker (exactBobQuestionFilter_posSemidef G n S D seed atom.1 atom.2.2.1 atom.2.2.2)) theorem exactFairBobScalarBornMass_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairBobScalarAtom X Y A B D seed) : 0 ≤ exactFairBobScalarBornMass G n S D seed atom := by exact trace_mul_posSemidef_nonneg S.state.positive ((exactAliceQuestionFilter_posSemidef G n S D seed atom.1 atom.2.1 atom.2.2.2).kronecker (exactBobMeanFilter_posSemidef G n S D seed atom.1 atom.2.2.1 atom.2.2.2)) theorem exactFairAliceScalarCountingWeight_sum_le (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : (∑ atom : ExactFairAliceScalarAtom X Y A B D seed, exactFairAliceScalarCountingWeight G n D seed atom) ≤ fullHistoryAnswerCount (A := A) (B := B) D := by classical simp only [Fintype.sum_prod_type] calc (∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, ∑ y : Y, exactFairAliceScalarCountingWeight G n D seed (history, aliceAnswer, bobAnswer, y)) ≤ ∑ history : ExactRevealHistory X Y D seed, ∑ _aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ _bobAnswer : {j : Fin n // j ∈ D} → B, ∑ y : Y, exactRevealMass G n D seed history * G.marginalY y := by apply Finset.sum_le_sum intro history _ apply Finset.sum_le_sum intro aliceAnswer _ apply Finset.sum_le_sum intro bobAnswer _ apply Finset.sum_le_sum intro y _ unfold exactFairAliceScalarCountingWeight split · exact le_rfl · exact mul_nonneg (exactRevealMass_nonneg G n D seed history) (G.marginalY_nonneg y) _ = fullHistoryAnswerCount (A := A) (B := B) D * (∑ history : ExactRevealHistory X Y D seed, exactRevealMass G n D seed history) * (∑ y : Y, G.marginalY y) := by simp [fullHistoryAnswerCount, Finset.mul_sum, mul_assoc, mul_comm] _ = _ := by rw [exactRevealMass_sum, G.marginalY_normalized] ring theorem exactFairBobScalarCountingWeight_sum_le (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : (∑ atom : ExactFairBobScalarAtom X Y A B D seed, exactFairBobScalarCountingWeight G n D seed atom) ≤ fullHistoryAnswerCount (A := A) (B := B) D := by classical simp only [Fintype.sum_prod_type] calc (∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, ∑ x : X, exactFairBobScalarCountingWeight G n D seed (history, aliceAnswer, bobAnswer, x)) ≤ ∑ history : ExactRevealHistory X Y D seed, ∑ _aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ _bobAnswer : {j : Fin n // j ∈ D} → B, ∑ x : X, exactRevealMass G n D seed history * G.marginalX x := by apply Finset.sum_le_sum intro history _ apply Finset.sum_le_sum intro aliceAnswer _ apply Finset.sum_le_sum intro bobAnswer _ apply Finset.sum_le_sum intro x _ unfold exactFairBobScalarCountingWeight split · exact le_rfl · exact mul_nonneg (exactRevealMass_nonneg G n D seed history) (G.marginalX_nonneg x) _ = fullHistoryAnswerCount (A := A) (B := B) D * (∑ history : ExactRevealHistory X Y D seed, exactRevealMass G n D seed history) * (∑ x : X, G.marginalX x) := by simp [fullHistoryAnswerCount, Finset.mul_sum, mul_assoc, mul_comm] _ = _ := by rw [exactRevealMass_sum, G.marginalX_normalized] ring theorem exactFairAliceScalarBornMass_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : (∑ atom : ExactFairAliceScalarAtom X Y A B D seed, exactFairAliceScalarCountingWeight G n D seed atom * exactFairAliceScalarBornMass G n S D seed atom) = repeatedPostselectionMass G n S D := by classical calc (∑ atom : ExactFairAliceScalarAtom X Y A B D seed, exactFairAliceScalarCountingWeight G n D seed atom * exactFairAliceScalarBornMass G n S D seed atom) = ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ y : Y, G.marginalY y * bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D seed history aliceAnswer y) (exactBobQuestionFilter G n S D seed history bobAnswer y)) else 0 := by simp only [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ · simp only [exactFairAliceScalarCountingWeight, exactFairAliceScalarBornMass, if_pos accepted, Finset.mul_sum] apply Finset.sum_congr rfl intro y _ ring · simp [exactFairAliceScalarCountingWeight, accepted] _ = _ := exactFairAliceMeanAcceptedBornMass_sum G n S D seed theorem exactFairBobScalarBornMass_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : (∑ atom : ExactFairBobScalarAtom X Y A B D seed, exactFairBobScalarCountingWeight G n D seed atom * exactFairBobScalarBornMass G n S D seed atom) = repeatedPostselectionMass G n S D := by classical calc (∑ atom : ExactFairBobScalarAtom X Y A B D seed, exactFairBobScalarCountingWeight G n D seed atom * exactFairBobScalarBornMass G n S D seed atom) = ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ x : X, G.marginalX x * bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D seed history aliceAnswer x) (exactBobMeanFilter G n S D seed history bobAnswer x)) else 0 := by simp only [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ · simp only [exactFairBobScalarCountingWeight, exactFairBobScalarBornMass, if_pos accepted, Finset.mul_sum] apply Finset.sum_congr rfl intro x _ ring · simp [exactFairBobScalarCountingWeight, accepted] _ = _ := exactFairBobMeanAcceptedBornMass_sum G n S D seed theorem exactFairAliceScalarBornMass_le_one (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairAliceScalarAtom X Y A B D seed) : exactFairAliceScalarBornMass G n S D seed atom ≤ 1 := by exact bornTracePairing_contractions_le_one S.state (exactAliceMeanFilter G n S D seed atom.1 atom.2.1 atom.2.2.2) (exactAliceMeanFilter_complement_posSemidef G n S D seed atom.1 atom.2.1 atom.2.2.2) (exactBobQuestionFilter G n S D seed atom.1 atom.2.2.1 atom.2.2.2) (exactBobQuestionFilter_posSemidef G n S D seed atom.1 atom.2.2.1 atom.2.2.2) (exactBobQuestionFilter_complement_posSemidef G n S D seed atom.1 atom.2.2.1 atom.2.2.2) theorem exactFairBobScalarBornMass_le_one (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (atom : ExactFairBobScalarAtom X Y A B D seed) : exactFairBobScalarBornMass G n S D seed atom ≤ 1 := by exact bornTracePairing_contractions_le_one S.state (exactAliceQuestionFilter G n S D seed atom.1 atom.2.1 atom.2.2.2) (exactAliceQuestionFilter_complement_posSemidef G n S D seed atom.1 atom.2.1 atom.2.2.2) (exactBobMeanFilter G n S D seed atom.1 atom.2.2.1 atom.2.2.2) (exactBobMeanFilter_posSemidef G n S D seed atom.1 atom.2.2.1 atom.2.2.2) (exactBobMeanFilter_complement_posSemidef G n S D seed atom.1 atom.2.2.1 atom.2.2.2) def exactFairAliceSeedScalarEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : ℝ := ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ y : Y, G.marginalY y * Real.negMulLog (bornTracePairing S.state.matrix (exactAliceMeanFilter G n S D seed history aliceAnswer y) (exactBobQuestionFilter G n S D seed history bobAnswer y))) else 0 def exactFairBobSeedScalarEntropy (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : ℝ := ∑ history : ExactRevealHistory X Y D seed, ∑ aliceAnswer : {j : Fin n // j ∈ D} → A, ∑ bobAnswer : {j : Fin n // j ∈ D} → B, if exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ then exactRevealMass G n D seed history * (∑ x : X, G.marginalX x * Real.negMulLog (bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D seed history aliceAnswer x) (exactBobMeanFilter G n S D seed history bobAnswer x))) else 0 theorem exactFairAliceSeedScalarEntropy_eq_weighted (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : exactFairAliceSeedScalarEntropy G n S D seed = ∑ atom : ExactFairAliceScalarAtom X Y A B D seed, exactFairAliceScalarCountingWeight G n D seed atom * Real.negMulLog (exactFairAliceScalarBornMass G n S D seed atom) := by classical unfold exactFairAliceSeedScalarEntropy simp only [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ · simp only [if_pos accepted, exactFairAliceScalarCountingWeight, exactFairAliceScalarBornMass, Finset.mul_sum] apply Finset.sum_congr rfl intro y _ ring · simp [exactFairAliceScalarCountingWeight, accepted] theorem exactFairBobSeedScalarEntropy_eq_weighted (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : exactFairBobSeedScalarEntropy G n S D seed = ∑ atom : ExactFairBobScalarAtom X Y A B D seed, exactFairBobScalarCountingWeight G n D seed atom * Real.negMulLog (exactFairBobScalarBornMass G n S D seed atom) := by classical unfold exactFairBobSeedScalarEntropy simp only [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro history _ apply Finset.sum_congr rfl intro aliceAnswer _ apply Finset.sum_congr rfl intro bobAnswer _ by_cases accepted : exactHistoryAccepted G n D ⟨seed, history, aliceAnswer, bobAnswer⟩ · simp only [if_pos accepted, exactFairBobScalarCountingWeight, exactFairBobScalarBornMass, Finset.mul_sum] apply Finset.sum_congr rfl intro x _ ring · simp [exactFairBobScalarCountingWeight, accepted] theorem exactFairAliceSeedScalarEntropy_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (seed : ExactRemainingSeed D) : exactFairAliceSeedScalarEntropy G n S D seed ≤ repeatedPostselectionMass G n S D * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) := by classical let w := exactFairAliceScalarCountingWeight G n D seed let mass := exactFairAliceScalarBornMass G n S D seed let W : ℝ := ∑ atom : ExactFairAliceScalarAtom X Y A B D seed, w atom have moment : (∑ atom : ExactFairAliceScalarAtom X Y A B D seed, w atom * mass atom) = repeatedPostselectionMass G n S D := exactFairAliceScalarBornMass_sum G n S D seed have lower : repeatedPostselectionMass G n S D ≤ W := by rw [← moment] apply Finset.sum_le_sum intro atom _ exact mul_le_of_le_one_right (exactFairAliceScalarCountingWeight_nonneg G n D seed atom) (exactFairAliceScalarBornMass_le_one G n S D seed atom) have count : W ≤ fullHistoryAnswerCount (A := A) (B := B) D := exactFairAliceScalarCountingWeight_sum_le G n D seed have estimate := finite_weighted_entropy_le_of_weight_bound (Finset.univ : Finset (ExactFairAliceScalarAtom X Y A B D seed)) w mass (W := W) (N := fullHistoryAnswerCount (A := A) (B := B) D) (p := repeatedPostselectionMass G n S D) (fun atom _ => exactFairAliceScalarCountingWeight_nonneg G n D seed atom) (fun atom _ => exactFairAliceScalarBornMass_nonneg G n S D seed atom) (lt_of_lt_of_le positive lower) positive rfl moment count rw [exactFairAliceSeedScalarEntropy_eq_weighted] exact estimate theorem exactFairBobSeedScalarEntropy_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (seed : ExactRemainingSeed D) : exactFairBobSeedScalarEntropy G n S D seed ≤ repeatedPostselectionMass G n S D * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) := by classical let w := exactFairBobScalarCountingWeight G n D seed let mass := exactFairBobScalarBornMass G n S D seed let W : ℝ := ∑ atom : ExactFairBobScalarAtom X Y A B D seed, w atom have moment : (∑ atom : ExactFairBobScalarAtom X Y A B D seed, w atom * mass atom) = repeatedPostselectionMass G n S D := exactFairBobScalarBornMass_sum G n S D seed have lower : repeatedPostselectionMass G n S D ≤ W := by rw [← moment] apply Finset.sum_le_sum intro atom _ exact mul_le_of_le_one_right (exactFairBobScalarCountingWeight_nonneg G n D seed atom) (exactFairBobScalarBornMass_le_one G n S D seed atom) have count : W ≤ fullHistoryAnswerCount (A := A) (B := B) D := exactFairBobScalarCountingWeight_sum_le G n D seed have estimate := finite_weighted_entropy_le_of_weight_bound (Finset.univ : Finset (ExactFairBobScalarAtom X Y A B D seed)) w mass (W := W) (N := fullHistoryAnswerCount (A := A) (B := B) D) (p := repeatedPostselectionMass G n S D) (fun atom _ => exactFairBobScalarCountingWeight_nonneg G n D seed atom) (fun atom _ => exactFairBobScalarBornMass_nonneg G n S D seed atom) (lt_of_lt_of_le positive lower) positive rfl moment count rw [exactFairBobSeedScalarEntropy_eq_weighted] exact estimate theorem exactReverseAliceAcceptedScalarEntropy_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseAliceAcceptedScalarEntropy G n S D side context marker ≤ repeatedPostselectionMass G n S D * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) := by exact exactFairAliceSeedScalarEntropy_le G n S D positive (exactReverseBobMarkerDecode side context marker) theorem exactReverseBobAcceptedScalarEntropy_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : exactReverseBobAcceptedScalarEntropy G n S D side context marker ≤ repeatedPostselectionMass G n S D * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) := by exact exactFairBobSeedScalarEntropy_le G n S D positive (exactReverseAliceMarkerDecode side context marker) end noncomputable section open scoped BigOperators InnerProductSpace variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def sourceAnswerAlphabetBound (A B : Type*) [Fintype A] [Fintype B] : ℝ := max 1 ((Fintype.card A : ℝ) * (Fintype.card B : ℝ)) theorem one_le_sourceAnswerAlphabetBound (A B : Type*) [Fintype A] [Fintype B] : 1 ≤ sourceAnswerAlphabetBound A B := by exact le_max_left _ _ theorem sourceAnswerAlphabetBound_log_nonneg (A B : Type*) [Fintype A] [Fintype B] : 0 ≤ Real.log (sourceAnswerAlphabetBound A B) := by exact Real.log_nonneg (one_le_sourceAnswerAlphabetBound A B) theorem fullHistoryAnswerCount_le_sourceAnswerAlphabetBound_pow {n : ℕ} (D : Finset (Fin n)) : fullHistoryAnswerCount (A := A) (B := B) D ≤ sourceAnswerAlphabetBound A B ^ D.card := by rw [fullHistoryAnswerCount_eq, ← mul_pow] exact pow_le_pow_left₀ (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) (le_max_right 1 _) _ theorem fullHistoryAnswerCount_pos_of_postselection (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D L : Finset (Fin n)) (hL : L ⊆ Finset.univ \ D) (hp : 0 < (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) : 0 < fullHistoryAnswerCount (A := A) (B := B) D := by classical have hmass := fullHistoryAtomBornMass_sum G n S D L hL have hfirst : (∑ t : FullHistoryEntropyAtom X Y A B n D L, fullHistoryAtomCountingWeight G D L t * fullHistoryAtomBornMass G n S D L t) ≤ ∑ t : FullHistoryEntropyAtom X Y A B n D L, fullHistoryAtomCountingWeight G D L t := by apply Finset.sum_le_sum intro t _ exact mul_le_of_le_one_right (fullHistoryAtomCountingWeight_nonneg G D L t) (fullHistoryAtomBornMass_le_one G n S D L t) have hsecond := fullHistoryAtomCountingWeight_sum_le G D L linarith theorem divisor_greedy_remaining_bounds {n q : ℕ} (hq : 2 ≤ q) {D : Finset (Fin n)} (hD : D.card < n / q) : 0 < (Finset.univ \ D).card ∧ n ≤ 2 * (Finset.univ \ D).card ∧ D.card * q ≤ 2 * (Finset.univ \ D).card := by classical have hqpos : 0 < q := by omega have hdq : D.card * q < n := divisor_greedy_card_mul_lt hqpos hD have htwo : D.card * 2 < n := lt_of_le_of_lt (Nat.mul_le_mul_left D.card hq) hdq have hcard : (Finset.univ \ D).card + D.card = n := by simpa using (Finset.card_sdiff_add_card_eq_card (Finset.subset_univ D)) omega theorem divisor_greedy_log_cost_per_remaining_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) {η : ℝ} (hη : 0 < η) {q : ℕ} (hq : 2 ≤ q) (D : Finset (Fin n)) (hD : D.card < n / q) (hwitness : Real.exp (-(η / (4 * (q : ℝ))) * (n : ℝ)) < S.winProbability) (hmass : S.winProbability ≤ (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) : Real.log (fullHistoryAnswerCount (A := A) (B := B) D / (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) / ((Finset.univ \ D).card : ℝ) ≤ (2 * Real.log (sourceAnswerAlphabetBound A B) + η / 2) / (q : ℝ) := by classical let p : ℝ := (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) let m : ℕ := (Finset.univ \ D).card let k : ℝ := sourceAnswerAlphabetBound A B have hqpos : 0 < q := by omega have hqreal : 0 < (q : ℝ) := by exact_mod_cast hqpos have hθ : 0 < S.winProbability := lt_trans (Real.exp_pos _) hwitness have hp : 0 < p := lt_of_lt_of_le hθ hmass have hN : 0 < fullHistoryAnswerCount (A := A) (B := B) D := fullHistoryAnswerCount_pos_of_postselection G n S D ∅ (Finset.empty_subset _) hp have hklog : 0 ≤ Real.log k := sourceAnswerAlphabetBound_log_nonneg A B have hcount : Real.log (fullHistoryAnswerCount (A := A) (B := B) D) ≤ (D.card : ℝ) * Real.log k := by calc Real.log (fullHistoryAnswerCount (A := A) (B := B) D) ≤ Real.log (k ^ D.card) := Real.log_le_log hN (fullHistoryAnswerCount_le_sourceAnswerAlphabetBound_pow D) _ = (D.card : ℝ) * Real.log k := Real.log_pow _ _ have hlogθ : Real.log (1 / S.winProbability) < (η / (4 * (q : ℝ))) * (n : ℝ) := by have hlog := (Real.lt_log_iff_exp_lt hθ).mpr hwitness rw [one_div, Real.log_inv] linarith have hlogp : Real.log (1 / p) ≤ (η / (4 * (q : ℝ))) * (n : ℝ) := by exact (postselection_log_cost_le hθ hmass).trans hlogθ.le have htotal : Real.log (fullHistoryAnswerCount (A := A) (B := B) D / p) ≤ (D.card : ℝ) * Real.log k + (η / (4 * (q : ℝ))) * (n : ℝ) := by rw [Real.log_div hN.ne' hp.ne'] rw [one_div, Real.log_inv] at hlogp linarith obtain ⟨hmnat, hnmnat, hdqmnat⟩ := divisor_greedy_remaining_bounds hq hD have hm : 0 < (m : ℝ) := by exact_mod_cast hmnat have hnm : (n : ℝ) ≤ 2 * (m : ℝ) := by exact_mod_cast hnmnat have hdqm : (D.card : ℝ) * (q : ℝ) ≤ 2 * (m : ℝ) := by exact_mod_cast hdqmnat have hdratio : (D.card : ℝ) / (m : ℝ) ≤ 2 / (q : ℝ) := by exact (div_le_div_iff₀ hm hqreal).mpr hdqm have hnratio : (n : ℝ) / (m : ℝ) ≤ 2 := by exact (div_le_iff₀ hm).mpr hnm have hrate : 0 ≤ η / (4 * (q : ℝ)) := by positivity change Real.log (fullHistoryAnswerCount (A := A) (B := B) D / p) / (m : ℝ) ≤ (2 * Real.log k + η / 2) / (q : ℝ) calc Real.log (fullHistoryAnswerCount (A := A) (B := B) D / p) / (m : ℝ) ≤ ((D.card : ℝ) * Real.log k + (η / (4 * (q : ℝ))) * (n : ℝ)) / (m : ℝ) := by exact (div_le_div_iff_of_pos_right hm).mpr htotal _ = ((D.card : ℝ) / (m : ℝ)) * Real.log k + (η / (4 * (q : ℝ))) * ((n : ℝ) / (m : ℝ)) := by ring _ ≤ (2 / (q : ℝ)) * Real.log k + (η / (4 * (q : ℝ))) * 2 := by exact add_le_add (mul_le_mul_of_nonneg_right hdratio hklog) (mul_le_mul_of_nonneg_left hnratio hrate) _ = (2 * Real.log k + η / 2) / (q : ℝ) := by field_simp ring theorem exists_source_rounding_divisor (A B : Type*) [Fintype A] [Fintype B] {K η δ : ℝ} (hK : 0 ≤ K) (hη : 0 < η) (hδ : 0 < δ) : ∃ q : ℕ, 2 ≤ q ∧ 8 * K * ((2 * Real.log (sourceAnswerAlphabetBound A B) + η / 2) / (q : ℝ)) ≤ δ ^ 2 := by let C : ℝ := 8 * K * (2 * Real.log (sourceAnswerAlphabetBound A B) + η / 2) have hC : 0 ≤ C := by dsimp [C] have hlog := sourceAnswerAlphabetBound_log_nonneg A B positivity have hsquare : 0 < δ ^ 2 := sq_pos_of_pos hδ obtain ⟨q, hq⟩ := exists_nat_gt (max (2 : ℝ) (C / δ ^ 2)) have htwo : (2 : ℝ) < (q : ℝ) := lt_of_le_of_lt (le_max_left _ _) hq have hqnat : 2 ≤ q := by have hstrict : 2 < q := by exact_mod_cast htwo omega have hqreal : 0 < (q : ℝ) := by positivity have hthreshold : C / δ ^ 2 < (q : ℝ) := lt_of_le_of_lt (le_max_right _ _) hq have hsmall : C / (q : ℝ) < δ ^ 2 := by apply (div_lt_iff₀ hqreal).mpr have hcross := (div_lt_iff₀ hsquare).mp hthreshold nlinarith [hC] refine ⟨q, hqnat, ?_⟩ calc 8 * K * ((2 * Real.log (sourceAnswerAlphabetBound A B) + η / 2) / (q : ℝ)) = C / (q : ℝ) := by dsimp [C] ring _ ≤ δ ^ 2 := hsmall.le theorem arbitrarily_large_purified_divisor_greedy_conditioning_with_rounding (G : Game X Y A B) (hwitness : HasSubexponentialWitness (repeatedEntangledValue G)) {η K δ : ℝ} (hη : 0 < η) (hη_one : η ≤ 1) (hK : 0 ≤ K) (hδ : 0 < δ) : ∃ q : ℕ, 2 ≤ q ∧ ∀ N₀ : ℕ, ∃ n : ℕ, N₀ < n ∧ ∃ S : Strategy (G.repeat n), ∃ D : Finset (Fin n), Real.exp (-(η / (4 * (q : ℝ))) * (n : ℝ)) < (purifiedStrategy S).winProbability ∧ D.card < n / q ∧ (purifiedStrategy S).winProbability ≤ (strategyEventLaw (G.repeat n) (purifiedStrategy S)).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) ∧ (∑ i ∈ Finset.univ \ D, FiniteEventLaw.failureMass (strategyEventLaw (G.repeat n) (purifiedStrategy S)) (repeatedCoordinateWin G n) D i) < ((Finset.univ \ D).card : ℝ) * (η * (strategyEventLaw (G.repeat n) (purifiedStrategy S)).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) ∧ 8 * K * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / (strategyEventLaw (G.repeat n) (purifiedStrategy S)).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) / ((Finset.univ \ D).card : ℝ) ≤ δ ^ 2 := by classical obtain ⟨q, hq, hqcost⟩ := exists_source_rounding_divisor A B hK hη hδ refine ⟨q, hq, ?_⟩ intro N₀ have hqpos : 0 < q := by omega have hqreal : 0 < (q : ℝ) := by exact_mod_cast hqpos have hrate : 0 < η / (4 * (q : ℝ)) := by positivity obtain ⟨n, hn, S, hS⟩ := arbitrarily_large_purifiedRepeatedStrategy_of_subexponentialWitness G hwitness hrate (max N₀ q) have hqn : q ≤ n := (Nat.le_max_right N₀ q).trans (Nat.le_of_lt hn) obtain ⟨D, hD, hp, hfail⟩ := repeatedStrategy_exists_divisor_greedy_conditioning G n (purifiedStrategy S) hη hη_one hqpos hqn hS refine ⟨n, (Nat.le_max_left N₀ q).trans_lt hn, S, D, hS, hD, hp, hfail, ?_⟩ have hlog := divisor_greedy_log_cost_per_remaining_le G n (purifiedStrategy S) hη hq D hD hS hp calc 8 * K * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / (strategyEventLaw (G.repeat n) (purifiedStrategy S)).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) / ((Finset.univ \ D).card : ℝ) = (8 * K) * (Real.log (fullHistoryAnswerCount (A := A) (B := B) D / (strategyEventLaw (G.repeat n) (purifiedStrategy S)).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D)) / ((Finset.univ \ D).card : ℝ)) := by ring _ ≤ 8 * K * ((2 * Real.log (sourceAnswerAlphabetBound A B) + η / 2) / (q : ℝ)) := by exact mul_le_mul_of_nonneg_left hlog (by positivity) _ ≤ δ ^ 2 := hqcost end noncomputable section open scoped BigOperators variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem postselectionLogCost_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : 0 ≤ postselectionLogCost G n S D := by have at_most_one : repeatedPostselectionMass G n S D ≤ 1 := postselectionMass_le_one (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D have inverse_at_least_one : (1 : ℝ) ≤ 1 / repeatedPostselectionMass G n S D := by apply (le_div_iff₀ positive).2 simpa using at_most_one exact Real.log_nonneg inverse_at_least_one theorem answerLogCost_nonneg_of_postselection (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : 0 ≤ answerLogCost (A := A) (B := B) D := by classical by_cases empty : D.card = 0 · simp [answerLogCost, empty] have count_positive := answerCount_pos_of_postselection G n S D positive rw [fullHistoryAnswerCount_eq, ← mul_pow] at count_positive have alphabet_nonnegative : 0 ≤ (Fintype.card A : ℝ) * (Fintype.card B : ℝ) := by positivity have alphabet_positive : 0 < (Fintype.card A : ℝ) * (Fintype.card B : ℝ) := by by_contra not_positive have zero : (Fintype.card A : ℝ) * (Fintype.card B : ℝ) = 0 := le_antisymm (le_of_not_gt not_positive) alphabet_nonnegative simp [zero, empty] at count_positive have natural_positive : 0 < Fintype.card A * Fintype.card B := by exact_mod_cast alphabet_positive have alphabet_at_least_one : (1 : ℝ) ≤ (Fintype.card A : ℝ) * (Fintype.card B : ℝ) := by exact_mod_cast natural_positive unfold answerLogCost exact mul_nonneg (Nat.cast_nonneg _) (Real.log_nonneg alphabet_at_least_one) theorem exactSourceClassicalInformationRate_le_three_martingaleRate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : exactSourceClassicalInformationRate G n S D ≤ 3 * martingaleRate G n S D := by have answer_nonnegative := answerLogCost_nonneg_of_postselection G n S D positive unfold exactSourceClassicalInformationRate martingaleRate have denominator_nonnegative : 0 ≤ ((Finset.univ \ D).card : ℝ) := by positivity by_cases denominator_zero : ((Finset.univ \ D).card : ℝ) = 0 · simp [denominator_zero] have denominator_positive : 0 < ((Finset.univ \ D).card : ℝ) := lt_of_le_of_ne denominator_nonnegative (Ne.symm denominator_zero) apply (div_le_iff₀ denominator_positive).2 field_simp linarith theorem exactSourcePinskerRate_le_half_of_martingaleRate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) {rateTolerance : ℝ} (rate_nonnegative : 0 ≤ rateTolerance) (rate_bound : martingaleRate G n S D ≤ rateTolerance ^ 2 / 8) : exactSourcePinskerRate G n S D ≤ rateTolerance / 2 := by unfold exactSourcePinskerRate apply Real.sqrt_le_iff.mpr constructor · positivity · have information := exactSourceClassicalInformationRate_le_three_martingaleRate G n S D positive nlinarith theorem exact_arbitrarily_large_conditioning_of_subexponentialWitness (G : Game X Y A B) (witness : HasSubexponentialWitness (repeatedEntangledValue G)) {failureTolerance rateTolerance : ℝ} (failure_positive : 0 < failureTolerance) (failure_at_most_one : failureTolerance ≤ 1) (rate_positive : 0 < rateTolerance) (lower : ℕ) : ∃ n : ℕ, lower < n ∧ ∃ S : Strategy (G.repeat n), ∃ D : Finset (Fin n), 0 < S.winProbability ∧ 0 < repeatedPostselectionMass G n S D ∧ 0 < (Finset.univ \ D).card ∧ uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < failureTolerance ∧ martingaleRate G n S D ≤ rateTolerance ^ 2 / 8 ∧ exactSourcePinskerRate G n S D ≤ rateTolerance / 2 := by classical obtain ⟨q, q_at_least_two, extract⟩ := arbitrarily_large_purified_divisor_greedy_conditioning_with_rounding G witness (K := (1 : ℝ)) failure_positive failure_at_most_one (by norm_num) rate_positive obtain ⟨n, beyond, S, D, winning, small, mass, failure, cost⟩ := extract lower let actual : Strategy (G.repeat n) := purifiedStrategy S have actual_positive : 0 < actual.winProbability := lt_trans (Real.exp_pos _) winning have postselection_positive : 0 < repeatedPostselectionMass G n actual D := by exact lt_of_lt_of_le actual_positive mass have remaining_positive : 0 < (Finset.univ \ D).card := (divisor_greedy_remaining_bounds q_at_least_two small).1 have failure_small : uniformRemainingFailure (strategyEventLaw (G.repeat n) actual) (repeatedCoordinateWin G n) D < failureTolerance := by apply uniformRemainingFailure_lt_of_failure_sum (strategyEventLaw (G.repeat n) actual) (repeatedCoordinateWin G n) D postselection_positive remaining_positive exact failure have scaled_rate : 8 * martingaleRate G n actual D ≤ rateTolerance ^ 2 := by calc 8 * martingaleRate G n actual D = 8 * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n actual D) / ((Finset.univ \ D).card : ℝ) := by unfold martingaleRate rw [← martingale_log_cost_eq G n actual D postselection_positive] ring _ ≤ rateTolerance ^ 2 := by simpa [actual, repeatedPostselectionMass, postselectionMass] using cost have actual_rate : martingaleRate G n actual D ≤ rateTolerance ^ 2 / 8 := by apply (le_div_iff₀ (by norm_num : (0 : ℝ) < 8)).2 nlinarith exact ⟨n, beyond, actual, D, actual_positive, postselection_positive, remaining_positive, failure_small, actual_rate, exactSourcePinskerRate_le_half_of_martingaleRate G n actual D postselection_positive rate_positive.le actual_rate⟩ end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 8000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactReversePartitionInverseCard_le {M : Type*} [Fintype M] [DecidableEq M] : (∑ side : Finset M, reversePartitionWeight side / (side.card : ℝ)) ≤ 2 / (Fintype.card M : ℝ) := by classical have point (side : Finset M) : reversePartitionWeight side / (side.card : ℝ) ≤ forwardMarkedPartitionWeight M := by by_cases nonempty : side.Nonempty · obtain ⟨coordinate, member⟩ := nonempty have marked := reverseMarkedPartitionWeight_eq_forward member simpa only [reverseMarkedPartitionWeight, if_pos member] using le_of_eq marked · have empty : side = ∅ := Finset.not_nonempty_iff_eq_empty.mp nonempty subst side have nonnegative : 0 ≤ forwardMarkedPartitionWeight M := by unfold forwardMarkedPartitionWeight exact div_nonneg (mul_nonneg (by norm_num) fairPartitionWeight_nonneg) (by exact_mod_cast Nat.zero_le (Fintype.card M)) simpa using nonnegative calc (∑ side : Finset M, reversePartitionWeight side / (side.card : ℝ)) ≤ ∑ _side : Finset M, forwardMarkedPartitionWeight M := by apply Finset.sum_le_sum intro side _ exact point side _ = (2 / (Fintype.card M : ℝ)) * (∑ _side : Finset M, fairPartitionWeight M) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro side _ unfold forwardMarkedPartitionWeight ring _ = _ := by rw [fairPartitionWeight_sum]; ring theorem exactReverseBobSeedInverseCard_le {M : Type*} [Fintype M] [DecidableEq M] : (∑ seed : ExactForwardSeed M, exactSeedWeight seed / ((exactReverseRightSide seed).card : ℝ)) ≤ 2 / (Fintype.card M : ℝ) := by classical have push := groupedMass_expectation (exactReverseRightSide (M := M)) (exactSeedWeight (M := M)) (fun side : Finset M => ((side.card : ℝ))⁻¹) calc (∑ seed : ExactForwardSeed M, exactSeedWeight seed / ((exactReverseRightSide seed).card : ℝ)) = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((exactReverseRightSide seed).card : ℝ)⁻¹ := by simp only [div_eq_mul_inv] _ = ∑ side : Finset M, groupedMass (exactReverseRightSide (M := M)) (exactSeedWeight (M := M)) side * ((side.card : ℝ))⁻¹ := push.symm _ = ∑ side : Finset M, reversePartitionWeight side / (side.card : ℝ) := by apply Finset.sum_congr rfl intro side _ rw [exactReverseBobSide_marginal] exact (div_eq_mul_inv _ _).symm _ ≤ _ := exactReversePartitionInverseCard_le theorem exactReverseAliceSeedInverseCard_le {M : Type*} [Fintype M] [DecidableEq M] : (∑ seed : ExactForwardSeed M, exactSeedWeight seed / ((exactReverseLeftSide seed).card : ℝ)) ≤ 2 / (Fintype.card M : ℝ) := by classical have push := groupedMass_expectation (exactReverseLeftSide (M := M)) (exactSeedWeight (M := M)) (fun side : Finset M => ((side.card : ℝ))⁻¹) calc (∑ seed : ExactForwardSeed M, exactSeedWeight seed / ((exactReverseLeftSide seed).card : ℝ)) = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((exactReverseLeftSide seed).card : ℝ)⁻¹ := by simp only [div_eq_mul_inv] _ = ∑ side : Finset M, groupedMass (exactReverseLeftSide (M := M)) (exactSeedWeight (M := M)) side * ((side.card : ℝ))⁻¹ := push.symm _ = ∑ side : Finset M, reversePartitionWeight side / (side.card : ℝ) := by apply Finset.sum_congr rfl intro side _ rw [exactReverseAliceSide_marginal] exact (div_eq_mul_inv _ _).symm _ ≤ _ := exactReversePartitionInverseCard_le theorem exactFairSourceScalarCost_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : 0 ≤ repeatedPostselectionMass G n S D * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) := by rw [martingale_log_cost_eq G n S D positive] exact mul_nonneg positive.le (add_nonneg (postselectionLogCost_nonneg G n S D positive) (answerLogCost_nonneg_of_postselection G n S D positive)) theorem exactFairAcceptedAliceEntropy_le_sourceRate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) : exactFairAcceptedAliceEntropy G n S D ≤ 2 * (repeatedPostselectionMass G n S D * martingaleRate G n S D) := by classical let cost : ℝ := repeatedPostselectionMass G n S D * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) have nonnegative : 0 ≤ cost := exactFairSourceScalarCost_nonneg G n S D positive have mpositive : 0 < Fintype.card (SourceRemainingCoordinate D) := by simpa using remaining unfold exactFairAcceptedAliceEntropy rw [exactFairAliceOperatorEntropy_reverse_marked_average G n S D mpositive] calc (∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, exactReverseAliceFilterOperatorMarkerEntropy G n S D (exactReverseRightSide seed) (exactReverseBobContext seed) marker) / ((exactReverseRightSide seed).card : ℝ))) ≤ ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * (cost / ((exactReverseRightSide seed).card : ℝ)) := by apply Finset.sum_le_sum intro seed _ have nonempty : 0 < (exactReverseRightSide seed).card := Finset.card_pos.mpr ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ have endpoint := exactReverseAliceFilterOperatorMarkerEntropy_sum_le_scalarEntropy G n S D (exactReverseRightSide seed) (exactReverseBobContext seed) nonempty have scalar := exactReverseAliceAcceptedScalarEntropy_le G n S D positive (exactReverseRightSide seed) (exactReverseBobContext seed) ⟨0, nonempty⟩ have total : (∑ marker : Fin (exactReverseRightSide seed).card, exactReverseAliceFilterOperatorMarkerEntropy G n S D (exactReverseRightSide seed) (exactReverseBobContext seed) marker) ≤ cost := endpoint.trans scalar apply mul_le_mul_of_nonneg_left ((div_le_div_iff_of_pos_right (by exact_mod_cast nonempty)).mpr total) (exactSeedWeight_nonneg seed) _ = cost * (∑ seed : ExactRemainingSeed D, exactSeedWeight seed / ((exactReverseRightSide seed).card : ℝ)) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro seed _ ring _ ≤ cost * (2 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) := mul_le_mul_of_nonneg_left (exactReverseBobSeedInverseCard_le (M := SourceRemainingCoordinate D)) nonnegative _ = 2 * (repeatedPostselectionMass G n S D * martingaleRate G n S D) := by dsimp [cost] rw [martingale_log_cost_eq G n S D positive] have cardinal : Fintype.card (SourceRemainingCoordinate D) = (Finset.univ \ D).card := by simp rw [cardinal] unfold martingaleRate ring theorem exactFairAcceptedBobEntropy_le_sourceRate (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) : exactFairAcceptedBobEntropy G n S D ≤ 2 * (repeatedPostselectionMass G n S D * martingaleRate G n S D) := by classical let cost : ℝ := repeatedPostselectionMass G n S D * Real.log (fullHistoryAnswerCount (A := A) (B := B) D / repeatedPostselectionMass G n S D) have nonnegative : 0 ≤ cost := exactFairSourceScalarCost_nonneg G n S D positive have mpositive : 0 < Fintype.card (SourceRemainingCoordinate D) := by simpa using remaining unfold exactFairAcceptedBobEntropy rw [exactFairBobOperatorEntropy_reverse_marked_average G n S D mpositive] calc (∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, exactReverseBobFilterOperatorMarkerEntropy G n S D (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) / ((exactReverseLeftSide seed).card : ℝ))) ≤ ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * (cost / ((exactReverseLeftSide seed).card : ℝ)) := by apply Finset.sum_le_sum intro seed _ have nonempty : 0 < (exactReverseLeftSide seed).card := Finset.card_pos.mpr ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ have endpoint := exactReverseBobFilterOperatorMarkerEntropy_sum_le_scalarEntropy G n S D (exactReverseLeftSide seed) (exactReverseAliceContext seed) nonempty have scalar := exactReverseBobAcceptedScalarEntropy_le G n S D positive (exactReverseLeftSide seed) (exactReverseAliceContext seed) ⟨0, nonempty⟩ have total : (∑ marker : Fin (exactReverseLeftSide seed).card, exactReverseBobFilterOperatorMarkerEntropy G n S D (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) ≤ cost := endpoint.trans scalar apply mul_le_mul_of_nonneg_left ((div_le_div_iff_of_pos_right (by exact_mod_cast nonempty)).mpr total) (exactSeedWeight_nonneg seed) _ = cost * (∑ seed : ExactRemainingSeed D, exactSeedWeight seed / ((exactReverseLeftSide seed).card : ℝ)) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro seed _ ring _ ≤ cost * (2 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) := mul_le_mul_of_nonneg_left (exactReverseAliceSeedInverseCard_le (M := SourceRemainingCoordinate D)) nonnegative _ = 2 * (repeatedPostselectionMass G n S D * martingaleRate G n S D) := by dsimp [cost] rw [martingale_log_cost_eq G n S D positive] have cardinal : Fintype.card (SourceRemainingCoordinate D) = (Finset.univ \ D).card := by simp rw [cardinal] unfold martingaleRate ring theorem exactFairOperatorEntropyBound_of_positive (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) : ExactFairOperatorEntropyBound G n S D (martingaleRate G n S D) := ⟨exactFairAcceptedAliceEntropy_le_sourceRate G n S D remaining positive, exactFairAcceptedBobEntropy_le_sourceRate G n S D remaining positive⟩ theorem exactSourceStateDistanceBound_of_positive (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) : ExactSourceStateDistanceBound G n S D (martingaleRate G n S D) := exactSourceStateDistanceBound_of_fair_operator_entropy G n S D (martingaleRate G n S D) positive (exactFairOperatorEntropyBound_of_positive G n S D remaining positive) end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder theorem unconditionalLiterature_weightedNormMean_le_sqrtEnergy {ι : Type*} [Fintype ι] (weight value : ι → ℝ) (weight_nonnegative : ∀ i, 0 ≤ weight i) (weight_normalized : (∑ i, weight i) = 1) (value_nonnegative : ∀ i, 0 ≤ value i) : (∑ i, weight i * value i) ≤ Real.sqrt (∑ i, weight i * value i ^ 2) := by classical have jensen := weighted_rpow_mean_le weight (fun i => value i ^ 2) weight_nonnegative weight_normalized (fun i => sq_nonneg (value i)) (r := (1 / 2 : ℝ)) (by norm_num) (by norm_num) calc (∑ i, weight i * value i) = ∑ i, weight i * (value i ^ 2) ^ (1 / 2 : ℝ) := by apply Finset.sum_congr rfl intro i _ rw [← Real.sqrt_eq_rpow, Real.sqrt_sq_eq_abs, abs_of_nonneg (value_nonnegative i)] _ ≤ (∑ i, weight i * value i ^ 2) ^ (1 / 2 : ℝ) := jensen _ = Real.sqrt (∑ i, weight i * value i ^ 2) := by rw [Real.sqrt_eq_rpow] theorem unconditionalLiterature_sqrt_two_mul_sqrt_thirtytwo (η : ℝ) : 8 * Real.sqrt 2 * Real.sqrt (32 * η) = 64 * Real.sqrt η := by calc 8 * Real.sqrt 2 * Real.sqrt (32 * η) = 8 * Real.sqrt ((2 : ℝ) * (32 * η)) := by rw [Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 2)] ring _ = 8 * Real.sqrt ((64 : ℝ) * η) := by congr 2 ring _ = 64 * Real.sqrt η := by rw [Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 64)] norm_num ring theorem unconditionalLiterature_weightedAsynchronous_le {ι : Type*} [Fintype ι] (weight value asynchronous : ι → ℝ) (weight_nonnegative : ∀ i, 0 ≤ weight i) (weight_normalized : (∑ i, weight i) = 1) (value_nonnegative : ∀ i, 0 ≤ value i) (η δ : ℝ) (source_energy : (∑ i, weight i * value i ^ 2) ≤ 32 * η) (physical : ∀ i, asynchronous i ≤ 8 * Real.sqrt 2 * value i + δ) : (∑ i, weight i * asynchronous i) ≤ 64 * Real.sqrt η + δ := by classical have mean := unconditionalLiterature_weightedNormMean_le_sqrtEnergy weight value weight_nonnegative weight_normalized value_nonnegative have distance : (∑ i, weight i * value i) ≤ Real.sqrt (32 * η) := mean.trans (Real.sqrt_le_sqrt source_energy) calc (∑ i, weight i * asynchronous i) ≤ ∑ i, weight i * (8 * Real.sqrt 2 * value i + δ) := by apply Finset.sum_le_sum intro i _ exact mul_le_mul_of_nonneg_left (physical i) (weight_nonnegative i) _ = 8 * Real.sqrt 2 * (∑ i, weight i * value i) + δ := by calc (∑ i, weight i * (8 * Real.sqrt 2 * value i + δ)) = 8 * Real.sqrt 2 * (∑ i, weight i * value i) + δ * (∑ i, weight i) := by rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro i _ ring _ = _ := by rw [weight_normalized]; ring _ ≤ 8 * Real.sqrt 2 * Real.sqrt (32 * η) + δ := by gcongr _ = 64 * Real.sqrt η + δ := by rw [unconditionalLiterature_sqrt_two_mul_sqrt_thirtytwo] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass {A C : Type*} [Fintype A] [Fintype C] {L : ℕ} (alice : A → Fin (L + 1)) (bob : C → Fin (L + 1)) (z : EuclideanSpace ℂ (A × C)) : ℝ := ∑ a : A, ∑ b : C, ‖z (a, b)‖ ^ 2 * if alice a = bob b then (0 : ℝ) else 1 theorem dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass_nonneg {A C : Type*} [Fintype A] [Fintype C] {L : ℕ} (alice : A → Fin (L + 1)) (bob : C → Fin (L + 1)) (z : EuclideanSpace ℂ (A × C)) : 0 ≤ dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass alice bob z := by classical unfold dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass apply Finset.sum_nonneg intro a _ apply Finset.sum_nonneg intro b _ split_ifs <;> positivity end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder attribute [local instance] Classical.propDecidable theorem dSVDensityRationalHeterogeneousActualPhysicalState_apply (N : ℕ) {S d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) : dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (a, b) = ∑ x : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, ∑ y : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, (dSVDensityRationalHeterogeneousActualAliceUnitary N width schedule ξ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) a x * (dSVDensityRationalHeterogeneousActualBobUnitary N width schedule ζ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) b y * dSVUniformDensityThresholdWholeHistorySharedState N d L (x, y) := by classical unfold dSVDensityRationalHeterogeneousActualPhysicalState change (∑ q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, ((dSVDensityRationalHeterogeneousActualAliceUnitary N width schedule ξ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) ⊗ₖ (dSVDensityRationalHeterogeneousActualBobUnitary N width schedule ζ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ)) (a, b) q * dSVUniformDensityThresholdWholeHistorySharedState N d L q) = _ rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rfl theorem dSVDensityRationalHeterogeneousActualPhysicalState_apply_zeroFlag (N : ℕ) {S d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) : dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (a, b) = ∑ x : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d, ∑ y : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d, (dSVDensityRationalHeterogeneousActualAliceUnitary N width schedule ξ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) a ⟨0, x⟩ * (dSVDensityRationalHeterogeneousActualBobUnitary N width schedule ζ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) b ⟨0, y⟩ * dSVUniformDensityIndependentSharedState (L + 1) N d (x, y) := by classical have split_zero (p q : Prop) [Decidable p] [Decidable q] (v : ℂ) : (if p ∧ q then v else 0) = if p then (if q then v else 0) else 0 := by split_ifs <;> simp_all rw [dSVDensityRationalHeterogeneousActualPhysicalState_apply] simp only [Fintype.sum_sigma] simp_rw [dSVUniformDensityCompletePureHistory_zeroFlag_apply, mul_ite, mul_zero] simp_rw [split_zero] simp theorem dSVDensityRationalHeterogeneousActualSpectralStopping_apply {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) (U : Matrix.unitaryGroup β ℂ) (flag : Fin (L + 1)) (history input : Fin (L + 1) → β) : ((dSVDensityRationalHeterogeneousActualFirstAcceptUnitary accepted * dSVDensityRationalFirstAcceptActualTensorBasis (L := L) U : Matrix.unitaryGroup (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) ⟨flag, history⟩ ⟨0, input⟩ = if flag = dSVDensityRationalHeterogeneousActualFirstAccepted accepted history then ∏ i : Fin (L + 1), (U : Matrix β β ℂ) (history i) (input i) else 0 := by classical let T := dSVDensityRationalFirstAcceptActualTensorBasis (L := L) U let W := dSVDensityRationalHeterogeneousActualFirstAcceptUnitary accepted let v : (Fin (L + 1) → β) → ℂ := fun h => ∏ i : Fin (L + 1), (U : Matrix β β ℂ) (h i) (input i) have spectral_column : (fun q : (Σ _ : Fin (L + 1), Fin (L + 1) → β) => (T : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) q ⟨0, input⟩) = fun q => if q.1 = 0 then v q.2 else 0 := by funext q rcases q with ⟨stop, copies⟩ change (controlledFiniteTensorLocalUnitary (fun (_ : Fin (L + 1)) (_ : Fin (L + 1)) => U) : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) ⟨stop, copies⟩ ⟨0, input⟩ = if stop = 0 then v copies else 0 rw [controlledFiniteTensorLocalUnitary_apply] change (W : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ).mulVec (fun q => (T : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) q ⟨0, input⟩) ⟨flag, history⟩ = if flag = dSVDensityRationalHeterogeneousActualFirstAccepted accepted history then v history else 0 rw [spectral_column] exact dSVDensityRationalHeterogeneousActualFirstAcceptUnitary_zeroFlag accepted v flag history theorem dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary_apply {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) (U : Matrix.unitaryGroup β ℂ) (flag : Fin (L + 1)) (output input : Fin (L + 1) → β) : (dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary accepted U : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) ⟨flag, output⟩ ⟨0, input⟩ = ∑ history : Fin (L + 1) → β, (∏ i : Fin (L + 1), star ((U : Matrix β β ℂ) (history i) (output i))) * (if flag = dSVDensityRationalHeterogeneousActualFirstAccepted accepted history then ∏ i : Fin (L + 1), (U : Matrix β β ℂ) (history i) (input i) else 0) := by classical have restoration (other : Fin (L + 1)) (history : Fin (L + 1) → β) : (((dSVDensityRationalFirstAcceptActualTensorBasis (L := L) U)⁻¹ : Matrix.unitaryGroup (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) ⟨flag, output⟩ ⟨other, history⟩ = if flag = other then ∏ i : Fin (L + 1), star ((U : Matrix β β ℂ) (history i) (output i)) else 0 := by exact dSVUniformDensityFirstAcceptControlledTensor_inv_apply (fun (_ : Fin (L + 1)) (_ : Fin (L + 1)) => U) flag other output history unfold dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary rw [mul_assoc] change ((((dSVDensityRationalFirstAcceptActualTensorBasis (L := L) U)⁻¹ : Matrix.unitaryGroup (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) * ((dSVDensityRationalHeterogeneousActualFirstAcceptUnitary accepted * dSVDensityRationalFirstAcceptActualTensorBasis (L := L) U : Matrix.unitaryGroup (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ)) ⟨flag, output⟩ ⟨0, input⟩ = _ rw [Matrix.mul_apply, Fintype.sum_sigma, Finset.sum_comm] simp_rw [restoration, dSVDensityRationalHeterogeneousActualSpectralStopping_apply] simp [ite_mul] theorem dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary_sourceProduct {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) (U : Matrix.unitaryGroup β ℂ) (flag : Fin (L + 1)) (output input : Fin (L + 1) → β) : (dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary accepted U : Matrix (Σ _ : Fin (L + 1), Fin (L + 1) → β) (Σ _ : Fin (L + 1), Fin (L + 1) → β) ℂ) ⟨flag, output⟩ ⟨0, input⟩ = ∏ i : Fin (L + 1), ∑ atom : β, star ((U : Matrix β β ℂ) atom (output i)) * (if dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i atom then (U : Matrix β β ℂ) atom (input i) else 0) := by rw [dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary_apply] exact dSVDensityRationalHeterogeneousActualFirstAccepted_sourceProduct accepted flag (fun i atom => star ((U : Matrix β β ℂ) atom (output i))) (fun i atom => (U : Matrix β β ℂ) atom (input i)) def dSVDensityRationalHeterogeneousActualPhysicalFlagMass (N : ℕ) {S d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (flagAlice flagBob : Fin (L + 1)) : ℝ := ∑ alice : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d, ∑ bob : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d, ‖dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (⟨flagAlice, alice⟩, ⟨flagBob, bob⟩)‖ ^ 2 def dSVDensityRationalHeterogeneousActualAsynchronousFlagMass (N : ℕ) {S d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : ℝ := dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ) theorem dSVDensityRationalHeterogeneousActualAsynchronousFlagMass_nonneg (N : ℕ) {S d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : 0 ≤ dSVDensityRationalHeterogeneousActualAsynchronousFlagMass N width schedule ξ ζ := by exact dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass_nonneg (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem dSVDensityRationalCompleteStoppedOptionalLocalSchedule_before {L : ℕ} (j : Fin L) (i : Fin (L + 1)) (earlier : i.val < j.val) : dSVDensityRationalCompleteStoppedOptionalLocalSchedule L j.succ i = some false := by have attempted : i.val < L := lt_trans earlier j.isLt simp [dSVDensityRationalCompleteStoppedOptionalLocalSchedule, attempted, Fin.succ_ne_zero, earlier] theorem dSVDensityRationalCompleteStoppedOptionalLocalSchedule_after {L : ℕ} (j : Fin L) (i : Fin (L + 1)) (later : j.val < i.val) : dSVDensityRationalCompleteStoppedOptionalLocalSchedule L j.succ i = none := by have not_before : ¬ i.val < j.val := by omega have not_equal : i.val ≠ j.val := by omega simp [dSVDensityRationalCompleteStoppedOptionalLocalSchedule, Fin.succ_ne_zero, not_before, not_equal] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable theorem dSVDensityRationalFirstAcceptActualPredicateMask_eq_spectralMask {d : ℕ} (w : ℝ) (N : ℕ) (ξ : BipartiteUnitVector d) (outcome : Bool) : (Matrix.diagonal fun q : DSVUniformDensityThresholdLocalIndex N d => if dSVDensityRationalProjectiveThresholdBin w N q.1 ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues q.2) = outcome then (1 : ℂ) else 0) = dSVDensityRationalFirstAcceptLocalSpectralMask w N ξ outcome := by classical ext ⟨k, i⟩ ⟨l, j⟩ by_cases flags : k = l · subst l by_cases atoms : i = j · subst j simp [dSVDensityRationalFirstAcceptLocalSpectralMask, Matrix.blockDiagonal'_apply] · simp [dSVDensityRationalFirstAcceptLocalSpectralMask, Matrix.blockDiagonal'_apply, atoms] · simp [dSVDensityRationalFirstAcceptLocalSpectralMask, Matrix.blockDiagonal'_apply, flags] theorem dSVDensityRationalFirstAcceptActualOptionalOutcome_apply {d : ℕ} (w : ℝ) (N : ℕ) (ξ ζ : BipartiteUnitVector d) (a b : Option Bool) (alice bob : DSVUniformDensityThresholdLocalIndex N d) : dSVDensityRationalCompleteStoppedOptionalOutcome w N ξ ζ a b (alice, bob) = ∑ x : DSVUniformDensityThresholdLocalIndex N d, ∑ y : DSVUniformDensityThresholdLocalIndex N d, dSVDensityRationalCompleteStoppedOptionalLocalEffect w N ξ a alice x * (dSVDensityRationalCompleteStoppedOptionalLocalEffect w N ζ b).transpose bob y * dSVUniformDensityThresholdSharedState N d (x, y) := by classical unfold dSVDensityRationalCompleteStoppedOptionalOutcome change (∑ q : DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d, (dSVDensityRationalCompleteStoppedOptionalLocalEffect w N ξ a ⊗ₖ (dSVDensityRationalCompleteStoppedOptionalLocalEffect w N ζ b).transpose) (alice, bob) q * dSVUniformDensityThresholdSharedState N d q) = _ rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ rfl end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth {S L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (i : Fin (L + 1)) : ℝ := if active : i.val < L then width (schedule ⟨i.val, active⟩) else 0 def dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) (U : Matrix.unitaryGroup β ℂ) (flag : Fin (L + 1)) (i : Fin (L + 1)) : Matrix β β ℂ := fun output input => ∑ atom : β, star ((U : Matrix β β ℂ) atom output) * (if dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i atom then (U : Matrix β β ℂ) atom input else 0) theorem dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix_eq_spectralMask {β : Type*} [Fintype β] [DecidableEq β] {L : ℕ} (accepted : Fin L → β → Prop) (U : Matrix.unitaryGroup β ℂ) (flag : Fin (L + 1)) (i : Fin (L + 1)) : dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix accepted U flag i = (((U⁻¹ : Matrix.unitaryGroup β ℂ) : Matrix β β ℂ) * (Matrix.diagonal fun atom : β => if dSVDensityRationalHeterogeneousActualCopyCondition accepted flag i atom then (1 : ℂ) else 0) * (U : Matrix β β ℂ)) := by classical ext output input simp [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix, Matrix.mul_apply, Matrix.diagonal_apply, mul_ite] theorem dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyConditionMask {S d N L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (flag i : Fin (L + 1)) : (Matrix.diagonal fun q : DSVUniformDensityThresholdLocalIndex N d => if dSVDensityRationalHeterogeneousActualCopyCondition (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ξ) flag i q then (1 : ℂ) else 0) = match dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flag i with | none => 1 | some outcome => dSVDensityRationalFirstAcceptLocalSpectralMask (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ outcome := by classical by_cases active : i.val < L · induction flag using Fin.cases with | zero => rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_zero, if_pos active] simp only [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth, dif_pos active] rw [← dSVDensityRationalFirstAcceptActualPredicateMask_eq_spectralMask (width (schedule ⟨i.val, active⟩)) N ξ false] congr 1 funext q cases h : dSVDensityRationalProjectiveThresholdBin (width (schedule ⟨i.val, active⟩)) N q.1 ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues q.2) <;> simp [dSVDensityRationalHeterogeneousActualCopyCondition, dSVDensityRationalHeterogeneousActualCopyAccepted, dSVDensityRationalCompletePhysicalStoppingCopyAccepted, active, h] | succ j => rcases lt_trichotomy i.val j.val with earlier | equal | later · rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_before j i earlier] simp only [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth, dif_pos active] rw [← dSVDensityRationalFirstAcceptActualPredicateMask_eq_spectralMask (width (schedule ⟨i.val, active⟩)) N ξ false] congr 1 funext q cases h : dSVDensityRationalProjectiveThresholdBin (width (schedule ⟨i.val, active⟩)) N q.1 ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues q.2) <;> simp [dSVDensityRationalHeterogeneousActualCopyCondition, dSVDensityRationalHeterogeneousActualCopyAccepted, dSVDensityRationalCompletePhysicalStoppingCopyAccepted, active, earlier, Fin.succ_ne_zero, h] · have selected : i = j.castSucc := Fin.ext equal subst i rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_hit] simp only [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth, dif_pos active] have selectedIndex : (⟨j.castSucc.val, active⟩ : Fin L) = j := Fin.ext rfl rw [selectedIndex] rw [← dSVDensityRationalFirstAcceptActualPredicateMask_eq_spectralMask (width (schedule j)) N ξ true] congr 1 funext q simp [dSVDensityRationalHeterogeneousActualCopyCondition, dSVDensityRationalHeterogeneousActualCopyAccepted, dSVDensityRationalCompletePhysicalStoppingCopyAccepted, j.isLt, Fin.succ_ne_zero] · rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_after j i later] simp [dSVDensityRationalHeterogeneousActualCopyCondition, active, Fin.succ_ne_zero, show ¬ i.val < j.val by omega, show i.val ≠ j.val by omega] · simp [dSVDensityRationalHeterogeneousActualCopyCondition, dSVDensityRationalCompleteStoppedOptionalLocalSchedule, active] theorem dSVDensityRationalHeterogeneousActualPhysicalFlagBornAliceCopy_eq_optionalEffect {S d N L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (flag i : Fin (L + 1)) : dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ξ) (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) flag i = dSVDensityRationalCompleteStoppedOptionalLocalEffect (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flag i) := by rw [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix_eq_spectralMask, dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyConditionMask] cases h : dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flag i with | none => simp [dSVDensityRationalCompleteStoppedOptionalLocalEffect] | some outcome => simpa [h, dSVDensityRationalCompleteStoppedOptionalLocalEffect] using (dSVDensityRationalFirstAcceptPhysicalEffect_eq_spectralMask (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ outcome).symm theorem dSVDensityRationalHeterogeneousActualPhysicalFlagBornBobCopy_eq_optionalEffect {S d N L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ζ : BipartiteUnitVector d) (flag i : Fin (L + 1)) : dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ζ) ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) flag i = (dSVDensityRationalCompleteStoppedOptionalLocalEffect (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flag i)).transpose := by rw [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix_eq_spectralMask, dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyConditionMask] cases h : dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flag i with | none => simp [dSVDensityRationalCompleteStoppedOptionalLocalEffect] | some outcome => change _ = (transposePOVM (dSVDensityRationalCompleteProjectiveBinaryPOVM (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ζ)).effect outcome simpa only [inv_inv] using (dSVDensityRationalFirstAcceptPhysicalBobEffect_eq_spectralMask (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ζ outcome).symm theorem dSVDensityRationalHeterogeneousActualPhysicalFlagBornAlice_sourceProduct {S d N L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (flag : Fin (L + 1)) (output input : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d) : (dSVDensityRationalHeterogeneousActualAliceUnitary N width schedule ξ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) ⟨flag, output⟩ ⟨0, input⟩ = ∏ i : Fin (L + 1), dSVDensityRationalCompleteStoppedOptionalLocalEffect (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flag i) (output i) (input i) := by change (dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ξ) (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) ⟨flag, output⟩ ⟨0, input⟩ = _ rw [dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary_sourceProduct] apply Finset.prod_congr rfl intro i _ change dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ξ) (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) flag i (output i) (input i) = _ exact congrArg (fun M => M (output i) (input i)) (dSVDensityRationalHeterogeneousActualPhysicalFlagBornAliceCopy_eq_optionalEffect width schedule ξ flag i) theorem dSVDensityRationalHeterogeneousActualPhysicalFlagBornBob_sourceProduct {S d N L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ζ : BipartiteUnitVector d) (flag : Fin (L + 1)) (output input : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d) : (dSVDensityRationalHeterogeneousActualBobUnitary N width schedule ζ : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) ⟨flag, output⟩ ⟨0, input⟩ = ∏ i : Fin (L + 1), (dSVDensityRationalCompleteStoppedOptionalLocalEffect (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flag i)).transpose (output i) (input i) := by change (dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ζ) ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) ⟨flag, output⟩ ⟨0, input⟩ = _ rw [dSVDensityRationalHeterogeneousActualPhysicalLocalUnitary_sourceProduct] apply Finset.prod_congr rfl intro i _ change dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyMatrix (dSVDensityRationalHeterogeneousActualCopyAccepted width schedule ζ) ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) flag i (output i) (input i) = _ exact congrArg (fun M => M (output i) (input i)) (dSVDensityRationalHeterogeneousActualPhysicalFlagBornBobCopy_eq_optionalEffect width schedule ζ flag i) theorem dSVDensityRationalHeterogeneousActualPhysicalFlagBornState_allFlags {S d N L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (flagAlice flagBob : Fin (L + 1)) (alice bob : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d) : dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (⟨flagAlice, alice⟩, ⟨flagBob, bob⟩) = ∏ i : Fin (L + 1), dSVDensityRationalCompleteStoppedOptionalOutcome (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagAlice i) (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagBob i) (alice i, bob i) := by rw [dSVDensityRationalHeterogeneousActualPhysicalState_apply_zeroFlag] simp_rw [dSVUniformDensityIndependentSharedState_apply, dSVDensityRationalHeterogeneousActualPhysicalFlagBornAlice_sourceProduct, dSVDensityRationalHeterogeneousActualPhysicalFlagBornBob_sourceProduct] calc _ = ∏ i : Fin (L + 1), ∑ x : DSVUniformDensityThresholdLocalIndex N d, ∑ y : DSVUniformDensityThresholdLocalIndex N d, dSVDensityRationalCompleteStoppedOptionalLocalEffect (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagAlice i) (alice i) x * (dSVDensityRationalCompleteStoppedOptionalLocalEffect (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagBob i)).transpose (bob i) y * dSVUniformDensityThresholdSharedState N d (x, y) := dSVUniformDensityPhysicalMatched_doubleTensorSourceFactor (fun i => dSVDensityRationalCompleteStoppedOptionalLocalEffect (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagAlice i)) (fun i => (dSVDensityRationalCompleteStoppedOptionalLocalEffect (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagBob i)).transpose) (dSVUniformDensityThresholdSharedState N d) alice bob _ = _ := by apply Finset.prod_congr rfl intro i _ exact (dSVDensityRationalFirstAcceptActualOptionalOutcome_apply (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagAlice i) (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagBob i) (alice i) (bob i)).symm end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder theorem dSVDensityRationalPublicLogPhasePhysicalAlignedLocalAction_apply (B N d L m : ℕ) (U V : Matrix.unitaryGroup (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) (φ ψ : Fin B) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (i j : Fin m) : localUnitaryAction (dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift B N d L m (dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary B U)) (dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift B N d L m (dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary B V)) (dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource B N d L m) (dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m ((φ, a), i), dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m ((ψ, b), j)) = (if φ = ψ then (((Real.sqrt (B : ℝ))⁻¹ : ℝ) : ℂ) else 0) * (∑ x : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, ∑ y : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, (U : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) a x * (V : Matrix (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) ℂ) b y * dSVUniformDensityThresholdWholeHistorySharedState N d L (x, y)) * embezzlementState m (i, j) := by classical let H := DSVUniformDensityThresholdWholeHistoryLocalIndex N d L let P := DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L let n := dSVDensityRationalPublicLogPhaseResidual B N d L m let e := dSVDensityRationalPublicLogPhaseTargetFirstIndexEquiv B N d L m let A := dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift B N d L m (dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary B U) let D := dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift B N d L m (dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary B V) let source := dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource B N d L m have left (χ : Fin B) (x : H) (k : Fin m) : (A : Matrix (Fin (d * n)) (Fin (d * n)) ℂ) (e ((φ, a), i)) (e ((χ, x), k)) = if i = k then if φ = χ then (U : Matrix H H ℂ) a x else 0 else 0 := by rw [dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift_apply, dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary_apply] have right (χ : Fin B) (x : H) (k : Fin m) : (D : Matrix (Fin (d * n)) (Fin (d * n)) ℂ) (e ((ψ, b), j)) (e ((χ, x), k)) = if j = k then if ψ = χ then (V : Matrix H H ℂ) b x else 0 else 0 := by rw [dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift_apply, dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary_apply] have resource (χ υ : Fin B) (x y : H) (k l : Fin m) : source (e ((χ, x), k), e ((υ, y), l)) = (if χ = υ then (((Real.sqrt (B : ℝ))⁻¹ : ℝ) : ℂ) else 0) * dSVUniformDensityThresholdWholeHistorySharedState N d L (x, y) * embezzlementState m (k, l) := dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource_apply B N d L m χ υ x y k l change (∑ q : Fin (d * n) × Fin (d * n), ((A : Matrix (Fin (d * n)) (Fin (d * n)) ℂ) ⊗ₖ (D : Matrix (Fin (d * n)) (Fin (d * n)) ℂ)) (e ((φ, a), i), e ((ψ, b), j)) q * source q) = _ calc _ = ∑ q : (P × Fin m) × (P × Fin m), ((A : Matrix (Fin (d * n)) (Fin (d * n)) ℂ) ⊗ₖ (D : Matrix (Fin (d * n)) (Fin (d * n)) ℂ)) (e ((φ, a), i), e ((ψ, b), j)) (e q.1, e q.2) * source (e q.1, e q.2) := (Equiv.sum_comp (Equiv.prodCongr e e) (fun q : Fin (d * n) × Fin (d * n) => ((A : Matrix (Fin (d * n)) (Fin (d * n)) ℂ) ⊗ₖ (D : Matrix (Fin (d * n)) (Fin (d * n)) ℂ)) (e ((φ, a), i), e ((ψ, b), j)) q * source q)).symm _ = _ := by simp only [Fintype.sum_prod_type, Matrix.kroneckerMap_apply] dsimp only [P, DSVDensityRationalPublicLogPhaseHistoryLocalIndex] simp only [Fintype.sum_prod_type] change (∑ χ : Fin B, ∑ x : H, ∑ k : Fin m, ∑ υ : Fin B, ∑ y : H, ∑ l : Fin m, (A : Matrix (Fin (d * n)) (Fin (d * n)) ℂ) (e ((φ, a), i)) (e ((χ, x), k)) * (D : Matrix (Fin (d * n)) (Fin (d * n)) ℂ) (e ((ψ, b), j)) (e ((υ, y), l)) * source (e ((χ, x), k), e ((υ, y), l))) = _ simp_rw [left, right, resource] simp [mul_ite, ite_mul, mul_assoc, Finset.sum_mul] split_ifs · simp_rw [Finset.mul_sum] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ ring · rfl def dSVDensityRationalHeterogeneousTargetFirstSpectralAlice (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) : Matrix.unitaryGroup (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) ℂ := dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) N d L m (dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (dSVDensityRationalHeterogeneousActualAliceUnitary N width schedule ξ)) def dSVDensityRationalHeterogeneousTargetFirstSpectralBob (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ζ : BipartiteUnitVector d) : Matrix.unitaryGroup (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) ℂ := dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) N d L m (dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (dSVDensityRationalHeterogeneousActualBobUnitary N width schedule ζ)) def dSVDensityRationalHeterogeneousTargetFirstSpectralPhysicalSource (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) × Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) := localUnitaryAction (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice S B N d L m width schedule ξ) (dSVDensityRationalHeterogeneousTargetFirstSpectralBob S B N d L m width schedule ζ) (dSVDensityRationalPublicMultiscalePhaseTargetFirstPreparedSource S B N d L m) theorem dSVDensityRationalHeterogeneousTargetFirstSpectralPhysicalSource_apply (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (φ ψ : DSVDensityRationalPublicMultiscalePhase S B) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (i j : Fin m) : dSVDensityRationalHeterogeneousTargetFirstSpectralPhysicalSource S B N d L m width schedule ξ ζ (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m (((Fintype.equivFin (DSVDensityRationalPublicMultiscalePhase S B)) φ, a), i), dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m (((Fintype.equivFin (DSVDensityRationalPublicMultiscalePhase S B)) ψ, b), j)) = (if φ = ψ then (((Real.sqrt ((B ^ S : ℕ) : ℝ))⁻¹ : ℝ) : ℂ) else 0) * dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (a, b) * embezzlementState m (i, j) := by unfold dSVDensityRationalHeterogeneousTargetFirstSpectralPhysicalSource dSVDensityRationalHeterogeneousTargetFirstSpectralAlice dSVDensityRationalHeterogeneousTargetFirstSpectralBob dSVDensityRationalPublicMultiscalePhaseTargetFirstPreparedSource dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv dSVDensityRationalPublicMultiscalePhaseResidual rw [dSVDensityRationalPublicLogPhasePhysicalAlignedLocalAction_apply] rw [← dSVDensityRationalHeterogeneousActualPhysicalState_apply] simp end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def dSVDensityRationalPublicBucketCoherentPhaseSigmaProductEquiv {H : Type*} (B m : ℕ) : (Σ _ : Fin B × H, Fin m) ≃ (Fin B × H) × Fin m := Equiv.sigmaEquivProd (Fin B × H) (Fin m) def dSVDensityRationalPublicMultiscaleBucketCoherentSigmaState {H : Type*} [Fintype H] {m : ℕ} (S B : ℕ) (history : EuclideanSpace ℂ (H × H)) (work : DSVDensityRationalPublicMultiscalePhaseIndex S B → H → H → EuclideanSpace ℂ (Fin m × Fin m)) : EuclideanSpace ℂ ((Σ _ : DSVDensityRationalPublicMultiscalePhaseIndex S B × H, Fin m) × (Σ _ : DSVDensityRationalPublicMultiscalePhaseIndex S B × H, Fin m)) := dSVDensityRationalPublicBucketCoherentPhaseSigmaState (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) history work def dSVDensityRationalHeterogeneousPureStoppedSigmaState {S B N d L m : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (work : DSVDensityRationalPublicMultiscalePhaseIndex S B → DSVUniformDensityThresholdWholeHistoryLocalIndex N d L → DSVUniformDensityThresholdWholeHistoryLocalIndex N d L → EuclideanSpace ℂ (Fin m × Fin m)) : EuclideanSpace ℂ ((Σ _ : DSVDensityRationalPublicMultiscalePhaseIndex S B × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, Fin m) × (Σ _ : DSVDensityRationalPublicMultiscalePhaseIndex S B × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, Fin m)) := dSVDensityRationalPublicMultiscaleBucketCoherentSigmaState S B (dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ) work def dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor {N : ℕ} (n : ℕ) (z : EuclideanSpace ℂ (Fin N × Fin N)) : EuclideanSpace ℂ (Fin (N * n) × Fin (N * n)) := toLp 2 fun q : Fin (N * n) × Fin (N * n) => let a : Fin N × Fin n := finProdFinEquiv.symm q.1 let b : Fin N × Fin n := finProdFinEquiv.symm q.2 z (a.1, b.1) * embezzlementState n (a.2, b.2) theorem dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_unit {N n : ℕ} (z : BipartiteUnitVector N) : dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n z.val = tensorEmbezzlementTarget (n := n) z := by rfl theorem dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_sub {N : ℕ} (n : ℕ) (x y : EuclideanSpace ℂ (Fin N × Fin N)) : dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (x - y) = dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n x - dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n y := by ext q change (x ((finProdFinEquiv.symm q.1).1, (finProdFinEquiv.symm q.2).1) - y ((finProdFinEquiv.symm q.1).1, (finProdFinEquiv.symm q.2).1)) * embezzlementState n ((finProdFinEquiv.symm q.1).2, (finProdFinEquiv.symm q.2).2) = x ((finProdFinEquiv.symm q.1).1, (finProdFinEquiv.symm q.2).1) * embezzlementState n ((finProdFinEquiv.symm q.1).2, (finProdFinEquiv.symm q.2).2) - y ((finProdFinEquiv.symm q.1).1, (finProdFinEquiv.symm q.2).1) * embezzlementState n ((finProdFinEquiv.symm q.1).2, (finProdFinEquiv.symm q.2).2) ring theorem dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_norm_sq {N n : ℕ} (positive : 0 < n) (z : EuclideanSpace ℂ (Fin N × Fin N)) : ‖dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n z‖ ^ 2 = ‖z‖ ^ 2 := by classical let e : ((Fin N × Fin N) × (Fin n × Fin n)) ≃ (Fin (N * n) × Fin (N * n)) := (Equiv.prodProdProdComm (Fin N) (Fin N) (Fin n) (Fin n)).trans (Equiv.prodCongr finProdFinEquiv finProdFinEquiv) have point (q : (Fin N × Fin N) × (Fin n × Fin n)) : dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n z (e q) = z q.1 * embezzlementState n q.2 := by rcases q with ⟨⟨a, b⟩, ⟨i, j⟩⟩ change z ((finProdFinEquiv.symm (finProdFinEquiv (a, i))).1, (finProdFinEquiv.symm (finProdFinEquiv (b, j))).1) * embezzlementState n ((finProdFinEquiv.symm (finProdFinEquiv (a, i))).2, (finProdFinEquiv.symm (finProdFinEquiv (b, j))).2) = z (a, b) * embezzlementState n (i, j) simp only [Equiv.symm_apply_apply] rw [EuclideanSpace.norm_sq_eq] calc (∑ q : Fin (N * n) × Fin (N * n), ‖dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n z q‖ ^ 2) = ∑ q : (Fin N × Fin N) × (Fin n × Fin n), ‖dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n z (e q)‖ ^ 2 := (Equiv.sum_comp e (fun q : Fin (N * n) × Fin (N * n) => ‖dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n z q‖ ^ 2)).symm _ = ∑ q : (Fin N × Fin N) × (Fin n × Fin n), ‖z q.1 * embezzlementState n q.2‖ ^ 2 := by apply Finset.sum_congr rfl intro q _ rw [point q] _ = (∑ a : Fin N × Fin N, ‖z a‖ ^ 2) * (∑ b : Fin n × Fin n, ‖embezzlementState n b‖ ^ 2) := by rw [Fintype.sum_prod_type] simp_rw [norm_mul, mul_pow] exact (Fintype.sum_mul_sum (fun a : Fin N × Fin N => ‖z a‖ ^ 2) (fun b : Fin n × Fin n => ‖embezzlementState n b‖ ^ 2)).symm _ = ‖z‖ ^ 2 := by rw [← EuclideanSpace.norm_sq_eq, ← EuclideanSpace.norm_sq_eq, embezzlementState_norm n positive] ring theorem dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_prefix_sub_norm_sq {N n : ℕ} (positive : 0 < n) (r s : Fin (N + 1)) : ‖dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix r) - dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix s)‖ ^ 2 = |(r.val : ℝ) - (s.val : ℝ)| := by rw [← dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_sub, dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_norm_sq positive, dSVCanonicalFailurePrefix_sub_norm_sq] def dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState {d N : ℕ} (w : ℝ) (n : ℕ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ ((Σ _ : Fin d, Fin (N * n)) × (Σ _ : Fin d, Fin (N * n))) := dSVUniformDensityCorrectedMatchedSigmaWeightedResidual (dSVDensityRationalLocalSpectralPairHistory N ξ ζ) (fun i j => dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j)) theorem dSVDensityRationalMixedCanonicalPrefixPhysicalSigmaWeighted_norm_sq {H : Type*} [Fintype H] {n : ℕ} (history : EuclideanSpace ℂ (H × H)) (work : H → H → EuclideanSpace ℂ (Fin n × Fin n)) : ‖dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history work‖ ^ 2 = ∑ i : H, ∑ j : H, ‖history (i, j)‖ ^ 2 * ‖work i j‖ ^ 2 := by have zero : dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history (fun _ _ => (0 : EuclideanSpace ℂ (Fin n × Fin n))) = 0 := by ext q simp [dSVUniformDensityCorrectedMatchedSigmaWeightedResidual] have distance := dSVUniformDensityCorrectedMatchedSigmaWeightedResidual_distance_sq history work (fun _ _ => (0 : EuclideanSpace ℂ (Fin n × Fin n))) simpa [zero] using distance theorem dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState_norm_sq {d N n : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (residual : 0 < n) (ξ ζ : BipartiteUnitVector d) : ‖dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState (N := N) w n ξ ζ‖ ^ 2 = ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ true true‖ ^ 2 := by unfold dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState rw [dSVDensityRationalMixedCanonicalPrefixPhysicalSigmaWeighted_norm_sq] simp_rw [ dSVDensityRationalLocalSpectralPairHistory_apply_norm_sq, dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_norm_sq residual, dSVDensityRationalPhysicalMixedAcceptedPrefixWork_norm_sq] rw [dSVDensityRationalMixedAcceptedPrefix_norm_sq width grid ξ ζ] unfold dSVDensityRationalPrefixHarmonicSpectralOverlap simp_rw [Finset.sum_div] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (i : Fin (L + 1)) : EuclideanSpace ℂ (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := dSVDensityRationalCompleteStoppedOptionalOutcome (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L j.succ i) (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L j.succ i) theorem dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome_before {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (i : Fin (L + 1)) (before : i.val < j.val) : dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j i = dSVDensityRationalCompleteProjectiveOutcome (width (schedule ⟨i.val, lt_trans before j.isLt⟩)) N ξ ζ false false := by unfold dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_before j i before] rw [dSVDensityRationalCompleteStoppedOptionalOutcome_some_some] simp [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth, lt_trans before j.isLt] theorem dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome_hit {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) : dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j j.castSucc = dSVDensityRationalCompleteProjectiveOutcome (width (schedule j)) N ξ ζ true true := by unfold dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_hit] rw [dSVDensityRationalCompleteStoppedOptionalOutcome_some_some] simp [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth] theorem dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome_after {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (i : Fin (L + 1)) (after : j.val < i.val) : dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j i = dSVUniformDensityThresholdSharedState N d := by unfold dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_after j i after] exact dSVDensityRationalCompleteStoppedOptionalOutcome_none_none (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ theorem dSVDensityRationalHeterogeneousActualCommonStopPhysicalState_eq_outcomeProduct {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (alice bob : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d) : dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (⟨j.succ, alice⟩, ⟨j.succ, bob⟩) = ∏ i : Fin (L + 1), dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j i (alice i, bob i) := by exact dSVDensityRationalHeterogeneousActualPhysicalFlagBornState_allFlags width schedule ξ ζ j.succ j.succ alice bob end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder def dSVDensityRationalPureBaseExactFlagBornMass {A C : Type*} [Fintype A] [Fintype C] {L : ℕ} (alice : A → Fin (L + 1)) (bob : C → Fin (L + 1)) (z : EuclideanSpace ℂ (A × C)) (flagAlice flagBob : Fin (L + 1)) : ℝ := ∑ a : A, ∑ c : C, ‖z (a, c)‖ ^ 2 * if alice a = flagAlice ∧ bob c = flagBob then 1 else 0 theorem dSVDensityRationalPureMatchedFlagIndicator_sum {L : ℕ} (a b : Fin (L + 1)) : (∑ flag : Fin (L + 1), if a = flag ∧ b = flag then (1 : ℝ) else 0) = if a = b then 1 else 0 := by classical by_cases same : a = b · subst b simp · have absent (flag : Fin (L + 1)) : ¬ (a = flag ∧ b = flag) := by rintro ⟨first, second⟩ exact same (first.trans second.symm) simp [same, absent] theorem dSVDensityRationalPureMatchedFlagBorn_sum_eq {A C : Type*} [Fintype A] [Fintype C] {L : ℕ} (alice : A → Fin (L + 1)) (bob : C → Fin (L + 1)) (z : EuclideanSpace ℂ (A × C)) : (∑ flag : Fin (L + 1), dSVDensityRationalPureBaseExactFlagBornMass alice bob z flag flag) = ∑ a : A, ∑ c : C, ‖z (a, c)‖ ^ 2 * if alice a = bob c then (1 : ℝ) else 0 := by classical unfold dSVDensityRationalPureBaseExactFlagBornMass calc (∑ flag : Fin (L + 1), ∑ a : A, ∑ c : C, ‖z (a, c)‖ ^ 2 * if alice a = flag ∧ bob c = flag then (1 : ℝ) else 0) = ∑ a : A, ∑ c : C, ∑ flag : Fin (L + 1), ‖z (a, c)‖ ^ 2 * if alice a = flag ∧ bob c = flag then (1 : ℝ) else 0 := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro a _ rw [Finset.sum_comm] _ = ∑ a : A, ∑ c : C, ‖z (a, c)‖ ^ 2 * if alice a = bob c then (1 : ℝ) else 0 := by apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro c _ rw [← Finset.mul_sum, dSVDensityRationalPureMatchedFlagIndicator_sum] theorem dSVDensityRationalPureFlagBorn_partition {A C : Type*} [Fintype A] [Fintype C] {L : ℕ} (alice : A → Fin (L + 1)) (bob : C → Fin (L + 1)) (z : EuclideanSpace ℂ (A × C)) : dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass alice bob z + (∑ flag : Fin (L + 1), dSVDensityRationalPureBaseExactFlagBornMass alice bob z flag flag) = ‖z‖ ^ 2 := by classical rw [dSVDensityRationalPureMatchedFlagBorn_sum_eq] unfold dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro a _ rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro c _ split_ifs <;> ring theorem dSVDensityRationalPureMatchedFlagBorn_zero_succ {A C : Type*} [Fintype A] [Fintype C] {L : ℕ} (alice : A → Fin (L + 1)) (bob : C → Fin (L + 1)) (z : EuclideanSpace ℂ (A × C)) : (∑ flag : Fin (L + 1), dSVDensityRationalPureBaseExactFlagBornMass alice bob z flag flag) = dSVDensityRationalPureBaseExactFlagBornMass alice bob z 0 0 + ∑ j : Fin L, dSVDensityRationalPureBaseExactFlagBornMass alice bob z j.succ j.succ := by rw [Fin.sum_univ_succ] theorem dSVDensityRationalPureFlagBorn_partition_zero_succ {A C : Type*} [Fintype A] [Fintype C] {L : ℕ} (alice : A → Fin (L + 1)) (bob : C → Fin (L + 1)) (z : EuclideanSpace ℂ (A × C)) : dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass alice bob z + dSVDensityRationalPureBaseExactFlagBornMass alice bob z 0 0 + (∑ j : Fin L, dSVDensityRationalPureBaseExactFlagBornMass alice bob z j.succ j.succ) = ‖z‖ ^ 2 := by have actual := dSVDensityRationalPureFlagBorn_partition alice bob z rw [dSVDensityRationalPureMatchedFlagBorn_zero_succ alice bob z] at actual linarith theorem dSVDensityRationalPureFlagBorn_normalized_partition_zero_succ {A C : Type*} [Fintype A] [Fintype C] {L : ℕ} (alice : A → Fin (L + 1)) (bob : C → Fin (L + 1)) (z : EuclideanSpace ℂ (A × C)) (normalized : ‖z‖ = 1) : dSVDensityRationalPublicMultiscaleFirstHitPhysicalFlagMismatchMass alice bob z + dSVDensityRationalPureBaseExactFlagBornMass alice bob z 0 0 + (∑ j : Fin L, dSVDensityRationalPureBaseExactFlagBornMass alice bob z j.succ j.succ) = 1 := by simpa [normalized] using dSVDensityRationalPureFlagBorn_partition_zero_succ alice bob z end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder attribute [local instance] Classical.propDecidable theorem dSVDensityRationalHeterogeneousActualPhysicalFlagMass_eq_optionalProduct {S d N L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (flagAlice flagBob : Fin (L + 1)) : dSVDensityRationalHeterogeneousActualPhysicalFlagMass N width schedule ξ ζ flagAlice flagBob = ∏ i : Fin (L + 1), ‖dSVDensityRationalCompleteStoppedOptionalOutcome (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagAlice i) (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagBob i)‖ ^ 2 := by classical unfold dSVDensityRationalHeterogeneousActualPhysicalFlagMass simp_rw [dSVDensityRationalHeterogeneousActualPhysicalFlagBornState_allFlags, norm_prod, ← Finset.prod_pow] calc _ = ∏ i : Fin (L + 1), ∑ a : DSVUniformDensityThresholdLocalIndex N d, ∑ b : DSVUniformDensityThresholdLocalIndex N d, ‖dSVDensityRationalCompleteStoppedOptionalOutcome (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagAlice i) (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagBob i) (a, b)‖ ^ 2 := dSVUniformDensityPhysicalAsync_doubleProductSum (fun i a b => ‖dSVDensityRationalCompleteStoppedOptionalOutcome (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagAlice i) (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L flagBob i) (a, b)‖ ^ 2) _ = _ := by apply Finset.prod_congr rfl intro i _ rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] theorem dSVDensityRationalHeterogeneousActualPhysical_firstHitProduct {L : ℕ} (continuation : ℕ → ℝ) (success : ℝ) (j : Fin L) : (∏ i : Fin (L + 1), if i.val < j.val then continuation i.val else if i.val = j.val then success else 1) = dSVHeterogeneousRealPrefix continuation j.val * success := by classical let f : ℕ → ℝ := fun i => if i < j.val then continuation i else if i = j.val then success else 1 have length : L + 1 = (j.val + 1) + (L - j.val) := by omega calc _ = ∏ k ∈ Finset.range (L + 1), f k := Fin.prod_univ_eq_prod_range f (L + 1) _ = (∏ k ∈ Finset.range (j.val + 1), f k) * (∏ k ∈ Finset.range (L - j.val), f (j.val + 1 + k)) := by rw [length, Finset.prod_range_add] _ = (∏ k ∈ Finset.range j.val, continuation k) * success := by rw [Finset.prod_range_succ] have prefixProduct : (∏ k ∈ Finset.range j.val, f k) = (∏ k ∈ Finset.range j.val, continuation k) := by apply Finset.prod_congr rfl intro k member have earlier : k < j.val := Finset.mem_range.mp member simp [f, earlier] have selected : f j.val = success := by simp [f] have tail : (∏ k ∈ Finset.range (L - j.val), f (j.val + 1 + k)) = 1 := by apply Finset.prod_eq_one intro k _ have notEarlier : ¬ j.val + 1 + k < j.val := by omega have notEqual : j.val + 1 + k ≠ j.val := by omega simp [f, notEarlier, notEqual] rw [prefixProduct, selected, tail, mul_one] _ = _ := rfl theorem dSVDensityRationalHeterogeneousActualPhysicalMatchedCopyBorn {S d N L : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (i : Fin (L + 1)) : ‖dSVDensityRationalCompleteStoppedOptionalOutcome (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L j.succ i) (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L j.succ i)‖ ^ 2 = if i.val < j.val then dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ i.val else if i.val = j.val then dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ j.val else 1 := by classical rcases lt_trichotomy i.val j.val with earlier | equal | later · rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_before j i earlier, dSVDensityRationalCompleteStoppedOptionalOutcome_some_some] have active : i.val < L := lt_trans earlier j.isLt simp [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth, dSVDensityRationalHeterogeneousPhysicalStageContinue, dSVDensityRationalHeterogeneousPhysicalStageOutcome, active, earlier] · have selected : i = j.castSucc := Fin.ext equal subst i rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_hit, dSVDensityRationalCompleteStoppedOptionalOutcome_some_some] simp [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth, dSVDensityRationalHeterogeneousPhysicalStageSuccess, dSVDensityRationalHeterogeneousPhysicalStageOutcome, j.isLt] · rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_after j i later, dSVDensityRationalCompleteStoppedOptionalOutcome_none_none, dSVUniformDensityThresholdSharedState_norm grid dimension] simp [show ¬ i.val < j.val by omega, show i.val ≠ j.val by omega] theorem dSVDensityRationalHeterogeneousActualPhysicalFlagMass_succ_succ_eq_stage {S d N L : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) : dSVDensityRationalHeterogeneousActualPhysicalFlagMass N width schedule ξ ζ j.succ j.succ = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val * dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ j.val := by rw [dSVDensityRationalHeterogeneousActualPhysicalFlagMass_eq_optionalProduct] simp_rw [dSVDensityRationalHeterogeneousActualPhysicalMatchedCopyBorn grid dimension width schedule ξ ζ j] exact dSVDensityRationalHeterogeneousActualPhysical_firstHitProduct (dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ) (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ j.val) j theorem dSVDensityRationalHeterogeneousActualPhysicalNoHitCopyBorn {S d N L : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (i : Fin (L + 1)) : ‖dSVDensityRationalCompleteStoppedOptionalOutcome (dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth width schedule i) N ξ ζ (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L 0 i) (dSVDensityRationalCompleteStoppedOptionalLocalSchedule L 0 i)‖ ^ 2 = if i.val < L then dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ i.val else 1 := by classical rw [dSVDensityRationalCompleteStoppedOptionalLocalSchedule_zero] by_cases active : i.val < L · rw [if_pos active, dSVDensityRationalCompleteStoppedOptionalOutcome_some_some] simp [dSVDensityRationalHeterogeneousActualPhysicalFlagBornCopyWidth, dSVDensityRationalHeterogeneousPhysicalStageContinue, dSVDensityRationalHeterogeneousPhysicalStageOutcome, active] · rw [if_neg active, dSVDensityRationalCompleteStoppedOptionalOutcome_none_none, dSVUniformDensityThresholdSharedState_norm grid dimension] simp [active] theorem dSVDensityRationalHeterogeneousActualPhysicalFlagMass_zero_zero_eq_terminal {S d N L : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousActualPhysicalFlagMass N width schedule ξ ζ 0 0 = dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule ξ ζ := by rw [dSVDensityRationalHeterogeneousActualPhysicalFlagMass_eq_optionalProduct] simp_rw [dSVDensityRationalHeterogeneousActualPhysicalNoHitCopyBorn grid dimension width schedule ξ ζ] unfold dSVDensityRationalHeterogeneousPhysicalTerminalMass dSVDensityRationalHeterogeneousPhysicalSurvival dSVHeterogeneousRealPrefix rw [Fin.prod_univ_castSucc] simp only [Fin.val_castSucc, Fin.val_last, Fin.is_lt, ↓reduceIte, lt_self_iff_false, mul_one] exact Fin.prod_univ_eq_prod_range (dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ) L theorem dSVDensityRationalHeterogeneousActualPhysicalBaseFlagBorn_eq_flagMass {S d N L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (flagAlice flagBob : Fin (L + 1)) : dSVDensityRationalPureBaseExactFlagBornMass (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ) flagAlice flagBob = dSVDensityRationalHeterogeneousActualPhysicalFlagMass N width schedule ξ ζ flagAlice flagBob := by classical unfold dSVDensityRationalPureBaseExactFlagBornMass dSVDensityRationalHeterogeneousActualPhysicalFlagMass simp only [Fintype.sum_sigma] simp [mul_ite, ite_and] theorem dSVDensityRationalHeterogeneousActualPhysicalMatchedFlagMass_eq_stoppedSuccess {S d N L : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : (∑ j : Fin L, dSVDensityRationalHeterogeneousActualPhysicalFlagMass N width schedule ξ ζ j.succ j.succ) = dSVDensityRationalHeterogeneousPhysicalStoppedSuccessMass N width schedule ξ ζ := by simp_rw [dSVDensityRationalHeterogeneousActualPhysicalFlagMass_succ_succ_eq_stage grid dimension width schedule ξ ζ] unfold dSVDensityRationalHeterogeneousPhysicalStoppedSuccessMass exact Fin.sum_univ_eq_sum_range (fun k : ℕ => dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k) L theorem dSVDensityRationalHeterogeneousActualPhysicalFlagBorn_mass_partition {S d N L : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousActualAsynchronousFlagMass N width schedule ξ ζ + dSVDensityRationalHeterogeneousActualPhysicalFlagMass N width schedule ξ ζ 0 0 + (∑ j : Fin L, dSVDensityRationalHeterogeneousActualPhysicalFlagMass N width schedule ξ ζ j.succ j.succ) = 1 := by have actual := dSVDensityRationalPureFlagBorn_normalized_partition_zero_succ (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ) (dSVDensityRationalHeterogeneousActualPhysicalState_norm grid dimension width schedule ξ ζ) change dSVDensityRationalHeterogeneousActualAsynchronousFlagMass N width schedule ξ ζ + dSVDensityRationalPureBaseExactFlagBornMass (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ) 0 0 + (∑ j : Fin L, dSVDensityRationalPureBaseExactFlagBornMass (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (fun q : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L => q.1) (dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ) j.succ j.succ) = 1 at actual simpa only [dSVDensityRationalHeterogeneousActualPhysicalBaseFlagBorn_eq_flagMass] using actual theorem dSVDensityRationalHeterogeneousActualAsynchronousFlagMass_eq_stoppedAsynchronousMass {S d N L : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousActualAsynchronousFlagMass N width schedule ξ ζ = dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ := by have physical := dSVDensityRationalHeterogeneousActualPhysicalFlagBorn_mass_partition grid dimension width schedule ξ ζ rw [dSVDensityRationalHeterogeneousActualPhysicalFlagMass_zero_zero_eq_terminal grid dimension width schedule ξ ζ, dSVDensityRationalHeterogeneousActualPhysicalMatchedFlagMass_eq_stoppedSuccess grid dimension width schedule ξ ζ] at physical have stages := dSVDensityRationalHeterogeneousPhysicalStopped_mass_partition grid dimension width schedule ξ ζ linarith end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem dSVDensityRationalMixedCanonicalPrefixPhysicalLocalAction_real_smul {n : ℕ} (A B : Matrix.unitaryGroup (Fin n) ℂ) (r : ℝ) (z : EuclideanSpace ℂ (Fin n × Fin n)) : localUnitaryAction A B (r • z) = r • localUnitaryAction A B z := by change Matrix.toEuclideanLin ((A : Matrix (Fin n) (Fin n) ℂ) ⊗ₖ (B : Matrix (Fin n) (Fin n) ℂ)) (r • z) = r • Matrix.toEuclideanLin ((A : Matrix (Fin n) (Fin n) ℂ) ⊗ₖ (B : Matrix (Fin n) (Fin n) ℂ)) z exact (Matrix.toEuclideanLin ((A : Matrix (Fin n) (Fin n) ℂ) ⊗ₖ (B : Matrix (Fin n) (Fin n) ℂ))).map_smul_of_tower r z theorem dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_real_smul {N : ℕ} (n : ℕ) (r : ℝ) (z : EuclideanSpace ℂ (Fin N × Fin N)) : dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (r • z) = r • dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n z := by ext q change ((r : ℂ) * z ((finProdFinEquiv.symm q.1).1, (finProdFinEquiv.symm q.2).1)) * embezzlementState n ((finProdFinEquiv.symm q.1).2, (finProdFinEquiv.symm q.2).2) = (r : ℂ) * (z ((finProdFinEquiv.symm q.1).1, (finProdFinEquiv.symm q.2).1) * embezzlementState n ((finProdFinEquiv.symm q.1).2, (finProdFinEquiv.symm q.2).2)) ring theorem dSVDensityRationalMixedCanonicalPrefixPhysicalRawHarmonicTensor_eq {N : ℕ} (grid : 0 < N) (n : ℕ) (rank : Fin (N + 1)) : dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix rank) = Real.sqrt (rank.val : ℝ) • tensorEmbezzlementTarget (n := n) (dSVCanonicalFailureUnitRankFamily N grid rank) := by classical have raw : dSVCanonicalFailurePrefix rank = Real.sqrt (rank.val : ℝ) • (dSVCanonicalFailureUnitRankFamily N grid rank : EuclideanSpace ℂ (Fin N × Fin N)) := by by_cases zero : rank.val = 0 · rw [dSVCanonicalFailurePrefix_eq_zero_of_rank_zero rank zero] simp [zero] · have nonzero : dSVCanonicalFailurePrefix rank ≠ 0 := by intro vanished have mass := dSVCanonicalFailurePrefix_norm_sq rank rw [vanished] at mass have cast_zero : (rank.val : ℝ) = 0 := by simpa using mass.symm exact zero (by exact_mod_cast cast_zero) change dSVCanonicalFailurePrefix rank = Real.sqrt (rank.val : ℝ) • normalizeOrDefault (embezzlementState N) (dSVCanonicalFailurePrefix rank) rw [normalizeOrDefault, if_neg nonzero, ← dSVCanonicalFailurePrefix_norm_eq_sqrt rank] exact (NormedSpace.norm_smul_normalize (dSVCanonicalFailurePrefix rank)).symm rw [raw, dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_real_smul, dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_unit] theorem dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState_apply {d N n : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) (k l : Fin N) (a b : Fin n) : dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState (N := N) w n ξ ζ (⟨i, finProdFinEquiv (k, a)⟩, ⟨j, finProdFinEquiv (l, b)⟩) = dSVDensityRationalCanonicalPrefixSpectralOutcome w N ξ ζ (⟨k, i⟩, ⟨l, j⟩) * embezzlementState n (a, b) := by classical rw [dSVDensityRationalMixedCanonicalSpectralOutcome_eq] simp only [ dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState, dSVUniformDensityCorrectedMatchedSigmaWeightedResidual, dSVDensityRationalLocalSpectralPairHistory, dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor, dSVDensityRationalPhysicalMixedAcceptedPrefixWork, dSVCanonicalFailurePrefix, Equiv.symm_apply_apply] change (((‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) : ℂ) * dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ i j) * ((if k = l ∧ k.val < (dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j).val then (1 : ℂ) else 0) * embezzlementState n (a, b)) = (((‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) : ℂ) * dSVDensityRationalMixedCanonicalRawSource w N ξ ζ (⟨k, i⟩, ⟨l, j⟩)) * embezzlementState n (a, b) rw [dSVDensityRationalMixedCanonicalRawSource_apply] by_cases same : k = l · subst l have accepted := dSVDensityRationalPhysicalMixedAcceptedThreshold_iff width grid ξ ζ i j k by_cases below : k.val < (dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j).val · have both := accepted.mpr below simp [below, both.1, both.2, mul_assoc] · have not_both : ¬ (dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ξ).isHermitian.eigenvalues i) = true ∧ dSVDensityRationalProjectiveThresholdBin w N k ((dSVSoftBobLeftReducedDensity_posSemidef ζ).isHermitian.eigenvalues j) = true) := fun both => below (accepted.mp both) simp [below, not_both] · simp [same] theorem dSVDensityRationalMixedCanonicalPrefixPhysicalRankWeightedAtomError_eq {N n : ℕ} (grid : 0 < N) (rank : Fin (N + 1)) (A B : Matrix.unitaryGroup (Fin (N * n)) ℂ) : ‖localUnitaryAction A B (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix rank)) - Real.sqrt (rank.val : ℝ) • embezzlementState (N * n)‖ ^ 2 = (rank.val : ℝ) * ‖localUnitaryAction A B (tensorEmbezzlementTarget (n := n) (dSVCanonicalFailureUnitRankFamily N grid rank)) - embezzlementState (N * n)‖ ^ 2 := by rw [dSVDensityRationalMixedCanonicalPrefixPhysicalRawHarmonicTensor_eq grid n rank] rw [dSVDensityRationalMixedCanonicalPrefixPhysicalLocalAction_real_smul] rw [← smul_sub, norm_smul, mul_pow, Real.norm_eq_abs, sq_abs, Real.sq_sqrt (by positivity : 0 ≤ (rank.val : ℝ))] def dSVDensityRationalPublicBucketPhysicalCommonRank {N : ℕ} (r s : Fin (N + 1)) : Fin (N + 1) := ⟨min r.val s.val, by have left := r.isLt have right := s.isLt omega⟩ theorem dSVDensityRationalPublicBucketPhysicalCommonRank_eq {d N : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : dSVDensityRationalPublicBucketPhysicalCommonRank (dSVDensityRationalPhysicalAcceptedRank w N ξ i) (dSVDensityRationalPhysicalAcceptedRank w N ζ j) = dSVDensityRationalPhysicalMixedAcceptedIntersectionRank w N ξ ζ i j := by rfl theorem exists_proofDSVDensityRationalPublicBucketPhysicalRawRankCleanup_sq {Ω I : Type*} [DecidableEq I] {N : ℕ} (grid : 0 < N) (bucket : Ω → Fin (N + 1) → I) (representative : Ω → I → Fin (N + 1)) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ A B : Ω → I → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ (phase : Ω) (r s : Fin (N + 1)), ‖localUnitaryAction (A phase (bucket phase r)) (B phase (bucket phase s)) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix r)) - Real.sqrt (r.val : ℝ) • embezzlementState (N * n)‖ ^ 2 ≤ (r.val : ℝ) * (2 * ε ^ 2 + 8 * |(r.val : ℝ) - ((representative phase (bucket phase r)).val : ℝ)| / (max 1 (min r.val (representative phase (bucket phase r)).val) : ℕ) + 4 * (if bucket phase r = bucket phase s then (0 : ℝ) else 1)) := by obtain ⟨n, positive, A, B, accurate⟩ := dSVDensityRationalPublicBucketCanonicalPrefixCleanup_sq grid bucket representative ε precision refine ⟨n, positive, A, B, ?_⟩ intro phase r s rw [dSVDensityRationalMixedCanonicalPrefixPhysicalRankWeightedAtomError_eq grid r] exact mul_le_mul_of_nonneg_left (accurate phase r s) (Nat.cast_nonneg r.val) theorem exists_proofDSVDensityRationalPublicBucketPhysicalMixedPrefixCleanup_sq {Ω I : Type*} [DecidableEq I] {N : ℕ} (grid : 0 < N) (bucket : Ω → Fin (N + 1) → I) (representative : Ω → I → Fin (N + 1)) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ A B : Ω → I → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ (phase : Ω) (r s : Fin (N + 1)), ‖localUnitaryAction (A phase (bucket phase r)) (B phase (bucket phase s)) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix (dSVDensityRationalPublicBucketPhysicalCommonRank r s))) - Real.sqrt (r.val : ℝ) • embezzlementState (N * n)‖ ^ 2 ≤ 2 * |(r.val : ℝ) - (s.val : ℝ)| + 2 * (r.val : ℝ) * (2 * ε ^ 2 + 8 * |(r.val : ℝ) - ((representative phase (bucket phase r)).val : ℝ)| / (max 1 (min r.val (representative phase (bucket phase r)).val) : ℕ) + 4 * (if bucket phase r = bucket phase s then (0 : ℝ) else 1)) := by obtain ⟨n, positive, A, B, accurate⟩ := exists_proofDSVDensityRationalPublicBucketPhysicalRawRankCleanup_sq grid bucket representative ε precision refine ⟨n, positive, A, B, ?_⟩ intro phase r s let U := A phase (bucket phase r) let V := B phase (bucket phase s) let common := dSVDensityRationalPublicBucketPhysicalCommonRank r s let mixed := dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix common) let alice := dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix r) let target := Real.sqrt (r.val : ℝ) • embezzlementState (N * n) have pure_distance : ‖localUnitaryAction U V mixed - localUnitaryAction U V alice‖ ^ 2 ≤ |(r.val : ℝ) - (s.val : ℝ)| := by rw [← localUnitaryAction_sub, localUnitaryAction_norm] dsimp [mixed, alice] rw [dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor_prefix_sub_norm_sq positive] dsimp [common, dSVDensityRationalPublicBucketPhysicalCommonRank] rcases le_total r.val s.val with ordered | ordered · rw [min_eq_left ordered] simp · rw [min_eq_right ordered] rw [abs_sub_comm] have cleanup := accurate phase r s change ‖localUnitaryAction U V mixed - target‖ ^ 2 ≤ _ have triangle : ‖localUnitaryAction U V mixed - target‖ ≤ ‖localUnitaryAction U V mixed - localUnitaryAction U V alice‖ + ‖localUnitaryAction U V alice - target‖ := by calc _ = ‖(localUnitaryAction U V mixed - localUnitaryAction U V alice) + (localUnitaryAction U V alice - target)‖ := by congr 1 abel _ ≤ _ := norm_add_le _ _ change ‖localUnitaryAction U V alice - target‖ ^ 2 ≤ _ at cleanup nlinarith [ norm_nonneg (localUnitaryAction U V mixed - target), norm_nonneg (localUnitaryAction U V mixed - localUnitaryAction U V alice), norm_nonneg (localUnitaryAction U V alice - target), sq_nonneg (‖localUnitaryAction U V mixed - localUnitaryAction U V alice‖ - ‖localUnitaryAction U V alice - target‖)] def dSVDensityRationalPublicBucketPhysicalPhaseWeightedMixedError {d N n B : ℕ} (Q : ℕ) (w : ℝ) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ) : ℝ := ∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * ∑ i : Fin d, ∑ j : Fin d, (dSVDensityRationalPrefixHarmonicSpectralOverlap ξ ζ i j / ((d : ℝ) * (N : ℝ))) * ‖localUnitaryAction (A phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ξ i))) (C phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ζ j))) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j)) - Real.sqrt ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) • embezzlementState (N * n)‖ ^ 2 def dSVDensityRationalPublicBucketPhysicalCoherentMixedState {d N B : ℕ} (w : ℝ) (n : ℕ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin (N * n)) × (Σ _ : Fin B × Fin d, Fin (N * n))) := dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (dSVDensityRationalLocalSpectralPairHistory N ξ ζ) (fun _ i j => dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j)) def dSVDensityRationalPublicBucketPhysicalCoherentTargetState {d N B : ℕ} (w : ℝ) (n : ℕ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin (N * n)) × (Σ _ : Fin B × Fin d, Fin (N * n))) := dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (dSVDensityRationalLocalSpectralPairHistory N ξ ζ) (fun _ i _ => Real.sqrt ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) • embezzlementState (N * n)) def dSVDensityRationalPublicBucketPhysicalCoherentLocalReset {d N B n : ℕ} (Q : ℕ) (w : ℝ) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ) (z : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin (N * n)) × (Σ _ : Fin B × Fin d, Fin (N * n)))) : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin (N * n)) × (Σ _ : Fin B × Fin d, Fin (N * n))) := dSVUniformDensityPhysicalAsyncSigmaContinuation (fun q : Fin B × Fin d => A q.1 (dSVDensityRationalPublicLogRankBucket Q q.1 (dSVDensityRationalPhysicalAcceptedRank w N ξ q.2))) (fun q : Fin B × Fin d => C q.1 (dSVDensityRationalPublicLogRankBucket Q q.1 (dSVDensityRationalPhysicalAcceptedRank w N ζ q.2))) z theorem dSVDensityRationalPublicBucketPhysicalCoherentMixedReset_distance_sq {d N B n : ℕ} (phases : 0 < B) (Q : ℕ) (w : ℝ) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ) : ‖dSVDensityRationalPublicBucketPhysicalCoherentLocalReset Q w ξ ζ A C (dSVDensityRationalPublicBucketPhysicalCoherentMixedState (N := N) (B := B) w n ξ ζ) - dSVDensityRationalPublicBucketPhysicalCoherentTargetState (N := N) (B := B) w n ξ ζ‖ ^ 2 = dSVDensityRationalPublicBucketPhysicalPhaseWeightedMixedError Q w ξ ζ A C := by unfold dSVDensityRationalPublicBucketPhysicalCoherentLocalReset dSVDensityRationalPublicBucketPhysicalCoherentMixedState dSVDensityRationalPublicBucketPhysicalCoherentTargetState rw [dSVDensityRationalPublicBucketCoherentPhaseSigmaReset_distance_sq phases] simp_rw [ dSVDensityRationalLocalSpectralPairHistory_apply_norm_sq] unfold dSVDensityRationalPublicBucketPhysicalPhaseWeightedMixedError dSVDensityRationalPublicLogRankPhaseWeight rw [Finset.sum_div] apply Finset.sum_congr rfl intro phase _ ring end noncomputable section open scoped BigOperators theorem dSVDensityRationalPublicShiftedResidue_sum {B : ℕ} (positive : 0 < B) (a : ℕ) : (∑ phase : Fin B, (a + phase.val) % B) = ∑ phase : Fin B, phase.val := by letI : NeZero B := ⟨Nat.ne_of_gt positive⟩ let offset : Fin B := ⟨a % B, Nat.mod_lt a positive⟩ calc (∑ phase : Fin B, (a + phase.val) % B) = ∑ phase : Fin B, (offset + phase).val := by apply Finset.sum_congr rfl intro phase _ simp [offset, Fin.val_add, Nat.add_mod] _ = ∑ phase : Fin B, phase.val := by apply Fintype.sum_equiv (Equiv.addLeft offset) intro phase rfl theorem dSVDensityRationalPublicShiftedQuotient_sum {B : ℕ} (positive : 0 < B) (a : ℕ) : (∑ phase : Fin B, (a + phase.val) / B) = a := by have decomposition : (∑ phase : Fin B, (a + phase.val) % B) + B * (∑ phase : Fin B, (a + phase.val) / B) = B * a + ∑ phase : Fin B, phase.val := by calc (∑ phase : Fin B, (a + phase.val) % B) + B * (∑ phase : Fin B, (a + phase.val) / B) = ∑ phase : Fin B, ((a + phase.val) % B + B * ((a + phase.val) / B)) := by rw [Finset.sum_add_distrib, Finset.mul_sum] _ = ∑ phase : Fin B, (a + phase.val) := by apply Finset.sum_congr rfl intro phase _ exact Nat.mod_add_div (a + phase.val) B _ = B * a + ∑ phase : Fin B, phase.val := by simp [Finset.sum_add_distrib] rw [dSVDensityRationalPublicShiftedResidue_sum positive a] at decomposition have cancelled : B * (∑ phase : Fin B, (a + phase.val) / B) = B * a := by apply Nat.add_left_cancel calc (∑ phase : Fin B, phase.val) + B * (∑ phase : Fin B, (a + phase.val) / B) = B * a + ∑ phase : Fin B, phase.val := decomposition _ = (∑ phase : Fin B, phase.val) + B * a := by omega exact Nat.mul_left_cancel positive cancelled theorem dSVDensityRationalPublicShiftedQuotient_real_sum {B : ℕ} (positive : 0 < B) (a : ℕ) : (∑ phase : Fin B, (((a + phase.val) / B : ℕ) : ℝ)) = (a : ℝ) := by exact_mod_cast dSVDensityRationalPublicShiftedQuotient_sum positive a theorem dSVDensityRationalPublicShiftedBucketMismatch_sum_le {B : ℕ} (positive : 0 < B) (a b : ℕ) : (∑ phase : Fin B, if (a + phase.val) / B = (b + phase.val) / B then (0 : ℝ) else 1) ≤ |(a : ℝ) - (b : ℝ)| := by have ordered_bound : ∀ x y : ℕ, x ≤ y → (∑ phase : Fin B, if (x + phase.val) / B = (y + phase.val) / B then (0 : ℝ) else 1) ≤ (y : ℝ) - (x : ℝ) := by intro x y ordered calc (∑ phase : Fin B, if (x + phase.val) / B = (y + phase.val) / B then (0 : ℝ) else 1) ≤ ∑ phase : Fin B, ((((y + phase.val) / B : ℕ) : ℝ) - (((x + phase.val) / B : ℕ) : ℝ)) := by apply Finset.sum_le_sum intro phase _ have monotone : (x + phase.val) / B ≤ (y + phase.val) / B := Nat.div_le_div_right (Nat.add_le_add_right ordered _) by_cases same : (x + phase.val) / B = (y + phase.val) / B · simp [same] · simp only [same, if_false] have strictly : (x + phase.val) / B < (y + phase.val) / B := lt_of_le_of_ne monotone same have cast_bound : (((x + phase.val) / B : ℕ) : ℝ) + 1 ≤ (((y + phase.val) / B : ℕ) : ℝ) := by exact_mod_cast Nat.succ_le_of_lt strictly linarith _ = (y : ℝ) - (x : ℝ) := by rw [Finset.sum_sub_distrib, dSVDensityRationalPublicShiftedQuotient_real_sum positive y, dSVDensityRationalPublicShiftedQuotient_real_sum positive x] rcases le_total a b with ordered | ordered · simpa [abs_of_nonpos (sub_nonpos.mpr (by exact_mod_cast ordered : (a : ℝ) ≤ b))] using ordered_bound a b ordered · have bound := ordered_bound b a ordered have same_sum : (∑ phase : Fin B, if (a + phase.val) / B = (b + phase.val) / B then (0 : ℝ) else 1) = ∑ phase : Fin B, if (b + phase.val) / B = (a + phase.val) / B then (0 : ℝ) else 1 := by apply Finset.sum_congr rfl intro phase _ by_cases same : (a + phase.val) / B = (b + phase.val) / B · simp only [if_pos same, if_pos same.symm] · have reversed : (b + phase.val) / B ≠ (a + phase.val) / B := Ne.symm same simp only [if_neg same, if_neg reversed] rw [same_sum] simpa [abs_of_nonneg (sub_nonneg.mpr (by exact_mod_cast ordered : (b : ℝ) ≤ a))] using bound theorem dSVDensityRationalPublicShiftedBucketMismatch_average_le {B : ℕ} (positive : 0 < B) (a b : ℕ) : (∑ phase : Fin B, (1 / (B : ℝ)) * (if (a + phase.val) / B = (b + phase.val) / B then (0 : ℝ) else 1)) ≤ |(a : ℝ) - (b : ℝ)| / (B : ℝ) := by rw [← Finset.mul_sum] have bound := dSVDensityRationalPublicShiftedBucketMismatch_sum_le positive a b calc (1 / (B : ℝ)) * (∑ phase : Fin B, if (a + phase.val) / B = (b + phase.val) / B then (0 : ℝ) else 1) ≤ (1 / (B : ℝ)) * |(a : ℝ) - (b : ℝ)| := by gcongr _ = |(a : ℝ) - (b : ℝ)| / (B : ℝ) := by ring end noncomputable section open scoped BigOperators ComplexOrder MatrixOrder def dSVDensityRationalPublicLogRankPhaseWeightedCrossing {N : ℕ} (Q B : ℕ) (r s : Fin (N + 1)) : ℝ := ∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * (if dSVDensityRationalPublicLogRankBucket Q phase r = dSVDensityRationalPublicLogRankBucket Q phase s then (0 : ℝ) else 1) theorem dSVDensityRationalPublicLogRankPhaseWeightedCrossing_nonneg {N : ℕ} (Q B : ℕ) (r s : Fin (N + 1)) : 0 ≤ dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s := by unfold dSVDensityRationalPublicLogRankPhaseWeightedCrossing apply Finset.sum_nonneg intro phase _ unfold dSVDensityRationalPublicLogRankPhaseWeight split <;> positivity theorem dSVDensityRationalPublicLogRankPhaseWeightedCrossing_le_fineLabel {N B : ℕ} (positive : 0 < B) (Q : ℕ) (r s : Fin (N + 1)) (nonzero_r : r.val ≠ 0) (nonzero_s : s.val ≠ 0) : dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s ≤ |(dSVDensityRationalPublicLogRankFineLabel Q r : ℝ) - (dSVDensityRationalPublicLogRankFineLabel Q s : ℝ)| / (B : ℝ) := by simpa [dSVDensityRationalPublicLogRankPhaseWeightedCrossing, dSVDensityRationalPublicLogRankPhaseWeight, dSVDensityRationalPublicLogRankBucket, nonzero_r, nonzero_s] using (dSVDensityRationalPublicShiftedBucketMismatch_average_le positive (dSVDensityRationalPublicLogRankFineLabel Q r) (dSVDensityRationalPublicLogRankFineLabel Q s)) theorem dSVDensityRationalPublicLogRankFineLabel_abs_sub_le {N : ℕ} (Q : ℕ) (r s : Fin (N + 1)) : |(dSVDensityRationalPublicLogRankFineLabel Q r : ℝ) - (dSVDensityRationalPublicLogRankFineLabel Q s : ℝ)| ≤ (Q : ℝ) * |Real.log ((max 1 r.val : ℕ) : ℝ) - Real.log ((max 1 s.val : ℕ) : ℝ)| + 1 := by have first := dSVDensityRationalPublicLogRankFineLabel_bounds Q r have second := dSVDensityRationalPublicLogRankFineLabel_bounds Q s have scaled : |(Q : ℝ) * Real.log ((max 1 r.val : ℕ) : ℝ) - (Q : ℝ) * Real.log ((max 1 s.val : ℕ) : ℝ)| = (Q : ℝ) * |Real.log ((max 1 r.val : ℕ) : ℝ) - Real.log ((max 1 s.val : ℕ) : ℝ)| := by rw [← mul_sub, abs_mul, abs_of_nonneg (Nat.cast_nonneg Q)] rw [← scaled] apply abs_le.mpr constructor · have lower := neg_le_abs ((Q : ℝ) * Real.log ((max 1 r.val : ℕ) : ℝ) - (Q : ℝ) * Real.log ((max 1 s.val : ℕ) : ℝ)) linarith [first.2, second.1] · have upper := le_abs_self ((Q : ℝ) * Real.log ((max 1 r.val : ℕ) : ℝ) - (Q : ℝ) * Real.log ((max 1 s.val : ℕ) : ℝ)) linarith [first.1, second.2] theorem dSVDensityRationalPublicLogRankPhaseWeightedCrossing_min_le {N B : ℕ} (positive : 0 < B) (Q : ℕ) (r s : Fin (N + 1)) : min (r.val : ℝ) (s.val : ℝ) * dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s ≤ (Q : ℝ) / (B : ℝ) * |(r.val : ℝ) - (s.val : ℝ)| + min (r.val : ℝ) (s.val : ℝ) / (B : ℝ) := by by_cases zero_r : r.val = 0 · simp [zero_r] positivity by_cases zero_s : s.val = 0 · simp [zero_s] positivity have positive_real : (0 : ℝ) < (B : ℝ) := by exact_mod_cast positive have common_nonnegative : 0 ≤ min (r.val : ℝ) (s.val : ℝ) := le_min (Nat.cast_nonneg _) (Nat.cast_nonneg _) have finite_crossing := dSVDensityRationalPublicLogRankPhaseWeightedCrossing_le_fineLabel positive Q r s zero_r zero_s have floor_error := dSVDensityRationalPublicLogRankFineLabel_abs_sub_le Q r s have logarithmic := dSVDensityRationalPublicLogRank_zeroSafe_fin_bound r s calc min (r.val : ℝ) (s.val : ℝ) * dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s ≤ min (r.val : ℝ) (s.val : ℝ) * (|(dSVDensityRationalPublicLogRankFineLabel Q r : ℝ) - (dSVDensityRationalPublicLogRankFineLabel Q s : ℝ)| / (B : ℝ)) := mul_le_mul_of_nonneg_left finite_crossing common_nonnegative _ ≤ min (r.val : ℝ) (s.val : ℝ) * (((Q : ℝ) * |Real.log ((max 1 r.val : ℕ) : ℝ) - Real.log ((max 1 s.val : ℕ) : ℝ)| + 1) / (B : ℝ)) := by apply mul_le_mul_of_nonneg_left _ common_nonnegative exact div_le_div_of_nonneg_right floor_error positive_real.le _ = (Q : ℝ) / (B : ℝ) * (min (r.val : ℝ) (s.val : ℝ) * |Real.log ((max 1 r.val : ℕ) : ℝ) - Real.log ((max 1 s.val : ℕ) : ℝ)|) + min (r.val : ℝ) (s.val : ℝ) / (B : ℝ) := by ring _ ≤ (Q : ℝ) / (B : ℝ) * |(r.val : ℝ) - (s.val : ℝ)| + min (r.val : ℝ) (s.val : ℝ) / (B : ℝ) := by have scaled := mul_le_mul_of_nonneg_left logarithmic (div_nonneg (Nat.cast_nonneg Q) positive_real.le) linarith end noncomputable section open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem dSVDensityRationalPublicLogRankBucketRepresentative_val_pos {N B : ℕ} (Q : ℕ) (phase : Fin B) (r : Fin (N + 1)) (nonzero : r.val ≠ 0) : 0 < (dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val := by exact Nat.pos_of_ne_zero (dSVDensityRationalPublicLogRankBucketRepresentative_same Q phase r nonzero).1 theorem dSVDensityRationalPublicLogRankBucketRepresentative_actual_log_sub_lt {N B : ℕ} {Q : ℕ} (positive_Q : 0 < Q) (phase : Fin B) (r : Fin (N + 1)) (nonzero : r.val ≠ 0) : |Real.log (r.val : ℝ) - Real.log ((dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val : ℝ)| < ((B : ℝ) + 1) / (Q : ℝ) := by have one_r : 1 ≤ r.val := Nat.one_le_iff_ne_zero.mpr nonzero have one_representative : 1 ≤ (dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val := dSVDensityRationalPublicLogRankBucketRepresentative_val_pos Q phase r nonzero simpa [max_eq_right one_r, max_eq_right one_representative] using (dSVDensityRationalPublicLogRankBucketRepresentative_log_sub_lt positive_Q phase r nonzero) theorem dSVDensityRationalPublicLogRankBucketRepresentative_rank_ratio_lt {N B : ℕ} {Q : ℕ} (positive_Q : 0 < Q) (phase : Fin B) (r : Fin (N + 1)) (nonzero : r.val ≠ 0) : (r.val : ℝ) / ((dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val : ℝ) < Real.exp (((B : ℝ) + 1) / (Q : ℝ)) := by let representative : Fin (N + 1) := dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r) have positive_r : (0 : ℝ) < (r.val : ℝ) := by exact_mod_cast (Nat.pos_of_ne_zero nonzero) have positive_representative_nat : 0 < representative.val := by dsimp [representative] exact dSVDensityRationalPublicLogRankBucketRepresentative_val_pos Q phase r nonzero have positive_representative : (0 : ℝ) < (representative.val : ℝ) := by exact_mod_cast positive_representative_nat have diameter := dSVDensityRationalPublicLogRankBucketRepresentative_actual_log_sub_lt positive_Q phase r nonzero change |Real.log (r.val : ℝ) - Real.log (representative.val : ℝ)| < ((B : ℝ) + 1) / (Q : ℝ) at diameter have logarithmic : Real.log (r.val : ℝ) - Real.log (representative.val : ℝ) < ((B : ℝ) + 1) / (Q : ℝ) := lt_of_le_of_lt (le_abs_self _) diameter have exponential := (Real.exp_lt_exp).mpr logarithmic rw [← Real.log_div positive_r.ne' positive_representative.ne', Real.exp_log (div_pos positive_r positive_representative)] at exponential exact exponential theorem dSVDensityRationalPublicLogRankBucketRepresentative_relative_sub_lt {N B : ℕ} {Q : ℕ} (positive_Q : 0 < Q) (phase : Fin B) (r : Fin (N + 1)) (nonzero : r.val ≠ 0) : ((r.val : ℝ) - ((dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val : ℝ)) / ((dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val : ℝ) < Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 := by let representative : Fin (N + 1) := dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r) have positive_representative_nat : 0 < representative.val := by dsimp [representative] exact dSVDensityRationalPublicLogRankBucketRepresentative_val_pos Q phase r nonzero have positive_representative : (0 : ℝ) < (representative.val : ℝ) := by exact_mod_cast positive_representative_nat have ratio := dSVDensityRationalPublicLogRankBucketRepresentative_rank_ratio_lt positive_Q phase r nonzero change (r.val : ℝ) / (representative.val : ℝ) < Real.exp (((B : ℝ) + 1) / (Q : ℝ)) at ratio change ((r.val : ℝ) - (representative.val : ℝ)) / (representative.val : ℝ) < Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 rw [sub_div, div_self positive_representative.ne'] linarith theorem dSVDensityRationalPublicLogRankBucketRepresentative_relative_abs_lt {N B : ℕ} {Q : ℕ} (positive_Q : 0 < Q) (phase : Fin B) (r : Fin (N + 1)) (nonzero : r.val ≠ 0) : |(r.val : ℝ) - ((dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val : ℝ)| / ((max 1 (min r.val (dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r)).val) : ℕ) : ℝ) < Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 := by let representative : Fin (N + 1) := dSVDensityRationalPublicLogRankBucketRepresentative (N := N) Q phase (dSVDensityRationalPublicLogRankBucket Q phase r) have ordered : representative.val ≤ r.val := by exact dSVDensityRationalPublicLogRankBucketRepresentative_le Q phase r nonzero have one_representative : 1 ≤ representative.val := by dsimp [representative] exact dSVDensityRationalPublicLogRankBucketRepresentative_val_pos Q phase r nonzero have real_ordered : (representative.val : ℝ) ≤ (r.val : ℝ) := by exact_mod_cast ordered have relative := dSVDensityRationalPublicLogRankBucketRepresentative_relative_sub_lt positive_Q phase r nonzero change ((r.val : ℝ) - (representative.val : ℝ)) / (representative.val : ℝ) < Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 at relative change |(r.val : ℝ) - (representative.val : ℝ)| / ((max 1 (min r.val representative.val) : ℕ) : ℝ) < Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 simpa [min_eq_right ordered, max_eq_right one_representative, abs_of_nonneg (sub_nonneg.mpr real_ordered)] using relative end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem dSVDensityRationalPublicLogRankPhaseWeightedCrossing_le_one {N B : ℕ} (positive : 0 < B) (Q : ℕ) (r s : Fin (N + 1)) : dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s ≤ 1 := by unfold dSVDensityRationalPublicLogRankPhaseWeightedCrossing calc _ ≤ ∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase := by apply Finset.sum_le_sum intro phase _ split_ifs <;> simp [dSVDensityRationalPublicLogRankPhaseWeight] _ = 1 := dSVDensityRationalPublicLogRankPhaseWeight_sum positive theorem dSVDensityRationalPublicLogRankPhaseWeightedCrossing_alice_le {N B : ℕ} (positive : 0 < B) (Q : ℕ) (r s : Fin (N + 1)) : (r.val : ℝ) * dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s ≤ ((Q : ℝ) / (B : ℝ) + 1) * |(r.val : ℝ) - (s.val : ℝ)| + min (r.val : ℝ) (s.val : ℝ) / (B : ℝ) := by let x := dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s let m : ℝ := min (r.val : ℝ) (s.val : ℝ) let t : ℝ := |(r.val : ℝ) - (s.val : ℝ)| have nonnegative : 0 ≤ x := dSVDensityRationalPublicLogRankPhaseWeightedCrossing_nonneg Q B r s have probability : x ≤ 1 := dSVDensityRationalPublicLogRankPhaseWeightedCrossing_le_one positive Q r s have min_le : m ≤ (r.val : ℝ) := min_le_left _ _ have difference : (r.val : ℝ) - m ≤ t := by dsimp [m, t] rcases le_total (r.val : ℝ) (s.val : ℝ) with ordered | ordered · rw [min_eq_left ordered] simp · rw [min_eq_right ordered, abs_of_nonneg (sub_nonneg.mpr ordered)] have extra : ((r.val : ℝ) - m) * x ≤ t := by calc _ ≤ ((r.val : ℝ) - m) * 1 := mul_le_mul_of_nonneg_left probability (sub_nonneg.mpr min_le) _ ≤ t := by simpa using difference have main := dSVDensityRationalPublicLogRankPhaseWeightedCrossing_min_le positive Q r s change m * x ≤ (Q : ℝ) / (B : ℝ) * t + m / (B : ℝ) at main change (r.val : ℝ) * x ≤ ((Q : ℝ) / (B : ℝ) + 1) * t + m / (B : ℝ) nlinarith theorem exists_proofDSVDensityRationalPublicBucketPhysicalQuantitativeMixedPrefixCleanup_sq {N B : ℕ} (grid : 0 < N) (phases : 0 < B) {Q : ℕ} (fine : 0 < Q) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ (r s : Fin (N + 1)), (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * ‖localUnitaryAction (A phase (dSVDensityRationalPublicLogRankBucket Q phase r)) (C phase (dSVDensityRationalPublicLogRankBucket Q phase s)) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix (dSVDensityRationalPublicBucketPhysicalCommonRank r s))) - Real.sqrt (r.val : ℝ) • embezzlementState (N * n)‖ ^ 2) ≤ 2 * |(r.val : ℝ) - (s.val : ℝ)| + 4 * (r.val : ℝ) * ε ^ 2 + 16 * (r.val : ℝ) * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 * (((Q : ℝ) / (B : ℝ) + 1) * |(r.val : ℝ) - (s.val : ℝ)| + min (r.val : ℝ) (s.val : ℝ) / (B : ℝ)) := by let bucket : Fin B → Fin (N + 1) → Option ℕ := dSVDensityRationalPublicLogRankBucket Q let representative : Fin B → Option ℕ → Fin (N + 1) := dSVDensityRationalPublicLogRankBucketRepresentative Q obtain ⟨n, positive, A, C, accurate⟩ := exists_proofDSVDensityRationalPublicBucketPhysicalMixedPrefixCleanup_sq grid bucket representative ε precision refine ⟨n, positive, A, C, ?_⟩ intro r s let gap : ℝ := |(r.val : ℝ) - (s.val : ℝ)| let radius : ℝ := Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 let base : ℝ := 2 * gap + 4 * (r.val : ℝ) * ε ^ 2 + 16 * (r.val : ℝ) * radius have representative_bound (phase : Fin B) : (r.val : ℝ) * (|(r.val : ℝ) - ((representative phase (bucket phase r)).val : ℝ)| / ((max 1 (min r.val (representative phase (bucket phase r)).val) : ℕ) : ℝ)) ≤ (r.val : ℝ) * radius := by by_cases zero : r.val = 0 · simp [zero] · have actual := dSVDensityRationalPublicLogRankBucketRepresentative_relative_abs_lt fine phase r zero change |(r.val : ℝ) - ((representative phase (bucket phase r)).val : ℝ)| / ((max 1 (min r.val (representative phase (bucket phase r)).val) : ℕ) : ℝ) < radius at actual exact mul_le_mul_of_nonneg_left actual.le (Nat.cast_nonneg r.val) have point (phase : Fin B) : ‖localUnitaryAction (A phase (bucket phase r)) (C phase (bucket phase s)) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix (dSVDensityRationalPublicBucketPhysicalCommonRank r s))) - Real.sqrt (r.val : ℝ) • embezzlementState (N * n)‖ ^ 2 ≤ base + 8 * (r.val : ℝ) * (if bucket phase r = bucket phase s then (0 : ℝ) else 1) := by have actual := accurate phase r s have variation := representative_bound phase calc _ ≤ 2 * gap + 2 * (r.val : ℝ) * (2 * ε ^ 2 + 8 * |(r.val : ℝ) - ((representative phase (bucket phase r)).val : ℝ)| / ((max 1 (min r.val (representative phase (bucket phase r)).val) : ℕ) : ℝ) + 4 * (if bucket phase r = bucket phase s then (0 : ℝ) else 1)) := by simpa [gap] using actual _ = 2 * gap + 4 * (r.val : ℝ) * ε ^ 2 + 16 * ((r.val : ℝ) * (|(r.val : ℝ) - ((representative phase (bucket phase r)).val : ℝ)| / ((max 1 (min r.val (representative phase (bucket phase r)).val) : ℕ) : ℝ))) + 8 * (r.val : ℝ) * (if bucket phase r = bucket phase s then (0 : ℝ) else 1) := by ring _ ≤ base + 8 * (r.val : ℝ) * (if bucket phase r = bucket phase s then (0 : ℝ) else 1) := by dsimp [base] nlinarith have averaged : (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * ‖localUnitaryAction (A phase (bucket phase r)) (C phase (bucket phase s)) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVCanonicalFailurePrefix (dSVDensityRationalPublicBucketPhysicalCommonRank r s))) - Real.sqrt (r.val : ℝ) • embezzlementState (N * n)‖ ^ 2) ≤ base + 8 * (r.val : ℝ) * dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s := by calc _ ≤ ∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * (base + 8 * (r.val : ℝ) * (if bucket phase r = bucket phase s then (0 : ℝ) else 1)) := by apply Finset.sum_le_sum intro phase _ exact mul_le_mul_of_nonneg_left (point phase) (by unfold dSVDensityRationalPublicLogRankPhaseWeight positivity) _ = base + 8 * (r.val : ℝ) * dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s := by unfold dSVDensityRationalPublicLogRankPhaseWeightedCrossing have total := dSVDensityRationalPublicLogRankPhaseWeight_sum phases calc _ = base * (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase) + 8 * (r.val : ℝ) * (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * (if bucket phase r = bucket phase s then (0 : ℝ) else 1)) := by simp_rw [Finset.mul_sum] rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro phase _ ring _ = _ := by rw [total]; simp [bucket] have crossing := dSVDensityRationalPublicLogRankPhaseWeightedCrossing_alice_le phases Q r s change _ ≤ 2 * gap + 4 * (r.val : ℝ) * ε ^ 2 + 16 * (r.val : ℝ) * radius + 8 * (((Q : ℝ) / (B : ℝ) + 1) * gap + min (r.val : ℝ) (s.val : ℝ) / (B : ℝ)) change (r.val : ℝ) * dSVDensityRationalPublicLogRankPhaseWeightedCrossing Q B r s ≤ ((Q : ℝ) / (B : ℝ) + 1) * gap + min (r.val : ℝ) (s.val : ℝ) / (B : ℝ) at crossing dsimp [bucket] at averaged dsimp [base] at averaged nlinarith def dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight {d : ℕ} (N : ℕ) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : ℝ := dSVDensityRationalPrefixHarmonicSpectralOverlap ξ ζ i j / ((d : ℝ) * (N : ℝ)) theorem dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight_nonneg {d : ℕ} (N : ℕ) (ξ ζ : BipartiteUnitVector d) (i j : Fin d) : 0 ≤ dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight N ξ ζ i j := by exact div_nonneg (dSVDensityRationalPrefixHarmonicSpectralOverlap_nonneg ξ ζ i j) (mul_nonneg (Nat.cast_nonneg d) (Nat.cast_nonneg N)) def dSVDensityRationalHeterogeneousCommonStopSpectralRankGap {d : ℕ} (N : ℕ) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : ℝ := ∑ i : Fin d, ∑ j : Fin d, dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight N ξ ζ i j * |((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) - ((dSVDensityRationalPhysicalAcceptedRank w N ζ j).val : ℝ)| theorem dSVDensityRationalHeterogeneousCommonStopSpectralRankGap_eq_hazard {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousCommonStopSpectralRankGap N w ξ ζ = dSVDensityRationalPhysicalProjectorCrossHazard N w ξ ζ := by rw [← dSVDensityRationalPrefixRankMismatch_physicalHazard grid dimension w ξ ζ] unfold dSVDensityRationalHeterogeneousCommonStopSpectralRankGap dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight dSVDensityRationalPrefixRankMismatch dSVDensityRationalPrefixHarmonicSpectralOverlap simp_rw [div_mul_eq_mul_div, ← Finset.sum_div] rw [div_div, mul_comm (N : ℝ) (d : ℝ)] def dSVDensityRationalHeterogeneousCommonStopSpectralAliceMass {d : ℕ} (N : ℕ) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : ℝ := ∑ i : Fin d, ∑ j : Fin d, dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight N ξ ζ i j * ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) theorem dSVDensityRationalHeterogeneousCommonStopSpectralAliceMass_eq_diagonalBorn {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (w : ℝ) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousCommonStopSpectralAliceMass N w ξ ζ = dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ := by classical have row (i : Fin d) : (∑ j : Fin d, dSVDensityRationalPrefixHarmonicSpectralOverlap ξ ζ i j) = 1 := by unfold dSVDensityRationalPrefixHarmonicSpectralOverlap exact spectralAtomOverlap_sum_right (dSVSoftBobLeftReducedDensity ξ) (dSVSoftBobLeftReducedDensity ζ) (dSVSoftBobLeftReducedDensity_posSemidef ξ) (dSVSoftBobLeftReducedDensity_posSemidef ζ) i rw [dSVDensityRationalPhysicalDiagonalBornSuccess_eq grid dimension w ξ] unfold dSVDensityRationalHeterogeneousCommonStopSpectralAliceMass dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight dSVDensityRationalLeftProjectiveDiagonalMass simp_rw [dSVDensityRationalPhysicalAcceptedRank_gridPrefix] calc (∑ i : Fin d, ∑ j : Fin d, dSVDensityRationalPrefixHarmonicSpectralOverlap ξ ζ i j / ((d : ℝ) * (N : ℝ)) * ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ)) = ∑ i : Fin d, (((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) / ((d : ℝ) * (N : ℝ))) * (∑ j : Fin d, dSVDensityRationalPrefixHarmonicSpectralOverlap ξ ζ i j) := by apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j _ ring _ = ∑ i : Fin d, ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) / ((d : ℝ) * (N : ℝ)) := by simp_rw [row, mul_one] _ = (∑ i : Fin d, ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ)) / ((d : ℝ) * (N : ℝ)) := by rw [Finset.sum_div] _ = ((∑ i : Fin d, ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ)) / (N : ℝ)) / (d : ℝ) := by rw [div_div, mul_comm (N : ℝ) (d : ℝ)] _ = (∑ i : Fin d, ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) / (N : ℝ)) / (d : ℝ) := by rw [Finset.sum_div] theorem exists_proofDSVDensityRationalHeterogeneousCommonStopSpectralGaugeContinuity_sq {d N B : ℕ} (grid : 0 < N) (dimension : 0 < d) (phases : 0 < B) {Q : ℕ} (fine : 0 < Q) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ {S L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (k : Fin L), ‖dSVDensityRationalPublicBucketPhysicalCoherentLocalReset Q (width (schedule k)) ξ ζ A C (dSVDensityRationalPublicBucketPhysicalCoherentMixedState (N := N) (B := B) (width (schedule k)) n ξ ζ) - dSVDensityRationalPublicBucketPhysicalCoherentTargetState (N := N) (B := B) (width (schedule k)) n ξ ζ‖ ^ 2 ≤ (10 + 8 * ((Q : ℝ) / (B : ℝ))) * dSVDensityRationalPhysicalProjectorCrossHazard N (width (schedule k)) ξ ζ + (4 * ε ^ 2 + 16 * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 / (B : ℝ)) * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ := by classical obtain ⟨n, harmonic, A, C, accurate⟩ := exists_proofDSVDensityRationalPublicBucketPhysicalQuantitativeMixedPrefixCleanup_sq grid phases fine ε precision refine ⟨n, harmonic, A, C, ?_⟩ intro S L width schedule ξ ζ k let w : ℝ := width (schedule k) let coefficient : Fin d → Fin d → ℝ := dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight N ξ ζ let gap : Fin d → Fin d → ℝ := fun i j => |((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) - ((dSVDensityRationalPhysicalAcceptedRank w N ζ j).val : ℝ)| let alice : Fin d → ℝ := fun i => ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) let Kgap : ℝ := 10 + 8 * ((Q : ℝ) / (B : ℝ)) let Kmass : ℝ := 4 * ε ^ 2 + 16 * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 / (B : ℝ) have point (i j : Fin d) : (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * ‖localUnitaryAction (A phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ξ i))) (C phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ζ j))) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j)) - Real.sqrt (alice i) • embezzlementState (N * n)‖ ^ 2) ≤ Kgap * gap i j + Kmass * alice i := by have atom := accurate (dSVDensityRationalPhysicalAcceptedRank w N ξ i) (dSVDensityRationalPhysicalAcceptedRank w N ζ j) rw [dSVDensityRationalPublicBucketPhysicalCommonRank_eq w ξ ζ i j] at atom change (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * ‖localUnitaryAction (A phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ξ i))) (C phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ζ j))) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j)) - Real.sqrt (alice i) • embezzlementState (N * n)‖ ^ 2) ≤ 2 * gap i j + 4 * alice i * ε ^ 2 + 16 * alice i * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 * (((Q : ℝ) / (B : ℝ) + 1) * gap i j + min (alice i) ((dSVDensityRationalPhysicalAcceptedRank w N ζ j).val : ℝ) / (B : ℝ)) at atom have min_bound : min (alice i) ((dSVDensityRationalPhysicalAcceptedRank w N ζ j).val : ℝ) / (B : ℝ) ≤ alice i / (B : ℝ) := div_le_div_of_nonneg_right (min_le_left _ _) (by exact_mod_cast phases.le) calc _ ≤ 2 * gap i j + 4 * alice i * ε ^ 2 + 16 * alice i * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 * (((Q : ℝ) / (B : ℝ) + 1) * gap i j + min (alice i) ((dSVDensityRationalPhysicalAcceptedRank w N ζ j).val : ℝ) / (B : ℝ)) := atom _ = Kgap * gap i j + (4 * ε ^ 2 + 16 * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1)) * alice i + 8 * (min (alice i) ((dSVDensityRationalPhysicalAcceptedRank w N ζ j).val : ℝ) / (B : ℝ)) := by dsimp [Kgap] ring _ ≤ Kgap * gap i j + (4 * ε ^ 2 + 16 * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1)) * alice i + 8 * (alice i / (B : ℝ)) := by nlinarith [min_bound] _ = Kgap * gap i j + Kmass * alice i := by dsimp [Kmass] ring have exchange : dSVDensityRationalPublicBucketPhysicalPhaseWeightedMixedError Q w ξ ζ A C = ∑ i : Fin d, ∑ j : Fin d, coefficient i j * (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * ‖localUnitaryAction (A phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ξ i))) (C phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ζ j))) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j)) - Real.sqrt (alice i) • embezzlementState (N * n)‖ ^ 2) := by unfold dSVDensityRationalPublicBucketPhysicalPhaseWeightedMixedError change (∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * ∑ i : Fin d, ∑ j : Fin d, coefficient i j * _) = _ calc _ = ∑ phase : Fin B, ∑ i : Fin d, ∑ j : Fin d, dSVDensityRationalPublicLogRankPhaseWeight B phase * (coefficient i j * ‖localUnitaryAction (A phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ξ i))) (C phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ζ j))) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j)) - Real.sqrt (alice i) • embezzlementState (N * n)‖ ^ 2) := by simp_rw [Finset.mul_sum] rfl _ = ∑ i : Fin d, ∑ j : Fin d, ∑ phase : Fin B, dSVDensityRationalPublicLogRankPhaseWeight B phase * (coefficient i j * ‖localUnitaryAction (A phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ξ i))) (C phase (dSVDensityRationalPublicLogRankBucket Q phase (dSVDensityRationalPhysicalAcceptedRank w N ζ j))) (dSVDensityRationalMixedCanonicalPrefixPureHarmonicTensor n (dSVDensityRationalPhysicalMixedAcceptedPrefixWork w N ξ ζ i j)) - Real.sqrt (alice i) • embezzlementState (N * n)‖ ^ 2) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro i _ rw [Finset.sum_comm] _ = _ := by apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro phase _ ring rw [dSVDensityRationalPublicBucketPhysicalCoherentMixedReset_distance_sq phases Q w ξ ζ A C, exchange] calc _ ≤ ∑ i : Fin d, ∑ j : Fin d, coefficient i j * (Kgap * gap i j + Kmass * alice i) := by apply Finset.sum_le_sum intro i _ apply Finset.sum_le_sum intro j _ exact mul_le_mul_of_nonneg_left (point i j) (dSVDensityRationalHeterogeneousCommonStopSpectralAtomWeight_nonneg N ξ ζ i j) _ = Kgap * dSVDensityRationalHeterogeneousCommonStopSpectralRankGap N w ξ ζ + Kmass * dSVDensityRationalHeterogeneousCommonStopSpectralAliceMass N w ξ ζ := by unfold dSVDensityRationalHeterogeneousCommonStopSpectralRankGap dSVDensityRationalHeterogeneousCommonStopSpectralAliceMass change (∑ i : Fin d, ∑ j : Fin d, coefficient i j * (Kgap * gap i j + Kmass * alice i)) = Kgap * (∑ i : Fin d, ∑ j : Fin d, coefficient i j * gap i j) + Kmass * (∑ i : Fin d, ∑ j : Fin d, coefficient i j * alice i) simp_rw [mul_add, Finset.sum_add_distrib, Finset.mul_sum] congr 1 · apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring · apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring _ = _ := by rw [ dSVDensityRationalHeterogeneousCommonStopSpectralRankGap_eq_hazard grid dimension w ξ ζ, dSVDensityRationalHeterogeneousCommonStopSpectralAliceMass_eq_diagonalBorn grid dimension w ξ ζ] end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder def dSVDensityRationalHeterogeneousCommonStopGaugeStageError {d N B : ℕ} (Q : ℕ) (w : ℝ) (n : ℕ) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ) : ℝ := ‖dSVDensityRationalPublicBucketPhysicalCoherentLocalReset Q w ξ ζ A C (dSVDensityRationalPublicBucketPhysicalCoherentMixedState (N := N) (B := B) w n ξ ζ) - dSVDensityRationalPublicBucketPhysicalCoherentTargetState (N := N) (B := B) w n ξ ζ‖ ^ 2 def dSVDensityRationalHeterogeneousStoppedCommonStopGaugeError {d N B S L : ℕ} (Q : ℕ) (n : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ) : ℝ := ∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * dSVDensityRationalHeterogeneousCommonStopGaugeStageError Q (width (schedule k)) n ξ ζ A C theorem dSVDensityRationalHeterogeneousPhysicalDiagonalSurvival_budget {d S L N : ℕ} (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : (∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ) ≤ 1 := by calc _ ≤ ∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k.val + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k.val) := by apply Finset.sum_le_sum intro k _ exact mul_le_mul_of_nonneg_left (dSVDensityRationalHeterogeneousPhysicalStage_escape_ge_diagonal grid dimension width schedule ξ ζ k) (dSVDensityRationalHeterogeneousPhysicalSurvival_nonneg N width schedule ξ ζ k.val) _ = ∑ k ∈ Finset.range L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k) := by simpa using (Fin.sum_univ_eq_sum_range (fun k : ℕ => dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * (dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k + dSVDensityRationalHeterogeneousPhysicalStageAsynchronous N width schedule ξ ζ k)) L) _ ≤ 1 := dSVDensityRationalHeterogeneousPhysicalStoppedEscape_budget grid dimension width schedule ξ ζ theorem exists_proofDSVDensityRationalHeterogeneousStoppedCommonStopGaugeErrorBound {d N B : ℕ} (grid : 0 < N) (dimension : 0 < d) (phases : 0 < B) {Q : ℕ} (fine : 0 < Q) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ {S L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d), dSVDensityRationalHeterogeneousStoppedCommonStopGaugeError Q n width schedule ξ ζ A C ≤ (10 + 8 * ((Q : ℝ) / (B : ℝ))) * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ + (4 * ε ^ 2 + 16 * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 / (B : ℝ)) := by obtain ⟨n, harmonic, A, C, stage⟩ := exists_proofDSVDensityRationalHeterogeneousCommonStopSpectralGaugeContinuity_sq grid dimension phases fine ε precision let Kgap : ℝ := 10 + 8 * ((Q : ℝ) / (B : ℝ)) let Kmass : ℝ := 4 * ε ^ 2 + 16 * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 / (B : ℝ) have exponent_nonnegative : 0 ≤ (((B : ℝ) + 1) / (Q : ℝ)) := by positivity have exponential_nonnegative : 0 ≤ Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 := by have exponential := Real.add_one_le_exp (((B : ℝ) + 1) / (Q : ℝ)) linarith have Kmass_nonnegative : 0 ≤ Kmass := by dsimp [Kmass] positivity refine ⟨n, harmonic, A, C, ?_⟩ intro S L width schedule ξ ζ have diagonal_budget := dSVDensityRationalHeterogeneousPhysicalDiagonalSurvival_budget grid dimension width schedule ξ ζ unfold dSVDensityRationalHeterogeneousStoppedCommonStopGaugeError change (∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * dSVDensityRationalHeterogeneousCommonStopGaugeStageError Q (width (schedule k)) n ξ ζ A C) ≤ Kgap * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ + Kmass calc _ ≤ ∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * (Kgap * dSVDensityRationalPhysicalProjectorCrossHazard N (width (schedule k)) ξ ζ + Kmass * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ) := by apply Finset.sum_le_sum intro k _ have stage_bound := stage width schedule ξ ζ k change dSVDensityRationalHeterogeneousCommonStopGaugeStageError Q (width (schedule k)) n ξ ζ A C ≤ Kgap * dSVDensityRationalPhysicalProjectorCrossHazard N (width (schedule k)) ξ ζ + Kmass * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ at stage_bound exact mul_le_mul_of_nonneg_left stage_bound (dSVDensityRationalHeterogeneousPhysicalSurvival_nonneg N width schedule ξ ζ k.val) _ = Kgap * (∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * dSVDensityRationalPhysicalProjectorCrossHazard N (width (schedule k)) ξ ζ) + Kmass * (∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ) := by simp_rw [Finset.mul_sum] rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro k _ ring _ = Kgap * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ + Kmass * (∑ k : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k.val * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule k)) ξ) := by rw [ dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass_eq_hazard] _ ≤ Kgap * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule ξ ζ + Kmass := by nlinarith [mul_nonneg Kmass_nonnegative (sub_nonneg.mpr diagonal_budget)] def dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureCopy {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (i : Fin j.val) : EuclideanSpace ℂ (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d) := dSVDensityRationalCompleteProjectiveOutcome (width (schedule ⟨i.val, lt_trans i.isLt j.isLt⟩)) N ξ ζ false false def dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) : EuclideanSpace ℂ (Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) := finiteTensorVector (dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureCopy width schedule ξ ζ j) theorem dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureCopy_eq_actual {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (i : Fin j.val) : dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureCopy (N := N) width schedule ξ ζ j i = dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j ⟨i.val, by omega⟩ := by symm exact dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome_before width schedule ξ ζ j ⟨i.val, by omega⟩ i.isLt theorem dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector_apply {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (q : Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) : dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector width schedule ξ ζ j q = ∏ i : Fin j.val, dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j ⟨i.val, by omega⟩ (q i) := by change (∏ i : Fin j.val, dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureCopy width schedule ξ ζ j i (q i)) = _ apply Finset.prod_congr rfl intro i _ rw [dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureCopy_eq_actual] theorem dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector_norm_sq {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) : ‖dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector (N := N) width schedule ξ ζ j‖ ^ 2 = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val := by rw [dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector, finiteTensorVector_norm_sq] unfold dSVDensityRationalHeterogeneousPhysicalSurvival dSVHeterogeneousRealPrefix calc (∏ i : Fin j.val, ‖dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureCopy width schedule ξ ζ j i‖ ^ 2) = ∏ i : Fin j.val, dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ i.val := by apply Finset.prod_congr rfl intro i _ simp [dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureCopy, dSVDensityRationalHeterogeneousPhysicalStageContinue, dSVDensityRationalHeterogeneousPhysicalStageOutcome, lt_trans i.isLt j.isLt] _ = _ := Fin.prod_univ_eq_prod_range (dSVDensityRationalHeterogeneousPhysicalStageContinue N width schedule ξ ζ) j.val def dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard {d N B S L : ℕ} (Q n : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ) : ℝ := ∑ j : Fin L, ‖dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector (N := N) width schedule ξ ζ j‖ ^ 2 * dSVDensityRationalHeterogeneousCommonStopGaugeStageError Q (width (schedule j)) n ξ ζ A C theorem dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard_eq_gaugeError {d N B S L : ℕ} (Q n : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ) : dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q n width schedule ξ ζ A C = dSVDensityRationalHeterogeneousStoppedCommonStopGaugeError Q n width schedule ξ ζ A C := by unfold dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard dSVDensityRationalHeterogeneousStoppedCommonStopGaugeError simp_rw [ dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector_norm_sq] theorem exists_proofDSVDensityRationalHeterogeneousStoppedCommonPrefixHazardBound {d N B : ℕ} (grid : 0 < N) (dimension : 0 < d) (phases : 0 < B) {Q : ℕ} (fine : 0 < Q) (ε : ℝ) (precision : 0 < ε) : ∃ n : ℕ, 0 < n ∧ ∃ A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ {S L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d), dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q n width schedule ξ ζ A C ≤ (10 + 8 * ((Q : ℝ) / (B : ℝ))) * dSVDensityRationalHeterogeneousActualAsynchronousFlagMass N width schedule ξ ζ + (4 * ε ^ 2 + 16 * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 / (B : ℝ)) := by obtain ⟨n, harmonic, A, C, bound⟩ := exists_proofDSVDensityRationalHeterogeneousStoppedCommonStopGaugeErrorBound grid dimension phases fine ε precision refine ⟨n, harmonic, A, C, ?_⟩ intro S L width schedule ξ ζ rw [dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard_eq_gaugeError, dSVDensityRationalHeterogeneousActualAsynchronousFlagMass_eq_stoppedAsynchronousMass grid dimension width schedule ξ ζ] exact bound width schedule ξ ζ end noncomputable section theorem unconditionalPublicBucket_exp_sub_one_le {u : ℝ} (nonnegative : 0 ≤ u) (bounded : u ≤ 1) : Real.exp u - 1 ≤ (Real.exp 1 - 1) * u := by have chord := convexOn_exp.2 (Set.mem_univ (0 : ℝ)) (Set.mem_univ (1 : ℝ)) (sub_nonneg.mpr bounded) nonnegative (show (1 - u) + u = (1 : ℝ) by ring) simp only [smul_eq_mul, mul_zero, zero_add, mul_one, Real.exp_zero] at chord nlinarith def unconditionalPublicBucketLoss (B Q : ℕ) (asynchronous precision : ℝ) : ℝ := (10 + 8 * ((Q : ℝ) / (B : ℝ))) * asynchronous + (4 * precision ^ 2 + 16 * (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1) + 8 / (B : ℝ)) theorem exists_proofUnconditionalPublicBucketBalance (t : ℝ) (positive : 0 < t) (bounded : t ≤ 1) : ∃ B Q : ℕ, 0 < B ∧ 0 < Q ∧ (1 / (B : ℝ) ≤ t / 2) ∧ ((Q : ℝ) / (B : ℝ) ≤ 3 / t) ∧ (((B : ℝ) + 1) / (Q : ℝ) ≤ t) ∧ (Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 ≤ (Real.exp 1 - 1) * t) ∧ ∀ asynchronous precision : ℝ, 0 ≤ asynchronous → unconditionalPublicBucketLoss B Q asynchronous precision ≤ (34 / t) * asynchronous + 4 * precision ^ 2 + (16 * (Real.exp 1 - 1) + 4) * t := by let B : ℕ := ⌈(2 : ℝ) / t⌉₊ let Q : ℕ := B ^ 2 have B_positive : 0 < B := by dsimp [B] exact Nat.ceil_pos.mpr (div_pos (by norm_num) positive) have B_real_positive : 0 < (B : ℝ) := by exact_mod_cast B_positive have Q_positive : 0 < Q := pow_pos B_positive 2 have Q_real_positive : 0 < (Q : ℝ) := by exact_mod_cast Q_positive have lower : 2 / t ≤ (B : ℝ) := by exact Nat.le_ceil ((2 : ℝ) / t) have product_lower : (2 : ℝ) ≤ (B : ℝ) * t := (div_le_iff₀ positive).mp lower have inverse_bound : 1 / (B : ℝ) ≤ t / 2 := by apply (div_le_iff₀ B_real_positive).mpr nlinarith have ceiling_upper : (B : ℝ) < 2 / t + 1 := by exact Nat.ceil_lt_add_one (by positivity : (0 : ℝ) ≤ 2 / t) have product_upper : (B : ℝ) * t < 2 + t := by calc (B : ℝ) * t < (2 / t + 1) * t := mul_lt_mul_of_pos_right ceiling_upper positive _ = 2 + t := by field_simp have B_upper : (B : ℝ) ≤ 3 / t := by apply (le_div_iff₀ positive).mpr nlinarith have ratio_eq : (Q : ℝ) / (B : ℝ) = (B : ℝ) := by dsimp [Q] push_cast field_simp have ratio_bound : (Q : ℝ) / (B : ℝ) ≤ 3 / t := ratio_eq.trans_le B_upper have B_at_least_one : (1 : ℝ) ≤ (B : ℝ) := by exact_mod_cast B_positive have width_bound : ((B : ℝ) + 1) / (Q : ℝ) ≤ t := by apply (div_le_iff₀ Q_real_positive).mpr have multiply := mul_le_mul_of_nonneg_right product_lower B_real_positive.le have Q_real : (Q : ℝ) = (B : ℝ) ^ 2 := by simp [Q] rw [Q_real] nlinarith have width_nonnegative : 0 ≤ ((B : ℝ) + 1) / (Q : ℝ) := by positivity have exponential_bound : Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 ≤ (Real.exp 1 - 1) * t := by calc Real.exp (((B : ℝ) + 1) / (Q : ℝ)) - 1 ≤ (Real.exp 1 - 1) * (((B : ℝ) + 1) / (Q : ℝ)) := unconditionalPublicBucket_exp_sub_one_le width_nonnegative (width_bound.trans bounded) _ ≤ (Real.exp 1 - 1) * t := by have coefficient : 0 ≤ Real.exp 1 - 1 := by nlinarith [Real.add_one_le_exp (1 : ℝ)] exact mul_le_mul_of_nonneg_left width_bound coefficient refine ⟨B, Q, B_positive, Q_positive, inverse_bound, ratio_bound, width_bound, exponential_bound, ?_⟩ intro asynchronous precision asynchronous_nonnegative have reciprocal : 8 / (B : ℝ) ≤ 4 * t := by have scale := mul_le_mul_of_nonneg_left inverse_bound (by norm_num : (0 : ℝ) ≤ 8) calc 8 / (B : ℝ) = 8 * (1 / (B : ℝ)) := by ring _ ≤ 8 * (t / 2) := scale _ = 4 * t := by ring have ratio_cost : (10 + 8 * ((Q : ℝ) / (B : ℝ))) * asynchronous ≤ (34 / t) * asynchronous := by apply mul_le_mul_of_nonneg_right _ asynchronous_nonnegative have t_inverse : (1 : ℝ) ≤ 1 / t := by apply (le_div_iff₀ positive).mpr simpa using bounded have ratio_scaled := mul_le_mul_of_nonneg_left ratio_bound (by norm_num : (0 : ℝ) ≤ 8) have ten_scaled := mul_le_mul_of_nonneg_left t_inverse (by norm_num : (0 : ℝ) ≤ 10) have ten_piece : (10 : ℝ) ≤ 10 / t := by calc (10 : ℝ) = 10 * 1 := by ring _ ≤ 10 * (1 / t) := ten_scaled _ = 10 / t := by ring have ratio_piece : 8 * ((Q : ℝ) / (B : ℝ)) ≤ 24 / t := by calc 8 * ((Q : ℝ) / (B : ℝ)) ≤ 8 * (3 / t) := ratio_scaled _ = 24 / t := by ring calc 10 + 8 * ((Q : ℝ) / (B : ℝ)) ≤ 10 / t + 24 / t := add_le_add ten_piece ratio_piece _ = 34 / t := by ring have exponential_scaled := mul_le_mul_of_nonneg_left exponential_bound (by norm_num : (0 : ℝ) ≤ 16) unfold unconditionalPublicBucketLoss nlinarith theorem exists_proofUnconditionalStoppedCommonPrefixBalancedHazard {d N : ℕ} (grid : 0 < N) (dimension : 0 < d) (t : ℝ) (positive : 0 < t) (bounded : t ≤ 1) (precision : ℝ) (precision_positive : 0 < precision) : ∃ B Q n : ℕ, 0 < B ∧ 0 < Q ∧ 0 < n ∧ ∃ A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * n)) ℂ, ∀ {S L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d), dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q n width schedule ξ ζ A C ≤ (34 / t) * dSVDensityRationalHeterogeneousActualAsynchronousFlagMass N width schedule ξ ζ + 4 * precision ^ 2 + (16 * (Real.exp 1 - 1) + 4) * t := by obtain ⟨B, Q, phases, fine, _, _, _, _, balance⟩ := exists_proofUnconditionalPublicBucketBalance t positive bounded obtain ⟨n, harmonic, A, C, source⟩ := exists_proofDSVDensityRationalHeterogeneousStoppedCommonPrefixHazardBound grid dimension phases fine precision precision_positive refine ⟨B, Q, n, phases, fine, harmonic, A, C, ?_⟩ intro S L width schedule ξ ζ have actual := source width schedule ξ ζ have asynchronous_nonnegative : 0 ≤ dSVDensityRationalHeterogeneousActualAsynchronousFlagMass N width schedule ξ ζ := by exact dSVDensityRationalHeterogeneousActualAsynchronousFlagMass_nonneg N width schedule ξ ζ exact actual.trans (balance (dSVDensityRationalHeterogeneousActualAsynchronousFlagMass N width schedule ξ ζ) precision asynchronous_nonnegative) def unconditionalPrefactorBucketCoefficient : ℝ := 16 * (Real.exp 1 - 1) + 4 theorem unconditionalPrefactorBucketCoefficient_nonneg : 0 ≤ unconditionalPrefactorBucketCoefficient := by have exponential := Real.add_one_le_exp (1 : ℝ) unfold unconditionalPrefactorBucketCoefficient nlinarith theorem unconditionalPrefactor_fourthRoot_sq {a : ℝ} (nonnegative : 0 ≤ a) : (a ^ (1 / 4 : ℝ)) ^ 2 = Real.sqrt a := by calc (a ^ (1 / 4 : ℝ)) ^ 2 = a ^ ((1 / 4 : ℝ) * 2) := (Real.rpow_mul_natCast nonnegative (1 / 4 : ℝ) 2).symm _ = a ^ (1 / 2 : ℝ) := by norm_num _ = Real.sqrt a := (Real.sqrt_eq_rpow a).symm theorem unconditionalPrefactor_sixtyFour_fourthRoot_le : (64 : ℝ) ^ (1 / 4 : ℝ) ≤ 4 := by have monotone := Real.rpow_le_rpow (by norm_num : (0 : ℝ) ≤ 64) (by norm_num : (64 : ℝ) ≤ 256) (by norm_num : (0 : ℝ) ≤ (1 / 4 : ℝ)) have fourth : (256 : ℝ) ^ (1 / 4 : ℝ) = 4 := by norm_num exact monotone.trans_eq fourth theorem unconditionalPrefactor_fourthRoot_async_le {eta alpha : ℝ} (eta_nonnegative : 0 ≤ eta) (alpha_nonnegative : 0 ≤ alpha) : (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) ^ (1 / 4 : ℝ) ≤ 4 * eta ^ (1 / 8 : ℝ) + alpha ^ (1 / 12 : ℝ) := by have asynchronous_nonnegative : 0 ≤ (64 : ℝ) * Real.sqrt eta := by positivity have precision_nonnegative : 0 ≤ alpha ^ (1 / 3 : ℝ) := Real.rpow_nonneg alpha_nonnegative _ have split := Real.rpow_add_le_add_rpow asynchronous_nonnegative precision_nonnegative (by norm_num : (0 : ℝ) ≤ 1 / 4) (by norm_num : (1 / 4 : ℝ) ≤ 1) have eta_identity : (Real.sqrt eta) ^ (1 / 4 : ℝ) = eta ^ (1 / 8 : ℝ) := by rw [Real.sqrt_eq_rpow] rw [← Real.rpow_mul eta_nonnegative] norm_num have alpha_identity : (alpha ^ (1 / 3 : ℝ)) ^ (1 / 4 : ℝ) = alpha ^ (1 / 12 : ℝ) := by rw [← Real.rpow_mul alpha_nonnegative] norm_num have numerical := unconditionalPrefactor_sixtyFour_fourthRoot_le calc (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) ^ (1 / 4 : ℝ) ≤ (64 * Real.sqrt eta) ^ (1 / 4 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ (1 / 4 : ℝ) := split _ = (64 : ℝ) ^ (1 / 4 : ℝ) * eta ^ (1 / 8 : ℝ) + alpha ^ (1 / 12 : ℝ) := by rw [Real.mul_rpow (by norm_num : (0 : ℝ) ≤ 64) (Real.sqrt_nonneg eta), eta_identity, alpha_identity] _ ≤ 4 * eta ^ (1 / 8 : ℝ) + alpha ^ (1 / 12 : ℝ) := by gcongr theorem unconditionalPrefactor_fourthRoot_async_le_twelfth {eta alpha : ℝ} (eta_nonnegative : 0 ≤ eta) (eta_bounded : eta ≤ 1) (alpha_nonnegative : 0 ≤ alpha) : (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) ^ (1 / 4 : ℝ) ≤ 4 * eta ^ (1 / 12 : ℝ) + alpha ^ (1 / 12 : ℝ) := by have root_compare : eta ^ (1 / 8 : ℝ) ≤ eta ^ (1 / 12 : ℝ) := Real.rpow_le_rpow_of_exponent_ge' eta_nonnegative eta_bounded (by norm_num : (0 : ℝ) ≤ 1 / 12) (by norm_num : (1 / 12 : ℝ) ≤ 1 / 8) calc (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) ^ (1 / 4 : ℝ) ≤ 4 * eta ^ (1 / 8 : ℝ) + alpha ^ (1 / 12 : ℝ) := unconditionalPrefactor_fourthRoot_async_le eta_nonnegative alpha_nonnegative _ ≤ 4 * eta ^ (1 / 12 : ℝ) + alpha ^ (1 / 12 : ℝ) := by gcongr theorem unconditionalPrefactor_balancedHazard_sqrt_le {a rho : ℝ} (positive : 0 < a) (rho_nonnegative : 0 ≤ rho) : Real.sqrt ((34 / Real.sqrt a) * a + 4 * rho ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt a) ≤ Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) * a ^ (1 / 4 : ℝ) + 2 * rho := by have root_positive : 0 < Real.sqrt a := Real.sqrt_pos.2 positive have root_square : (Real.sqrt a) ^ 2 = a := Real.sq_sqrt positive.le have coefficient_nonnegative := unconditionalPrefactorBucketCoefficient_nonneg have coefficient_square : (Real.sqrt (34 + unconditionalPrefactorBucketCoefficient)) ^ 2 = 34 + unconditionalPrefactorBucketCoefficient := Real.sq_sqrt (by linarith) have fourth_square := unconditionalPrefactor_fourthRoot_sq positive.le have product_square : (Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) * a ^ (1 / 4 : ℝ)) ^ 2 = (34 + unconditionalPrefactorBucketCoefficient) * Real.sqrt a := by calc (Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) * a ^ (1 / 4 : ℝ)) ^ 2 = (Real.sqrt (34 + unconditionalPrefactorBucketCoefficient)) ^ 2 * (a ^ (1 / 4 : ℝ)) ^ 2 := by ring _ = (34 + unconditionalPrefactorBucketCoefficient) * Real.sqrt a := by rw [coefficient_square, fourth_square] have quotient : (34 / Real.sqrt a) * a = 34 * Real.sqrt a := by field_simp [ne_of_gt root_positive] nlinarith [root_square] apply Real.sqrt_le_iff.mpr constructor · positivity · rw [quotient] have cross_nonnegative : 0 ≤ (Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) * a ^ (1 / 4 : ℝ)) * rho := mul_nonneg (mul_nonneg (Real.sqrt_nonneg _) (Real.rpow_nonneg positive.le _)) rho_nonnegative nlinarith [product_square] theorem unconditionalPrefactor_smallHazard_twelfthRoot_le {eta alpha : ℝ} (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (small : 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) ≤ 1) : Real.sqrt ((34 / Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) ≤ (4 * Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) + 2) * (eta ^ (1 / 12 : ℝ) + alpha ^ (1 / 12 : ℝ)) := by let a : ℝ := 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) let rho : ℝ := alpha ^ (1 / 12 : ℝ) have alpha_third_positive : 0 < alpha ^ (1 / 3 : ℝ) := Real.rpow_pos_of_pos alpha_positive _ have a_positive : 0 < a := by dsimp [a] have := Real.sqrt_nonneg eta linarith have eta_root_square : (Real.sqrt eta) ^ 2 = eta := Real.sq_sqrt eta_nonnegative have eta_bounded : eta ≤ 1 := by have eta_root_bounded : Real.sqrt eta ≤ 1 := by nlinarith [Real.sqrt_nonneg eta, alpha_third_positive] nlinarith [Real.sqrt_nonneg eta] have rho_nonnegative : 0 ≤ rho := by dsimp [rho] exact Real.rpow_nonneg alpha_positive.le _ have eta_twelfth_nonnegative : 0 ≤ eta ^ (1 / 12 : ℝ) := Real.rpow_nonneg eta_nonnegative _ have quarter := unconditionalPrefactor_fourthRoot_async_le_twelfth eta_nonnegative eta_bounded alpha_positive.le have balanced := unconditionalPrefactor_balancedHazard_sqrt_le a_positive rho_nonnegative have coefficient_root_nonnegative : 0 ≤ Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) := Real.sqrt_nonneg _ change Real.sqrt ((34 / Real.sqrt a) * a + 4 * rho ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt a) ≤ (4 * Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) + 2) * (eta ^ (1 / 12 : ℝ) + rho) change a ^ (1 / 4 : ℝ) ≤ 4 * eta ^ (1 / 12 : ℝ) + rho at quarter nlinarith [mul_nonneg coefficient_root_nonnegative (sub_nonneg.mpr quarter), mul_nonneg coefficient_root_nonnegative rho_nonnegative, mul_nonneg (show 0 ≤ (2 : ℝ) by norm_num) eta_twelfth_nonnegative] theorem unconditionalPrefactor_largeVerifier_twelfthRoot_le {eta alpha : ℝ} (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (large : 1 < 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) : (2 : ℝ) ≤ 128 * (eta ^ (1 / 12 : ℝ) + alpha ^ (1 / 12 : ℝ)) := by have eta_root_nonnegative : 0 ≤ eta ^ (1 / 12 : ℝ) := Real.rpow_nonneg eta_nonnegative _ have alpha_root_nonnegative : 0 ≤ alpha ^ (1 / 12 : ℝ) := Real.rpow_nonneg alpha_positive.le _ by_cases eta_bounded : eta ≤ 1 · have eta_root_compare : Real.sqrt eta ≤ eta ^ (1 / 12 : ℝ) := by rw [Real.sqrt_eq_rpow] exact Real.rpow_le_rpow_of_exponent_ge' eta_nonnegative eta_bounded (by norm_num : (0 : ℝ) ≤ 1 / 12) (by norm_num : (1 / 12 : ℝ) ≤ 1 / 2) have alpha_root_compare : alpha ^ (1 / 3 : ℝ) ≤ alpha ^ (1 / 12 : ℝ) := Real.rpow_le_rpow_of_exponent_ge' alpha_positive.le alpha_bounded (by norm_num : (0 : ℝ) ≤ 1 / 12) (by norm_num : (1 / 12 : ℝ) ≤ 1 / 3) nlinarith · have eta_large : 1 ≤ eta := (lt_of_not_ge eta_bounded).le have eta_root_large : 1 ≤ eta ^ (1 / 12 : ℝ) := Real.one_le_rpow eta_large (by norm_num : (0 : ℝ) ≤ 1 / 12) nlinarith end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalExactSourceScalarClipping (d : ℕ) (dimension : 0 < d) (alpha : ℝ) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) : ∃ (w : ℝ) (N : ℕ), 1 ≤ w ∧ 0 < N ∧ 2 * (w + 1) * ((d : ℝ) / N) ≤ alpha ^ (1 / 3 : ℝ) ∧ (1 / w + (d : ℝ) * w / (N : ℝ) ≤ 3 * alpha ^ (1 / 3 : ℝ) / 2) ∧ (∀ ξ : BipartiteUnitVector d, ‖ξ.val - dSVDensityRationalCanonicalAcceptedTarget w N ξ‖ ^ 2 ≤ 3 * alpha ^ (1 / 3 : ℝ) / 2) ∧ (∀ ξ ζ : BipartiteUnitVector d, dSVDensityRationalLeftProjectiveThresholdAtomMismatch w N ξ ζ / dSVDensityRationalLeftProjectiveDiagonalMass w N ξ ≤ 8 * Real.sqrt 2 * ‖ξ.val - ζ.val‖ + alpha ^ (1 / 3 : ℝ)) := by have precision : 0 < alpha ^ (1 / 3 : ℝ) := Real.rpow_pos_of_pos alpha_positive _ have small : alpha ^ (1 / 3 : ℝ) ≤ 1 := Real.rpow_le_one alpha_positive.le alpha_bounded (by norm_num) obtain ⟨w, N, width, grid, fine, rounding, _diagonal, mismatch⟩ := dSVDensityRationalLargeWidth_exists_sourceUniformParameters d dimension (alpha ^ (1 / 3 : ℝ)) precision small have scalar : 1 / w + (d : ℝ) * w / (N : ℝ) ≤ 3 * alpha ^ (1 / 3 : ℝ) / 2 := by calc 1 / w + (d : ℝ) * w / (N : ℝ) = 1 / w + w * ((d : ℝ) / N) := by ring _ ≤ 3 * alpha ^ (1 / 3 : ℝ) / 2 := rounding refine ⟨w, N, width, grid, fine, scalar, ?_, mismatch⟩ intro ξ exact (dSVDensityRationalCanonicalAcceptedTarget_distance_sq_le (by linarith) grid ξ).trans scalar end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalSampling open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactLocalQuestionHistoryEquiv {n : ℕ} (D : Finset (Fin n)) : (LocalQuestionContext X Y D × ExactHistoryFlag X Y A B D) ≃ ExactLocallySampleableTuple X Y A B D where toFun t := (t.1.1, t.1.2.1, t.1.2.2, t.2) invFun t := ((t.1, t.2.1, t.2.2.1), t.2.2.2) left_inv t := by rcases t with ⟨⟨i, x, y⟩, r⟩ rfl right_inv t := by rcases t with ⟨i, x, y, r⟩ rfl def exactLocallySampleableJARounded (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (t : ExactLocallySampleableTuple X Y A B D) : ℝ := G.questionWeight t.2.1 t.2.2.1 * ((numerator (.inl (t.1, t.2.1)) t.2.2.2 : ℝ) / denominator) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) def exactLocallySampleableJBRounded (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (t : ExactLocallySampleableTuple X Y A B D) : ℝ := G.questionWeight t.2.1 t.2.2.1 * ((numerator (.inr (t.1, t.2.2.1)) t.2.2.2 : ℝ) / denominator) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) theorem exactLocallySampleableJA_weightedConditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : (exactLocallySampleableJA G n S D base ∘ exactLocalQuestionHistoryEquiv D) = weightedConditionalJoint (localQuestionWeight G n D) (fun c r => exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) c.1 c.2.1 r) := by funext t rcases t with ⟨⟨i, x, y⟩, r⟩ change G.questionWeight x y * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = (G.questionWeight x y / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r ring theorem exactLocallySampleableJB_weightedConditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) : (exactLocallySampleableJB G n S D base ∘ exactLocalQuestionHistoryEquiv D) = weightedConditionalJoint (localQuestionWeight G n D) (fun c r => exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) c.1 c.2.2 r) := by funext t rcases t with ⟨⟨i, x, y⟩, r⟩ change G.questionWeight x y * exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = (G.questionWeight x y / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r ring theorem exactLocallySampleableJARounded_weightedConditional (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) : (exactLocallySampleableJARounded G n D denominator numerator ∘ exactLocalQuestionHistoryEquiv D) = weightedConditionalJoint (localQuestionWeight G n D) (fun c r => (numerator (.inl (c.1, c.2.1)) r : ℝ) / denominator) := by funext t rcases t with ⟨⟨i, x, y⟩, r⟩ change G.questionWeight x y * ((numerator (.inl (i, x)) r : ℝ) / denominator) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = (G.questionWeight x y / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * ((numerator (.inl (i, x)) r : ℝ) / denominator) ring theorem exactLocallySampleableJBRounded_weightedConditional (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) : (exactLocallySampleableJBRounded G n D denominator numerator ∘ exactLocalQuestionHistoryEquiv D) = weightedConditionalJoint (localQuestionWeight G n D) (fun c r => (numerator (.inr (c.1, c.2.2)) r : ℝ) / denominator) := by funext t rcases t with ⟨⟨i, x, y⟩, r⟩ change G.questionWeight x y * ((numerator (.inr (i, y)) r : ℝ) / denominator) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = (G.questionWeight x y / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * ((numerator (.inr (i, y)) r : ℝ) / denominator) ring theorem exactLocallySampleableJA_rounded_totalVariation_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) {gamma : ℝ} (approximation : ∀ k, finiteTotalVariation (exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) k) (fun r => (numerator k r : ℝ) / denominator) < gamma) : finiteTotalVariation (exactLocallySampleableJA G n S D base) (exactLocallySampleableJARounded G n D denominator numerator) ≤ gamma := by calc finiteTotalVariation (exactLocallySampleableJA G n S D base) (exactLocallySampleableJARounded G n D denominator numerator) = finiteTotalVariation (exactLocallySampleableJA G n S D base ∘ exactLocalQuestionHistoryEquiv D) (exactLocallySampleableJARounded G n D denominator numerator ∘ exactLocalQuestionHistoryEquiv D) := (finiteTotalVariation_equiv (exactLocalQuestionHistoryEquiv D) (exactLocallySampleableJA G n S D base) (exactLocallySampleableJARounded G n D denominator numerator)).symm _ = ∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * finiteTotalVariation (fun r => exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) c.1 c.2.1 r) (fun r => (numerator (.inl (c.1, c.2.1)) r : ℝ) / denominator) := by rw [exactLocallySampleableJA_weightedConditional, exactLocallySampleableJARounded_weightedConditional, weightedConditionalJoint_totalVariation (localQuestionWeight G n D) (localQuestionWeight_nonneg G n D)] _ ≤ ∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * gamma := by apply Finset.sum_le_sum intro c _ apply mul_le_mul_of_nonneg_left _ (localQuestionWeight_nonneg G n D c) exact (approximation (.inl (c.1, c.2.1))).le _ = gamma := by rw [← Finset.sum_mul, localQuestionWeight_sum G n D remaining] ring theorem exactLocallySampleableJB_rounded_totalVariation_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) {gamma : ℝ} (approximation : ∀ k, finiteTotalVariation (exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) k) (fun r => (numerator k r : ℝ) / denominator) < gamma) : finiteTotalVariation (exactLocallySampleableJB G n S D base) (exactLocallySampleableJBRounded G n D denominator numerator) ≤ gamma := by calc finiteTotalVariation (exactLocallySampleableJB G n S D base) (exactLocallySampleableJBRounded G n D denominator numerator) = finiteTotalVariation (exactLocallySampleableJB G n S D base ∘ exactLocalQuestionHistoryEquiv D) (exactLocallySampleableJBRounded G n D denominator numerator ∘ exactLocalQuestionHistoryEquiv D) := (finiteTotalVariation_equiv (exactLocalQuestionHistoryEquiv D) (exactLocallySampleableJB G n S D base) (exactLocallySampleableJBRounded G n D denominator numerator)).symm _ = ∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * finiteTotalVariation (fun r => exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) c.1 c.2.2 r) (fun r => (numerator (.inr (c.1, c.2.2)) r : ℝ) / denominator) := by rw [exactLocallySampleableJB_weightedConditional, exactLocallySampleableJBRounded_weightedConditional, weightedConditionalJoint_totalVariation (localQuestionWeight G n D) (localQuestionWeight_nonneg G n D)] _ ≤ ∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * gamma := by apply Finset.sum_le_sum intro c _ apply mul_le_mul_of_nonneg_left _ (localQuestionWeight_nonneg G n D c) exact (approximation (.inr (c.1, c.2.2))).le _ = gamma := by rw [← Finset.sum_mul, localQuestionWeight_sum G n D remaining] ring theorem exactLocallySampleableRounded_pair_totalVariation (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) : finiteTotalVariation (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableJBRounded G n D denominator numerator) = ∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * finiteTotalVariation (fun r => (numerator (.inl (c.1, c.2.1)) r : ℝ) / denominator) (fun r => (numerator (.inr (c.1, c.2.2)) r : ℝ) / denominator) := by calc finiteTotalVariation (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableJBRounded G n D denominator numerator) = finiteTotalVariation (exactLocallySampleableJARounded G n D denominator numerator ∘ exactLocalQuestionHistoryEquiv D) (exactLocallySampleableJBRounded G n D denominator numerator ∘ exactLocalQuestionHistoryEquiv D) := (finiteTotalVariation_equiv (exactLocalQuestionHistoryEquiv D) (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableJBRounded G n D denominator numerator)).symm _ = _ := by rw [exactLocallySampleableJARounded_weightedConditional, exactLocallySampleableJBRounded_weightedConditional, weightedConditionalJoint_totalVariation (localQuestionWeight G n D) (localQuestionWeight_nonneg G n D)] def exactLocallySampleablePermutationMismatch (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) : ℝ := ∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * uniformPermutationProbability (fun permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator) => rationalPermutationOutput denominator (numerator (.inl (c.1, c.2.1))) (nonempty (.inl (c.1, c.2.1))) permutation ≠ rationalPermutationOutput denominator (numerator (.inr (c.1, c.2.2))) (nonempty (.inr (c.1, c.2.2))) permutation) theorem exactLocallySampleablePermutationMismatch_le_two_tv (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (positive : 0 < denominator) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (normalized : ∀ k, (∑ r, numerator k r) = denominator) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) : exactLocallySampleablePermutationMismatch G n D denominator numerator nonempty ≤ 2 * finiteTotalVariation (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableJBRounded G n D denominator numerator) := by unfold exactLocallySampleablePermutationMismatch calc (∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * uniformPermutationProbability (fun permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator) => rationalPermutationOutput denominator (numerator (.inl (c.1, c.2.1))) (nonempty (.inl (c.1, c.2.1))) permutation ≠ rationalPermutationOutput denominator (numerator (.inr (c.1, c.2.2))) (nonempty (.inr (c.1, c.2.2))) permutation)) ≤ ∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * (2 * finiteTotalVariation (fun r => (numerator (.inl (c.1, c.2.1)) r : ℝ) / denominator) (fun r => (numerator (.inr (c.1, c.2.2)) r : ℝ) / denominator)) := by apply Finset.sum_le_sum intro c _ apply mul_le_mul_of_nonneg_left _ (localQuestionWeight_nonneg G n D c) exact rationalPermutationOutput_disagreement_le_two_mul_finiteTotalVariation denominator positive (numerator (.inl (c.1, c.2.1))) (numerator (.inr (c.1, c.2.2))) (normalized (.inl (c.1, c.2.1))) (normalized (.inr (c.1, c.2.2))) (nonempty (.inl (c.1, c.2.1))) (nonempty (.inr (c.1, c.2.2))) _ = 2 * (∑ c : LocalQuestionContext X Y D, localQuestionWeight G n D c * finiteTotalVariation (fun r => (numerator (.inl (c.1, c.2.1)) r : ℝ) / denominator) (fun r => (numerator (.inr (c.1, c.2.2)) r : ℝ) / denominator)) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro c _ ring _ = 2 * finiteTotalVariation (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableJBRounded G n D denominator numerator) := by rw [exactLocallySampleableRounded_pair_totalVariation] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1500000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalSampling open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactSourceSharedFlag (X Y A B : Type) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) (denominator : ℕ) := SourceRemainingCoordinate D × Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator) def exactSourceSharedFlagWeight {n : ℕ} (D : Finset (Fin n)) (denominator : ℕ) (_ : ExactSourceSharedFlag X Y A B D denominator) : ℝ := (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (1 / (Fintype.card (Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator)) : ℝ)) theorem exactSourceSharedFlagWeight_nonneg {n : ℕ} (D : Finset (Fin n)) (denominator : ℕ) (j : ExactSourceSharedFlag X Y A B D denominator) : 0 ≤ exactSourceSharedFlagWeight D denominator j := by unfold exactSourceSharedFlagWeight positivity theorem exactSourceSharedFlagWeight_sum {n : ℕ} (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (denominator : ℕ) : (∑ j : ExactSourceSharedFlag X Y A B D denominator, exactSourceSharedFlagWeight D denominator j) = 1 := by classical have coordinate_nonzero : (Fintype.card (SourceRemainingCoordinate D) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (exactRemainingCoordinate_card_pos D remaining)) have permutation_nonzero : (Fintype.card (Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator)) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (Fintype.card_pos_iff.mpr ⟨Equiv.refl (ExactHistoryFlag X Y A B D × Fin denominator)⟩)) rw [Fintype.sum_prod_type] simp only [exactSourceSharedFlagWeight, Finset.sum_const, Finset.card_univ, nsmul_eq_mul] field_simp def exactSourceAlicePermutationHistory {n : ℕ} (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) (j : ExactSourceSharedFlag X Y A B D denominator) (x : X) : ExactHistoryFlag X Y A B D := rationalPermutationOutput denominator (numerator (.inl (j.1, x))) (nonempty (.inl (j.1, x))) j.2 def exactSourceBobPermutationHistory {n : ℕ} (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) (j : ExactSourceSharedFlag X Y A B D denominator) (y : Y) : ExactHistoryFlag X Y A B D := rationalPermutationOutput denominator (numerator (.inr (j.1, y))) (nonempty (.inr (j.1, y))) j.2 def exactSourcePermutationMatched {n : ℕ} (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) (ω : ExactSourceSharedFlag X Y A B D denominator × (X × Y)) : Bool := by classical exact decide (exactSourceAlicePermutationHistory D denominator numerator nonempty ω.1 ω.2.1 = exactSourceBobPermutationHistory D denominator numerator nonempty ω.1 ω.2.2) theorem exactUniformPermutationProbability_eq_indicator_sum {ι : Type*} [Fintype ι] [DecidableEq ι] (event : Equiv.Perm ι → Prop) : uniformPermutationProbability event = (∑ permutation : Equiv.Perm ι, if event permutation then (1 : ℝ) else 0) / (Fintype.card (Equiv.Perm ι) : ℝ) := by classical unfold uniformPermutationProbability congr 1 exact (Finset.sum_boole (R := ℝ) event (Finset.univ : Finset (Equiv.Perm ι))).symm theorem exactSourceSharedFlag_mismatch_eq (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) : (∑ ω : ExactSourceSharedFlag X Y A B D denominator × (X × Y), flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator) ω * if exactSourcePermutationMatched D denominator numerator nonempty ω then 0 else 1) = exactLocallySampleablePermutationMismatch G n D denominator numerator nonempty := by classical have point (i : SourceRemainingCoordinate D) (x : X) (y : Y) : (∑ permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator), ((1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (1 / (Fintype.card (Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator)) : ℝ))) * G.questionWeight x y * if rationalPermutationOutput denominator (numerator (.inl (i, x))) (nonempty (.inl (i, x))) permutation = rationalPermutationOutput denominator (numerator (.inr (i, y))) (nonempty (.inr (i, y))) permutation then 0 else 1) = (G.questionWeight x y / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * uniformPermutationProbability (fun permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator) => rationalPermutationOutput denominator (numerator (.inl (i, x))) (nonempty (.inl (i, x))) permutation ≠ rationalPermutationOutput denominator (numerator (.inr (i, y))) (nonempty (.inr (i, y))) permutation) := by have probability := exactUniformPermutationProbability_eq_indicator_sum (ι := ExactHistoryFlag X Y A B D × Fin denominator) (fun permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator) => rationalPermutationOutput denominator (numerator (.inl (i, x))) (nonempty (.inl (i, x))) permutation ≠ rationalPermutationOutput denominator (numerator (.inr (i, y))) (nonempty (.inr (i, y))) permutation) rw [probability, Finset.sum_div, Finset.mul_sum] apply Finset.sum_congr rfl intro permutation _ by_cases matched : rationalPermutationOutput denominator (numerator (.inl (i, x))) (nonempty (.inl (i, x))) permutation = rationalPermutationOutput denominator (numerator (.inr (i, y))) (nonempty (.inr (i, y))) permutation · simp [matched] · simp [matched] ring unfold exactLocallySampleablePermutationMismatch simp only [flaggedQuestionWeight, exactSourceSharedFlagWeight, localQuestionWeight, exactSourcePermutationMatched, exactSourceAlicePermutationHistory, exactSourceBobPermutationHistory, Fintype.sum_prod_type, decide_eq_true_eq] apply Finset.sum_congr rfl intro i _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro x _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro y _ exact point i x y theorem exactSourceSharedFlag_mismatch_le (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) {lam : ℝ} (mismatch : exactLocallySampleablePermutationMismatch G n D denominator numerator nonempty ≤ 4 * lam) : (∑ ω : ExactSourceSharedFlag X Y A B D denominator × (X × Y), flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator) ω * if exactSourcePermutationMatched D denominator numerator nonempty ω then 0 else 1) ≤ 4 * lam := by rw [exactSourceSharedFlag_mismatch_eq G n D denominator numerator nonempty] exact mismatch end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem reweightedSeed_reverse_source_prefix_information_budget {K V : Type*} [Fintype K] [Fintype V] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (seedLaw : Finset (SourceRemainingCoordinate D) → FiniteEventLaw K) (Ω : Finset (SourceRemainingCoordinate D) → Type*) [∀ side, Fintype (Ω side)] (projection : ∀ side : Finset (SourceRemainingCoordinate D), K × ExactOutcome X Y A B n → Ω side × (Fin side.card → V)) (default : V) : (∑ side : Finset (SourceRemainingCoordinate D), reversePartitionWeight side * ((∑ k : Fin side.card, reweightedSeedPrefixEntropyIncrement (seedLaw side) G n S D (projection side) default k) / (side.card : ℝ))) ≤ 2 * (postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D) / ((Finset.univ \ D).card : ℝ) := by have nonnegative_cost : 0 ≤ postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D := by have hempty := reweightedSeed_source_equation_twenty_six (seedLaw ∅) G n S D positive (projection ∅) default simpa using hempty exact exactRemainingReverse_relativeEntropy_budget D remaining (fun side k => reweightedSeedPrefixEntropyIncrement (seedLaw side) G n S D (projection side) default k) nonnegative_cost (fun side => reweightedSeed_source_equation_twenty_six (seedLaw side) G n S D positive (projection side) default) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable def finiteIndependentProductWeight {ι V : Type*} [Fintype ι] [Fintype V] (q : ι → V → ℝ) (x : ι → V) : ℝ := ∏ i : ι, q i (x i) def finiteCoordinateMarginal {ι V : Type*} [Fintype ι] [Fintype V] (p : (ι → V) → ℝ) (i : ι) : V → ℝ := by classical exact groupedMass (fun x : ι → V => x i) p theorem finiteIndependentProductWeight_nonneg {ι V : Type*} [Fintype ι] [Fintype V] (q : ι → V → ℝ) (hq : ∀ i v, 0 ≤ q i v) (x : ι → V) : 0 ≤ finiteIndependentProductWeight q x := by classical unfold finiteIndependentProductWeight exact Finset.prod_nonneg fun i _ => hq i (x i) theorem finiteIndependentProductWeight_sum {ι V : Type*} [Fintype ι] [Fintype V] (q : ι → V → ℝ) (hq : ∀ i, (∑ v : V, q i v) = 1) : (∑ x : ι → V, finiteIndependentProductWeight q x) = 1 := by classical unfold finiteIndependentProductWeight calc (∑ x : ι → V, ∏ i : ι, q i (x i)) = ∏ i : ι, ∑ v : V, q i v := (Fintype.prod_sum (fun i : ι => fun v : V => q i v)).symm _ = 1 := by simp [hq] theorem finiteCoordinateMarginal_nonneg {ι V : Type*} [Fintype ι] [Fintype V] (p : (ι → V) → ℝ) (hp : ∀ x, 0 ≤ p x) (i : ι) (v : V) : 0 ≤ finiteCoordinateMarginal p i v := by classical unfold finiteCoordinateMarginal exact groupedMass_nonneg (fun x : ι → V => x i) p hp v theorem finiteCoordinateMarginal_sum {ι V : Type*} [Fintype ι] [Fintype V] (p : (ι → V) → ℝ) (i : ι) : (∑ v : V, finiteCoordinateMarginal p i v) = ∑ x : ι → V, p x := by classical unfold finiteCoordinateMarginal exact groupedMass_sum (fun x : ι → V => x i) p theorem finiteJoint_le_coordinateMarginal {ι V : Type*} [Fintype ι] [Fintype V] (p : (ι → V) → ℝ) (hp : ∀ x, 0 ≤ p x) (x : ι → V) (i : ι) : p x ≤ finiteCoordinateMarginal p i (x i) := by classical unfold finiteCoordinateMarginal groupedMass exact Finset.single_le_sum (fun a _ => hp a) (by simp) theorem finiteCoordinateMarginal_absolute_continuity {ι V : Type*} [Fintype ι] [Fintype V] (p : (ι → V) → ℝ) (q : ι → V → ℝ) (hac : ∀ x, finiteIndependentProductWeight q x = 0 → p x = 0) (i : ι) (v : V) : q i v = 0 → finiteCoordinateMarginal p i v = 0 := by classical intro hz unfold finiteCoordinateMarginal groupedMass apply Finset.sum_eq_zero intro x hx have hxi : x i = v := (Finset.mem_filter.mp hx).2 apply hac x unfold finiteIndependentProductWeight apply Finset.prod_eq_zero (Finset.mem_univ i) simpa [hxi] using hz theorem finiteJoint_absolute_continuous_product_marginals {ι V : Type*} [Fintype ι] [Fintype V] (p : (ι → V) → ℝ) (hp : ∀ x, 0 ≤ p x) (x : ι → V) : finiteIndependentProductWeight (finiteCoordinateMarginal p) x = 0 → p x = 0 := by classical intro hz by_contra hpx have hpositive : 0 < p x := lt_of_le_of_ne (hp x) (Ne.symm hpx) have hmarginal (i : ι) : 0 < finiteCoordinateMarginal p i (x i) := lt_of_lt_of_le hpositive (finiteJoint_le_coordinateMarginal p hp x i) have hproduct : 0 < finiteIndependentProductWeight (finiteCoordinateMarginal p) x := by unfold finiteIndependentProductWeight exact Finset.prod_pos fun i _ => hmarginal i exact hproduct.ne' hz theorem finiteCoordinateMarginal_sum_mul {ι V : Type*} [Fintype ι] [Fintype V] (p : (ι → V) → ℝ) (i : ι) (f : V → ℝ) : (∑ x : ι → V, p x * f (x i)) = ∑ v : V, finiteCoordinateMarginal p i v * f v := by classical calc (∑ x : ι → V, p x * f (x i)) = ∑ v : V, groupedMass (fun x : ι → V => x i) (fun x => p x * f (x i)) v := by symm exact groupedMass_sum (fun x : ι → V => x i) (fun x => p x * f (x i)) _ = ∑ v : V, finiteCoordinateMarginal p i v * f v := by apply Finset.sum_congr rfl intro v _ unfold finiteCoordinateMarginal groupedMass rw [Finset.sum_mul] apply Finset.sum_congr rfl intro x hx have hxi : x i = v := (Finset.mem_filter.mp hx).2 simp [hxi] theorem finiteProductMarginal_relativeEntropy_le {ι V : Type*} [Fintype ι] [Fintype V] (p : (ι → V) → ℝ) (q : ι → V → ℝ) (hp : ∀ x, 0 ≤ p x) (hp_normalized : (∑ x : ι → V, p x) = 1) (hq : ∀ i v, 0 ≤ q i v) (hq_normalized : ∀ i, (∑ v : V, q i v) = 1) (absolute_continuity : ∀ x, finiteIndependentProductWeight q x = 0 → p x = 0) : (∑ i : ι, finiteRelativeEntropy (finiteCoordinateMarginal p i) (q i)) ≤ finiteRelativeEntropy p (finiteIndependentProductWeight q) := by classical let marginal : ι → V → ℝ := finiteCoordinateMarginal p have hm_nonnegative (i : ι) (v : V) : 0 ≤ marginal i v := finiteCoordinateMarginal_nonneg p hp i v have hm_normalized (i : ι) : (∑ v : V, marginal i v) = 1 := by change (∑ v : V, finiteCoordinateMarginal p i v) = 1 rw [finiteCoordinateMarginal_sum, hp_normalized] have hm_absolute (x : ι → V) : finiteIndependentProductWeight marginal x = 0 → p x = 0 := finiteJoint_absolute_continuous_product_marginals p hp x have hq_absolute (i : ι) (v : V) : q i v = 0 → marginal i v = 0 := finiteCoordinateMarginal_absolute_continuity p q absolute_continuity i v have hpoint (x : ι → V) : p x * Real.log (p x / finiteIndependentProductWeight q x) = p x * Real.log (p x / finiteIndependentProductWeight marginal x) + ∑ i : ι, p x * Real.log (marginal i (x i) / q i (x i)) := by by_cases hpx : p x = 0 · simp [hpx] · have hp_positive : 0 < p x := lt_of_le_of_ne (hp x) (Ne.symm hpx) have hq_product : finiteIndependentProductWeight q x ≠ 0 := by intro hz exact hpx (absolute_continuity x hz) have hm_product : finiteIndependentProductWeight marginal x ≠ 0 := by intro hz exact hpx (hm_absolute x hz) have hq_factor (i : ι) : q i (x i) ≠ 0 := by intro hz apply hq_product unfold finiteIndependentProductWeight exact Finset.prod_eq_zero (Finset.mem_univ i) hz have hm_factor (i : ι) : marginal i (x i) ≠ 0 := by have hm_positive : 0 < marginal i (x i) := lt_of_lt_of_le hp_positive (finiteJoint_le_coordinateMarginal p hp x i) exact hm_positive.ne' have hlogq : Real.log (finiteIndependentProductWeight q x) = ∑ i : ι, Real.log (q i (x i)) := by unfold finiteIndependentProductWeight exact Real.log_prod (fun i _ => hq_factor i) have hlogm : Real.log (finiteIndependentProductWeight marginal x) = ∑ i : ι, Real.log (marginal i (x i)) := by unfold finiteIndependentProductWeight exact Real.log_prod (fun i _ => hm_factor i) rw [Real.log_div hpx hq_product, Real.log_div hpx hm_product, hlogq, hlogm] simp_rw [Real.log_div (hm_factor _) (hq_factor _)] rw [← Finset.mul_sum, Finset.sum_sub_distrib] ring have hidentity : finiteRelativeEntropy p (finiteIndependentProductWeight q) = finiteRelativeEntropy p (finiteIndependentProductWeight marginal) + ∑ i : ι, finiteRelativeEntropy (marginal i) (q i) := by rw [finiteRelativeEntropy_eq_log_sum_of_absolute_continuity p (finiteIndependentProductWeight q) (finiteIndependentProductWeight_nonneg q hq) absolute_continuity hp_normalized (finiteIndependentProductWeight_sum q hq_normalized)] rw [finiteRelativeEntropy_eq_log_sum_of_absolute_continuity p (finiteIndependentProductWeight marginal) (finiteIndependentProductWeight_nonneg marginal hm_nonnegative) hm_absolute hp_normalized (finiteIndependentProductWeight_sum marginal hm_normalized)] simp_rw [finiteRelativeEntropy_eq_log_sum_of_absolute_continuity (marginal _) (q _) (hq _) (hq_absolute _) (hm_normalized _) (hq_normalized _)] calc (∑ x : ι → V, p x * Real.log (p x / finiteIndependentProductWeight q x)) = ∑ x : ι → V, (p x * Real.log (p x / finiteIndependentProductWeight marginal x) + ∑ i : ι, p x * Real.log (marginal i (x i) / q i (x i))) := by apply Finset.sum_congr rfl intro x _ exact hpoint x _ = (∑ x : ι → V, p x * Real.log (p x / finiteIndependentProductWeight marginal x)) + ∑ i : ι, ∑ x : ι → V, p x * Real.log (marginal i (x i) / q i (x i)) := by rw [Finset.sum_add_distrib, Finset.sum_comm] _ = (∑ x : ι → V, p x * Real.log (p x / finiteIndependentProductWeight marginal x)) + ∑ i : ι, ∑ v : V, marginal i v * Real.log (marginal i v / q i v) := by congr 1 apply Finset.sum_congr rfl intro i _ exact finiteCoordinateMarginal_sum_mul p i (fun v => Real.log (marginal i v / q i v)) rw [hidentity] have hnonnegative : 0 ≤ finiteRelativeEntropy p (finiteIndependentProductWeight marginal) := finiteRelativeEntropy_nonneg p (finiteIndependentProductWeight marginal) hp (finiteIndependentProductWeight_nonneg marginal hm_nonnegative) change (∑ i : ι, finiteRelativeEntropy (marginal i) (q i)) ≤ _ linarith end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactIndependentCoordinateQuestion_marginal {M Ω V : Type*} [Fintype M] [DecidableEq M] [Fintype Ω] [Fintype V] (outcome : Ω → ℝ) (question : Ω → M → V) (i : M) (v : V) : groupedMass (fun t : ExactForwardSeed M × Ω => (t.1.coordinate, question t.2 t.1.coordinate)) (fun t : ExactForwardSeed M × Ω => exactSeedWeight t.1 * outcome t.2) (i, v) = (1 / (Fintype.card M : ℝ)) * groupedMass (fun ω : Ω => question ω i) outcome v := by classical let coordinateMass := groupedMass (fun ω : Ω => question ω i) outcome v have hinner (seed : ExactForwardSeed M) : (∑ ω : Ω, if (seed.coordinate, question ω seed.coordinate) = (i, v) then exactSeedWeight seed * outcome ω else 0) = if seed.coordinate = i then exactSeedWeight seed * coordinateMass else 0 := by by_cases hc : seed.coordinate = i · subst i simp only [Prod.mk.injEq, true_and, ↓reduceIte] dsimp [coordinateMass] unfold groupedMass rw [Finset.sum_filter] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro ω _ split_ifs <;> simp_all · simp [hc] unfold groupedMass rw [Finset.sum_filter, Fintype.sum_prod_type] simp_rw [hinner] calc (∑ seed : ExactForwardSeed M, if seed.coordinate = i then exactSeedWeight seed * coordinateMass else 0) = (∑ seed : ExactForwardSeed M, if seed.coordinate = i then exactSeedWeight seed else 0) * coordinateMass := by rw [Finset.sum_mul] apply Finset.sum_congr rfl intro seed _ split_ifs <;> simp _ = (1 / (Fintype.card M : ℝ)) * coordinateMass := by rw [exactSeedWeight_coordinate_marginal i] theorem strategyAliceQuestionPrior_marginal (G : Game X Y A B) (S : Strategy G) (x : X) : groupedMass (fun ω : StrategyOutcome X Y A B => ω.1) (strategyEventLaw G S).weight x = G.marginalX x := by classical unfold groupedMass rw [Finset.sum_filter] simp only [Fintype.sum_prod_type] change (∑ x' : X, ∑ y : Y, ∑ a : A, ∑ b : B, if x' = x then G.questionWeight x' y * S.outcomeProbability x' y a b else 0) = G.marginalX x simp only [Finset.sum_ite_irrel, Finset.sum_const_zero, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] unfold Game.marginalX apply Finset.sum_congr rfl intro y _ simp_rw [← Finset.mul_sum] rw [S.outcomeProbability_normalized x y] ring theorem strategyBobQuestionPrior_marginal (G : Game X Y A B) (S : Strategy G) (y : Y) : groupedMass (fun ω : StrategyOutcome X Y A B => ω.2.1) (strategyEventLaw G S).weight y = G.marginalY y := by classical unfold groupedMass rw [Finset.sum_filter] simp only [Fintype.sum_prod_type] change (∑ x : X, ∑ y' : Y, ∑ a : A, ∑ b : B, if y' = y then G.questionWeight x y' * S.outcomeProbability x y' a b else 0) = G.marginalY y simp only [Finset.sum_ite_irrel, Finset.sum_const_zero, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] unfold Game.marginalY apply Finset.sum_congr rfl intro x _ simp_rw [← Finset.mul_sum] rw [S.outcomeProbability_normalized x y] ring theorem repeatedAliceQuestionPrior_product (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (xs : Fin n → X) : groupedMass (fun ω : ExactOutcome X Y A B n => ω.1) (strategyEventLaw (G.repeat n) S).weight xs = finiteIndependentProductWeight (fun _ : Fin n => G.marginalX) xs := by classical calc groupedMass (fun ω : ExactOutcome X Y A B n => ω.1) (strategyEventLaw (G.repeat n) S).weight xs = (G.repeat n).marginalX xs := by calc groupedMass (fun ω : ExactOutcome X Y A B n => ω.1) (strategyEventLaw (G.repeat n) S).weight xs = @groupedMass (ExactOutcome X Y A B n) inferInstance (Fin n → X) (fun a b => Classical.propDecidable (a = b)) (fun ω : ExactOutcome X Y A B n => ω.1) (strategyEventLaw (G.repeat n) S).weight xs := by exact congrFun (exactGroupedMass_decidableEq_irrel _ _ (fun ω : ExactOutcome X Y A B n => ω.1) (strategyEventLaw (G.repeat n) S).weight) xs _ = (G.repeat n).marginalX xs := strategyAliceQuestionPrior_marginal (G.repeat n) S xs _ = finiteIndependentProductWeight (fun _ : Fin n => G.marginalX) xs := by unfold Game.marginalX finiteIndependentProductWeight simp only [Game.repeat_questionWeight] exact (Fintype.prod_sum (fun i : Fin n => fun y : Y => G.questionWeight (xs i) y)).symm theorem repeatedBobQuestionPrior_product (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (ys : Fin n → Y) : groupedMass (fun ω : ExactOutcome X Y A B n => ω.2.1) (strategyEventLaw (G.repeat n) S).weight ys = finiteIndependentProductWeight (fun _ : Fin n => G.marginalY) ys := by classical calc groupedMass (fun ω : ExactOutcome X Y A B n => ω.2.1) (strategyEventLaw (G.repeat n) S).weight ys = (G.repeat n).marginalY ys := by calc groupedMass (fun ω : ExactOutcome X Y A B n => ω.2.1) (strategyEventLaw (G.repeat n) S).weight ys = @groupedMass (ExactOutcome X Y A B n) inferInstance (Fin n → Y) (fun a b => Classical.propDecidable (a = b)) (fun ω : ExactOutcome X Y A B n => ω.2.1) (strategyEventLaw (G.repeat n) S).weight ys := by exact congrFun (exactGroupedMass_decidableEq_irrel _ _ (fun ω : ExactOutcome X Y A B n => ω.2.1) (strategyEventLaw (G.repeat n) S).weight) ys _ = (G.repeat n).marginalY ys := strategyBobQuestionPrior_marginal (G.repeat n) S ys _ = finiteIndependentProductWeight (fun _ : Fin n => G.marginalY) ys := by unfold Game.marginalY finiteIndependentProductWeight simp only [Game.repeat_questionWeight] exact (Fintype.prod_sum (fun i : Fin n => fun x : X => G.questionWeight x (ys i))).symm def repeatedAlicePostselectedQuestionLaw (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (Fin n → X) → ℝ := by classical exact groupedMass (fun ω : ExactOutcome X Y A B n => ω.1) (repeatedConditionedOutcomeLaw G n S D) def repeatedBobPostselectedQuestionLaw (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (Fin n → Y) → ℝ := by classical exact groupedMass (fun ω : ExactOutcome X Y A B n => ω.2.1) (repeatedConditionedOutcomeLaw G n S D) theorem exactGroupedMass_equiv {Ω K V : Type*} [Fintype Ω] [Fintype K] [Fintype V] (equiv : Ω ≃ K) (projection : Ω → V) (mass : Ω → ℝ) (v : V) : groupedMass (fun k : K => projection (equiv.symm k)) (fun k : K => mass (equiv.symm k)) v = groupedMass projection mass v := by classical unfold groupedMass rw [Finset.sum_filter, Finset.sum_filter] exact equiv.symm.sum_comp (fun ω : Ω => if projection ω = v then mass ω else 0) theorem exactAliceInformationPosterior_firstMarginal_pushforward (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (x : X) : jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x) = groupedMass (fun t : ExactLocallySampleableTuple X Y A B D => (t.1, t.2.1)) (exactLocallySampleableLaw G n S D) (i, x) := by classical let equiv := exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D let projection := fun t : ExactLocallySampleableTuple X Y A B D => (t.1, t.2.1) let mass := exactLocallySampleableLaw G n S D have hfirst := congrFun (groupedMass_first (exactAliceInformationPosterior G n S D)) (i, x) have hreindex := exactGroupedMass_equiv equiv projection mass (i, x) have hprojection : (fun k : (SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y) => projection (equiv.symm k)) = Prod.fst := by funext k rcases k with ⟨⟨j, z⟩, r, w⟩ rfl have hmass : (fun k : (SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y) => mass (equiv.symm k)) = exactAliceInformationPosterior G n S D := by funext k rfl rw [hprojection, hmass] at hreindex calc jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x) = groupedMass Prod.fst (exactAliceInformationPosterior G n S D) (i, x) := by exact hfirst.symm _ = groupedMass projection mass (i, x) := by have hchange : groupedMass Prod.fst (exactAliceInformationPosterior G n S D) (i, x) = @groupedMass ((SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y)) inferInstance (SourceRemainingCoordinate D × X) (fun a b => Classical.propDecidable (a = b)) Prod.fst (exactAliceInformationPosterior G n S D) (i, x) := by exact congrFun (exactGroupedMass_decidableEq_irrel _ _ Prod.fst (exactAliceInformationPosterior G n S D)) (i, x) have hreindex' : @groupedMass ((SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y)) inferInstance (SourceRemainingCoordinate D × X) (fun a b => Classical.propDecidable (a = b)) Prod.fst (exactAliceInformationPosterior G n S D) (i, x) = @groupedMass (ExactLocallySampleableTuple X Y A B D) inferInstance (SourceRemainingCoordinate D × X) (fun a b => Classical.propDecidable (a = b)) projection mass (i, x) := by exact hreindex have hright : @groupedMass (ExactLocallySampleableTuple X Y A B D) inferInstance (SourceRemainingCoordinate D × X) (fun a b => Classical.propDecidable (a = b)) projection mass (i, x) = groupedMass projection mass (i, x) := by exact congrFun (exactGroupedMass_decidableEq_irrel _ _ projection mass) (i, x) exact hchange.trans (hreindex'.trans hright) theorem exactBobInformationPosterior_firstMarginal_pushforward (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (y : Y) : jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y) = groupedMass (fun t : ExactLocallySampleableTuple X Y A B D => (t.1, t.2.2.1)) (exactLocallySampleableLaw G n S D) (i, y) := by classical let equiv := exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D let projection := fun t : ExactLocallySampleableTuple X Y A B D => (t.1, t.2.2.1) let mass := exactLocallySampleableLaw G n S D have hfirst := congrFun (groupedMass_first (exactBobInformationPosterior G n S D)) (i, y) have hreindex := exactGroupedMass_equiv equiv projection mass (i, y) have hprojection : (fun k : (SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X) => projection (equiv.symm k)) = Prod.fst := by funext k rcases k with ⟨⟨j, z⟩, r, w⟩ rfl have hmass : (fun k : (SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X) => mass (equiv.symm k)) = exactBobInformationPosterior G n S D := by funext k rfl rw [hprojection, hmass] at hreindex calc jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y) = groupedMass Prod.fst (exactBobInformationPosterior G n S D) (i, y) := by exact hfirst.symm _ = groupedMass projection mass (i, y) := by have hchange : groupedMass Prod.fst (exactBobInformationPosterior G n S D) (i, y) = @groupedMass ((SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X)) inferInstance (SourceRemainingCoordinate D × Y) (fun a b => Classical.propDecidable (a = b)) Prod.fst (exactBobInformationPosterior G n S D) (i, y) := by exact congrFun (exactGroupedMass_decidableEq_irrel _ _ Prod.fst (exactBobInformationPosterior G n S D)) (i, y) have hreindex' : @groupedMass ((SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X)) inferInstance (SourceRemainingCoordinate D × Y) (fun a b => Classical.propDecidable (a = b)) Prod.fst (exactBobInformationPosterior G n S D) (i, y) = @groupedMass (ExactLocallySampleableTuple X Y A B D) inferInstance (SourceRemainingCoordinate D × Y) (fun a b => Classical.propDecidable (a = b)) projection mass (i, y) := by exact hreindex have hright : @groupedMass (ExactLocallySampleableTuple X Y A B D) inferInstance (SourceRemainingCoordinate D × Y) (fun a b => Classical.propDecidable (a = b)) projection mass (i, y) = groupedMass projection mass (i, y) := by exact congrFun (exactGroupedMass_decidableEq_irrel _ _ projection mass) (i, y) exact hchange.trans (hreindex'.trans hright) theorem exactAliceInformationPosterior_firstMarginal (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (x : X) : jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x) = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * groupedMass (fun ω : ExactOutcome X Y A B n => ω.1 i.val) (repeatedConditionedOutcomeLaw G n S D) x := by classical let code := exactLocallySampleableCode (X := X) (Y := Y) (A := A) (B := B) D let projection := fun t : ExactLocallySampleableTuple X Y A B D => (t.1, t.2.1) let joint := exactPostselectedJointLaw G n S D have hlaw : exactLocallySampleableLaw G n S D = groupedMass code joint := by unfold exactLocallySampleableLaw exactSourcePushforward exact exactGroupedMass_decidableEq_irrel _ _ _ _ have hcomp := congrFun (groupedMass_comp code projection joint) (i, x) have hprojection : projection ∘ code = (fun q : ExactJointOutcome X Y A B D => (q.1.coordinate, q.2.1 q.1.coordinate.val)) := by funext q rfl rw [hprojection] at hcomp calc jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x) = groupedMass projection (exactLocallySampleableLaw G n S D) (i, x) := exactAliceInformationPosterior_firstMarginal_pushforward G n S D i x _ = groupedMass projection (groupedMass code joint) (i, x) := by rw [hlaw] _ = groupedMass (fun q : ExactJointOutcome X Y A B D => (q.1.coordinate, q.2.1 q.1.coordinate.val)) joint (i, x) := hcomp _ = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * groupedMass (fun ω : ExactOutcome X Y A B n => ω.1 i.val) (repeatedConditionedOutcomeLaw G n S D) x := by exact exactIndependentCoordinateQuestion_marginal (repeatedConditionedOutcomeLaw G n S D) (fun ω : ExactOutcome X Y A B n => fun j : SourceRemainingCoordinate D => ω.1 j.val) i x theorem exactBobInformationPosterior_firstMarginal (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (y : Y) : jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y) = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * groupedMass (fun ω : ExactOutcome X Y A B n => ω.2.1 i.val) (repeatedConditionedOutcomeLaw G n S D) y := by classical let code := exactLocallySampleableCode (X := X) (Y := Y) (A := A) (B := B) D let projection := fun t : ExactLocallySampleableTuple X Y A B D => (t.1, t.2.2.1) let joint := exactPostselectedJointLaw G n S D have hlaw : exactLocallySampleableLaw G n S D = groupedMass code joint := by unfold exactLocallySampleableLaw exactSourcePushforward exact exactGroupedMass_decidableEq_irrel _ _ _ _ have hcomp := congrFun (groupedMass_comp code projection joint) (i, y) have hprojection : projection ∘ code = (fun q : ExactJointOutcome X Y A B D => (q.1.coordinate, q.2.2.1 q.1.coordinate.val)) := by funext q rfl rw [hprojection] at hcomp calc jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y) = groupedMass projection (exactLocallySampleableLaw G n S D) (i, y) := exactBobInformationPosterior_firstMarginal_pushforward G n S D i y _ = groupedMass projection (groupedMass code joint) (i, y) := by rw [hlaw] _ = groupedMass (fun q : ExactJointOutcome X Y A B D => (q.1.coordinate, q.2.2.1 q.1.coordinate.val)) joint (i, y) := hcomp _ = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * groupedMass (fun ω : ExactOutcome X Y A B n => ω.2.1 i.val) (repeatedConditionedOutcomeLaw G n S D) y := by exact exactIndependentCoordinateQuestion_marginal (repeatedConditionedOutcomeLaw G n S D) (fun ω : ExactOutcome X Y A B n => fun j : SourceRemainingCoordinate D => ω.2.1 j.val) i y theorem finiteProductMarginal_projection_relativeEntropy_le {Ω ι V : Type*} [Fintype Ω] [Fintype ι] [Fintype V] (posterior prior : Ω → ℝ) (projection : Ω → (ι → V)) (q : ι → V → ℝ) (budget : ℝ) (posterior_nonnegative : ∀ ω, 0 ≤ posterior ω) (posterior_normalized : (∑ ω : Ω, posterior ω) = 1) (prior_nonnegative : ∀ ω, 0 ≤ prior ω) (absolute_continuity : ∀ ω, prior ω = 0 → posterior ω = 0) (coordinate_nonnegative : ∀ i v, 0 ≤ q i v) (coordinate_normalized : ∀ i, (∑ v : V, q i v) = 1) (actual_prior : groupedMass projection prior = finiteIndependentProductWeight q) (actual_budget : finiteRelativeEntropy posterior prior ≤ budget) : (∑ i : ι, finiteRelativeEntropy (finiteCoordinateMarginal (groupedMass projection posterior) i) (q i)) ≤ budget := by classical let projected := groupedMass projection posterior have hnonnegative (x : ι → V) : 0 ≤ projected x := groupedMass_nonneg projection posterior posterior_nonnegative x have hnormalized : (∑ x : ι → V, projected x) = 1 := by dsimp [projected] rw [groupedMass_sum, posterior_normalized] have habsolute (x : ι → V) : finiteIndependentProductWeight q x = 0 → projected x = 0 := by intro hx have hprior : groupedMass projection prior x = 0 := by rw [actual_prior] exact hx exact groupedMass_absolute_continuity projection posterior prior prior_nonnegative absolute_continuity x hprior have htensor := finiteProductMarginal_relativeEntropy_le projected q hnonnegative hnormalized coordinate_nonnegative coordinate_normalized habsolute have hdpi := finite_relative_entropy_data_processing projection posterior prior posterior_nonnegative prior_nonnegative absolute_continuity rw [actual_prior] at hdpi exact htensor.trans (hdpi.trans actual_budget) theorem repeatedAliceCoordinateInformation_sum_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ j : Fin n, finiteRelativeEntropy (finiteCoordinateMarginal (repeatedAlicePostselectedQuestionLaw G n S D) j) G.marginalX) ≤ postselectionLogCost G n S D := by classical let posterior := repeatedConditionedOutcomeLaw G n S D let prior := (strategyEventLaw (G.repeat n) S).weight let projection := fun ω : ExactOutcome X Y A B n => ω.1 let q := fun _ : Fin n => G.marginalX have hposterior (ω : ExactOutcome X Y A B n) : 0 ≤ posterior ω := conditionedEventDistribution_nonneg (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive ω have hnormalized : (∑ ω : ExactOutcome X Y A B n, posterior ω) = 1 := conditionedEventDistribution_sum (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive have hac (ω : ExactOutcome X Y A B n) : prior ω = 0 → posterior ω = 0 := conditionedEventDistribution_absolute_continuity (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) ω have hprior : groupedMass projection prior = finiteIndependentProductWeight q := by funext xs exact repeatedAliceQuestionPrior_product G n S xs have hbudget : finiteRelativeEntropy posterior prior ≤ postselectionLogCost G n S D := by exact le_of_eq (repeatedConditionedOutcomeLaw_relativeEntropy G n S D positive) have h := finiteProductMarginal_projection_relativeEntropy_le posterior prior projection q (postselectionLogCost G n S D) hposterior hnormalized (strategyEventLaw (G.repeat n) S).weight_nonneg hac (fun j x => G.marginalX_nonneg x) (fun j => G.marginalX_normalized) hprior hbudget have hprojected : groupedMass projection posterior = repeatedAlicePostselectedQuestionLaw G n S D := by unfold repeatedAlicePostselectedQuestionLaw exact exactGroupedMass_decidableEq_irrel _ _ _ _ rw [hprojected] at h exact h theorem repeatedBobCoordinateInformation_sum_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ j : Fin n, finiteRelativeEntropy (finiteCoordinateMarginal (repeatedBobPostselectedQuestionLaw G n S D) j) G.marginalY) ≤ postselectionLogCost G n S D := by classical let posterior := repeatedConditionedOutcomeLaw G n S D let prior := (strategyEventLaw (G.repeat n) S).weight let projection := fun ω : ExactOutcome X Y A B n => ω.2.1 let q := fun _ : Fin n => G.marginalY have hposterior (ω : ExactOutcome X Y A B n) : 0 ≤ posterior ω := conditionedEventDistribution_nonneg (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive ω have hnormalized : (∑ ω : ExactOutcome X Y A B n, posterior ω) = 1 := conditionedEventDistribution_sum (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive have hac (ω : ExactOutcome X Y A B n) : prior ω = 0 → posterior ω = 0 := conditionedEventDistribution_absolute_continuity (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) ω have hprior : groupedMass projection prior = finiteIndependentProductWeight q := by funext ys exact repeatedBobQuestionPrior_product G n S ys have hbudget : finiteRelativeEntropy posterior prior ≤ postselectionLogCost G n S D := by exact le_of_eq (repeatedConditionedOutcomeLaw_relativeEntropy G n S D positive) have h := finiteProductMarginal_projection_relativeEntropy_le posterior prior projection q (postselectionLogCost G n S D) hposterior hnormalized (strategyEventLaw (G.repeat n) S).weight_nonneg hac (fun j y => G.marginalY_nonneg y) (fun j => G.marginalY_normalized) hprior hbudget have hprojected : groupedMass projection posterior = repeatedBobPostselectedQuestionLaw G n S D := by unfold repeatedBobPostselectedQuestionLaw exact exactGroupedMass_decidableEq_irrel _ _ _ _ rw [hprojected] at h exact h theorem finiteCoordinateMarginal_groupedMass {Ω ι V : Type*} [Fintype Ω] [Fintype ι] [Fintype V] (projection : Ω → (ι → V)) (mass : Ω → ℝ) (i : ι) (v : V) : finiteCoordinateMarginal (groupedMass projection mass) i v = groupedMass (fun ω : Ω => projection ω i) mass v := by classical let eval : (ι → V) → V := fun x => x i have h := congrFun (groupedMass_comp projection eval mass) v unfold finiteCoordinateMarginal have hleft : groupedMass (fun x : ι → V => x i) (groupedMass projection mass) v = @groupedMass (ι → V) inferInstance V (fun a b => Classical.propDecidable (a = b)) eval (groupedMass projection mass) v := by exact congrFun (exactGroupedMass_decidableEq_irrel _ _ eval (groupedMass projection mass)) v have hright : @groupedMass Ω inferInstance V (fun a b => Classical.propDecidable (a = b)) (eval ∘ projection) mass v = groupedMass (fun ω : Ω => projection ω i) mass v := by exact congrFun (exactGroupedMass_decidableEq_irrel _ _ (fun ω : Ω => projection ω i) mass) v exact hleft.trans (h.trans hright) theorem finiteUniformCoordinate_relativeEntropy {ι V : Type*} [Fintype ι] [Fintype V] (positive : 0 < Fintype.card ι) (posterior : ι → V → ℝ) (prior : V → ℝ) : finiteRelativeEntropy (fun t : ι × V => (1 / (Fintype.card ι : ℝ)) * posterior t.1 t.2) (fun t : ι × V => (1 / (Fintype.card ι : ℝ)) * prior t.2) = (1 / (Fintype.card ι : ℝ)) * ∑ i : ι, finiteRelativeEntropy (posterior i) prior := by classical have hcard : (Fintype.card ι : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt positive) have huniform : (1 / (Fintype.card ι : ℝ)) ≠ 0 := one_div_ne_zero hcard unfold finiteRelativeEntropy rw [Fintype.sum_prod_type] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro v _ rw [mul_div_mul_left _ _ huniform] ring theorem repeatedAlicePostselectedQuestionLaw_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (xs : Fin n → X) : 0 ≤ repeatedAlicePostselectedQuestionLaw G n S D xs := by classical unfold repeatedAlicePostselectedQuestionLaw apply groupedMass_nonneg intro ω exact conditionedEventDistribution_nonneg (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive ω theorem repeatedBobPostselectedQuestionLaw_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (ys : Fin n → Y) : 0 ≤ repeatedBobPostselectedQuestionLaw G n S D ys := by classical unfold repeatedBobPostselectedQuestionLaw apply groupedMass_nonneg intro ω exact conditionedEventDistribution_nonneg (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive ω theorem repeatedAlicePostselectedCoordinateMarginal (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (j : Fin n) (x : X) : finiteCoordinateMarginal (repeatedAlicePostselectedQuestionLaw G n S D) j x = groupedMass (fun ω : ExactOutcome X Y A B n => ω.1 j) (repeatedConditionedOutcomeLaw G n S D) x := by classical let projection := fun ω : ExactOutcome X Y A B n => ω.1 let posterior := repeatedConditionedOutcomeLaw G n S D have hlaw : repeatedAlicePostselectedQuestionLaw G n S D = groupedMass projection posterior := by unfold repeatedAlicePostselectedQuestionLaw exact exactGroupedMass_decidableEq_irrel _ _ _ _ rw [hlaw] exact finiteCoordinateMarginal_groupedMass projection posterior j x theorem repeatedBobPostselectedCoordinateMarginal (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (j : Fin n) (y : Y) : finiteCoordinateMarginal (repeatedBobPostselectedQuestionLaw G n S D) j y = groupedMass (fun ω : ExactOutcome X Y A B n => ω.2.1 j) (repeatedConditionedOutcomeLaw G n S D) y := by classical let projection := fun ω : ExactOutcome X Y A B n => ω.2.1 let posterior := repeatedConditionedOutcomeLaw G n S D have hlaw : repeatedBobPostselectedQuestionLaw G n S D = groupedMass projection posterior := by unfold repeatedBobPostselectedQuestionLaw exact exactGroupedMass_decidableEq_irrel _ _ _ _ rw [hlaw] exact finiteCoordinateMarginal_groupedMass projection posterior j y theorem exactAliceSourceMarginalInformation_eq (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (base : ExactHistoryFlag X Y A B D) : exactAliceSourceMarginalInformation G n S D base = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * ∑ i : SourceRemainingCoordinate D, finiteRelativeEntropy (finiteCoordinateMarginal (repeatedAlicePostselectedQuestionLaw G n S D) i.val) G.marginalX := by classical let posterior := repeatedAlicePostselectedQuestionLaw G n S D have hposterior : jointFirstMarginal (exactAliceInformationPosterior G n S D) = (fun t : SourceRemainingCoordinate D × X => (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * finiteCoordinateMarginal posterior t.1.val t.2) := by funext t rcases t with ⟨i, x⟩ rw [exactAliceInformationPosterior_firstMarginal] congr 1 exact (repeatedAlicePostselectedCoordinateMarginal G n S D i.val x).symm have hreference : jointFirstMarginal (exactAliceInformationReference G n S D base) = (fun t : SourceRemainingCoordinate D × X => (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * G.marginalX t.2) := by funext t rcases t with ⟨i, x⟩ rw [exactAliceInformationReference_firstMarginal] change G.marginalX x / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = _ ring unfold exactAliceSourceMarginalInformation rw [hposterior, hreference] exact finiteUniformCoordinate_relativeEntropy (exactRemainingCoordinate_card_pos D remaining) (fun i : SourceRemainingCoordinate D => finiteCoordinateMarginal posterior i.val) G.marginalX theorem exactBobSourceMarginalInformation_eq (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (base : ExactHistoryFlag X Y A B D) : exactBobSourceMarginalInformation G n S D base = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * ∑ i : SourceRemainingCoordinate D, finiteRelativeEntropy (finiteCoordinateMarginal (repeatedBobPostselectedQuestionLaw G n S D) i.val) G.marginalY := by classical let posterior := repeatedBobPostselectedQuestionLaw G n S D have hposterior : jointFirstMarginal (exactBobInformationPosterior G n S D) = (fun t : SourceRemainingCoordinate D × Y => (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * finiteCoordinateMarginal posterior t.1.val t.2) := by funext t rcases t with ⟨i, y⟩ rw [exactBobInformationPosterior_firstMarginal] congr 1 exact (repeatedBobPostselectedCoordinateMarginal G n S D i.val y).symm have hreference : jointFirstMarginal (exactBobInformationReference G n S D base) = (fun t : SourceRemainingCoordinate D × Y => (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * G.marginalY t.2) := by funext t rcases t with ⟨i, y⟩ rw [exactBobInformationReference_firstMarginal] change G.marginalY y / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = _ ring unfold exactBobSourceMarginalInformation rw [hposterior, hreference] exact finiteUniformCoordinate_relativeEntropy (exactRemainingCoordinate_card_pos D remaining) (fun i : SourceRemainingCoordinate D => finiteCoordinateMarginal posterior i.val) G.marginalY theorem sourceRemaining_nonnegative_sum_le {n : ℕ} (D : Finset (Fin n)) (f : Fin n → ℝ) (nonnegative : ∀ j, 0 ≤ f j) : (∑ i : SourceRemainingCoordinate D, f i.val) ≤ ∑ j : Fin n, f j := by classical change (∑ i ∈ (Finset.univ \ D).attach, f i.val) ≤ ∑ j : Fin n, f j rw [Finset.sum_attach] exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ (Finset.univ \ D)) (fun j _ _ => nonnegative j) theorem exactAliceSourceMarginalInformation_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactAliceSourceMarginalInformation G n S D base ≤ postselectionLogCost G n S D / ((Finset.univ \ D).card : ℝ) := by classical let posterior := repeatedAlicePostselectedQuestionLaw G n S D let coordinateInfo : Fin n → ℝ := fun j => finiteRelativeEntropy (finiteCoordinateMarginal posterior j) G.marginalX have hnonnegative (j : Fin n) : 0 ≤ coordinateInfo j := by exact finiteRelativeEntropy_nonneg (finiteCoordinateMarginal posterior j) G.marginalX (fun x => finiteCoordinateMarginal_nonneg posterior (repeatedAlicePostselectedQuestionLaw_nonneg G n S D positive) j x) G.marginalX_nonneg have hremaining : (∑ i : SourceRemainingCoordinate D, coordinateInfo i.val) ≤ postselectionLogCost G n S D := by exact (sourceRemaining_nonnegative_sum_le D coordinateInfo hnonnegative).trans (repeatedAliceCoordinateInformation_sum_le G n S D positive) have hcard : Fintype.card (SourceRemainingCoordinate D) = (Finset.univ \ D).card := by simp calc exactAliceSourceMarginalInformation G n S D base = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * ∑ i : SourceRemainingCoordinate D, coordinateInfo i.val := exactAliceSourceMarginalInformation_eq G n S D remaining base _ ≤ (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * postselectionLogCost G n S D := by exact mul_le_mul_of_nonneg_left hremaining (one_div_nonneg.mpr (Nat.cast_nonneg _)) _ = postselectionLogCost G n S D / ((Finset.univ \ D).card : ℝ) := by rw [hcard] ring theorem exactBobSourceMarginalInformation_le (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactBobSourceMarginalInformation G n S D base ≤ postselectionLogCost G n S D / ((Finset.univ \ D).card : ℝ) := by classical let posterior := repeatedBobPostselectedQuestionLaw G n S D let coordinateInfo : Fin n → ℝ := fun j => finiteRelativeEntropy (finiteCoordinateMarginal posterior j) G.marginalY have hnonnegative (j : Fin n) : 0 ≤ coordinateInfo j := by exact finiteRelativeEntropy_nonneg (finiteCoordinateMarginal posterior j) G.marginalY (fun y => finiteCoordinateMarginal_nonneg posterior (repeatedBobPostselectedQuestionLaw_nonneg G n S D positive) j y) G.marginalY_nonneg have hremaining : (∑ i : SourceRemainingCoordinate D, coordinateInfo i.val) ≤ postselectionLogCost G n S D := by exact (sourceRemaining_nonnegative_sum_le D coordinateInfo hnonnegative).trans (repeatedBobCoordinateInformation_sum_le G n S D positive) have hcard : Fintype.card (SourceRemainingCoordinate D) = (Finset.univ \ D).card := by simp calc exactBobSourceMarginalInformation G n S D base = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * ∑ i : SourceRemainingCoordinate D, coordinateInfo i.val := exactBobSourceMarginalInformation_eq G n S D remaining base _ ≤ (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * postselectionLogCost G n S D := by exact mul_le_mul_of_nonneg_left hremaining (one_div_nonneg.mpr (Nat.cast_nonneg _)) _ = postselectionLogCost G n S D / ((Finset.univ \ D).card : ℝ) := by rw [hcard] ring end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exact_source_equation_twenty_three_of_conditioned_reverse_prefix {KA KB : Type*} [Fintype KA] [Fintype KB] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (seedLawA : Finset (SourceRemainingCoordinate D) → FiniteEventLaw KA) (seedLawB : Finset (SourceRemainingCoordinate D) → FiniteEventLaw KB) (ΩA ΩB : Finset (SourceRemainingCoordinate D) → Type*) [∀ side, Fintype (ΩA side)] [∀ side, Fintype (ΩB side)] (projectionA : ∀ side : Finset (SourceRemainingCoordinate D), KA × ExactOutcome X Y A B n → ΩA side × (Fin side.card → Y)) (projectionB : ∀ side : Finset (SourceRemainingCoordinate D), KB × ExactOutcome X Y A B n → ΩB side × (Fin side.card → X)) (defaultY : Y) (defaultX : X) (aliceConditionedReverseIdentification : exactAliceSourceConditionalInformation G n S D base = ∑ side : Finset (SourceRemainingCoordinate D), reversePartitionWeight side * ((∑ k : Fin side.card, reweightedSeedPrefixEntropyIncrement (seedLawA side) G n S D (projectionA side) defaultY k) / (side.card : ℝ))) (bobConditionedReverseIdentification : exactBobSourceConditionalInformation G n S D base = ∑ side : Finset (SourceRemainingCoordinate D), reversePartitionWeight side * ((∑ k : Fin side.card, reweightedSeedPrefixEntropyIncrement (seedLawB side) G n S D (projectionB side) defaultX k) / (side.card : ℝ))) : ExactSourceClassicalInformationBound G n S D base := by constructor · rw [exact_source_equation_twenty_four_alice G n S D remaining positive base] change exactAliceSourceMarginalInformation G n S D base + exactAliceSourceConditionalInformation G n S D base ≤ exactSourceClassicalInformationRate G n S D calc exactAliceSourceMarginalInformation G n S D base + exactAliceSourceConditionalInformation G n S D base ≤ postselectionLogCost G n S D / ((Finset.univ \ D).card : ℝ) + 2 * (postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D) / ((Finset.univ \ D).card : ℝ) := by apply add_le_add · exact exactAliceSourceMarginalInformation_le G n S D remaining positive base · rw [aliceConditionedReverseIdentification] exact reweightedSeed_reverse_source_prefix_information_budget G n S D remaining positive seedLawA ΩA projectionA defaultY _ = exactSourceClassicalInformationRate G n S D := by unfold exactSourceClassicalInformationRate ring · rw [exact_source_equation_twenty_four_bob G n S D remaining positive base] change exactBobSourceMarginalInformation G n S D base + exactBobSourceConditionalInformation G n S D base ≤ exactSourceClassicalInformationRate G n S D calc exactBobSourceMarginalInformation G n S D base + exactBobSourceConditionalInformation G n S D base ≤ postselectionLogCost G n S D / ((Finset.univ \ D).card : ℝ) + 2 * (postselectionLogCost G n S D + answerLogCost (A := A) (B := B) D) / ((Finset.univ \ D).card : ℝ) := by apply add_le_add · exact exactBobSourceMarginalInformation_le G n S D remaining positive base · rw [bobConditionedReverseIdentification] exact reweightedSeed_reverse_source_prefix_information_budget G n S D remaining positive seedLawB ΩB projectionB defaultX _ = exactSourceClassicalInformationRate G n S D := by unfold exactSourceClassicalInformationRate ring end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactConditionedReverseAlicePrefixEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (k : Fin side.card) : ℝ := reweightedSeedPrefixEntropyIncrement (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side) G n S D (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side) default k def exactConditionedReverseBobPrefixEntropyIncrement (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : X) (k : Fin side.card) : ℝ := reweightedSeedPrefixEntropyIncrement (exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side) G n S D (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side) default k def exactConditionedReverseAlicePrefixInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : Y) : ℝ := ∑ side : Finset (SourceRemainingCoordinate D), reversePartitionWeight side * ((∑ k : Fin side.card, exactConditionedReverseAlicePrefixEntropyIncrement G n S D remaining side default k) / (side.card : ℝ)) def exactConditionedReverseBobPrefixInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : X) : ℝ := ∑ side : Finset (SourceRemainingCoordinate D), reversePartitionWeight side * ((∑ k : Fin side.card, exactConditionedReverseBobPrefixEntropyIncrement G n S D remaining side default k) / (side.card : ℝ)) def ExactReverseAliceConditionalHistoryIdentification (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (base : ExactHistoryFlag X Y A B D) (default : Y) : Prop := exactAliceSourceConditionalInformation G n S D base = exactConditionedReverseAlicePrefixInformation G n S D remaining default def ExactReverseBobConditionalHistoryIdentification (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (base : ExactHistoryFlag X Y A B D) (default : X) : Prop := exactBobSourceConditionalInformation G n S D base = exactConditionedReverseBobPrefixInformation G n S D remaining default theorem exact_source_equation_twenty_three_of_actual_conditioned_reindex (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (defaultY : Y) (defaultX : X) (alice : ExactReverseAliceConditionalHistoryIdentification G n S D remaining base defaultY) (bob : ExactReverseBobConditionalHistoryIdentification G n S D remaining base defaultX) : ExactSourceClassicalInformationBound G n S D base := by apply exact_source_equation_twenty_three_of_conditioned_reverse_prefix G n S D remaining positive base (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining)) (exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining)) (ExactReverseAliceFixedInformation X Y D) (ExactReverseBobFixedInformation X Y D) (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D) (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D) defaultY defaultX · exact alice · exact bob end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem finiteRelativeEntropy_self {I : Type*} [Fintype I] (mass : I → ℝ) : finiteRelativeEntropy mass mass = 0 := by unfold finiteRelativeEntropy apply Finset.sum_eq_zero intro i _ by_cases hi : mass i = 0 · simp [hi] · simp [hi, InformationTheory.klFun] theorem finiteConditionalHistoryRelativeEntropy_eq {I R V : Type*} [Fintype I] [Fintype R] [Fintype V] (p q : I × (R × V) → ℝ) (p_nonnegative : ∀ point, 0 ≤ p point) (q_nonnegative : ∀ point, 0 ≤ q point) (absolute_continuity : ∀ point, q point = 0 → p point = 0) (reference : I → R → V → ℝ) (same_history : ∀ i, jointFirstMarginal p i ≠ 0 → jointFirstMarginal (jointConditional p i) = jointFirstMarginal (jointConditional q i)) (next_reference : ∀ i r, jointFirstMarginal p i ≠ 0 → jointFirstMarginal (jointConditional p i) r ≠ 0 → jointConditional (jointConditional q i) r = reference i r) : (∑ i : I, jointFirstMarginal p i * finiteRelativeEntropy (jointConditional p i) (jointConditional q i)) = ∑ i : I, jointFirstMarginal p i * (∑ r : R, jointFirstMarginal (jointConditional p i) r * finiteRelativeEntropy (jointConditional (jointConditional p i) r) (reference i r)) := by apply Finset.sum_congr rfl intro i _ by_cases hpi : jointFirstMarginal p i = 0 · simp [hpi] · have hqi : jointFirstMarginal q i ≠ 0 := by intro hz exact hpi (jointFirstMarginal_absolute_continuity p q q_nonnegative absolute_continuity i hz) have hpconditional : ∀ t : R × V, 0 ≤ jointConditional p i t := by intro t exact div_nonneg (p_nonnegative (i, t)) (jointFirstMarginal_nonneg p p_nonnegative i) have hqconditional : ∀ t : R × V, 0 ≤ jointConditional q i t := by intro t exact div_nonneg (q_nonnegative (i, t)) (jointFirstMarginal_nonneg q q_nonnegative i) have hconditional_absolute : ∀ t : R × V, jointConditional q i t = 0 → jointConditional p i t = 0 := by intro t hz have hqzero : q (i, t) = 0 := by change q (i, t) / jointFirstMarginal q i = 0 at hz exact (div_eq_zero_iff.mp hz).resolve_right hqi simp [jointConditional, absolute_continuity (i, t) hqzero] have hchain := finite_relative_entropy_joint_chain_rule (jointConditional p i) (jointConditional q i) hpconditional hqconditional hconditional_absolute (jointConditional_sum p i hpi) (jointConditional_sum q i hqi) have hhistory_entropy : finiteRelativeEntropy (jointFirstMarginal (jointConditional p i)) (jointFirstMarginal (jointConditional q i)) = 0 := by rw [← same_history i hpi] exact finiteRelativeEntropy_self _ rw [hhistory_entropy, zero_add] at hchain rw [hchain] congr 1 apply Finset.sum_congr rfl intro r _ by_cases hr : jointFirstMarginal (jointConditional p i) r = 0 · simp [hr] · rw [next_reference i r hpi hr] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem finiteSupportedConditionalHistoryReferenceFirstMarginal_eq {I R V : Type*} [Fintype I] [Fintype R] [Fintype V] (p q : I × (R × V) → ℝ) (q_nonnegative : ∀ point, 0 ≤ q point) (absolute_continuity : ∀ point, q point = 0 → p point = 0) (reference : I → R → V → ℝ) (reference_normalized : ∀ i, jointFirstMarginal p i ≠ 0 → ∀ r, (∑ v : V, reference i r v) = 1) (factor : ∀ i, jointFirstMarginal p i ≠ 0 → ∀ r v, q (i, (r, v)) = jointFirstMarginal q i * jointFirstMarginal (jointConditional p i) r * reference i r v) (i : I) (supported : jointFirstMarginal p i ≠ 0) : jointFirstMarginal (jointConditional q i) = jointFirstMarginal (jointConditional p i) := by have hqi : jointFirstMarginal q i ≠ 0 := by intro hz exact supported (jointFirstMarginal_absolute_continuity p q q_nonnegative absolute_continuity i hz) funext r change (∑ v : V, q (i, (r, v)) / jointFirstMarginal q i) = jointFirstMarginal (jointConditional p i) r simp_rw [factor i supported r] calc (∑ v : V, (jointFirstMarginal q i * jointFirstMarginal (jointConditional p i) r * reference i r v) / jointFirstMarginal q i) = ∑ v : V, jointFirstMarginal (jointConditional p i) r * reference i r v := by apply Finset.sum_congr rfl intro v _ field_simp [hqi] _ = jointFirstMarginal (jointConditional p i) r := by rw [← Finset.mul_sum, reference_normalized i supported r] ring theorem finiteSupportedConditionalHistoryReferenceConditional_eq {I R V : Type*} [Fintype I] [Fintype R] [Fintype V] (p q : I × (R × V) → ℝ) (q_nonnegative : ∀ point, 0 ≤ q point) (absolute_continuity : ∀ point, q point = 0 → p point = 0) (reference : I → R → V → ℝ) (reference_normalized : ∀ i, jointFirstMarginal p i ≠ 0 → ∀ r, (∑ v : V, reference i r v) = 1) (factor : ∀ i, jointFirstMarginal p i ≠ 0 → ∀ r v, q (i, (r, v)) = jointFirstMarginal q i * jointFirstMarginal (jointConditional p i) r * reference i r v) (i : I) (r : R) (supported : jointFirstMarginal p i ≠ 0) (history_supported : jointFirstMarginal (jointConditional p i) r ≠ 0) : jointConditional (jointConditional q i) r = reference i r := by have hqi : jointFirstMarginal q i ≠ 0 := by intro hz exact supported (jointFirstMarginal_absolute_continuity p q q_nonnegative absolute_continuity i hz) have hhistory := finiteSupportedConditionalHistoryReferenceFirstMarginal_eq p q q_nonnegative absolute_continuity reference reference_normalized factor i supported funext v change (q (i, (r, v)) / jointFirstMarginal q i) / jointFirstMarginal (jointConditional q i) r = reference i r v rw [factor i supported r v, congrFun hhistory r] field_simp [hqi, history_supported] theorem finiteSupportedConditionalHistoryRelativeEntropy_eq_of_factor {I R V : Type*} [Fintype I] [Fintype R] [Fintype V] (p q : I × (R × V) → ℝ) (p_nonnegative : ∀ point, 0 ≤ p point) (q_nonnegative : ∀ point, 0 ≤ q point) (absolute_continuity : ∀ point, q point = 0 → p point = 0) (reference : I → R → V → ℝ) (reference_normalized : ∀ i, jointFirstMarginal p i ≠ 0 → ∀ r, (∑ v : V, reference i r v) = 1) (factor : ∀ i, jointFirstMarginal p i ≠ 0 → ∀ r v, q (i, (r, v)) = jointFirstMarginal q i * jointFirstMarginal (jointConditional p i) r * reference i r v) : (∑ i : I, jointFirstMarginal p i * finiteRelativeEntropy (jointConditional p i) (jointConditional q i)) = ∑ i : I, jointFirstMarginal p i * (∑ r : R, jointFirstMarginal (jointConditional p i) r * finiteRelativeEntropy (jointConditional (jointConditional p i) r) (reference i r)) := by apply finiteConditionalHistoryRelativeEntropy_eq p q p_nonnegative q_nonnegative absolute_continuity reference · intro i hi exact (finiteSupportedConditionalHistoryReferenceFirstMarginal_eq p q q_nonnegative absolute_continuity reference reference_normalized factor i hi).symm · intro i r hi hr exact finiteSupportedConditionalHistoryReferenceConditional_eq p q q_nonnegative absolute_continuity reference reference_normalized factor i r hi hr end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactAliceInformationPosterior_firstMarginal_eq_localMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (x : X) : jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x) = exactAliceLocalMass D (exactLocallySampleableLaw G n S D) i x := by unfold jointFirstMarginal rw [Fintype.sum_prod_type] rfl theorem exactBobInformationPosterior_firstMarginal_eq_localMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : SourceRemainingCoordinate D) (y : Y) : jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y) = exactBobLocalMass D (exactLocallySampleableLaw G n S D) i y := by unfold jointFirstMarginal rw [Fintype.sum_prod_type] rfl theorem exactAliceSupportedQuestion_marginal_pos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (i : SourceRemainingCoordinate D) (x : X) (supported : jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x) ≠ 0) : 0 < G.marginalX x := by let p := exactAliceInformationPosterior G n S D let q := exactAliceInformationReference G n S D base have hqnonnegative : ∀ t, 0 ≤ q t := by intro t exact exactLocallySampleableJA_nonneg G n S D positive base ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) have hac : ∀ t, q t = 0 → p t = 0 := by intro t hz exact exactLocallySampleableLaw_absolute_continuous_JA G n S D remaining positive base ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) hz have hqmass : jointFirstMarginal q (i, x) ≠ 0 := by intro hz exact supported (jointFirstMarginal_absolute_continuity p q hqnonnegative hac (i, x) hz) rw [exactAliceInformationReference_firstMarginal G n S D base i x] at hqmass have hx : G.marginalX x ≠ 0 := by intro hz apply hqmass change G.marginalX x / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = 0 rw [hz] simp exact lt_of_le_of_ne (G.marginalX_nonneg x) (Ne.symm hx) theorem exactBobSupportedQuestion_marginal_pos (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (i : SourceRemainingCoordinate D) (y : Y) (supported : jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y) ≠ 0) : 0 < G.marginalY y := by let p := exactBobInformationPosterior G n S D let q := exactBobInformationReference G n S D base have hqnonnegative : ∀ t, 0 ≤ q t := by intro t exact exactLocallySampleableJB_nonneg G n S D positive base ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) have hac : ∀ t, q t = 0 → p t = 0 := by intro t hz exact exactLocallySampleableLaw_absolute_continuous_JB G n S D remaining positive base ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) hz have hqmass : jointFirstMarginal q (i, y) ≠ 0 := by intro hz exact supported (jointFirstMarginal_absolute_continuity p q hqnonnegative hac (i, y) hz) rw [exactBobInformationReference_firstMarginal G n S D base i y] at hqmass have hy : G.marginalY y ≠ 0 := by intro hz apply hqmass change G.marginalY y / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = 0 rw [hz] simp exact lt_of_le_of_ne (G.marginalY_nonneg y) (Ne.symm hy) theorem exactAliceInformationPosterior_historyMarginal (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (i : SourceRemainingCoordinate D) (x : X) (supported : jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x) ≠ 0) (r : ExactHistoryFlag X Y A B D) : jointFirstMarginal (jointConditional (exactAliceInformationPosterior G n S D) (i, x)) r = exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r := by have hmass := exactAliceInformationPosterior_firstMarginal_eq_localMass G n S D i x have hlocal : exactAliceLocalMass D (exactLocallySampleableLaw G n S D) i x ≠ 0 := by rw [← hmass] exact supported unfold jointFirstMarginal jointConditional change (∑ y : Y, exactLocallySampleableLaw G n S D (i, x, y, r) / jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x)) = exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r rw [← Finset.sum_div, hmass] simp [exactAliceLocalConditional, hlocal] theorem exactBobInformationPosterior_historyMarginal (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (i : SourceRemainingCoordinate D) (y : Y) (supported : jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y) ≠ 0) (r : ExactHistoryFlag X Y A B D) : jointFirstMarginal (jointConditional (exactBobInformationPosterior G n S D) (i, y)) r = exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r := by have hmass := exactBobInformationPosterior_firstMarginal_eq_localMass G n S D i y have hlocal : exactBobLocalMass D (exactLocallySampleableLaw G n S D) i y ≠ 0 := by rw [← hmass] exact supported unfold jointFirstMarginal jointConditional change (∑ x : X, exactLocallySampleableLaw G n S D (i, x, y, r) / jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y)) = exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r rw [← Finset.sum_div, hmass] simp [exactBobLocalConditional, hlocal] theorem exactAliceInformationReference_supported_factor (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (i : SourceRemainingCoordinate D) (x : X) (supported : jointFirstMarginal (exactAliceInformationPosterior G n S D) (i, x) ≠ 0) (r : ExactHistoryFlag X Y A B D) (y : Y) : exactAliceInformationReference G n S D base ((i, x), (r, y)) = jointFirstMarginal (exactAliceInformationReference G n S D base) (i, x) * jointFirstMarginal (jointConditional (exactAliceInformationPosterior G n S D) (i, x)) r * G.conditionalYGivenX x y := by rw [exactAliceInformationReference_firstMarginal G n S D base i x, exactAliceInformationPosterior_historyMarginal G n S D base i x supported r] change G.questionWeight x y * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = (G.marginalX x / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) i x r * G.conditionalYGivenX x y rw [← G.marginalX_mul_conditionalYGivenX x y] ring theorem exactBobInformationReference_supported_factor (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (i : SourceRemainingCoordinate D) (y : Y) (supported : jointFirstMarginal (exactBobInformationPosterior G n S D) (i, y) ≠ 0) (r : ExactHistoryFlag X Y A B D) (x : X) : exactBobInformationReference G n S D base ((i, y), (r, x)) = jointFirstMarginal (exactBobInformationReference G n S D base) (i, y) * jointFirstMarginal (jointConditional (exactBobInformationPosterior G n S D) (i, y)) r * G.conditionalXGivenY y x := by rw [exactBobInformationReference_firstMarginal G n S D base i y, exactBobInformationPosterior_historyMarginal G n S D base i y supported r] change G.questionWeight x y * exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = (G.marginalY y / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * exactBobLocalConditional D base (exactLocallySampleableLaw G n S D) i y r * G.conditionalXGivenY y x rw [← G.marginalY_mul_conditionalXGivenY x y] ring theorem exactAliceSourceConditionalInformation_eq_question (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactAliceSourceConditionalInformation G n S D base = ∑ ix : SourceRemainingCoordinate D × X, jointFirstMarginal (exactAliceInformationPosterior G n S D) ix * (∑ r : ExactHistoryFlag X Y A B D, jointFirstMarginal (jointConditional (exactAliceInformationPosterior G n S D) ix) r * finiteRelativeEntropy (jointConditional (jointConditional (exactAliceInformationPosterior G n S D) ix) r) (G.conditionalYGivenX ix.2)) := by let p := exactAliceInformationPosterior G n S D let q := exactAliceInformationReference G n S D base have hp : ∀ t, 0 ≤ p t := by intro t exact exactLocallySampleableLaw_nonneg G n S D positive ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) have hq : ∀ t, 0 ≤ q t := by intro t exact exactLocallySampleableJA_nonneg G n S D positive base ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) have hac : ∀ t, q t = 0 → p t = 0 := by intro t hz exact exactLocallySampleableLaw_absolute_continuous_JA G n S D remaining positive base ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) hz unfold exactAliceSourceConditionalInformation apply finiteSupportedConditionalHistoryRelativeEntropy_eq_of_factor p q hp hq hac (fun ix _ => G.conditionalYGivenX ix.2) · intro ix hix r exact G.conditionalYGivenX_sum ix.2 (exactAliceSupportedQuestion_marginal_pos G n S D remaining positive base ix.1 ix.2 hix) · intro ix hix r y exact exactAliceInformationReference_supported_factor G n S D base ix.1 ix.2 hix r y theorem exactBobSourceConditionalInformation_eq_question (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactBobSourceConditionalInformation G n S D base = ∑ iy : SourceRemainingCoordinate D × Y, jointFirstMarginal (exactBobInformationPosterior G n S D) iy * (∑ r : ExactHistoryFlag X Y A B D, jointFirstMarginal (jointConditional (exactBobInformationPosterior G n S D) iy) r * finiteRelativeEntropy (jointConditional (jointConditional (exactBobInformationPosterior G n S D) iy) r) (G.conditionalXGivenY iy.2)) := by let p := exactBobInformationPosterior G n S D let q := exactBobInformationReference G n S D base have hp : ∀ t, 0 ≤ p t := by intro t exact exactLocallySampleableLaw_nonneg G n S D positive ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) have hq : ∀ t, 0 ≤ q t := by intro t exact exactLocallySampleableJB_nonneg G n S D positive base ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) have hac : ∀ t, q t = 0 → p t = 0 := by intro t hz exact exactLocallySampleableLaw_absolute_continuous_JB G n S D remaining positive base ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm t) hz unfold exactBobSourceConditionalInformation apply finiteSupportedConditionalHistoryRelativeEntropy_eq_of_factor p q hp hq hac (fun iy _ => G.conditionalXGivenY iy.2) · intro iy hiy r exact G.conditionalXGivenY_sum iy.2 (exactBobSupportedQuestion_marginal_pos G n S D remaining positive base iy.1 iy.2 hiy) · intro iy hiy r x exact exactBobInformationReference_supported_factor G n S D base iy.1 iy.2 hiy r x end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] abbrev ExactReverseAliceNextContext (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) := (ExactReverseAliceFixedInformation X Y D side × ConditionedAnswerFlag A B D) × (Fin side.card → Y) abbrev ExactReverseBobNextContext (X Y A B : Type*) [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) := (ExactReverseBobFixedInformation X Y D side × ConditionedAnswerFlag A B D) × (Fin side.card → X) def exactConditionedReverseAliceNextJoint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) : ExactReverseAliceNextContext X Y A B D side → ℝ := reweightedSeedPrefixJoint (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side) G n S D (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side) def exactConditionedReverseAliceNextPrior (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) : ExactReverseAliceNextContext X Y A B D side → ℝ := reweightedSeedPrefixPrior (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side) G n S D (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side) def exactConditionedReverseBobNextJoint (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) : ExactReverseBobNextContext X Y A B D side → ℝ := reweightedSeedPrefixJoint (exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side) G n S D (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side) def exactConditionedReverseBobNextPrior (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) : ExactReverseBobNextContext X Y A B D side → ℝ := reweightedSeedPrefixPrior (exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side) G n S D (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side) theorem exactReverseAliceMaskedProjection_eq_of_history {n : ℕ} (D : Finset (Fin n)) (default : Y) (q q' : ExactJointOutcome X Y A B D) (same_history : exactHistoryCode D q = exactHistoryCode D q') (same_question : q.2.1 q.1.coordinate.val = q'.2.1 q'.1.coordinate.val) : finitePrefixMask default ((exactReverseAliceContext q.1).sideRank ⟨q.1.coordinate, exactReverseLeftSide_coordinate_mem q.1⟩).castSucc (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseLeftSide q.1) q) = finitePrefixMask default ((exactReverseAliceContext q.1).sideRank ⟨q.1.coordinate, exactReverseLeftSide_coordinate_mem q.1⟩).castSucc (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseLeftSide q.1) q') := by rcases q with ⟨seed, outcome⟩ rcases q' with ⟨seed', outcome'⟩ have hseed : seed = seed' := congrArg (fun r : ExactHistoryFlag X Y A B D => r.seed) same_history subst seed' have htuple := congrArg (exactHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D) same_history change (⟨seed, (exactRevealCode D seed (outcome.1, outcome.2.1), (fun j : {j : Fin n // j ∈ D} => outcome.2.2.1 j.val), (fun j : {j : Fin n // j ∈ D} => outcome.2.2.2 j.val))⟩ : ExactHistoryFlagTuple X Y A B D) = (⟨seed, (exactRevealCode D seed (outcome'.1, outcome'.2.1), (fun j : {j : Fin n // j ∈ D} => outcome'.2.2.1 j.val), (fun j : {j : Fin n // j ∈ D} => outcome'.2.2.2 j.val))⟩ : ExactHistoryFlagTuple X Y A B D) at htuple have hpair := eq_of_heq (Sigma.mk.inj htuple).2 have hreveal : exactRevealCode D seed (outcome.1, outcome.2.1) = exactRevealCode D seed (outcome'.1, outcome'.2.1) := congrArg Prod.fst hpair have hac := congrArg (fun r : ExactRevealHistory X Y D seed => r.aliceConditioned) hreveal have hbc := congrArg (fun r : ExactRevealHistory X Y D seed => r.bobConditioned) hreveal have hal := congrArg (fun r : ExactRevealHistory X Y D seed => r.aliceLeft) hreveal have hbr := congrArg (fun r : ExactRevealHistory X Y D seed => r.bobRight) hreveal have hbl := congrArg (fun r : ExactRevealHistory X Y D seed => r.bobLeftPrefix) hreveal have har := congrArg (fun r : ExactRevealHistory X Y D seed => r.aliceRightPrefix) hreveal let side := exactReverseLeftSide seed let context := exactReverseAliceContext seed let marker : Fin side.card := context.sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ have hmarker : marker.val = seed.leftCut.val := by exact exactReverseAliceContext_marked_rank seed have hfixed : (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome)).1 = (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome')).1 := by simp only [side, exactReverseAliceSourceProjection, exactReverseAliceContextAt_actual] apply Sigma.ext · rfl · apply heq_of_eq apply Prod.ext · exact hac apply Prod.ext · exact hbc apply Prod.ext · funext j by_cases hj : j.val = seed.coordinate · have hval : j.val.val = seed.coordinate.val := congrArg Subtype.val hj simpa [hval] using same_question · have hleft : j.val ∈ exactLeft seed.coordinate seed.partition := by have hmem : j.val ∈ insert seed.coordinate (exactLeft seed.coordinate seed.partition) := j.property exact (Finset.mem_insert.mp hmem).resolve_left hj exact congrFun hal ⟨j.val, hleft⟩ apply Prod.ext · funext j have hj : j.val ∈ exactRight seed.coordinate seed.partition := by simpa [exactReverseAliceContextAt, exactReverseAliceContext] using j.property exact congrFun hbr ⟨j.val, hj⟩ funext j have hj : j.val ∈ exactRightPrefix seed := by have hprefix : exactReverseContextOtherPrefix (exactReverseAliceContextAt (exactReverseLeftSide seed) seed) = exactRightPrefix seed := by rw [exactReverseAliceContextAt_actual, exactReverseAliceContext_otherPrefix] exact (Finset.ext_iff.mp hprefix j.val).mp j.property exact congrFun har ⟨j.val, hj⟩ apply Prod.ext · exact hfixed · funext k by_cases hk : k.val < marker.val · have hbefore : (context.sideRank.symm k).val ∈ exactLeftPrefix seed := by rw [← exactReverseAliceContext_prefix_before_marked seed] apply (exactOrderedSidePrefix_mem_iff side context.sideRank marker.castSucc (context.sideRank.symm k).val).mpr refine ⟨(context.sideRank.symm k).property, ?_⟩ change (context.sideRank (context.sideRank.symm k)).val < marker.val rw [Equiv.apply_symm_apply] exact hk have hy := congrFun hbl ⟨(context.sideRank.symm k).val, hbefore⟩ change outcome.2.1 (context.sideRank.symm k).val.val = outcome'.2.1 (context.sideRank.symm k).val.val at hy have hkcut : k.val < seed.leftCut.val := by rw [← hmarker] exact hk simpa [finitePrefixMask, exactReverseAliceSourceProjection, exactReverseAliceContextAt, side, context, marker, hkcut] using hy · have hkcut : ¬ k.val < seed.leftCut.val := by rw [← hmarker] exact hk simp [finitePrefixMask, exactReverseAliceSourceProjection, exactReverseAliceContextAt, hkcut] theorem exactReverseBobMaskedProjection_eq_of_history {n : ℕ} (D : Finset (Fin n)) (default : X) (q q' : ExactJointOutcome X Y A B D) (same_history : exactHistoryCode D q = exactHistoryCode D q') (same_question : q.2.2.1 q.1.coordinate.val = q'.2.2.1 q'.1.coordinate.val) : finitePrefixMask default ((exactReverseBobContext q.1).sideRank ⟨q.1.coordinate, exactReverseRightSide_coordinate_mem q.1⟩).castSucc (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseRightSide q.1) q) = finitePrefixMask default ((exactReverseBobContext q.1).sideRank ⟨q.1.coordinate, exactReverseRightSide_coordinate_mem q.1⟩).castSucc (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseRightSide q.1) q') := by rcases q with ⟨seed, outcome⟩ rcases q' with ⟨seed', outcome'⟩ have hseed : seed = seed' := congrArg (fun r : ExactHistoryFlag X Y A B D => r.seed) same_history subst seed' have htuple := congrArg (exactHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D) same_history change (⟨seed, (exactRevealCode D seed (outcome.1, outcome.2.1), (fun j : {j : Fin n // j ∈ D} => outcome.2.2.1 j.val), (fun j : {j : Fin n // j ∈ D} => outcome.2.2.2 j.val))⟩ : ExactHistoryFlagTuple X Y A B D) = (⟨seed, (exactRevealCode D seed (outcome'.1, outcome'.2.1), (fun j : {j : Fin n // j ∈ D} => outcome'.2.2.1 j.val), (fun j : {j : Fin n // j ∈ D} => outcome'.2.2.2 j.val))⟩ : ExactHistoryFlagTuple X Y A B D) at htuple have hpair := eq_of_heq (Sigma.mk.inj htuple).2 have hreveal : exactRevealCode D seed (outcome.1, outcome.2.1) = exactRevealCode D seed (outcome'.1, outcome'.2.1) := congrArg Prod.fst hpair have hac := congrArg (fun r : ExactRevealHistory X Y D seed => r.aliceConditioned) hreveal have hbc := congrArg (fun r : ExactRevealHistory X Y D seed => r.bobConditioned) hreveal have hal := congrArg (fun r : ExactRevealHistory X Y D seed => r.aliceLeft) hreveal have hbr := congrArg (fun r : ExactRevealHistory X Y D seed => r.bobRight) hreveal have hbl := congrArg (fun r : ExactRevealHistory X Y D seed => r.bobLeftPrefix) hreveal have har := congrArg (fun r : ExactRevealHistory X Y D seed => r.aliceRightPrefix) hreveal let side := exactReverseRightSide seed let context := exactReverseBobContext seed let marker : Fin side.card := context.sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ have hmarker : marker.val = seed.rightCut.val := by exact exactReverseBobContext_marked_rank seed have hfixed : (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome)).1 = (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome')).1 := by simp only [side, exactReverseBobSourceProjection, exactReverseBobContextAt_actual] apply Sigma.ext · rfl · apply heq_of_eq apply Prod.ext · exact hac apply Prod.ext · exact hbc apply Prod.ext · funext j by_cases hj : j.val = seed.coordinate · have hval : j.val.val = seed.coordinate.val := congrArg Subtype.val hj simpa [hval] using same_question · have hright : j.val ∈ exactRight seed.coordinate seed.partition := by have hmem : j.val ∈ insert seed.coordinate (exactRight seed.coordinate seed.partition) := j.property exact (Finset.mem_insert.mp hmem).resolve_left hj exact congrFun hbr ⟨j.val, hright⟩ apply Prod.ext · funext j have hj : j.val ∈ exactLeft seed.coordinate seed.partition := by simpa [exactReverseBobContextAt, exactReverseBobContext] using j.property exact congrFun hal ⟨j.val, hj⟩ funext j have hj : j.val ∈ exactLeftPrefix seed := by have hprefix : exactReverseContextOtherPrefix (exactReverseBobContextAt (exactReverseRightSide seed) seed) = exactLeftPrefix seed := by rw [exactReverseBobContextAt_actual, exactReverseBobContext_otherPrefix] exact (Finset.ext_iff.mp hprefix j.val).mp j.property exact congrFun hbl ⟨j.val, hj⟩ apply Prod.ext · exact hfixed · funext k by_cases hk : k.val < marker.val · have hbefore : (context.sideRank.symm k).val ∈ exactRightPrefix seed := by rw [← exactReverseBobContext_prefix_before_marked seed] apply (exactOrderedSidePrefix_mem_iff side context.sideRank marker.castSucc (context.sideRank.symm k).val).mpr refine ⟨(context.sideRank.symm k).property, ?_⟩ change (context.sideRank (context.sideRank.symm k)).val < marker.val rw [Equiv.apply_symm_apply] exact hk have hx := congrFun har ⟨(context.sideRank.symm k).val, hbefore⟩ change outcome.1 (context.sideRank.symm k).val.val = outcome'.1 (context.sideRank.symm k).val.val at hx have hkcut : k.val < seed.rightCut.val := by rw [← hmarker] exact hk simpa [finitePrefixMask, exactReverseBobSourceProjection, exactReverseBobContextAt, side, context, marker, hkcut] using hx · have hkcut : ¬ k.val < seed.rightCut.val := by rw [← hmarker] exact hk simp [finitePrefixMask, exactReverseBobSourceProjection, exactReverseBobContextAt, hkcut] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem groupedMass_product_injective_seed {K Ω C T : Type*} [Fintype K] [Fintype Ω] [Fintype C] [Fintype T] [DecidableEq C] [DecidableEq T] (code : K → C) (injective : Function.Injective code) (projection : K → Ω → T) (seedWeight : K → ℝ) (outcomeWeight : Ω → ℝ) (seed : K) (target : T) : groupedMass (fun q : K × Ω => (code q.1, projection q.1 q.2)) (fun q : K × Ω => seedWeight q.1 * outcomeWeight q.2) (code seed, target) = seedWeight seed * groupedMass (projection seed) outcomeWeight target := by classical unfold groupedMass rw [Finset.sum_filter, Fintype.sum_prod_type, Finset.sum_filter, Finset.mul_sum] simp [injective.eq_iff] rw [Finset.sum_eq_single seed] · simp · intro other _ different simp [different] · simp variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem jointConditional_groupedMass_eq_of_fiber {Ω C D V : Type*} [Fintype Ω] [Fintype C] [Fintype D] [Fintype V] [DecidableEq (C × V)] [DecidableEq (D × V)] (mass : Ω → ℝ) (left : Ω → C) (right : Ω → D) (next : Ω → V) (leftTarget : C) (rightTarget : D) (same_fiber : ∀ outcome : Ω, left outcome = leftTarget ↔ right outcome = rightTarget) : jointConditional (groupedMass (fun outcome => (left outcome, next outcome)) mass) leftTarget = jointConditional (groupedMass (fun outcome => (right outcome, next outcome)) mass) rightTarget := by classical have hatom (value : V) : groupedMass (fun outcome => (left outcome, next outcome)) mass (leftTarget, value) = groupedMass (fun outcome => (right outcome, next outcome)) mass (rightTarget, value) := by unfold groupedMass apply Finset.sum_congr · ext outcome simp only [Finset.mem_filter, Finset.mem_univ, true_and, Prod.mk.injEq] exact and_congr_left (fun _ => same_fiber outcome) · intro outcome _ rfl have hmarginal : jointFirstMarginal (groupedMass (fun outcome => (left outcome, next outcome)) mass) leftTarget = jointFirstMarginal (groupedMass (fun outcome => (right outcome, next outcome)) mass) rightTarget := by unfold jointFirstMarginal apply Finset.sum_congr rfl intro value _ exact hatom value funext value unfold jointConditional rw [hatom value, hmarginal] variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseAliceMarkedHistoryContext (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : Y) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) : ExactReverseAliceNextContext X Y A B D (exactReverseLeftSide seed) := let side := exactReverseLeftSide seed let marker := (exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ let projection := exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome) finitePrefixMask default marker.castSucc ((projection.1, repeatedConditionedAnswerFlag G n S D outcome), projection.2) def exactReverseBobMarkedHistoryContext (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : X) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) : ExactReverseBobNextContext X Y A B D (exactReverseRightSide seed) := let side := exactReverseRightSide seed let marker := (exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ let projection := exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome) finitePrefixMask default marker.castSucc ((projection.1, repeatedConditionedAnswerFlag G n S D outcome), projection.2) theorem exactConditionedAnswerFlag_eq_of_history (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (q q' : ExactJointOutcome X Y A B D) (same_history : exactHistoryCode D q = exactHistoryCode D q') : repeatedConditionedAnswerFlag G n S D q.2 = repeatedConditionedAnswerFlag G n S D q'.2 := by apply Prod.ext · exact congrArg (fun r : ExactHistoryFlag X Y A B D => r.aliceAnswer) same_history · exact congrArg (fun r : ExactHistoryFlag X Y A B D => r.bobAnswer) same_history theorem exactReverseAliceMarkedHistoryContext_eq_of_history (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : Y) (seed : ExactRemainingSeed D) (outcome outcome' : ExactOutcome X Y A B n) (same_history : exactHistoryCode D (seed, outcome) = exactHistoryCode D (seed, outcome')) (same_question : outcome.1 seed.coordinate.val = outcome'.1 seed.coordinate.val) : exactReverseAliceMarkedHistoryContext G n S D default seed outcome = exactReverseAliceMarkedHistoryContext G n S D default seed outcome' := by have hmask := exactReverseAliceMaskedProjection_eq_of_history (X := X) (Y := Y) (A := A) (B := B) D default (seed, outcome) (seed, outcome') same_history same_question have hflag := exactConditionedAnswerFlag_eq_of_history G n S D (seed, outcome) (seed, outcome') same_history have hfixed : (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseLeftSide seed) (seed, outcome)).1 = (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseLeftSide seed) (seed, outcome')).1 := by have h := congrArg (fun t : ExactReverseAliceFixedInformation X Y D (exactReverseLeftSide seed) × (Fin (exactReverseLeftSide seed).card → Y) => t.1) hmask simpa only [finitePrefixMask] using h have hprefix : (finitePrefixMask default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩).castSucc (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseLeftSide seed) (seed, outcome))).2 = (finitePrefixMask default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩).castSucc (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseLeftSide seed) (seed, outcome'))).2 := by exact congrArg (fun t : ExactReverseAliceFixedInformation X Y D (exactReverseLeftSide seed) × (Fin (exactReverseLeftSide seed).card → Y) => t.2) hmask unfold exactReverseAliceMarkedHistoryContext dsimp apply Prod.ext · apply Prod.ext · exact hfixed · exact hflag · exact hprefix theorem exactReverseBobMarkedHistoryContext_eq_of_history (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : X) (seed : ExactRemainingSeed D) (outcome outcome' : ExactOutcome X Y A B n) (same_history : exactHistoryCode D (seed, outcome) = exactHistoryCode D (seed, outcome')) (same_question : outcome.2.1 seed.coordinate.val = outcome'.2.1 seed.coordinate.val) : exactReverseBobMarkedHistoryContext G n S D default seed outcome = exactReverseBobMarkedHistoryContext G n S D default seed outcome' := by have hmask := exactReverseBobMaskedProjection_eq_of_history (X := X) (Y := Y) (A := A) (B := B) D default (seed, outcome) (seed, outcome') same_history same_question have hflag := exactConditionedAnswerFlag_eq_of_history G n S D (seed, outcome) (seed, outcome') same_history have hfixed : (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseRightSide seed) (seed, outcome)).1 = (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseRightSide seed) (seed, outcome')).1 := by have h := congrArg (fun t : ExactReverseBobFixedInformation X Y D (exactReverseRightSide seed) × (Fin (exactReverseRightSide seed).card → X) => t.1) hmask simpa only [finitePrefixMask] using h have hprefix : (finitePrefixMask default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩).castSucc (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseRightSide seed) (seed, outcome))).2 = (finitePrefixMask default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩).castSucc (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D (exactReverseRightSide seed) (seed, outcome'))).2 := by exact congrArg (fun t : ExactReverseBobFixedInformation X Y D (exactReverseRightSide seed) × (Fin (exactReverseRightSide seed).card → X) => t.2) hmask unfold exactReverseBobMarkedHistoryContext dsimp apply Prod.ext · apply Prod.ext · exact hfixed · exact hflag · exact hprefix theorem exactReverseAlice_history_of_marked_context (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : Y) (seed : ExactRemainingSeed D) (outcome outcome' : ExactOutcome X Y A B n) (same_context : exactReverseAliceMarkedHistoryContext G n S D default seed outcome = exactReverseAliceMarkedHistoryContext G n S D default seed outcome') : outcome.1 seed.coordinate.val = outcome'.1 seed.coordinate.val ∧ exactHistoryCode D (seed, outcome) = exactHistoryCode D (seed, outcome') := by let side := exactReverseLeftSide seed let context := exactReverseAliceContext seed let marker : Fin side.card := context.sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ have hfixed : (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome)).1 = (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome')).1 := by have h := congrArg (fun t : ExactReverseAliceNextContext X Y A B D (exactReverseLeftSide seed) => t.1.1) same_context simpa only [exactReverseAliceMarkedHistoryContext, finitePrefixMask, side] using h have hflag : repeatedConditionedAnswerFlag G n S D outcome = repeatedConditionedAnswerFlag G n S D outcome' := by have h := congrArg (fun t : ExactReverseAliceNextContext X Y A B D (exactReverseLeftSide seed) => t.1.2) same_context simpa only [exactReverseAliceMarkedHistoryContext, finitePrefixMask] using h have hprefix : (finitePrefixMask default marker.castSucc (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome))).2 = (finitePrefixMask default marker.castSucc (exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome'))).2 := by have h := congrArg (fun t : ExactReverseAliceNextContext X Y A B D (exactReverseLeftSide seed) => t.2) same_context simpa only [exactReverseAliceMarkedHistoryContext, finitePrefixMask, side, context, marker] using h have hfields := eq_of_heq (Sigma.mk.inj hfixed).2 have hac := congrArg (fun t => t.1) hfields have hbc := congrArg (fun t => t.2.1) hfields have hside := congrArg (fun t => t.2.2.1) hfields have hother := congrArg (fun t => t.2.2.2.1) hfields have hoppositePrefix := congrArg (fun t => t.2.2.2.2) hfields have hquestion : outcome.1 seed.coordinate.val = outcome'.1 seed.coordinate.val := by have h := congrFun hside ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ exact h have hreveal : exactRevealCode D seed (outcome.1, outcome.2.1) = exactRevealCode D seed (outcome'.1, outcome'.2.1) := by apply (exactRevealHistoryEquiv (X := X) (Y := Y) D seed).injective apply Prod.ext · exact hac apply Prod.ext · exact hbc apply Prod.ext · funext j have hj : j.val ∈ side := by change j.val ∈ insert seed.coordinate (exactLeft seed.coordinate seed.partition) exact Finset.mem_insert_of_mem j.property exact congrFun hside ⟨j.val, hj⟩ apply Prod.ext · funext j have hotherSide : (exactReverseAliceContextAt side seed).otherSide = exactRight seed.coordinate seed.partition := by change (exactReverseAliceContextAt (exactReverseLeftSide seed) seed).otherSide = _ rw [exactReverseAliceContextAt_actual] rfl have hj : j.val ∈ (exactReverseAliceContextAt side seed).otherSide := (Finset.ext_iff.mp hotherSide j.val).mpr j.property exact congrFun hother ⟨j.val, hj⟩ apply Prod.ext · funext j have hbefore : j.val ∈ exactReverseContextPrefixBefore context marker := by change j.val ∈ exactReverseContextPrefixBefore (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) rw [exactReverseAliceContext_prefix_before_marked] exact j.property have hparts := (exactOrderedSidePrefix_mem_iff side context.sideRank marker.castSucc j.val).mp (by simpa [exactReverseContextPrefixBefore] using hbefore) let position : Fin side.card := context.sideRank ⟨j.val, hparts.1⟩ have hlt : position.val < marker.val := by simpa [position] using hparts.2 have hltCut : position.val < seed.leftCut.val := by calc position.val < marker.val := hlt _ = seed.leftCut.val := by exact exactReverseAliceContext_marked_rank seed have h := congrFun hprefix position change outcome.2.1 j.val.val = outcome'.2.1 j.val.val simpa [finitePrefixMask, exactReverseAliceSourceProjection, exactReverseAliceContextAt, side, context, marker, position, hlt, hltCut] using h · funext j have hotherPrefix : exactReverseContextOtherPrefix (exactReverseAliceContextAt side seed) = exactRightPrefix seed := by change exactReverseContextOtherPrefix (exactReverseAliceContextAt (exactReverseLeftSide seed) seed) = _ rw [exactReverseAliceContextAt_actual, exactReverseAliceContext_otherPrefix] have hj : j.val ∈ exactReverseContextOtherPrefix (exactReverseAliceContextAt side seed) := (Finset.ext_iff.mp hotherPrefix j.val).mpr j.property exact congrFun hoppositePrefix ⟨j.val, hj⟩ refine ⟨hquestion, ?_⟩ apply (exactHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D).injective change (⟨seed, (exactRevealCode D seed (outcome.1, outcome.2.1), (fun j : {j : Fin n // j ∈ D} => outcome.2.2.1 j.val), (fun j : {j : Fin n // j ∈ D} => outcome.2.2.2 j.val))⟩ : ExactHistoryFlagTuple X Y A B D) = (⟨seed, (exactRevealCode D seed (outcome'.1, outcome'.2.1), (fun j : {j : Fin n // j ∈ D} => outcome'.2.2.1 j.val), (fun j : {j : Fin n // j ∈ D} => outcome'.2.2.2 j.val))⟩ : ExactHistoryFlagTuple X Y A B D) apply Sigma.ext · rfl · apply heq_of_eq apply Prod.ext · exact hreveal apply Prod.ext · exact congrArg Prod.fst hflag · exact congrArg Prod.snd hflag theorem exactReverseBob_history_of_marked_context (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : X) (seed : ExactRemainingSeed D) (outcome outcome' : ExactOutcome X Y A B n) (same_context : exactReverseBobMarkedHistoryContext G n S D default seed outcome = exactReverseBobMarkedHistoryContext G n S D default seed outcome') : outcome.2.1 seed.coordinate.val = outcome'.2.1 seed.coordinate.val ∧ exactHistoryCode D (seed, outcome) = exactHistoryCode D (seed, outcome') := by let side := exactReverseRightSide seed let context := exactReverseBobContext seed let marker : Fin side.card := context.sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ have hfixed : (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome)).1 = (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome')).1 := by have h := congrArg (fun t : ExactReverseBobNextContext X Y A B D (exactReverseRightSide seed) => t.1.1) same_context simpa only [exactReverseBobMarkedHistoryContext, finitePrefixMask, side] using h have hflag : repeatedConditionedAnswerFlag G n S D outcome = repeatedConditionedAnswerFlag G n S D outcome' := by have h := congrArg (fun t : ExactReverseBobNextContext X Y A B D (exactReverseRightSide seed) => t.1.2) same_context simpa only [exactReverseBobMarkedHistoryContext, finitePrefixMask] using h have hprefix : (finitePrefixMask default marker.castSucc (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome))).2 = (finitePrefixMask default marker.castSucc (exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side (seed, outcome'))).2 := by have h := congrArg (fun t : ExactReverseBobNextContext X Y A B D (exactReverseRightSide seed) => t.2) same_context simpa only [exactReverseBobMarkedHistoryContext, finitePrefixMask, side, context, marker] using h have hfields := eq_of_heq (Sigma.mk.inj hfixed).2 have hac := congrArg (fun t => t.1) hfields have hbc := congrArg (fun t => t.2.1) hfields have hside := congrArg (fun t => t.2.2.1) hfields have hother := congrArg (fun t => t.2.2.2.1) hfields have hoppositePrefix := congrArg (fun t => t.2.2.2.2) hfields have hquestion : outcome.2.1 seed.coordinate.val = outcome'.2.1 seed.coordinate.val := by have h := congrFun hside ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ exact h have hreveal : exactRevealCode D seed (outcome.1, outcome.2.1) = exactRevealCode D seed (outcome'.1, outcome'.2.1) := by apply (exactRevealHistoryEquiv (X := X) (Y := Y) D seed).injective apply Prod.ext · exact hac apply Prod.ext · exact hbc apply Prod.ext · funext j have hotherSide : (exactReverseBobContextAt side seed).otherSide = exactLeft seed.coordinate seed.partition := by change (exactReverseBobContextAt (exactReverseRightSide seed) seed).otherSide = _ rw [exactReverseBobContextAt_actual] rfl have hj : j.val ∈ (exactReverseBobContextAt side seed).otherSide := (Finset.ext_iff.mp hotherSide j.val).mpr j.property exact congrFun hother ⟨j.val, hj⟩ apply Prod.ext · funext j have hj : j.val ∈ side := by change j.val ∈ insert seed.coordinate (exactRight seed.coordinate seed.partition) exact Finset.mem_insert_of_mem j.property exact congrFun hside ⟨j.val, hj⟩ apply Prod.ext · funext j have hotherPrefix : exactReverseContextOtherPrefix (exactReverseBobContextAt side seed) = exactLeftPrefix seed := by change exactReverseContextOtherPrefix (exactReverseBobContextAt (exactReverseRightSide seed) seed) = _ rw [exactReverseBobContextAt_actual, exactReverseBobContext_otherPrefix] have hj : j.val ∈ exactReverseContextOtherPrefix (exactReverseBobContextAt side seed) := (Finset.ext_iff.mp hotherPrefix j.val).mpr j.property exact congrFun hoppositePrefix ⟨j.val, hj⟩ · funext j have hbefore : j.val ∈ exactReverseContextPrefixBefore context marker := by change j.val ∈ exactReverseContextPrefixBefore (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) rw [exactReverseBobContext_prefix_before_marked] exact j.property have hparts := (exactOrderedSidePrefix_mem_iff side context.sideRank marker.castSucc j.val).mp (by simpa [exactReverseContextPrefixBefore] using hbefore) let position : Fin side.card := context.sideRank ⟨j.val, hparts.1⟩ have hlt : position.val < marker.val := by simpa [position] using hparts.2 have hltCut : position.val < seed.rightCut.val := by calc position.val < marker.val := hlt _ = seed.rightCut.val := by exact exactReverseBobContext_marked_rank seed have h := congrFun hprefix position change outcome.1 j.val.val = outcome'.1 j.val.val simpa [finitePrefixMask, exactReverseBobSourceProjection, exactReverseBobContextAt, side, context, marker, position, hlt, hltCut] using h refine ⟨hquestion, ?_⟩ apply (exactHistoryFlagEquiv (X := X) (Y := Y) (A := A) (B := B) D).injective change (⟨seed, (exactRevealCode D seed (outcome.1, outcome.2.1), (fun j : {j : Fin n // j ∈ D} => outcome.2.2.1 j.val), (fun j : {j : Fin n // j ∈ D} => outcome.2.2.2 j.val))⟩ : ExactHistoryFlagTuple X Y A B D) = (⟨seed, (exactRevealCode D seed (outcome'.1, outcome'.2.1), (fun j : {j : Fin n // j ∈ D} => outcome'.2.2.1 j.val), (fun j : {j : Fin n // j ∈ D} => outcome'.2.2.2 j.val))⟩ : ExactHistoryFlagTuple X Y A B D) apply Sigma.ext · rfl · apply heq_of_eq apply Prod.ext · exact hreveal apply Prod.ext · exact congrArg Prod.fst hflag · exact congrArg Prod.snd hflag theorem exactReverseAliceMarkedHistoryContext_fiber_iff (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : Y) (seed : ExactRemainingSeed D) (outcome reference : ExactOutcome X Y A B n) : (exactReverseAliceMarkedHistoryContext G n S D default seed outcome = exactReverseAliceMarkedHistoryContext G n S D default seed reference) ↔ (outcome.1 seed.coordinate.val, exactHistoryCode D (seed, outcome)) = (reference.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) := by constructor · intro same obtain ⟨hquestion, hhistory⟩ := exactReverseAlice_history_of_marked_context G n S D default seed outcome reference same exact Prod.ext hquestion hhistory · intro same apply exactReverseAliceMarkedHistoryContext_eq_of_history G n S D default seed outcome reference · exact congrArg Prod.snd same · exact congrArg Prod.fst same theorem exactReverseBobMarkedHistoryContext_fiber_iff (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : X) (seed : ExactRemainingSeed D) (outcome reference : ExactOutcome X Y A B n) : (exactReverseBobMarkedHistoryContext G n S D default seed outcome = exactReverseBobMarkedHistoryContext G n S D default seed reference) ↔ (outcome.2.1 seed.coordinate.val, exactHistoryCode D (seed, outcome)) = (reference.2.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) := by constructor · intro same obtain ⟨hquestion, hhistory⟩ := exactReverseBob_history_of_marked_context G n S D default seed outcome reference same exact Prod.ext hquestion hhistory · intro same apply exactReverseBobMarkedHistoryContext_eq_of_history G n S D default seed outcome reference · exact congrArg Prod.snd same · exact congrArg Prod.fst same theorem exactReverseAliceMarkedPosteriorConditional_eq_sourceFiber (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : Y) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseAliceMarkedHistoryContext G n S D default seed outcome, outcome.2.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => ((outcome.1 seed.coordinate.val, exactHistoryCode D (seed, outcome)), outcome.2.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (reference.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) := by apply jointConditional_groupedMass_eq_of_fiber (repeatedConditionedOutcomeLaw G n S D) (fun outcome : ExactOutcome X Y A B n => exactReverseAliceMarkedHistoryContext G n S D default seed outcome) (fun outcome : ExactOutcome X Y A B n => (outcome.1 seed.coordinate.val, exactHistoryCode D (seed, outcome))) (fun outcome : ExactOutcome X Y A B n => outcome.2.1 seed.coordinate.val) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) (reference.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) intro outcome exact exactReverseAliceMarkedHistoryContext_fiber_iff G n S D default seed outcome reference theorem exactReverseBobMarkedPosteriorConditional_eq_sourceFiber (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : X) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseBobMarkedHistoryContext G n S D default seed outcome, outcome.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (exactReverseBobMarkedHistoryContext G n S D default seed reference) = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => ((outcome.2.1 seed.coordinate.val, exactHistoryCode D (seed, outcome)), outcome.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (reference.2.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) := by apply jointConditional_groupedMass_eq_of_fiber (repeatedConditionedOutcomeLaw G n S D) (fun outcome : ExactOutcome X Y A B n => exactReverseBobMarkedHistoryContext G n S D default seed outcome) (fun outcome : ExactOutcome X Y A B n => (outcome.2.1 seed.coordinate.val, exactHistoryCode D (seed, outcome))) (fun outcome : ExactOutcome X Y A B n => outcome.1 seed.coordinate.val) (exactReverseBobMarkedHistoryContext G n S D default seed reference) (reference.2.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) intro outcome exact exactReverseBobMarkedHistoryContext_fiber_iff G n S D default seed outcome reference end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem reweightedSeedPrefixPrior_as_flagged_pushforward {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (t : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V)) : reweightedSeedPrefixPrior seedLaw G n S D projection t = groupedMass (fun q : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) => (((projection q.2).1, q.1), (projection q.2).2)) (fun q : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) => finiteUniformWeight (ConditionedAnswerFlag A B D) * (reweightedSeedPriorEventLaw seedLaw G n S).weight q.2) t := by classical change groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight (t.1.1, t.2) * finiteUniformWeight (ConditionedAnswerFlag A B D) = _ calc groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight (t.1.1, t.2) * finiteUniformWeight (ConditionedAnswerFlag A B D) = finiteUniformWeight (ConditionedAnswerFlag A B D) * groupedMass projection (reweightedSeedPriorEventLaw seedLaw G n S).weight (t.1.1, t.2) := by ring _ = groupedMass (fun q : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) => (q.1, projection q.2)) (fun q : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) => finiteUniformWeight (ConditionedAnswerFlag A B D) * (reweightedSeedPriorEventLaw seedLaw G n S).weight q.2) (t.1.2, (t.1.1, t.2)) := by symm exact groupedMass_product_injective_seed (fun z : ConditionedAnswerFlag A B D => z) (fun _ _ same => same) (fun (_ : ConditionedAnswerFlag A B D) q => projection q) (fun _ : ConditionedAnswerFlag A B D => finiteUniformWeight (ConditionedAnswerFlag A B D)) (reweightedSeedPriorEventLaw seedLaw G n S).weight t.1.2 (t.1.1, t.2) _ = groupedMass (fun q : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) => (((projection q.2).1, q.1), (projection q.2).2)) (fun q : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) => finiteUniformWeight (ConditionedAnswerFlag A B D) * (reweightedSeedPriorEventLaw seedLaw G n S).weight q.2) t := by unfold groupedMass congr 1 ext q simp only [Finset.mem_filter, Finset.mem_univ, true_and] constructor · intro same have hflag : q.1 = t.1.2 := congrArg Prod.fst same have hprojection : projection q.2 = (t.1.1, t.2) := congrArg Prod.snd same apply Prod.ext · apply Prod.ext · exact congrArg (fun u : Ω × (Fin h → V) => u.1) hprojection · exact hflag · exact congrArg (fun u : Ω × (Fin h → V) => u.2) hprojection · intro same have hfixed : ((projection q.2).1, q.1) = t.1 := congrArg Prod.fst same have hsequence : (projection q.2).2 = t.2 := congrArg Prod.snd same apply Prod.ext · exact congrArg (fun u : Ω × ConditionedAnswerFlag A B D => u.2) hfixed · apply Prod.ext · exact congrArg (fun u : Ω × ConditionedAnswerFlag A B D => u.1) hfixed · exact hsequence theorem reweightedSeedPrefixPrior_next_flagged_pushforward {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (default : V) (k : Fin h) (target : ((Ω × ConditionedAnswerFlag A B D) × (Fin h → V)) × V) : groupedMass (exactPrefixNextCode default k) (reweightedSeedPrefixPrior seedLaw G n S D projection) target = groupedMass (fun q : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) => exactPrefixNextCode default k (((projection q.2).1, q.1), (projection q.2).2)) (fun q : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) => finiteUniformWeight (ConditionedAnswerFlag A B D) * (reweightedSeedPriorEventLaw seedLaw G n S).weight q.2) target := by classical let augmented : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) → (Ω × ConditionedAnswerFlag A B D) × (Fin h → V) := fun q => (((projection q.2).1, q.1), (projection q.2).2) let weight : ConditionedAnswerFlag A B D × (K × ExactOutcome X Y A B n) → ℝ := fun q => finiteUniformWeight (ConditionedAnswerFlag A B D) * (reweightedSeedPriorEventLaw seedLaw G n S).weight q.2 have hprior : reweightedSeedPrefixPrior seedLaw G n S D projection = groupedMass augmented weight := by funext t exact reweightedSeedPrefixPrior_as_flagged_pushforward seedLaw G n S D projection t rw [hprior] exact congrFun (groupedMass_comp augmented (exactPrefixNextCode default k) weight) target end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem finiteGroupedExpectation_eq_atom_sum {Ω C : Type*} [Fintype Ω] [Fintype C] [DecidableEq C] (code : Ω → C) (mass : Ω → ℝ) (value : C → ℝ) : (∑ target : C, groupedMass code mass target * value target) = ∑ outcome : Ω, mass outcome * value (code outcome) := by classical unfold groupedMass calc (∑ target : C, (∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => code outcome = target), mass outcome) * value target) = ∑ target : C, ∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => code outcome = target), mass outcome * value (code outcome) := by apply Finset.sum_congr rfl intro target _ rw [Finset.sum_mul] apply Finset.sum_congr rfl intro outcome houtcome have hcode : code outcome = target := (Finset.mem_filter.mp houtcome).2 rw [hcode] _ = ∑ outcome : Ω, mass outcome * value (code outcome) := Finset.sum_fiberwise Finset.univ code (fun outcome => mass outcome * value (code outcome)) theorem jointFirstMarginal_groupedContextNext {Ω C V : Type*} [Fintype Ω] [Fintype C] [Fintype V] [DecidableEq C] [DecidableEq (C × V)] (context : Ω → C) (next : Ω → V) (mass : Ω → ℝ) (target : C) : jointFirstMarginal (groupedMass (fun outcome => (context outcome, next outcome)) mass) target = groupedMass context mass target := by classical unfold jointFirstMarginal groupedMass calc (∑ value : V, ∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => (context outcome, next outcome) = (target, value)), mass outcome) = ∑ value : V, ∑ outcome ∈ ((Finset.univ.filter fun outcome : Ω => context outcome = target).filter fun outcome => next outcome = value), mass outcome := by apply Finset.sum_congr rfl intro value _ congr 1 ext outcome simp [Prod.mk.injEq] _ = ∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => context outcome = target), mass outcome := Finset.sum_fiberwise (Finset.univ.filter fun outcome : Ω => context outcome = target) next mass theorem finiteNextInformation_eq_atom_sum {Ω C V : Type*} [Fintype Ω] [Fintype C] [Fintype V] [DecidableEq C] [DecidableEq (C × V)] (context : Ω → C) (next : Ω → V) (mass : Ω → ℝ) (reference : C → V → ℝ) : (∑ target : C, jointFirstMarginal (groupedMass (fun outcome => (context outcome, next outcome)) mass) target * finiteRelativeEntropy (jointConditional (groupedMass (fun outcome => (context outcome, next outcome)) mass) target) (reference target)) = ∑ outcome : Ω, mass outcome * finiteRelativeEntropy (jointConditional (groupedMass (fun source => (context source, next source)) mass) (context outcome)) (reference (context outcome)) := by simp_rw [jointFirstMarginal_groupedContextNext context next mass] exact finiteGroupedExpectation_eq_atom_sum context mass (fun target => finiteRelativeEntropy (jointConditional (groupedMass (fun outcome => (context outcome, next outcome)) mass) target) (reference target)) theorem jointAtom_eq_zero_of_firstMarginal_zero {I V : Type*} [Fintype I] [Fintype V] (mass : I × V → ℝ) (nonnegative : ∀ point, 0 ≤ mass point) (index : I) (zero : jointFirstMarginal mass index = 0) (value : V) : mass (index, value) = 0 := by unfold jointFirstMarginal at zero exact (Finset.sum_eq_zero_iff_of_nonneg (fun value _ => nonnegative (index, value))).mp zero value (Finset.mem_univ value) theorem nestedFirstMarginal_mul_conditional {I R V : Type*} [Fintype I] [Fintype R] [Fintype V] (mass : I × (R × V) → ℝ) (nonnegative : ∀ point, 0 ≤ mass point) (index : I) (history : R) : jointFirstMarginal mass index * jointFirstMarginal (jointConditional mass index) history = jointFirstMarginal (fun point : (I × R) × V => mass (point.1.1, (point.1.2, point.2))) (index, history) := by unfold jointFirstMarginal jointConditional change (∑ point : R × V, mass (index, point)) * (∑ value : V, mass (index, (history, value)) / (∑ point : R × V, mass (index, point))) = ∑ value : V, mass (index, (history, value)) rw [← Finset.sum_div] by_cases houter : (∑ point : R × V, mass (index, point)) = 0 · have hinner : (∑ value : V, mass (index, (history, value))) = 0 := by apply Finset.sum_eq_zero intro value _ exact jointAtom_eq_zero_of_firstMarginal_zero mass nonnegative index houter (history, value) simp [houter, hinner] · field_simp [houter] theorem nestedConditional_eq_flat {I R V : Type*} [Fintype I] [Fintype R] [Fintype V] (mass : I × (R × V) → ℝ) (nonnegative : ∀ point, 0 ≤ mass point) (index : I) (history : R) : jointConditional (jointConditional mass index) history = jointConditional (fun point : (I × R) × V => mass (point.1.1, (point.1.2, point.2))) (index, history) := by funext value unfold jointConditional jointFirstMarginal rw [← Finset.sum_div] by_cases houter : (∑ point : R × V, mass (index, point)) = 0 · have hatom : mass (index, (history, value)) = 0 := jointAtom_eq_zero_of_firstMarginal_zero mass nonnegative index houter (history, value) simp [houter, hatom] · by_cases hhistory : (∑ v : V, mass (index, (history, v))) = 0 · have hatom : mass (index, (history, value)) = 0 := (Finset.sum_eq_zero_iff_of_nonneg (fun v _ => nonnegative (index, (history, v)))).mp hhistory value (Finset.mem_univ value) simp [hatom, hhistory] · field_simp [houter, hhistory] theorem finiteNestedNextInformation_eq_atom_sum {I R V : Type*} [Fintype I] [Fintype R] [Fintype V] (mass : I × (R × V) → ℝ) (nonnegative : ∀ point, 0 ≤ mass point) (reference : I → V → ℝ) : (∑ index : I, jointFirstMarginal mass index * (∑ history : R, jointFirstMarginal (jointConditional mass index) history * finiteRelativeEntropy (jointConditional (jointConditional mass index) history) (reference index))) = ∑ point : I × (R × V), mass point * finiteRelativeEntropy (jointConditional (fun atom : (I × R) × V => mass (atom.1.1, (atom.1.2, atom.2))) (point.1, point.2.1)) (reference point.1) := by classical simp_rw [Finset.mul_sum] simp_rw [← mul_assoc, nestedFirstMarginal_mul_conditional mass nonnegative, nestedConditional_eq_flat mass nonnegative] let flat : (I × R) × V → ℝ := fun atom => mass (atom.1.1, (atom.1.2, atom.2)) let score : I × R → ℝ := fun target => finiteRelativeEntropy (jointConditional flat target) (reference target.1) have h := finiteGroupedExpectation_eq_atom_sum (fun atom : (I × R) × V => atom.1) flat score have hfirst (target : I × R) : groupedMass (fun atom : (I × R) × V => atom.1) flat target = jointFirstMarginal flat target := by exact congrFun (groupedMass_first flat) target simp_rw [hfirst] at h change (∑ index : I, ∑ history : R, jointFirstMarginal flat (index, history) * score (index, history)) = _ calc (∑ index : I, ∑ history : R, jointFirstMarginal flat (index, history) * score (index, history)) = ∑ target : I × R, jointFirstMarginal flat target * score target := by rw [Fintype.sum_prod_type] _ = ∑ atom : (I × R) × V, flat atom * score atom.1 := h _ = ∑ point : I × (R × V), mass point * finiteRelativeEntropy (jointConditional (fun atom : (I × R) × V => mass (atom.1.1, (atom.1.2, atom.2))) (point.1, point.2.1)) (reference point.1) := by simp only [flat, score, Fintype.sum_prod_type] variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem reweightedSeedPrefixJoint_as_actual_flagged_pushforward {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (target : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V)) : reweightedSeedPrefixJoint seedLaw G n S D projection target = groupedMass (fun point : K × ExactOutcome X Y A B n => (((projection point).1, repeatedConditionedAnswerFlag G n S D point.2), (projection point).2)) (reweightedSeedPosterior seedLaw G n S D) target := by classical unfold reweightedSeedPrefixJoint reweightedSeedFlaggedProjectionLaw groupedMass apply Finset.sum_congr · ext point simp only [Finset.mem_filter, Finset.mem_univ, true_and, exactSourcePrefixFlagEquiv] change ((projection point, repeatedConditionedAnswerFlag G n S D point.2) = ((target.1.1, target.2), target.1.2)) ↔ (((projection point).1, repeatedConditionedAnswerFlag G n S D point.2), (projection point).2) = target constructor · intro same have hprojection : projection point = (target.1.1, target.2) := congrArg (fun t : (Ω × (Fin h → V)) × ConditionedAnswerFlag A B D => t.1) same have hflag : repeatedConditionedAnswerFlag G n S D point.2 = target.1.2 := congrArg (fun t : (Ω × (Fin h → V)) × ConditionedAnswerFlag A B D => t.2) same apply Prod.ext · apply Prod.ext · exact congrArg (fun t : Ω × (Fin h → V) => t.1) hprojection · exact hflag · exact congrArg (fun t : Ω × (Fin h → V) => t.2) hprojection · intro same have hfixed : ((projection point).1, repeatedConditionedAnswerFlag G n S D point.2) = target.1 := congrArg (fun t : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V) => t.1) same have hsequence : (projection point).2 = target.2 := congrArg (fun t : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V) => t.2) same apply Prod.ext · apply Prod.ext · exact congrArg (fun t : Ω × ConditionedAnswerFlag A B D => t.1) hfixed · exact hsequence · exact congrArg (fun t : Ω × ConditionedAnswerFlag A B D => t.2) hfixed · intro point _ rfl theorem exactAliceSourceConditionalInformation_eq_atom_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactAliceSourceConditionalInformation G n S D base = ∑ point : (SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y), exactAliceInformationPosterior G n S D point * finiteRelativeEntropy (jointConditional (fun atom : ((SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D) × Y => exactAliceInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) (point.1, point.2.1)) (G.conditionalYGivenX point.1.2) := by have hnonnegative : ∀ point, 0 ≤ exactAliceInformationPosterior G n S D point := by intro point exact exactLocallySampleableLaw_nonneg G n S D positive ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm point) calc exactAliceSourceConditionalInformation G n S D base = ∑ index : SourceRemainingCoordinate D × X, jointFirstMarginal (exactAliceInformationPosterior G n S D) index * (∑ history : ExactHistoryFlag X Y A B D, jointFirstMarginal (jointConditional (exactAliceInformationPosterior G n S D) index) history * finiteRelativeEntropy (jointConditional (jointConditional (exactAliceInformationPosterior G n S D) index) history) (G.conditionalYGivenX index.2)) := exactAliceSourceConditionalInformation_eq_question G n S D remaining positive base _ = _ := finiteNestedNextInformation_eq_atom_sum (exactAliceInformationPosterior G n S D) hnonnegative (fun index : SourceRemainingCoordinate D × X => G.conditionalYGivenX index.2) theorem exactBobSourceConditionalInformation_eq_atom_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactBobSourceConditionalInformation G n S D base = ∑ point : (SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X), exactBobInformationPosterior G n S D point * finiteRelativeEntropy (jointConditional (fun atom : ((SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D) × X => exactBobInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) (point.1, point.2.1)) (G.conditionalXGivenY point.1.2) := by have hnonnegative : ∀ point, 0 ≤ exactBobInformationPosterior G n S D point := by intro point exact exactLocallySampleableLaw_nonneg G n S D positive ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm point) calc exactBobSourceConditionalInformation G n S D base = ∑ index : SourceRemainingCoordinate D × Y, jointFirstMarginal (exactBobInformationPosterior G n S D) index * (∑ history : ExactHistoryFlag X Y A B D, jointFirstMarginal (jointConditional (exactBobInformationPosterior G n S D) index) history * finiteRelativeEntropy (jointConditional (jointConditional (exactBobInformationPosterior G n S D) index) history) (G.conditionalXGivenY index.2)) := exactBobSourceConditionalInformation_eq_question G n S D remaining positive base _ = _ := finiteNestedNextInformation_eq_atom_sum (exactBobInformationPosterior G n S D) hnonnegative (fun index : SourceRemainingCoordinate D × Y => G.conditionalXGivenY index.2) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalSampling open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactPermutationOutputUniformPushforward {R : Type*} [Fintype R] [DecidableEq R] (denominator : ℕ) (numerator : R → ℕ) (normalized : (∑ r, numerator r) = denominator) (nonempty : (rationalMarked denominator numerator).Nonempty) (letter : R) : groupedMass (rationalPermutationOutput denominator numerator nonempty) (fun _ : Equiv.Perm (R × Fin denominator) => (1 : ℝ) / (Fintype.card (Equiv.Perm (R × Fin denominator)) : ℝ)) letter = (numerator letter : ℝ) / denominator := by classical calc groupedMass (rationalPermutationOutput denominator numerator nonempty) (fun _ : Equiv.Perm (R × Fin denominator) => (1 : ℝ) / (Fintype.card (Equiv.Perm (R × Fin denominator)) : ℝ)) letter = uniformPermutationProbability (fun permutation : Equiv.Perm (R × Fin denominator) => rationalPermutationOutput denominator numerator nonempty permutation = letter) := by rw [exactUniformPermutationProbability_eq_indicator_sum] unfold groupedMass rw [Finset.sum_filter, Finset.sum_div] apply Finset.sum_congr rfl intro permutation _ by_cases selected : rationalPermutationOutput denominator numerator nonempty permutation = letter · simp [selected] · simp [selected] _ = (numerator letter : ℝ) / denominator := rationalPermutationOutput_probability denominator numerator normalized nonempty letter theorem exactPermutationOutputUniformExpectation {R : Type*} [Fintype R] [DecidableEq R] (denominator : ℕ) (numerator : R → ℕ) (normalized : (∑ r, numerator r) = denominator) (nonempty : (rationalMarked denominator numerator).Nonempty) (value : R → ℝ) : (∑ permutation : Equiv.Perm (R × Fin denominator), ((1 : ℝ) / (Fintype.card (Equiv.Perm (R × Fin denominator)) : ℝ)) * value (rationalPermutationOutput denominator numerator nonempty permutation)) = ∑ letter : R, ((numerator letter : ℝ) / denominator) * value letter := by calc (∑ permutation : Equiv.Perm (R × Fin denominator), ((1 : ℝ) / (Fintype.card (Equiv.Perm (R × Fin denominator)) : ℝ)) * value (rationalPermutationOutput denominator numerator nonempty permutation)) = ∑ letter : R, groupedMass (rationalPermutationOutput denominator numerator nonempty) (fun _ : Equiv.Perm (R × Fin denominator) => (1 : ℝ) / (Fintype.card (Equiv.Perm (R × Fin denominator)) : ℝ)) letter * value letter := (finiteGroupedExpectation_eq_atom_sum (rationalPermutationOutput denominator numerator nonempty) (fun _ : Equiv.Perm (R × Fin denominator) => (1 : ℝ) / (Fintype.card (Equiv.Perm (R × Fin denominator)) : ℝ)) value).symm _ = ∑ letter : R, ((numerator letter : ℝ) / denominator) * value letter := by simp_rw [exactPermutationOutputUniformPushforward denominator numerator normalized nonempty] def exactSourceAliceSampleTuple {n : ℕ} (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) (outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y)) : ExactLocallySampleableTuple X Y A B D := (outcome.1.1, outcome.2.1, outcome.2.2, exactSourceAlicePermutationHistory D denominator numerator nonempty outcome.1 outcome.2.1) theorem exactSourceAliceSampleTuple_expectation (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (normalized : ∀ k, (∑ r, numerator k r) = denominator) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) (value : ExactLocallySampleableTuple X Y A B D → ℝ) : (∑ outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y), flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator) outcome * value (exactSourceAliceSampleTuple D denominator numerator nonempty outcome)) = ∑ history : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableJARounded G n D denominator numerator history * value history := by classical have point (coordinate : SourceRemainingCoordinate D) (x : X) (y : Y) : (∑ permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator), ((1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (1 / (Fintype.card (Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator)) : ℝ))) * G.questionWeight x y * value (coordinate, x, y, rationalPermutationOutput denominator (numerator (.inl (coordinate, x))) (nonempty (.inl (coordinate, x))) permutation)) = ∑ history : ExactHistoryFlag X Y A B D, (G.questionWeight x y * ((numerator (.inl (coordinate, x)) history : ℝ) / denominator) / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * value (coordinate, x, y, history) := by have output := exactPermutationOutputUniformExpectation denominator (numerator (.inl (coordinate, x))) (normalized (.inl (coordinate, x))) (nonempty (.inl (coordinate, x))) (fun history : ExactHistoryFlag X Y A B D => value (coordinate, x, y, history)) calc (∑ permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator), ((1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (1 / (Fintype.card (Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator)) : ℝ))) * G.questionWeight x y * value (coordinate, x, y, rationalPermutationOutput denominator (numerator (.inl (coordinate, x))) (nonempty (.inl (coordinate, x))) permutation)) = (G.questionWeight x y / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (∑ permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator), ((1 : ℝ) / (Fintype.card (Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator)) : ℝ)) * value (coordinate, x, y, rationalPermutationOutput denominator (numerator (.inl (coordinate, x))) (nonempty (.inl (coordinate, x))) permutation)) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro permutation _ ring _ = (G.questionWeight x y / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (∑ history : ExactHistoryFlag X Y A B D, ((numerator (.inl (coordinate, x)) history : ℝ) / denominator) * value (coordinate, x, y, history)) := by rw [output] _ = ∑ history : ExactHistoryFlag X Y A B D, (G.questionWeight x y * ((numerator (.inl (coordinate, x)) history : ℝ) / denominator) / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * value (coordinate, x, y, history) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro history _ ring simp only [flaggedQuestionWeight, exactSourceSharedFlagWeight, exactSourceAliceSampleTuple, exactSourceAlicePermutationHistory, exactLocallySampleableJARounded, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro coordinate _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro x _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro y _ exact point coordinate x y theorem exactSourceAliceSampleTuple_groupedMass (G : Game X Y A B) (n : ℕ) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (normalized : ∀ k, (∑ r, numerator k r) = denominator) (nonempty : ∀ k, (rationalMarked denominator (numerator k)).Nonempty) (history : ExactLocallySampleableTuple X Y A B D) : groupedMass (exactSourceAliceSampleTuple D denominator numerator nonempty) (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) history = exactLocallySampleableJARounded G n D denominator numerator history := by classical have expectation := exactSourceAliceSampleTuple_expectation G n D denominator numerator normalized nonempty (fun candidate => if candidate = history then (1 : ℝ) else 0) simpa [groupedMass, Finset.sum_filter, mul_ite] using expectation end noncomputable section open scoped BigOperators open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {Ω T : Type*} [Fintype Ω] [Fintype T] [DecidableEq T] def exactFiniteFiberLift (projection : Ω → T) (original : Ω → ℝ) (target : T → ℝ) (outcome : Ω) : ℝ := target (projection outcome) * original outcome / groupedMass projection original (projection outcome) omit [Fintype T] in theorem exactFiniteFiberLift_groupedMass (projection : Ω → T) (original : Ω → ℝ) (target : T → ℝ) (supported : ∀ point, groupedMass projection original point = 0 → target point = 0) (point : T) : groupedMass projection (exactFiniteFiberLift projection original target) point = target point := by classical change (∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point), exactFiniteFiberLift projection original target outcome) = target point calc (∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point), exactFiniteFiberLift projection original target outcome) = ∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point), target point * original outcome / groupedMass projection original point := by apply Finset.sum_congr rfl intro outcome member have same : projection outcome = point := (Finset.mem_filter.mp member).2 simp [exactFiniteFiberLift, same] _ = target point * groupedMass projection original point / groupedMass projection original point := by rw [← Finset.sum_div, ← Finset.mul_sum] rfl _ = target point := by by_cases empty : groupedMass projection original point = 0 · simp [empty, supported point empty] · field_simp theorem exactFiniteFiberLift_expectation (projection : Ω → T) (original : Ω → ℝ) (target : T → ℝ) (supported : ∀ point, groupedMass projection original point = 0 → target point = 0) (value : T → ℝ) : (∑ outcome : Ω, exactFiniteFiberLift projection original target outcome * value (projection outcome)) = ∑ point : T, target point * value point := by calc (∑ outcome : Ω, exactFiniteFiberLift projection original target outcome * value (projection outcome)) = ∑ point : T, groupedMass projection (exactFiniteFiberLift projection original target) point * value point := (finiteGroupedExpectation_eq_atom_sum projection (exactFiniteFiberLift projection original target) value).symm _ = ∑ point : T, target point * value point := by simp_rw [exactFiniteFiberLift_groupedMass projection original target supported] omit [Fintype T] in theorem exactFiniteFiberLift_absolute_groupedMass (projection : Ω → T) (original : Ω → ℝ) (target : T → ℝ) (original_nonnegative : ∀ outcome, 0 ≤ original outcome) (supported : ∀ point, groupedMass projection original point = 0 → target point = 0) (point : T) : groupedMass projection (fun outcome => |original outcome - exactFiniteFiberLift projection original target outcome|) point = |groupedMass projection original point - target point| := by classical by_cases empty : groupedMass projection original point = 0 · have vanishes : ∀ outcome, outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point) → original outcome = 0 := by intro outcome member exact (Finset.sum_eq_zero_iff_of_nonneg (fun outcome _ => original_nonnegative outcome)).mp (show (∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point), original outcome) = 0 from empty) outcome member unfold groupedMass rw [Finset.sum_eq_zero (fun outcome member => by have zero := vanishes outcome member simp [exactFiniteFiberLift, zero])] simpa [supported point empty, groupedMass] using (congrArg abs empty).symm · have pointwise (outcome : Ω) (member : outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point)) : |original outcome - exactFiniteFiberLift projection original target outcome| = original outcome * |groupedMass projection original point - target point| / groupedMass projection original point := by have same : projection outcome = point := (Finset.mem_filter.mp member).2 have mass_nonnegative : 0 ≤ groupedMass projection original point := by unfold groupedMass exact Finset.sum_nonneg (fun outcome _ => original_nonnegative outcome) have mass_positive : 0 < groupedMass projection original point := lt_of_le_of_ne mass_nonnegative (Ne.symm empty) rw [exactFiniteFiberLift, same] rw [show original outcome - target point * original outcome / groupedMass projection original point = original outcome * (groupedMass projection original point - target point) / groupedMass projection original point by field_simp] rw [abs_div, abs_mul, abs_of_nonneg (original_nonnegative outcome), abs_of_pos mass_positive] change (∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point), |original outcome - exactFiniteFiberLift projection original target outcome|) = |groupedMass projection original point - target point| calc (∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point), |original outcome - exactFiniteFiberLift projection original target outcome|) = ∑ outcome ∈ (Finset.univ.filter fun outcome : Ω => projection outcome = point), original outcome * |groupedMass projection original point - target point| / groupedMass projection original point := by apply Finset.sum_congr rfl exact pointwise _ = groupedMass projection original point * |groupedMass projection original point - target point| / groupedMass projection original point := by rw [← Finset.sum_div, ← Finset.sum_mul] rfl _ = |groupedMass projection original point - target point| := by field_simp theorem exactFiniteFiberLift_totalVariation (projection : Ω → T) (original : Ω → ℝ) (target : T → ℝ) (original_nonnegative : ∀ outcome, 0 ≤ original outcome) (supported : ∀ point, groupedMass projection original point = 0 → target point = 0) : finiteTotalVariation original (exactFiniteFiberLift projection original target) = finiteTotalVariation (groupedMass projection original) target := by unfold finiteTotalVariation congr 1 calc (∑ outcome : Ω, |original outcome - exactFiniteFiberLift projection original target outcome|) = ∑ point : T, groupedMass projection (fun outcome => |original outcome - exactFiniteFiberLift projection original target outcome|) point := by simpa using (finiteGroupedExpectation_eq_atom_sum projection (fun outcome => |original outcome - exactFiniteFiberLift projection original target outcome|) (fun _ => (1 : ℝ))).symm _ = ∑ point : T, |groupedMass projection original point - target point| := by simp_rw [exactFiniteFiberLift_absolute_groupedMass projection original target original_nonnegative supported] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalSampling open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem existsCommonSupportPreservingRationalApproximations {I K : Type*} [Fintype I] [DecidableEq I] [Fintype K] (base : I) (probability : K → I → ℝ) (nonnegative : ∀ index letter, 0 ≤ probability index letter) (normalized : ∀ index, (∑ letter, probability index letter) = 1) {gamma : ℝ} (gamma_positive : 0 < gamma) : ∃ denominator : ℕ, 0 < denominator ∧ ∃ numerator : K → I → ℕ, (∀ index, (∑ letter, numerator index letter) = denominator) ∧ (∀ index, finiteTotalVariation (probability index) (fun letter => (numerator index letter : ℝ) / denominator) < gamma) ∧ (∀ index letter, 0 < probability index letter → 0 < numerator index letter) := by classical let supportCost : ℝ := ∑ index : K, ∑ letter : I, if 0 < probability index letter then 1 / probability index letter else 0 have cost_nonnegative : 0 ≤ supportCost := by dsimp [supportCost] apply Finset.sum_nonneg intro index _ apply Finset.sum_nonneg intro letter _ split_ifs with positive · exact (one_div_pos.mpr positive).le · exact le_rfl have cardinal_positive : 0 < (Fintype.card I : ℝ) := by exact_mod_cast (Fintype.card_pos_iff.mpr ⟨base⟩ : 0 < Fintype.card I) have ratio_positive : 0 < (Fintype.card I : ℝ) / gamma := div_pos cardinal_positive gamma_positive obtain ⟨denominator, denominator_large⟩ := exists_nat_gt ((Fintype.card I : ℝ) / gamma + supportCost) have denominator_real_positive : 0 < (denominator : ℝ) := lt_of_lt_of_le (lt_of_lt_of_le ratio_positive (le_add_of_nonneg_right cost_nonnegative)) denominator_large.le have denominator_positive : 0 < denominator := by exact_mod_cast denominator_real_positive have approximation_budget : (Fintype.card I : ℝ) / denominator < gamma := by apply (div_lt_iff₀ denominator_real_positive).mpr have reciprocal_bound : (Fintype.card I : ℝ) / gamma < (denominator : ℝ) := lt_of_le_of_lt (le_add_of_nonneg_right cost_nonnegative) denominator_large have crossed := (div_lt_iff₀ gamma_positive).mp reciprocal_bound nlinarith refine ⟨denominator, denominator_positive, fun index => distributionRoundedNumerator base denominator (probability index), ?_, ?_, ?_⟩ · intro index exact distributionRoundedNumerator_sum base denominator (probability index) (nonnegative index) (normalized index) · intro index change finiteTotalVariation (probability index) (distributionRoundedProbability base denominator (probability index)) < gamma exact (distributionRoundedProbability_totalVariation_le base denominator denominator_positive (probability index) (nonnegative index) (normalized index)).trans_lt approximation_budget · intro index letter genuinely_positive have letter_le_inner : 1 / probability index letter ≤ ∑ candidate : I, if 0 < probability index candidate then 1 / probability index candidate else 0 := by have single := Finset.single_le_sum (s := (Finset.univ : Finset I)) (f := fun candidate : I => if 0 < probability index candidate then 1 / probability index candidate else 0) (fun candidate _ => by split_ifs with positive · exact (one_div_pos.mpr positive).le · exact le_rfl) (Finset.mem_univ letter) simpa [genuinely_positive] using single have inner_le_cost : (∑ candidate : I, if 0 < probability index candidate then 1 / probability index candidate else 0) ≤ supportCost := by dsimp [supportCost] exact Finset.single_le_sum (s := (Finset.univ : Finset K)) (f := fun current : K => ∑ candidate : I, if 0 < probability current candidate then 1 / probability current candidate else 0) (fun current _ => by apply Finset.sum_nonneg intro candidate _ split_ifs with positive · exact (one_div_pos.mpr positive).le · exact le_rfl) (Finset.mem_univ index) have reciprocal_lt_denominator : 1 / probability index letter < (denominator : ℝ) := lt_of_le_of_lt (letter_le_inner.trans inner_le_cost) (lt_of_le_of_lt (le_add_of_nonneg_left ratio_positive.le) denominator_large) have mass_exceeds_one : (1 : ℝ) ≤ probability index letter * (denominator : ℝ) := by have crossed := (div_lt_iff₀ genuinely_positive).mp reciprocal_lt_denominator nlinarith have positive_floor : 0 < distributionFloorNumerator denominator (probability index) letter := by unfold distributionFloorNumerator exact Nat.floor_pos.mpr mass_exceeds_one change 0 < distributionFloorNumerator denominator (probability index) letter + if letter = base then distributionFloorResidual denominator (probability index) else 0 exact lt_of_lt_of_le positive_floor (Nat.le_add_right _ _) variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactLocallySampleableLaw_absolute_continuous_roundedJA (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (denominator_positive : 0 < denominator) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (preserves : ∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) (history : ExactLocallySampleableTuple X Y A B D) : exactLocallySampleableJARounded G n D denominator numerator history = 0 → exactLocallySampleableLaw G n S D history = 0 := by classical intro rounded_zero apply exactLocallySampleableLaw_absolute_continuous_JA G n S D remaining positive base history rcases history with ⟨coordinate, x, y, flag⟩ have card_nonzero : (Fintype.card (SourceRemainingCoordinate D) : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt (exactRemainingCoordinate_card_pos D remaining)) have denominator_nonzero : (denominator : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt denominator_positive) change G.questionWeight x y * ((numerator (.inl (coordinate, x)) flag : ℝ) / denominator) / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = 0 at rounded_zero have product_zero : G.questionWeight x y * ((numerator (.inl (coordinate, x)) flag : ℝ) / denominator) = 0 := (div_eq_zero_iff.mp rounded_zero).resolve_right card_nonzero rcases mul_eq_zero.mp product_zero with question_zero | numerator_zero · change G.questionWeight x y * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) coordinate x flag / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = 0 simp [question_zero] · have cast_zero : (numerator (.inl (coordinate, x)) flag : ℝ) = 0 := (div_eq_zero_iff.mp numerator_zero).resolve_right denominator_nonzero have natural_zero : numerator (.inl (coordinate, x)) flag = 0 := by exact_mod_cast cast_zero have conditional_nonnegative : 0 ≤ exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) coordinate x flag := exactAliceLocalConditional_nonneg D base (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive) coordinate x flag have conditional_zero : exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) coordinate x flag = 0 := by by_contra nonzero have strictly_positive := lt_of_le_of_ne conditional_nonnegative (Ne.symm nonzero) have retained := preserves (.inl (coordinate, x)) flag strictly_positive omega change G.questionWeight x y * exactAliceLocalConditional D base (exactLocallySampleableLaw G n S D) coordinate x flag / (Fintype.card (SourceRemainingCoordinate D) : ℝ) = 0 simp [conditional_zero] theorem exact_exists_support_preserving_local_shared_permutation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) {gamma : ℝ} (gamma_positive : 0 < gamma) : ∃ denominator : ℕ, 0 < denominator ∧ ∃ numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ, (∀ index, (∑ history, numerator index history) = denominator) ∧ (∀ index, finiteTotalVariation (exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index) (fun history => (numerator index history : ℝ) / denominator) < gamma) ∧ (∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) ∧ ∃ nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty, (∀ index history, uniformPermutationProbability (fun permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator) => rationalPermutationOutput denominator (numerator index) (nonempty index) permutation = history) = (numerator index history : ℝ) / denominator) ∧ (∀ left right, uniformPermutationProbability (fun permutation : Equiv.Perm (ExactHistoryFlag X Y A B D × Fin denominator) => rationalPermutationOutput denominator (numerator left) (nonempty left) permutation ≠ rationalPermutationOutput denominator (numerator right) (nonempty right) permutation) ≤ 2 * finiteTotalVariation (fun history => (numerator left history : ℝ) / denominator) (fun history => (numerator right history : ℝ) / denominator)) := by obtain ⟨denominator, denominator_positive, numerator, normalized, approximation, preserves⟩ := existsCommonSupportPreservingRationalApproximations base (exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D)) (exactLocalConditionalFamily_nonneg D base (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive)) (exactLocalConditionalFamily_sum D base (exactLocallySampleableLaw G n S D)) gamma_positive refine ⟨denominator, denominator_positive, numerator, normalized, approximation, preserves, fun index => rationalMarked_nonempty denominator (numerator index) (normalized index) denominator_positive, ?_, ?_⟩ · intro index history exact rationalPermutationOutput_probability denominator (numerator index) (normalized index) _ history · intro left right exact rationalPermutationOutput_disagreement_le_two_mul_finiteTotalVariation denominator denominator_positive (numerator left) (numerator right) (normalized left) (normalized right) _ _ end noncomputable section open Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactSourceAliceRefinedPOVM [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (x : X) : POVM A (ExactAliceLocalIndex G n S D r) := by classical exact purificationAlicePOVM (exactAliceRefinedPOVM G n S D r a₀ x) def exactSourceBobRefinedPOVM [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (b₀ : B) (y : Y) : POVM B (ExactBobLocalIndex G n S D r) := exactBobRefinedPOVM G n S D r b₀ y def exactSourceJointEffect [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) (a : A) (b : B) : Matrix (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) ℂ := (exactSourceAliceRefinedPOVM G n S D r a₀ x).effect a ⊗ₖ (exactSourceBobRefinedPOVM G n S D r b₀ y).effect b def exactSourceWinningEffect [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) : Matrix (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then exactSourceJointEffect G n S D r a₀ b₀ x y a b else 0 def exactSourceWinningEffectCLM [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) →L[ℂ] EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) := by classical exact Matrix.toEuclideanCLM (n := ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) (𝕜 := ℂ) (exactSourceWinningEffect G n S D r a₀ b₀ x y) theorem exactSourceJointEffect_quadratic [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) (a : A) (b : B) : quadraticExpectation (Matrix.toEuclideanCLM (n := ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) (𝕜 := ℂ) (exactSourceJointEffect G n S D r a₀ b₀ x y a b)) (exactUnnormalizedPsi G n S D r x y) = bornTracePairing S.state.matrix (exactAliceCoordinateFilter G n S D r.seed r.history r.aliceAnswer x a) (exactBobCoordinateFilter G n S D r.seed r.history r.bobAnswer y b) := by classical simpa [exactSourceJointEffect, exactSourceAliceRefinedPOVM, exactSourceBobRefinedPOVM, purificationAlicePOVM] using (exactRefinedPOVM_quadratic G n S D r a₀ b₀ x y a b) theorem exactSourceWinningEffect_quadratic [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) : quadraticExpectation (exactSourceWinningEffectCLM G n S D r a₀ b₀ x y) (exactUnnormalizedPsi G n S D r x y) = ∑ a : A, ∑ b : B, if G.predicate x y a b = true then bornTracePairing S.state.matrix (exactAliceCoordinateFilter G n S D r.seed r.history r.aliceAnswer x a) (exactBobCoordinateFilter G n S D r.seed r.history r.bobAnswer y b) else 0 := by classical unfold exactSourceWinningEffectCLM exactSourceWinningEffect rw [sourceHistoryQuadraticExpectation_matrix_sum] apply Finset.sum_congr rfl intro a _ rw [sourceHistoryQuadraticExpectation_matrix_sum] apply Finset.sum_congr rfl intro b _ split_ifs · exact exactSourceJointEffect_quadratic G n S D r a₀ b₀ x y a b · simp [quadraticExpectation] theorem exactSourceWinningEffect_quadratic_eq_conditional [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) (supported : exactFiberQuestionMass G n D r.seed r.history x y ≠ 0) : quadraticExpectation (exactSourceWinningEffectCLM G n S D r a₀ b₀ x y) (exactUnnormalizedPsi G n S D r x y) = exactJointConditionalWinningMass G n S D r.seed r.history r.aliceAnswer r.bobAnswer x y := by rw [exactSourceWinningEffect_quadratic] unfold exactJointConditionalWinningMass apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ split_ifs · rw [exactAliceCoordinateFilter_eq_joint G n S D r.seed r.history r.aliceAnswer x y a supported, exactBobCoordinateFilter_eq_joint G n S D r.seed r.history r.bobAnswer x y b supported] · rfl theorem exactSourceNormalizedWinningEffect_eq_conditional [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) (supported : exactFiberQuestionMass G n D r.seed r.history x y ≠ 0) : quadraticExpectation (exactSourceWinningEffectCLM G n S D r a₀ b₀ x y) (normalizedPureVector (exactUnnormalizedPsi G n S D r x y)) = exactJointConditionalWinningMass G n S D r.seed r.history r.aliceAnswer r.bobAnswer x y / bornTracePairing S.state.matrix (exactAliceQuestionFilter G n S D r.seed r.history r.aliceAnswer x) (exactBobQuestionFilter G n S D r.seed r.history r.bobAnswer y) := by rw [quadraticExpectation_normalizedPureVector, exactSourceWinningEffect_quadratic_eq_conditional G n S D r a₀ b₀ x y supported, exactUnnormalizedPsi_norm_sq] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactSourceAcceptedCoordinateMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) : ℝ := ∑ q : ExactJointOutcome X Y A B D, if exactLocallySampleableCode D q = t ∧ repeatedCoordinateWin G n q.1.coordinate.val q.2 = true then exactPostselectedJointLaw G n S D q else 0 theorem exactSourceAcceptedCoordinateMass_nonneg (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (t : ExactLocallySampleableTuple X Y A B D) : 0 ≤ exactSourceAcceptedCoordinateMass G n S D t := by unfold exactSourceAcceptedCoordinateMass apply Finset.sum_nonneg intro q _ split · exact exactPostselectedJointLaw_nonneg G n S D positive q · exact le_rfl theorem exactSourceAcceptedCoordinateMass_le_law (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (t : ExactLocallySampleableTuple X Y A B D) : exactSourceAcceptedCoordinateMass G n S D t ≤ exactLocallySampleableLaw G n S D t := by classical unfold exactSourceAcceptedCoordinateMass exactLocallySampleableLaw exactSourcePushforward groupedMass rw [Finset.sum_filter] apply Finset.sum_le_sum intro q _ by_cases history : exactLocallySampleableCode D q = t · by_cases winning : repeatedCoordinateWin G n q.1.coordinate.val q.2 = true · simp [history, winning] · simp [history, winning, exactPostselectedJointLaw_nonneg G n S D positive q] · simp [history] def exactSourceConditionalWinningProbability (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) : ℝ := exactSourceAcceptedCoordinateMass G n S D t / exactLocallySampleableLaw G n S D t theorem exactSourceConditionalWinningProbability_bounds (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (t : ExactLocallySampleableTuple X Y A B D) : 0 ≤ exactSourceConditionalWinningProbability G n S D t ∧ exactSourceConditionalWinningProbability G n S D t ≤ 1 := by have mass_nonnegative := exactSourceAcceptedCoordinateMass_nonneg G n S D positive t have mass_le := exactSourceAcceptedCoordinateMass_le_law G n S D positive t have law_nonnegative := exactLocallySampleableLaw_nonneg G n S D positive t unfold exactSourceConditionalWinningProbability constructor · exact div_nonneg mass_nonnegative law_nonnegative · by_cases zero : exactLocallySampleableLaw G n S D t = 0 · simp [zero] · exact (div_le_one (lt_of_le_of_ne law_nonnegative (Ne.symm zero))).mpr mass_le theorem exactSourceConditionalWinningProbability_mul_law (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (t : ExactLocallySampleableTuple X Y A B D) : exactLocallySampleableLaw G n S D t * exactSourceConditionalWinningProbability G n S D t = exactSourceAcceptedCoordinateMass G n S D t := by by_cases zero : exactLocallySampleableLaw G n S D t = 0 · have nonnegative := exactSourceAcceptedCoordinateMass_nonneg G n S D positive t have bounded := exactSourceAcceptedCoordinateMass_le_law G n S D positive t rw [zero] at bounded have accepted_zero : exactSourceAcceptedCoordinateMass G n S D t = 0 := by linarith simp [zero, accepted_zero] · unfold exactSourceConditionalWinningProbability field_simp [zero] theorem exactSourceAcceptedCoordinateMass_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactSourceAcceptedCoordinateMass G n S D t) = ∑ q : ExactJointOutcome X Y A B D, if repeatedCoordinateWin G n q.1.coordinate.val q.2 = true then exactPostselectedJointLaw G n S D q else 0 := by classical unfold exactSourceAcceptedCoordinateMass rw [Finset.sum_comm] apply Finset.sum_congr rfl intro q _ by_cases winning : repeatedCoordinateWin G n q.1.coordinate.val q.2 = true · simp [winning] · simp [winning] theorem exactSourceConditionalWinningProbability_expectation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * exactSourceConditionalWinningProbability G n S D t) = ∑ q : ExactJointOutcome X Y A B D, if repeatedCoordinateWin G n q.1.coordinate.val q.2 = true then exactPostselectedJointLaw G n S D q else 0 := by simp_rw [exactSourceConditionalWinningProbability_mul_law G n S D positive] exact exactSourceAcceptedCoordinateMass_sum G n S D theorem exactRepeatedConditionedCoordinateWin (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (i : Fin n) : (∑ outcome : ExactOutcome X Y A B n, if repeatedCoordinateWin G n i outcome = true then repeatedConditionedOutcomeLaw G n S D outcome else 0) = (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i D)) / repeatedPostselectionMass G n S D := by classical have accepted_as_indicator : (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i D)) = ∑ outcome : ExactOutcome X Y A B n, if outcome ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i D) then (strategyEventLaw (G.repeat n) S).weight outcome else 0 := by simp [FiniteEventLaw.eventMass] rw [accepted_as_indicator] rw [Finset.sum_div] apply Finset.sum_congr rfl intro outcome _ by_cases winning : repeatedCoordinateWin G n i outcome = true · simp [repeatedConditionedOutcomeLaw, conditionedEventDistribution, repeatedPostselectionMass, postselectionMass, FiniteEventLaw.winEvent, winning, ite_div] · simp [FiniteEventLaw.winEvent, winning] theorem exactSourceAcceptedCoordinateMass_sum_eq_remaining_average (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactSourceAcceptedCoordinateMass G n S D t) = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (∑ i : SourceRemainingCoordinate D, (strategyEventLaw (G.repeat n) S).eventMass (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) (insert i.val D)) / repeatedPostselectionMass G n S D) := by classical rw [exactSourceAcceptedCoordinateMass_sum] unfold exactPostselectedJointLaw rw [Fintype.sum_prod_type, Finset.sum_comm] calc (∑ outcome : ExactOutcome X Y A B n, ∑ seed : ExactRemainingSeed D, if repeatedCoordinateWin G n seed.coordinate.val outcome = true then exactSeedWeight seed * repeatedConditionedOutcomeLaw G n S D outcome else 0) = ∑ outcome : ExactOutcome X Y A B n, ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * (if repeatedCoordinateWin G n seed.coordinate.val outcome = true then repeatedConditionedOutcomeLaw G n S D outcome else 0) := by apply Finset.sum_congr rfl intro outcome _ apply Finset.sum_congr rfl intro seed _ split <;> simp _ = ∑ outcome : ExactOutcome X Y A B n, ∑ i : SourceRemainingCoordinate D, (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (if repeatedCoordinateWin G n i.val outcome = true then repeatedConditionedOutcomeLaw G n S D outcome else 0) := by apply Finset.sum_congr rfl intro outcome _ exact exactSeedWeight_coordinate_sum (M := SourceRemainingCoordinate D) (fun i => if repeatedCoordinateWin G n i.val outcome = true then repeatedConditionedOutcomeLaw G n S D outcome else 0) _ = (1 / (Fintype.card (SourceRemainingCoordinate D) : ℝ)) * (∑ i : SourceRemainingCoordinate D, ∑ outcome : ExactOutcome X Y A B n, if repeatedCoordinateWin G n i.val outcome = true then repeatedConditionedOutcomeLaw G n S D outcome else 0) := by rw [Finset.sum_comm, Finset.mul_sum] apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] _ = _ := by congr 1 apply Finset.sum_congr rfl intro i _ exact exactRepeatedConditionedCoordinateWin G n S D i.val theorem exactSourceConditionalWinningProbability_eq_accepted_average (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * exactSourceConditionalWinningProbability G n S D t) = sourceHistoryAcceptedMass G n S D / repeatedPostselectionMass G n S D := by rw [exactSourceConditionalWinningProbability_expectation G n S D positive, ← exactSourceAcceptedCoordinateMass_sum, exactSourceAcceptedCoordinateMass_sum_eq_remaining_average, sourceHistoryAcceptedMass_eq_remaining_average] have cardinality : Fintype.card (SourceRemainingCoordinate D) = (Finset.univ \ D).card := by simpa only [Fintype.card_fin] using Fintype.card_congr (Finset.equivFin (Finset.univ \ D)) push_cast [cardinality] rw [← Finset.sum_div] ring theorem exactSource_failure_sum_lt_of_uniform (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) {δ : ℝ} (failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < δ) : (∑ i ∈ Finset.univ \ D, FiniteEventLaw.failureMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D i) < ((Finset.univ \ D).card : ℝ) * (δ * repeatedPostselectionMass G n S D) := by have cardinality : 0 < ((Finset.univ \ D).card : ℝ) := by exact_mod_cast remaining unfold uniformRemainingFailure conditionalCoordinateFailure at failure change (∑ i ∈ Finset.univ \ D, FiniteEventLaw.failureMass (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D i / repeatedPostselectionMass G n S D) / ((Finset.univ \ D).card : ℝ) < δ at failure rw [← Finset.sum_div] at failure have first := (div_lt_iff₀ cardinality).mp failure have second := (div_lt_iff₀ positive).mp first nlinarith theorem exactSourceConditionalWinningProbability_gt_of_uniform_failure (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) {δ : ℝ} (failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < δ) : 1 - δ < ∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t * exactSourceConditionalWinningProbability G n S D t := by rw [exactSourceConditionalWinningProbability_eq_accepted_average G n S D positive] have numerator := exactSource_failure_sum_lt_of_uniform G n S D remaining positive failure have accepted := sourceHistoryAcceptedMass_gt_of_greedy G n S D remaining numerator apply (lt_div_iff₀ positive).mpr exact accepted end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalSampling open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B dA dB : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable [Fintype dA] [Fintype dB] [DecidableEq dA] [DecidableEq dB] def exactSourceAliceFlagCoupling (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) : ExactSourceSharedFlag X Y A B D denominator × (X × Y) → ℝ := exactFiniteFiberLift (exactSourceAliceSampleTuple D denominator numerator nonempty) (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactLocallySampleableLaw G n S D) theorem exactSourceAliceFlagCoupling_supported (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (denominator_positive : 0 < denominator) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (normalized : ∀ index, (∑ history, numerator index history) = denominator) (preserves : ∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (history : ExactLocallySampleableTuple X Y A B D) : groupedMass (exactSourceAliceSampleTuple D denominator numerator nonempty) (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) history = 0 → exactLocallySampleableLaw G n S D history = 0 := by rw [exactSourceAliceSampleTuple_groupedMass G n D denominator numerator normalized nonempty] exact exactLocallySampleableLaw_absolute_continuous_roundedJA G n S D remaining positive base denominator denominator_positive numerator preserves history theorem exactSourceAliceFlagCoupling_expectation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (denominator_positive : 0 < denominator) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (normalized : ∀ index, (∑ history, numerator index history) = denominator) (preserves : ∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (value : ExactLocallySampleableTuple X Y A B D → ℝ) : (∑ outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y), exactSourceAliceFlagCoupling G n S D denominator numerator nonempty outcome * value (exactSourceAliceSampleTuple D denominator numerator nonempty outcome)) = ∑ history : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D history * value history := by exact exactFiniteFiberLift_expectation (exactSourceAliceSampleTuple D denominator numerator nonempty) (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactLocallySampleableLaw G n S D) (exactSourceAliceFlagCoupling_supported G n S D remaining positive base denominator denominator_positive numerator normalized preserves nonempty) value theorem exactSourceAliceFlagCoupling_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (denominator_positive : 0 < denominator) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (normalized : ∀ index, (∑ history, numerator index history) = denominator) (preserves : ∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) : (∑ outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y), exactSourceAliceFlagCoupling G n S D denominator numerator nonempty outcome) = 1 := by have expectation := exactSourceAliceFlagCoupling_expectation G n S D remaining positive base denominator denominator_positive numerator normalized preserves nonempty (fun _ => (1 : ℝ)) simpa [exactLocallySampleableLaw_sum G n S D remaining positive] using expectation theorem exactSourceAliceFlagCoupling_totalVariation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (denominator_positive : 0 < denominator) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (normalized : ∀ index, (∑ history, numerator index history) = denominator) (preserves : ∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) : finiteTotalVariation (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactSourceAliceFlagCoupling G n S D denominator numerator nonempty) = finiteTotalVariation (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableLaw G n S D) := by change finiteTotalVariation (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactFiniteFiberLift (exactSourceAliceSampleTuple D denominator numerator nonempty) (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactLocallySampleableLaw G n S D)) = _ rw [exactFiniteFiberLift_totalVariation (exactSourceAliceSampleTuple D denominator numerator nonempty) (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactLocallySampleableLaw G n S D) (flaggedQuestionWeight_nonneg G (exactSourceSharedFlagWeight D denominator) (exactSourceSharedFlagWeight_nonneg D denominator)) (exactSourceAliceFlagCoupling_supported G n S D remaining positive base denominator denominator_positive numerator normalized preserves nonempty)] congr 1 funext history exact exactSourceAliceSampleTuple_groupedMass G n D denominator numerator normalized nonempty history end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactFairWinningOutcomeBornMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (history : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ℝ := ∑ outcome : ExactOutcome X Y A B n, if exactLocallySampleableCode D (history.seed, outcome) = (history.seed.coordinate, x, y, history) ∧ repeatedCoordinateWin G n history.seed.coordinate.val outcome = true then (strategyEventLaw (G.repeat n) S).weight outcome else 0 theorem exactSourceAcceptedCoordinateMass_eq_seeded_fair_born (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (history : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : exactSourceAcceptedCoordinateMass G n S D (history.seed.coordinate, x, y, history) = if exactHistoryAccepted G n D history then (exactSeedWeight history.seed * exactFairWinningOutcomeBornMass G n S D history x y) / repeatedPostselectionMass G n S D else 0 := by classical by_cases accepted : exactHistoryAccepted G n D history · rw [if_pos accepted] unfold exactSourceAcceptedCoordinateMass rw [Fintype.sum_prod_type] rw [Finset.sum_eq_single history.seed] · unfold exactFairWinningOutcomeBornMass rw [Finset.mul_sum, Finset.sum_div] apply Finset.sum_congr rfl intro outcome _ by_cases code : exactLocallySampleableCode D (history.seed, outcome) = (history.seed.coordinate, x, y, history) · by_cases winning : repeatedCoordinateWin G n history.seed.coordinate.val outcome = true · have same_history : exactHistoryCode D (history.seed, outcome) = history := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.2) code have conditioned : outcome ∈ FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D := by apply (exactHistoryCode_accepted_iff G n D (history.seed, outcome)).mp rw [same_history] exact accepted simp [code, winning, exactPostselectedJointLaw, repeatedConditionedOutcomeLaw, conditionedEventDistribution, repeatedPostselectionMass, postselectionMass, conditioned] ring · simp [code, winning] · simp [code] · intro seed _ distinct apply Finset.sum_eq_zero intro outcome _ have not_code : exactLocallySampleableCode D (seed, outcome) ≠ (history.seed.coordinate, x, y, history) := by intro code have same := congrArg (fun t : ExactLocallySampleableTuple X Y A B D => t.2.2.2.seed) code exact distinct same simp [not_code] · simp · rw [if_neg accepted] have law_zero := exactLocallySampleableLaw_zero_of_not_accepted G n S D history.seed.coordinate x y history accepted exact le_antisymm (by simpa [law_zero] using exactSourceAcceptedCoordinateMass_le_law G n S D positive (history.seed.coordinate, x, y, history)) (exactSourceAcceptedCoordinateMass_nonneg G n S D positive (history.seed.coordinate, x, y, history)) theorem exactSourceConditionalWinningProbability_eq_fine_born_ratio (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (history : ExactHistoryFlag X Y A B D) (accepted : exactHistoryAccepted G n D history) (x : X) (y : Y) : exactSourceConditionalWinningProbability G n S D (history.seed.coordinate, x, y, history) = exactFairWinningOutcomeBornMass G n S D history x y / exactFairFullOutcomeBornMass G n S D history x y := by have seed_positive : 0 < exactSeedWeight history.seed := by unfold exactSeedWeight have coordinate_positive : 0 < Fintype.card (SourceRemainingCoordinate D) := Fintype.card_pos_iff.mpr ⟨history.seed.coordinate⟩ positivity have posterior : exactLocallySampleableLaw G n S D (history.seed.coordinate, x, y, history) = (exactSeedWeight history.seed * exactFairFullOutcomeBornMass G n S D history x y) / repeatedPostselectionMass G n S D := by rw [exactLocallySampleableLaw_eq_fair_born, if_pos accepted, exactFairFullOutcomeBornMass_eq_reveal_question_norm] ring unfold exactSourceConditionalWinningProbability rw [exactSourceAcceptedCoordinateMass_eq_seeded_fair_born G n S D positive history x y, if_pos accepted, posterior] by_cases mass_zero : exactFairFullOutcomeBornMass G n S D history x y = 0 · simp [mass_zero] · field_simp [positive.ne', seed_positive.ne', mass_zero] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactFineCoordinateWinningBorn_collapse (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (aliceAnswer : {j : Fin n // j ∈ D} → A) (bobAnswer : {j : Fin n // j ∈ D} → B) (xs : Fin n → X) (ys : Fin n → Y) (coordinate : Fin n) (x : X) (y : Y) : (∑ a : A, ∑ b : B, if G.predicate x y a b = true then bornTracePairing S.state.matrix (conditionedAliceCoordinateEffect G n S D aliceAnswer xs coordinate a) (conditionedBobCoordinateEffect G n S D bobAnswer ys coordinate b) else 0) = ∑ aa : Fin n → A, ∑ bb : Fin n → B, if (∀ (j : Fin n) (member : j ∈ D), aa j = aliceAnswer ⟨j, member⟩) ∧ (∀ (j : Fin n) (member : j ∈ D), bb j = bobAnswer ⟨j, member⟩) ∧ G.predicate x y (aa coordinate) (bb coordinate) = true then S.outcomeProbability xs ys aa bb else 0 := by classical simp_rw [conditionedCoordinateEffects_born_expansion G n S D] let f : A → B → (Fin n → A) → (Fin n → B) → ℝ := fun a b aa bb => if G.predicate x y a b = true then if (∀ (j : Fin n) (member : j ∈ D), aa j = aliceAnswer ⟨j, member⟩) ∧ aa coordinate = a then if (∀ (j : Fin n) (member : j ∈ D), bb j = bobAnswer ⟨j, member⟩) ∧ bb coordinate = b then S.outcomeProbability xs ys aa bb else 0 else 0 else 0 calc (∑ a : A, ∑ b : B, if G.predicate x y a b = true then ∑ aa : Fin n → A, ∑ bb : Fin n → B, if (∀ (j : Fin n) (member : j ∈ D), aa j = aliceAnswer ⟨j, member⟩) ∧ aa coordinate = a then if (∀ (j : Fin n) (member : j ∈ D), bb j = bobAnswer ⟨j, member⟩) ∧ bb coordinate = b then S.outcomeProbability xs ys aa bb else 0 else 0 else 0) = ∑ a : A, ∑ b : B, ∑ aa : Fin n → A, ∑ bb : Fin n → B, f a b aa bb := by apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ by_cases wins : G.predicate x y a b = true · simp [f, wins] · simp [f, wins] _ = ∑ aa : Fin n → A, ∑ bb : Fin n → B, ∑ a : A, ∑ b : B, f a b aa bb := finite_sum_four_swap f _ = ∑ aa : Fin n → A, ∑ bb : Fin n → B, if (∀ (j : Fin n) (member : j ∈ D), aa j = aliceAnswer ⟨j, member⟩) ∧ (∀ (j : Fin n) (member : j ∈ D), bb j = bobAnswer ⟨j, member⟩) ∧ G.predicate x y (aa coordinate) (bb coordinate) = true then S.outcomeProbability xs ys aa bb else 0 := by apply Finset.sum_congr rfl intro aa _ apply Finset.sum_congr rfl intro bb _ by_cases alice_matches : ∀ (j : Fin n) (member : j ∈ D), aa j = aliceAnswer ⟨j, member⟩ · by_cases bob_matches : ∀ (j : Fin n) (member : j ∈ D), bb j = bobAnswer ⟨j, member⟩ · rw [Finset.sum_eq_single (aa coordinate)] · rw [Finset.sum_eq_single (bb coordinate)] · dsimp only [f] by_cases wins : G.predicate x y (aa coordinate) (bb coordinate) = true · rw [if_pos wins, if_pos ⟨alice_matches, rfl⟩, if_pos ⟨bob_matches, rfl⟩, if_pos ⟨alice_matches, bob_matches, wins⟩] · rw [if_neg wins, if_neg (fun h => wins h.2.2)] · intro b _ different simp [f, Ne.symm different] · simp · intro a _ different simp [f, Ne.symm different] · simp · simp [f, bob_matches] · simp [f, alice_matches] def exactFairCoordinateRefinedWinningBornMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (history : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : ℝ := ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D history.seed history.history x y xs ys * (∑ a : A, ∑ b : B, if G.predicate x y a b = true then bornTracePairing S.state.matrix (conditionedAliceCoordinateEffect G n S D history.aliceAnswer xs history.seed.coordinate.val a) (conditionedBobCoordinateEffect G n S D history.bobAnswer ys history.seed.coordinate.val b) else 0) theorem exactFairWinningOutcomeBornMass_eq_refined (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (history : ExactHistoryFlag X Y A B D) (x : X) (y : Y) : exactFairWinningOutcomeBornMass G n S D history x y = exactFairCoordinateRefinedWinningBornMass G n S D history x y := by classical unfold exactFairWinningOutcomeBornMass exactFairCoordinateRefinedWinningBornMass simp only [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ have compatibility : (exactAliceQuestionCompatible D history.seed history.history x xs ∧ exactBobQuestionCompatible D history.seed history.history y ys) ↔ exactRevealCode D history.seed (xs, ys) = history.history ∧ xs history.seed.coordinate.val = x ∧ ys history.seed.coordinate.val = y := (exactRevealCode_compatible_iff D history.seed history.history x y xs ys).symm by_cases compatible : exactAliceQuestionCompatible D history.seed history.history x xs ∧ exactBobQuestionCompatible D history.seed history.history y ys · have actual := compatibility.mp compatible rw [exactFiberQuestionWeight, if_pos compatible, exactFineCoordinateWinningBorn_collapse G n S D history.aliceAnswer history.bobAnswer xs ys history.seed.coordinate.val x y] calc (∑ aa : Fin n → A, ∑ bb : Fin n → B, if exactLocallySampleableCode D (history.seed, (xs, ys, aa, bb)) = (history.seed.coordinate, x, y, history) ∧ repeatedCoordinateWin G n history.seed.coordinate.val (xs, ys, aa, bb) = true then (strategyEventLaw (G.repeat n) S).weight (xs, ys, aa, bb) else 0) = ∑ aa : Fin n → A, ∑ bb : Fin n → B, (G.repeat n).questionWeight xs ys * if (∀ (j : Fin n) (member : j ∈ D), aa j = history.aliceAnswer ⟨j, member⟩) ∧ (∀ (j : Fin n) (member : j ∈ D), bb j = history.bobAnswer ⟨j, member⟩) ∧ G.predicate x y (aa history.seed.coordinate.val) (bb history.seed.coordinate.val) = true then S.outcomeProbability xs ys aa bb else 0 := by apply Finset.sum_congr rfl intro aa _ apply Finset.sum_congr rfl intro bb _ have fiber := exactLocallySampleableCode_fixedSeed_fiber_iff D history x y (xs, ys, aa, bb) have event : (exactLocallySampleableCode D (history.seed, (xs, ys, aa, bb)) = (history.seed.coordinate, x, y, history) ∧ repeatedCoordinateWin G n history.seed.coordinate.val (xs, ys, aa, bb) = true) ↔ ((∀ (j : Fin n) (member : j ∈ D), aa j = history.aliceAnswer ⟨j, member⟩) ∧ (∀ (j : Fin n) (member : j ∈ D), bb j = history.bobAnswer ⟨j, member⟩) ∧ G.predicate x y (aa history.seed.coordinate.val) (bb history.seed.coordinate.val) = true) := by rw [fiber] simp [actual.1, actual.2.1, actual.2.2, repeatedCoordinateWin, and_assoc] by_cases wins : (∀ (j : Fin n) (member : j ∈ D), aa j = history.aliceAnswer ⟨j, member⟩) ∧ (∀ (j : Fin n) (member : j ∈ D), bb j = history.bobAnswer ⟨j, member⟩) ∧ G.predicate x y (aa history.seed.coordinate.val) (bb history.seed.coordinate.val) = true · have selected := event.mpr wins rw [if_pos selected, if_pos wins] rfl · have rejected : ¬ (exactLocallySampleableCode D (history.seed, (xs, ys, aa, bb)) = (history.seed.coordinate, x, y, history) ∧ repeatedCoordinateWin G n history.seed.coordinate.val (xs, ys, aa, bb) = true) := by intro selected exact wins (event.mp selected) rw [if_neg rejected, if_neg wins] simp _ = (G.repeat n).questionWeight xs ys * (∑ aa : Fin n → A, ∑ bb : Fin n → B, if (∀ (j : Fin n) (member : j ∈ D), aa j = history.aliceAnswer ⟨j, member⟩) ∧ (∀ (j : Fin n) (member : j ∈ D), bb j = history.bobAnswer ⟨j, member⟩) ∧ G.predicate x y (aa history.seed.coordinate.val) (bb history.seed.coordinate.val) = true then S.outcomeProbability xs ys aa bb else 0) := by simp only [Finset.mul_sum] · rw [exactFiberQuestionWeight, if_neg compatible, zero_mul] apply Finset.sum_eq_zero intro aa _ apply Finset.sum_eq_zero intro bb _ have no_code : exactLocallySampleableCode D (history.seed, (xs, ys, aa, bb)) ≠ (history.seed.coordinate, x, y, history) := by intro code have conditions := (exactLocallySampleableCode_fixedSeed_fiber_iff D history x y (xs, ys, aa, bb)).mp code exact compatible (compatibility.mpr ⟨conditions.1, conditions.2.1, conditions.2.2.1⟩) simp [no_code] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactFairWinningOutcomeBornMass_eq_fiber_conditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (history : ExactHistoryFlag X Y A B D) (x : X) (y : Y) (supported : exactFiberQuestionMass G n D history.seed history.history x y ≠ 0) : exactFairWinningOutcomeBornMass G n S D history x y = exactFiberQuestionMass G n D history.seed history.history x y * exactJointConditionalWinningMass G n S D history.seed history.history history.aliceAnswer history.bobAnswer x y := by classical rw [exactFairWinningOutcomeBornMass_eq_refined, exactJointConditionalWinningMass_born G n S D history.seed history.history history.aliceAnswer history.bobAnswer x y supported] unfold exactFairCoordinateRefinedWinningBornMass let summand : (Fin n → X) → (Fin n → Y) → A → B → ℝ := fun xs ys a b => if G.predicate x y a b = true then exactFiberQuestionWeight G n D history.seed history.history x y xs ys * bornTracePairing S.state.matrix (conditionedAliceCoordinateEffect G n S D history.aliceAnswer xs history.seed.coordinate.val a) (conditionedBobCoordinateEffect G n S D history.bobAnswer ys history.seed.coordinate.val b) else 0 calc (∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactFiberQuestionWeight G n D history.seed history.history x y xs ys * (∑ a : A, ∑ b : B, if G.predicate x y a b = true then bornTracePairing S.state.matrix (conditionedAliceCoordinateEffect G n S D history.aliceAnswer xs history.seed.coordinate.val a) (conditionedBobCoordinateEffect G n S D history.bobAnswer ys history.seed.coordinate.val b) else 0)) = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ a : A, ∑ b : B, summand xs ys a b := by simp only [summand, Finset.mul_sum, mul_ite, mul_zero] _ = ∑ a : A, ∑ b : B, ∑ xs : Fin n → X, ∑ ys : Fin n → Y, summand xs ys a b := finite_sum_four_swap summand _ = exactFiberQuestionMass G n D history.seed history.history x y * (∑ a : A, ∑ b : B, if G.predicate x y a b = true then ∑ xs : Fin n → X, ∑ ys : Fin n → Y, exactConditionalQuestionWeight G n D history.seed history.history x y xs ys * bornTracePairing S.state.matrix (conditionedAliceCoordinateEffect G n S D history.aliceAnswer xs history.seed.coordinate.val a) (conditionedBobCoordinateEffect G n S D history.bobAnswer ys history.seed.coordinate.val b) else 0) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro a _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro b _ by_cases wins : G.predicate x y a b = true · simp only [if_pos wins] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro xs _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro ys _ dsimp only [summand] rw [if_pos wins] unfold exactConditionalQuestionWeight field_simp [supported] · simp [summand, wins] theorem exactSourceConditionalWinningProbability_eq_normalized_verifier [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (history : ExactHistoryFlag X Y A B D) (accepted : exactHistoryAccepted G n D history) (a₀ : A) (b₀ : B) (x : X) (y : Y) (supported : exactFiberQuestionMass G n D history.seed history.history x y ≠ 0) : exactSourceConditionalWinningProbability G n S D (history.seed.coordinate, x, y, history) = quadraticExpectation (exactSourceWinningEffectCLM G n S D history a₀ b₀ x y) (normalizedPureVector (exactUnnormalizedPsi G n S D history x y)) := by rw [exactSourceConditionalWinningProbability_eq_fine_born_ratio G n S D positive history accepted x y, exactFairWinningOutcomeBornMass_eq_fiber_conditional G n S D history x y supported, exactFairFullOutcomeBornMass_eq_conditioned, exactFairConditionedAnswerBornMass_eq_fiber_norm, exactSourceNormalizedWinningEffect_eq_conditional G n S D history a₀ b₀ x y supported, exactUnnormalizedPsi_norm_sq] exact mul_div_mul_left _ _ supported end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactLocallySampleableLaw_coordinate_eq_of_ne_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) (supported : exactLocallySampleableLaw G n S D t ≠ 0) : t.1 = t.2.2.2.seed.coordinate := by classical by_contra different apply supported unfold exactLocallySampleableLaw exactSourcePushforward groupedMass apply Finset.sum_eq_zero intro q member have code : exactLocallySampleableCode D q = t := by exact ((@Finset.mem_filter (ExactJointOutcome X Y A B D) (fun a => exactLocallySampleableCode D a = t) (fun _ => Classical.propDecidable _) Finset.univ q).mp member).2 have coordinate := congrArg (fun u : ExactLocallySampleableTuple X Y A B D => u.1) code have history_coordinate := congrArg (fun u : ExactLocallySampleableTuple X Y A B D => u.2.2.2.seed.coordinate) code exact False.elim (different (coordinate.symm.trans history_coordinate)) theorem exactLocallySampleableLaw_accepted_of_ne_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) (supported : exactLocallySampleableLaw G n S D t ≠ 0) : exactHistoryAccepted G n D t.2.2.2 := by classical by_contra rejected exact supported (exactLocallySampleableLaw_zero_of_not_accepted G n S D t.1 t.2.1 t.2.2.1 t.2.2.2 rejected) theorem exactLocallySampleableLaw_fiber_ne_zero_of_ne_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) (supported : exactLocallySampleableLaw G n S D t ≠ 0) : exactFiberQuestionMass G n D t.2.2.2.seed t.2.2.2.history t.2.1 t.2.2.1 ≠ 0 := by classical have coordinate := exactLocallySampleableLaw_coordinate_eq_of_ne_zero G n S D t supported have accepted := exactLocallySampleableLaw_accepted_of_ne_zero G n S D t supported intro zero have reveal_zero : exactRevealMass G n D t.2.2.2.seed t.2.2.2.history * G.questionWeight t.2.1 t.2.2.1 = 0 := by simpa [exactFiberQuestionMass_eq_jointQuestionMass, exactJointQuestionMass_eq_reveal_mul_question] using zero apply supported have source := exactLocallySampleableLaw_eq_fair_born G n S D t.2.2.2 t.2.1 t.2.2.1 have tuple : t = (t.2.2.2.seed.coordinate, t.2.1, t.2.2.1, t.2.2.2) := by rcases t with ⟨i, x, y, r⟩ simpa using coordinate rw [tuple, source, if_pos accepted] rw [show exactSeedWeight t.2.2.2.seed * exactRevealMass G n D t.2.2.2.seed t.2.2.2.history * G.questionWeight t.2.1 t.2.2.1 = exactSeedWeight t.2.2.2.seed * (exactRevealMass G n D t.2.2.2.seed t.2.2.2.history * G.questionWeight t.2.1 t.2.2.1) by ring] simp [reveal_zero] theorem exactLocallySampleableLaw_psi_ne_zero_of_ne_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (t : ExactLocallySampleableTuple X Y A B D) (supported : exactLocallySampleableLaw G n S D t ≠ 0) : exactUnnormalizedPsi G n S D t.2.2.2 t.2.1 t.2.2.1 ≠ 0 := by classical have coordinate := exactLocallySampleableLaw_coordinate_eq_of_ne_zero G n S D t supported have accepted := exactLocallySampleableLaw_accepted_of_ne_zero G n S D t supported intro zero apply supported have source := exactLocallySampleableLaw_eq_fair_born G n S D t.2.2.2 t.2.1 t.2.2.1 have tuple : t = (t.2.2.2.seed.coordinate, t.2.1, t.2.2.1, t.2.2.2) := by rcases t with ⟨i, x, y, r⟩ simpa using coordinate rw [tuple, source, if_pos accepted, zero] simp def dependentBlockPOVM {R C : Type*} [Fintype R] [DecidableEq R] [Fintype C] {ι : R → Type*} [∀ r, Fintype (ι r)] [∀ r, DecidableEq (ι r)] (P : (r : R) → POVM C (ι r)) : POVM C (Σ r : R, ι r) where effect c := Matrix.blockDiagonal' fun r => (P r).effect c positive c := by apply posSemidef_blockDiagonal' intro r exact (P r).positive c complete := by classical ext ⟨r, u⟩ ⟨s, v⟩ by_cases same : r = s · subst s have completed := congrArg (fun M : Matrix (ι r) (ι r) ℂ => M u v) (P r).complete simpa [Matrix.sum_apply, Matrix.blockDiagonal'_apply, Matrix.one_apply] using completed · simp [Matrix.sum_apply, Matrix.blockDiagonal'_apply, same] def reindexedPOVM {C d e : Type*} [Fintype C] [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (basis : d ≃ e) (P : POVM C d) : POVM C e where effect c := (P.effect c).submatrix basis.symm basis.symm positive c := (P.positive c).submatrix basis.symm complete := by classical ext i j have completed := congrArg (fun M : Matrix d d ℂ => M (basis.symm i) (basis.symm j)) P.complete simpa [Matrix.sum_apply, Matrix.one_apply] using completed def twoBlockPOVM {C d e : Type} [Fintype C] [DecidableEq C] [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (P : POVM C d) (Q : POVM C e) : POVM C (d ⊕ e) := by classical letI : (b : Bool) → Fintype (bif b then e else d) | false => inferInstanceAs (Fintype d) | true => inferInstanceAs (Fintype e) letI : (b : Bool) → DecidableEq (bif b then e else d) | false => inferInstanceAs (DecidableEq d) | true => inferInstanceAs (DecidableEq e) let blocks : (b : Bool) → POVM C (bif b then e else d) | false => P | true => Q exact reindexedPOVM (Equiv.sumEquivSigmaBool d e).symm (dependentBlockPOVM blocks) def deterministicOutcomePOVM {C d : Type*} [Fintype C] [DecidableEq C] [Fintype d] [DecidableEq d] (default : C) : POVM C d where effect c := if c = default then 1 else 0 positive c := by split_ifs · exact Matrix.PosSemidef.one · exact Matrix.PosSemidef.zero complete := by classical simp def pOVMChangeDecidableEq {C d : Type*} [Fintype C] [Fintype d] (source target : DecidableEq d) (P : @POVM C d inferInstance inferInstance source) : @POVM C d inferInstance inferInstance target where effect c := @POVM.effect C d inferInstance inferInstance source P c positive c := @POVM.positive C d inferInstance inferInstance source P c complete := by classical ext i j have completed := congrArg (fun M : Matrix d d ℂ => M i j) (@POVM.complete C d inferInstance inferInstance source P) simp only [Matrix.sum_apply, Matrix.one_apply] at completed ⊢ by_cases same : i = j · subst j simpa using completed · simpa [same] using completed def exactSourceAlicePaddedPOVM [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (x : X) : POVM A (ExactPaddedLocalIndex G n S D r) := by classical exact twoBlockPOVM (deterministicOutcomePOVM (d := PUnit) a₀) (twoBlockPOVM (exactSourceAliceRefinedPOVM G n S D r a₀ x) (deterministicOutcomePOVM (d := ExactBobLocalIndex G n S D r) a₀)) def exactSourceBobPaddedPOVM [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (b₀ : B) (y : Y) : POVM B (ExactPaddedLocalIndex G n S D r) := by classical exact twoBlockPOVM (deterministicOutcomePOVM (d := PUnit) b₀) (twoBlockPOVM (deterministicOutcomePOVM (d := ExactAliceLocalIndex G n S D r) b₀) (exactSourceBobRefinedPOVM G n S D r b₀ y)) def exactSourceGlobalAlicePOVM [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (x : X) : POVM A (ExactGlobalHistoryLocalIndex G n S D) := by classical let actual := twoBlockPOVM (deterministicOutcomePOVM (d := PUnit) a₀) (dependentBlockPOVM (fun r : ExactHistoryFlag X Y A B D => exactSourceAlicePaddedPOVM G n S D r a₀ x)) exact pOVMChangeDecidableEq (@instDecidableEqSum PUnit (Σ r : ExactHistoryFlag X Y A B D, ExactPaddedLocalIndex G n S D r) inferInstance inferInstance) (Classical.decEq (ExactGlobalHistoryLocalIndex G n S D)) actual def exactSourceGlobalBobPOVM [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (b₀ : B) (y : Y) : POVM B (ExactGlobalHistoryLocalIndex G n S D) := by classical let actual := twoBlockPOVM (deterministicOutcomePOVM (d := PUnit) b₀) (dependentBlockPOVM (fun r : ExactHistoryFlag X Y A B D => exactSourceBobPaddedPOVM G n S D r b₀ y)) exact pOVMChangeDecidableEq (@instDecidableEqSum PUnit (Σ r : ExactHistoryFlag X Y A B D, ExactPaddedLocalIndex G n S D r) inferInstance inferInstance) (Classical.decEq (ExactGlobalHistoryLocalIndex G n S D)) actual def exactSourceGlobalCatalystAlicePOVM [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (a₀ : A) (x : X) : POVM A (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) := by classical exact reindexedPOVM finProdFinEquiv (purificationAlicePOVM (k := Fin e) (reindexedPOVM (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) (exactSourceGlobalAlicePOVM G n S D a₀ x))) def exactSourceGlobalCatalystBobPOVM [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (b₀ : B) (y : Y) : POVM B (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) := by classical exact reindexedPOVM finProdFinEquiv (purificationAlicePOVM (k := Fin e) (reindexedPOVM (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) (exactSourceGlobalBobPOVM G n S D b₀ y))) end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable @[simp] theorem twoBlockPOVM_effect_inl {C d e : Type} [Fintype C] [DecidableEq C] [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (P : POVM C d) (Q : POVM C e) (c : C) (i j : d) : (twoBlockPOVM P Q).effect c (.inl i) (.inl j) = P.effect c i j := by classical simp [twoBlockPOVM, reindexedPOVM, dependentBlockPOVM, Equiv.sumEquivSigmaBool, Matrix.blockDiagonal'_apply] @[simp] theorem twoBlockPOVM_effect_inr {C d e : Type} [Fintype C] [DecidableEq C] [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (P : POVM C d) (Q : POVM C e) (c : C) (i j : e) : (twoBlockPOVM P Q).effect c (.inr i) (.inr j) = Q.effect c i j := by classical simp [twoBlockPOVM, reindexedPOVM, dependentBlockPOVM, Equiv.sumEquivSigmaBool, Matrix.blockDiagonal'_apply] @[simp] theorem dependentBlockPOVM_effect_same {R C : Type*} [Fintype R] [DecidableEq R] [Fintype C] {ι : R → Type*} [∀ r, Fintype (ι r)] [∀ r, DecidableEq (ι r)] (P : (r : R) → POVM C (ι r)) (r : R) (c : C) (i j : ι r) : (dependentBlockPOVM P).effect c ⟨r, i⟩ ⟨r, j⟩ = (P r).effect c i j := by classical simp [dependentBlockPOVM, Matrix.blockDiagonal'_apply] variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] @[simp] theorem exactSourceGlobalAlicePOVM_effect [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ a : A) (x : X) (i j : ExactAliceLocalIndex G n S D r) : (exactSourceGlobalAlicePOVM G n S D a₀ x).effect a (.inr ⟨r, .inr (.inl i)⟩) (.inr ⟨r, .inr (.inl j)⟩) = (exactSourceAliceRefinedPOVM G n S D r a₀ x).effect a i j := by classical simp [exactSourceGlobalAlicePOVM, pOVMChangeDecidableEq, exactSourceAlicePaddedPOVM] @[simp] theorem exactSourceGlobalBobPOVM_effect [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (b₀ b : B) (y : Y) (i j : ExactBobLocalIndex G n S D r) : (exactSourceGlobalBobPOVM G n S D b₀ y).effect b (.inr ⟨r, .inr (.inr i)⟩) (.inr ⟨r, .inr (.inr j)⟩) = (exactSourceBobRefinedPOVM G n S D r b₀ y).effect b i j := by classical simp [exactSourceGlobalBobPOVM, pOVMChangeDecidableEq, exactSourceBobPaddedPOVM] theorem matrixQuadraticExpectation_expand {d : Type*} [Fintype d] [DecidableEq d] (M : Matrix d d ℂ) (z : EuclideanSpace ℂ d) : quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) M) z = (∑ i : d, (∑ j : d, M i j * z j) * star (z i)).re := by simp [quadraticExpectation, EuclideanSpace.inner_eq_star_dotProduct, Matrix.mulVec, dotProduct] theorem finiteSum_injective_support {d e K : Type*} [Fintype d] [Fintype e] [AddCommMonoid K] (f : d → e) (injective : Function.Injective f) (g : e → K) (supported : ∀ j : e, (∀ i : d, f i ≠ j) → g j = 0) : (∑ j : e, g j) = ∑ i : d, g (f i) := by classical calc (∑ j : e, g j) = ∑ j ∈ Finset.univ.image f, g j := by symm apply Finset.sum_subset (Finset.subset_univ _) intro j _ outside apply supported j intro i same exact outside (Finset.mem_image.mpr ⟨i, Finset.mem_univ i, same⟩) _ = ∑ i : d, g (f i) := by rw [Finset.sum_image] intro i _ j _ same exact injective same theorem matrixQuadraticExpectation_injective {d e : Type*} [Fintype d] [Fintype e] [DecidableEq d] [DecidableEq e] (f : d → e) (injective : Function.Injective f) (M : Matrix e e ℂ) (N : Matrix d d ℂ) (v : EuclideanSpace ℂ e) (z : EuclideanSpace ℂ d) (included : ∀ i : d, v (f i) = z i) (supported : ∀ j : e, (∀ i : d, f i ≠ j) → v j = 0) (compressed : ∀ i j : d, M (f i) (f j) = N i j) : quadraticExpectation (Matrix.toEuclideanCLM (n := e) (𝕜 := ℂ) M) v = quadraticExpectation (Matrix.toEuclideanCLM (n := d) (𝕜 := ℂ) N) z := by classical rw [matrixQuadraticExpectation_expand, matrixQuadraticExpectation_expand] congr 1 rw [finiteSum_injective_support f injective (fun i : e => (∑ j : e, M i j * v j) * star (v i)) (by intro i outside simp [supported i outside])] apply Finset.sum_congr rfl intro i _ rw [included i] congr 1 rw [finiteSum_injective_support f injective (fun j : e => M (f i) j * v j) (by intro j outside simp [supported j outside])] apply Finset.sum_congr rfl intro j _ rw [compressed i j, included j] def exactSourceGlobalJointBasis (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) → (ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) | (i, j) => (.inr ⟨r, .inr (.inl i)⟩, .inr ⟨r, .inr (.inr j)⟩) theorem exactSourceGlobalJointBasis_injective (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) : Function.Injective (exactSourceGlobalJointBasis G n S D r) := by intro i j same rcases i with ⟨ia, ib⟩ rcases j with ⟨ja, jb⟩ have alice := congrArg Prod.fst same have bob := congrArg Prod.snd same change (Sum.inr ⟨r, .inr (.inl ia)⟩ : ExactGlobalHistoryLocalIndex G n S D) = Sum.inr ⟨r, .inr (.inl ja)⟩ at alice change (Sum.inr ⟨r, .inr (.inr ib)⟩ : ExactGlobalHistoryLocalIndex G n S D) = Sum.inr ⟨r, .inr (.inr jb)⟩ at bob have alice_block : (Sum.inr (.inl ia) : ExactPaddedLocalIndex G n S D r) = Sum.inr (.inl ja) := eq_of_heq (Sigma.mk.inj (Sum.inr.inj alice)).2 have bob_block : (Sum.inr (.inr ib) : ExactPaddedLocalIndex G n S D r) = Sum.inr (.inr jb) := eq_of_heq (Sigma.mk.inj (Sum.inr.inj bob)).2 have alice' : ia = ja := Sum.inl.inj (Sum.inr.inj alice_block) have bob' : ib = jb := Sum.inr.inj (Sum.inr.inj bob_block) exact Prod.ext alice' bob' theorem exactSourceGlobalJointBasis_vector (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (z : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r)) (i : ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) : exactGlobalHistoryVector G n S D r (exactPaddedVector G n S D r z) (exactSourceGlobalJointBasis G n S D r i) = z i := by rcases i with ⟨ia, ib⟩ change (if ha : r = r then if hb : r = r then exactPaddedVector G n S D r z (ha ▸ Sum.inr (Sum.inl ia), hb ▸ Sum.inr (Sum.inr ib)) else 0 else 0) = z (ia, ib) simp only [exactPaddedVector, dite_true] theorem exactSourceGlobalJointBasis_support (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (z : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r)) (j : ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) (outside : ∀ i, exactSourceGlobalJointBasis G n S D r i ≠ j) : exactGlobalHistoryVector G n S D r (exactPaddedVector G n S D r z) j = 0 := by classical rcases j with ⟨u, v⟩ rcases u with u | ⟨ru, u⟩ · rfl rcases v with v | ⟨rv, v⟩ · rfl change (if ha : ru = r then if hb : rv = r then exactPaddedVector G n S D r z (ha ▸ u, hb ▸ v) else 0 else 0) = 0 by_cases hu : ru = r · subst ru by_cases hv : rv = r · subst rv simp only [dite_true] rcases u with u | (u | u) · rfl · rcases v with v | (v | v) · rfl · rfl · exact False.elim (outside (u, v) (by rfl)) · rfl · simp only [dif_neg hv, dite_true] · simp only [dif_neg hu] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactSourceGlobalWinningEffect [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) (x : X) (y : Y) : Matrix (ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) (ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then (exactSourceGlobalAlicePOVM G n S D a₀ x).effect a ⊗ₖ (exactSourceGlobalBobPOVM G n S D b₀ y).effect b else 0 theorem exactSourceGlobalWinningEffect_compression [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) (i j : ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r) : exactSourceGlobalWinningEffect G n S D a₀ b₀ x y (exactSourceGlobalJointBasis G n S D r i) (exactSourceGlobalJointBasis G n S D r j) = exactSourceWinningEffect G n S D r a₀ b₀ x y i j := by classical rcases i with ⟨ia, ib⟩ rcases j with ⟨ja, jb⟩ simp only [exactSourceGlobalWinningEffect, exactSourceWinningEffect, Matrix.sum_apply] apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ split_ifs · simp only [exactSourceGlobalJointBasis, exactSourceJointEffect, Matrix.kroneckerMap_apply, exactSourceGlobalAlicePOVM_effect, exactSourceGlobalBobPOVM_effect] · rfl theorem exactSourceGlobalWinningEffect_quadratic [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (a₀ : A) (b₀ : B) (x : X) (y : Y) (z : EuclideanSpace ℂ (ExactAliceLocalIndex G n S D r × ExactBobLocalIndex G n S D r)) : quadraticExpectation (Matrix.toEuclideanCLM (n := ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) (𝕜 := ℂ) (exactSourceGlobalWinningEffect G n S D a₀ b₀ x y)) (exactGlobalHistoryVector G n S D r (exactPaddedVector G n S D r z)) = quadraticExpectation (exactSourceWinningEffectCLM G n S D r a₀ b₀ x y) z := by classical unfold exactSourceWinningEffectCLM apply matrixQuadraticExpectation_injective (exactSourceGlobalJointBasis G n S D r) (exactSourceGlobalJointBasis_injective G n S D r) · exact exactSourceGlobalJointBasis_vector G n S D r z · exact exactSourceGlobalJointBasis_support G n S D r z · exact exactSourceGlobalWinningEffect_compression G n S D r a₀ b₀ x y end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1200000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] @[simp] theorem reindexedCatalystPOVM_effect {C d : Type*} [Fintype C] [Fintype d] [DecidableEq d] (P : POVM C d) (e : ℕ) (c : C) (i j : d) (k l : Fin e) : (reindexedPOVM finProdFinEquiv (purificationAlicePOVM (k := Fin e) (reindexedPOVM (Fintype.equivFin d) P))).effect c (finProdFinEquiv ((Fintype.equivFin d) i, k)) (finProdFinEquiv ((Fintype.equivFin d) j, l)) = P.effect c i j * (if k = l then 1 else 0) := by classical simp [reindexedPOVM, purificationAlicePOVM, Matrix.kroneckerMap_apply, Matrix.one_apply] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] @[simp] theorem exactSourceGlobalCatalystBobPOVM_effect [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (b₀ b : B) (y : Y) (i j : ExactGlobalHistoryLocalIndex G n S D) (k l : Fin e) : (exactSourceGlobalCatalystBobPOVM G n S D e b₀ y).effect b (finProdFinEquiv (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D) i, k)) (finProdFinEquiv (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D) j, l)) = (exactSourceGlobalBobPOVM G n S D b₀ y).effect b i j * (if k = l then 1 else 0) := by classical simp [exactSourceGlobalCatalystBobPOVM, reindexedPOVM, purificationAlicePOVM, Matrix.kroneckerMap_apply, Matrix.one_apply] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem reweightedSeedPrefixEntropyIncrement_eq_actual_atom_sum {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (default : V) (k : Fin h) : reweightedSeedPrefixEntropyIncrement seedLaw G n S D projection default k = ∑ point : K × ExactOutcome X Y A B n, reweightedSeedPosterior seedLaw G n S D point * finiteRelativeEntropy (jointConditional (groupedMass (exactPrefixNextCode default k) (reweightedSeedPrefixJoint seedLaw G n S D projection)) (finitePrefixMask default k.castSucc (((projection point).1, repeatedConditionedAnswerFlag G n S D point.2), (projection point).2))) (jointConditional (groupedMass (exactPrefixNextCode default k) (reweightedSeedPrefixPrior seedLaw G n S D projection)) (finitePrefixMask default k.castSucc (((projection point).1, repeatedConditionedAnswerFlag G n S D point.2), (projection point).2))) := by classical let joint := reweightedSeedPrefixJoint seedLaw G n S D projection let prior := reweightedSeedPrefixPrior seedLaw G n S D projection let posterior := reweightedSeedPosterior seedLaw G n S D let augmented : K × ExactOutcome X Y A B n → (Ω × ConditionedAnswerFlag A B D) × (Fin h → V) := fun point => (((projection point).1, repeatedConditionedAnswerFlag G n S D point.2), (projection point).2) let posteriorNext := groupedMass (exactPrefixNextCode default k) joint let priorNext := groupedMass (exactPrefixNextCode default k) prior let score : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V) → ℝ := fun context => finiteRelativeEntropy (jointConditional posteriorNext (finitePrefixMask default k.castSucc context)) (jointConditional priorNext (finitePrefixMask default k.castSucc context)) have hjoint : joint = groupedMass augmented posterior := by funext target exact reweightedSeedPrefixJoint_as_actual_flagged_pushforward seedLaw G n S D projection target calc reweightedSeedPrefixEntropyIncrement seedLaw G n S D projection default k = ∑ context : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V), groupedMass (finitePrefixMask default k.castSucc) joint context * finiteRelativeEntropy (jointConditional posteriorNext context) (jointConditional priorNext context) := reweightedSeedPrefixEntropyIncrement_eq_conditional seedLaw G n S D positive projection default k _ = ∑ context : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V), jointFirstMarginal posteriorNext context * finiteRelativeEntropy (jointConditional posteriorNext context) (jointConditional priorNext context) := by apply Finset.sum_congr rfl intro context _ congr 1 convert (congrFun (exactPrefixNext_firstMarginal joint default k) context).symm using 1 · exact congrFun (exactGroupedMass_decidableEq_irrel _ _ (finitePrefixMask default k.castSucc) joint) context · exact congrArg (fun law => jointFirstMarginal law context) (exactGroupedMass_decidableEq_irrel _ _ (exactPrefixNextCode default k) joint) _ = ∑ target : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V), joint target * score target := by exact finiteNextInformation_eq_atom_sum (finitePrefixMask default k.castSucc) (fun target : (Ω × ConditionedAnswerFlag A B D) × (Fin h → V) => target.2 k) joint (fun context => jointConditional priorNext context) _ = ∑ point : K × ExactOutcome X Y A B n, posterior point * score (augmented point) := by rw [hjoint] exact finiteGroupedExpectation_eq_atom_sum augmented posterior score _ = _ := rfl end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactStrategyQuestionCodeGroupedMass {C : Type*} [Fintype C] [DecidableEq C] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (code : (Fin n → X) → (Fin n → Y) → C) (target : C) : groupedMass (fun outcome : ExactOutcome X Y A B n => code outcome.1 outcome.2.1) (strategyEventLaw (G.repeat n) S).weight target = ∑ xs : Fin n → X, ∑ ys : Fin n → Y, if code xs ys = target then (G.repeat n).questionWeight xs ys else 0 := by classical unfold groupedMass rw [Finset.sum_filter] simp only [Fintype.sum_prod_type] change (∑ xs : Fin n → X, ∑ ys : Fin n → Y, ∑ answersA : Fin n → A, ∑ answersB : Fin n → B, if code xs ys = target then (G.repeat n).questionWeight xs ys * S.outcomeProbability xs ys answersA answersB else 0) = _ apply Finset.sum_congr rfl intro xs _ apply Finset.sum_congr rfl intro ys _ by_cases compatible : code xs ys = target · simp only [if_pos compatible] calc (∑ answersA : Fin n → A, ∑ answersB : Fin n → B, (G.repeat n).questionWeight xs ys * S.outcomeProbability xs ys answersA answersB) = (G.repeat n).questionWeight xs ys * (∑ answersA : Fin n → A, ∑ answersB : Fin n → B, S.outcomeProbability xs ys answersA answersB) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro answersA _ rw [Finset.mul_sum] _ = (G.repeat n).questionWeight xs ys := by rw [S.outcomeProbability_normalized xs ys] ring · simp [compatible] theorem exactRepeatedQuestionWeight_splitAt_bob (G : Game X Y A B) (n : ℕ) (i : Fin n) (xs : Fin n → X) (y : Y) (tail : {j : Fin n // j ≠ i} → Y) : (G.repeat n).questionWeight xs ((Equiv.funSplitAt i Y).symm (y, tail)) = G.questionWeight (xs i) y * ∏ j ∈ (Finset.univ : Finset (Fin n)).erase i, G.questionWeight (xs j) ((Equiv.funSplitAt i Y).symm (y, tail) j) := by classical rw [Game.repeat_questionWeight] rw [← Finset.mul_prod_erase (Finset.univ : Finset (Fin n)) (fun j : Fin n => G.questionWeight (xs j) ((Equiv.funSplitAt i Y).symm (y, tail) j)) (Finset.mem_univ i)] simp [Equiv.funSplitAt, Equiv.piSplitAt] theorem exactRepeatedQuestionTail_splitAt_bob (G : Game X Y A B) (n : ℕ) (i : Fin n) (xs : Fin n → X) (y y' : Y) (tail : {j : Fin n // j ≠ i} → Y) : (∏ j ∈ (Finset.univ : Finset (Fin n)).erase i, G.questionWeight (xs j) ((Equiv.funSplitAt i Y).symm (y, tail) j)) = (∏ j ∈ (Finset.univ : Finset (Fin n)).erase i, G.questionWeight (xs j) ((Equiv.funSplitAt i Y).symm (y', tail) j)) := by classical apply Finset.prod_congr rfl intro j hj have different : j ≠ i := (Finset.mem_erase.mp hj).1 simp [Equiv.funSplitAt, Equiv.piSplitAt, different] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactStrategyStableBobQuestionCode_joint_factor {C : Type*} [Fintype C] [DecidableEq C] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (coordinate : Fin n) (code : (Fin n → X) → (Fin n → Y) → C) (target : C) (question : X) (next : Y) (stable : ∀ (xs : Fin n → X) (tail : {j : Fin n // j ≠ coordinate} → Y) (y y' : Y), code xs ((Equiv.funSplitAt coordinate Y).symm (y, tail)) = code xs ((Equiv.funSplitAt coordinate Y).symm (y', tail))) (determines : ∀ (xs : Fin n → X) (ys : Fin n → Y), code xs ys = target → xs coordinate = question) : groupedMass (fun outcome : ExactOutcome X Y A B n => (code outcome.1 outcome.2.1, outcome.2.1 coordinate)) (strategyEventLaw (G.repeat n) S).weight (target, next) = G.conditionalYGivenX question next * groupedMass (fun outcome : ExactOutcome X Y A B n => code outcome.1 outcome.2.1) (strategyEventLaw (G.repeat n) S).weight target := by classical rw [exactStrategyQuestionCodeGroupedMass G n S (fun xs ys => (code xs ys, ys coordinate)) (target, next), exactStrategyQuestionCodeGroupedMass G n S code target] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro xs _ let split := Equiv.funSplitAt coordinate Y have hsplit (f : (Fin n → Y) → ℝ) : (∑ ys : Fin n → Y, f ys) = ∑ pair : Y × ({j : Fin n // j ≠ coordinate} → Y), f (split.symm pair) := (split.symm.sum_comp f).symm rw [hsplit (fun ys => if (code xs ys, ys coordinate) = (target, next) then (G.repeat n).questionWeight xs ys else 0), hsplit (fun ys => if code xs ys = target then (G.repeat n).questionWeight xs ys else 0)] simp only [Fintype.sum_prod_type] conv_lhs => rw [Finset.sum_comm] conv_rhs => arg 2 rw [Finset.sum_comm] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro tail _ have same_code (y : Y) : code xs (split.symm (y, tail)) = code xs (split.symm (next, tail)) := stable xs tail y next have same_tail (y : Y) : (∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight (xs j) (split.symm (y, tail) j)) = ∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight (xs j) (split.symm (next, tail) j) := exactRepeatedQuestionTail_splitAt_bob G n coordinate xs y next tail by_cases compatible : code xs (split.symm (next, tail)) = target · have hx : xs coordinate = question := determines xs (split.symm (next, tail)) compatible have marked (y : Y) : split.symm (y, tail) coordinate = y := by simp [split, Equiv.funSplitAt, Equiv.piSplitAt] simp_rw [same_code, marked] simp only [compatible, Prod.mk.injEq, true_and, ↓reduceIte] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have hweight (y : Y) : (G.repeat n).questionWeight xs (split.symm (y, tail)) = G.questionWeight (xs coordinate) y * (∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight (xs j) (split.symm (next, tail) j)) := by calc (G.repeat n).questionWeight xs (split.symm (y, tail)) = G.questionWeight (xs coordinate) y * (∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight (xs j) (split.symm (y, tail) j)) := by exact exactRepeatedQuestionWeight_splitAt_bob G n coordinate xs y tail _ = _ := by rw [same_tail y] simp_rw [hweight] rw [← Finset.sum_mul] change G.questionWeight (xs coordinate) next * _ = G.conditionalYGivenX question next * (G.marginalX (xs coordinate) * _) rw [hx] rw [← G.marginalX_mul_conditionalYGivenX question next] ring · simp_rw [same_code] simp [compatible] theorem exactRepeatedQuestionWeight_splitAt_alice (G : Game X Y A B) (n : ℕ) (coordinate : Fin n) (ys : Fin n → Y) (x : X) (tail : {j : Fin n // j ≠ coordinate} → X) : (G.repeat n).questionWeight ((Equiv.funSplitAt coordinate X).symm (x, tail)) ys = G.questionWeight x (ys coordinate) * ∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight ((Equiv.funSplitAt coordinate X).symm (x, tail) j) (ys j) := by classical rw [Game.repeat_questionWeight] rw [← Finset.mul_prod_erase (Finset.univ : Finset (Fin n)) (fun j : Fin n => G.questionWeight ((Equiv.funSplitAt coordinate X).symm (x, tail) j) (ys j)) (Finset.mem_univ coordinate)] simp [Equiv.funSplitAt, Equiv.piSplitAt] theorem exactRepeatedQuestionTail_splitAt_alice (G : Game X Y A B) (n : ℕ) (coordinate : Fin n) (ys : Fin n → Y) (x x' : X) (tail : {j : Fin n // j ≠ coordinate} → X) : (∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight ((Equiv.funSplitAt coordinate X).symm (x, tail) j) (ys j)) = ∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight ((Equiv.funSplitAt coordinate X).symm (x', tail) j) (ys j) := by classical apply Finset.prod_congr rfl intro j hj have different : j ≠ coordinate := (Finset.mem_erase.mp hj).1 simp [Equiv.funSplitAt, Equiv.piSplitAt, different] theorem exactStrategyStableAliceQuestionCode_joint_factor {C : Type*} [Fintype C] [DecidableEq C] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (coordinate : Fin n) (code : (Fin n → X) → (Fin n → Y) → C) (target : C) (question : Y) (next : X) (stable : ∀ (ys : Fin n → Y) (tail : {j : Fin n // j ≠ coordinate} → X) (x x' : X), code ((Equiv.funSplitAt coordinate X).symm (x, tail)) ys = code ((Equiv.funSplitAt coordinate X).symm (x', tail)) ys) (determines : ∀ (xs : Fin n → X) (ys : Fin n → Y), code xs ys = target → ys coordinate = question) : groupedMass (fun outcome : ExactOutcome X Y A B n => (code outcome.1 outcome.2.1, outcome.1 coordinate)) (strategyEventLaw (G.repeat n) S).weight (target, next) = G.conditionalXGivenY question next * groupedMass (fun outcome : ExactOutcome X Y A B n => code outcome.1 outcome.2.1) (strategyEventLaw (G.repeat n) S).weight target := by classical rw [exactStrategyQuestionCodeGroupedMass G n S (fun xs ys => (code xs ys, xs coordinate)) (target, next), exactStrategyQuestionCodeGroupedMass G n S code target] conv_lhs => rw [Finset.sum_comm] conv_rhs => arg 2 rw [Finset.sum_comm] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro ys _ let split := Equiv.funSplitAt coordinate X have hsplit (f : (Fin n → X) → ℝ) : (∑ xs : Fin n → X, f xs) = ∑ pair : X × ({j : Fin n // j ≠ coordinate} → X), f (split.symm pair) := (split.symm.sum_comp f).symm rw [hsplit (fun xs => if (code xs ys, xs coordinate) = (target, next) then (G.repeat n).questionWeight xs ys else 0), hsplit (fun xs => if code xs ys = target then (G.repeat n).questionWeight xs ys else 0)] simp only [Fintype.sum_prod_type] conv_lhs => rw [Finset.sum_comm] conv_rhs => arg 2 rw [Finset.sum_comm] rw [Finset.mul_sum] apply Finset.sum_congr rfl intro tail _ have same_code (x : X) : code (split.symm (x, tail)) ys = code (split.symm (next, tail)) ys := stable ys tail x next have same_tail (x : X) : (∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight (split.symm (x, tail) j) (ys j)) = ∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight (split.symm (next, tail) j) (ys j) := exactRepeatedQuestionTail_splitAt_alice G n coordinate ys x next tail by_cases compatible : code (split.symm (next, tail)) ys = target · have hy : ys coordinate = question := determines (split.symm (next, tail)) ys compatible have marked (x : X) : split.symm (x, tail) coordinate = x := by simp [split, Equiv.funSplitAt, Equiv.piSplitAt] simp_rw [same_code, marked] simp only [compatible, Prod.mk.injEq, true_and, ↓reduceIte] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have hweight (x : X) : (G.repeat n).questionWeight (split.symm (x, tail)) ys = G.questionWeight x (ys coordinate) * (∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight (split.symm (next, tail) j) (ys j)) := by calc (G.repeat n).questionWeight (split.symm (x, tail)) ys = G.questionWeight x (ys coordinate) * (∏ j ∈ (Finset.univ : Finset (Fin n)).erase coordinate, G.questionWeight (split.symm (x, tail) j) (ys j)) := by exact exactRepeatedQuestionWeight_splitAt_alice G n coordinate ys x tail _ = _ := by rw [same_tail x] simp_rw [hweight] rw [← Finset.sum_mul] change G.questionWeight next (ys coordinate) * _ = G.conditionalXGivenY question next * (G.marginalY (ys coordinate) * _) rw [hy] rw [← G.marginalY_mul_conditionalXGivenY next question] ring · simp_rw [same_code] simp [compatible] end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 3600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactAliceSourceAtomCode {n : ℕ} (D : Finset (Fin n)) : ExactJointOutcome X Y A B D → (SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y) := fun point => ((point.1.coordinate, point.2.1 point.1.coordinate.val), (exactHistoryCode D point, point.2.2.1 point.1.coordinate.val)) def exactBobSourceAtomCode {n : ℕ} (D : Finset (Fin n)) : ExactJointOutcome X Y A B D → (SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X) := fun point => ((point.1.coordinate, point.2.2.1 point.1.coordinate.val), (exactHistoryCode D point, point.2.1 point.1.coordinate.val)) theorem exactAliceInformationPosterior_eq_jointPushforward (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : exactAliceInformationPosterior G n S D = groupedMass (exactAliceSourceAtomCode (X := X) (Y := Y) (A := A) (B := B) D) (exactPostselectedJointLaw G n S D) := by classical funext target unfold exactAliceInformationPosterior exactLocallySampleableLaw exactSourcePushforward groupedMass apply Finset.sum_congr · ext point simp only [Finset.mem_filter, Finset.mem_univ, true_and] change (exactLocallySampleableCode D point = (exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm target) ↔ (exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D) (exactLocallySampleableCode D point) = target exact ((exactAliceInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).apply_eq_iff_eq_symm_apply).symm · intro point _ rfl theorem exactBobInformationPosterior_eq_jointPushforward (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : exactBobInformationPosterior G n S D = groupedMass (exactBobSourceAtomCode (X := X) (Y := Y) (A := A) (B := B) D) (exactPostselectedJointLaw G n S D) := by classical funext target unfold exactBobInformationPosterior exactLocallySampleableLaw exactSourcePushforward groupedMass apply Finset.sum_congr · ext point simp only [Finset.mem_filter, Finset.mem_univ, true_and] change (exactLocallySampleableCode D point = (exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).symm target) ↔ (exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D) (exactLocallySampleableCode D point) = target exact ((exactBobInformationEquiv (X := X) (Y := Y) (A := A) (B := B) D).apply_eq_iff_eq_symm_apply).symm · intro point _ rfl theorem exactAliceSourceConditionalInformation_eq_joint_atom_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactAliceSourceConditionalInformation G n S D base = ∑ point : ExactJointOutcome X Y A B D, exactPostselectedJointLaw G n S D point * finiteRelativeEntropy (jointConditional (fun atom : ((SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D) × Y => exactAliceInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((point.1.coordinate, point.2.1 point.1.coordinate.val), exactHistoryCode D point)) (G.conditionalYGivenX (point.2.1 point.1.coordinate.val)) := by classical let posterior := exactAliceInformationPosterior G n S D let code := exactAliceSourceAtomCode (X := X) (Y := Y) (A := A) (B := B) D let joint := exactPostselectedJointLaw G n S D let score : (SourceRemainingCoordinate D × X) × (ExactHistoryFlag X Y A B D × Y) → ℝ := fun point => finiteRelativeEntropy (jointConditional (fun atom : ((SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D) × Y => posterior (atom.1.1, (atom.1.2, atom.2))) (point.1, point.2.1)) (G.conditionalYGivenX point.1.2) have hsource := exactAliceSourceConditionalInformation_eq_atom_sum G n S D remaining positive base change exactAliceSourceConditionalInformation G n S D base = ∑ point, posterior point * score point at hsource have hposterior : posterior = groupedMass code joint := exactAliceInformationPosterior_eq_jointPushforward G n S D calc exactAliceSourceConditionalInformation G n S D base = ∑ point, posterior point * score point := hsource _ = ∑ point : ExactJointOutcome X Y A B D, joint point * score (code point) := by rw [hposterior] exact finiteGroupedExpectation_eq_atom_sum code joint score _ = _ := rfl theorem exactBobSourceConditionalInformation_eq_joint_atom_sum (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactBobSourceConditionalInformation G n S D base = ∑ point : ExactJointOutcome X Y A B D, exactPostselectedJointLaw G n S D point * finiteRelativeEntropy (jointConditional (fun atom : ((SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D) × X => exactBobInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((point.1.coordinate, point.2.2.1 point.1.coordinate.val), exactHistoryCode D point)) (G.conditionalXGivenY (point.2.2.1 point.1.coordinate.val)) := by classical let posterior := exactBobInformationPosterior G n S D let code := exactBobSourceAtomCode (X := X) (Y := Y) (A := A) (B := B) D let joint := exactPostselectedJointLaw G n S D let score : (SourceRemainingCoordinate D × Y) × (ExactHistoryFlag X Y A B D × X) → ℝ := fun point => finiteRelativeEntropy (jointConditional (fun atom : ((SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D) × X => posterior (atom.1.1, (atom.1.2, atom.2))) (point.1, point.2.1)) (G.conditionalXGivenY point.1.2) have hsource := exactBobSourceConditionalInformation_eq_atom_sum G n S D remaining positive base change exactBobSourceConditionalInformation G n S D base = ∑ point, posterior point * score point at hsource have hposterior : posterior = groupedMass code joint := exactBobInformationPosterior_eq_jointPushforward G n S D calc exactBobSourceConditionalInformation G n S D base = ∑ point, posterior point * score point := hsource _ = ∑ point : ExactJointOutcome X Y A B D, joint point * score (code point) := by rw [hposterior] exact finiteGroupedExpectation_eq_atom_sum code joint score _ = _ := rfl end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 4200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem exactSeedWeight_pos_of_seed {M : Type*} [Fintype M] [DecidableEq M] (seed : ExactForwardSeed M) : 0 < exactSeedWeight seed := by have nonempty : 0 < Fintype.card M := Fintype.card_pos_iff.mpr ⟨seed.coordinate⟩ have bits : 0 < Fintype.card (M → Bool) := Fintype.card_pos_iff.mpr ⟨fun _ => false⟩ have left : 0 < Fintype.card (Equiv.Perm {j : M // j ∈ exactLeft seed.coordinate seed.partition}) := Fintype.card_pos_iff.mpr ⟨Equiv.refl _⟩ have right : 0 < Fintype.card (Equiv.Perm {j : M // j ∈ exactRight seed.coordinate seed.partition}) := Fintype.card_pos_iff.mpr ⟨Equiv.refl _⟩ unfold exactSeedWeight positivity theorem jointConditional_product_context_seed {K Ω C V : Type*} [Fintype K] [Fintype Ω] [Fintype C] [Fintype V] (context : K → Ω → C) (next : K → Ω → V) (seedWeight : K → ℝ) (outcomeWeight : Ω → ℝ) (seed : K) (target : C) (nonzero : seedWeight seed ≠ 0) : jointConditional (groupedMass (fun q : K × Ω => ((q.1, context q.1 q.2), next q.1 q.2)) (fun q : K × Ω => seedWeight q.1 * outcomeWeight q.2)) (seed, target) = jointConditional (groupedMass (fun outcome : Ω => (context seed outcome, next seed outcome)) outcomeWeight) target := by classical have atom (value : V) : groupedMass (fun q : K × Ω => ((q.1, context q.1 q.2), next q.1 q.2)) (fun q : K × Ω => seedWeight q.1 * outcomeWeight q.2) ((seed, target), value) = seedWeight seed * groupedMass (fun outcome : Ω => (context seed outcome, next seed outcome)) outcomeWeight (target, value) := by calc groupedMass (fun q : K × Ω => ((q.1, context q.1 q.2), next q.1 q.2)) (fun q : K × Ω => seedWeight q.1 * outcomeWeight q.2) ((seed, target), value) = groupedMass (fun q : K × Ω => (q.1, (context q.1 q.2, next q.1 q.2))) (fun q : K × Ω => seedWeight q.1 * outcomeWeight q.2) (seed, (target, value)) := by unfold groupedMass apply Finset.sum_congr · ext q simp [and_assoc] · intro q _ rfl _ = seedWeight seed * groupedMass (fun outcome : Ω => (context seed outcome, next seed outcome)) outcomeWeight (target, value) := by exact groupedMass_product_injective_seed (fun k : K => k) (fun _ _ equal => equal) (fun k outcome => (context k outcome, next k outcome)) seedWeight outcomeWeight seed (target, value) funext value unfold jointConditional jointFirstMarginal simp_rw [atom] rw [← Finset.mul_sum] exact mul_div_mul_left _ _ nonzero variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactAliceSourceContextNextPosterior_eq_groupedMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (fun atom : ((SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D) × Y => exactAliceInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) = groupedMass (fun point : ExactJointOutcome X Y A B D => (((point.1.coordinate, point.2.1 point.1.coordinate.val), exactHistoryCode D point), point.2.2.1 point.1.coordinate.val)) (exactPostselectedJointLaw G n S D) := by classical funext atom rcases atom with ⟨⟨⟨coordinate, question⟩, history⟩, next⟩ rw [exactAliceInformationPosterior_eq_jointPushforward] unfold groupedMass apply Finset.sum_congr · ext point simp [exactAliceSourceAtomCode, and_assoc] · intro point _ rfl theorem exactBobSourceContextNextPosterior_eq_groupedMass (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) : (fun atom : ((SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D) × X => exactBobInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) = groupedMass (fun point : ExactJointOutcome X Y A B D => (((point.1.coordinate, point.2.2.1 point.1.coordinate.val), exactHistoryCode D point), point.2.1 point.1.coordinate.val)) (exactPostselectedJointLaw G n S D) := by classical funext atom rcases atom with ⟨⟨⟨coordinate, question⟩, history⟩, next⟩ rw [exactBobInformationPosterior_eq_jointPushforward] unfold groupedMass apply Finset.sum_congr · ext point simp [exactBobSourceAtomCode, and_assoc] · intro point _ rfl theorem exactAliceSourcePosteriorConditional_eq_fixedSeedFiber (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (fun atom : ((SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D) × Y => exactAliceInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((seed.coordinate, reference.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => ((outcome.1 seed.coordinate.val, exactHistoryCode D (seed, outcome)), outcome.2.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (reference.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) := by classical rw [exactAliceSourceContextNextPosterior_eq_groupedMass] have fiber : jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => (((point.1.coordinate, point.2.1 point.1.coordinate.val), exactHistoryCode D point), point.2.2.1 point.1.coordinate.val)) (exactPostselectedJointLaw G n S D)) ((seed.coordinate, reference.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) = jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => ((point.1, (point.2.1 point.1.coordinate.val, exactHistoryCode D point)), point.2.2.1 point.1.coordinate.val)) (exactPostselectedJointLaw G n S D)) (seed, (reference.1 seed.coordinate.val, exactHistoryCode D (seed, reference))) := by apply jointConditional_groupedMass_eq_of_fiber (exactPostselectedJointLaw G n S D) (fun point : ExactJointOutcome X Y A B D => ((point.1.coordinate, point.2.1 point.1.coordinate.val), exactHistoryCode D point)) (fun point : ExactJointOutcome X Y A B D => (point.1, (point.2.1 point.1.coordinate.val, exactHistoryCode D point))) (fun point : ExactJointOutcome X Y A B D => point.2.2.1 point.1.coordinate.val) ((seed.coordinate, reference.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) (seed, (reference.1 seed.coordinate.val, exactHistoryCode D (seed, reference))) intro point constructor · intro same have history : exactHistoryCode D point = exactHistoryCode D (seed, reference) := congrArg Prod.snd same have seed_eq : point.1 = seed := by simpa only [exactHistoryCode] using congrArg (fun r : ExactHistoryFlag X Y A B D => r.seed) history have question : point.2.1 point.1.coordinate.val = reference.1 seed.coordinate.val := congrArg (fun t : (SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D => t.1.2) same exact Prod.ext seed_eq (Prod.ext question history) · intro same have seed_eq : point.1 = seed := congrArg Prod.fst same have question : point.2.1 point.1.coordinate.val = reference.1 seed.coordinate.val := congrArg (fun t : ExactRemainingSeed D × (X × ExactHistoryFlag X Y A B D) => t.2.1) same have history : exactHistoryCode D point = exactHistoryCode D (seed, reference) := congrArg (fun t : ExactRemainingSeed D × (X × ExactHistoryFlag X Y A B D) => t.2.2) same apply Prod.ext · exact Prod.ext (congrArg (fun s : ExactRemainingSeed D => s.coordinate) seed_eq) question · exact history calc _ = jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => ((point.1, (point.2.1 point.1.coordinate.val, exactHistoryCode D point)), point.2.2.1 point.1.coordinate.val)) (exactPostselectedJointLaw G n S D)) (seed, (reference.1 seed.coordinate.val, exactHistoryCode D (seed, reference))) := fiber _ = _ := by unfold exactPostselectedJointLaw convert (jointConditional_product_context_seed (fun (source : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) => (outcome.1 source.coordinate.val, exactHistoryCode D (source, outcome))) (fun (source : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) => outcome.2.1 source.coordinate.val) exactSeedWeight (repeatedConditionedOutcomeLaw G n S D) seed (reference.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) (ne_of_gt (exactSeedWeight_pos_of_seed seed))) using 1 · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ _ _ · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ _ _ theorem exactBobSourcePosteriorConditional_eq_fixedSeedFiber (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (fun atom : ((SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D) × X => exactBobInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((seed.coordinate, reference.2.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => ((outcome.2.1 seed.coordinate.val, exactHistoryCode D (seed, outcome)), outcome.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (reference.2.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) := by classical rw [exactBobSourceContextNextPosterior_eq_groupedMass] have fiber : jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => (((point.1.coordinate, point.2.2.1 point.1.coordinate.val), exactHistoryCode D point), point.2.1 point.1.coordinate.val)) (exactPostselectedJointLaw G n S D)) ((seed.coordinate, reference.2.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) = jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => ((point.1, (point.2.2.1 point.1.coordinate.val, exactHistoryCode D point)), point.2.1 point.1.coordinate.val)) (exactPostselectedJointLaw G n S D)) (seed, (reference.2.1 seed.coordinate.val, exactHistoryCode D (seed, reference))) := by apply jointConditional_groupedMass_eq_of_fiber (exactPostselectedJointLaw G n S D) (fun point : ExactJointOutcome X Y A B D => ((point.1.coordinate, point.2.2.1 point.1.coordinate.val), exactHistoryCode D point)) (fun point : ExactJointOutcome X Y A B D => (point.1, (point.2.2.1 point.1.coordinate.val, exactHistoryCode D point))) (fun point : ExactJointOutcome X Y A B D => point.2.1 point.1.coordinate.val) ((seed.coordinate, reference.2.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) (seed, (reference.2.1 seed.coordinate.val, exactHistoryCode D (seed, reference))) intro point constructor · intro same have history : exactHistoryCode D point = exactHistoryCode D (seed, reference) := congrArg Prod.snd same have seed_eq : point.1 = seed := by simpa only [exactHistoryCode] using congrArg (fun r : ExactHistoryFlag X Y A B D => r.seed) history have question : point.2.2.1 point.1.coordinate.val = reference.2.1 seed.coordinate.val := congrArg (fun t : (SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D => t.1.2) same exact Prod.ext seed_eq (Prod.ext question history) · intro same have seed_eq : point.1 = seed := congrArg Prod.fst same have question : point.2.2.1 point.1.coordinate.val = reference.2.1 seed.coordinate.val := congrArg (fun t : ExactRemainingSeed D × (Y × ExactHistoryFlag X Y A B D) => t.2.1) same have history : exactHistoryCode D point = exactHistoryCode D (seed, reference) := congrArg (fun t : ExactRemainingSeed D × (Y × ExactHistoryFlag X Y A B D) => t.2.2) same apply Prod.ext · exact Prod.ext (congrArg (fun s : ExactRemainingSeed D => s.coordinate) seed_eq) question · exact history calc _ = jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => ((point.1, (point.2.2.1 point.1.coordinate.val, exactHistoryCode D point)), point.2.1 point.1.coordinate.val)) (exactPostselectedJointLaw G n S D)) (seed, (reference.2.1 seed.coordinate.val, exactHistoryCode D (seed, reference))) := fiber _ = _ := by unfold exactPostselectedJointLaw convert (jointConditional_product_context_seed (fun (source : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) => (outcome.2.1 source.coordinate.val, exactHistoryCode D (source, outcome))) (fun (source : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) => outcome.1 source.coordinate.val) exactSeedWeight (repeatedConditionedOutcomeLaw G n S D) seed (reference.2.1 seed.coordinate.val, exactHistoryCode D (seed, reference)) (ne_of_gt (exactSeedWeight_pos_of_seed seed))) using 1 · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ _ _ · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ _ _ theorem exactReverseAliceMarkedPosteriorConditional_eq_sourcePosterior (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : Y) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseAliceMarkedHistoryContext G n S D default seed outcome, outcome.2.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) = jointConditional (fun atom : ((SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D) × Y => exactAliceInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((seed.coordinate, reference.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) := by exact (exactReverseAliceMarkedPosteriorConditional_eq_sourceFiber G n S D default seed reference).trans (exactAliceSourcePosteriorConditional_eq_fixedSeedFiber G n S D seed reference).symm theorem exactReverseBobMarkedPosteriorConditional_eq_sourcePosterior (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : X) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseBobMarkedHistoryContext G n S D default seed outcome, outcome.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (exactReverseBobMarkedHistoryContext G n S D default seed reference) = jointConditional (fun atom : ((SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D) × X => exactBobInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((seed.coordinate, reference.2.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) := by exact (exactReverseBobMarkedPosteriorConditional_eq_sourceFiber G n S D default seed reference).trans (exactBobSourcePosteriorConditional_eq_fixedSeedFiber G n S D seed reference).symm end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 4200000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem exactReverseAliceSideWeightedPrefix_sum {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (score : (side : Finset M) → ExactForwardSeed M → Fin side.card → ℝ) : (∑ side : Finset M, reversePartitionWeight side * ((∑ marker : Fin side.card, ∑ seed : ExactForwardSeed M, (exactReverseAliceConditionalSeedLaw nonempty side).weight seed * score side seed marker) / (side.card : ℝ))) = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, score (exactReverseLeftSide seed) seed marker) / ((exactReverseLeftSide seed).card : ℝ)) := by classical calc (∑ side : Finset M, reversePartitionWeight side * ((∑ marker : Fin side.card, ∑ seed : ExactForwardSeed M, (exactReverseAliceConditionalSeedLaw nonempty side).weight seed * score side seed marker) / (side.card : ℝ))) = ∑ side : Finset M, ∑ seed : ExactForwardSeed M, (reversePartitionWeight side * (exactReverseAliceConditionalSeedLaw nonempty side).weight seed) * ((∑ marker : Fin side.card, score side seed marker) / (side.card : ℝ)) := by apply Finset.sum_congr rfl intro side _ rw [Finset.sum_comm] simp_rw [← Finset.mul_sum] rw [Finset.sum_div, Finset.mul_sum] apply Finset.sum_congr rfl intro seed _ ring _ = ∑ side : Finset M, ∑ seed : ExactForwardSeed M, (if exactReverseLeftSide seed = side then exactSeedWeight seed else 0) * ((∑ marker : Fin side.card, score side seed marker) / (side.card : ℝ)) := by simp_rw [exactReverseAliceConditionalSeedLaw_weight_cancel nonempty] _ = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, score (exactReverseLeftSide seed) seed marker) / ((exactReverseLeftSide seed).card : ℝ)) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro seed _ simp theorem exactReverseBobSideWeightedPrefix_sum {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (score : (side : Finset M) → ExactForwardSeed M → Fin side.card → ℝ) : (∑ side : Finset M, reversePartitionWeight side * ((∑ marker : Fin side.card, ∑ seed : ExactForwardSeed M, (exactReverseBobConditionalSeedLaw nonempty side).weight seed * score side seed marker) / (side.card : ℝ))) = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, score (exactReverseRightSide seed) seed marker) / ((exactReverseRightSide seed).card : ℝ)) := by classical calc (∑ side : Finset M, reversePartitionWeight side * ((∑ marker : Fin side.card, ∑ seed : ExactForwardSeed M, (exactReverseBobConditionalSeedLaw nonempty side).weight seed * score side seed marker) / (side.card : ℝ))) = ∑ side : Finset M, ∑ seed : ExactForwardSeed M, (reversePartitionWeight side * (exactReverseBobConditionalSeedLaw nonempty side).weight seed) * ((∑ marker : Fin side.card, score side seed marker) / (side.card : ℝ)) := by apply Finset.sum_congr rfl intro side _ rw [Finset.sum_comm] simp_rw [← Finset.mul_sum] rw [Finset.sum_div, Finset.mul_sum] apply Finset.sum_congr rfl intro seed _ ring _ = ∑ side : Finset M, ∑ seed : ExactForwardSeed M, (if exactReverseRightSide seed = side then exactSeedWeight seed else 0) * ((∑ marker : Fin side.card, score side seed marker) / (side.card : ℝ)) := by simp_rw [exactReverseBobConditionalSeedLaw_weight_cancel nonempty] _ = ∑ seed : ExactForwardSeed M, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, score (exactReverseRightSide seed) seed marker) / ((exactReverseRightSide seed).card : ℝ)) := by rw [Finset.sum_comm] apply Finset.sum_congr rfl intro seed _ simp end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem groupedMass_product_stable_context_fiber {K Ω I C V : Type*} [Fintype K] [Fintype Ω] [Fintype I] [Fintype C] [Fintype V] (index : K → I) (context : I → Ω → C) (next : I → Ω → V) (extract : C → I) (extract_context : ∀ (i : I) (outcome : Ω), extract (context i outcome) = i) (seedWeight : K → ℝ) (outcomeWeight : Ω → ℝ) (target : C) (value : V) : groupedMass (fun point : K × Ω => (context (index point.1) point.2, next (index point.1) point.2)) (fun point : K × Ω => seedWeight point.1 * outcomeWeight point.2) (target, value) = groupedMass index seedWeight (extract target) * groupedMass (fun outcome : Ω => (context (extract target) outcome, next (extract target) outcome)) outcomeWeight (target, value) := by classical unfold groupedMass simp only [Finset.sum_filter, Fintype.sum_prod_type] rw [Finset.sum_mul] apply Finset.sum_congr rfl intro seed _ by_cases same : index seed = extract target · simp [same, Prod.mk.injEq, Finset.mul_sum, mul_ite] · have different (outcome : Ω) : context (index seed) outcome ≠ target := by intro equal apply same calc index seed = extract (context (index seed) outcome) := (extract_context (index seed) outcome).symm _ = extract target := congrArg extract equal simp [same, different, Prod.mk.injEq] theorem jointConditional_product_stable_context_seed {K Ω I C V : Type*} [Fintype K] [Fintype Ω] [Fintype I] [Fintype C] [Fintype V] (index : K → I) (context : I → Ω → C) (next : I → Ω → V) (extract : C → I) (extract_context : ∀ (i : I) (outcome : Ω), extract (context i outcome) = i) (seedWeight : K → ℝ) (outcomeWeight : Ω → ℝ) (seed : K) (target : C) (target_index : extract target = index seed) (nonzero : groupedMass index seedWeight (index seed) ≠ 0) : jointConditional (groupedMass (fun point : K × Ω => (context (index point.1) point.2, next (index point.1) point.2)) (fun point : K × Ω => seedWeight point.1 * outcomeWeight point.2)) target = jointConditional (groupedMass (fun outcome : Ω => (context (index seed) outcome, next (index seed) outcome)) outcomeWeight) target := by classical have atom (value : V) : groupedMass (fun point : K × Ω => (context (index point.1) point.2, next (index point.1) point.2)) (fun point : K × Ω => seedWeight point.1 * outcomeWeight point.2) (target, value) = groupedMass index seedWeight (index seed) * groupedMass (fun outcome : Ω => (context (index seed) outcome, next (index seed) outcome)) outcomeWeight (target, value) := by simpa only [target_index] using groupedMass_product_stable_context_fiber index context next extract extract_context seedWeight outcomeWeight target value funext value unfold jointConditional jointFirstMarginal simp_rw [atom] rw [← Finset.mul_sum] exact mul_div_mul_left _ _ nonzero theorem groupedMass_pos_of_supported_atom {K I : Type*} [Fintype K] [Fintype I] [DecidableEq I] (code : K → I) (weight : K → ℝ) (nonnegative : ∀ seed : K, 0 ≤ weight seed) (seed : K) (positive : 0 < weight seed) : 0 < groupedMass code weight (code seed) := by unfold groupedMass apply lt_of_lt_of_le positive apply Finset.single_le_sum · intro other _ exact nonnegative other · exact Finset.mem_filter.mpr ⟨Finset.mem_univ seed, rfl⟩ variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseAliceContextOutcomeProjection {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (outcome : ExactOutcome X Y A B n) : ExactReverseAliceFixedInformation X Y D side × (Fin side.card → Y) := (⟨context, (fun j => outcome.1 j.val), (fun j => outcome.2.1 j.val), (fun j => outcome.1 j.val.val), (fun j => outcome.2.1 j.val.val), (fun j => outcome.1 j.val.val)⟩, fun marker => outcome.2.1 (context.sideRank.symm marker).val.val) def exactReverseBobContextOutcomeProjection {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (outcome : ExactOutcome X Y A B n) : ExactReverseBobFixedInformation X Y D side × (Fin side.card → X) := (⟨context, (fun j => outcome.1 j.val), (fun j => outcome.2.1 j.val), (fun j => outcome.2.1 j.val.val), (fun j => outcome.1 j.val.val), (fun j => outcome.2.1 j.val.val)⟩, fun marker => outcome.1 (context.sideRank.symm marker).val.val) theorem reweightedSeedPrefixNextJoint_as_actual_pushforward {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (seedLaw : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (default : V) (marker : Fin h) : groupedMass (exactPrefixNextCode default marker) (reweightedSeedPrefixJoint seedLaw G n S D projection) = groupedMass (fun point : K × ExactOutcome X Y A B n => exactPrefixNextCode default marker (((projection point).1, repeatedConditionedAnswerFlag G n S D point.2), (projection point).2)) (reweightedSeedPosterior seedLaw G n S D) := by classical let augmented : K × ExactOutcome X Y A B n → (Ω × ConditionedAnswerFlag A B D) × (Fin h → V) := fun point => (((projection point).1, repeatedConditionedAnswerFlag G n S D point.2), (projection point).2) have actual : reweightedSeedPrefixJoint seedLaw G n S D projection = groupedMass augmented (reweightedSeedPosterior seedLaw G n S D) := by funext target exact reweightedSeedPrefixJoint_as_actual_flagged_pushforward seedLaw G n S D projection target rw [actual] exact groupedMass_comp augmented (exactPrefixNextCode default marker) (reweightedSeedPosterior seedLaw G n S D) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable theorem groupedMass_productCode_weighted_sum {K Ω C : Type*} [Fintype K] [Fintype Ω] [Fintype C] [DecidableEq C] (code : K → Ω → C) (weight : K → ℝ) (mass : Ω → ℝ) (target : C) : groupedMass (fun point : K × Ω => code point.1 point.2) (fun point : K × Ω => weight point.1 * mass point.2) target = ∑ index : K, weight index * groupedMass (code index) mass target := by classical unfold groupedMass simp only [Finset.sum_filter, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro index _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro outcome _ split <;> simp_all theorem groupedMass_flagSeedOutcome_reassoc {F K Ω C : Type*} [Fintype F] [Fintype K] [Fintype Ω] [Fintype C] [DecidableEq C] (code : F → K → Ω → C) (flagWeight : F → ℝ) (seedWeight : K → ℝ) (outcomeWeight : Ω → ℝ) (target : C) : groupedMass (fun point : F × (K × Ω) => code point.1 point.2.1 point.2.2) (fun point : F × (K × Ω) => flagWeight point.1 * (seedWeight point.2.1 * outcomeWeight point.2.2)) target = groupedMass (fun point : (F × K) × Ω => code point.1.1 point.1.2 point.2) (fun point : (F × K) × Ω => (flagWeight point.1.1 * seedWeight point.1.2) * outcomeWeight point.2) target := by classical unfold groupedMass simp only [Finset.sum_filter] symm apply Fintype.sum_equiv (Equiv.prodAssoc F K Ω) intro point change (if code point.1.1 point.1.2 point.2 = target then (flagWeight point.1.1 * seedWeight point.1.2) * outcomeWeight point.2 else 0) = (if code point.1.1 point.1.2 point.2 = target then flagWeight point.1.1 * (seedWeight point.1.2 * outcomeWeight point.2) else 0) split <;> simp [mul_assoc] variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem mixedStableBobQuestionCode_joint_factor {K C : Type*} [Fintype K] [Fintype C] [DecidableEq C] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (weight : K → ℝ) (coordinate : K → Fin n) (code : K → (Fin n → X) → (Fin n → Y) → C) (target : C) (question : X) (next : Y) (stable : ∀ (index : K) (xs : Fin n → X) (tail : {j : Fin n // j ≠ coordinate index} → Y) (y y' : Y), code index xs ((Equiv.funSplitAt (coordinate index) Y).symm (y, tail)) = code index xs ((Equiv.funSplitAt (coordinate index) Y).symm (y', tail))) (determines : ∀ (index : K) (xs : Fin n → X) (ys : Fin n → Y), code index xs ys = target → xs (coordinate index) = question) : groupedMass (fun point : K × ExactOutcome X Y A B n => (code point.1 point.2.1 point.2.2.1, point.2.2.1 (coordinate point.1))) (fun point : K × ExactOutcome X Y A B n => weight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) (target, next) = G.conditionalYGivenX question next * groupedMass (fun point : K × ExactOutcome X Y A B n => code point.1 point.2.1 point.2.2.1) (fun point : K × ExactOutcome X Y A B n => weight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) target := by classical calc groupedMass (fun point : K × ExactOutcome X Y A B n => (code point.1 point.2.1 point.2.2.1, point.2.2.1 (coordinate point.1))) (fun point : K × ExactOutcome X Y A B n => weight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) (target, next) = ∑ index : K, weight index * groupedMass (fun outcome : ExactOutcome X Y A B n => (code index outcome.1 outcome.2.1, outcome.2.1 (coordinate index))) (strategyEventLaw (G.repeat n) S).weight (target, next) := groupedMass_productCode_weighted_sum (fun index (outcome : ExactOutcome X Y A B n) => (code index outcome.1 outcome.2.1, outcome.2.1 (coordinate index))) weight (strategyEventLaw (G.repeat n) S).weight (target, next) _ = ∑ index : K, weight index * (G.conditionalYGivenX question next * groupedMass (fun outcome : ExactOutcome X Y A B n => code index outcome.1 outcome.2.1) (strategyEventLaw (G.repeat n) S).weight target) := by apply Finset.sum_congr rfl intro index _ congr 1 exact exactStrategyStableBobQuestionCode_joint_factor G n S (coordinate index) (code index) target question next (stable index) (determines index) _ = G.conditionalYGivenX question next * (∑ index : K, weight index * groupedMass (fun outcome : ExactOutcome X Y A B n => code index outcome.1 outcome.2.1) (strategyEventLaw (G.repeat n) S).weight target) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro index _ ring _ = G.conditionalYGivenX question next * groupedMass (fun point : K × ExactOutcome X Y A B n => code point.1 point.2.1 point.2.2.1) (fun point : K × ExactOutcome X Y A B n => weight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) target := by congr 1 exact (groupedMass_productCode_weighted_sum (fun index (outcome : ExactOutcome X Y A B n) => code index outcome.1 outcome.2.1) weight (strategyEventLaw (G.repeat n) S).weight target).symm theorem mixedStableAliceQuestionCode_joint_factor {K C : Type*} [Fintype K] [Fintype C] [DecidableEq C] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (weight : K → ℝ) (coordinate : K → Fin n) (code : K → (Fin n → X) → (Fin n → Y) → C) (target : C) (question : Y) (next : X) (stable : ∀ (index : K) (ys : Fin n → Y) (tail : {j : Fin n // j ≠ coordinate index} → X) (x x' : X), code index ((Equiv.funSplitAt (coordinate index) X).symm (x, tail)) ys = code index ((Equiv.funSplitAt (coordinate index) X).symm (x', tail)) ys) (determines : ∀ (index : K) (xs : Fin n → X) (ys : Fin n → Y), code index xs ys = target → ys (coordinate index) = question) : groupedMass (fun point : K × ExactOutcome X Y A B n => (code point.1 point.2.1 point.2.2.1, point.2.1 (coordinate point.1))) (fun point : K × ExactOutcome X Y A B n => weight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) (target, next) = G.conditionalXGivenY question next * groupedMass (fun point : K × ExactOutcome X Y A B n => code point.1 point.2.1 point.2.2.1) (fun point : K × ExactOutcome X Y A B n => weight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) target := by classical calc groupedMass (fun point : K × ExactOutcome X Y A B n => (code point.1 point.2.1 point.2.2.1, point.2.1 (coordinate point.1))) (fun point : K × ExactOutcome X Y A B n => weight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) (target, next) = ∑ index : K, weight index * groupedMass (fun outcome : ExactOutcome X Y A B n => (code index outcome.1 outcome.2.1, outcome.1 (coordinate index))) (strategyEventLaw (G.repeat n) S).weight (target, next) := groupedMass_productCode_weighted_sum (fun index (outcome : ExactOutcome X Y A B n) => (code index outcome.1 outcome.2.1, outcome.1 (coordinate index))) weight (strategyEventLaw (G.repeat n) S).weight (target, next) _ = ∑ index : K, weight index * (G.conditionalXGivenY question next * groupedMass (fun outcome : ExactOutcome X Y A B n => code index outcome.1 outcome.2.1) (strategyEventLaw (G.repeat n) S).weight target) := by apply Finset.sum_congr rfl intro index _ congr 1 exact exactStrategyStableAliceQuestionCode_joint_factor G n S (coordinate index) (code index) target question next (stable index) (determines index) _ = G.conditionalXGivenY question next * (∑ index : K, weight index * groupedMass (fun outcome : ExactOutcome X Y A B n => code index outcome.1 outcome.2.1) (strategyEventLaw (G.repeat n) S).weight target) := by rw [Finset.mul_sum] apply Finset.sum_congr rfl intro index _ ring _ = G.conditionalXGivenY question next * groupedMass (fun point : K × ExactOutcome X Y A B n => code point.1 point.2.1 point.2.2.1) (fun point : K × ExactOutcome X Y A B n => weight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) target := by congr 1 exact (groupedMass_productCode_weighted_sum (fun index (outcome : ExactOutcome X Y A B n) => code index outcome.1 outcome.2.1) weight (strategyEventLaw (G.repeat n) S).weight target).symm def exactReverseAliceMaskedQuestionRegister {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) (flag : ConditionedAnswerFlag A B D) (seed : ExactRemainingSeed D) (xs : Fin n → X) (ys : Fin n → Y) : ExactReverseAliceNextContext X Y A B D side := let context := exactReverseAliceContextAt side seed let fixed : ExactReverseAliceFixedInformation X Y D side := ⟨context, (fun j => xs j.val), (fun j => ys j.val), (fun j => xs j.val.val), (fun j => ys j.val.val), (fun j => xs j.val.val)⟩ finitePrefixMask default marker.castSucc ((fixed, flag), fun position => ys (context.sideRank.symm position).val.val) def exactReverseBobMaskedQuestionRegister {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) (flag : ConditionedAnswerFlag A B D) (seed : ExactRemainingSeed D) (xs : Fin n → X) (ys : Fin n → Y) : ExactReverseBobNextContext X Y A B D side := let context := exactReverseBobContextAt side seed let fixed : ExactReverseBobFixedInformation X Y D side := ⟨context, (fun j => xs j.val), (fun j => ys j.val), (fun j => ys j.val.val), (fun j => xs j.val.val), (fun j => ys j.val.val)⟩ finitePrefixMask default marker.castSucc ((fixed, flag), fun position => xs (context.sideRank.symm position).val.val) theorem exactReverseAliceMaskedQuestionRegister_stable {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) (flag : ConditionedAnswerFlag A B D) (seed : ExactRemainingSeed D) (xs : Fin n → X) (tail : {j : Fin n // j ≠ ((exactReverseAliceContextAt side seed).sideRank.symm marker).val.val} → Y) (y y' : Y) : exactReverseAliceMaskedQuestionRegister D side default marker flag seed xs ((Equiv.funSplitAt ((exactReverseAliceContextAt side seed).sideRank.symm marker).val.val Y).symm (y, tail)) = exactReverseAliceMaskedQuestionRegister D side default marker flag seed xs ((Equiv.funSplitAt ((exactReverseAliceContextAt side seed).sideRank.symm marker).val.val Y).symm (y', tail)) := by classical let context := exactReverseAliceContextAt side seed let marked : SourceRemainingCoordinate D := (context.sideRank.symm marker).val let coordinate : Fin n := marked.val have outsideD : coordinate ∉ D := by exact (Finset.mem_sdiff.mp marked.property).2 have outsideOther : marked ∉ context.otherSide := by rw [context.otherSide_eq_complement] simp [marked, (context.sideRank.symm marker).property] change exactReverseAliceMaskedQuestionRegister D side default marker flag seed xs ((Equiv.funSplitAt coordinate Y).symm (y, tail)) = exactReverseAliceMaskedQuestionRegister D side default marker flag seed xs ((Equiv.funSplitAt coordinate Y).symm (y', tail)) unfold exactReverseAliceMaskedQuestionRegister finitePrefixMask apply Prod.ext · apply Prod.ext · apply Sigma.ext · rfl · apply heq_of_eq apply Prod.ext · rfl apply Prod.ext · funext j have different : j.val ≠ coordinate := by intro same exact outsideD (same ▸ j.property) simp [Equiv.funSplitAt, Equiv.piSplitAt, different] apply Prod.ext · rfl apply Prod.ext · funext j have different : j.val.val ≠ coordinate := by intro same apply outsideOther have actual : j.val = marked := by apply Subtype.ext exact same exact actual ▸ j.property simp [Equiv.funSplitAt, Equiv.piSplitAt, different] · rfl · rfl · funext position by_cases before : position.val < marker.val · have different : ((context.sideRank.symm position).val.val) ≠ coordinate := by intro same have sameMarked : context.sideRank.symm position = context.sideRank.symm marker := by apply Subtype.ext apply Subtype.ext exact same have samePosition := context.sideRank.symm.injective sameMarked exact (Nat.ne_of_lt before) (congrArg Fin.val samePosition) simp [before, context, Equiv.funSplitAt, Equiv.piSplitAt, different] · simp [before] theorem exactConditionedReverseAliceNextPrior_flagged_mixture (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) : groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseAliceNextPrior G n S D remaining side) = groupedMass (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => (exactReverseAliceMaskedQuestionRegister D side default marker point.1.1 point.1.2 point.2.1 point.2.2.1, point.2.2.1 (((exactReverseAliceContextAt side point.1.2).sideRank.symm marker).val.val))) (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => (finiteUniformWeight (ConditionedAnswerFlag A B D) * (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side).weight point.1.2) * (strategyEventLaw (G.repeat n) S).weight point.2) := by classical funext target let seedLaw := exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let projection := exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side change groupedMass (exactPrefixNextCode default marker) (reweightedSeedPrefixPrior seedLaw G n S D projection) target = _ calc groupedMass (exactPrefixNextCode default marker) (reweightedSeedPrefixPrior seedLaw G n S D projection) target = groupedMass (fun point : ConditionedAnswerFlag A B D × (ExactRemainingSeed D × ExactOutcome X Y A B n) => exactPrefixNextCode default marker (((projection point.2).1, point.1), (projection point.2).2)) (fun point : ConditionedAnswerFlag A B D × (ExactRemainingSeed D × ExactOutcome X Y A B n) => finiteUniformWeight (ConditionedAnswerFlag A B D) * (reweightedSeedPriorEventLaw seedLaw G n S).weight point.2) target := reweightedSeedPrefixPrior_next_flagged_pushforward seedLaw G n S D projection default marker target _ = _ := by change groupedMass (fun point : ConditionedAnswerFlag A B D × (ExactRemainingSeed D × ExactOutcome X Y A B n) => (exactReverseAliceMaskedQuestionRegister D side default marker point.1 point.2.1 point.2.2.1 point.2.2.2.1, point.2.2.2.1 (((exactReverseAliceContextAt side point.2.1).sideRank.symm marker).val.val))) (fun point : ConditionedAnswerFlag A B D × (ExactRemainingSeed D × ExactOutcome X Y A B n) => finiteUniformWeight (ConditionedAnswerFlag A B D) * (seedLaw.weight point.2.1 * (strategyEventLaw (G.repeat n) S).weight point.2.2)) target = _ exact groupedMass_flagSeedOutcome_reassoc (fun flag seed (outcome : ExactOutcome X Y A B n) => (exactReverseAliceMaskedQuestionRegister D side default marker flag seed outcome.1 outcome.2.1, outcome.2.1 (((exactReverseAliceContextAt side seed).sideRank.symm marker).val.val))) (fun _ : ConditionedAnswerFlag A B D => finiteUniformWeight (ConditionedAnswerFlag A B D)) seedLaw.weight (strategyEventLaw (G.repeat n) S).weight target theorem exactReverseAliceMaskedQuestionRegister_determines {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) (flag : ConditionedAnswerFlag A B D) (seed : ExactRemainingSeed D) (xs : Fin n → X) (ys : Fin n → Y) (target : ExactReverseAliceNextContext X Y A B D side) (same : exactReverseAliceMaskedQuestionRegister D side default marker flag seed xs ys = target) : xs (((exactReverseAliceContextAt side seed).sideRank.symm marker).val.val) = target.1.1.2.2.2.1 (target.1.1.1.sideRank.symm marker) := by have actual := congrArg (fun context : ExactReverseAliceNextContext X Y A B D side => context.1.1.2.2.2.1 (context.1.1.1.sideRank.symm marker)) same exact actual theorem exactConditionedReverseAliceNextPrior_marked_joint_factor (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) (target : ExactReverseAliceNextContext X Y A B D side) (next : Y) : groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseAliceNextPrior G n S D remaining side) (target, next) = G.conditionalYGivenX (target.1.1.2.2.2.1 (target.1.1.1.sideRank.symm marker)) next * jointFirstMarginal (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseAliceNextPrior G n S D remaining side)) target := by classical let seedLaw := exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let mixedWeight : ConditionedAnswerFlag A B D × ExactRemainingSeed D → ℝ := fun index => finiteUniformWeight (ConditionedAnswerFlag A B D) * seedLaw.weight index.2 let coordinate : ConditionedAnswerFlag A B D × ExactRemainingSeed D → Fin n := fun index => ((exactReverseAliceContextAt side index.2).sideRank.symm marker).val.val let code : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) → (Fin n → X) → (Fin n → Y) → ExactReverseAliceNextContext X Y A B D side := fun index xs ys => exactReverseAliceMaskedQuestionRegister D side default marker index.1 index.2 xs ys let question : X := target.1.1.2.2.2.1 (target.1.1.1.sideRank.symm marker) have stable : ∀ (index : ConditionedAnswerFlag A B D × ExactRemainingSeed D) (xs : Fin n → X) (tail : {j : Fin n // j ≠ coordinate index} → Y) (y y' : Y), code index xs ((Equiv.funSplitAt (coordinate index) Y).symm (y, tail)) = code index xs ((Equiv.funSplitAt (coordinate index) Y).symm (y', tail)) := by intro index xs tail y y' exact exactReverseAliceMaskedQuestionRegister_stable D side default marker index.1 index.2 xs tail y y' have determines : ∀ (index : ConditionedAnswerFlag A B D × ExactRemainingSeed D) (xs : Fin n → X) (ys : Fin n → Y), code index xs ys = target → xs (coordinate index) = question := by intro index xs ys same exact exactReverseAliceMaskedQuestionRegister_determines D side default marker index.1 index.2 xs ys target same have mixed := mixedStableBobQuestionCode_joint_factor G n S mixedWeight coordinate code target question next stable determines rw [exactConditionedReverseAliceNextPrior_flagged_mixture G n S D remaining side default marker] change groupedMass (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => (code point.1 point.2.1 point.2.2.1, point.2.2.1 (coordinate point.1))) (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => mixedWeight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) (target, next) = G.conditionalYGivenX question next * jointFirstMarginal (groupedMass (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => (code point.1 point.2.1 point.2.2.1, point.2.2.1 (coordinate point.1))) (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => mixedWeight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2)) target rw [jointFirstMarginal_groupedContextNext] convert mixed using 1 exact congrFun (exactGroupedMass_decidableEq_irrel _ _ _ _) (target, next) theorem exactConditionedReverseAliceNextPrior_marked_conditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) (target : ExactReverseAliceNextContext X Y A B D side) (supported : jointFirstMarginal (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseAliceNextPrior G n S D remaining side)) target ≠ 0) : jointConditional (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseAliceNextPrior G n S D remaining side)) target = G.conditionalYGivenX (target.1.1.2.2.2.1 (target.1.1.1.sideRank.symm marker)) := by funext next unfold jointConditional rw [exactConditionedReverseAliceNextPrior_marked_joint_factor G n S D remaining side default marker target next] exact mul_div_cancel_right₀ _ supported theorem exactReverseAliceMarkedPriorConditional_eq_game (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : Y) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) (supported : jointFirstMarginal (groupedMass (exactPrefixNextCode default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩)) (exactConditionedReverseAliceNextPrior G n S D remaining (exactReverseLeftSide seed))) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) ≠ 0) : jointConditional (groupedMass (exactPrefixNextCode default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩)) (exactConditionedReverseAliceNextPrior G n S D remaining (exactReverseLeftSide seed))) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) = G.conditionalYGivenX (reference.1 seed.coordinate.val) := by have actual := exactConditionedReverseAliceNextPrior_marked_conditional G n S D remaining (exactReverseLeftSide seed) default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) supported simpa [exactReverseAliceMarkedHistoryContext, finitePrefixMask, exactReverseAliceSourceProjection] using actual end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 6000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseAliceMaskedOutcomeContext (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (outcome : ExactOutcome X Y A B n) : ExactReverseAliceNextContext X Y A B D side := let projection := exactReverseAliceContextOutcomeProjection (X := X) (Y := Y) (A := A) (B := B) D side context outcome finitePrefixMask default marker.castSucc ((projection.1, repeatedConditionedAnswerFlag G n S D outcome), projection.2) theorem exactReverseAliceMaskedOutcomeContext_extract (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (outcome : ExactOutcome X Y A B n) : (exactReverseAliceMaskedOutcomeContext G n S D side default marker context outcome).1.1.1 = context := by rfl theorem exactConditionedReverseAliceNextJoint_marked_mixture (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) : groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseAliceNextJoint G n S D remaining side) = groupedMass (fun point : ExactJointOutcome X Y A B D => (exactReverseAliceMaskedOutcomeContext G n S D side default marker (exactReverseAliceContextAt side point.1) point.2, point.2.2.1 (((exactReverseAliceContextAt side point.1).sideRank.symm marker).val.val))) (fun point : ExactJointOutcome X Y A B D => (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side).weight point.1 * repeatedConditionedOutcomeLaw G n S D point.2) := by classical let law := exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let projection := exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side change groupedMass (exactPrefixNextCode default marker) (reweightedSeedPrefixJoint law G n S D projection) = _ rw [reweightedSeedPrefixNextJoint_as_actual_pushforward] funext target unfold groupedMass apply Finset.sum_congr · ext point simp [exactPrefixNextCode, exactReverseAliceMaskedOutcomeContext, exactReverseAliceContextOutcomeProjection, exactReverseAliceSourceProjection, projection] · intro point _ exact reweightedSeedPosterior_eq_product law G n S D point theorem exactReverseAliceActualConditionalSeedWeight_pos {n : ℕ} (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (seed : ExactRemainingSeed D) : 0 < (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) (exactReverseLeftSide seed)).weight seed := by have side : (exactReverseLeftSide seed).Nonempty := ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ rw [exactReverseAliceConditionalSeedLaw_weight (exactRemainingCoordinate_card_pos D remaining) (exactReverseLeftSide seed) side seed] unfold exactReverseAliceConditionalSeedWeight simp only [↓reduceIte] exact div_pos (exactSeedWeight_pos_of_seed seed) ((reversePartitionWeight_pos_iff (exactRemainingCoordinate_card_pos D remaining) (exactReverseLeftSide seed)).mpr side) theorem exactReverseAliceMaskedOutcomeContext_actual (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : Y) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) : exactReverseAliceMaskedOutcomeContext G n S D (exactReverseLeftSide seed) default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) (exactReverseAliceContextAt (exactReverseLeftSide seed) seed) outcome = exactReverseAliceMarkedHistoryContext G n S D default seed outcome := by simp [exactReverseAliceMaskedOutcomeContext, exactReverseAliceContextOutcomeProjection, exactReverseAliceMarkedHistoryContext, exactReverseAliceSourceProjection] theorem exactReverseAliceSideMarkedPosteriorConditional_eq_fixedSeedFiber (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : Y) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (groupedMass (exactPrefixNextCode default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩)) (exactConditionedReverseAliceNextJoint G n S D remaining (exactReverseLeftSide seed))) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseAliceMarkedHistoryContext G n S D default seed outcome, outcome.2.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) := by classical let side := exactReverseLeftSide seed let marker : Fin side.card := (exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ let law := exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let index : ExactRemainingSeed D → ExactReverseSideContext (SourceRemainingCoordinate D) side := exactReverseAliceContextAt side let context : ExactReverseSideContext (SourceRemainingCoordinate D) side → ExactOutcome X Y A B n → ExactReverseAliceNextContext X Y A B D side := exactReverseAliceMaskedOutcomeContext G n S D side default marker let next : ExactReverseSideContext (SourceRemainingCoordinate D) side → ExactOutcome X Y A B n → Y := fun current outcome => outcome.2.1 (current.sideRank.symm marker).val.val let extract : ExactReverseAliceNextContext X Y A B D side → ExactReverseSideContext (SourceRemainingCoordinate D) side := fun current => current.1.1.1 let target := exactReverseAliceMarkedHistoryContext G n S D default seed reference have extracts : ∀ current outcome, extract (context current outcome) = current := by intro current outcome exact exactReverseAliceMaskedOutcomeContext_extract G n S D side default marker current outcome have target_index : extract target = index seed := by rfl have positive : 0 < groupedMass index law.weight (index seed) := by apply groupedMass_pos_of_supported_atom index law.weight law.weight_nonneg seed exact exactReverseAliceActualConditionalSeedWeight_pos D remaining seed have stable := jointConditional_product_stable_context_seed index context next extract extracts law.weight (repeatedConditionedOutcomeLaw G n S D) seed target target_index (ne_of_gt positive) rw [exactConditionedReverseAliceNextJoint_marked_mixture G n S D remaining side default marker] change jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => (context (index point.1) point.2, next (index point.1) point.2)) (fun point : ExactJointOutcome X Y A B D => law.weight point.1 * repeatedConditionedOutcomeLaw G n S D point.2)) target = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseAliceMarkedHistoryContext G n S D default seed outcome, outcome.2.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) target calc jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => (context (index point.1) point.2, next (index point.1) point.2)) (fun point : ExactJointOutcome X Y A B D => law.weight point.1 * repeatedConditionedOutcomeLaw G n S D point.2)) target = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (context (index seed) outcome, next (index seed) outcome)) (repeatedConditionedOutcomeLaw G n S D)) target := by convert stable using 1 · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ _ _ · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ _ _ _ = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseAliceMarkedHistoryContext G n S D default seed outcome, outcome.2.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) target := by congr 1 apply congrArg (fun code => groupedMass code (repeatedConditionedOutcomeLaw G n S D)) funext outcome apply Prod.ext · exact exactReverseAliceMaskedOutcomeContext_actual G n S D default seed outcome · simp [next, index, side, marker] theorem exactReverseAliceSideMarkedPosteriorConditional_eq_sourcePosterior (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : Y) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (groupedMass (exactPrefixNextCode default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩)) (exactConditionedReverseAliceNextJoint G n S D remaining (exactReverseLeftSide seed))) (exactReverseAliceMarkedHistoryContext G n S D default seed reference) = jointConditional (fun atom : ((SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D) × Y => exactAliceInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((seed.coordinate, reference.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) := by exact (exactReverseAliceSideMarkedPosteriorConditional_eq_fixedSeedFiber G n S D remaining default seed reference).trans (exactReverseAliceMarkedPosteriorConditional_eq_sourcePosterior G n S D default seed reference) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 4000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem reweightedSeedPrefixPriorMarginal_ne_zero_of_positive_atom {K Ω V : Type*} [Fintype K] [Fintype Ω] [Fintype V] {h : ℕ} (law : FiniteEventLaw K) (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (projection : K × ExactOutcome X Y A B n → Ω × (Fin h → V)) (default : V) (marker : Fin h) (point : K × ExactOutcome X Y A B n) (atom_positive : 0 < reweightedSeedPosterior law G n S D point) : jointFirstMarginal (groupedMass (exactPrefixNextCode default marker) (reweightedSeedPrefixPrior law G n S D projection)) (finitePrefixMask default marker.castSucc (((projection point).1, repeatedConditionedAnswerFlag G n S D point.2), (projection point).2)) ≠ 0 := by classical let augmented : K × ExactOutcome X Y A B n → (Ω × ConditionedAnswerFlag A B D) × (Fin h → V) := fun source => (((projection source).1, repeatedConditionedAnswerFlag G n S D source.2), (projection source).2) let target := finitePrefixMask default marker.castSucc (augmented point) let posterior := reweightedSeedPosterior law G n S D let joint := reweightedSeedPrefixJoint law G n S D projection let prior := reweightedSeedPrefixPrior law G n S D projection have joint_pushforward : joint = groupedMass augmented posterior := by funext outcome exact reweightedSeedPrefixJoint_as_actual_flagged_pushforward law G n S D projection outcome have posterior_nonnegative : ∀ source, 0 ≤ posterior source := by intro source unfold posterior reweightedSeedPosterior apply conditionedEventDistribution_nonneg rw [reweightedSeedWinEventMass] exact positive have masked_posterior_positive : 0 < groupedMass (finitePrefixMask default marker.castSucc) joint target := by rw [joint_pushforward, groupedMass_comp] exact groupedMass_pos_of_supported_atom (finitePrefixMask default marker.castSucc ∘ augmented) posterior posterior_nonnegative point atom_positive intro zero have masked_prior_zero : groupedMass (finitePrefixMask default marker.castSucc) prior target = 0 := by have first := congrFun (exactPrefixNext_firstMarginal prior default marker) target calc groupedMass (finitePrefixMask default marker.castSucc) prior target = jointFirstMarginal (groupedMass (exactPrefixNextCode default marker) prior) target := by convert first.symm using 1 · exact congrFun (exactGroupedMass_decidableEq_irrel _ _ (finitePrefixMask default marker.castSucc) prior) target · exact congrArg (fun mass => jointFirstMarginal mass target) (exactGroupedMass_decidableEq_irrel _ _ (exactPrefixNextCode default marker) prior) _ = 0 := zero have masked_posterior_zero : groupedMass (finitePrefixMask default marker.castSucc) joint target = 0 := groupedMass_absolute_continuity (finitePrefixMask default marker.castSucc) joint prior (reweightedSeedPrefixPrior_nonneg law G n S D positive projection) (reweightedSeedPrefix_absolute_continuity law G n S D positive projection) target masked_prior_zero exact (ne_of_gt masked_posterior_positive) masked_posterior_zero end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 8000000 set_option maxRecDepth 3072 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseAliceContextMarkerInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : Y) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) : ℝ := ∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome * finiteRelativeEntropy (jointConditional (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseAliceNextJoint G n S D remaining side)) (exactReverseAliceMaskedOutcomeContext G n S D side default marker context outcome)) (jointConditional (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseAliceNextPrior G n S D remaining side)) (exactReverseAliceMaskedOutcomeContext G n S D side default marker context outcome)) theorem exactReverseAlicePrefixIncrement_eq_contextMarkerInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (side : Finset (SourceRemainingCoordinate D)) (default : Y) (marker : Fin side.card) : exactConditionedReverseAlicePrefixEntropyIncrement G n S D remaining side default marker = ∑ seed : ExactRemainingSeed D, (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side).weight seed * exactReverseAliceContextMarkerInformation G n S D remaining default side (exactReverseAliceContextAt side seed) marker := by classical let law := exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let projection := exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side have actual := reweightedSeedPrefixEntropyIncrement_eq_actual_atom_sum law G n S D positive projection default marker have actual_joint : reweightedSeedPrefixJoint law G n S D projection = exactConditionedReverseAliceNextJoint G n S D remaining side := by rfl have actual_prior : reweightedSeedPrefixPrior law G n S D projection = exactConditionedReverseAliceNextPrior G n S D remaining side := by rfl rw [actual_joint, actual_prior] at actual change reweightedSeedPrefixEntropyIncrement law G n S D projection default marker = _ rw [actual, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro seed _ unfold exactReverseAliceContextMarkerInformation rw [Finset.mul_sum] apply Finset.sum_congr rfl intro outcome _ rw [reweightedSeedPosterior_eq_product] have same_context : finitePrefixMask default marker.castSucc (((projection (seed, outcome)).1, repeatedConditionedAnswerFlag G n S D outcome), (projection (seed, outcome)).2) = exactReverseAliceMaskedOutcomeContext G n S D side default marker (exactReverseAliceContextAt side seed) outcome := by rfl rw [same_context] change (law.weight seed * repeatedConditionedOutcomeLaw G n S D outcome) * _ = law.weight seed * (repeatedConditionedOutcomeLaw G n S D outcome * _) ring theorem exactReverseAlicePrefixInformation_eq_seedMarkerAverage (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (default : Y) : exactConditionedReverseAlicePrefixInformation G n S D remaining default = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, exactReverseAliceContextMarkerInformation G n S D remaining default (exactReverseLeftSide seed) (exactReverseAliceContextAt (exactReverseLeftSide seed) seed) marker) / ((exactReverseLeftSide seed).card : ℝ)) := by classical calc exactConditionedReverseAlicePrefixInformation G n S D remaining default = ∑ side : Finset (SourceRemainingCoordinate D), reversePartitionWeight side * ((∑ marker : Fin side.card, ∑ seed : ExactRemainingSeed D, (exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side).weight seed * exactReverseAliceContextMarkerInformation G n S D remaining default side (exactReverseAliceContextAt side seed) marker) / (side.card : ℝ)) := by unfold exactConditionedReverseAlicePrefixInformation apply Finset.sum_congr rfl intro side _ congr 1 apply congrArg (fun total : ℝ => total / (side.card : ℝ)) apply Finset.sum_congr rfl intro marker _ exact exactReverseAlicePrefixIncrement_eq_contextMarkerInformation G n S D remaining positive side default marker _ = _ := by exact exactReverseAliceSideWeightedPrefix_sum (exactRemainingCoordinate_card_pos D remaining) (fun side seed marker => exactReverseAliceContextMarkerInformation G n S D remaining default side (exactReverseAliceContextAt side seed) marker) theorem exactReverseAlicePrefixInformation_eq_markedSeedAverage (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (default : Y) : exactConditionedReverseAlicePrefixInformation G n S D remaining default = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * exactReverseAliceContextMarkerInformation G n S D remaining default (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) := by classical calc exactConditionedReverseAlicePrefixInformation G n S D remaining default = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, exactReverseAliceContextMarkerInformation G n S D remaining default (exactReverseLeftSide seed) (exactReverseAliceContextAt (exactReverseLeftSide seed) seed) marker) / ((exactReverseLeftSide seed).card : ℝ)) := exactReverseAlicePrefixInformation_eq_seedMarkerAverage G n S D remaining positive default _ = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseLeftSide seed).card, exactReverseAliceContextMarkerInformation G n S D remaining default (exactReverseLeftSide seed) (exactReverseAliceContext seed) marker) / ((exactReverseLeftSide seed).card : ℝ)) := by simp_rw [exactReverseAliceContextAt_actual] _ = _ := exactReverseAliceUniformMarkedSeed_sum (exactRemainingCoordinate_card_pos D remaining) (fun side context marker => exactReverseAliceContextMarkerInformation G n S D remaining default side context marker) theorem repeatedConditionedOutcomeLaw_pos_of_ne_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (outcome : ExactOutcome X Y A B n) (nonzero : repeatedConditionedOutcomeLaw G n S D outcome ≠ 0) : 0 < repeatedConditionedOutcomeLaw G n S D outcome := by have nonnegative : 0 ≤ repeatedConditionedOutcomeLaw G n S D outcome := by exact conditionedEventDistribution_nonneg (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive outcome exact lt_of_le_of_ne nonnegative nonzero.symm theorem exactReverseAliceMarkedPriorMarginal_ne_zero_of_outcome (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (default : Y) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) (outcome_nonzero : repeatedConditionedOutcomeLaw G n S D outcome ≠ 0) : jointFirstMarginal (groupedMass (exactPrefixNextCode default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩)) (exactConditionedReverseAliceNextPrior G n S D remaining (exactReverseLeftSide seed))) (exactReverseAliceMarkedHistoryContext G n S D default seed outcome) ≠ 0 := by classical let side := exactReverseLeftSide seed let marker : Fin side.card := (exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩ let law := exactReverseAliceConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let projection := exactReverseAliceSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side have atom_positive : 0 < reweightedSeedPosterior law G n S D (seed, outcome) := by rw [reweightedSeedPosterior_eq_product] exact mul_pos (exactReverseAliceActualConditionalSeedWeight_pos D remaining seed) (repeatedConditionedOutcomeLaw_pos_of_ne_zero G n S D positive outcome outcome_nonzero) have supported := reweightedSeedPrefixPriorMarginal_ne_zero_of_positive_atom law G n S D positive projection default marker (seed, outcome) atom_positive simpa [law, projection, side, marker, exactConditionedReverseAliceNextPrior, exactReverseAliceMarkedHistoryContext, exactReverseAliceSourceProjection] using supported def exactAliceSourceSeedBornInformation (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (seed : ExactRemainingSeed D) : ℝ := ∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome * finiteRelativeEntropy (jointConditional (fun atom : ((SourceRemainingCoordinate D × X) × ExactHistoryFlag X Y A B D) × Y => exactAliceInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((seed.coordinate, outcome.1 seed.coordinate.val), exactHistoryCode D (seed, outcome))) (G.conditionalYGivenX (outcome.1 seed.coordinate.val)) theorem exactReverseAliceMarkedContextInformation_eq_source (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (default : Y) (seed : ExactRemainingSeed D) : exactReverseAliceContextMarkerInformation G n S D remaining default (exactReverseLeftSide seed) (exactReverseAliceContext seed) ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) = exactAliceSourceSeedBornInformation G n S D seed := by classical unfold exactReverseAliceContextMarkerInformation exactAliceSourceSeedBornInformation apply Finset.sum_congr rfl intro outcome _ by_cases zero : repeatedConditionedOutcomeLaw G n S D outcome = 0 · simp [zero] · have actual_context : exactReverseAliceMaskedOutcomeContext G n S D (exactReverseLeftSide seed) default ((exactReverseAliceContext seed).sideRank ⟨seed.coordinate, exactReverseLeftSide_coordinate_mem seed⟩) (exactReverseAliceContext seed) outcome = exactReverseAliceMarkedHistoryContext G n S D default seed outcome := by simpa only [exactReverseAliceContextAt_actual] using exactReverseAliceMaskedOutcomeContext_actual G n S D default seed outcome rw [actual_context] congr 1 exact congrArg₂ finiteRelativeEntropy (exactReverseAliceSideMarkedPosteriorConditional_eq_sourcePosterior G n S D remaining default seed outcome) (exactReverseAliceMarkedPriorConditional_eq_game G n S D remaining default seed outcome (exactReverseAliceMarkedPriorMarginal_ne_zero_of_outcome G n S D remaining positive default seed outcome zero)) theorem exactAliceSourceConditionalInformation_eq_seedBornAverage (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : exactAliceSourceConditionalInformation G n S D base = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * exactAliceSourceSeedBornInformation G n S D seed := by classical rw [exactAliceSourceConditionalInformation_eq_joint_atom_sum G n S D remaining positive base, Fintype.sum_prod_type] apply Finset.sum_congr rfl intro seed _ unfold exactAliceSourceSeedBornInformation rw [Finset.mul_sum] apply Finset.sum_congr rfl intro outcome _ unfold exactPostselectedJointLaw ring theorem exactReverseAliceConditionalHistoryIdentification_proved (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (default : Y) : ExactReverseAliceConditionalHistoryIdentification G n S D remaining base default := by unfold ExactReverseAliceConditionalHistoryIdentification rw [exactAliceSourceConditionalInformation_eq_seedBornAverage G n S D remaining positive base, exactReverseAlicePrefixInformation_eq_markedSeedAverage G n S D remaining positive default] apply Finset.sum_congr rfl intro seed _ congr 1 exact (exactReverseAliceMarkedContextInformation_eq_source G n S D remaining positive default seed).symm end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 5000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactReverseBobMaskedQuestionRegister_stable {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) (flag : ConditionedAnswerFlag A B D) (seed : ExactRemainingSeed D) (ys : Fin n → Y) (tail : {j : Fin n // j ≠ ((exactReverseBobContextAt side seed).sideRank.symm marker).val.val} → X) (x x' : X) : exactReverseBobMaskedQuestionRegister D side default marker flag seed ((Equiv.funSplitAt ((exactReverseBobContextAt side seed).sideRank.symm marker).val.val X).symm (x, tail)) ys = exactReverseBobMaskedQuestionRegister D side default marker flag seed ((Equiv.funSplitAt ((exactReverseBobContextAt side seed).sideRank.symm marker).val.val X).symm (x', tail)) ys := by classical let context := exactReverseBobContextAt side seed let marked : SourceRemainingCoordinate D := (context.sideRank.symm marker).val let coordinate : Fin n := marked.val have outsideD : coordinate ∉ D := by exact (Finset.mem_sdiff.mp marked.property).2 have outsideOther : marked ∉ context.otherSide := by rw [context.otherSide_eq_complement] simp [marked, (context.sideRank.symm marker).property] change exactReverseBobMaskedQuestionRegister D side default marker flag seed ((Equiv.funSplitAt coordinate X).symm (x, tail)) ys = exactReverseBobMaskedQuestionRegister D side default marker flag seed ((Equiv.funSplitAt coordinate X).symm (x', tail)) ys unfold exactReverseBobMaskedQuestionRegister finitePrefixMask apply Prod.ext · apply Prod.ext · apply Sigma.ext · rfl · apply heq_of_eq apply Prod.ext · funext j have different : j.val ≠ coordinate := by intro same exact outsideD (same ▸ j.property) simp [Equiv.funSplitAt, Equiv.piSplitAt, different] apply Prod.ext · rfl apply Prod.ext · rfl apply Prod.ext · funext j have different : j.val.val ≠ coordinate := by intro same apply outsideOther have actual : j.val = marked := by apply Subtype.ext exact same exact actual ▸ j.property simp [Equiv.funSplitAt, Equiv.piSplitAt, different] · rfl · rfl · funext position by_cases before : position.val < marker.val · have different : ((context.sideRank.symm position).val.val) ≠ coordinate := by intro same have sameMarked : context.sideRank.symm position = context.sideRank.symm marker := by apply Subtype.ext apply Subtype.ext exact same have samePosition := context.sideRank.symm.injective sameMarked exact (Nat.ne_of_lt before) (congrArg Fin.val samePosition) simp [before, context, Equiv.funSplitAt, Equiv.piSplitAt, different] · simp [before] theorem exactConditionedReverseBobNextPrior_flagged_mixture (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) : groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextPrior G n S D remaining side) = groupedMass (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => (exactReverseBobMaskedQuestionRegister D side default marker point.1.1 point.1.2 point.2.1 point.2.2.1, point.2.1 (((exactReverseBobContextAt side point.1.2).sideRank.symm marker).val.val))) (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => (finiteUniformWeight (ConditionedAnswerFlag A B D) * (exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side).weight point.1.2) * (strategyEventLaw (G.repeat n) S).weight point.2) := by classical funext target let seedLaw := exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let projection := exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side change groupedMass (exactPrefixNextCode default marker) (reweightedSeedPrefixPrior seedLaw G n S D projection) target = _ calc groupedMass (exactPrefixNextCode default marker) (reweightedSeedPrefixPrior seedLaw G n S D projection) target = groupedMass (fun point : ConditionedAnswerFlag A B D × (ExactRemainingSeed D × ExactOutcome X Y A B n) => exactPrefixNextCode default marker (((projection point.2).1, point.1), (projection point.2).2)) (fun point : ConditionedAnswerFlag A B D × (ExactRemainingSeed D × ExactOutcome X Y A B n) => finiteUniformWeight (ConditionedAnswerFlag A B D) * (reweightedSeedPriorEventLaw seedLaw G n S).weight point.2) target := reweightedSeedPrefixPrior_next_flagged_pushforward seedLaw G n S D projection default marker target _ = _ := by change groupedMass (fun point : ConditionedAnswerFlag A B D × (ExactRemainingSeed D × ExactOutcome X Y A B n) => (exactReverseBobMaskedQuestionRegister D side default marker point.1 point.2.1 point.2.2.1 point.2.2.2.1, point.2.2.1 (((exactReverseBobContextAt side point.2.1).sideRank.symm marker).val.val))) (fun point : ConditionedAnswerFlag A B D × (ExactRemainingSeed D × ExactOutcome X Y A B n) => finiteUniformWeight (ConditionedAnswerFlag A B D) * (seedLaw.weight point.2.1 * (strategyEventLaw (G.repeat n) S).weight point.2.2)) target = _ exact groupedMass_flagSeedOutcome_reassoc (fun flag seed (outcome : ExactOutcome X Y A B n) => (exactReverseBobMaskedQuestionRegister D side default marker flag seed outcome.1 outcome.2.1, outcome.1 (((exactReverseBobContextAt side seed).sideRank.symm marker).val.val))) (fun _ : ConditionedAnswerFlag A B D => finiteUniformWeight (ConditionedAnswerFlag A B D)) seedLaw.weight (strategyEventLaw (G.repeat n) S).weight target theorem exactReverseBobMaskedQuestionRegister_determines {n : ℕ} (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) (flag : ConditionedAnswerFlag A B D) (seed : ExactRemainingSeed D) (xs : Fin n → X) (ys : Fin n → Y) (target : ExactReverseBobNextContext X Y A B D side) (same : exactReverseBobMaskedQuestionRegister D side default marker flag seed xs ys = target) : ys (((exactReverseBobContextAt side seed).sideRank.symm marker).val.val) = target.1.1.2.2.2.1 (target.1.1.1.sideRank.symm marker) := by have actual := congrArg (fun context : ExactReverseBobNextContext X Y A B D side => context.1.1.2.2.2.1 (context.1.1.1.sideRank.symm marker)) same exact actual theorem exactConditionedReverseBobNextPrior_marked_joint_factor (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) (target : ExactReverseBobNextContext X Y A B D side) (next : X) : groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextPrior G n S D remaining side) (target, next) = G.conditionalXGivenY (target.1.1.2.2.2.1 (target.1.1.1.sideRank.symm marker)) next * jointFirstMarginal (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextPrior G n S D remaining side)) target := by classical let seedLaw := exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let mixedWeight : ConditionedAnswerFlag A B D × ExactRemainingSeed D → ℝ := fun index => finiteUniformWeight (ConditionedAnswerFlag A B D) * seedLaw.weight index.2 let coordinate : ConditionedAnswerFlag A B D × ExactRemainingSeed D → Fin n := fun index => ((exactReverseBobContextAt side index.2).sideRank.symm marker).val.val let code : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) → (Fin n → X) → (Fin n → Y) → ExactReverseBobNextContext X Y A B D side := fun index xs ys => exactReverseBobMaskedQuestionRegister D side default marker index.1 index.2 xs ys let question : Y := target.1.1.2.2.2.1 (target.1.1.1.sideRank.symm marker) have stable : ∀ (index : ConditionedAnswerFlag A B D × ExactRemainingSeed D) (ys : Fin n → Y) (tail : {j : Fin n // j ≠ coordinate index} → X) (x x' : X), code index ((Equiv.funSplitAt (coordinate index) X).symm (x, tail)) ys = code index ((Equiv.funSplitAt (coordinate index) X).symm (x', tail)) ys := by intro index ys tail x x' exact exactReverseBobMaskedQuestionRegister_stable D side default marker index.1 index.2 ys tail x x' have determines : ∀ (index : ConditionedAnswerFlag A B D × ExactRemainingSeed D) (xs : Fin n → X) (ys : Fin n → Y), code index xs ys = target → ys (coordinate index) = question := by intro index xs ys same exact exactReverseBobMaskedQuestionRegister_determines D side default marker index.1 index.2 xs ys target same have mixed := mixedStableAliceQuestionCode_joint_factor G n S mixedWeight coordinate code target question next stable determines rw [exactConditionedReverseBobNextPrior_flagged_mixture G n S D remaining side default marker] change groupedMass (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => (code point.1 point.2.1 point.2.2.1, point.2.1 (coordinate point.1))) (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => mixedWeight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2) (target, next) = G.conditionalXGivenY question next * jointFirstMarginal (groupedMass (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => (code point.1 point.2.1 point.2.2.1, point.2.1 (coordinate point.1))) (fun point : (ConditionedAnswerFlag A B D × ExactRemainingSeed D) × ExactOutcome X Y A B n => mixedWeight point.1 * (strategyEventLaw (G.repeat n) S).weight point.2)) target rw [jointFirstMarginal_groupedContextNext] convert mixed using 1 exact congrFun (exactGroupedMass_decidableEq_irrel _ _ _ _) (target, next) theorem exactConditionedReverseBobNextPrior_marked_conditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) (target : ExactReverseBobNextContext X Y A B D side) (supported : jointFirstMarginal (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextPrior G n S D remaining side)) target ≠ 0) : jointConditional (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextPrior G n S D remaining side)) target = G.conditionalXGivenY (target.1.1.2.2.2.1 (target.1.1.1.sideRank.symm marker)) := by funext next unfold jointConditional rw [exactConditionedReverseBobNextPrior_marked_joint_factor G n S D remaining side default marker target next] exact mul_div_cancel_right₀ _ supported theorem exactReverseBobMarkedPriorConditional_eq_game (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : X) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) (supported : jointFirstMarginal (groupedMass (exactPrefixNextCode default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩)) (exactConditionedReverseBobNextPrior G n S D remaining (exactReverseRightSide seed))) (exactReverseBobMarkedHistoryContext G n S D default seed reference) ≠ 0) : jointConditional (groupedMass (exactPrefixNextCode default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩)) (exactConditionedReverseBobNextPrior G n S D remaining (exactReverseRightSide seed))) (exactReverseBobMarkedHistoryContext G n S D default seed reference) = G.conditionalXGivenY (reference.2.1 seed.coordinate.val) := by have actual := exactConditionedReverseBobNextPrior_marked_conditional G n S D remaining (exactReverseRightSide seed) default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) (exactReverseBobMarkedHistoryContext G n S D default seed reference) supported simpa [exactReverseBobMarkedHistoryContext, finitePrefixMask, exactReverseBobSourceProjection] using actual end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 6000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseBobMaskedOutcomeContext (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (outcome : ExactOutcome X Y A B n) : ExactReverseBobNextContext X Y A B D side := let projection := exactReverseBobContextOutcomeProjection (X := X) (Y := Y) (A := A) (B := B) D side context outcome finitePrefixMask default marker.castSucc ((projection.1, repeatedConditionedAnswerFlag G n S D outcome), projection.2) theorem exactReverseBobMaskedOutcomeContext_extract (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (outcome : ExactOutcome X Y A B n) : (exactReverseBobMaskedOutcomeContext G n S D side default marker context outcome).1.1.1 = context := by rfl theorem exactConditionedReverseBobNextJoint_marked_mixture (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) : groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextJoint G n S D remaining side) = groupedMass (fun point : ExactJointOutcome X Y A B D => (exactReverseBobMaskedOutcomeContext G n S D side default marker (exactReverseBobContextAt side point.1) point.2, point.2.1 (((exactReverseBobContextAt side point.1).sideRank.symm marker).val.val))) (fun point : ExactJointOutcome X Y A B D => (exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side).weight point.1 * repeatedConditionedOutcomeLaw G n S D point.2) := by classical let law := exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let projection := exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side change groupedMass (exactPrefixNextCode default marker) (reweightedSeedPrefixJoint law G n S D projection) = _ rw [reweightedSeedPrefixNextJoint_as_actual_pushforward] funext target unfold groupedMass apply Finset.sum_congr · ext point simp [exactPrefixNextCode, exactReverseBobMaskedOutcomeContext, exactReverseBobContextOutcomeProjection, exactReverseBobSourceProjection, projection] · intro point _ exact reweightedSeedPosterior_eq_product law G n S D point theorem exactReverseBobConditionalSeedLaw_actual_pos {M : Type*} [Fintype M] [DecidableEq M] (nonempty : 0 < Fintype.card M) (seed : ExactForwardSeed M) : 0 < (exactReverseBobConditionalSeedLaw nonempty (exactReverseRightSide seed)).weight seed := by have sideNonempty : (exactReverseRightSide seed).Nonempty := ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ rw [exactReverseBobConditionalSeedLaw_weight nonempty (exactReverseRightSide seed) sideNonempty seed] unfold exactReverseBobConditionalSeedWeight rw [if_pos rfl] exact div_pos (exactSeedWeight_pos_of_seed seed) ((reversePartitionWeight_pos_iff nonempty (exactReverseRightSide seed)).mpr sideNonempty) theorem exactReverseBobMaskedOutcomeContext_actual (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (default : X) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) : exactReverseBobMaskedOutcomeContext G n S D (exactReverseRightSide seed) default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) (exactReverseBobContextAt (exactReverseRightSide seed) seed) outcome = exactReverseBobMarkedHistoryContext G n S D default seed outcome := by simp [exactReverseBobMaskedOutcomeContext, exactReverseBobContextOutcomeProjection, exactReverseBobMarkedHistoryContext, exactReverseBobSourceProjection] theorem exactConditionedReverseBobNextJoint_marked_conditional_eq_fixedOutcome (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : X) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (groupedMass (exactPrefixNextCode default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩)) (exactConditionedReverseBobNextJoint G n S D remaining (exactReverseRightSide seed))) (exactReverseBobMarkedHistoryContext G n S D default seed reference) = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseBobMarkedHistoryContext G n S D default seed outcome, outcome.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) (exactReverseBobMarkedHistoryContext G n S D default seed reference) := by classical let side := exactReverseRightSide seed let marker : Fin side.card := (exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ let law := exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let index : ExactRemainingSeed D → ExactReverseSideContext (SourceRemainingCoordinate D) side := exactReverseBobContextAt side let context : ExactReverseSideContext (SourceRemainingCoordinate D) side → ExactOutcome X Y A B n → ExactReverseBobNextContext X Y A B D side := exactReverseBobMaskedOutcomeContext G n S D side default marker let next : ExactReverseSideContext (SourceRemainingCoordinate D) side → ExactOutcome X Y A B n → X := fun reverseContext outcome => outcome.1 ((reverseContext.sideRank.symm marker).val.val) let extract : ExactReverseBobNextContext X Y A B D side → ExactReverseSideContext (SourceRemainingCoordinate D) side := fun target => target.1.1.1 let target := exactReverseBobMarkedHistoryContext G n S D default seed reference have extract_context : ∀ (reverseContext : ExactReverseSideContext (SourceRemainingCoordinate D) side) (outcome : ExactOutcome X Y A B n), extract (context reverseContext outcome) = reverseContext := by intro reverseContext outcome exact exactReverseBobMaskedOutcomeContext_extract G n S D side default marker reverseContext outcome have target_index : extract target = index seed := by rfl have positive : 0 < groupedMass index law.weight (index seed) := by apply groupedMass_pos_of_supported_atom index law.weight law.weight_nonneg seed exact exactReverseBobConditionalSeedLaw_actual_pos (exactRemainingCoordinate_card_pos D remaining) seed have stable := jointConditional_product_stable_context_seed index context next extract extract_context law.weight (repeatedConditionedOutcomeLaw G n S D) seed target target_index (ne_of_gt positive) rw [exactConditionedReverseBobNextJoint_marked_mixture G n S D remaining side default marker] change jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => (context (index point.1) point.2, next (index point.1) point.2)) (fun point : ExactJointOutcome X Y A B D => law.weight point.1 * repeatedConditionedOutcomeLaw G n S D point.2)) target = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseBobMarkedHistoryContext G n S D default seed outcome, outcome.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) target calc jointConditional (groupedMass (fun point : ExactJointOutcome X Y A B D => (context (index point.1) point.2, next (index point.1) point.2)) (fun point : ExactJointOutcome X Y A B D => law.weight point.1 * repeatedConditionedOutcomeLaw G n S D point.2)) target = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (context (index seed) outcome, next (index seed) outcome)) (repeatedConditionedOutcomeLaw G n S D)) target := by convert stable using 1 · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ _ _ · congr 1 exact exactGroupedMass_decidableEq_irrel _ _ _ _ _ = jointConditional (groupedMass (fun outcome : ExactOutcome X Y A B n => (exactReverseBobMarkedHistoryContext G n S D default seed outcome, outcome.1 seed.coordinate.val)) (repeatedConditionedOutcomeLaw G n S D)) target := by congr 1 apply congrArg (fun code => groupedMass code (repeatedConditionedOutcomeLaw G n S D)) funext outcome apply Prod.ext · exact exactReverseBobMaskedOutcomeContext_actual G n S D default seed outcome · simp [next, index, side, marker] theorem exactConditionedReverseBobNextJoint_marked_conditional_eq_sourcePosterior (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : X) (seed : ExactRemainingSeed D) (reference : ExactOutcome X Y A B n) : jointConditional (groupedMass (exactPrefixNextCode default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩)) (exactConditionedReverseBobNextJoint G n S D remaining (exactReverseRightSide seed))) (exactReverseBobMarkedHistoryContext G n S D default seed reference) = jointConditional (fun atom : ((SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D) × X => exactBobInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((seed.coordinate, reference.2.1 seed.coordinate.val), exactHistoryCode D (seed, reference)) := by exact (exactConditionedReverseBobNextJoint_marked_conditional_eq_fixedOutcome G n S D remaining default seed reference).trans (exactReverseBobMarkedPosteriorConditional_eq_sourcePosterior G n S D default seed reference) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 8000000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactReverseBobContextMarkedEntropyScore (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : X) (side : Finset (SourceRemainingCoordinate D)) (context : ExactReverseSideContext (SourceRemainingCoordinate D) side) (marker : Fin side.card) (outcome : ExactOutcome X Y A B n) : ℝ := let target := exactReverseBobMaskedOutcomeContext G n S D side default marker context outcome finiteRelativeEntropy (jointConditional (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextJoint G n S D remaining side)) target) (jointConditional (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextPrior G n S D remaining side)) target) def exactReverseBobActualMarkedEntropyScore (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : X) (side : Finset (SourceRemainingCoordinate D)) (seed : ExactRemainingSeed D) (marker : Fin side.card) (outcome : ExactOutcome X Y A B n) : ℝ := let target := exactReverseBobMaskedOutcomeContext G n S D side default marker (exactReverseBobContextAt side seed) outcome finiteRelativeEntropy (jointConditional (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextJoint G n S D remaining side)) target) (jointConditional (groupedMass (exactPrefixNextCode default marker) (exactConditionedReverseBobNextPrior G n S D remaining side)) target) theorem exactReverseBobActualMarkedEntropyScore_eq_context (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (default : X) (side : Finset (SourceRemainingCoordinate D)) (seed : ExactRemainingSeed D) (marker : Fin side.card) (outcome : ExactOutcome X Y A B n) : exactReverseBobActualMarkedEntropyScore G n S D remaining default side seed marker outcome = exactReverseBobContextMarkedEntropyScore G n S D remaining default side (exactReverseBobContextAt side seed) marker outcome := by rfl theorem exactConditionedReverseBobPrefixEntropyIncrement_eq_markedOutcomeScore (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (side : Finset (SourceRemainingCoordinate D)) (default : X) (marker : Fin side.card) : exactConditionedReverseBobPrefixEntropyIncrement G n S D remaining side default marker = ∑ seed : ExactRemainingSeed D, (exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side).weight seed * ∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome * exactReverseBobActualMarkedEntropyScore G n S D remaining default side seed marker outcome := by classical let law := exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let projection := exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side change reweightedSeedPrefixEntropyIncrement law G n S D projection default marker = _ rw [reweightedSeedPrefixEntropyIncrement_eq_actual_atom_sum law G n S D positive projection default marker] rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro seed _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro outcome _ rw [reweightedSeedPosterior_eq_product] change (law.weight seed * repeatedConditionedOutcomeLaw G n S D outcome) * exactReverseBobActualMarkedEntropyScore G n S D remaining default side seed marker outcome = law.weight seed * (repeatedConditionedOutcomeLaw G n S D outcome * exactReverseBobActualMarkedEntropyScore G n S D remaining default side seed marker outcome) ring theorem exactConditionedReverseBobPrefixInformation_eq_sourceMarkerAverage (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (default : X) : exactConditionedReverseBobPrefixInformation G n S D remaining default = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, ∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome * exactReverseBobActualMarkedEntropyScore G n S D remaining default (exactReverseRightSide seed) seed marker outcome) / ((exactReverseRightSide seed).card : ℝ)) := by classical unfold exactConditionedReverseBobPrefixInformation simp_rw [ exactConditionedReverseBobPrefixEntropyIncrement_eq_markedOutcomeScore G n S D remaining positive] exact exactReverseBobSideWeightedPrefix_sum (exactRemainingCoordinate_card_pos D remaining) (fun side seed marker => ∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome * exactReverseBobActualMarkedEntropyScore G n S D remaining default side seed marker outcome) theorem exactConditionedReverseBobPrefixInformation_eq_sourceMarkedOutcomeScore (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (default : X) : exactConditionedReverseBobPrefixInformation G n S D remaining default = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome * exactReverseBobContextMarkedEntropyScore G n S D remaining default (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) outcome := by calc exactConditionedReverseBobPrefixInformation G n S D remaining default = ∑ seed : ExactRemainingSeed D, exactSeedWeight seed * ((∑ marker : Fin (exactReverseRightSide seed).card, ∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome * exactReverseBobActualMarkedEntropyScore G n S D remaining default (exactReverseRightSide seed) seed marker outcome) / ((exactReverseRightSide seed).card : ℝ)) := exactConditionedReverseBobPrefixInformation_eq_sourceMarkerAverage G n S D remaining positive default _ = _ := by simpa only [ exactReverseBobActualMarkedEntropyScore_eq_context, exactReverseBobContextAt_actual] using (exactReverseBobUniformMarkedSeed_sum (exactRemainingCoordinate_card_pos D remaining) (fun side context marker => ∑ outcome : ExactOutcome X Y A B n, repeatedConditionedOutcomeLaw G n S D outcome * exactReverseBobContextMarkedEntropyScore G n S D remaining default side context marker outcome)) theorem exactReverseBobMarkedPriorMarginal_ne_zero_of_outcome (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (default : X) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) (supported : repeatedConditionedOutcomeLaw G n S D outcome ≠ 0) : jointFirstMarginal (groupedMass (exactPrefixNextCode default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩)) (exactConditionedReverseBobNextPrior G n S D remaining (exactReverseRightSide seed))) (exactReverseBobMarkedHistoryContext G n S D default seed outcome) ≠ 0 := by let side := exactReverseRightSide seed let marker : Fin side.card := (exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩ let law := exactReverseBobConditionalSeedLaw (exactRemainingCoordinate_card_pos D remaining) side let projection := exactReverseBobSourceProjection (X := X) (Y := Y) (A := A) (B := B) D side have outcome_nonnegative : 0 ≤ repeatedConditionedOutcomeLaw G n S D outcome := conditionedEventDistribution_nonneg (strategyEventLaw (G.repeat n) S) (FiniteEventLaw.winEvent (repeatedCoordinateWin G n) D) positive outcome have outcome_positive : 0 < repeatedConditionedOutcomeLaw G n S D outcome := lt_of_le_of_ne outcome_nonnegative (Ne.symm supported) have seed_positive : 0 < law.weight seed := exactReverseBobConditionalSeedLaw_actual_pos (exactRemainingCoordinate_card_pos D remaining) seed have atom_positive : 0 < reweightedSeedPosterior law G n S D (seed, outcome) := by rw [reweightedSeedPosterior_eq_product] exact mul_pos seed_positive outcome_positive have actual := reweightedSeedPrefixPriorMarginal_ne_zero_of_positive_atom law G n S D positive projection default marker (seed, outcome) atom_positive exact actual theorem exactReverseBobActualMarkedEntropy_eq_source (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (default : X) (seed : ExactRemainingSeed D) (outcome : ExactOutcome X Y A B n) (supported : repeatedConditionedOutcomeLaw G n S D outcome ≠ 0) : exactReverseBobContextMarkedEntropyScore G n S D remaining default (exactReverseRightSide seed) (exactReverseBobContext seed) ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) outcome = finiteRelativeEntropy (jointConditional (fun atom : ((SourceRemainingCoordinate D × Y) × ExactHistoryFlag X Y A B D) × X => exactBobInformationPosterior G n S D (atom.1.1, (atom.1.2, atom.2))) ((seed.coordinate, outcome.2.1 seed.coordinate.val), exactHistoryCode D (seed, outcome))) (G.conditionalXGivenY (outcome.2.1 seed.coordinate.val)) := by have history : exactReverseBobMaskedOutcomeContext G n S D (exactReverseRightSide seed) default ((exactReverseBobContext seed).sideRank ⟨seed.coordinate, exactReverseRightSide_coordinate_mem seed⟩) (exactReverseBobContext seed) outcome = exactReverseBobMarkedHistoryContext G n S D default seed outcome := by simpa only [exactReverseBobContextAt_actual] using (exactReverseBobMaskedOutcomeContext_actual G n S D default seed outcome) have prior_supported := exactReverseBobMarkedPriorMarginal_ne_zero_of_outcome G n S D remaining positive default seed outcome supported unfold exactReverseBobContextMarkedEntropyScore dsimp only rw [history] rw [exactConditionedReverseBobNextJoint_marked_conditional_eq_sourcePosterior G n S D remaining default seed outcome] rw [exactReverseBobMarkedPriorConditional_eq_game G n S D remaining default seed outcome prior_supported] theorem exactReverseBobConditionalHistoryIdentification_proved (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (default : X) : ExactReverseBobConditionalHistoryIdentification G n S D remaining base default := by classical unfold ExactReverseBobConditionalHistoryIdentification rw [exactBobSourceConditionalInformation_eq_joint_atom_sum G n S D remaining positive base] rw [exactConditionedReverseBobPrefixInformation_eq_sourceMarkedOutcomeScore G n S D remaining positive default] rw [Fintype.sum_prod_type] apply Finset.sum_congr rfl intro seed _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro outcome _ by_cases zero : repeatedConditionedOutcomeLaw G n S D outcome = 0 · simp [exactPostselectedJointLaw, zero] · rw [exactReverseBobActualMarkedEntropy_eq_source G n S D remaining positive default seed outcome zero] unfold exactPostselectedJointLaw ring end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exact_source_equation_twenty_three_unconditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (defaultY : Y) (defaultX : X) : ExactSourceClassicalInformationBound G n S D base := by exact exact_source_equation_twenty_three_of_actual_conditioned_reindex G n S D remaining positive base defaultY defaultX (exactReverseAliceConditionalHistoryIdentification_proved G n S D remaining positive base defaultY) (exactReverseBobConditionalHistoryIdentification_proved G n S D remaining positive base defaultX) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1600000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker open QuantumParallelRepetition.ClassicalSampling open QuantumParallelRepetition.ClassicalInformation attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def ExactSourceSupportPreservingClassicalSampler (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (base : ExactHistoryFlag X Y A B D) (kappa gamma : ℝ) : Prop := ∃ denominator : ℕ, 0 < denominator ∧ ∃ numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ, (∀ index, (∑ history, numerator index history) = denominator) ∧ (∀ index, finiteTotalVariation (exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index) (fun history => (numerator index history : ℝ) / denominator) < gamma) ∧ (∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) ∧ ∃ nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty, finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJARounded G n D denominator numerator) ≤ kappa + gamma ∧ finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJBRounded G n D denominator numerator) ≤ kappa + gamma ∧ exactLocallySampleablePermutationMismatch G n D denominator numerator nonempty ≤ 4 * (kappa + gamma) theorem exact_source_equation_twenty_seven_support_preserving (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) {kappa gamma : ℝ} (gamma_positive : 0 < gamma) (alice : finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) ≤ kappa) (bob : finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) ≤ kappa) : ExactSourceSupportPreservingClassicalSampler G n S D base kappa gamma := by obtain ⟨denominator, denominator_positive, numerator, normalized, approximation, preserves, nonempty, _, _⟩ := exact_exists_support_preserving_local_shared_permutation G n S D positive base gamma_positive have rounded_alice : finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJARounded G n D denominator numerator) ≤ kappa + gamma := by calc finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJARounded G n D denominator numerator) ≤ finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJA G n S D base) + finiteTotalVariation (exactLocallySampleableJA G n S D base) (exactLocallySampleableJARounded G n D denominator numerator) := finiteTotalVariation_triangle _ _ _ _ ≤ kappa + gamma := add_le_add alice (exactLocallySampleableJA_rounded_totalVariation_le G n S D remaining base denominator numerator approximation) have rounded_bob : finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJBRounded G n D denominator numerator) ≤ kappa + gamma := by calc finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJBRounded G n D denominator numerator) ≤ finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJB G n S D base) + finiteTotalVariation (exactLocallySampleableJB G n S D base) (exactLocallySampleableJBRounded G n D denominator numerator) := finiteTotalVariation_triangle _ _ _ _ ≤ kappa + gamma := add_le_add bob (exactLocallySampleableJB_rounded_totalVariation_le G n S D remaining base denominator numerator approximation) refine ⟨denominator, denominator_positive, numerator, normalized, approximation, preserves, nonempty, rounded_alice, rounded_bob, ?_⟩ calc exactLocallySampleablePermutationMismatch G n D denominator numerator nonempty ≤ 2 * finiteTotalVariation (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableJBRounded G n D denominator numerator) := exactLocallySampleablePermutationMismatch_le_two_tv G n D denominator denominator_positive numerator normalized nonempty _ ≤ 2 * (finiteTotalVariation (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableLaw G n S D) + finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJBRounded G n D denominator numerator)) := by gcongr exact finiteTotalVariation_triangle _ _ _ _ = 2 * (finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJARounded G n D denominator numerator) + finiteTotalVariation (exactLocallySampleableLaw G n S D) (exactLocallySampleableJBRounded G n D denominator numerator)) := by rw [finiteTotalVariation_comm (exactLocallySampleableJARounded G n D denominator numerator) (exactLocallySampleableLaw G n S D)] _ ≤ 4 * (kappa + gamma) := by nlinarith theorem exact_source_equation_twenty_seven_support_preserving_of_information (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (information : ExactSourceClassicalInformationBound G n S D base) {gamma : ℝ} (gamma_positive : 0 < gamma) : ExactSourceSupportPreservingClassicalSampler G n S D base (exactSourcePinskerRate G n S D) gamma := by exact exact_source_equation_twenty_seven_support_preserving G n S D remaining positive base gamma_positive (exact_source_alice_pinsker_of_classical_information G n S D remaining positive base information) (exact_source_bob_pinsker_of_classical_information G n S D remaining positive base information) end noncomputable section open scoped BigOperators set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 1800000 set_option maxRecDepth 2048 open QuantumParallelRepetition.Pinsker attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem gameQuestionX_nonempty (G : Game X Y A B) : Nonempty X := by classical by_contra empty have zero : (∑ x : X, ∑ y : Y, G.questionWeight x y) = 0 := by apply Finset.sum_eq_zero intro x _ exact (empty ⟨x⟩).elim linarith [G.weight_normalized] theorem gameQuestionY_nonempty (G : Game X Y A B) : Nonempty Y := by classical by_contra empty have zero : (∑ x : X, ∑ y : Y, G.questionWeight x y) = 0 := by apply Finset.sum_eq_zero intro x _ apply Finset.sum_eq_zero intro y _ exact (empty ⟨y⟩).elim linarith [G.weight_normalized] theorem exact_source_equation_twenty_three (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) : ExactSourceClassicalInformationBound G n S D base := by classical exact exact_source_equation_twenty_three_unconditional G n S D remaining positive base (Classical.choice (gameQuestionY_nonempty G)) (Classical.choice (gameQuestionX_nonempty G)) theorem exact_source_equation_twenty_seven_support_preserving_unconditional (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) {gamma : ℝ} (gamma_positive : 0 < gamma) : ExactSourceSupportPreservingClassicalSampler G n S D base (exactSourcePinskerRate G n S D) gamma := by exact exact_source_equation_twenty_seven_support_preserving_of_information G n S D remaining positive base (exact_source_equation_twenty_three G n S D remaining positive base) gamma_positive end noncomputable section open Filter open scoped Topology variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def ExactSourceOneGameRounding (G : Game X Y A B) : Prop := ∃ K₀ : ℝ, 0 ≤ K₀ ∧ ∀ (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)), 0 < (Finset.univ \ D).card → 0 < repeatedPostselectionMass G n S D → ∀ (α gamma : ℝ), 0 < α → α ≤ 1 → 0 < gamma → uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2 → ∃ rounded : Strategy G, roundedWinningLowerBound (1 - entangledValue G) K₀ α (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability theorem exact_totalSamplingLoss_mono {K₀ α₁ α₂ η₁ η₂ lam₁ lam₂ : ℝ} (constant_nonnegative : 0 ≤ K₀) (alpha_nonnegative : 0 ≤ α₁) (alpha_le : α₁ ≤ α₂) (eta_nonnegative : 0 ≤ η₁) (eta_le : η₁ ≤ η₂) (lam_le : lam₁ ≤ lam₂) : totalSamplingLoss K₀ α₁ η₁ lam₁ ≤ totalSamplingLoss K₀ α₂ η₂ lam₂ := by have ceiling_nonnegative : 0 ≤ universalErrorCeiling K₀ := by unfold universalErrorCeiling positivity have alpha_root : α₁ ^ (1 / 12 : ℝ) ≤ α₂ ^ (1 / 12 : ℝ) := Real.rpow_le_rpow alpha_nonnegative alpha_le (by norm_num) have eta_root : (32 * η₁) ^ (1 / 12 : ℝ) ≤ (32 * η₂) ^ (1 / 12 : ℝ) := by apply Real.rpow_le_rpow · positivity · linarith · norm_num have eta_sqrt : Real.sqrt (8 * η₁) ≤ Real.sqrt (8 * η₂) := by apply Real.sqrt_le_sqrt linarith unfold totalSamplingLoss gcongr theorem exact_standardQuantumParallelRepetition_of_source_rounding (G : Game X Y A B) (rounding : ExactSourceOneGameRounding G) : StandardQuantumParallelRepetition G := by intro gap by_contra no_exponential_bound have witness : HasSubexponentialWitness (repeatedEntangledValue G) := (not_hasExponentialBound_iff (repeatedEntangledValue G)).mp no_exponential_bound obtain ⟨K₀, constant_nonnegative, construct⟩ := rounding let gapValue : ℝ := 1 - entangledValue G have gap_positive : 0 < gapValue := by dsimp [gapValue] linarith let failureTolerance : ℝ := min (gapValue / 2) (1 / 2) have failure_positive : 0 < failureTolerance := by dsimp [failureTolerance] exact lt_min (by positivity) (by norm_num) have failure_at_most_one : failureTolerance ≤ 1 := by have half := min_le_right (gapValue / 2) (1 / 2 : ℝ) dsimp [failureTolerance] linarith let rate : ℕ → ℝ := fun k => 1 / ((k : ℝ) + 1) have rate_positive (k : ℕ) : 0 < rate k := by dsimp [rate] positivity have rate_at_most_one (k : ℕ) : rate k ≤ 1 := by dsimp [rate] apply (div_le_iff₀ (by positivity : (0 : ℝ) < (k : ℝ) + 1)).2 have nonnegative : (0 : ℝ) ≤ (k : ℝ) := by positivity nlinarith have rate_tendsto : Tendsto rate atTop (𝓝 0) := by exact tendsto_one_div_add_atTop_nhds_zero_nat have martingale_tendsto : Tendsto (fun k => rate k ^ 2 / 8) atTop (𝓝 0) := by simpa using (rate_tendsto.pow 2).div_const (8 : ℝ) have sampling_tendsto : Tendsto (fun k => rate k / 2 + rate k) atTop (𝓝 0) := by simpa using (rate_tendsto.div_const (2 : ℝ)).add rate_tendsto have eventually_small : ∀ᶠ k : ℕ in atTop, totalSamplingLoss K₀ (rate k) (rate k ^ 2 / 8) (rate k / 2 + rate k) < gapValue / 2 := totalSamplingLoss_eventually_lt K₀ rate_tendsto martingale_tendsto sampling_tendsto (by positivity) obtain ⟨k, loss_small⟩ := eventually_small.exists obtain ⟨n, _, S, D, _, postselection_positive, remaining_positive, failure_small, martingale_small, pinsker_small⟩ := exact_arbitrarily_large_conditioning_of_subexponentialWitness G witness failure_positive failure_at_most_one (rate_positive k) 0 have failure_gap : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < gapValue / 2 := lt_of_lt_of_le failure_small (min_le_left (gapValue / 2) (1 / 2 : ℝ)) obtain ⟨rounded, rounded_bound⟩ := construct n S D remaining_positive postselection_positive (rate k) (rate k) (rate_positive k) (rate_at_most_one k) (rate_positive k) (by simpa [gapValue] using failure_gap) have martingale_nonnegative := martingaleRate_nonneg G n S D remaining_positive postselection_positive have exact_loss_small : totalSamplingLoss K₀ (rate k) (martingaleRate G n S D) (exactSourcePinskerRate G n S D + rate k) < gapValue / 2 := by refine lt_of_le_of_lt ?_ loss_small apply exact_totalSamplingLoss_mono constant_nonnegative (rate_positive k).le (le_refl _) martingale_nonnegative martingale_small linarith exact source_equation_twenty_nine_contradiction G rounded K₀ (rate k) (martingaleRate G n S D) (exactSourcePinskerRate G n S D + rate k) rounded_bound (by simpa [gapValue] using exact_loss_small) end noncomputable section open Matrix open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2000000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def unitaryConjugatePOVM {C d : Type} [Fintype C] [Fintype d] [DecidableEq d] (U : Matrix.unitaryGroup d ℂ) (P : POVM C d) : POVM C d where effect c := (U : Matrix d d ℂ)ᴴ * P.effect c * (U : Matrix d d ℂ) positive c := by have positive := (P.positive c).mul_mul_conjTranspose_same ((U : Matrix d d ℂ)ᴴ) simpa using positive complete := by classical have unitary : (U : Matrix d d ℂ)ᴴ * (U : Matrix d d ℂ) = 1 := by simpa [Matrix.star_eq_conjTranspose] using (Matrix.mem_unitaryGroup_iff').mp U.property calc (∑ c : C, (U : Matrix d d ℂ)ᴴ * P.effect c * (U : Matrix d d ℂ)) = (U : Matrix d d ℂ)ᴴ * (∑ c : C, P.effect c) * (U : Matrix d d ℂ) := by simp [Finset.mul_sum, Finset.sum_mul] _ = 1 := by rw [P.complete, Matrix.mul_one, unitary] end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable theorem residualIdentity_quadratic {s t : Type} [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (M : Matrix s s ℂ) (z : EuclideanSpace ℂ s) (κ : EuclideanSpace ℂ t) (normalized : ‖κ‖ = 1) : quadraticExpectation (Matrix.toEuclideanCLM (n := s × t) (𝕜 := ℂ) (M ⊗ₖ (1 : Matrix t t ℂ))) (toLp 2 (fun q : s × t => z q.1 * κ q.2)) = quadraticExpectation (Matrix.toEuclideanCLM (n := s) (𝕜 := ℂ) M) z := by classical rw [matrixQuadraticExpectation_expand, matrixQuadraticExpectation_expand] have residual_square : (∑ j : t, ‖κ j‖ ^ 2) = 1 := by rw [← EuclideanSpace.norm_sq_eq, normalized] norm_num have residual_complex : (∑ j : t, κ j * star (κ j)) = 1 := by calc (∑ j : t, κ j * star (κ j)) = (↑(∑ j : t, ‖κ j‖ ^ 2) : ℂ) := by push_cast apply Finset.sum_congr rfl intro j _ simpa [Complex.normSq_eq_norm_sq] using Complex.mul_conj (κ j) _ = 1 := by rw [residual_square]; norm_num congr 1 change (∑ i : s × t, (∑ j : s × t, (M i.1 j.1 * (if i.2 = j.2 then 1 else 0)) * (z j.1 * κ j.2)) * star (z i.1 * κ i.2)) = ∑ i : s, (∑ j : s, M i j * z j) * star (z i) rw [Fintype.sum_prod_type] calc (∑ i : s, ∑ k : t, (∑ j : s × t, (M i j.1 * (if k = j.2 then 1 else 0)) * (z j.1 * κ j.2)) * star (z i * κ k)) = ∑ i : s, ∑ k : t, ((∑ j : s, M i j * z j) * κ k) * star (z i * κ k) := by apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro k _ congr 1 rw [Fintype.sum_prod_type] simp [mul_ite, ite_mul, Finset.sum_mul, mul_assoc] _ = ∑ i : s, ((∑ j : s, M i j * z j) * star (z i)) * (∑ k : t, κ k * star (κ k)) := by apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro k _ simp only [star_mul] ring _ = ∑ i : s, (∑ j : s, M i j * z j) * star (z i) := by rw [residual_complex] simp variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def exactSourceGlobalCatalystWinningEffect [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (a₀ : A) (b₀ : B) (x : X) (y : Y) : Matrix (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then (exactSourceGlobalCatalystAlicePOVM G n S D e a₀ x).effect a ⊗ₖ (exactSourceGlobalCatalystBobPOVM G n S D e b₀ y).effect b else 0 def exactSourceGlobalCatalystBasisEquiv (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) : ((ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) × (Fin e × Fin e)) ≃ (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) := by classical let localEquiv : (ExactGlobalHistoryLocalIndex G n S D × Fin e) ≃ Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) := (Equiv.prodCongr (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) (Equiv.refl (Fin e))).trans finProdFinEquiv exact (Equiv.prodProdProdComm (ExactGlobalHistoryLocalIndex G n S D) (ExactGlobalHistoryLocalIndex G n S D) (Fin e) (Fin e)).trans (Equiv.prodCongr localEquiv localEquiv) @[simp] theorem exactSourceGlobalCatalystAlicePOVM_effect_global [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (a₀ a : A) (x : X) (i j : ExactGlobalHistoryLocalIndex G n S D) (k l : Fin e) : (exactSourceGlobalCatalystAlicePOVM G n S D e a₀ x).effect a (finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) i, k)) (finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) j, l)) = (exactSourceGlobalAlicePOVM G n S D a₀ x).effect a i j * (if k = l then 1 else 0) := by classical change (reindexedPOVM finProdFinEquiv (purificationAlicePOVM (k := Fin e) (reindexedPOVM (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) (exactSourceGlobalAlicePOVM G n S D a₀ x)))).effect a (finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) i, k)) (finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) j, l)) = _ exact reindexedCatalystPOVM_effect (exactSourceGlobalAlicePOVM G n S D a₀ x) e a i j k l theorem exactSourceGlobalCatalystWinningEffect_compression [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (a₀ : A) (b₀ : B) (x : X) (y : Y) (i j : (ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) × (Fin e × Fin e)) : exactSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ x y (exactSourceGlobalCatalystBasisEquiv G n S D e i) (exactSourceGlobalCatalystBasisEquiv G n S D e j) = ((exactSourceGlobalWinningEffect G n S D a₀ b₀ x y) ⊗ₖ (1 : Matrix (Fin e × Fin e) (Fin e × Fin e) ℂ)) i j := by classical rcases i with ⟨⟨ia, ib⟩, ⟨ka, kb⟩⟩ rcases j with ⟨⟨ja, jb⟩, ⟨la, lb⟩⟩ by_cases alice_residual : ka = la · subst la by_cases bob_residual : kb = lb · subst lb simp only [exactSourceGlobalCatalystWinningEffect, exactSourceGlobalWinningEffect, Matrix.sum_apply, Matrix.kroneckerMap_apply, exactSourceGlobalCatalystBasisEquiv, Equiv.trans_apply, Equiv.prodCongr_apply, Equiv.prodProdProdComm_apply, Matrix.one_apply, ite_true, mul_one] apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ split_ifs with winning · simp [Matrix.kroneckerMap_apply, exactSourceGlobalCatalystAlicePOVM_effect_global, exactSourceGlobalCatalystBobPOVM_effect] · rfl · simp [exactSourceGlobalCatalystWinningEffect, exactSourceGlobalWinningEffect, exactSourceGlobalCatalystBasisEquiv, Matrix.sum_apply, Matrix.kroneckerMap_apply, bob_residual] apply Finset.sum_eq_zero intro a _ apply Finset.sum_eq_zero intro b _ split_ifs with winning · simp [Matrix.kroneckerMap_apply, exactSourceGlobalCatalystAlicePOVM_effect_global, exactSourceGlobalCatalystBobPOVM_effect, bob_residual] · rfl · simp [exactSourceGlobalCatalystWinningEffect, exactSourceGlobalWinningEffect, exactSourceGlobalCatalystBasisEquiv, Matrix.sum_apply, Matrix.kroneckerMap_apply, alice_residual] apply Finset.sum_eq_zero intro a _ apply Finset.sum_eq_zero intro b _ split_ifs with winning · simp [Matrix.kroneckerMap_apply, exactSourceGlobalCatalystAlicePOVM_effect_global, exactSourceGlobalCatalystBobPOVM_effect, alice_residual] · rfl theorem exactSourceGlobalCatalystWinningEffect_tensor_quadratic [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (e : ℕ) (residual_positive : 0 < e) (a₀ : A) (b₀ : B) (x : X) (y : Y) : quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (𝕜 := ℂ) (exactSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ x y)) (tensorEmbezzlementTarget (n := e) (exactGlobalHistoryFinPsi G n S D r x y)) = quadraticExpectation (Matrix.toEuclideanCLM (n := ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) (𝕜 := ℂ) (exactSourceGlobalWinningEffect G n S D a₀ b₀ x y)) (exactGlobalHistoryVector G n S D r (exactPsi G n S D r x y)) := by classical let source := exactGlobalHistoryVector G n S D r (exactPsi G n S D r x y) let residual := embezzlementState e let tensor : EuclideanSpace ℂ ((ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) × (Fin e × Fin e)) := toLp 2 (fun q => source q.1 * residual q.2) let basis := exactSourceGlobalCatalystBasisEquiv G n S D e calc _ = quadraticExpectation (Matrix.toEuclideanCLM (n := (ExactGlobalHistoryLocalIndex G n S D × ExactGlobalHistoryLocalIndex G n S D) × (Fin e × Fin e)) (𝕜 := ℂ) ((exactSourceGlobalWinningEffect G n S D a₀ b₀ x y) ⊗ₖ (1 : Matrix (Fin e × Fin e) (Fin e × Fin e) ℂ))) tensor := by apply matrixQuadraticExpectation_injective basis basis.injective · intro i rcases i with ⟨⟨ia, ib⟩, ⟨ka, kb⟩⟩ have alice_system : (finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ia, ka)).divNat = (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ia := by exact congrArg Prod.fst (Equiv.symm_apply_apply finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ia, ka)) have alice_residual : (finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ia, ka)).modNat = ka := by exact congrArg Prod.snd (Equiv.symm_apply_apply finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ia, ka)) have bob_system : (finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ib, kb)).divNat = (Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ib := by exact congrArg Prod.fst (Equiv.symm_apply_apply finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ib, kb)) have bob_residual : (finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ib, kb)).modNat = kb := by exact congrArg Prod.snd (Equiv.symm_apply_apply finProdFinEquiv ((Fintype.equivFin (ExactGlobalHistoryLocalIndex G n S D)) ib, kb)) simp [basis, tensor, source, residual, exactSourceGlobalCatalystBasisEquiv, tensorEmbezzlementTarget, exactGlobalHistoryFinPsi, exactGlobalHistoryFinReindex, LinearIsometryEquiv.piLpCongrLeft_apply, Equiv.piCongrLeft'_apply, alice_system, alice_residual, bob_system, bob_residual] · intro j outside exact False.elim (outside (basis.symm j) (basis.apply_symm_apply j)) · exact exactSourceGlobalCatalystWinningEffect_compression G n S D e a₀ b₀ x y _ = _ := residualIdentity_quadratic (exactSourceGlobalWinningEffect G n S D a₀ b₀ x y) source residual (embezzlementState_norm e residual_positive) theorem exactPsi_eq_padded_normalizedPureVector_of_ne_zero (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (r : ExactHistoryFlag X Y A B D) (x : X) (y : Y) (nonzero : exactUnnormalizedPsi G n S D r x y ≠ 0) : exactPsi G n S D r x y = exactPaddedVector G n S D r (normalizedPureVector (exactUnnormalizedPsi G n S D r x y)) := by classical let raw := exactUnnormalizedPsi G n S D r x y have padded_nonzero : exactPaddedVector G n S D r raw ≠ 0 := by intro zero apply nonzero apply norm_eq_zero.mp rw [← exactPaddedVector_norm G n S D r raw, zero] exact norm_zero unfold exactPsi normalizeOrDefault rw [if_neg padded_nonzero, NormedSpace.normalize, exactPaddedVector_norm] ext q rcases q with ⟨i, j⟩ rcases i with i | (i | i) <;> rcases j with j | (j | j) <;> simp [exactPaddedVector, normalizedPureVector, smul_eq_mul] theorem exactSourceGlobalCatalystWinningEffect_law_supported_verifier [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (e : ℕ) (residual_positive : 0 < e) (a₀ : A) (b₀ : B) (t : ExactLocallySampleableTuple X Y A B D) (supported : exactLocallySampleableLaw G n S D t ≠ 0) : exactSourceConditionalWinningProbability G n S D t = quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (𝕜 := ℂ) (exactSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ t.2.1 t.2.2.1)) (tensorEmbezzlementTarget (n := e) (exactGlobalHistoryFinPsi G n S D t.2.2.2 t.2.1 t.2.2.1)) := by classical have coordinate := exactLocallySampleableLaw_coordinate_eq_of_ne_zero G n S D t supported have accepted := exactLocallySampleableLaw_accepted_of_ne_zero G n S D t supported have fiber := exactLocallySampleableLaw_fiber_ne_zero_of_ne_zero G n S D t supported have raw_nonzero := exactLocallySampleableLaw_psi_ne_zero_of_ne_zero G n S D t supported rw [exactSourceGlobalCatalystWinningEffect_tensor_quadratic G n S D t.2.2.2 e residual_positive a₀ b₀ t.2.1 t.2.2.1] rw [exactPsi_eq_padded_normalizedPureVector_of_ne_zero G n S D t.2.2.2 t.2.1 t.2.2.1 raw_nonzero] rw [exactSourceGlobalWinningEffect_quadratic G n S D t.2.2.2 a₀ b₀ t.2.1 t.2.2.1] have tuple : t = (t.2.2.2.seed.coordinate, t.2.1, t.2.2.1, t.2.2.2) := by rcases t with ⟨i, x, y, r⟩ simpa using coordinate conv_lhs => rw [tuple] exact exactSourceConditionalWinningProbability_eq_normalized_verifier G n S D positive t.2.2.2 accepted a₀ b₀ t.2.1 t.2.2.1 fiber end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace def unconditionalMatchedVerifierTensor {s t : Type*} [Fintype s] [Fintype t] (target : EuclideanSpace ℂ s) (work : EuclideanSpace ℂ t) : EuclideanSpace ℂ (s × t) := toLp 2 (fun q : s × t => target q.1 * work q.2) theorem unconditionalMatchedVerifierTensor_norm_sq {s t : Type*} [Fintype s] [Fintype t] (target : EuclideanSpace ℂ s) (work : EuclideanSpace ℂ t) : ‖unconditionalMatchedVerifierTensor target work‖ ^ 2 = ‖target‖ ^ 2 * ‖work‖ ^ 2 := by classical rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] change (∑ i : s, ∑ j : t, ‖target i * work j‖ ^ 2) = ‖target‖ ^ 2 * ‖work‖ ^ 2 simp_rw [norm_mul, mul_pow] rw [← Fintype.sum_mul_sum, ← EuclideanSpace.norm_sq_eq, ← EuclideanSpace.norm_sq_eq] theorem unconditionalMatchedVerifierTensor_norm {s t : Type*} [Fintype s] [Fintype t] (target : EuclideanSpace ℂ s) (work : EuclideanSpace ℂ t) : ‖unconditionalMatchedVerifierTensor target work‖ = ‖target‖ * ‖work‖ := by have squared := unconditionalMatchedVerifierTensor_norm_sq target work nlinarith [ norm_nonneg (unconditionalMatchedVerifierTensor target work), norm_nonneg target, norm_nonneg work, mul_nonneg (norm_nonneg target) (norm_nonneg work)] theorem unconditionalMatchedVerifierEffect_tensor_complement {s t : Type*} [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (effect : Matrix s s ℂ) : (1 : Matrix (s × t) (s × t) ℂ) - (effect ⊗ₖ (1 : Matrix t t ℂ)) = (1 - effect) ⊗ₖ (1 : Matrix t t ℂ) := by classical ext ⟨i, k⟩ ⟨j, l⟩ by_cases same_target : i = j · subst j by_cases same_work : k = l · subst l simp [Matrix.kroneckerMap_apply] · simp [Matrix.kroneckerMap_apply, same_work] · by_cases same_work : k = l · subst l simp [Matrix.kroneckerMap_apply, same_target] · simp [Matrix.kroneckerMap_apply, same_target, same_work] theorem unconditionalMatchedVerifierEffect_tensor_posSemidef {s t : Type*} [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (effect : Matrix s s ℂ) (positive : effect.PosSemidef) : (effect ⊗ₖ (1 : Matrix t t ℂ)).PosSemidef := positive.kronecker Matrix.PosSemidef.one theorem unconditionalMatchedVerifierEffect_tensor_complement_posSemidef {s t : Type*} [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (effect : Matrix s s ℂ) (complement : (1 - effect).PosSemidef) : ((1 : Matrix (s × t) (s × t) ℂ) - (effect ⊗ₖ (1 : Matrix t t ℂ))).PosSemidef := by rw [unconditionalMatchedVerifierEffect_tensor_complement] exact complement.kronecker Matrix.PosSemidef.one theorem unconditionalMatchedVerifierEffect_tensor_norm_le_one {s t : Type*} [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (effect : Matrix s s ℂ) (positive : effect.PosSemidef) (complement : (1 - effect).PosSemidef) : ‖Matrix.toEuclideanCLM (n := s × t) (𝕜 := ℂ) (effect ⊗ₖ (1 : Matrix t t ℂ))‖ ≤ 1 := by exact matrixEffectCLM_norm_le_one (effect ⊗ₖ (1 : Matrix t t ℂ)) (unconditionalMatchedVerifierEffect_tensor_posSemidef effect positive) (unconditionalMatchedVerifierEffect_tensor_complement_posSemidef effect complement) theorem unconditionalMatchedVerifierEffect_tensor_quadratic {s t : Type*} [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (effect : Matrix s s ℂ) (target : EuclideanSpace ℂ s) (work : EuclideanSpace ℂ t) : quadraticExpectation (Matrix.toEuclideanCLM (n := s × t) (𝕜 := ℂ) (effect ⊗ₖ (1 : Matrix t t ℂ))) (unconditionalMatchedVerifierTensor target work) = ‖work‖ ^ 2 * quadraticExpectation (Matrix.toEuclideanCLM (n := s) (𝕜 := ℂ) effect) target := by classical rw [matrixQuadraticExpectation_expand, matrixQuadraticExpectation_expand] have residual_complex : (∑ k : t, work k * star (work k)) = (↑(‖work‖ ^ 2) : ℂ) := by calc (∑ k : t, work k * star (work k)) = (↑(∑ k : t, ‖work k‖ ^ 2) : ℂ) := by push_cast apply Finset.sum_congr rfl intro k _ simpa [Complex.normSq_eq_norm_sq] using Complex.mul_conj (work k) _ = (↑(‖work‖ ^ 2) : ℂ) := by rw [← EuclideanSpace.norm_sq_eq] change (∑ i : s × t, (∑ j : s × t, (effect i.1 j.1 * (if i.2 = j.2 then 1 else 0)) * (target j.1 * work j.2)) * star (target i.1 * work i.2)).re = ‖work‖ ^ 2 * (∑ i : s, (∑ j : s, effect i j * target j) * star (target i)).re rw [Fintype.sum_prod_type] have complex_factor : (∑ i : s, ∑ k : t, (∑ j : s × t, (effect i j.1 * (if k = j.2 then 1 else 0)) * (target j.1 * work j.2)) * star (target i * work k)) = (∑ i : s, (∑ j : s, effect i j * target j) * star (target i)) * (↑(‖work‖ ^ 2) : ℂ) := by calc (∑ i : s, ∑ k : t, (∑ j : s × t, (effect i j.1 * (if k = j.2 then 1 else 0)) * (target j.1 * work j.2)) * star (target i * work k)) = ∑ i : s, ∑ k : t, ((∑ j : s, effect i j * target j) * work k) * star (target i * work k) := by apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro k _ congr 1 rw [Fintype.sum_prod_type] simp [mul_ite, ite_mul, Finset.sum_mul, mul_assoc] _ = ∑ i : s, ((∑ j : s, effect i j * target j) * star (target i)) * (∑ k : t, work k * star (work k)) := by apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro k _ simp only [star_mul] ring _ = (∑ i : s, (∑ j : s, effect i j * target j) * star (target i)) * (↑(‖work‖ ^ 2) : ℂ) := by rw [residual_complex, Finset.sum_mul] rw [complex_factor, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im] ring variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace abbrev UnconditionalSelectedCopyLocalIndex (B d N m : ℕ) := Σ _ : Fin B × Fin d, Fin (N * m) def unconditionalSelectedCopyCleanedStage {d N B m : ℕ} (Q : ℕ) (w : ℝ) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : EuclideanSpace ℂ (UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) := dSVDensityRationalPublicBucketPhysicalCoherentLocalReset Q w ξ ζ A C (dSVDensityRationalPublicBucketPhysicalCoherentMixedState (N := N) (B := B) w m ξ ζ) def unconditionalSelectedCopyIdealStage {d N B m : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) := dSVDensityRationalPublicBucketPhysicalCoherentTargetState (N := N) (B := B) w m ξ ζ def unconditionalSelectedCopyRetainedWork {S N d L : ℕ} {τ : Type*} [Fintype τ] (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (rest : EuclideanSpace ℂ τ) : EuclideanSpace ℂ ((Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) × τ) := unconditionalMatchedVerifierTensor (dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector (N := N) width schedule ξ ζ j) rest def unconditionalSelectedCopyCleanedMatchedBranch {S N d L B m : ℕ} {τ : Type*} [Fintype τ] (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) (rest : EuclideanSpace ℂ τ) : EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) × ((Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) × τ)) := unconditionalMatchedVerifierTensor (unconditionalSelectedCopyCleanedStage (N := N) (B := B) (m := m) Q (width (schedule j)) ξ ζ A C) (unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j rest) def unconditionalSelectedCopyIdealMatchedBranch {S N d L B m : ℕ} {τ : Type*} [Fintype τ] (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (rest : EuclideanSpace ℂ τ) : EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) × ((Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) × τ)) := unconditionalMatchedVerifierTensor (unconditionalSelectedCopyIdealStage (N := N) (B := B) (m := m) (width (schedule j)) ξ ζ) (unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j rest) theorem unconditionalSelectedCopy_tensor_sub {s τ : Type*} [Fintype s] [Fintype τ] (x y : EuclideanSpace ℂ s) (work : EuclideanSpace ℂ τ) : unconditionalMatchedVerifierTensor x work - unconditionalMatchedVerifierTensor y work = unconditionalMatchedVerifierTensor (x - y) work := by ext ⟨i, j⟩ change x i * work j - y i * work j = (x i - y i) * work j ring theorem unconditionalSelectedCopyRetainedWork_norm_sq {S N d L : ℕ} {τ : Type*} [Fintype τ] (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (rest : EuclideanSpace ℂ τ) : ‖unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j rest‖ ^ 2 = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val * ‖rest‖ ^ 2 := by unfold unconditionalSelectedCopyRetainedWork rw [unconditionalMatchedVerifierTensor_norm_sq, dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector_norm_sq] theorem unconditionalSelectedCopyMatchedBranch_deviation_sq {S N d L B m : ℕ} {τ : Type*} [Fintype τ] (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) (rest : EuclideanSpace ℂ τ) (rest_unit : ‖rest‖ = 1) : ‖unconditionalSelectedCopyCleanedMatchedBranch Q width schedule ξ ζ A C j rest - unconditionalSelectedCopyIdealMatchedBranch (B := B) (m := m) width schedule ξ ζ j rest‖ ^ 2 = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val * dSVDensityRationalHeterogeneousCommonStopGaugeStageError Q (width (schedule j)) m ξ ζ A C := by unfold unconditionalSelectedCopyCleanedMatchedBranch unconditionalSelectedCopyIdealMatchedBranch rw [unconditionalSelectedCopy_tensor_sub, unconditionalMatchedVerifierTensor_norm_sq, unconditionalSelectedCopyRetainedWork_norm_sq, rest_unit] unfold dSVDensityRationalHeterogeneousCommonStopGaugeStageError unconditionalSelectedCopyCleanedStage unconditionalSelectedCopyIdealStage ring theorem unconditionalSelectedCopy_weightedAffine {ι : Type*} [Fintype ι] (weight error asynchronous : ι → ℝ) (nonnegative : ∀ i, 0 ≤ weight i) (normalized : (∑ i, weight i) = 1) (coefficient residual : ℝ) (pointwise : ∀ i, error i ≤ coefficient * asynchronous i + residual) : (∑ i, weight i * error i) ≤ coefficient * (∑ i, weight i * asynchronous i) + residual := by classical calc (∑ i, weight i * error i) ≤ ∑ i, weight i * (coefficient * asynchronous i + residual) := by apply Finset.sum_le_sum intro i _ exact mul_le_mul_of_nonneg_left (pointwise i) (nonnegative i) _ = coefficient * (∑ i, weight i * asynchronous i) + (∑ i, weight i) * residual := by simp_rw [mul_add] rw [Finset.sum_add_distrib, Finset.mul_sum, Finset.sum_mul] congr 1 apply Finset.sum_congr rfl intro i _ ring _ = coefficient * (∑ i, weight i * asynchronous i) + residual := by rw [normalized] ring end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalMatchedVerifierAggregate_dependent_continuity {J : Type*} [Fintype J] {H : J → Type*} [∀ j, NormedAddCommGroup (H j)] [∀ j, InnerProductSpace ℂ (H j)] (weight : J → ℝ) (nonnegative : ∀ j, 0 ≤ weight j) (effect : (j : J) → (H j →L[ℂ] H j)) (contraction : ∀ j, ‖effect j‖ ≤ 1) (actual ideal : (j : J) → H j) : |(∑ j : J, weight j * quadraticExpectation (effect j) (actual j)) - (∑ j : J, weight j * quadraticExpectation (effect j) (ideal j))| ≤ (Real.sqrt (∑ j : J, weight j * ‖actual j‖ ^ 2) + Real.sqrt (∑ j : J, weight j * ‖ideal j‖ ^ 2)) * Real.sqrt (∑ j : J, weight j * ‖actual j - ideal j‖ ^ 2) := by classical have point (j : J) : |quadraticExpectation (effect j) (actual j) - quadraticExpectation (effect j) (ideal j)| ≤ (‖actual j‖ + ‖ideal j‖) * ‖actual j - ideal j‖ := quadraticExpectation_sub_le (effect j) (contraction j) (actual j) (ideal j) calc |(∑ j : J, weight j * quadraticExpectation (effect j) (actual j)) - (∑ j : J, weight j * quadraticExpectation (effect j) (ideal j))| = |∑ j : J, weight j * (quadraticExpectation (effect j) (actual j) - quadraticExpectation (effect j) (ideal j))| := by congr 1 simp_rw [mul_sub] rw [Finset.sum_sub_distrib] _ ≤ ∑ j : J, |weight j * (quadraticExpectation (effect j) (actual j) - quadraticExpectation (effect j) (ideal j))| := Finset.abs_sum_le_sum_abs _ _ _ = ∑ j : J, weight j * |quadraticExpectation (effect j) (actual j) - quadraticExpectation (effect j) (ideal j)| := by apply Finset.sum_congr rfl intro j _ rw [abs_mul, abs_of_nonneg (nonnegative j)] _ ≤ ∑ j : J, weight j * ((‖actual j‖ + ‖ideal j‖) * ‖actual j - ideal j‖) := by apply Finset.sum_le_sum intro j _ exact mul_le_mul_of_nonneg_left (point j) (nonnegative j) _ = (∑ j : J, weight j * ‖actual j‖ * ‖actual j - ideal j‖) + (∑ j : J, weight j * ‖ideal j‖ * ‖actual j - ideal j‖) := by rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro j _ ring _ ≤ Real.sqrt (∑ j : J, weight j * ‖actual j‖ ^ 2) * Real.sqrt (∑ j : J, weight j * ‖actual j - ideal j‖ ^ 2) + Real.sqrt (∑ j : J, weight j * ‖ideal j‖ ^ 2) * Real.sqrt (∑ j : J, weight j * ‖actual j - ideal j‖ ^ 2) := by exact add_le_add (weighted_real_cauchy weight (fun j => ‖actual j‖) (fun j => ‖actual j - ideal j‖) nonnegative) (weighted_real_cauchy weight (fun j => ‖ideal j‖) (fun j => ‖actual j - ideal j‖) nonnegative) _ = (Real.sqrt (∑ j : J, weight j * ‖actual j‖ ^ 2) + Real.sqrt (∑ j : J, weight j * ‖ideal j‖ ^ 2)) * Real.sqrt (∑ j : J, weight j * ‖actual j - ideal j‖ ^ 2) := by ring theorem unconditionalMatchedVerifierAggregate_dependent_le {J : Type*} [Fintype J] {H : J → Type*} [∀ j, NormedAddCommGroup (H j)] [∀ j, InnerProductSpace ℂ (H j)] (weight : J → ℝ) (nonnegative : ∀ j, 0 ≤ weight j) (effect : (j : J) → (H j →L[ℂ] H j)) (contraction : ∀ j, ‖effect j‖ ≤ 1) (actual ideal : (j : J) → H j) (actual_mass : (∑ j : J, weight j * ‖actual j‖ ^ 2) ≤ 1) (ideal_mass : (∑ j : J, weight j * ‖ideal j‖ ^ 2) ≤ 1) (Δ : ℝ) (deviation : (∑ j : J, weight j * ‖actual j - ideal j‖ ^ 2) ≤ Δ) : |(∑ j : J, weight j * quadraticExpectation (effect j) (actual j)) - (∑ j : J, weight j * quadraticExpectation (effect j) (ideal j))| ≤ 2 * Real.sqrt Δ := by have actual_nonnegative : 0 ≤ ∑ j : J, weight j * ‖actual j‖ ^ 2 := Finset.sum_nonneg (fun j _ => mul_nonneg (nonnegative j) (sq_nonneg _)) have ideal_nonnegative : 0 ≤ ∑ j : J, weight j * ‖ideal j‖ ^ 2 := Finset.sum_nonneg (fun j _ => mul_nonneg (nonnegative j) (sq_nonneg _)) have error_nonnegative : 0 ≤ ∑ j : J, weight j * ‖actual j - ideal j‖ ^ 2 := Finset.sum_nonneg (fun j _ => mul_nonneg (nonnegative j) (sq_nonneg _)) have actual_root : Real.sqrt (∑ j : J, weight j * ‖actual j‖ ^ 2) ≤ 1 := by nlinarith [ Real.sq_sqrt actual_nonnegative, Real.sqrt_nonneg (∑ j : J, weight j * ‖actual j‖ ^ 2)] have ideal_root : Real.sqrt (∑ j : J, weight j * ‖ideal j‖ ^ 2) ≤ 1 := by nlinarith [ Real.sq_sqrt ideal_nonnegative, Real.sqrt_nonneg (∑ j : J, weight j * ‖ideal j‖ ^ 2)] calc |(∑ j : J, weight j * quadraticExpectation (effect j) (actual j)) - (∑ j : J, weight j * quadraticExpectation (effect j) (ideal j))| ≤ (Real.sqrt (∑ j : J, weight j * ‖actual j‖ ^ 2) + Real.sqrt (∑ j : J, weight j * ‖ideal j‖ ^ 2)) * Real.sqrt (∑ j : J, weight j * ‖actual j - ideal j‖ ^ 2) := unconditionalMatchedVerifierAggregate_dependent_continuity weight nonnegative effect contraction actual ideal _ ≤ 2 * Real.sqrt Δ := by apply mul_le_mul · linarith · exact Real.sqrt_le_sqrt deviation · exact Real.sqrt_nonneg _ · norm_num variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace def unconditionalConjugatePureVector {ι : Type*} [Fintype ι] (z : EuclideanSpace ℂ ι) : EuclideanSpace ℂ ι := toLp 2 (fun i : ι => star (z i)) @[simp] theorem unconditionalConjugatePureVector_apply {ι : Type*} [Fintype ι] (z : EuclideanSpace ℂ ι) (i : ι) : unconditionalConjugatePureVector z i = star (z i) := by rfl theorem unconditionalConjugatePureVector_norm_sq {ι : Type*} [Fintype ι] (z : EuclideanSpace ℂ ι) : ‖unconditionalConjugatePureVector z‖ ^ 2 = ‖z‖ ^ 2 := by simp [EuclideanSpace.norm_sq_eq] theorem unconditionalConjugatePureVector_norm {ι : Type*} [Fintype ι] (z : EuclideanSpace ℂ ι) : ‖unconditionalConjugatePureVector z‖ = ‖z‖ := by have squares := unconditionalConjugatePureVector_norm_sq z nlinarith [norm_nonneg (unconditionalConjugatePureVector z), norm_nonneg z] def unconditionalConjugatePOVM {A ι : Type*} [Fintype A] [Fintype ι] [DecidableEq ι] (P : POVM A ι) : POVM A ι where effect a := (P.effect a).transpose positive a := (P.positive a).transpose complete := by classical rw [← Matrix.transpose_sum] rw [P.complete, Matrix.transpose_one] theorem unconditionalConjugatePureVector_transpose_quadratic {ι : Type*} [Fintype ι] [DecidableEq ι] (M : Matrix ι ι ℂ) (z : EuclideanSpace ℂ ι) : quadraticExpectation (Matrix.toEuclideanCLM (n := ι) (𝕜 := ℂ) M.transpose) (unconditionalConjugatePureVector z) = quadraticExpectation (Matrix.toEuclideanCLM (n := ι) (𝕜 := ℂ) M) z := by classical rw [matrixQuadraticExpectation_expand, matrixQuadraticExpectation_expand] congr 1 simp only [Matrix.transpose_apply, unconditionalConjugatePureVector_apply, star_star] simp_rw [Finset.sum_mul] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring theorem unconditionalConjugatePOVM_jointEffect {A B ι κ : Type*} [Fintype A] [Fintype B] [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] (P : POVM A ι) (Q : POVM B κ) (a : A) (b : B) : (unconditionalConjugatePOVM P).effect a ⊗ₖ (unconditionalConjugatePOVM Q).effect b = (P.effect a ⊗ₖ Q.effect b).transpose := by exact Matrix.kroneckerMap_transpose (fun x y : ℂ => x * y) (P.effect a) (Q.effect b) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def unconditionalConjugateSourceGlobalCatalystWinningEffect [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (a₀ : A) (b₀ : B) (x : X) (y : Y) : Matrix (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then (unconditionalConjugatePOVM (exactSourceGlobalCatalystAlicePOVM G n S D e a₀ x)).effect a ⊗ₖ (unconditionalConjugatePOVM (exactSourceGlobalCatalystBobPOVM G n S D e b₀ y)).effect b else 0 theorem unconditionalConjugateSourceGlobalCatalystWinningEffect_eq_transpose [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (a₀ : A) (b₀ : B) (x : X) (y : Y) : unconditionalConjugateSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ x y = (exactSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ x y).transpose := by classical unfold unconditionalConjugateSourceGlobalCatalystWinningEffect exactSourceGlobalCatalystWinningEffect rw [Matrix.transpose_sum] apply Finset.sum_congr rfl intro a _ rw [Matrix.transpose_sum] apply Finset.sum_congr rfl intro b _ split_ifs · exact unconditionalConjugatePOVM_jointEffect (exactSourceGlobalCatalystAlicePOVM G n S D e a₀ x) (exactSourceGlobalCatalystBobPOVM G n S D e b₀ y) a b · exact Matrix.transpose_zero.symm theorem unconditionalConjugateSourceGlobalCatalystWinningEffect_quadratic [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (e : ℕ) (a₀ : A) (b₀ : B) (x : X) (y : Y) (z : EuclideanSpace ℂ (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e))) : quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (𝕜 := ℂ) (unconditionalConjugateSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ x y)) (unconditionalConjugatePureVector z) = quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (𝕜 := ℂ) (exactSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ x y)) z := by calc _ = quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (𝕜 := ℂ) (exactSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ x y).transpose) (unconditionalConjugatePureVector z) := by exact congrArg (fun M => quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (𝕜 := ℂ) M) (unconditionalConjugatePureVector z)) (unconditionalConjugateSourceGlobalCatalystWinningEffect_eq_transpose G n S D e a₀ b₀ x y) _ = _ := unconditionalConjugatePureVector_transpose_quadratic (exactSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ x y) z theorem unconditionalConjugateSourceGlobalCatalystWinningEffect_law_supported [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (e : ℕ) (residual_positive : 0 < e) (a₀ : A) (b₀ : B) (u : ExactLocallySampleableTuple X Y A B D) (supported : exactLocallySampleableLaw G n S D u ≠ 0) : quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * e)) (𝕜 := ℂ) (unconditionalConjugateSourceGlobalCatalystWinningEffect G n S D e a₀ b₀ u.2.1 u.2.2.1)) (unconditionalConjugatePureVector (tensorEmbezzlementTarget (n := e) (exactGlobalHistoryFinPsi G n S D u.2.2.2 u.2.1 u.2.2.1))) = exactSourceConditionalWinningProbability G n S D u := by rw [unconditionalConjugateSourceGlobalCatalystWinningEffect_quadratic] exact (exactSourceGlobalCatalystWinningEffect_law_supported_verifier G n S D positive e residual_positive a₀ b₀ u supported).symm end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem unconditionalPublicBucketPhysicalCoherentTarget_apply {d N B n : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) (φ ψ : Fin B) (i j : Fin d) (a b : Fin (N * n)) : dSVDensityRationalPublicBucketPhysicalCoherentTargetState (N := N) (B := B) w n ξ ζ (⟨(φ, i), a⟩, ⟨(ψ, j), b⟩) = (ePRState B (φ, ψ) * (((‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) : ℂ) * dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ i j)) * ((Real.sqrt ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) : ℂ) * embezzlementState (N * n) (a, b)) := by rfl theorem unconditionalCanonicalAcceptedCoefficient_sourceScale {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (dimension : 0 < d) (ξ : BipartiteUnitVector d) (i : Fin d) : Real.sqrt (w * (d : ℝ)) * (‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) * Real.sqrt ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) = dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i := by have d_nonzero : (d : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt dimension) have n_nonzero : (N : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt grid) have source_positive : 0 < ‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖ := by have source_sq := dSVUniformDensityThresholdRaw_norm_sq N d have product_positive : (0 : ℝ) < (d : ℝ) * (N : ℝ) := by positivity nlinarith [norm_nonneg (sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ)))] have left_nonnegative : 0 ≤ Real.sqrt (w * (d : ℝ)) * (‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) * Real.sqrt ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) := by positivity have right_nonnegative := dSVDensityRationalCanonicalAcceptedCoefficient_nonneg w N ξ i have same_square : (Real.sqrt (w * (d : ℝ)) * (‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) * Real.sqrt ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ)) ^ 2 = dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i ^ 2 := by rw [mul_pow, mul_pow, Real.sq_sqrt (by positivity : (0 : ℝ) ≤ w * (d : ℝ)), inv_pow, dSVUniformDensityThresholdRaw_norm_sq, Real.sq_sqrt (by positivity : (0 : ℝ) ≤ (dSVDensityRationalPhysicalAcceptedRank w N ξ i).val), dSVDensityRationalPhysicalAcceptedRank_targetCoefficient_sq width N ξ i] field_simp nlinarith theorem unconditionalConjugateTranspose_eq_inverse {d : ℕ} (U : Matrix.unitaryGroup (Fin d) ℂ) : (conjugateUnitary U : Matrix (Fin d) (Fin d) ℂ).transpose = ((U⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ) := by change U.val.conjTranspose.transpose.transpose = ((U⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ) rw [Matrix.transpose_transpose] change star (U : Matrix (Fin d) (Fin d) ℂ) = _ exact congrArg (fun V : Matrix.unitaryGroup (Fin d) ℂ => (V : Matrix (Fin d) (Fin d) ℂ)) (Unitary.star_eq_inv U) theorem unconditionalConjugateBobBasisOverlapCancellation {d : ℕ} (U V : Matrix.unitaryGroup (Fin d) ℂ) : (unitaryBasisOverlap U V : Matrix (Fin d) (Fin d) ℂ) * (conjugateUnitary V : Matrix (Fin d) (Fin d) ℂ).transpose = (conjugateUnitary U : Matrix (Fin d) (Fin d) ℂ).transpose := by rw [unconditionalConjugateTranspose_eq_inverse, unconditionalConjugateTranspose_eq_inverse] change (((U⁻¹ * V : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ)) * ((V⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ) = ((U⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ) change (((U⁻¹ * V) * V⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ) = ((U⁻¹ : Matrix.unitaryGroup (Fin d) ℂ) : Matrix (Fin d) (Fin d) ℂ) simp theorem unconditionalConjugateBobBasisOverlap_sum {d : ℕ} (U V : Matrix.unitaryGroup (Fin d) ℂ) (i b : Fin d) : (∑ j : Fin d, unitaryBasisOverlap U V i j * star ((V : Matrix (Fin d) (Fin d) ℂ) b j)) = star ((U : Matrix (Fin d) (Fin d) ℂ) b i) := by have identity := congrArg (fun M : Matrix (Fin d) (Fin d) ℂ => M i b) (unconditionalConjugateBobBasisOverlapCancellation U V) simpa [Matrix.mul_apply, Matrix.transpose_apply, conjugateUnitary_apply] using identity theorem unconditionalRationalMixedConjugateBobSpectral_sum {d : ℕ} (ξ ζ : BipartiteUnitVector d) (i b : Fin d) : (∑ j : Fin d, dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ i j * star ((dSVUniformDensityThresholdLeftBobBasis ζ : Matrix (Fin d) (Fin d) ℂ) b j)) = star ((dSVUniformDensityThresholdLeftBobBasis ξ : Matrix (Fin d) (Fin d) ℂ) b i) := by exact unconditionalConjugateBobBasisOverlap_sum (dSVUniformDensityThresholdLeftBobBasis ξ) (dSVUniformDensityThresholdLeftBobBasis ζ) i b theorem unconditionalConjugateCanonicalAcceptedTarget_apply {d N : ℕ} (w : ℝ) (ξ : BipartiteUnitVector d) (a b : Fin d) : star (dSVDensityRationalCanonicalAcceptedTarget w N ξ (a, b)) = ∑ i : Fin d, (dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i : ℂ) * star ((dSVDensityRationalCanonicalAliceBasis ξ : Matrix (Fin d) (Fin d) ℂ) a i) * star ((dSVUniformDensityThresholdLeftBobBasis ξ : Matrix (Fin d) (Fin d) ℂ) b i) := by unfold dSVDensityRationalCanonicalAcceptedTarget rw [schmidtVector_apply] simp theorem unconditionalMixedConjugateCanonicalAcceptedTarget_sum {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (dimension : 0 < d) (ξ ζ : BipartiteUnitVector d) (a b : Fin d) : (∑ i : Fin d, ∑ j : Fin d, (Real.sqrt (w * (d : ℝ)) : ℂ) * ((‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) : ℂ) * (Real.sqrt ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) : ℂ) * star ((dSVDensityRationalCanonicalAliceBasis ξ : Matrix (Fin d) (Fin d) ℂ) a i) * dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ i j * star ((dSVUniformDensityThresholdLeftBobBasis ζ : Matrix (Fin d) (Fin d) ℂ) b j)) = star (dSVDensityRationalCanonicalAcceptedTarget w N ξ (a, b)) := by classical calc _ = ∑ i : Fin d, ((Real.sqrt (w * (d : ℝ)) : ℂ) * ((‖sharedThresholdResourceRaw (d := Fin d) (fun _ : Fin N => (1 : ℝ))‖⁻¹ : ℝ) : ℂ) * (Real.sqrt ((dSVDensityRationalPhysicalAcceptedRank w N ξ i).val : ℝ) : ℂ) * star ((dSVDensityRationalCanonicalAliceBasis ξ : Matrix (Fin d) (Fin d) ℂ) a i)) * (∑ j : Fin d, dSVDensityRationalLocalSpectralPairBasisOverlap ξ ζ i j * star ((dSVUniformDensityThresholdLeftBobBasis ζ : Matrix (Fin d) (Fin d) ℂ) b j)) := by apply Finset.sum_congr rfl intro i _ rw [Finset.mul_sum] apply Finset.sum_congr rfl intro j _ ring _ = ∑ i : Fin d, (dSVDensityRationalCanonicalAcceptedCoefficient w N ξ i : ℂ) * star ((dSVDensityRationalCanonicalAliceBasis ξ : Matrix (Fin d) (Fin d) ℂ) a i) * star ((dSVUniformDensityThresholdLeftBobBasis ξ : Matrix (Fin d) (Fin d) ℂ) b i) := by apply Finset.sum_congr rfl intro i _ rw [unconditionalRationalMixedConjugateBobSpectral_sum] have coefficient := congrArg (fun x : ℝ => (x : ℂ)) (unconditionalCanonicalAcceptedCoefficient_sourceScale width grid dimension ξ i) push_cast at coefficient rw [← coefficient] push_cast ring _ = _ := (unconditionalConjugateCanonicalAcceptedTarget_apply w ξ a b).symm def unconditionalMixedConjugateSigmaAtomLift {d m : ℕ} (B : ℕ) (U : Matrix.unitaryGroup (Fin d) ℂ) : Matrix.unitaryGroup (Σ _ : Fin B × Fin d, Fin m) ℂ := by classical let e : ((Fin B × Fin d) × Fin m) ≃ (Σ _ : Fin B × Fin d, Fin m) := (Equiv.sigmaEquivProd (Fin B × Fin d) (Fin m)).symm let M : Matrix ((Fin B × Fin d) × Fin m) ((Fin B × Fin d) × Fin m) ℂ := ((1 : Matrix (Fin B) (Fin B) ℂ) ⊗ₖ (U : Matrix (Fin d) (Fin d) ℂ)) ⊗ₖ (1 : Matrix (Fin m) (Fin m) ℂ) have unitary : M ∈ Matrix.unitaryGroup ((Fin B × Fin d) × Fin m) ℂ := Matrix.kronecker_mem_unitary (Matrix.kronecker_mem_unitary (Matrix.unitaryGroup (Fin B) ℂ).one_mem U.property) (Matrix.unitaryGroup (Fin m) ℂ).one_mem refine ⟨Matrix.reindex e e M, ?_⟩ rw [Matrix.mem_unitaryGroup_iff'] have compatible : star (Matrix.reindex e e M) = Matrix.reindex e e (star M) := by ext i j simp [Matrix.star_eq_conjTranspose, Matrix.reindex_apply, Matrix.conjTranspose_apply] rw [compatible] change (Matrix.reindexRingEquiv ℂ e) (star M) * (Matrix.reindexRingEquiv ℂ e) M = 1 rw [← (Matrix.reindexRingEquiv ℂ e).map_mul, (Matrix.mem_unitaryGroup_iff').mp unitary] exact (Matrix.reindexRingEquiv ℂ e).map_one theorem unconditionalMixedConjugateSigmaAtomLift_apply {d m : ℕ} (B : ℕ) (U : Matrix.unitaryGroup (Fin d) ℂ) (φ ψ : Fin B) (i j : Fin d) (a b : Fin m) : (unconditionalMixedConjugateSigmaAtomLift (m := m) B U : Matrix (Σ _ : Fin B × Fin d, Fin m) (Σ _ : Fin B × Fin d, Fin m) ℂ) ⟨(φ, i), a⟩ ⟨(ψ, j), b⟩ = if φ = ψ ∧ a = b then (U : Matrix (Fin d) (Fin d) ℂ) i j else 0 := by classical by_cases phase : φ = ψ <;> by_cases work : a = b <;> simp [unconditionalMixedConjugateSigmaAtomLift, Matrix.reindex_apply, Matrix.kroneckerMap_apply, phase, work] def unconditionalMixedConjugateSigmaLocalAction {d m : ℕ} (B : ℕ) (U V : Matrix.unitaryGroup (Fin d) ℂ) (z : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin m) × (Σ _ : Fin B × Fin d, Fin m))) : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin m) × (Σ _ : Fin B × Fin d, Fin m)) := toLp 2 ((((unconditionalMixedConjugateSigmaAtomLift (m := m) B U : Matrix (Σ _ : Fin B × Fin d, Fin m) (Σ _ : Fin B × Fin d, Fin m) ℂ) ⊗ₖ (unconditionalMixedConjugateSigmaAtomLift (m := m) B V : Matrix (Σ _ : Fin B × Fin d, Fin m) (Σ _ : Fin B × Fin d, Fin m) ℂ)).mulVec (ofLp z))) theorem unconditionalMixedConjugateSigmaLocalAction_apply {d m : ℕ} (B : ℕ) (U V : Matrix.unitaryGroup (Fin d) ℂ) (z : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin m) × (Σ _ : Fin B × Fin d, Fin m))) (φ ψ : Fin B) (i j : Fin d) (a b : Fin m) : unconditionalMixedConjugateSigmaLocalAction B U V z (⟨(φ, i), a⟩, ⟨(ψ, j), b⟩) = ∑ k : Fin d, ∑ l : Fin d, (U : Matrix (Fin d) (Fin d) ℂ) i k * (V : Matrix (Fin d) (Fin d) ℂ) j l * z (⟨(φ, k), a⟩, ⟨(ψ, l), b⟩) := by classical simp [unconditionalMixedConjugateSigmaLocalAction, Matrix.mulVec, dotProduct, Matrix.kroneckerMap_apply, Fintype.sum_prod_type, Fintype.sum_sigma, unconditionalMixedConjugateSigmaAtomLift_apply, mul_assoc, ite_and] def unconditionalMixedConjugateAcceptedPhaseHarmonicTarget {d N B : ℕ} (w : ℝ) (n : ℕ) (ξ : BipartiteUnitVector d) : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin (N * n)) × (Σ _ : Fin B × Fin d, Fin (N * n))) := dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedTarget w N ξ)) (fun _ _ _ => embezzlementState (N * n)) theorem unconditionalMixedConjugateTargetCovariance {d N B n : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (dimension : 0 < d) (ξ ζ : BipartiteUnitVector d) : Real.sqrt (w * (d : ℝ)) • unconditionalMixedConjugateSigmaLocalAction (m := N * n) B (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis ξ)) (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis ζ)) (dSVDensityRationalPublicBucketPhysicalCoherentTargetState (N := N) (B := B) w n ξ ζ) = unconditionalMixedConjugateAcceptedPhaseHarmonicTarget (B := B) w n ξ := by classical ext ⟨⟨⟨φ, i⟩, a⟩, ⟨⟨ψ, j⟩, b⟩⟩ change (Real.sqrt (w * (d : ℝ)) : ℂ) * unconditionalMixedConjugateSigmaLocalAction B (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis ξ)) (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis ζ)) (dSVDensityRationalPublicBucketPhysicalCoherentTargetState (N := N) (B := B) w n ξ ζ) (⟨(φ, i), a⟩, ⟨(ψ, j), b⟩) = (ePRState B (φ, ψ) * star (dSVDensityRationalCanonicalAcceptedTarget w N ξ (i, j))) * embezzlementState (N * n) (a, b) rw [unconditionalMixedConjugateSigmaLocalAction_apply] simp_rw [conjugateUnitary_apply, unconditionalPublicBucketPhysicalCoherentTarget_apply] rw [← unconditionalMixedConjugateCanonicalAcceptedTarget_sum width grid dimension ξ ζ i j] simp_rw [Finset.mul_sum, Finset.sum_mul] apply Finset.sum_congr rfl intro k _ apply Finset.sum_congr rfl intro l _ ring end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalSelectedCopy_coherentPhaseSigma_norm_sq {H : Type*} [Fintype H] {B m : ℕ} (phases : 0 < B) (history : EuclideanSpace ℂ (H × H)) (work : H → H → EuclideanSpace ℂ (Fin m × Fin m)) : ‖dSVDensityRationalPublicBucketCoherentPhaseSigmaState B history (fun _ i j => work i j)‖ ^ 2 = ‖dSVUniformDensityCorrectedMatchedSigmaWeightedResidual history work‖ ^ 2 := by classical unfold dSVDensityRationalPublicBucketCoherentPhaseSigmaState rw [dSVDensityRationalMixedCanonicalPrefixPhysicalSigmaWeighted_norm_sq, dSVDensityRationalMixedCanonicalPrefixPhysicalSigmaWeighted_norm_sq] simp only [Fintype.sum_prod_type] simp_rw [ dSVDensityRationalPublicBucketCoherentPhaseHistory_apply_norm_sq phases] have phase_ne : (B : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt phases) calc (∑ φ : Fin B, ∑ i : H, ∑ ψ : Fin B, ∑ j : H, (if φ = ψ then (B : ℝ)⁻¹ else 0) * ‖history (i, j)‖ ^ 2 * ‖work i j‖ ^ 2) = ∑ φ : Fin B, ∑ i : H, ∑ j : H, (B : ℝ)⁻¹ * ‖history (i, j)‖ ^ 2 * ‖work i j‖ ^ 2 := by apply Finset.sum_congr rfl intro φ _ apply Finset.sum_congr rfl intro i _ simp _ = _ := by calc (∑ φ : Fin B, ∑ i : H, ∑ j : H, (B : ℝ)⁻¹ * ‖history (i, j)‖ ^ 2 * ‖work i j‖ ^ 2) = ∑ _φ : Fin B, (B : ℝ)⁻¹ * (∑ i : H, ∑ j : H, ‖history (i, j)‖ ^ 2 * ‖work i j‖ ^ 2) := by apply Finset.sum_congr rfl intro φ _ simp_rw [Finset.mul_sum] apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ ring _ = _ := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] field_simp theorem unconditionalSelectedCopy_coherentPhaseConstantWork_norm_sq {H : Type*} [Fintype H] {B m : ℕ} (phases : 0 < B) (history : EuclideanSpace ℂ (H × H)) (work : EuclideanSpace ℂ (Fin m × Fin m)) : ‖dSVDensityRationalPublicBucketCoherentPhaseSigmaState B history (fun _ _ _ => work)‖ ^ 2 = ‖history‖ ^ 2 * ‖work‖ ^ 2 := by rw [unconditionalSelectedCopy_coherentPhaseSigma_norm_sq phases history (fun _ _ => work), dSVDensityRationalMixedCanonicalPrefixPhysicalSigmaWeighted_norm_sq] calc (∑ i : H, ∑ j : H, ‖history (i, j)‖ ^ 2 * ‖work‖ ^ 2) = (∑ i : H, ∑ j : H, ‖history (i, j)‖ ^ 2) * ‖work‖ ^ 2 := by simp_rw [Finset.sum_mul] _ = _ := by congr 1 rw [EuclideanSpace.norm_sq_eq, Fintype.sum_prod_type] theorem unconditionalSelectedCopy_conjugateAcceptedTarget_norm_sq {d N B m : ℕ} (phases : 0 < B) (grid : 0 < N) (harmonic : 0 < m) (w : ℝ) (ξ : BipartiteUnitVector d) : ‖unconditionalMixedConjugateAcceptedPhaseHarmonicTarget (N := N) (B := B) w m ξ‖ ^ 2 = ‖dSVDensityRationalCanonicalAcceptedTarget w N ξ‖ ^ 2 := by unfold unconditionalMixedConjugateAcceptedPhaseHarmonicTarget rw [unconditionalSelectedCopy_coherentPhaseConstantWork_norm_sq phases] rw [unconditionalConjugatePureVector_norm_sq, embezzlementState_norm (N * m) (Nat.mul_pos grid harmonic)] ring theorem unconditionalSelectedCopy_mixedConjugateLocalAction_norm {d B m : ℕ} (U V : Matrix.unitaryGroup (Fin d) ℂ) (z : EuclideanSpace ℂ ((Σ _ : Fin B × Fin d, Fin m) × (Σ _ : Fin B × Fin d, Fin m))) : ‖unconditionalMixedConjugateSigmaLocalAction B U V z‖ = ‖z‖ := by simpa [unconditionalMixedConjugateSigmaLocalAction] using dSVUniformDensityMixedProtocolLocalAction_norm (unconditionalMixedConjugateSigmaAtomLift (m := m) B U) (unconditionalMixedConjugateSigmaAtomLift (m := m) B V) z theorem unconditionalSelectedCopyIdealStage_norm_sq {d N B m : ℕ} {w : ℝ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : 0 < w) (ξ ζ : BipartiteUnitVector d) : ‖unconditionalSelectedCopyIdealStage (N := N) (B := B) (m := m) w ξ ζ‖ ^ 2 = dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w ξ := by have covariance := unconditionalMixedConjugateTargetCovariance (B := B) (n := m) width grid dimension ξ ζ have squared := congrArg (fun z => ‖z‖ ^ 2) covariance rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg (Real.sqrt_nonneg _), mul_pow, Real.sq_sqrt (by positivity : (0 : ℝ) ≤ w * (d : ℝ)), unconditionalSelectedCopy_mixedConjugateLocalAction_norm, unconditionalSelectedCopy_conjugateAcceptedTarget_norm_sq phases grid harmonic, dSVDensityRationalCanonicalAcceptedTarget_norm_sq width] at squared have dimension_real : 0 < (d : ℝ) := by exact_mod_cast dimension have cancelled : (d : ℝ) * ‖unconditionalSelectedCopyIdealStage (N := N) (B := B) (m := m) w ξ ζ‖ ^ 2 = dSVDensityRationalLeftProjectiveDiagonalMass w N ξ := by apply mul_left_cancel₀ (ne_of_gt width) simpa [unconditionalSelectedCopyIdealStage, mul_assoc] using squared rw [dSVDensityRationalPhysicalDiagonalBornSuccess_eq] apply (eq_div_iff (ne_of_gt dimension_real)).2 simpa [mul_comm] using cancelled theorem unconditionalSelectedCopyCleanedStage_norm_sq {d N B m : ℕ} {w : ℝ} (phases : 0 < B) (grid : 0 < N) (harmonic : 0 < m) (width : 0 < w) (ξ ζ : BipartiteUnitVector d) (Q : ℕ) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : ‖unconditionalSelectedCopyCleanedStage (N := N) (B := B) (m := m) Q w ξ ζ A C‖ ^ 2 = ‖dSVDensityRationalCompleteProjectiveOutcome w N ξ ζ true true‖ ^ 2 := by unfold unconditionalSelectedCopyCleanedStage dSVDensityRationalPublicBucketPhysicalCoherentLocalReset rw [dSVUniformDensityPhysicalAsyncSigmaContinuation_norm] unfold dSVDensityRationalPublicBucketPhysicalCoherentMixedState rw [unconditionalSelectedCopy_coherentPhaseSigma_norm_sq phases] exact dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState_norm_sq width grid harmonic ξ ζ theorem unconditionalSelectedCopyCleanedMatchedBranch_norm_sq {S N d L B m : ℕ} {τ : Type*} [Fintype τ] (phases : 0 < B) (grid : 0 < N) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (Q : ℕ) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) (rest : EuclideanSpace ℂ τ) (rest_unit : ‖rest‖ = 1) : ‖unconditionalSelectedCopyCleanedMatchedBranch Q width schedule ξ ζ A C j rest‖ ^ 2 = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val * dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ j.val := by unfold unconditionalSelectedCopyCleanedMatchedBranch rw [unconditionalMatchedVerifierTensor_norm_sq, unconditionalSelectedCopyCleanedStage_norm_sq phases grid harmonic (width_positive (schedule j)), unconditionalSelectedCopyRetainedWork_norm_sq, rest_unit] simp [dSVDensityRationalHeterogeneousPhysicalStageSuccess, dSVDensityRationalHeterogeneousPhysicalStageOutcome, j.isLt, mul_comm] theorem unconditionalSelectedCopyIdealMatchedBranch_norm_sq {S N d L B m : ℕ} {τ : Type*} [Fintype τ] (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (rest : EuclideanSpace ℂ τ) (rest_unit : ‖rest‖ = 1) : ‖unconditionalSelectedCopyIdealMatchedBranch (N := N) (B := B) (m := m) width schedule ξ ζ j rest‖ ^ 2 = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule j)) ξ := by unfold unconditionalSelectedCopyIdealMatchedBranch rw [unconditionalMatchedVerifierTensor_norm_sq, unconditionalSelectedCopyIdealStage_norm_sq phases grid dimension harmonic (width_positive (schedule j)), unconditionalSelectedCopyRetainedWork_norm_sq, rest_unit] ring end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def unconditionalMixedConjugateSelectedBranchUnitary {ι τ : Type*} [Fintype ι] [DecidableEq ι] [Fintype τ] [DecidableEq τ] (U V : Matrix.unitaryGroup ι ℂ) : Matrix.unitaryGroup ((ι × ι) × τ) ℂ := by classical refine ⟨(((U : Matrix ι ι ℂ) ⊗ₖ (V : Matrix ι ι ℂ)) ⊗ₖ (1 : Matrix τ τ ℂ)), ?_⟩ exact Matrix.kronecker_mem_unitary (Matrix.kronecker_mem_unitary U.property V.property) (Matrix.unitaryGroup τ ℂ).one_mem def unconditionalMixedConjugateSelectedBranchLocalAction {ι τ : Type*} [Fintype ι] [DecidableEq ι] [Fintype τ] [DecidableEq τ] (U V : Matrix.unitaryGroup ι ℂ) (z : EuclideanSpace ℂ ((ι × ι) × τ)) : EuclideanSpace ℂ ((ι × ι) × τ) := toLp 2 ((unconditionalMixedConjugateSelectedBranchUnitary (τ := τ) U V : Matrix ((ι × ι) × τ) ((ι × ι) × τ) ℂ).mulVec (ofLp z)) theorem unconditionalMixedConjugateSelectedBranch_tensorAction {ι τ : Type*} [Fintype ι] [DecidableEq ι] [Fintype τ] [DecidableEq τ] (U V : Matrix.unitaryGroup ι ℂ) (stage : EuclideanSpace ℂ (ι × ι)) (work : EuclideanSpace ℂ τ) : unconditionalMixedConjugateSelectedBranchLocalAction U V (unconditionalMatchedVerifierTensor stage work) = unconditionalMatchedVerifierTensor (toLp 2 ((((U : Matrix ι ι ℂ) ⊗ₖ (V : Matrix ι ι ℂ)).mulVec (ofLp stage)))) work := by classical ext ⟨⟨a, b⟩, t⟩ simp [unconditionalMixedConjugateSelectedBranchLocalAction, unconditionalMixedConjugateSelectedBranchUnitary, unconditionalMatchedVerifierTensor, Matrix.mulVec, dotProduct, Matrix.kroneckerMap_apply, Matrix.one_apply, Fintype.sum_prod_type, Finset.sum_mul, mul_assoc] theorem unconditionalMixedConjugateSelectedBranch_tensor_smul {s τ : Type*} [Fintype s] [Fintype τ] (c : ℝ) (stage : EuclideanSpace ℂ s) (work : EuclideanSpace ℂ τ) : c • unconditionalMatchedVerifierTensor stage work = unconditionalMatchedVerifierTensor (c • stage) work := by ext ⟨a, b⟩ change (c : ℂ) * (stage a * work b) = ((c : ℂ) * stage a) * work b ring theorem unconditionalMixedConjugateSelectedBranchCovariance {S N d L B m : ℕ} {τ : Type*} [Fintype τ] [DecidableEq τ] (grid : 0 < N) (dimension : 0 < d) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (positive : 0 < width (schedule j)) (rest : EuclideanSpace ℂ τ) : Real.sqrt (width (schedule j) * (d : ℝ)) • unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) B (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis ξ))) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) B (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis ζ))) (unconditionalSelectedCopyIdealMatchedBranch (N := N) (B := B) (m := m) width schedule ξ ζ j rest) = unconditionalMatchedVerifierTensor (unconditionalMixedConjugateAcceptedPhaseHarmonicTarget (N := N) (B := B) (width (schedule j)) m ξ) (unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j rest) := by classical unfold unconditionalSelectedCopyIdealMatchedBranch unconditionalSelectedCopyIdealStage rw [unconditionalMixedConjugateSelectedBranch_tensorAction, unconditionalMixedConjugateSelectedBranch_tensor_smul] congr 1 exact unconditionalMixedConjugateTargetCovariance positive grid dimension ξ ζ theorem unconditionalPhysicalAcceptedCoherentStage_eq_phaseSigma {d N B m : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) (φ ψ : Fin B) (i j : Fin d) (a b : Fin (N * m)) : dSVDensityRationalPublicBucketPhysicalCoherentMixedState (N := N) (B := B) w m ξ ζ (⟨(φ, i), a⟩, ⟨(ψ, j), b⟩) = ePRState B (φ, ψ) * dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState w m ξ ζ (⟨i, a⟩, ⟨j, b⟩) := by simp [dSVDensityRationalPublicBucketPhysicalCoherentMixedState, dSVDensityRationalPublicBucketCoherentPhaseSigmaState, dSVDensityRationalPublicBucketCoherentPhaseHistory, dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState, dSVUniformDensityCorrectedMatchedSigmaWeightedResidual, mul_assoc] theorem unconditionalPhysicalAcceptedCoherentStage_apply {d N B m : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ ζ : BipartiteUnitVector d) (φ ψ : Fin B) (i j : Fin d) (k l : Fin N) (a b : Fin m) : dSVDensityRationalPublicBucketPhysicalCoherentMixedState (N := N) (B := B) w m ξ ζ (⟨(φ, i), finProdFinEquiv (k, a)⟩, ⟨(ψ, j), finProdFinEquiv (l, b)⟩) = ePRState B (φ, ψ) * dSVDensityRationalCanonicalPrefixSpectralOutcome w N ξ ζ (⟨k, i⟩, ⟨l, j⟩) * embezzlementState m (a, b) := by rw [unconditionalPhysicalAcceptedCoherentStage_eq_phaseSigma, dSVDensityRationalMixedCanonicalPrefixPhysicalAcceptedSigmaState_apply width grid] ring end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable section DependentStoppingBlocks variable {X Y A B R : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable [Fintype R] [DecidableEq R] variable {ι κ : R → Type} variable [∀ r, Fintype (ι r)] [∀ r, DecidableEq (ι r)] variable [∀ r, Fintype (κ r)] [∀ r, DecidableEq (κ r)] def actualStoppingBranchVector (z : EuclideanSpace ℂ ((Σ r, ι r) × (Σ s, κ s))) (r s : R) : EuclideanSpace ℂ (ι r × κ s) := toLp 2 fun q => z (⟨r, q.1⟩, ⟨s, q.2⟩) def actualStoppingBranchWinningEffect (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (s : R) → Y → POVM B (κ s)) (r s : R) (x : X) (y : Y) : Matrix (ι r × κ s) (ι r × κ s) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then (PA r x).effect a ⊗ₖ (PB s y).effect b else 0 omit [Fintype R] [DecidableEq R] in theorem actualStoppingBranchWinningEffect_posSemidef (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (s : R) → Y → POVM B (κ s)) (r s : R) (x : X) (y : Y) : (actualStoppingBranchWinningEffect G PA PB r s x y).PosSemidef := by classical apply Matrix.nonneg_iff_posSemidef.mp unfold actualStoppingBranchWinningEffect apply Finset.sum_nonneg intro a _ apply Finset.sum_nonneg intro b _ split · exact ((PA r x).positive a).kronecker ((PB s y).positive b) |>.nonneg · exact le_rfl omit [Fintype R] [DecidableEq R] in theorem actualStoppingBranchBorn_nonneg (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (s : R) → Y → POVM B (κ s)) (z : EuclideanSpace ℂ ((Σ r, ι r) × (Σ s, κ s))) (r s : R) (x : X) (y : Y) : 0 ≤ quadraticExpectation (Matrix.toEuclideanCLM (n := ι r × κ s) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G PA PB r s x y)) (actualStoppingBranchVector z r s) := by apply positive_quadraticExpectation_nonneg apply matrixEffectCLM_isPositive exact actualStoppingBranchWinningEffect_posSemidef G PA PB r s x y def actualStoppingGlobalWinningEffect (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (s : R) → Y → POVM B (κ s)) (x : X) (y : Y) : Matrix ((Σ r, ι r) × (Σ s, κ s)) ((Σ r, ι r) × (Σ s, κ s)) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then (dependentBlockPOVM (fun r => PA r x)).effect a ⊗ₖ (dependentBlockPOVM (fun s => PB s y)).effect b else 0 theorem actualStoppingGlobalWinningEffect_same (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (s : R) → Y → POVM B (κ s)) (r s : R) (x : X) (y : Y) (i i' : ι r) (j j' : κ s) : actualStoppingGlobalWinningEffect G PA PB x y (⟨r, i⟩, ⟨s, j⟩) (⟨r, i'⟩, ⟨s, j'⟩) = actualStoppingBranchWinningEffect G PA PB r s x y (i, j) (i', j') := by classical unfold actualStoppingGlobalWinningEffect actualStoppingBranchWinningEffect simp only [Matrix.sum_apply] apply Finset.sum_congr rfl intro a _ apply Finset.sum_congr rfl intro b _ split_ifs · simp [dependentBlockPOVM_effect_same] · rfl theorem actualStoppingGlobalWinningEffect_cross_eq_zero (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (s : R) → Y → POVM B (κ s)) (r s r' s' : R) (x : X) (y : Y) (i : ι r) (j : κ s) (i' : ι r') (j' : κ s') (different : r ≠ r' ∨ s ≠ s') : actualStoppingGlobalWinningEffect G PA PB x y (⟨r, i⟩, ⟨s, j⟩) (⟨r', i'⟩, ⟨s', j'⟩) = 0 := by classical rcases different with left | right · unfold actualStoppingGlobalWinningEffect simp only [Matrix.sum_apply] apply Finset.sum_eq_zero intro a _ apply Finset.sum_eq_zero intro b _ split_ifs · simp [dependentBlockPOVM, Matrix.blockDiagonal'_apply, left] · rfl · unfold actualStoppingGlobalWinningEffect simp only [Matrix.sum_apply] apply Finset.sum_eq_zero intro a _ apply Finset.sum_eq_zero intro b _ split_ifs · simp [dependentBlockPOVM, Matrix.blockDiagonal'_apply, right] · rfl theorem actualStoppingGlobalBorn_eq_sum (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (s : R) → Y → POVM B (κ s)) (z : EuclideanSpace ℂ ((Σ r, ι r) × (Σ s, κ s))) (x : X) (y : Y) : quadraticExpectation (Matrix.toEuclideanCLM (n := (Σ r, ι r) × (Σ s, κ s)) (𝕜 := ℂ) (actualStoppingGlobalWinningEffect G PA PB x y)) z = ∑ r : R, ∑ s : R, quadraticExpectation (Matrix.toEuclideanCLM (n := ι r × κ s) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G PA PB r s x y)) (actualStoppingBranchVector z r s) := by classical have collapse (r s : R) (i : ι r) (j : κ s) : (∑ r' : R, ∑ i' : ι r', ∑ s' : R, ∑ j' : κ s', actualStoppingGlobalWinningEffect G PA PB x y (⟨r, i⟩, ⟨s, j⟩) (⟨r', i'⟩, ⟨s', j'⟩) * z (⟨r', i'⟩, ⟨s', j'⟩)) = ∑ i' : ι r, ∑ j' : κ s, actualStoppingBranchWinningEffect G PA PB r s x y (i, j) (i', j') * z (⟨r, i'⟩, ⟨s, j'⟩) := by rw [Finset.sum_eq_single r] · apply Finset.sum_congr rfl intro i' _ rw [Finset.sum_eq_single s] · apply Finset.sum_congr rfl intro j' _ rw [actualStoppingGlobalWinningEffect_same] · intro s' _ unequal apply Finset.sum_eq_zero intro j' _ rw [actualStoppingGlobalWinningEffect_cross_eq_zero G PA PB r s r s' x y i j i' j' (Or.inr (Ne.symm unequal))] simp · simp · intro r' _ unequal apply Finset.sum_eq_zero intro i' _ apply Finset.sum_eq_zero intro s' _ apply Finset.sum_eq_zero intro j' _ rw [actualStoppingGlobalWinningEffect_cross_eq_zero G PA PB r s r' s' x y i j i' j' (Or.inl (Ne.symm unequal))] simp · simp rw [matrixQuadraticExpectation_expand] simp_rw [matrixQuadraticExpectation_expand] simp only [Fintype.sum_prod_type, Fintype.sum_sigma, Complex.re_sum] apply Finset.sum_congr rfl intro r _ rw [Finset.sum_comm] apply Finset.sum_congr rfl intro s _ apply Finset.sum_congr rfl intro i _ apply Finset.sum_congr rfl intro j _ congr 1 rw [collapse] rfl end DependentStoppingBlocks end noncomputable section open Matrix open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2200000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable theorem unitaryConjugatePOVM_jointEffect {A B d : Type} [Fintype A] [Fintype B] [Fintype d] [DecidableEq d] (U V : Matrix.unitaryGroup d ℂ) (P : POVM A d) (Q : POVM B d) (a : A) (b : B) : (unitaryConjugatePOVM U P).effect a ⊗ₖ (unitaryConjugatePOVM V Q).effect b = (((U : Matrix d d ℂ) ⊗ₖ (V : Matrix d d ℂ))ᴴ * (P.effect a ⊗ₖ Q.effect b) * ((U : Matrix d d ℂ) ⊗ₖ (V : Matrix d d ℂ))) := by change (((U : Matrix d d ℂ)ᴴ * P.effect a * (U : Matrix d d ℂ)) ⊗ₖ ((V : Matrix d d ℂ)ᴴ * Q.effect b * (V : Matrix d d ℂ))) = (((U : Matrix d d ℂ) ⊗ₖ (V : Matrix d d ℂ))ᴴ * (P.effect a ⊗ₖ Q.effect b) * ((U : Matrix d d ℂ) ⊗ₖ (V : Matrix d d ℂ))) rw [Matrix.conjTranspose_kronecker, ← Matrix.mul_kronecker_mul, ← Matrix.mul_kronecker_mul] end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable section QuestionLocalStopping variable {X Y A B R : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable [Fintype R] [DecidableEq R] variable {ι : R → Type} variable [∀ r, Fintype (ι r)] [∀ r, DecidableEq (ι r)] def actualStoppingQuestionLocalAction (U V : Matrix.unitaryGroup (Σ r, ι r) ℂ) (z : EuclideanSpace ℂ ((Σ r, ι r) × (Σ r, ι r))) : EuclideanSpace ℂ ((Σ r, ι r) × (Σ r, ι r)) := toLp 2 (((U : Matrix (Σ r, ι r) (Σ r, ι r) ℂ) ⊗ₖ (V : Matrix (Σ r, ι r) (Σ r, ι r) ℂ)).mulVec (ofLp z)) theorem actualStoppingQuestionLocalWinningEffect_quadratic (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (r : R) → Y → POVM B (ι r)) (U : X → Matrix.unitaryGroup (Σ r, ι r) ℂ) (V : Y → Matrix.unitaryGroup (Σ r, ι r) ℂ) (z : EuclideanSpace ℂ ((Σ r, ι r) × (Σ r, ι r))) (normalized : ‖z‖ = 1) (x : X) (y : Y) : quadraticExpectation (Matrix.toEuclideanCLM (n := (Σ r, ι r) × (Σ r, ι r)) (𝕜 := ℂ) (pureVerifierEffect G z normalized (fun x => unitaryConjugatePOVM (U x) (dependentBlockPOVM (fun r => PA r x))) (fun y => unitaryConjugatePOVM (V y) (dependentBlockPOVM (fun r => PB r y))) x y)) z = quadraticExpectation (Matrix.toEuclideanCLM (n := (Σ r, ι r) × (Σ r, ι r)) (𝕜 := ℂ) (actualStoppingGlobalWinningEffect G PA PB x y)) (actualStoppingQuestionLocalAction (U x) (V y) z) := by classical change quadraticExpectation (Matrix.toEuclideanCLM (n := (Σ r, ι r) × (Σ r, ι r)) (𝕜 := ℂ) (∑ a : A, ∑ b : B, if G.predicate x y a b = true then (unitaryConjugatePOVM (U x) (dependentBlockPOVM (fun r => PA r x))).effect a ⊗ₖ (unitaryConjugatePOVM (V y) (dependentBlockPOVM (fun r => PB r y))).effect b else 0)) z = quadraticExpectation (Matrix.toEuclideanCLM (n := (Σ r, ι r) × (Σ r, ι r)) (𝕜 := ℂ) (∑ a : A, ∑ b : B, if G.predicate x y a b = true then (dependentBlockPOVM (fun r => PA r x)).effect a ⊗ₖ (dependentBlockPOVM (fun r => PB r y)).effect b else 0)) (actualStoppingQuestionLocalAction (U x) (V y) z) rw [sourceHistoryQuadraticExpectation_matrix_sum, sourceHistoryQuadraticExpectation_matrix_sum] apply Finset.sum_congr rfl intro a _ rw [sourceHistoryQuadraticExpectation_matrix_sum, sourceHistoryQuadraticExpectation_matrix_sum] apply Finset.sum_congr rfl intro b _ split_ifs with accepted · rw [unitaryConjugatePOVM_jointEffect] exact (rectangular_matrix_quadratic_compression (((U x : Matrix (Σ r, ι r) (Σ r, ι r) ℂ) ⊗ₖ (V y : Matrix (Σ r, ι r) (Σ r, ι r) ℂ))) (((dependentBlockPOVM (fun r => PA r x)).effect a) ⊗ₖ ((dependentBlockPOVM (fun r => PB r y)).effect b)) z).symm · simp [quadraticExpectation] theorem actualStoppingQuestionLocalWinningProbability_eq_sum (G : Game X Y A B) (PA : (r : R) → X → POVM A (ι r)) (PB : (r : R) → Y → POVM B (ι r)) (U : X → Matrix.unitaryGroup (Σ r, ι r) ℂ) (V : Y → Matrix.unitaryGroup (Σ r, ι r) ℂ) (z : EuclideanSpace ℂ ((Σ r, ι r) × (Σ r, ι r))) (normalized : ‖z‖ = 1) : (pureVectorStrategy G z normalized (fun x => unitaryConjugatePOVM (U x) (dependentBlockPOVM (fun r => PA r x))) (fun y => unitaryConjugatePOVM (V y) (dependentBlockPOVM (fun r => PB r y)))).winProbability = ∑ x : X, ∑ y : Y, G.questionWeight x y * ∑ r : R, ∑ s : R, quadraticExpectation (Matrix.toEuclideanCLM (n := ι r × ι s) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G PA PB r s x y)) (actualStoppingBranchVector (actualStoppingQuestionLocalAction (U x) (V y) z) r s) := by classical rw [pureVectorWinningProbability_eq] apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ congr 1 rw [actualStoppingQuestionLocalWinningEffect_quadratic] exact actualStoppingGlobalBorn_eq_sum G PA PB (actualStoppingQuestionLocalAction (U x) (V y) z) x y theorem actualStoppingQuestionLocalWinningProbability_ge_matched {L : ℕ} {ι : Fin (L + 1) → Type} [∀ r, Fintype (ι r)] [∀ r, DecidableEq (ι r)] (G : Game X Y A B) (PA : (r : Fin (L + 1)) → X → POVM A (ι r)) (PB : (r : Fin (L + 1)) → Y → POVM B (ι r)) (U : X → Matrix.unitaryGroup (Σ r, ι r) ℂ) (V : Y → Matrix.unitaryGroup (Σ r, ι r) ℂ) (z : EuclideanSpace ℂ ((Σ r : Fin (L + 1), ι r) × (Σ r : Fin (L + 1), ι r))) (normalized : ‖z‖ = 1) : (∑ x : X, ∑ y : Y, G.questionWeight x y * ∑ j : Fin L, quadraticExpectation (Matrix.toEuclideanCLM (n := ι j.succ × ι j.succ) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G PA PB j.succ j.succ x y)) (actualStoppingBranchVector (actualStoppingQuestionLocalAction (U x) (V y) z) j.succ j.succ)) ≤ (pureVectorStrategy G z normalized (fun x => unitaryConjugatePOVM (U x) (dependentBlockPOVM (fun r => PA r x))) (fun y => unitaryConjugatePOVM (V y) (dependentBlockPOVM (fun r => PB r y)))).winProbability := by classical rw [actualStoppingQuestionLocalWinningProbability_eq_sum] apply Finset.sum_le_sum intro x _ apply Finset.sum_le_sum intro y _ apply mul_le_mul_of_nonneg_left _ (G.weight_nonneg x y) let stopped := actualStoppingQuestionLocalAction (U x) (V y) z calc (∑ j : Fin L, quadraticExpectation (Matrix.toEuclideanCLM (n := ι j.succ × ι j.succ) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G PA PB j.succ j.succ x y)) (actualStoppingBranchVector stopped j.succ j.succ)) ≤ ∑ r : Fin (L + 1), quadraticExpectation (Matrix.toEuclideanCLM (n := ι r × ι r) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G PA PB r r x y)) (actualStoppingBranchVector stopped r r) := by rw [Fin.sum_univ_succ] have nonnegative := actualStoppingBranchBorn_nonneg G PA PB stopped (0 : Fin (L + 1)) 0 x y linarith _ ≤ ∑ r : Fin (L + 1), ∑ s : Fin (L + 1), quadraticExpectation (Matrix.toEuclideanCLM (n := ι r × ι s) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G PA PB r s x y)) (actualStoppingBranchVector stopped r s) := by apply Finset.sum_le_sum intro r _ exact Finset.single_le_sum (fun s _ => actualStoppingBranchBorn_nonneg G PA PB stopped r s x y) (Finset.mem_univ r) theorem actualStoppingQuestionLocalFlaggedWinningProbability_ge_matched {L : ℕ} {J : Type} [Fintype J] [DecidableEq J] {ι : Fin (L + 1) → Type} [∀ r, Fintype (ι r)] [∀ r, DecidableEq (ι r)] (G : Game X Y A B) (weight : J → ℝ) (weight_nonnegative : ∀ j, 0 ≤ weight j) (weight_normalized : (∑ j : J, weight j) = 1) (PA : J → (r : Fin (L + 1)) → X → POVM A (ι r)) (PB : J → (r : Fin (L + 1)) → Y → POVM B (ι r)) (U : J → X → Matrix.unitaryGroup (Σ r : Fin (L + 1), ι r) ℂ) (V : J → Y → Matrix.unitaryGroup (Σ r : Fin (L + 1), ι r) ℂ) (z : J → EuclideanSpace ℂ ((Σ r : Fin (L + 1), ι r) × (Σ r : Fin (L + 1), ι r))) (normalized : ∀ j, ‖z j‖ = 1) : (∑ q : J, weight q * (∑ x : X, ∑ y : Y, G.questionWeight x y * ∑ j : Fin L, quadraticExpectation (Matrix.toEuclideanCLM (n := ι j.succ × ι j.succ) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G (PA q) (PB q) j.succ j.succ x y)) (actualStoppingBranchVector (actualStoppingQuestionLocalAction (U q x) (V q y) (z q)) j.succ j.succ))) ≤ (pureFlaggedStrategy G weight weight_nonnegative weight_normalized z normalized (fun q x => unitaryConjugatePOVM (U q x) (dependentBlockPOVM (fun r => PA q r x))) (fun q y => unitaryConjugatePOVM (V q y) (dependentBlockPOVM (fun r => PB q r y)))).winProbability := by classical rw [pureFlaggedStrategy_winProbability] apply Finset.sum_le_sum intro q _ apply mul_le_mul_of_nonneg_left _ (weight_nonnegative q) exact actualStoppingQuestionLocalWinningProbability_ge_matched G (PA q) (PB q) (U q) (V q) (z q) (normalized q) end QuestionLocalStopping end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder abbrev DSVDensityRationalPublicLogPhaseHistoryFamily (B N d L : ℕ) := BipartiteUnitVector d → Matrix.unitaryGroup (DSVDensityRationalPublicLogPhaseHistoryLocalIndex B N d L) ℂ def dSVDensityRationalPublicLogPhaseStoppedState (B N d L m : ℕ) (S T : DSVDensityRationalPublicLogPhaseHistoryFamily B N d L) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicLogPhaseResidual B N d L m) × Fin (d * dSVDensityRationalPublicLogPhaseResidual B N d L m)) := localUnitaryAction (dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift B N d L m (S ξ)) (dSVDensityRationalPublicLogPhaseActualTargetFirstLocalLift B N d L m (T ζ)) (dSVDensityRationalPublicLogPhaseTargetFirstPreparedSource B N d L m) def dSVDensityRationalPublicMultiscaleOriginalSigmaTargetFirstEquiv (S B N d L m : ℕ) : (Σ _ : DSVDensityRationalPublicMultiscalePhaseIndex S B × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, Fin m) ≃ Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) := (dSVDensityRationalPublicBucketCoherentPhaseSigmaProductEquiv (H := DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) m).trans (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m) def dSVDensityRationalHeterogeneousOriginalAliceHistoryFamily (S B N d L : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) : DSVDensityRationalPublicLogPhaseHistoryFamily (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) N d L := fun ξ => dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (dSVDensityRationalHeterogeneousActualAliceUnitary N width schedule ξ) def dSVDensityRationalHeterogeneousOriginalBobHistoryFamily (S B N d L : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) : DSVDensityRationalPublicLogPhaseHistoryFamily (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) N d L := fun ζ => dSVDensityRationalPublicLogPhasePhysicalHistoryUnitary (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (dSVDensityRationalHeterogeneousActualBobUnitary N width schedule ζ) def dSVDensityRationalHeterogeneousOriginalStoppedState (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) × Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) := dSVDensityRationalPublicLogPhaseStoppedState (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) N d L m (dSVDensityRationalHeterogeneousOriginalAliceHistoryFamily S B N d L width schedule) (dSVDensityRationalHeterogeneousOriginalBobHistoryFamily S B N d L width schedule) ξ ζ def dSVDensityRationalHeterogeneousOriginalSameStopStateEquiv (S B N d L m : ℕ) : EuclideanSpace ℂ ((Σ _ : DSVDensityRationalPublicMultiscalePhaseIndex S B × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, Fin m) × (Σ _ : DSVDensityRationalPublicMultiscalePhaseIndex S B × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L, Fin m)) ≃ₗᵢ[ℂ] EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) × Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) := LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (dSVDensityRationalPublicMultiscaleOriginalSigmaTargetFirstEquiv S B N d L m) (dSVDensityRationalPublicMultiscaleOriginalSigmaTargetFirstEquiv S B N d L m)) def dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) × Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) := dSVDensityRationalHeterogeneousOriginalSameStopStateEquiv S B N d L m (dSVDensityRationalHeterogeneousPureStoppedSigmaState width schedule ξ ζ (fun _ _ _ => embezzlementState m)) theorem dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource_apply (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (φ ψ : DSVDensityRationalPublicMultiscalePhaseIndex S B) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (i j : Fin m) : dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource S B N d L m width schedule ξ ζ (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m ((φ, a), i), dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m ((ψ, b), j)) = ePRState (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (φ, ψ) * dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (a, b) * embezzlementState m (i, j) := by simp [dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource, dSVDensityRationalHeterogeneousOriginalSameStopStateEquiv, dSVDensityRationalPublicMultiscaleOriginalSigmaTargetFirstEquiv, dSVDensityRationalPublicBucketCoherentPhaseSigmaProductEquiv, LinearIsometryEquiv.piLpCongrLeft_apply, Equiv.piCongrLeft', dSVDensityRationalHeterogeneousPureStoppedSigmaState, dSVDensityRationalPublicMultiscaleBucketCoherentSigmaState, dSVDensityRationalPublicBucketCoherentPhaseSigmaState, dSVUniformDensityCorrectedMatchedSigmaWeightedResidual, dSVDensityRationalPublicBucketCoherentPhaseHistory] theorem dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource_eq_stopped (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource S B N d L m width schedule ξ ζ = dSVDensityRationalHeterogeneousOriginalStoppedState S B N d L m width schedule ξ ζ := by classical ext ⟨x, y⟩ obtain ⟨⟨⟨φ, a⟩, i⟩, rfl⟩ := (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m).surjective x obtain ⟨⟨⟨ψ, b⟩, j⟩, rfl⟩ := (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m).surjective y obtain ⟨φ', rfl⟩ := (Fintype.equivFin (DSVDensityRationalPublicMultiscalePhase S B)).surjective φ obtain ⟨ψ', rfl⟩ := (Fintype.equivFin (DSVDensityRationalPublicMultiscalePhase S B)).surjective ψ rw [dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource_apply] change _ = dSVDensityRationalHeterogeneousTargetFirstSpectralPhysicalSource S B N d L m width schedule ξ ζ (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m (((Fintype.equivFin (DSVDensityRationalPublicMultiscalePhase S B)) φ', a), i), dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m (((Fintype.equivFin (DSVDensityRationalPublicMultiscalePhase S B)) ψ', b), j)) rw [dSVDensityRationalHeterogeneousTargetFirstSpectralPhysicalSource_apply] simp [ePRState] theorem dSVDensityRationalHeterogeneousOriginalStoppedState_apply (S B N d L m : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (φ ψ : DSVDensityRationalPublicMultiscalePhaseIndex S B) (a b : DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) (i j : Fin m) : dSVDensityRationalHeterogeneousOriginalStoppedState S B N d L m width schedule ξ ζ (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m ((φ, a), i), dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m ((ψ, b), j)) = ePRState (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (φ, ψ) * dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (a, b) * embezzlementState m (i, j) := by rw [← dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource_eq_stopped] exact dSVDensityRationalHeterogeneousOriginalSameStopSigmaSource_apply S B N d L m width schedule ξ ζ φ ψ a b i j end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder def directDSVRemainingCopyEquiv {L : ℕ} {β : Type*} (j : Fin L) : ((Fin j.val → β) × (Fin (L - j.val) → β)) ≃ (Fin L → β) where toFun z i := if before : i.val < j.val then z.1 ⟨i.val, before⟩ else z.2 ⟨i.val - j.val, by omega⟩ invFun z := (fun i => z ⟨i.val, by omega⟩, fun i => z ⟨j.val + i.val, by omega⟩) left_inv z := by rcases z with ⟨before, after⟩ apply Prod.ext · funext i simp · funext i simp right_inv z := by funext i dsimp split_ifs with before · rfl · apply congrArg z apply Fin.ext change j.val + (i.val - j.val) = i.val omega def directDSVSelectedCopyLocalHistoryEquiv {L : ℕ} {β : Type*} (j : Fin L) : (β × ((Fin j.val → β) × (Fin (L - j.val) → β))) ≃ (Fin (L + 1) → β) := (Equiv.prodCongr (Equiv.refl β) (directDSVRemainingCopyEquiv (β := β) j)).trans (Fin.insertNthEquiv (fun _ : Fin (L + 1) => β) j.castSucc) @[simp] theorem directDSVSelectedCopyLocalHistoryEquiv_hit {L : ℕ} {β : Type*} (j : Fin L) (selected : β) (before : Fin j.val → β) (after : Fin (L - j.val) → β) : directDSVSelectedCopyLocalHistoryEquiv j (selected, (before, after)) j.castSucc = selected := by simp [directDSVSelectedCopyLocalHistoryEquiv] @[simp] theorem directDSVSelectedCopyLocalHistoryEquiv_before {L : ℕ} {β : Type*} (j : Fin L) (selected : β) (before : Fin j.val → β) (after : Fin (L - j.val) → β) (i : Fin j.val) : directDSVSelectedCopyLocalHistoryEquiv j (selected, (before, after)) ⟨i.val, by omega⟩ = before i := by let k : Fin L := ⟨i.val, by omega⟩ have earlier : k < j := by change i.val < j.val exact i.isLt have selected_index : j.castSucc.succAbove k = (⟨i.val, by omega⟩ : Fin (L + 1)) := by rw [Fin.succAbove_castSucc_of_lt j k earlier] rfl unfold directDSVSelectedCopyLocalHistoryEquiv simp only [Equiv.trans_apply, Equiv.prodCongr_apply, Fin.insertNthEquiv_apply] rw [← selected_index, Fin.insertNth_apply_succAbove] change (if h : k.val < j.val then before ⟨k.val, h⟩ else after ⟨k.val - j.val, by omega⟩) = before i simp only [k, i.isLt, ↓reduceDIte] @[simp] theorem directDSVSelectedCopyLocalHistoryEquiv_after {L : ℕ} {β : Type*} (j : Fin L) (selected : β) (before : Fin j.val → β) (after : Fin (L - j.val) → β) (i : Fin (L - j.val)) : directDSVSelectedCopyLocalHistoryEquiv j (selected, (before, after)) ⟨j.val + 1 + i.val, by omega⟩ = after i := by let k : Fin L := ⟨j.val + i.val, by omega⟩ have later : j ≤ k := by change j.val ≤ j.val + i.val omega have selected_index : j.castSucc.succAbove k = (⟨j.val + 1 + i.val, by omega⟩ : Fin (L + 1)) := by rw [Fin.succAbove_castSucc_of_le j k later] apply Fin.ext change j.val + i.val + 1 = j.val + 1 + i.val omega unfold directDSVSelectedCopyLocalHistoryEquiv simp only [Equiv.trans_apply, Equiv.prodCongr_apply, Fin.insertNthEquiv_apply] rw [← selected_index, Fin.insertNth_apply_succAbove] change (if h : k.val < j.val then before ⟨k.val, h⟩ else after ⟨k.val - j.val, by omega⟩) = after i have not_before : ¬ j.val + i.val < j.val := by omega simp [k, not_before] theorem directDSVRemainingCopyProductSplit {M : Type*} [CommMonoid M] {L : ℕ} (j : Fin L) (f : Fin L → M) : (∏ i : Fin L, f i) = (∏ i : Fin j.val, f ⟨i.val, by omega⟩) * (∏ i : Fin (L - j.val), f ⟨j.val + i.val, by omega⟩) := by classical have length : j.val + (L - j.val) = L := by omega calc (∏ i : Fin L, f i) = ∏ i : Fin (j.val + (L - j.val)), f (i.cast length) := (Fin.prod_congr' f length).symm _ = (∏ i : Fin j.val, f ⟨i.val, by omega⟩) * (∏ i : Fin (L - j.val), f ⟨j.val + i.val, by omega⟩) := by rw [Fin.prod_univ_add] congr 1 theorem directDSVActualStoppingSelectedHistory_sourceProduct {S N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (selectedA selectedB : DSVUniformDensityThresholdLocalIndex N d) (beforeA beforeB : Fin j.val → DSVUniformDensityThresholdLocalIndex N d) (afterA afterB : Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) : dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (⟨j.succ, directDSVSelectedCopyLocalHistoryEquiv j (selectedA, (beforeA, afterA))⟩, ⟨j.succ, directDSVSelectedCopyLocalHistoryEquiv j (selectedB, (beforeB, afterB))⟩) = dSVDensityRationalCompleteProjectiveOutcome (width (schedule j)) N ξ ζ true true (selectedA, selectedB) * dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector (N := N) width schedule ξ ζ j (fun i => (beforeA i, beforeB i)) * dSVUniformDensityIndependentSharedState (L - j.val) N d (afterA, afterB) := by classical let a := directDSVSelectedCopyLocalHistoryEquiv j (selectedA, (beforeA, afterA)) let b := directDSVSelectedCopyLocalHistoryEquiv j (selectedB, (beforeB, afterB)) rw [dSVDensityRationalHeterogeneousActualCommonStopPhysicalState_eq_outcomeProduct] rw [Fin.prod_univ_succAbove _ j.castSucc] rw [directDSVRemainingCopyProductSplit j] rw [dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector_apply] rw [dSVUniformDensityIndependentSharedState_apply] have hitA : a j.castSucc = selectedA := directDSVSelectedCopyLocalHistoryEquiv_hit j selectedA beforeA afterA have hitB : b j.castSucc = selectedB := directDSVSelectedCopyLocalHistoryEquiv_hit j selectedB beforeB afterB have selected : dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j j.castSucc (a j.castSucc, b j.castSucc) = dSVDensityRationalCompleteProjectiveOutcome (width (schedule j)) N ξ ζ true true (selectedA, selectedB) := by rw [dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome_hit, hitA, hitB] rw [selected] simp only [mul_assoc] apply congrArg (fun t : ℂ => dSVDensityRationalCompleteProjectiveOutcome (width (schedule j)) N ξ ζ true true (selectedA, selectedB) * t) apply congrArg₂ (fun x y : ℂ => x * y) · apply Finset.prod_congr rfl intro i _ let k : Fin L := ⟨i.val, by omega⟩ have earlier : k < j := by change i.val < j.val exact i.isLt have index : j.castSucc.succAbove k = (⟨i.val, by omega⟩ : Fin (L + 1)) := by rw [Fin.succAbove_castSucc_of_lt j k earlier] rfl change dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j (j.castSucc.succAbove k) (a (j.castSucc.succAbove k), b (j.castSucc.succAbove k)) = _ rw [index] change dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j (⟨i.val, by omega⟩ : Fin (L + 1)) (a ⟨i.val, by omega⟩, b ⟨i.val, by omega⟩) = _ change dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j (⟨i.val, by omega⟩ : Fin (L + 1)) (directDSVSelectedCopyLocalHistoryEquiv j (selectedA, (beforeA, afterA)) ⟨i.val, by omega⟩, directDSVSelectedCopyLocalHistoryEquiv j (selectedB, (beforeB, afterB)) ⟨i.val, by omega⟩) = _ rw [directDSVSelectedCopyLocalHistoryEquiv_before, directDSVSelectedCopyLocalHistoryEquiv_before] · apply Finset.prod_congr rfl intro i _ let k : Fin L := ⟨j.val + i.val, by omega⟩ have later : j ≤ k := by change j.val ≤ j.val + i.val omega have index : j.castSucc.succAbove k = (⟨j.val + 1 + i.val, by omega⟩ : Fin (L + 1)) := by rw [Fin.succAbove_castSucc_of_le j k later] apply Fin.ext change j.val + i.val + 1 = j.val + 1 + i.val omega change dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j (j.castSucc.succAbove k) (a (j.castSucc.succAbove k), b (j.castSucc.succAbove k)) = _ rw [index] change dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome width schedule ξ ζ j (⟨j.val + 1 + i.val, by omega⟩ : Fin (L + 1)) (directDSVSelectedCopyLocalHistoryEquiv j (selectedA, (beforeA, afterA)) ⟨j.val + 1 + i.val, by omega⟩, directDSVSelectedCopyLocalHistoryEquiv j (selectedB, (beforeB, afterB)) ⟨j.val + 1 + i.val, by omega⟩) = _ rw [directDSVSelectedCopyLocalHistoryEquiv_after, directDSVSelectedCopyLocalHistoryEquiv_after] have is_after : j.val < (⟨j.val + 1 + i.val, by omega⟩ : Fin (L + 1)).val := by change j.val < j.val + 1 + i.val omega rw [dSVDensityRationalHeterogeneousActualCommonStopScheduledOutcome_after width schedule ξ ζ j (⟨j.val + 1 + i.val, by omega⟩ : Fin (L + 1)) is_after] abbrev UnconditionalSourcePhysicalStoppingPhaseFiber (S B N d L m : ℕ) := Σ _ : DSVDensityRationalPublicMultiscalePhaseIndex S B × DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d, Fin m def unconditionalSourcePhysicalStoppingPhaseHarmonicIndexEquiv (S B N d L m : ℕ) : ((DSVDensityRationalPublicMultiscalePhaseIndex S B × DSVUniformDensityThresholdWholeHistoryLocalIndex N d L) × Fin m) ≃ (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) where toFun q := ⟨q.1.2.1, ⟨(q.1.1, q.1.2.2), q.2⟩⟩ invFun q := ((q.2.1.1, ⟨q.1, q.2.1.2⟩), q.2.2) left_inv := by intro q rcases q with ⟨⟨phase, ⟨flag, history⟩⟩, work⟩ rfl right_inv := by intro q rcases q with ⟨flag, ⟨⟨phase, history⟩, work⟩⟩ rfl def unconditionalSourcePhysicalStoppingTargetFirstIndexEquiv (S B N d L m : ℕ) : Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) ≃ (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) := (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m).symm.trans (unconditionalSourcePhysicalStoppingPhaseHarmonicIndexEquiv S B N d L m) def unconditionalSourcePhysicalStoppingTargetFirstStateEquiv (S B N d L m : ℕ) : EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) × Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) ≃ₗᵢ[ℂ] EuclideanSpace ℂ ((Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) × (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m)) := LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (unconditionalSourcePhysicalStoppingTargetFirstIndexEquiv S B N d L m) (unconditionalSourcePhysicalStoppingTargetFirstIndexEquiv S B N d L m)) theorem unconditionalSourcePhysicalStoppingTargetFirst_branch_apply {S B N d L m : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (r s : Fin (L + 1)) (φ ψ : DSVDensityRationalPublicMultiscalePhaseIndex S B) (a b : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d) (i k : Fin m) : actualStoppingBranchVector (unconditionalSourcePhysicalStoppingTargetFirstStateEquiv S B N d L m (dSVDensityRationalHeterogeneousOriginalStoppedState S B N d L m width schedule ξ ζ)) r s (⟨(φ, a), i⟩, ⟨(ψ, b), k⟩) = ePRState (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (φ, ψ) * dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (⟨r, a⟩, ⟨s, b⟩) * embezzlementState m (i, k) := by change dSVDensityRationalHeterogeneousOriginalStoppedState S B N d L m width schedule ξ ζ (dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m ((φ, ⟨r, a⟩), i), dSVDensityRationalPublicMultiscalePhaseTargetFirstIndexEquiv S B N d L m ((ψ, ⟨s, b⟩), k)) = _ exact dSVDensityRationalHeterogeneousOriginalStoppedState_apply S B N d L m width schedule ξ ζ φ ψ ⟨r, a⟩ ⟨s, b⟩ i k theorem unconditionalSourcePhysicalStoppingBranch_sigmaContinuation {R κ : Type} [Fintype R] [DecidableEq R] [Fintype κ] [DecidableEq κ] (U V : R → Matrix.unitaryGroup κ ℂ) (z : EuclideanSpace ℂ ((Σ _ : R, κ) × (Σ _ : R, κ))) (r s : R) : actualStoppingBranchVector (dSVUniformDensityPhysicalAsyncSigmaContinuation U V z) r s = toLp 2 ((((U r : Matrix κ κ ℂ) ⊗ₖ (V s : Matrix κ κ ℂ)).mulVec (ofLp (actualStoppingBranchVector z r s)))) := by classical ext ⟨i, j⟩ simp [actualStoppingBranchVector, dSVUniformDensityPhysicalAsyncSigmaContinuation, coherentSharedRandomControlledUnitary, Matrix.mulVec, dotProduct, Matrix.kroneckerMap_apply, Matrix.blockDiagonal'_apply, Fintype.sum_prod_type, Fintype.sum_sigma] def unconditionalSourceFixedPureStoppedSigmaReindexedUnitary {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] (e : ι ≃ κ) (U : Matrix.unitaryGroup ι ℂ) : Matrix.unitaryGroup κ ℂ := by classical let M : Matrix ι ι ℂ := U.val refine ⟨Matrix.reindex e e M, ?_⟩ rw [Matrix.mem_unitaryGroup_iff'] have compatible : star (Matrix.reindex e e M) = Matrix.reindex e e (star M) := by ext i j simp [Matrix.star_eq_conjTranspose, Matrix.reindex_apply, Matrix.conjTranspose_apply] rw [compatible] change (Matrix.reindexRingEquiv ℂ e) (star M) * (Matrix.reindexRingEquiv ℂ e) M = 1 rw [← (Matrix.reindexRingEquiv ℂ e).map_mul, (Matrix.mem_unitaryGroup_iff').mp U.property] exact (Matrix.reindexRingEquiv ℂ e).map_one def unconditionalSelectedMultiscalePhaseIndexEquiv {S B : ℕ} (scale : Fin (S + 1)) : (Fin B × Fin (Fintype.card (Fin S → Fin B))) ≃ DSVDensityRationalPublicMultiscalePhaseIndex (S + 1) B := ((Equiv.prodCongr (Equiv.refl (Fin B)) (Fintype.equivFin (Fin S → Fin B)).symm).trans (Fin.insertNthEquiv (fun _ : Fin (S + 1) => Fin B) scale)).trans (Fintype.equivFin (Fin (S + 1) → Fin B)) theorem unconditionalSelectedMultiscalePhase_card (S B : ℕ) : Fintype.card (DSVDensityRationalPublicMultiscalePhase (S + 1) B) = B * Fintype.card (Fin S → Fin B) := by simp [DSVDensityRationalPublicMultiscalePhase, pow_succ, Nat.mul_comm] theorem unconditionalSelectedMultiscalePhase_EPR_apply {S B : ℕ} (scale : Fin (S + 1)) (p q : Fin B) (r t : Fin (Fintype.card (Fin S → Fin B))) : ePRState (Fintype.card (DSVDensityRationalPublicMultiscalePhase (S + 1) B)) (unconditionalSelectedMultiscalePhaseIndexEquiv scale (p, r), unconditionalSelectedMultiscalePhaseIndexEquiv scale (q, t)) = ePRState B (p, q) * ePRState (Fintype.card (Fin S → Fin B)) (r, t) := by classical by_cases selected : p = q · subst q by_cases residual : r = t · subst t simp only [ePRState, ↓reduceIte] rw [unconditionalSelectedMultiscalePhase_card, Nat.cast_mul, Real.sqrt_mul (Nat.cast_nonneg B), mul_inv] exact Complex.ofReal_mul _ _ · have different : unconditionalSelectedMultiscalePhaseIndexEquiv scale (p, r) ≠ unconditionalSelectedMultiscalePhaseIndexEquiv scale (p, t) := by intro equal exact residual (congrArg Prod.snd ((unconditionalSelectedMultiscalePhaseIndexEquiv scale).injective equal)) simp [ePRState, different, residual] · have different : unconditionalSelectedMultiscalePhaseIndexEquiv scale (p, r) ≠ unconditionalSelectedMultiscalePhaseIndexEquiv scale (q, t) := by intro equal exact selected (congrArg Prod.fst ((unconditionalSelectedMultiscalePhaseIndexEquiv scale).injective equal)) simp [ePRState, different, selected] def unconditionalActualMultiscalePhaseIndexEquiv {S B : ℕ} (scale : Fin S) : (Fin B × Fin (Fintype.card (Fin (S - 1) → Fin B))) ≃ DSVDensityRationalPublicMultiscalePhaseIndex S B := by cases S with | zero => exact Fin.elim0 scale | succ S => exact unconditionalSelectedMultiscalePhaseIndexEquiv (S := S) scale theorem unconditionalActualMultiscalePhase_EPR_apply {S B : ℕ} (scale : Fin S) (p q : Fin B) (r t : Fin (Fintype.card (Fin (S - 1) → Fin B))) : ePRState (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (unconditionalActualMultiscalePhaseIndexEquiv scale (p, r), unconditionalActualMultiscalePhaseIndexEquiv scale (q, t)) = ePRState B (p, q) * ePRState (Fintype.card (Fin (S - 1) → Fin B)) (r, t) := by cases S with | zero => exact Fin.elim0 scale | succ S => exact unconditionalSelectedMultiscalePhase_EPR_apply scale p q r t def unconditionalSourcePhysicalCleanedReindexedUnitary {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] (e : ι ≃ κ) (U : Matrix.unitaryGroup ι ℂ) : Matrix.unitaryGroup κ ℂ := by classical let M : Matrix ι ι ℂ := U.val refine ⟨Matrix.reindex e e M, ?_⟩ rw [Matrix.mem_unitaryGroup_iff'] have compatible : star (Matrix.reindex e e M) = Matrix.reindex e e (star M) := by ext i j simp [Matrix.star_eq_conjTranspose, Matrix.reindex_apply, Matrix.conjTranspose_apply] rw [compatible] change (Matrix.reindexRingEquiv ℂ e) (star M) * (Matrix.reindexRingEquiv ℂ e) M = 1 rw [← (Matrix.reindexRingEquiv ℂ e).map_mul, (Matrix.mem_unitaryGroup_iff').mp U.property] exact (Matrix.reindexRingEquiv ℂ e).map_one def unconditionalSourcePhysicalCleanedTargetFirstUnitary (S B N d L m : ℕ) (U : Matrix.unitaryGroup (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) ℂ) : Matrix.unitaryGroup (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ := unconditionalSourcePhysicalCleanedReindexedUnitary (unconditionalSourcePhysicalStoppingTargetFirstIndexEquiv S B N d L m) U def unconditionalSourcePhysicalCleanedStoppingFixedSource (S B N d L m : ℕ) : EuclideanSpace ℂ ((Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) × (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m)) := unconditionalSourcePhysicalStoppingTargetFirstStateEquiv S B N d L m (dSVDensityRationalPublicMultiscalePhaseTargetFirstPreparedSource S B N d L m) theorem unconditionalSourcePhysicalCleanedStoppingFixedSource_norm {S B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) : ‖unconditionalSourcePhysicalCleanedStoppingFixedSource S B N d L m‖ = 1 := by unfold unconditionalSourcePhysicalCleanedStoppingFixedSource rw [LinearIsometryEquiv.norm_map] exact dSVDensityRationalPublicMultiscalePhaseTargetFirstPreparedSource_norm phases grid dimension harmonic theorem unconditionalSourcePhysicalCleanedStoppingLocalAction_reindex {S B N d L m : ℕ} (U V : Matrix.unitaryGroup (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m)) ℂ) (z : EuclideanSpace ℂ (Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) × Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m))) : actualStoppingQuestionLocalAction (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m U) (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m V) (unconditionalSourcePhysicalStoppingTargetFirstStateEquiv S B N d L m z) = unconditionalSourcePhysicalStoppingTargetFirstStateEquiv S B N d L m (localUnitaryAction U V z) := by classical let e := unconditionalSourcePhysicalStoppingTargetFirstIndexEquiv S B N d L m ext ⟨a, b⟩ change (∑ q : (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) × (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m), (U : Matrix _ _ ℂ) (e.symm a) (e.symm q.1) * (V : Matrix _ _ ℂ) (e.symm b) (e.symm q.2) * z (e.symm q.1, e.symm q.2)) = ∑ q : Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m) × Fin (d * dSVDensityRationalPublicMultiscalePhaseResidual S B N d L m), (U : Matrix _ _ ℂ) (e.symm a) q.1 * (V : Matrix _ _ ℂ) (e.symm b) q.2 * z q simpa using (Equiv.sum_comp (Equiv.prodCongr e e) (fun q : (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) × (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) => (U : Matrix _ _ ℂ) (e.symm a) (e.symm q.1) * (V : Matrix _ _ ℂ) (e.symm b) (e.symm q.2) * z (e.symm q.1, e.symm q.2))).symm theorem unconditionalSourcePhysicalCleanedStoppingFixedSource_physicalAction {S B N d L m : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : actualStoppingQuestionLocalAction (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice S B N d L m width schedule ξ)) (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralBob S B N d L m width schedule ζ)) (unconditionalSourcePhysicalCleanedStoppingFixedSource S B N d L m) = unconditionalSourcePhysicalStoppingTargetFirstStateEquiv S B N d L m (dSVDensityRationalHeterogeneousOriginalStoppedState S B N d L m width schedule ξ ζ) := by unfold unconditionalSourcePhysicalCleanedStoppingFixedSource rw [unconditionalSourcePhysicalCleanedStoppingLocalAction_reindex] rfl theorem unconditionalSourcePhysicalCleanedStoppingFixedSource_branch_apply {S B N d L m : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (r s : Fin (L + 1)) (φ ψ : DSVDensityRationalPublicMultiscalePhaseIndex S B) (a b : DSVUniformDensityIndependentHistoryLocalIndex (L + 1) N d) (i k : Fin m) : actualStoppingBranchVector (actualStoppingQuestionLocalAction (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice S B N d L m width schedule ξ)) (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralBob S B N d L m width schedule ζ)) (unconditionalSourcePhysicalCleanedStoppingFixedSource S B N d L m)) r s (⟨(φ, a), i⟩, ⟨(ψ, b), k⟩) = ePRState (Fintype.card (DSVDensityRationalPublicMultiscalePhase S B)) (φ, ψ) * dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (⟨r, a⟩, ⟨s, b⟩) * embezzlementState m (i, k) := by rw [unconditionalSourcePhysicalCleanedStoppingFixedSource_physicalAction] exact unconditionalSourcePhysicalStoppingTargetFirst_branch_apply width schedule ξ ζ r s φ ψ a b i k def unconditionalSourcePhysicalCleanedSelectedHistoryEquiv {L : ℕ} (j : Fin L) (β : Type*) : (Fin (L + 1) → β) ≃ β × ((Fin j.val → β) × (Fin (L - j.val) → β)) where toFun f := (f j.castSucc, (fun i => f ⟨i.val, by omega⟩, fun i => f ⟨j.val + 1 + i.val, by omega⟩)) invFun q i := if before : i.val < j.val then q.2.1 ⟨i.val, before⟩ else if hit : i.val = j.val then q.1 else q.2.2 ⟨i.val - (j.val + 1), by omega⟩ left_inv := by intro f funext i dsimp split <;> rename_i before · apply congrArg f apply Fin.ext rfl · split <;> rename_i hit · apply congrArg f apply Fin.ext exact hit.symm · apply congrArg f apply Fin.ext simp only omega right_inv := by intro q rcases q with ⟨selected, before, later⟩ apply Prod.ext · simp · apply Prod.ext · funext i simp · funext i have not_before : ¬ j.val + 1 + i.val < j.val := by omega have not_hit : ¬ j.val + 1 + i.val = j.val := by omega simp [not_before, not_hit] @[simp] theorem unconditionalSourcePhysicalCleanedSelectedHistoryEquiv_hit {L : ℕ} (j : Fin L) (β : Type*) (f : Fin (L + 1) → β) : (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j β f).1 = f j.castSucc := by rfl def unconditionalSourcePhysicalCleanedFullLocalIndexEquiv {P R : Type*} {B N d L m : ℕ} (phaseSplit : P ≃ Fin B × R) (j : Fin L) : (Σ _ : P × (Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d), Fin m) ≃ UnconditionalSelectedCopyLocalIndex B d N m × ((Fin j.val → DSVUniformDensityThresholdLocalIndex N d) × ((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × R)) where toFun q := let phase := phaseSplit q.1.1 let history := unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d) q.1.2 (⟨(phase.1, history.1.2), finProdFinEquiv (history.1.1, q.2)⟩, (history.2.1, (history.2.2, phase.2))) invFun q := let work := finProdFinEquiv.symm q.1.2 ⟨(phaseSplit.symm (q.1.1.1, q.2.2.2), (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d)).symm (⟨work.1, q.1.1.2⟩, (q.2.1, q.2.2.1))), work.2⟩ left_inv := by rintro ⟨⟨phase, history⟩, work⟩ simp only [Equiv.symm_apply_apply] change (⟨(phaseSplit.symm ((phaseSplit phase).1, (phaseSplit phase).2), (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d)).symm ((unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d) history).1, ((unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d) history).2.1, (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d) history).2.2))), work⟩ : Σ _ : P × (Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d), Fin m) = ⟨(phase, history), work⟩ simp exact (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d)).symm_apply_apply history right_inv := by rintro ⟨⟨⟨phase, spectral⟩, packed⟩, ⟨before, ⟨later, remainder⟩⟩⟩ simp exact finProdFinEquiv.apply_symm_apply packed def unconditionalSourcePhysicalCleanedFullBilateralRegroup {R : Type*} {B N d L m : ℕ} (j : Fin L) : ((UnconditionalSelectedCopyLocalIndex B d N m × ((Fin j.val → DSVUniformDensityThresholdLocalIndex N d) × ((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × R))) × (UnconditionalSelectedCopyLocalIndex B d N m × ((Fin j.val → DSVUniformDensityThresholdLocalIndex N d) × ((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × R)))) ≃ ((UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) × ((Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) × (((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × (Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d)) × (R × R)))) where toFun q := ((q.1.1, q.2.1), ((fun i => (q.1.2.1 i, q.2.2.1 i)), ((q.1.2.2.1, q.2.2.2.1), (q.1.2.2.2, q.2.2.2.2)))) invFun q := ((q.1.1, ((fun i => (q.2.1 i).1), (q.2.2.1.1, q.2.2.2.1))), (q.1.2, ((fun i => (q.2.1 i).2), (q.2.2.1.2, q.2.2.2.2)))) left_inv := by rintro ⟨⟨selectedA, beforeA, laterA, phaseA⟩, ⟨selectedB, beforeB, laterB, phaseB⟩⟩ simp right_inv := by rintro ⟨⟨selectedA, selectedB⟩, ⟨before, ⟨⟨laterA, laterB⟩, ⟨phaseA, phaseB⟩⟩⟩⟩ simp def unconditionalSourcePhysicalCleanedFullBilateralStateIsometry {P R : Type*} [Fintype P] [Fintype R] {B N d L m : ℕ} (phaseSplit : P ≃ Fin B × R) (j : Fin L) : EuclideanSpace ℂ ((Σ _ : P × (Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d), Fin m) × (Σ _ : P × (Fin (L + 1) → DSVUniformDensityThresholdLocalIndex N d), Fin m)) ≃ₗᵢ[ℂ] EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) × ((Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) × (((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × (Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d)) × (R × R)))) := LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ ((Equiv.prodCongr (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv phaseSplit j) (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv phaseSplit j)).trans (unconditionalSourcePhysicalCleanedFullBilateralRegroup (R := R) (B := B) (N := N) (d := d) (m := m) j)) def unconditionalSourcePhysicalCleanedSelectedStageUnitary {B N d m : ℕ} (Q : ℕ) (w : ℝ) (ξ : BipartiteUnitVector d) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : Matrix.unitaryGroup (UnconditionalSelectedCopyLocalIndex B d N m) ℂ := dSVDensityRationalPublicBucketCoherentPhaseLocalUnitary (dSVDensityRationalPhysicalAcceptedRank w N ξ) (dSVDensityRationalPublicLogRankBucket Q) A end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable abbrev UnconditionalActualCleanedSelectedRetainedIndex {N d L : ℕ} (j : Fin L) (R : Type) := (Fin j.val → DSVUniformDensityThresholdLocalIndex N d) × ((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × R) def unconditionalActualCleanedSelectedTensorUnitary {ι κ : Type*} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] (U : Matrix.unitaryGroup ι ℂ) (V : Matrix.unitaryGroup κ ℂ) : Matrix.unitaryGroup (ι × κ) ℂ := ⟨(U : Matrix ι ι ℂ) ⊗ₖ (V : Matrix κ κ ℂ), Matrix.kronecker_mem_unitary U.property V.property⟩ def unconditionalActualCleanedSelectedStageBucketUnitary {B N d m : ℕ} (Q : ℕ) (w : ℝ) (ξ : BipartiteUnitVector d) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : Matrix.unitaryGroup (UnconditionalSelectedCopyLocalIndex B d N m) ℂ := unconditionalSourcePhysicalCleanedSelectedStageUnitary Q w ξ A def unconditionalActualCleanedSelectedStagePhysicalIndexEquiv (B N d m : ℕ) : (Σ _ : Fin B, DSVUniformDensityThresholdLocalIndex N d × Fin m) ≃ UnconditionalSelectedCopyLocalIndex B d N m where toFun q := ⟨(q.1, q.2.1.2), finProdFinEquiv (q.2.1.1, q.2.2)⟩ invFun q := let work := finProdFinEquiv.symm q.2 ⟨q.1.1, (⟨work.1, q.1.2⟩, work.2)⟩ left_inv := by rintro ⟨phase, ⟨⟨threshold, spectral⟩, harmonic⟩⟩ simp right_inv := by rintro ⟨⟨phase, spectral⟩, work⟩ simp exact finProdFinEquiv.apply_symm_apply work def unconditionalActualCleanedSelectedStageSpectralUnitary {B N d m : ℕ} (spectral : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix.unitaryGroup (UnconditionalSelectedCopyLocalIndex B d N m) ℂ := unconditionalSourceFixedPureStoppedSigmaReindexedUnitary (unconditionalActualCleanedSelectedStagePhysicalIndexEquiv B N d m) (coherentSharedRandomControlledUnitary (fun _ : Fin B => unconditionalActualCleanedSelectedTensorUnitary spectral (1 : Matrix.unitaryGroup (Fin m) ℂ))) def unconditionalActualCleanedSelectedFullStageUnitary {S B N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × R) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (spectral : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) : Matrix.unitaryGroup (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ := by let retained := UnconditionalActualCleanedSelectedRetainedIndex (N := N) (d := d) j R let selected := UnconditionalSelectedCopyLocalIndex B d N m let regroup : UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m ≃ (Σ _ : retained, selected) := (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv phaseSplit j).trans ((Equiv.prodComm selected retained).trans (Equiv.sigmaEquivProd retained selected).symm) exact unconditionalSourceFixedPureStoppedSigmaReindexedUnitary regroup.symm (coherentSharedRandomControlledUnitary (fun _ : retained => unconditionalActualCleanedSelectedStageBucketUnitary Q (width (schedule j)) ξ A * unconditionalActualCleanedSelectedStageSpectralUnitary (B := B) (m := m) spectral)) def unconditionalActualCleanedSelectedFiniteStageDecoder {S B N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × R) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (spectral : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : Fin (L + 1) → Matrix.unitaryGroup (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ := Fin.cases 1 (fun j => unconditionalActualCleanedSelectedFullStageUnitary phaseSplit Q width schedule ξ spectral A j) @[simp] theorem unconditionalActualCleanedSelectedFiniteStageDecoder_succ {S B N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × R) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (spectral : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) : unconditionalActualCleanedSelectedFiniteStageDecoder phaseSplit Q width schedule ξ spectral A j.succ = unconditionalActualCleanedSelectedFullStageUnitary phaseSplit Q width schedule ξ spectral A j := by simp [unconditionalActualCleanedSelectedFiniteStageDecoder] theorem unconditionalActualCleanedSelectedMatchedStoppingBranch {S B N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × R) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) : actualStoppingBranchVector (dSVUniformDensityPhysicalAsyncSigmaContinuation (unconditionalActualCleanedSelectedFiniteStageDecoder phaseSplit Q width schedule ξ (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) A) (unconditionalActualCleanedSelectedFiniteStageDecoder phaseSplit Q width schedule ζ ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) C) (actualStoppingQuestionLocalAction (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice S B N d L m width schedule ξ)) (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralBob S B N d L m width schedule ζ)) (unconditionalSourcePhysicalCleanedStoppingFixedSource S B N d L m))) j.succ j.succ = toLp 2 ((((unconditionalActualCleanedSelectedFullStageUnitary phaseSplit Q width schedule ξ (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) A j : Matrix (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ) ⊗ₖ (unconditionalActualCleanedSelectedFullStageUnitary phaseSplit Q width schedule ζ ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) C j : Matrix (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ)).mulVec (ofLp (actualStoppingBranchVector (unconditionalSourcePhysicalStoppingTargetFirstStateEquiv S B N d L m (dSVDensityRationalHeterogeneousOriginalStoppedState S B N d L m width schedule ξ ζ)) j.succ j.succ)))) := by rw [unconditionalSourcePhysicalCleanedStoppingFixedSource_physicalAction, unconditionalSourcePhysicalStoppingBranch_sigmaContinuation, unconditionalActualCleanedSelectedFiniteStageDecoder_succ, unconditionalActualCleanedSelectedFiniteStageDecoder_succ] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable abbrev UnconditionalSourceFlagControlledRetainedIndex {N d L : ℕ} (j : Fin L) (R : Type) := (Fin j.val → DSVUniformDensityThresholdLocalIndex N d) × ((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × R) def unconditionalSourceFlagControlledTensorUnitary {ι κ : Type} [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] (U : Matrix.unitaryGroup ι ℂ) (V : Matrix.unitaryGroup κ ℂ) : Matrix.unitaryGroup (ι × κ) ℂ := ⟨(U : Matrix ι ι ℂ) ⊗ₖ (V : Matrix κ κ ℂ), Matrix.kronecker_mem_unitary U.property V.property⟩ def unconditionalSourceFlagControlledStagePhysicalIndexEquiv (B N d m : ℕ) : (Σ _ : Fin B, DSVUniformDensityThresholdLocalIndex N d × Fin m) ≃ UnconditionalSelectedCopyLocalIndex B d N m where toFun q := ⟨(q.1, q.2.1.2), finProdFinEquiv (q.2.1.1, q.2.2)⟩ invFun q := let work := finProdFinEquiv.symm q.2 ⟨q.1.1, (⟨work.1, q.1.2⟩, work.2)⟩ left_inv := by rintro ⟨phase, ⟨⟨threshold, spectral⟩, harmonic⟩⟩ simp right_inv := by rintro ⟨⟨phase, spectral⟩, work⟩ simp exact finProdFinEquiv.apply_symm_apply work def unconditionalSourceFlagControlledStageSpectralUnitary {B N d m : ℕ} (spectral : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) : Matrix.unitaryGroup (UnconditionalSelectedCopyLocalIndex B d N m) ℂ := unconditionalSourceFixedPureStoppedSigmaReindexedUnitary (unconditionalSourceFlagControlledStagePhysicalIndexEquiv B N d m) (coherentSharedRandomControlledUnitary (fun _ : Fin B => unconditionalSourceFlagControlledTensorUnitary spectral (1 : Matrix.unitaryGroup (Fin m) ℂ))) def unconditionalSourceFlagControlledStageBucketUnitary {B N d m : ℕ} (Q : ℕ) (w : ℝ) (ξ : BipartiteUnitVector d) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : Matrix.unitaryGroup (UnconditionalSelectedCopyLocalIndex B d N m) ℂ := coherentSharedRandomControlledUnitary (fun q : Fin B × Fin d => A q.1 (dSVDensityRationalPublicLogRankBucket Q q.1 (dSVDensityRationalPhysicalAcceptedRank w N ξ q.2))) def unconditionalSourceFlagControlledFullStageUnitary {S B N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × R) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (spectral : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) : Matrix.unitaryGroup (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ := by let retained := UnconditionalSourceFlagControlledRetainedIndex (N := N) (d := d) j R let selected := UnconditionalSelectedCopyLocalIndex B d N m let regroup : UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m ≃ (Σ _ : retained, selected) := (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv phaseSplit j).trans ((Equiv.prodComm selected retained).trans (Equiv.sigmaEquivProd retained selected).symm) exact unconditionalSourceFixedPureStoppedSigmaReindexedUnitary regroup.symm (coherentSharedRandomControlledUnitary (fun _ : retained => unconditionalSourceFlagControlledStageBucketUnitary Q (width (schedule j)) ξ A * unconditionalSourceFlagControlledStageSpectralUnitary (B := B) (m := m) spectral)) def unconditionalSourceFlagControlledFiniteStageDecoder {S B N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × R) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (spectral : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : Fin (L + 1) → Matrix.unitaryGroup (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ := Fin.cases 1 (fun j => unconditionalSourceFlagControlledFullStageUnitary phaseSplit Q width schedule ξ spectral A j) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def unconditionalActualPhysicalMixedAcceptedRawStage {B N d m : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) := toLp 2 fun q => ePRState B (q.1.1.1, q.2.1.1) * dSVDensityRationalPhysicalAcceptedOutcome w N ξ ζ (⟨(finProdFinEquiv.symm q.1.2).1, q.1.1.2⟩, ⟨(finProdFinEquiv.symm q.2.2).1, q.2.1.2⟩) * embezzlementState m ((finProdFinEquiv.symm q.1.2).2, (finProdFinEquiv.symm q.2.2).2) theorem unconditionalActualPhysicalMixedAcceptedSpectralGauge_apply {B N d m : ℕ} (U : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) (φ ψ : Fin B) (i j : Fin d) (k l : Fin N) (a b : Fin m) : (unconditionalActualCleanedSelectedStageSpectralUnitary (B := B) (m := m) U : Matrix (UnconditionalSelectedCopyLocalIndex B d N m) (UnconditionalSelectedCopyLocalIndex B d N m) ℂ) ⟨(φ, i), finProdFinEquiv (k, a)⟩ ⟨(ψ, j), finProdFinEquiv (l, b)⟩ = if φ = ψ then (U : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ) ⟨k, i⟩ ⟨l, j⟩ * (if a = b then (1 : ℂ) else 0) else 0 := by classical have threshold_a : (finProdFinEquiv (k, a)).divNat = k := by change (finProdFinEquiv.symm (finProdFinEquiv (k, a))).1 = k rw [Equiv.symm_apply_apply] have harmonic_a : (finProdFinEquiv (k, a)).modNat = a := by change (finProdFinEquiv.symm (finProdFinEquiv (k, a))).2 = a rw [Equiv.symm_apply_apply] have threshold_b : (finProdFinEquiv (l, b)).divNat = l := by change (finProdFinEquiv.symm (finProdFinEquiv (l, b))).1 = l rw [Equiv.symm_apply_apply] have harmonic_b : (finProdFinEquiv (l, b)).modNat = b := by change (finProdFinEquiv.symm (finProdFinEquiv (l, b))).2 = b rw [Equiv.symm_apply_apply] simp [unconditionalActualCleanedSelectedStageSpectralUnitary, unconditionalSourceFixedPureStoppedSigmaReindexedUnitary, unconditionalActualCleanedSelectedStagePhysicalIndexEquiv, coherentSharedRandomControlledUnitary, unconditionalActualCleanedSelectedTensorUnitary, Matrix.blockDiagonal'_apply, Matrix.kroneckerMap_apply, Matrix.one_apply, threshold_a, harmonic_a, threshold_b, harmonic_b] theorem unconditionalActualPhysicalMixedAcceptedSpectralGauge_sum {N d : ℕ} (f : DSVUniformDensityThresholdLocalIndex N d → DSVUniformDensityThresholdLocalIndex N d → ℂ) : (∑ i : Fin d, ∑ k : Fin N, ∑ j : Fin d, ∑ l : Fin N, f ⟨k, i⟩ ⟨l, j⟩) = ∑ x : DSVUniformDensityThresholdLocalIndex N d, ∑ y : DSVUniformDensityThresholdLocalIndex N d, f x y := by classical simp only [Fintype.sum_sigma] rw [Finset.sum_comm] apply Finset.sum_congr rfl intro k _ apply Finset.sum_congr rfl intro i _ rw [Finset.sum_comm] theorem unconditionalActualPhysicalMixedAcceptedSpectralGauge_stage {B N d m : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (ξ ζ : BipartiteUnitVector d) : toLp 2 ((((unconditionalActualCleanedSelectedStageSpectralUnitary (B := B) (m := m) (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) : Matrix (UnconditionalSelectedCopyLocalIndex B d N m) (UnconditionalSelectedCopyLocalIndex B d N m) ℂ) ⊗ₖ (unconditionalActualCleanedSelectedStageSpectralUnitary (B := B) (m := m) ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) : Matrix (UnconditionalSelectedCopyLocalIndex B d N m) (UnconditionalSelectedCopyLocalIndex B d N m) ℂ)).mulVec (ofLp (unconditionalActualPhysicalMixedAcceptedRawStage (B := B) (m := m) w ξ ζ)))) = dSVDensityRationalPublicBucketPhysicalCoherentMixedState (N := N) (B := B) w m ξ ζ := by classical ext ⟨⟨⟨φ, i⟩, packedA⟩, ⟨⟨ψ, j⟩, packedB⟩⟩ obtain ⟨⟨k, a⟩, rfl⟩ := finProdFinEquiv.surjective packedA obtain ⟨⟨l, b⟩, rfl⟩ := finProdFinEquiv.surjective packedB have reindex_packed (f : Fin (N * m) → ℂ) : (∑ packed : Fin (N * m), f packed) = ∑ packed : Fin N × Fin m, f (finProdFinEquiv packed) := (Equiv.sum_comp finProdFinEquiv f).symm rw [unconditionalPhysicalAcceptedCoherentStage_apply width grid ξ ζ φ ψ i j k l a b] simp only [Matrix.mulVec, dotProduct, Matrix.kroneckerMap_apply, Fintype.sum_prod_type, Fintype.sum_sigma] simp_rw [reindex_packed] simp only [Fintype.sum_prod_type] simp_rw [unconditionalActualPhysicalMixedAcceptedSpectralGauge_apply] simp only [ unconditionalActualPhysicalMixedAcceptedRawStage, Equiv.symm_apply_apply, ite_mul, mul_ite, zero_mul, mul_zero, mul_one] simp [dSVDensityRationalCanonicalPrefixSpectralOutcome, ePRState, Matrix.mulVec, dotProduct, Matrix.kroneckerMap_apply, Fintype.sum_prod_type, Finset.mul_sum, mul_assoc, mul_left_comm, mul_comm] let alice : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ let bob : Matrix (DSVUniformDensityThresholdLocalIndex N d) (DSVUniformDensityThresholdLocalIndex N d) ℂ := dSVUniformDensityBobHistoryCopyBasis (N := N) ζ let summand : DSVUniformDensityThresholdLocalIndex N d → DSVUniformDensityThresholdLocalIndex N d → ℂ := fun x y => (↑(Real.sqrt (B : ℝ)) : ℂ)⁻¹ * (embezzlementState m (a, b) * (dSVDensityRationalPhysicalAcceptedOutcome w N ξ ζ (x, y) * (alice ⟨k, i⟩ x * (starRingEnd ℂ) (bob y ⟨l, j⟩)))) by_cases phases : φ = ψ · simp only [if_pos phases] exact unconditionalActualPhysicalMixedAcceptedSpectralGauge_sum summand · simp only [if_neg phases] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder abbrev UnconditionalActualCanonicalRetainedPhaseIndex (S B : ℕ) := Fin (Fintype.card (Fin (S - 1) → Fin B)) def unconditionalActualCanonicalRetainedPhaseTail {S B N d L : ℕ} (j : Fin L) : EuclideanSpace ℂ (((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × (Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d)) × (UnconditionalActualCanonicalRetainedPhaseIndex S B × UnconditionalActualCanonicalRetainedPhaseIndex S B)) := toLp 2 fun q => dSVUniformDensityIndependentSharedState (L - j.val) N d q.1 * ePRState (Fintype.card (Fin (S - 1) → Fin B)) q.2 def unconditionalActualCanonicalFixedSourceMatchedBranch {S B N d L m : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) : EuclideanSpace ℂ (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m × UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) := actualStoppingBranchVector (actualStoppingQuestionLocalAction (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice S B N d L m width schedule ξ)) (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralBob S B N d L m width schedule ζ)) (unconditionalSourcePhysicalCleanedStoppingFixedSource S B N d L m)) j.succ j.succ def unconditionalActualCanonicalRawSelectedPhysicalStage {B N d m : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) : EuclideanSpace ℂ (UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) := toLp 2 fun q => ePRState B (q.1.1.1, q.2.1.1) * dSVDensityRationalPhysicalAcceptedOutcome w N ξ ζ (⟨(finProdFinEquiv.symm q.1.2).1, q.1.1.2⟩, ⟨(finProdFinEquiv.symm q.2.2).1, q.2.1.2⟩) * embezzlementState m ((finProdFinEquiv.symm q.1.2).2, (finProdFinEquiv.symm q.2.2).2) theorem unconditionalActualCanonicalCleanedHistorySymm_eq_direct {L : ℕ} (j : Fin L) (β : Type*) (selected : β) (before : Fin j.val → β) (later : Fin (L - j.val) → β) : (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j β).symm (selected, (before, later)) = directDSVSelectedCopyLocalHistoryEquiv j (selected, (before, later)) := by apply (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j β).injective rw [Equiv.apply_symm_apply] apply Prod.ext · exact (directDSVSelectedCopyLocalHistoryEquiv_hit j selected before later).symm · apply Prod.ext · funext i exact (directDSVSelectedCopyLocalHistoryEquiv_before j selected before later i).symm · funext i exact (directDSVSelectedCopyLocalHistoryEquiv_after j selected before later i).symm theorem unconditionalActualCanonicalFullSource_eq_rawSelectedStage {S B N d L m : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) : unconditionalSourcePhysicalCleanedFullBilateralStateIsometry (unconditionalActualMultiscalePhaseIndexEquiv (schedule j)).symm j (unconditionalActualCanonicalFixedSourceMatchedBranch (B := B) (m := m) width schedule ξ ζ j) = unconditionalMatchedVerifierTensor (unconditionalActualCanonicalRawSelectedPhysicalStage (B := B) (m := m) (width (schedule j)) ξ ζ) (unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) j)) := by classical ext ⟨⟨⟨⟨p, i⟩, packedA⟩, ⟨⟨q, k⟩, packedB⟩⟩, ⟨before, ⟨⟨afterA, afterB⟩, ⟨tailA, tailB⟩⟩⟩⟩ let a := finProdFinEquiv.symm packedA let b := finProdFinEquiv.symm packedB let historyA := (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d)).symm (⟨a.1, i⟩, ((fun t => (before t).1), afterA)) let historyB := (unconditionalSourcePhysicalCleanedSelectedHistoryEquiv j (DSVUniformDensityThresholdLocalIndex N d)).symm (⟨b.1, k⟩, ((fun t => (before t).2), afterB)) change unconditionalActualCanonicalFixedSourceMatchedBranch width schedule ξ ζ j (⟨(unconditionalActualMultiscalePhaseIndexEquiv (schedule j) (p, tailA), historyA), a.2⟩, ⟨(unconditionalActualMultiscalePhaseIndexEquiv (schedule j) (q, tailB), historyB), b.2⟩) = unconditionalActualCanonicalRawSelectedPhysicalStage (width (schedule j)) ξ ζ (⟨(p, i), packedA⟩, ⟨(q, k), packedB⟩) * unconditionalSelectedCopyRetainedWork width schedule ξ ζ j (unconditionalActualCanonicalRetainedPhaseTail j) (before, ((afterA, afterB), (tailA, tailB))) unfold unconditionalActualCanonicalFixedSourceMatchedBranch rw [unconditionalSourcePhysicalCleanedStoppingFixedSource_branch_apply width schedule ξ ζ j.succ j.succ] rw [unconditionalActualMultiscalePhase_EPR_apply (schedule j) p q tailA tailB] change (ePRState B (p, q) * ePRState (Fintype.card (Fin (S - 1) → Fin B)) (tailA, tailB)) * dSVDensityRationalHeterogeneousActualPhysicalState N width schedule ξ ζ (⟨j.succ, historyA⟩, ⟨j.succ, historyB⟩) * embezzlementState m (a.2, b.2) = (ePRState B (p, q) * dSVDensityRationalPhysicalAcceptedOutcome (width (schedule j)) N ξ ζ (⟨a.1, i⟩, ⟨b.1, k⟩) * embezzlementState m (a.2, b.2)) * (dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector (N := N) width schedule ξ ζ j before * (dSVUniformDensityIndependentSharedState (L - j.val) N d (afterA, afterB) * ePRState (Fintype.card (Fin (S - 1) → Fin B)) (tailA, tailB))) rw [show historyA = directDSVSelectedCopyLocalHistoryEquiv j (⟨a.1, i⟩, ((fun t => (before t).1), afterA)) from unconditionalActualCanonicalCleanedHistorySymm_eq_direct j _ _ _ _, show historyB = directDSVSelectedCopyLocalHistoryEquiv j (⟨b.1, k⟩, ((fun t => (before t).2), afterB)) from unconditionalActualCanonicalCleanedHistorySymm_eq_direct j _ _ _ _] rw [directDSVActualStoppingSelectedHistory_sourceProduct] unfold dSVDensityRationalPhysicalAcceptedOutcome ring theorem unconditionalActualCanonicalRawSelectedPhysicalStage_eq {B N d m : ℕ} (w : ℝ) (ξ ζ : BipartiteUnitVector d) : unconditionalActualCanonicalRawSelectedPhysicalStage (B := B) (N := N) (m := m) w ξ ζ = unconditionalActualPhysicalMixedAcceptedRawStage (B := B) (N := N) (m := m) w ξ ζ := by rfl end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace def directDSVActualReindexedRetainedPOVM {C s t ι : Type*} [Fintype C] [Fintype s] [Fintype t] [Fintype ι] [DecidableEq s] [DecidableEq t] [DecidableEq ι] (e : ι ≃ s × t) (P : POVM C s) : POVM C ι := reindexedPOVM e.symm (purificationAlicePOVM (k := t) P) @[simp] theorem directDSVActualReindexedRetainedPOVM_effect {C s t ι : Type*} [Fintype C] [Fintype s] [Fintype t] [Fintype ι] [DecidableEq s] [DecidableEq t] [DecidableEq ι] (e : ι ≃ s × t) (P : POVM C s) (a : C) (i j : ι) : (directDSVActualReindexedRetainedPOVM e P).effect a i j = P.effect a (e i).1 (e j).1 * if (e i).2 = (e j).2 then 1 else 0 := by change (P.effect a ⊗ₖ (1 : Matrix t t ℂ)) (e i) (e j) = _ simp [Matrix.kroneckerMap_apply, Matrix.one_apply] def directDSVActualBilateralRetainedIndexEquiv {s t u v ι κ : Type*} (eA : ι ≃ s × t) (eB : κ ≃ u × v) : (ι × κ) ≃ ((s × u) × (t × v)) := (Equiv.prodCongr eA eB).trans (Equiv.prodProdProdComm s t u v) def directDSVActualLocalPOVMWinningEffect {X Y A B s t : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (G : Game X Y A B) (PA : POVM A s) (PB : POVM B t) (x : X) (y : Y) : Matrix (s × t) (s × t) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then PA.effect a ⊗ₖ PB.effect b else 0 theorem directDSVActualReindexedRetainedPOVMWinningEffect {X Y A B s t u v ι κ : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [Fintype u] [Fintype v] [Fintype ι] [Fintype κ] [DecidableEq s] [DecidableEq t] [DecidableEq u] [DecidableEq v] [DecidableEq ι] [DecidableEq κ] (G : Game X Y A B) (eA : ι ≃ s × t) (eB : κ ≃ u × v) (PA : POVM A s) (PB : POVM B u) (x : X) (y : Y) : directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM eA PA) (directDSVActualReindexedRetainedPOVM eB PB) x y = Matrix.reindex (directDSVActualBilateralRetainedIndexEquiv eA eB).symm (directDSVActualBilateralRetainedIndexEquiv eA eB).symm (directDSVActualLocalPOVMWinningEffect G PA PB x y ⊗ₖ (1 : Matrix (t × v) (t × v) ℂ)) := by classical ext ⟨i, k⟩ ⟨j, l⟩ by_cases alice_work : (eA i).2 = (eA j).2 <;> by_cases bob_work : (eB k).2 = (eB l).2 <;> simp [directDSVActualLocalPOVMWinningEffect, directDSVActualReindexedRetainedPOVM, reindexedPOVM, purificationAlicePOVM, directDSVActualBilateralRetainedIndexEquiv, Matrix.reindex_apply, Matrix.sum_apply, Matrix.ite_apply, Matrix.submatrix_apply, Matrix.kroneckerMap_apply, Matrix.one_apply, Equiv.prodProdProdComm_apply, alice_work, bob_work] theorem directDSVActualReindexedWinningEffect_quadratic {ι κ : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] (e : ι ≃ κ) (winning : Matrix κ κ ℂ) (z : EuclideanSpace ℂ ι) : quadraticExpectation (Matrix.toEuclideanCLM (n := ι) (𝕜 := ℂ) (Matrix.reindex e.symm e.symm winning)) z = quadraticExpectation (Matrix.toEuclideanCLM (n := κ) (𝕜 := ℂ) winning) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ e z) := by classical rw [matrixQuadraticExpectation_expand, matrixQuadraticExpectation_expand] change (∑ i : ι, (∑ j : ι, winning (e i) (e j) * z j) * star (z i)).re = (∑ i : κ, (∑ j : κ, winning i j * z (e.symm j)) * star (z (e.symm i))).re congr 1 calc (∑ i : ι, (∑ j : ι, winning (e i) (e j) * z j) * star (z i)) = ∑ i : ι, (∑ j : κ, winning (e i) j * z (e.symm j)) * star (z i) := by apply Finset.sum_congr rfl intro i _ congr 1 simpa only [Equiv.symm_apply_apply] using (Equiv.sum_comp e (fun j : κ => winning (e i) j * z (e.symm j))) _ = ∑ i : κ, (∑ j : κ, winning i j * z (e.symm j)) * star (z (e.symm i)) := by simpa only [Equiv.symm_apply_apply] using (Equiv.sum_comp e (fun i : κ => (∑ j : κ, winning i j * z (e.symm j)) * star (z (e.symm i)))) theorem directDSVActualReindexedRetainedPOVMWinningEffect_tensor_quadratic {X Y A B s t u v ι κ : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [Fintype u] [Fintype v] [Fintype ι] [Fintype κ] [DecidableEq s] [DecidableEq t] [DecidableEq u] [DecidableEq v] [DecidableEq ι] [DecidableEq κ] (G : Game X Y A B) (eA : ι ≃ s × t) (eB : κ ≃ u × v) (PA : POVM A s) (PB : POVM B u) (x : X) (y : Y) (z : EuclideanSpace ℂ (ι × κ)) (target : EuclideanSpace ℂ (s × u)) (work : EuclideanSpace ℂ (t × v)) (selected : LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z = unconditionalMatchedVerifierTensor target work) : quadraticExpectation (Matrix.toEuclideanCLM (n := ι × κ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM eA PA) (directDSVActualReindexedRetainedPOVM eB PB) x y)) z = ‖work‖ ^ 2 * quadraticExpectation (Matrix.toEuclideanCLM (n := s × u) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G PA PB x y)) target := by rw [directDSVActualReindexedRetainedPOVMWinningEffect, directDSVActualReindexedWinningEffect_quadratic, selected, unconditionalMatchedVerifierEffect_tensor_quadratic] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder theorem unconditionalSelectedBranchLocalAction_mul {s t : Type*} [Fintype s] [DecidableEq s] [Fintype t] [DecidableEq t] (U₁ U₂ V₁ V₂ : Matrix.unitaryGroup s ℂ) (z : EuclideanSpace ℂ ((s × s) × t)) : unconditionalMixedConjugateSelectedBranchLocalAction (U₁ * U₂) (V₁ * V₂) z = unconditionalMixedConjugateSelectedBranchLocalAction U₁ V₁ (unconditionalMixedConjugateSelectedBranchLocalAction U₂ V₂ z) := by classical simp [unconditionalMixedConjugateSelectedBranchLocalAction, unconditionalMixedConjugateSelectedBranchUnitary, Matrix.mulVec_mulVec, Matrix.mul_kronecker_mul] apply congrArg (fun (W : Matrix ((s × s) × t) ((s × s) × t) ℂ) => W.mulVec (ofLp z)) simpa using (Matrix.mul_kronecker_mul ((U₁ : Matrix s s ℂ) ⊗ₖ (V₁ : Matrix s s ℂ)) ((U₂ : Matrix s s ℂ) ⊗ₖ (V₂ : Matrix s s ℂ)) (1 : Matrix t t ℂ) (1 : Matrix t t ℂ)) def unconditionalSelectedRetainedBilateralRegroup (ι τ : Type) : ((ι × τ) × (ι × τ)) ≃ ((ι × ι) × (τ × τ)) where toFun p := ((p.1.1, p.2.1), (p.1.2, p.2.2)) invFun p := ((p.1.1, p.2.1), (p.1.2, p.2.2)) left_inv := by rintro ⟨⟨_, _⟩, ⟨_, _⟩⟩; rfl right_inv := by rintro ⟨⟨_, _⟩, ⟨_, _⟩⟩; rfl theorem unconditionalRegroupedSelectedRetainedReindexAction {κ ι τ δ : Type} [Fintype κ] [DecidableEq κ] [Fintype ι] [DecidableEq ι] [Fintype τ] [DecidableEq τ] [Fintype δ] [DecidableEq δ] (e : κ ≃ ι × τ) (workEquiv : τ × τ ≃ δ) (U V : Matrix.unitaryGroup ι ℂ) (z : EuclideanSpace ℂ (κ × κ)) : let regroup := (unconditionalSelectedRetainedBilateralRegroup ι τ).trans (Equiv.prodCongr (Equiv.refl (ι × ι)) workEquiv) let sigma := (Equiv.prodComm ι τ).trans (Equiv.sigmaEquivProd τ ι).symm let localEquiv := e.trans sigma let A := unconditionalSourceFixedPureStoppedSigmaReindexedUnitary localEquiv.symm (coherentSharedRandomControlledUnitary (fun _ : τ => U)) let B := unconditionalSourceFixedPureStoppedSigmaReindexedUnitary localEquiv.symm (coherentSharedRandomControlledUnitary (fun _ : τ => V)) let state := LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ ((Equiv.prodCongr e e).trans regroup) state (toLp 2 ((((A : Matrix κ κ ℂ) ⊗ₖ (B : Matrix κ κ ℂ)).mulVec (ofLp z)))) = unconditionalMixedConjugateSelectedBranchLocalAction U V (state z) := by classical dsimp ext ⟨⟨i, j⟩, c⟩ have reindex (f : κ × κ → ℂ) : (∑ p : κ × κ, f p) = ∑ p : (ι × τ) × (ι × τ), f (e.symm p.1, e.symm p.2) := by simpa using (Equiv.sum_comp (Equiv.prodCongr e e) (fun p : (ι × τ) × (ι × τ) => f (e.symm p.1, e.symm p.2))) change (∑ p : κ × κ, (unconditionalSourceFixedPureStoppedSigmaReindexedUnitary (((Equiv.sigmaEquivProd τ ι).trans (Equiv.prodComm τ ι)).trans e.symm) (coherentSharedRandomControlledUnitary (fun _ : τ => U)) : Matrix κ κ ℂ) (e.symm (i, (workEquiv.symm c).1)) p.1 * (unconditionalSourceFixedPureStoppedSigmaReindexedUnitary (((Equiv.sigmaEquivProd τ ι).trans (Equiv.prodComm τ ι)).trans e.symm) (coherentSharedRandomControlledUnitary (fun _ : τ => V)) : Matrix κ κ ℂ) (e.symm (j, (workEquiv.symm c).2)) p.2 * z p) = _ rw [reindex] simp [unconditionalSourceFixedPureStoppedSigmaReindexedUnitary, coherentSharedRandomControlledUnitary, unconditionalSelectedRetainedBilateralRegroup, unconditionalMixedConjugateSelectedBranchLocalAction, unconditionalMixedConjugateSelectedBranchUnitary, Matrix.mulVec, dotProduct, Matrix.blockDiagonal'_apply, Matrix.one_apply, Matrix.kroneckerMap_apply, LinearIsometryEquiv.piLpCongrLeft_apply, Equiv.piCongrLeft', Fintype.sum_prod_type, mul_assoc] end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def unconditionalActualFixedSourceRetainedHistoryPairEquiv {N d L : ℕ} {R : Type} (j : Fin L) : (UnconditionalActualCleanedSelectedRetainedIndex (N := N) (d := d) j R × UnconditionalActualCleanedSelectedRetainedIndex (N := N) (d := d) j R) ≃ ((Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) × (((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × (Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d)) × (R × R))) where toFun p := ((fun i => (p.1.1 i, p.2.1 i)), ((p.1.2.1, p.2.2.1), (p.1.2.2, p.2.2.2))) invFun p := ((fun i => (p.1 i).1, (p.2.1.1, p.2.2.1)), (fun i => (p.1 i).2, (p.2.1.2, p.2.2.2))) left_inv := by rintro ⟨⟨beforeA, afterA, phaseA⟩, ⟨beforeB, afterB, phaseB⟩⟩ simp right_inv := by rintro ⟨before, ⟨⟨afterA, afterB⟩, ⟨phaseA, phaseB⟩⟩⟩ simp theorem unconditionalActualFixedSourceFullBilateralRegroup_eq {B N d L m : ℕ} {R : Type} (j : Fin L) : unconditionalSourcePhysicalCleanedFullBilateralRegroup (R := R) (B := B) (N := N) (d := d) (m := m) j = (unconditionalSelectedRetainedBilateralRegroup (UnconditionalSelectedCopyLocalIndex B d N m) (UnconditionalActualCleanedSelectedRetainedIndex (N := N) (d := d) j R)).trans (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m)) (unconditionalActualFixedSourceRetainedHistoryPairEquiv (N := N) (d := d) (R := R) j)) := by apply Equiv.ext rintro ⟨⟨selectedA, beforeA, afterA, phaseA⟩, ⟨selectedB, beforeB, afterB, phaseB⟩⟩ rfl theorem unconditionalActualFixedSourceFullPhysicalBilateralStageTransport {S B N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × R) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (spectralA spectralB : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) (z : EuclideanSpace ℂ (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m × UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m)) : unconditionalSourcePhysicalCleanedFullBilateralStateIsometry phaseSplit j (toLp 2 (((unconditionalActualCleanedSelectedFullStageUnitary phaseSplit Q width schedule ξ spectralA A j : Matrix (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ) ⊗ₖ (unconditionalActualCleanedSelectedFullStageUnitary phaseSplit Q width schedule ζ spectralB C j : Matrix (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) (UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m) ℂ)).mulVec (ofLp z))) = unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalActualCleanedSelectedStageBucketUnitary Q (width (schedule j)) ξ A * unconditionalActualCleanedSelectedStageSpectralUnitary (B := B) (m := m) spectralA) (unconditionalActualCleanedSelectedStageBucketUnitary Q (width (schedule j)) ζ C * unconditionalActualCleanedSelectedStageSpectralUnitary (B := B) (m := m) spectralB) (unconditionalSourcePhysicalCleanedFullBilateralStateIsometry phaseSplit j z) := by classical let e : UnconditionalSourcePhysicalStoppingPhaseFiber S B N d L m ≃ UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalActualCleanedSelectedRetainedIndex (N := N) (d := d) j R := unconditionalSourcePhysicalCleanedFullLocalIndexEquiv (N := N) (d := d) (m := m) phaseSplit j let work := unconditionalActualFixedSourceRetainedHistoryPairEquiv (N := N) (d := d) (R := R) j let UA := unconditionalActualCleanedSelectedStageBucketUnitary Q (width (schedule j)) ξ A * unconditionalActualCleanedSelectedStageSpectralUnitary (B := B) (m := m) spectralA let UB := unconditionalActualCleanedSelectedStageBucketUnitary Q (width (schedule j)) ζ C * unconditionalActualCleanedSelectedStageSpectralUnitary (B := B) (m := m) spectralB have transport := unconditionalRegroupedSelectedRetainedReindexAction e work UA UB z simpa only [unconditionalActualCleanedSelectedFullStageUnitary, unconditionalSourcePhysicalCleanedFullBilateralStateIsometry, unconditionalActualFixedSourceFullBilateralRegroup_eq, e, work, UA, UB] using transport theorem unconditionalActualFixedSourceDecodedMatchedBranch {S B N d L m : ℕ} (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) (positive : 0 < width (schedule j)) (grid : 0 < N) : unconditionalSourcePhysicalCleanedFullBilateralStateIsometry (unconditionalActualMultiscalePhaseIndexEquiv (schedule j)).symm j (actualStoppingBranchVector (dSVUniformDensityPhysicalAsyncSigmaContinuation (unconditionalActualCleanedSelectedFiniteStageDecoder (unconditionalActualMultiscalePhaseIndexEquiv (schedule j)).symm Q width schedule ξ (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) A) (unconditionalActualCleanedSelectedFiniteStageDecoder (unconditionalActualMultiscalePhaseIndexEquiv (schedule j)).symm Q width schedule ζ ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) C) (actualStoppingQuestionLocalAction (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice S B N d L m width schedule ξ)) (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralBob S B N d L m width schedule ζ)) (unconditionalSourcePhysicalCleanedStoppingFixedSource S B N d L m))) j.succ j.succ) = unconditionalSelectedCopyCleanedMatchedBranch (N := N) (B := B) (m := m) Q width schedule ξ ζ A C j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j) := by let phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × UnconditionalActualCanonicalRetainedPhaseIndex S B := (unconditionalActualMultiscalePhaseIndexEquiv (B := B) (schedule j)).symm have sameSource : actualStoppingBranchVector (unconditionalSourcePhysicalStoppingTargetFirstStateEquiv S B N d L m (dSVDensityRationalHeterogeneousOriginalStoppedState S B N d L m width schedule ξ ζ)) j.succ j.succ = unconditionalActualCanonicalFixedSourceMatchedBranch (B := B) (m := m) width schedule ξ ζ j := by unfold unconditionalActualCanonicalFixedSourceMatchedBranch rw [unconditionalSourcePhysicalCleanedStoppingFixedSource_physicalAction] change unconditionalSourcePhysicalCleanedFullBilateralStateIsometry phaseSplit j (actualStoppingBranchVector (dSVUniformDensityPhysicalAsyncSigmaContinuation (unconditionalActualCleanedSelectedFiniteStageDecoder phaseSplit Q width schedule ξ (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) A) (unconditionalActualCleanedSelectedFiniteStageDecoder phaseSplit Q width schedule ζ ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) C) (actualStoppingQuestionLocalAction (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice S B N d L m width schedule ξ)) (unconditionalSourcePhysicalCleanedTargetFirstUnitary S B N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralBob S B N d L m width schedule ζ)) (unconditionalSourcePhysicalCleanedStoppingFixedSource S B N d L m))) j.succ j.succ) = _ rw [unconditionalActualCleanedSelectedMatchedStoppingBranch phaseSplit Q width schedule ξ ζ A C j] rw [unconditionalActualFixedSourceFullPhysicalBilateralStageTransport] rw [sameSource, unconditionalActualCanonicalFullSource_eq_rawSelectedStage] rw [unconditionalSelectedBranchLocalAction_mul, unconditionalMixedConjugateSelectedBranch_tensorAction, unconditionalActualCanonicalRawSelectedPhysicalStage_eq, unconditionalActualPhysicalMixedAcceptedSpectralGauge_stage positive grid ξ ζ, unconditionalMixedConjugateSelectedBranch_tensorAction] congr 1 end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace set_option backward.isDefEq.respectTransparency false set_option maxHeartbeats 2400000 set_option maxRecDepth 2048 attribute [local instance] Classical.propDecidable variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem exactSourceHistoryFlag_nonempty_of_positive (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) : Nonempty (ExactHistoryFlag X Y A B D) := by classical have nonzero : (∑ t : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D t) ≠ 0 := by rw [exactLocallySampleableLaw_sum G n S D remaining positive] exact one_ne_zero obtain ⟨t, _, _⟩ := Finset.exists_ne_zero_of_sum_ne_zero nonzero exact ⟨t.2.2.2⟩ theorem exactSourceAnswerTypes_nonempty_of_remaining (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) : Nonempty A ∧ Nonempty B := by classical let i : Fin n := (Classical.choice (Fintype.card_pos_iff.mp (exactRemainingCoordinate_card_pos D remaining))).val let xs : Fin n → X := fun _ => Classical.choice (gameQuestionX_nonempty G) let ys : Fin n → Y := fun _ => Classical.choice (gameQuestionY_nonempty G) have normalized := S.outcomeProbability_normalized xs ys constructor · by_contra empty have zero : (∑ a : Fin n → A, ∑ b : Fin n → B, S.outcomeProbability xs ys a b) = 0 := by apply Finset.sum_eq_zero intro a _ exact (empty ⟨a i⟩).elim rw [zero] at normalized norm_num at normalized · by_contra empty have zero : (∑ a : Fin n → A, ∑ b : Fin n → B, S.outcomeProbability xs ys a b) = 0 := by apply Finset.sum_eq_zero intro a _ apply Finset.sum_eq_zero intro b _ exact (empty ⟨b i⟩).elim rw [zero] at normalized norm_num at normalized end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable def physical8SelectedGlobalTargetWorkEquiv (P N d m : ℕ) : UnconditionalSelectedCopyLocalIndex P d N m ≃ Fin d × (Fin P × Fin (N * m)) where toFun q := (q.1.2, (q.1.1, q.2)) invFun q := ⟨(q.2.1, q.1), q.2.2⟩ left_inv := by rintro ⟨⟨phase, atom⟩, work⟩ rfl right_inv := by rintro ⟨atom, phase, work⟩ rfl def physical8OneScaleActualGlobalFiberEquiv {P N d L m : ℕ} {R : Type} (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex 1 P ≃ Fin P × R) (j : Fin L) : UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m ≃ Fin d × ((Fin P × Fin (N * m)) × UnconditionalSourceFlagControlledRetainedIndex (N := N) (d := d) j R) := (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv phaseSplit j).trans ((Equiv.prodCongr (physical8SelectedGlobalTargetWorkEquiv P N d m) (Equiv.refl (UnconditionalSourceFlagControlledRetainedIndex (N := N) (d := d) j R))).trans (Equiv.prodAssoc (Fin d) (Fin P × Fin (N * m)) (UnconditionalSourceFlagControlledRetainedIndex (N := N) (d := d) j R))) def physical8OneScaleOriginalFlagPOVM {C Z : Type*} [Fintype C] [DecidableEq C] {P N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex 1 P ≃ Fin P × R) (default : C) (sourcePOVM : Z → POVM C (Fin d)) : Fin (L + 1) → Z → POVM C (UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m) := Fin.cases (fun _ => deterministicOutcomePOVM default) (fun j x => directDSVActualReindexedRetainedPOVM (physical8OneScaleActualGlobalFiberEquiv (N := N) (d := d) (m := m) phaseSplit j) (sourcePOVM x)) def physical8OneScaleActualAliceStoppingUnitary {F Z : Type*} {P N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex 1 P ≃ Fin P × R) (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (target : F → Z → BipartiteUnitVector d) (cleanup : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : F → Z → Matrix.unitaryGroup (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m) ℂ := fun flag x => coherentSharedRandomControlledUnitary (unconditionalSourceFlagControlledFiniteStageDecoder phaseSplit Q width schedule (target flag x) (dSVUniformDensityAliceHistorySpectralCopy (N := N) (target flag x)) cleanup) * unconditionalSourcePhysicalCleanedTargetFirstUnitary 1 P N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice 1 P N d L m width schedule (target flag x)) def physical8OneScaleActualBobStoppingUnitary {F Z : Type*} {P N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex 1 P ≃ Fin P × R) (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (target : F → Z → BipartiteUnitVector d) (cleanup : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : F → Z → Matrix.unitaryGroup (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m) ℂ := fun flag y => coherentSharedRandomControlledUnitary (unconditionalSourceFlagControlledFiniteStageDecoder phaseSplit Q width schedule (target flag y) ((dSVUniformDensityBobHistoryCopyBasis (N := N) (target flag y))⁻¹) cleanup) * unconditionalSourcePhysicalCleanedTargetFirstUnitary 1 P N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralBob 1 P N d L m width schedule (target flag y)) def physical8OneScaleActualSourceFlaggedStrategy {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (w : ℝ) (N L P Q m : ℕ) (phases : 0 < P) (grid : 0 < N) (harmonic : 0 < m) (UA UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : Strategy G := by classical let d : ℕ := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) have dimension : 0 < d := exactGlobalHistoryLocalIndex_card_pos G n S D let R : Type := Fin (Fintype.card (Fin (1 - 1) → Fin P)) let phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex 1 P ≃ Fin P × R := (unconditionalActualMultiscalePhaseIndexEquiv (B := P) (0 : Fin 1)).symm let width : Fin 1 → ℝ := fun _ => w let schedule : Fin L → Fin 1 := fun _ => 0 let F : Type := ExactSourceSharedFlag X Y A B D denominator let ξ : F → X → BipartiteUnitVector d := fun flag x => exactGlobalHistoryFinGamma G n S D (exactSourceAlicePermutationHistory D denominator numerator nonempty flag x) x let ζ : F → Y → BipartiteUnitVector d := fun flag y => exactGlobalHistoryFinPhi G n S D (exactSourceBobPermutationHistory D denominator numerator nonempty flag y) y let a₀ : A := Classical.choice (exactSourceAnswerTypes_nonempty_of_remaining G n S D remaining).1 let b₀ : B := Classical.choice (exactSourceAnswerTypes_nonempty_of_remaining G n S D remaining).2 let globalAlice : X → POVM A (Fin d) := fun x => reindexedPOVM (finCongr (Nat.mul_one d)) (unconditionalConjugatePOVM (exactSourceGlobalCatalystAlicePOVM G n S D 1 a₀ x)) let globalBob : Y → POVM B (Fin d) := fun y => reindexedPOVM (finCongr (Nat.mul_one d)) (unconditionalConjugatePOVM (exactSourceGlobalCatalystBobPOVM G n S D 1 b₀ y)) let PA : F → Fin (L + 1) → X → POVM A (UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m) := fun flag => physical8OneScaleOriginalFlagPOVM (N := N) (d := d) (m := m) phaseSplit a₀ (fun x => unitaryConjugatePOVM (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (ξ flag x))) (globalAlice x)) let PB : F → Fin (L + 1) → Y → POVM B (UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m) := fun flag => physical8OneScaleOriginalFlagPOVM (N := N) (d := d) (m := m) phaseSplit b₀ (fun y => unitaryConjugatePOVM (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (ζ flag y))) (globalBob y)) let U := physical8OneScaleActualAliceStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) phaseSplit Q width schedule ξ UA let V := physical8OneScaleActualBobStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) phaseSplit Q width schedule ζ UB let prepared : F → EuclideanSpace ℂ ((Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m) × (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m)) := fun _ => unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m have prepared_normalized : ∀ flag : F, ‖prepared flag‖ = 1 := by intro flag exact unconditionalSourcePhysicalCleanedStoppingFixedSource_norm phases grid dimension harmonic exact pureFlaggedStrategy G (exactSourceSharedFlagWeight D denominator) (exactSourceSharedFlagWeight_nonneg D denominator) (exactSourceSharedFlagWeight_sum D remaining denominator) prepared prepared_normalized (fun flag x => unitaryConjugatePOVM (U flag x) (dependentBlockPOVM (fun r => PA flag r x))) (fun flag y => unitaryConjugatePOVM (V flag y) (dependentBlockPOVM (fun r => PB flag r y))) abbrev unconditionalOneScaleActualSourceFlaggedStrategy := @physical8OneScaleActualSourceFlaggedStrategy end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable def unconditionalActualOneScaleFixedSourcePhaseSplit (P : ℕ) : DSVDensityRationalPublicMultiscalePhaseIndex 1 P ≃ Fin P × UnconditionalActualCanonicalRetainedPhaseIndex 1 P := (unconditionalActualMultiscalePhaseIndexEquiv (B := P) (0 : Fin 1)).symm theorem unconditionalActualOneScaleFlagControlledFiniteStageDecoder_eq {S B N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex S B ≃ Fin B × R) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ : BipartiteUnitVector d) (spectral : Matrix.unitaryGroup (DSVUniformDensityThresholdLocalIndex N d) ℂ) (A : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : unconditionalSourceFlagControlledFiniteStageDecoder phaseSplit Q width schedule ξ spectral A = unconditionalActualCleanedSelectedFiniteStageDecoder phaseSplit Q width schedule ξ spectral A := by rfl def unconditionalActualOneScaleFixedSourceDecodedState {P N d L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (ξ ζ : BipartiteUnitVector d) (A C : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : EuclideanSpace ℂ ((Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m) × (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m)) := dSVUniformDensityPhysicalAsyncSigmaContinuation (unconditionalSourceFlagControlledFiniteStageDecoder (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule ξ (dSVUniformDensityAliceHistorySpectralCopy (N := N) ξ) A) (unconditionalSourceFlagControlledFiniteStageDecoder (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule ζ ((dSVUniformDensityBobHistoryCopyBasis (N := N) ζ)⁻¹) C) (actualStoppingQuestionLocalAction (unconditionalSourcePhysicalCleanedTargetFirstUnitary 1 P N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralAlice 1 P N d L m width schedule ξ)) (unconditionalSourcePhysicalCleanedTargetFirstUnitary 1 P N d L m (dSVDensityRationalHeterogeneousTargetFirstSpectralBob 1 P N d L m width schedule ζ)) (unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m)) theorem unconditionalActualOneScaleFixedSourcePhysicalQuestionAction {F X Y : Type} {P N d L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (ξ : F → X → BipartiteUnitVector d) (ζ : F → Y → BipartiteUnitVector d) (A C : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (flag : F) (x : X) (y : Y) : actualStoppingQuestionLocalAction (physical8OneScaleActualAliceStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule ξ A flag x) (physical8OneScaleActualBobStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule ζ C flag y) (unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m) = unconditionalActualOneScaleFixedSourceDecodedState Q width schedule (ξ flag x) (ζ flag y) A C := by classical unfold physical8OneScaleActualAliceStoppingUnitary physical8OneScaleActualBobStoppingUnitary unconditionalActualOneScaleFixedSourceDecodedState actualStoppingQuestionLocalAction dSVUniformDensityPhysicalAsyncSigmaContinuation simp only [] rw [Matrix.mulVec_mulVec, ← Matrix.mul_kronecker_mul] rfl theorem unconditionalActualOneScaleFixedSourceDecodedMatchedBranch {P N d L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (ξ ζ : BipartiteUnitVector d) (A C : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) (positive : 0 < width (schedule j)) (grid : 0 < N) : unconditionalSourcePhysicalCleanedFullBilateralStateIsometry (unconditionalActualOneScaleFixedSourcePhaseSplit P) j (actualStoppingBranchVector (unconditionalActualOneScaleFixedSourceDecodedState Q width schedule ξ ζ A C) j.succ j.succ) = unconditionalSelectedCopyCleanedMatchedBranch (N := N) (B := P) (m := m) Q width schedule ξ ζ A C j (unconditionalActualCanonicalRetainedPhaseTail (S := 1) (B := P) (N := N) (d := d) (L := L) j) := by have sameScale : schedule j = (0 : Fin 1) := Subsingleton.elim _ _ have samePhase : (unconditionalActualMultiscalePhaseIndexEquiv (B := P) (schedule j)).symm = unconditionalActualOneScaleFixedSourcePhaseSplit P := by simp only [unconditionalActualOneScaleFixedSourcePhaseSplit] rw [sameScale] have decoded := unconditionalActualFixedSourceDecodedMatchedBranch (S := 1) (B := P) (N := N) (d := d) (L := L) (m := m) Q width schedule ξ ζ A C j positive grid rw [samePhase] at decoded simpa only [unconditionalActualOneScaleFixedSourceDecodedState, unconditionalActualOneScaleFlagControlledFiniteStageDecoder_eq] using decoded theorem unconditionalActualOneScalePhysicalQuestionDecodedMatchedBranch {F X Y : Type} {P N d L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (ξ : F → X → BipartiteUnitVector d) (ζ : F → Y → BipartiteUnitVector d) (A C : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (grid : 0 < N) (flag : F) (x : X) (y : Y) (j : Fin L) (positive : 0 < width (schedule j)) : unconditionalSourcePhysicalCleanedFullBilateralStateIsometry (unconditionalActualOneScaleFixedSourcePhaseSplit P) j (actualStoppingBranchVector (actualStoppingQuestionLocalAction (physical8OneScaleActualAliceStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule ξ A flag x) (physical8OneScaleActualBobStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule ζ C flag y) (unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m)) j.succ j.succ) = unconditionalSelectedCopyCleanedMatchedBranch (N := N) (B := P) (m := m) Q width schedule (ξ flag x) (ζ flag y) A C j (unconditionalActualCanonicalRetainedPhaseTail (S := 1) (B := P) (N := N) (d := d) (L := L) j) := by rw [unconditionalActualOneScaleFixedSourcePhysicalQuestionAction] exact unconditionalActualOneScaleFixedSourceDecodedMatchedBranch Q width schedule (ξ flag x) (ζ flag y) A C j positive grid end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalConjugatePureVector_sub_norm {ι : Type*} [Fintype ι] (x y : EuclideanSpace ℂ ι) : ‖unconditionalConjugatePureVector x - unconditionalConjugatePureVector y‖ = ‖x - y‖ := by have conjugate_sub : unconditionalConjugatePureVector x - unconditionalConjugatePureVector y = unconditionalConjugatePureVector (x - y) := by ext i simp [unconditionalConjugatePureVector, star_sub] rw [conjugate_sub, unconditionalConjugatePureVector_norm] theorem unconditionalClippedConjugateUnitTarget_distance_sq_le {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (gamma : BipartiteUnitVector d) (psi : EuclideanSpace ℂ (Fin d × Fin d)) : ‖unconditionalConjugatePureVector psi - unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val‖ ^ 2 ≤ 2 * ‖psi - gamma.val‖ ^ 2 + 8 * (1 / w + (d : ℝ) * w / (N : ℝ)) := by rw [unconditionalConjugatePureVector_sub_norm] let accepted : BipartiteUnitVector d := dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma have triangle : ‖psi - accepted.val‖ ≤ ‖psi - gamma.val‖ + ‖gamma.val - accepted.val‖ := by calc ‖psi - accepted.val‖ = ‖(psi - gamma.val) + (gamma.val - accepted.val)‖ := by congr 1 abel _ ≤ _ := norm_add_le _ _ have clipping := dSVDensityRationalCanonicalAcceptedUnitTarget_distance_le width grid fine gamma have clipping_nonnegative : 0 ≤ 1 / w + (d : ℝ) * w / (N : ℝ) := by positivity have clipping_squared : ‖gamma.val - accepted.val‖ ^ 2 ≤ 4 * (1 / w + (d : ℝ) * w / (N : ℝ)) := by change ‖gamma.val - (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val‖ ^ 2 ≤ _ nlinarith [ norm_nonneg (gamma.val - (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val), Real.sqrt_nonneg (1 / w + (d : ℝ) * w / (N : ℝ)), Real.sq_sqrt clipping_nonnegative] change ‖psi - accepted.val‖ ^ 2 ≤ _ nlinarith [norm_nonneg (psi - accepted.val), norm_nonneg (psi - gamma.val), norm_nonneg (gamma.val - accepted.val), sq_nonneg (‖psi - gamma.val‖ - ‖gamma.val - accepted.val‖)] theorem unconditionalMatchedVerifierTensor_sub_right {s t : Type*} [Fintype s] [Fintype t] (x y : EuclideanSpace ℂ s) (work : EuclideanSpace ℂ t) : unconditionalMatchedVerifierTensor x work - unconditionalMatchedVerifierTensor y work = unconditionalMatchedVerifierTensor (x - y) work := by ext q change x q.1 * work q.2 - y q.1 * work q.2 = (x q.1 - y q.1) * work q.2 ring theorem unconditionalWeightedClippedConjugateUnitSource_distance_sq_le {J : Type*} [Fintype J] {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (weight : J → ℝ) (weight_nonnegative : ∀ j, 0 ≤ weight j) (weight_normalized : (∑ j, weight j) = 1) (gamma : J → BipartiteUnitVector d) (psi : J → EuclideanSpace ℂ (Fin d × Fin d)) (energy : ℝ) (energy_bound : (∑ j, weight j * ‖psi j - (gamma j).val‖ ^ 2) ≤ energy) : (∑ j, weight j * ‖unconditionalConjugatePureVector (psi j) - unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine (gamma j)).val‖ ^ 2) ≤ 2 * energy + 8 * (1 / w + (d : ℝ) * w / (N : ℝ)) := by classical let clip : ℝ := 1 / w + (d : ℝ) * w / (N : ℝ) calc _ ≤ ∑ j, weight j * (2 * ‖psi j - (gamma j).val‖ ^ 2 + 8 * clip) := by apply Finset.sum_le_sum intro j _ exact mul_le_mul_of_nonneg_left (unconditionalClippedConjugateUnitTarget_distance_sq_le width grid fine (gamma j) (psi j)) (weight_nonnegative j) _ = 2 * (∑ j, weight j * ‖psi j - (gamma j).val‖ ^ 2) + (8 * clip) * (∑ j, weight j) := by rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro j _ ring _ = 2 * (∑ j, weight j * ‖psi j - (gamma j).val‖ ^ 2) + 8 * clip := by rw [weight_normalized] ring _ ≤ 2 * energy + 8 * (1 / w + (d : ℝ) * w / (N : ℝ)) := by dsimp [clip] linarith variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def unconditionalExactFairGammaUnit (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (u : ExactLocallySampleableTuple X Y A B D) : BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) := ⟨exactSourceTupleGamma G n S D u, exactSourceTupleGamma_norm G n S D u⟩ theorem unconditionalExactFairGammaUnit_eq_global (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (u : ExactLocallySampleableTuple X Y A B D) : unconditionalExactFairGammaUnit G n S D u = exactGlobalHistoryFinGamma G n S D u.2.2.2 u.2.1 := by apply Subtype.ext rfl end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalCoherentPhaseConstantWork_sub {H : Type*} [Fintype H] {B m : ℕ} (x y : EuclideanSpace ℂ (H × H)) (work : EuclideanSpace ℂ (Fin m × Fin m)) : dSVDensityRationalPublicBucketCoherentPhaseSigmaState B x (fun _ _ _ => work) - dSVDensityRationalPublicBucketCoherentPhaseSigmaState B y (fun _ _ _ => work) = dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (x - y) (fun _ _ _ => work) := by ext ⟨⟨⟨φ, i⟩, a⟩, ⟨⟨ψ, j⟩, b⟩⟩ change (ePRState B (φ, ψ) * x (i, j)) * work (a, b) - (ePRState B (φ, ψ) * y (i, j)) * work (a, b) = (ePRState B (φ, ψ) * (x (i, j) - y (i, j))) * work (a, b) ring theorem unconditionalStoppedPhaseHarmonic_distance_sq {H : Type*} [Fintype H] {B m : ℕ} (phases : 0 < B) (harmonic : 0 < m) (x y : EuclideanSpace ℂ (H × H)) : ‖dSVDensityRationalPublicBucketCoherentPhaseSigmaState B x (fun _ _ _ => embezzlementState m) - dSVDensityRationalPublicBucketCoherentPhaseSigmaState B y (fun _ _ _ => embezzlementState m)‖ ^ 2 = ‖x - y‖ ^ 2 := by rw [unconditionalCoherentPhaseConstantWork_sub, unconditionalSelectedCopy_coherentPhaseConstantWork_norm_sq phases, embezzlementState_norm m harmonic] ring theorem unconditionalStoppedPhaseHarmonicDistance_sum_le {J K : Type*} [Fintype K] {d B m : ℕ} (phases : 0 < B) (harmonic : 0 < m) (x y : J → EuclideanSpace ℂ (Fin d × Fin d)) {T : J × K → Type*} [∀ p, Fintype (T p)] (work : (p : J × K) → EuclideanSpace ℂ (T p)) (work_row : ∀ j : J, (∑ k : K, ‖work (j, k)‖ ^ 2) ≤ 1) (j : J) : (∑ k : K, ‖unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (x j) (fun _ _ _ => embezzlementState m)) (work (j, k)) - unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (y j) (fun _ _ _ => embezzlementState m)) (work (j, k))‖ ^ 2) ≤ ‖x j - y j‖ ^ 2 := by classical let sx := dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (x j) (fun _ _ _ => embezzlementState m) let sy := dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (y j) (fun _ _ _ => embezzlementState m) have stage : ‖sx - sy‖ ^ 2 = ‖x j - y j‖ ^ 2 := unconditionalStoppedPhaseHarmonic_distance_sq phases harmonic (x j) (y j) change (∑ k : K, ‖unconditionalMatchedVerifierTensor sx (work (j, k)) - unconditionalMatchedVerifierTensor sy (work (j, k))‖ ^ 2) ≤ _ calc _ = ∑ k : K, ‖sx - sy‖ ^ 2 * ‖work (j, k)‖ ^ 2 := by apply Finset.sum_congr rfl intro k _ rw [unconditionalMatchedVerifierTensor_sub_right, unconditionalMatchedVerifierTensor_norm_sq] _ = ‖sx - sy‖ ^ 2 * (∑ k : K, ‖work (j, k)‖ ^ 2) := by rw [Finset.mul_sum] _ ≤ ‖sx - sy‖ ^ 2 := mul_le_of_le_one_right (sq_nonneg _) (work_row j) _ = _ := stage theorem unconditionalWeightedStoppedPhaseHarmonicClippedUnit_le {J K : Type*} [Fintype J] [Fintype K] {d N B m : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (phases : 0 < B) (harmonic : 0 < m) (weight : J → ℝ) (weight_nonnegative : ∀ j, 0 ≤ weight j) (weight_normalized : (∑ j, weight j) = 1) (gamma : J → BipartiteUnitVector d) (psi : J → EuclideanSpace ℂ (Fin d × Fin d)) (energy : ℝ) (energy_bound : (∑ j, weight j * ‖psi j - (gamma j).val‖ ^ 2) ≤ energy) {T : J × K → Type*} [∀ p, Fintype (T p)] (work : (p : J × K) → EuclideanSpace ℂ (T p)) (work_row : ∀ j : J, (∑ k : K, ‖work (j, k)‖ ^ 2) ≤ 1) : (∑ j : J, weight j * ∑ k : K, ‖unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (psi j)) (fun _ _ _ => embezzlementState m)) (work (j, k)) - unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine (gamma j)).val) (fun _ _ _ => embezzlementState m)) (work (j, k))‖ ^ 2) ≤ 2 * energy + 8 * (1 / w + (d : ℝ) * w / (N : ℝ)) := by classical calc _ ≤ ∑ j : J, weight j * ‖unconditionalConjugatePureVector (psi j) - unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine (gamma j)).val‖ ^ 2 := by apply Finset.sum_le_sum intro j _ exact mul_le_mul_of_nonneg_left (unconditionalStoppedPhaseHarmonicDistance_sum_le phases harmonic (fun i => unconditionalConjugatePureVector (psi i)) (fun i => unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine (gamma i)).val) work work_row j) (weight_nonnegative j) _ ≤ _ := unconditionalWeightedClippedConjugateUnitSource_distance_sq_le width grid fine weight weight_nonnegative weight_normalized gamma psi energy energy_bound theorem unconditionalExactFairStoppedPhaseHarmonicClippedUnit_le {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) {w : ℝ} {N P m : ℕ} (width : 0 < w) (grid : 0 < N) (fine : (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) / (N : ℝ) < 1 / (w + 1)) (phases : 0 < P) (harmonic : 0 < m) {K : Type*} [Fintype K] {T : ExactLocallySampleableTuple X Y A B D × K → Type*} [∀ p, Fintype (T p)] (work : (p : ExactLocallySampleableTuple X Y A B D × K) → EuclideanSpace ℂ (T p)) (work_row : ∀ u : ExactLocallySampleableTuple X Y A B D, (∑ k : K, ‖work (u, k)‖ ^ 2) ≤ 1) : (∑ u : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D u * ∑ k : K, ‖unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState P (unconditionalConjugatePureVector (exactSourceTuplePsi G n S D u)) (fun _ _ _ => embezzlementState m)) (work (u, k)) - unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState P (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine (unconditionalExactFairGammaUnit G n S D u)).val) (fun _ _ _ => embezzlementState m)) (work (u, k))‖ ^ 2) ≤ 16 * martingaleRate G n S D + 8 * (1 / w + (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) * w / (N : ℝ)) := by classical have source := (exactSourceStateDistanceBound_of_positive G n S D remaining positive).1 have energy : (∑ u : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D u * ‖exactSourceTuplePsi G n S D u - (unconditionalExactFairGammaUnit G n S D u).val‖ ^ 2) ≤ 8 * martingaleRate G n S D := by simpa only [unconditionalExactFairGammaUnit, norm_sub_rev] using source have result := unconditionalWeightedStoppedPhaseHarmonicClippedUnit_le width grid fine phases harmonic (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive) (exactLocallySampleableLaw_sum G n S D remaining positive) (unconditionalExactFairGammaUnit G n S D) (exactSourceTuplePsi G n S D) (8 * martingaleRate G n S D) energy work work_row convert result using 1 ring theorem unconditionalCanonicalRaw_eq_norm_smul_unit {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (gamma : BipartiteUnitVector d) : dSVDensityRationalCanonicalAcceptedTarget w N gamma = ‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ • (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val := by exact (NormedSpace.norm_smul_normalize (dSVDensityRationalCanonicalAcceptedTarget w N gamma)).symm theorem unconditionalConjugateCanonicalRaw_eq_norm_smul_unit {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (gamma : BipartiteUnitVector d) : unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedTarget w N gamma) = ‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ • unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val := by have raw := unconditionalCanonicalRaw_eq_norm_smul_unit width grid fine gamma ext i have coefficient := congrArg (fun z : EuclideanSpace ℂ (Fin d × Fin d) => z i) raw change star (dSVDensityRationalCanonicalAcceptedTarget w N gamma i) = (‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ : ℂ) * star ((dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val i) change dSVDensityRationalCanonicalAcceptedTarget w N gamma i = (‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ : ℂ) * (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val i at coefficient rw [coefficient] simp theorem unconditionalPhaseCanonicalRaw_eq_norm_smul_unit {d N B m : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (gamma : BipartiteUnitVector d) : dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedTarget w N gamma)) (fun _ _ _ => embezzlementState m) = ‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ • dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val) (fun _ _ _ => embezzlementState m) := by have raw := unconditionalConjugateCanonicalRaw_eq_norm_smul_unit width grid fine gamma ext ⟨⟨⟨φ, i⟩, a⟩, ⟨⟨ψ, j⟩, b⟩⟩ have coefficient := congrArg (fun z : EuclideanSpace ℂ (Fin d × Fin d) => z (i, j)) raw change (ePRState B (φ, ψ) * star (dSVDensityRationalCanonicalAcceptedTarget w N gamma (i, j))) * embezzlementState m (a, b) = (‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ : ℂ) * ((ePRState B (φ, ψ) * star ((dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val (i, j))) * embezzlementState m (a, b)) change star (dSVDensityRationalCanonicalAcceptedTarget w N gamma (i, j)) = (‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ : ℂ) * star ((dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val (i, j)) at coefficient rw [coefficient] ring theorem unconditionalMatchedTensor_real_smul_work {s t : Type*} [Fintype s] [Fintype t] (c : ℝ) (stage : EuclideanSpace ℂ s) (work : EuclideanSpace ℂ t) : c • unconditionalMatchedVerifierTensor stage work = unconditionalMatchedVerifierTensor stage (c • work) := by ext q change (c : ℂ) * (stage q.1 * work q.2) = stage q.1 * ((c : ℂ) * work q.2) ring theorem unconditionalPhaseCanonical_sourceScale_absorbed {d N B m : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (dimension : 0 < d) (fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1)) (gamma : BipartiteUnitVector d) {T : Type*} [Fintype T] (work : EuclideanSpace ℂ T) : Real.sqrt (w * (d : ℝ)) • unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val) (fun _ _ _ => embezzlementState m)) ((‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ / Real.sqrt (w * (d : ℝ))) • work) = unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedTarget w N gamma)) (fun _ _ _ => embezzlementState m)) work := by let scale : ℝ := Real.sqrt (w * (d : ℝ)) let mass : ℝ := ‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ let stage := dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine gamma).val) (fun _ _ _ => embezzlementState m) have real_dimension : 0 < (d : ℝ) := by exact_mod_cast dimension have scale_positive : 0 < scale := by dsimp [scale] positivity have scalar : scale * (mass / scale) = mass := by field_simp [ne_of_gt scale_positive] have factor := unconditionalPhaseCanonicalRaw_eq_norm_smul_unit (B := B) (m := m) width grid fine gamma change scale • unconditionalMatchedVerifierTensor stage ((mass / scale) • work) = _ calc scale • unconditionalMatchedVerifierTensor stage ((mass / scale) • work) = unconditionalMatchedVerifierTensor stage (scale • ((mass / scale) • work)) := unconditionalMatchedTensor_real_smul_work scale stage ((mass / scale) • work) _ = unconditionalMatchedVerifierTensor stage (mass • work) := by rw [smul_smul, scalar] _ = mass • unconditionalMatchedVerifierTensor stage work := (unconditionalMatchedTensor_real_smul_work mass stage work).symm _ = unconditionalMatchedVerifierTensor (mass • stage) work := unconditionalMixedConjugateSelectedBranch_tensor_smul mass stage work _ = _ := by rw [factor] theorem unconditionalCanonicalAcceptedScale_sq_eq_diagonalBorn {d N : ℕ} {w : ℝ} (width : 0 < w) (grid : 0 < N) (dimension : 0 < d) (gamma : BipartiteUnitVector d) : (‖dSVDensityRationalCanonicalAcceptedTarget w N gamma‖ / Real.sqrt (w * (d : ℝ))) ^ 2 = dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension w gamma := by have dimension_real : 0 < (d : ℝ) := by exact_mod_cast dimension rw [div_pow, dSVDensityRationalCanonicalAcceptedTarget_norm_sq width N gamma, Real.sq_sqrt (by positivity : 0 ≤ w * (d : ℝ)), dSVDensityRationalPhysicalDiagonalBornSuccess_eq] field_simp [ne_of_gt width, ne_of_gt dimension_real] theorem unconditionalNormalizedCanonicalRetainedWork_norm_sq {S N d L B m : ℕ} {T : Type*} [Fintype T] (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (gamma phi : BipartiteUnitVector d) (j : Fin L) (rest : EuclideanSpace ℂ T) (rest_unit : ‖rest‖ = 1) : ‖(‖dSVDensityRationalCanonicalAcceptedTarget (width (schedule j)) N gamma‖ / Real.sqrt ((width (schedule j)) * (d : ℝ))) • unconditionalSelectedCopyRetainedWork (N := N) width schedule gamma phi j rest‖ ^ 2 = ‖unconditionalSelectedCopyIdealMatchedBranch (N := N) (B := B) (m := m) width schedule gamma phi j rest‖ ^ 2 := by have positive := width_positive (schedule j) have ratio_nonnegative : 0 ≤ ‖dSVDensityRationalCanonicalAcceptedTarget (width (schedule j)) N gamma‖ / Real.sqrt ((width (schedule j)) * (d : ℝ)) := by exact div_nonneg (norm_nonneg _) (Real.sqrt_nonneg _) calc _ = (‖dSVDensityRationalCanonicalAcceptedTarget (width (schedule j)) N gamma‖ / Real.sqrt ((width (schedule j)) * (d : ℝ))) ^ 2 * ‖unconditionalSelectedCopyRetainedWork (N := N) width schedule gamma phi j rest‖ ^ 2 := by rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg ratio_nonnegative, mul_pow] _ = dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule j)) gamma * (dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule gamma phi j.val * ‖rest‖ ^ 2) := by rw [unconditionalCanonicalAcceptedScale_sq_eq_diagonalBorn positive grid dimension gamma, unconditionalSelectedCopyRetainedWork_norm_sq] _ = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule gamma phi j.val * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule j)) gamma := by rw [rest_unit] ring _ = _ := (unconditionalSelectedCopyIdealMatchedBranch_norm_sq phases grid dimension harmonic width width_positive schedule gamma phi j rest rest_unit).symm theorem integratorActualCanonicalRetainedPhaseTail_norm {S B N d L : ℕ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (j : Fin L) : ‖unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j‖ = 1 := by have residual : 0 < Fintype.card (Fin (S - 1) → Fin B) := by apply Fintype.card_pos_iff.mpr exact ⟨fun _ => ⟨0, phases⟩⟩ change ‖unconditionalMatchedVerifierTensor (dSVUniformDensityIndependentSharedState (L - j.val) N d) (ePRState (Fintype.card (Fin (S - 1) → Fin B)))‖ = 1 rw [unconditionalMatchedVerifierTensor_norm, dSVUniformDensityIndependentSharedState_norm (L - j.val) grid dimension, ePRState_norm _ residual] norm_num abbrev IntegratorActualC485TailIndex (S B N d L : ℕ) (j : Fin L) := (((Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d) × (Fin (L - j.val) → DSVUniformDensityThresholdLocalIndex N d)) × (UnconditionalActualCanonicalRetainedPhaseIndex S B × UnconditionalActualCanonicalRetainedPhaseIndex S B)) abbrev IntegratorActualC485RetainedIndex (S B N d L : ℕ) (j : Fin L) := (Fin j.val → (DSVUniformDensityThresholdLocalIndex N d × DSVUniformDensityThresholdLocalIndex N d)) × IntegratorActualC485TailIndex S B N d L j abbrev IntegratorActualC485BranchSpace (S B N d L m : ℕ) (j : Fin L) := EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex B d N m × UnconditionalSelectedCopyLocalIndex B d N m) × IntegratorActualC485RetainedIndex S B N d L j) def integratorActualC485OriginalRetainedWork {S B N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) : EuclideanSpace ℂ (IntegratorActualC485RetainedIndex S B N d L j) := unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j) def integratorActualC485NormalizedDiagonalWork {S B N d L : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) : EuclideanSpace ℂ (IntegratorActualC485RetainedIndex S B N d L j) := (‖dSVDensityRationalCanonicalAcceptedTarget (width (schedule j)) N ξ‖ / Real.sqrt (width (schedule j) * (d : ℝ))) • integratorActualC485OriginalRetainedWork (B := B) width schedule ξ ζ j def integratorActualC485CleanedVector {S B N d L m : ℕ} (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) : IntegratorActualC485BranchSpace S B N d L m j := unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) B (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis ξ))) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) B (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis ζ))) (unconditionalSelectedCopyCleanedMatchedBranch (N := N) (B := B) (m := m) Q width schedule ξ ζ A C j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j)) def integratorActualC485CanonicalVector {S B N d L m : ℕ} {width : Fin S → ℝ} (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (positive : 0 < width (schedule j)) (grid : 0 < N) (fine : (d : ℝ) / (N : ℝ) < 1 / (width (schedule j) + 1)) : IntegratorActualC485BranchSpace S B N d L m j := unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget positive grid fine ξ).val) (fun _ _ _ => embezzlementState (N * m))) (integratorActualC485NormalizedDiagonalWork (B := B) width schedule ξ ζ j) def integratorActualC485SourceVector {S B N d L m : ℕ} (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (ψ : EuclideanSpace ℂ (Fin d × Fin d)) (j : Fin L) : IntegratorActualC485BranchSpace S B N d L m j := unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector ψ) (fun _ _ _ => embezzlementState (N * m))) (integratorActualC485NormalizedDiagonalWork (B := B) width schedule ξ ζ j) theorem unconditionalActualC485NormalizedDiagonalWork_mass_sum_le_one {S B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) : (∑ j : Fin L, ‖integratorActualC485NormalizedDiagonalWork (S := S) (B := B) (N := N) (d := d) (L := L) width schedule ξ ζ j‖ ^ 2) ≤ 1 := by classical calc _ = ∑ j : Fin L, dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val * dSVDensityRationalPhysicalDiagonalBornSuccess grid dimension (width (schedule j)) ξ := by apply Finset.sum_congr rfl intro j _ unfold integratorActualC485NormalizedDiagonalWork integratorActualC485OriginalRetainedWork rw [unconditionalNormalizedCanonicalRetainedWork_norm_sq (B := B) (m := m) phases grid dimension harmonic width positive schedule ξ ζ j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j) (integratorActualCanonicalRetainedPhaseTail_norm phases grid dimension j)] exact unconditionalSelectedCopyIdealMatchedBranch_norm_sq phases grid dimension harmonic width positive schedule ξ ζ j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j) (integratorActualCanonicalRetainedPhaseTail_norm phases grid dimension j) _ ≤ 1 := dSVDensityRationalHeterogeneousPhysicalDiagonalSurvival_budget grid dimension width schedule ξ ζ end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalActualSelectedBranchLocalAction_decidableEq_irrel {ι τ : Type*} [Fintype ι] [DecidableEq ι] [Fintype τ] (left right : DecidableEq τ) (U V : Matrix.unitaryGroup ι ℂ) (z : EuclideanSpace ℂ ((ι × ι) × τ)) : @unconditionalMixedConjugateSelectedBranchLocalAction ι τ inferInstance inferInstance inferInstance left U V z = @unconditionalMixedConjugateSelectedBranchLocalAction ι τ inferInstance inferInstance inferInstance right U V z := by have same : left = right := Subsingleton.elim left right cases same rfl theorem unconditionalActualC485CanonicalCorrectedIdeal_generic {S N d L B m : ℕ} {T : Type*} [Fintype T] [DecidableEq T] {width : Fin S → ℝ} (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (positive : 0 < width (schedule j)) (grid : 0 < N) (dimension : 0 < d) (fine : (d : ℝ) / (N : ℝ) < 1 / (width (schedule j) + 1)) (rest : EuclideanSpace ℂ T) : unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget positive grid fine ξ).val) (fun _ _ _ => embezzlementState (N * m))) ((‖dSVDensityRationalCanonicalAcceptedTarget (width (schedule j)) N ξ‖ / Real.sqrt (width (schedule j) * (d : ℝ))) • unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j rest) = unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) B (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis ξ))) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) B (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis ζ))) (unconditionalSelectedCopyIdealMatchedBranch (N := N) (B := B) (m := m) width schedule ξ ζ j rest) := by have scale_positive : 0 < Real.sqrt (width (schedule j) * (d : ℝ)) := by positivity apply smul_right_injective _ scale_positive.ne' exact (unconditionalPhaseCanonical_sourceScale_absorbed (B := B) (m := N * m) positive grid dimension fine ξ (unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j rest)).trans (unconditionalMixedConjugateSelectedBranchCovariance (B := B) (m := m) grid dimension width schedule ξ ζ j positive rest).symm theorem unconditionalActualC485CanonicalVector_eq_correctedIdeal {S B N d L m : ℕ} {width : Fin S → ℝ} (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (positive : 0 < width (schedule j)) (grid : 0 < N) (dimension : 0 < d) (fine : (d : ℝ) / (N : ℝ) < 1 / (width (schedule j) + 1)) : integratorActualC485CanonicalVector (B := B) (m := m) schedule ξ ζ j positive grid fine = unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) B (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis ξ))) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) B (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis ζ))) (unconditionalSelectedCopyIdealMatchedBranch (N := N) (B := B) (m := m) width schedule ξ ζ j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j)) := by change unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState B (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget positive grid fine ξ).val) (fun _ _ _ => embezzlementState (N * m))) ((‖dSVDensityRationalCanonicalAcceptedTarget (width (schedule j)) N ξ‖ / Real.sqrt (width (schedule j) * (d : ℝ))) • unconditionalSelectedCopyRetainedWork (N := N) width schedule ξ ζ j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j)) = _ convert (unconditionalActualC485CanonicalCorrectedIdeal_generic (B := B) (m := m) schedule ξ ζ j positive grid dimension fine (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j)) using 1 exact unconditionalActualSelectedBranchLocalAction_decidableEq_irrel _ _ _ _ _ theorem unconditionalActualSelectedBranchLocalAction_norm {ι τ : Type*} [Fintype ι] [DecidableEq ι] [Fintype τ] [DecidableEq τ] (U V : Matrix.unitaryGroup ι ℂ) (z : EuclideanSpace ℂ ((ι × ι) × τ)) : ‖unconditionalMixedConjugateSelectedBranchLocalAction U V z‖ = ‖z‖ := by classical let M : Matrix ((ι × ι) × τ) ((ι × ι) × τ) ℂ := (unconditionalMixedConjugateSelectedBranchUnitary (τ := τ) U V : Matrix ((ι × ι) × τ) ((ι × ι) × τ) ℂ) have gram : M.conjTranspose * M = 1 := by simpa [M, Matrix.star_eq_conjTranspose] using (Matrix.mem_unitaryGroup_iff'.mp (unconditionalMixedConjugateSelectedBranchUnitary (τ := τ) U V).property) have squared : ‖toLp 2 (M.mulVec (ofLp z))‖ ^ 2 = ‖z‖ ^ 2 := by rw [rectangular_matrix_mulVec_norm_sq, gram] simp [quadraticExpectation, ← Complex.ofReal_pow] change ‖toLp 2 (M.mulVec (ofLp z))‖ = ‖z‖ nlinarith [norm_nonneg (toLp 2 (M.mulVec (ofLp z))), norm_nonneg z] theorem unconditionalActualSelectedBranchLocalAction_sub {ι τ : Type*} [Fintype ι] [DecidableEq ι] [Fintype τ] [DecidableEq τ] (U V : Matrix.unitaryGroup ι ℂ) (x y : EuclideanSpace ℂ ((ι × ι) × τ)) : unconditionalMixedConjugateSelectedBranchLocalAction U V x - unconditionalMixedConjugateSelectedBranchLocalAction U V y = unconditionalMixedConjugateSelectedBranchLocalAction U V (x - y) := by classical ext i simp [unconditionalMixedConjugateSelectedBranchLocalAction, Matrix.mulVec, dotProduct, Finset.sum_sub_distrib, mul_sub] theorem unconditionalActualC485CleanDeviation_sq {S B N d L m : ℕ} (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) (positive : 0 < width (schedule j)) (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (fine : (d : ℝ) / (N : ℝ) < 1 / (width (schedule j) + 1)) : ‖integratorActualC485CleanedVector (B := B) (m := m) Q width schedule ξ ζ A C j - integratorActualC485CanonicalVector (B := B) (m := m) schedule ξ ζ j positive grid fine‖ ^ 2 = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val * dSVDensityRationalHeterogeneousCommonStopGaugeStageError Q (width (schedule j)) m ξ ζ A C := by classical rw [unconditionalActualC485CanonicalVector_eq_correctedIdeal schedule ξ ζ j positive grid dimension fine] unfold integratorActualC485CleanedVector rw [unconditionalActualSelectedBranchLocalAction_sub, unconditionalActualSelectedBranchLocalAction_norm] exact unconditionalSelectedCopyMatchedBranch_deviation_sq Q width schedule ξ ζ A C j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j) (integratorActualCanonicalRetainedPhaseTail_norm phases grid dimension j) theorem unconditionalActualC485CleanDeviation_eq_hazard {S B N d L m : ℕ} (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (positive : ∀ s, 0 < width s) (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (fine : ∀ s, (d : ℝ) / (N : ℝ) < 1 / (width s + 1)) : (∑ j : Fin L, ‖integratorActualC485CleanedVector (B := B) (m := m) Q width schedule ξ ζ A C j - integratorActualC485CanonicalVector (B := B) (m := m) schedule ξ ζ j (positive (schedule j)) grid (fine (schedule j))‖ ^ 2) = dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q m width schedule ξ ζ A C := by classical simp_rw [unconditionalActualC485CleanDeviation_sq Q width schedule ξ ζ A C _ (positive _) phases grid dimension (fine _)] unfold dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard simp_rw [ dSVDensityRationalHeterogeneousStoppedCommonPrefixFailureVector_norm_sq] theorem unconditionalActualC485WeightedCleanDeviation_eq_hazard {ι : Type*} [Fintype ι] {S B N d L m : ℕ} (law : ι → ℝ) (Q : ℕ) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : ι → BipartiteUnitVector d) (A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (positive : ∀ s, 0 < width s) (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (fine : ∀ s, (d : ℝ) / (N : ℝ) < 1 / (width s + 1)) : (∑ u : ι, law u * ∑ j : Fin L, ‖integratorActualC485CleanedVector (B := B) (m := m) Q width schedule (ξ u) (ζ u) A C j - integratorActualC485CanonicalVector (B := B) (m := m) schedule (ξ u) (ζ u) j (positive (schedule j)) grid (fine (schedule j))‖ ^ 2) = ∑ u : ι, law u * dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q m width schedule (ξ u) (ζ u) A C := by classical apply Finset.sum_congr rfl intro u _ rw [unconditionalActualC485CleanDeviation_eq_hazard Q width schedule (ξ u) (ζ u) A C positive phases grid dimension fine] end noncomputable section open scoped BigOperators open QuantumParallelRepetition.ClassicalSampling theorem unconditionalFairMatchedFlag_history_eq {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {n : ℕ} (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) (matched : exactSourcePermutationMatched D denominator numerator nonempty (flag, (x, y)) = true) : exactSourceAlicePermutationHistory D denominator numerator nonempty flag x = exactSourceBobPermutationHistory D denominator numerator nonempty flag y := by classical change decide (exactSourceAlicePermutationHistory D denominator numerator nonempty flag x = exactSourceBobPermutationHistory D denominator numerator nonempty flag y) = true at matched exact of_decide_eq_true matched theorem unconditionalFairMatchedFlag_bobTarget_eq_aliceSample {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) (matched : exactSourcePermutationMatched D denominator numerator nonempty (flag, (x, y)) = true) : exactGlobalHistoryFinPhi G n S D (exactSourceBobPermutationHistory D denominator numerator nonempty flag y) y = exactGlobalHistoryFinPhi G n S D (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y))).2.2.2 y := by have same := unconditionalFairMatchedFlag_history_eq D denominator numerator nonempty flag x y matched simp only [exactSourceAliceSampleTuple] rw [same] theorem unconditionalFairMatchedFlag_aliceTarget_eq_aliceSample {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) : exactGlobalHistoryFinGamma G n S D (exactSourceAlicePermutationHistory D denominator numerator nonempty flag x) x = exactGlobalHistoryFinGamma G n S D (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y))).2.2.2 x := by rfl end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalActualOneScaleDecodedMatchedCleanedVector {F X Y : Type} {P N d L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (ξ : F → X → BipartiteUnitVector d) (ζ : F → Y → BipartiteUnitVector d) (A C : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (grid : 0 < N) (flag : F) (x : X) (y : Y) (j : Fin L) (positive : 0 < width (schedule j)) : unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (ξ flag x)))) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (ζ flag y)))) (unconditionalSourcePhysicalCleanedFullBilateralStateIsometry (unconditionalActualOneScaleFixedSourcePhaseSplit P) j (actualStoppingBranchVector (actualStoppingQuestionLocalAction (physical8OneScaleActualAliceStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule ξ A flag x) (physical8OneScaleActualBobStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule ζ C flag y) (unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m)) j.succ j.succ)) = integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := d) (L := L) (m := m) Q width schedule (ξ flag x) (ζ flag y) A C j := by classical have decoded := unconditionalActualOneScalePhysicalQuestionDecodedMatchedBranch Q width schedule ξ ζ A C grid flag x y j positive change unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (ξ flag x)))) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (ζ flag y)))) _ = unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (ξ flag x)))) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (ζ flag y)))) _ rw [decoded] def integratorActualC485SourceAlicePOVM {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (x : X) : POVM A (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))) := by classical exact reindexedPOVM (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)))) (unconditionalConjugatePOVM (exactSourceGlobalCatalystAlicePOVM G n S D 1 a₀ x)) def integratorActualC485SourceBobPOVM {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (b₀ : B) (y : Y) : POVM B (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))) := by classical exact reindexedPOVM (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)))) (unconditionalConjugatePOVM (exactSourceGlobalCatalystBobPOVM G n S D 1 b₀ y)) def integratorActualC485SelectedAlicePOVM {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (P N m : ℕ) (x : X) : POVM A (UnconditionalSelectedCopyLocalIndex P (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) N m) := by classical exact directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) m) (integratorActualC485SourceAlicePOVM G n S D a₀ x) def integratorActualC485SelectedBobPOVM {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (b₀ : B) (P N m : ℕ) (y : Y) : POVM B (UnconditionalSelectedCopyLocalIndex P (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) N m) := by classical exact directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) m) (integratorActualC485SourceBobPOVM G n S D b₀ y) def integratorActualC485WinningEffect {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (j : Fin L) (x : X) (y : Y) : IntegratorActualC485BranchSpace 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m j →L[ℂ] IntegratorActualC485BranchSpace 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m j := by classical let d : ℕ := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) let selected : Type := UnconditionalSelectedCopyLocalIndex P d N m let retained : Type := IntegratorActualC485RetainedIndex 1 P N d L j exact Matrix.toEuclideanCLM (n := (selected × selected) × retained) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m y) x y ⊗ₖ (1 : Matrix retained retained ℂ)) theorem unconditionalActualFairSourceEmbezzlementOne_apply : embezzlementState 1 (0, 0) = 1 := by simp [embezzlementState, rawEmbezzlementState, EuclideanSpace.norm_eq, Fintype.sum_prod_type] theorem unconditionalActualFairSourceTensorEmbezzlementOne_reindex {d : ℕ} (ξ : BipartiteUnitVector d) : LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (finCongr (Nat.mul_one d)) (finCongr (Nat.mul_one d))) (tensorEmbezzlementTarget (n := 1) ξ) = ξ.val := by classical ext ⟨i, j⟩ have first : (((finCongr (Nat.mul_one d)).symm i).divNat : Fin d) = i := by apply Fin.ext change i.val / 1 = i.val simp have second : (((finCongr (Nat.mul_one d)).symm j).divNat : Fin d) = j := by apply Fin.ext change j.val / 1 = j.val simp have first_work : (((finCongr (Nat.mul_one d)).symm i).modNat : Fin 1) = 0 := Subsingleton.elim _ _ have second_work : (((finCongr (Nat.mul_one d)).symm j).modNat : Fin 1) = 0 := Subsingleton.elim _ _ change ξ.val ((((finCongr (Nat.mul_one d)).symm i).divNat : Fin d), (((finCongr (Nat.mul_one d)).symm j).divNat : Fin d)) * embezzlementState 1 ((((finCongr (Nat.mul_one d)).symm i).modNat : Fin 1), (((finCongr (Nat.mul_one d)).symm j).modNat : Fin 1)) = ξ.val (i, j) rw [first, second, first_work, second_work, unconditionalActualFairSourceEmbezzlementOne_apply, mul_one] theorem unconditionalActualFairSourceConjugateTensorEmbezzlementOne_inverse_reindex {d : ℕ} (ξ : BipartiteUnitVector d) : LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (finCongr (Nat.mul_one d)).symm (finCongr (Nat.mul_one d)).symm) (unconditionalConjugatePureVector ξ.val) = unconditionalConjugatePureVector (tensorEmbezzlementTarget (n := 1) ξ) := by classical ext ⟨i, j⟩ change star (ξ.val ((finCongr (Nat.mul_one d)) i, (finCongr (Nat.mul_one d)) j)) = star (tensorEmbezzlementTarget (n := 1) ξ (i, j)) congr 1 have recovered := congrArg (fun z : EuclideanSpace ℂ (Fin d × Fin d) => z ((finCongr (Nat.mul_one d)) i, (finCongr (Nat.mul_one d)) j)) (unconditionalActualFairSourceTensorEmbezzlementOne_reindex ξ) simpa [LinearIsometryEquiv.piLpCongrLeft_apply] using recovered.symm theorem unconditionalActualFairSourceWinningEffect_reindex {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [decA : DecidableEq A] [decB : DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) (x : X) (y : Y) : directDSVActualLocalPOVMWinningEffect G (integratorActualC485SourceAlicePOVM G n S D a₀ x) (integratorActualC485SourceBobPOVM G n S D b₀ y) x y = Matrix.reindex (Equiv.prodCongr (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)))) (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))))) (Equiv.prodCongr (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)))) (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))))) (unconditionalConjugateSourceGlobalCatalystWinningEffect G n S D 1 a₀ b₀ x y) := by classical have alice_instance : decA = Classical.decEq A := Subsingleton.elim _ _ have bob_instance : decB = Classical.decEq B := Subsingleton.elim _ _ cases alice_instance cases bob_instance ext ⟨i, k⟩ ⟨j, l⟩ simp only [directDSVActualLocalPOVMWinningEffect, integratorActualC485SourceAlicePOVM, integratorActualC485SourceBobPOVM, unconditionalConjugateSourceGlobalCatalystWinningEffect, reindexedPOVM, Matrix.reindex_apply, Matrix.sum_apply, Matrix.ite_apply, Matrix.zero_apply, Matrix.submatrix_apply, Matrix.kroneckerMap_apply, Equiv.prodCongr_symm, Equiv.prodCongr_apply, Prod.map] def unconditionalActualFairSourceBaseWinningCLM {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) (x : X) (y : Y) : ExactSourceGlobalState G n S D →L[ℂ] ExactSourceGlobalState G n S D := by classical exact Matrix.toEuclideanCLM (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (integratorActualC485SourceAlicePOVM G n S D a₀ x) (integratorActualC485SourceBobPOVM G n S D b₀ y) x y) theorem unconditionalActualFairSourceEOneReindexedGlobalWinningBorn {d : ℕ} (winning : Matrix (Fin (d * 1) × Fin (d * 1)) (Fin (d * 1) × Fin (d * 1)) ℂ) (ξ : BipartiteUnitVector d) : quadraticExpectation (Matrix.toEuclideanCLM (n := Fin d × Fin d) (𝕜 := ℂ) (Matrix.reindex (Equiv.prodCongr (finCongr (Nat.mul_one d)) (finCongr (Nat.mul_one d))) (Equiv.prodCongr (finCongr (Nat.mul_one d)) (finCongr (Nat.mul_one d))) winning)) (unconditionalConjugatePureVector ξ.val) = quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (d * 1) × Fin (d * 1)) (𝕜 := ℂ) winning) (unconditionalConjugatePureVector (tensorEmbezzlementTarget (n := 1) ξ)) := by classical let e : (Fin (d * 1) × Fin (d * 1)) ≃ (Fin d × Fin d) := Equiv.prodCongr (finCongr (Nat.mul_one d)) (finCongr (Nat.mul_one d)) calc _ = quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (d * 1) × Fin (d * 1)) (𝕜 := ℂ) winning) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ e.symm (unconditionalConjugatePureVector ξ.val)) := by exact directDSVActualReindexedWinningEffect_quadratic e.symm winning (unconditionalConjugatePureVector ξ.val) _ = _ := by congr 1 exact unconditionalActualFairSourceConjugateTensorEmbezzlementOne_inverse_reindex ξ theorem unconditionalActualFairSourceBaseSupportedBorn {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (a₀ : A) (b₀ : B) (h : ExactLocallySampleableTuple X Y A B D) (supported : exactLocallySampleableLaw G n S D h ≠ 0) : quadraticExpectation (unconditionalActualFairSourceBaseWinningCLM G n S D a₀ b₀ h.2.1 h.2.2.1) (unconditionalConjugatePureVector (exactSourceTuplePsi G n S D h)) = exactSourceConditionalWinningProbability G n S D h := by classical unfold unconditionalActualFairSourceBaseWinningCLM calc _ = quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))) (𝕜 := ℂ) (Matrix.reindex (Equiv.prodCongr (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)))) (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))))) (Equiv.prodCongr (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)))) (finCongr (Nat.mul_one (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))))) (unconditionalConjugateSourceGlobalCatalystWinningEffect G n S D 1 a₀ b₀ h.2.1 h.2.2.1))) (unconditionalConjugatePureVector (exactSourceTuplePsi G n S D h)) := by congr 2 exact unconditionalActualFairSourceWinningEffect_reindex G n S D a₀ b₀ h.2.1 h.2.2.1 _ = quadraticExpectation (Matrix.toEuclideanCLM (n := Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * 1) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) * 1)) (𝕜 := ℂ) (unconditionalConjugateSourceGlobalCatalystWinningEffect G n S D 1 a₀ b₀ h.2.1 h.2.2.1)) (unconditionalConjugatePureVector (tensorEmbezzlementTarget (n := 1) (exactGlobalHistoryFinPsi G n S D h.2.2.2 h.2.1 h.2.2.1))) := by exact unconditionalActualFairSourceEOneReindexedGlobalWinningBorn (unconditionalConjugateSourceGlobalCatalystWinningEffect G n S D 1 a₀ b₀ h.2.1 h.2.2.1) (exactGlobalHistoryFinPsi G n S D h.2.2.2 h.2.1 h.2.2.1) _ = _ := unconditionalConjugateSourceGlobalCatalystWinningEffect_law_supported G n S D positive 1 (by norm_num) a₀ b₀ h supported def unconditionalActualFairSourcePhaseHarmonicWork (P k : ℕ) : EuclideanSpace ℂ ((Fin P × Fin k) × (Fin P × Fin k)) := LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodProdProdComm (Fin P) (Fin P) (Fin k) (Fin k)) (unconditionalMatchedVerifierTensor (ePRState P) (embezzlementState k)) theorem unconditionalActualFairSourcePhaseHarmonicWork_norm {P k : ℕ} (phases : 0 < P) (harmonic : 0 < k) : ‖unconditionalActualFairSourcePhaseHarmonicWork P k‖ = 1 := by unfold unconditionalActualFairSourcePhaseHarmonicWork rw [LinearIsometryEquiv.norm_map, unconditionalMatchedVerifierTensor_norm, ePRState_norm P phases, embezzlementState_norm k harmonic] norm_num theorem unconditionalActualFairSourcePhaseHarmonicStage_sourceProduct {P N d m : ℕ} (ψ : EuclideanSpace ℂ (Fin d × Fin d)) : LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv (physical8SelectedGlobalTargetWorkEquiv P N d m) (physical8SelectedGlobalTargetWorkEquiv P N d m)) (dSVDensityRationalPublicBucketCoherentPhaseSigmaState P (unconditionalConjugatePureVector ψ) (fun _ _ _ => embezzlementState (N * m))) = unconditionalMatchedVerifierTensor (unconditionalConjugatePureVector ψ) (unconditionalActualFairSourcePhaseHarmonicWork P (N * m)) := by classical ext ⟨⟨i, j⟩, ⟨⟨p, a⟩, ⟨q, b⟩⟩⟩ simp [LinearIsometryEquiv.piLpCongrLeft_apply, directDSVActualBilateralRetainedIndexEquiv, physical8SelectedGlobalTargetWorkEquiv, dSVDensityRationalPublicBucketCoherentPhaseSigmaState, dSVUniformDensityCorrectedMatchedSigmaWeightedResidual, dSVDensityRationalPublicBucketCoherentPhaseHistory, unconditionalMatchedVerifierTensor, unconditionalActualFairSourcePhaseHarmonicWork, mul_assoc, mul_left_comm, mul_comm] theorem unconditionalActualFairSourceSelectedBorn_of_base {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N m : ℕ} (phases : 0 < P) (grid : 0 < N) (harmonic : 0 < m) (x : X) (y : Y) (ψ : EuclideanSpace ℂ (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)))) (value : ℝ) (base_born : quadraticExpectation (unconditionalActualFairSourceBaseWinningCLM G n S D a₀ b₀ x y) (unconditionalConjugatePureVector ψ) = value) : quadraticExpectation (Matrix.toEuclideanCLM (n := UnconditionalSelectedCopyLocalIndex P (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) N m × UnconditionalSelectedCopyLocalIndex P (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) N m) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m y) x y)) (dSVDensityRationalPublicBucketCoherentPhaseSigmaState P (unconditionalConjugatePureVector ψ) (fun _ _ _ => embezzlementState (N * m))) = value := by classical let d : ℕ := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) let e := physical8SelectedGlobalTargetWorkEquiv P N d m let stage := dSVDensityRationalPublicBucketCoherentPhaseSigmaState P (unconditionalConjugatePureVector ψ) (fun _ _ _ => embezzlementState (N * m)) let work := unconditionalActualFairSourcePhaseHarmonicWork P (N * m) have work_unit : ‖work‖ = 1 := unconditionalActualFairSourcePhaseHarmonicWork_norm phases (Nat.mul_pos grid harmonic) change quadraticExpectation (Matrix.toEuclideanCLM (n := UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM e (integratorActualC485SourceAlicePOVM G n S D a₀ x)) (directDSVActualReindexedRetainedPOVM e (integratorActualC485SourceBobPOVM G n S D b₀ y)) x y)) stage = value rw [directDSVActualReindexedRetainedPOVMWinningEffect_tensor_quadratic G e e (integratorActualC485SourceAlicePOVM G n S D a₀ x) (integratorActualC485SourceBobPOVM G n S D b₀ y) x y stage (unconditionalConjugatePureVector ψ) work (unconditionalActualFairSourcePhaseHarmonicStage_sourceProduct ψ)] change ‖work‖ ^ 2 * quadraticExpectation (unconditionalActualFairSourceBaseWinningCLM G n S D a₀ b₀ x y) (unconditionalConjugatePureVector ψ) = value rw [work_unit, one_pow, one_mul, base_born] theorem unconditionalActualFairSourceOuterBorn_of_base {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (phases : 0 < P) (grid : 0 < N) (harmonic : 0 < m) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (ξ ζ : BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))) (ψ : EuclideanSpace ℂ (Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) × Fin (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)))) (ψ_unit : ‖ψ‖ = 1) (j : Fin L) (x : X) (y : Y) (value : ℝ) (base_born : quadraticExpectation (unconditionalActualFairSourceBaseWinningCLM G n S D a₀ b₀ x y) (unconditionalConjugatePureVector ψ) = value) : quadraticExpectation (integratorActualC485WinningEffect G n S D a₀ b₀ (P := P) (N := N) (m := m) j x y) (integratorActualC485SourceVector (B := P) (N := N) (m := m) width schedule ξ ζ ψ j) = ‖integratorActualC485SourceVector (B := P) (N := N) (m := m) width schedule ξ ζ ψ j‖ ^ 2 * value := by classical let d : ℕ := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) let stage := dSVDensityRationalPublicBucketCoherentPhaseSigmaState P (unconditionalConjugatePureVector ψ) (fun _ _ _ => embezzlementState (N * m)) let retained := integratorActualC485NormalizedDiagonalWork (B := P) (N := N) width schedule ξ ζ j have selected_born : quadraticExpectation (Matrix.toEuclideanCLM (n := UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m y) x y)) stage = value := unconditionalActualFairSourceSelectedBorn_of_base G n S D a₀ b₀ phases grid harmonic x y ψ value base_born have stage_unit : ‖stage‖ = 1 := by calc ‖stage‖ = ‖LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv (physical8SelectedGlobalTargetWorkEquiv P N d m) (physical8SelectedGlobalTargetWorkEquiv P N d m)) stage‖ := by rw [LinearIsometryEquiv.norm_map] _ = ‖unconditionalMatchedVerifierTensor (unconditionalConjugatePureVector ψ) (unconditionalActualFairSourcePhaseHarmonicWork P (N * m))‖ := by rw [unconditionalActualFairSourcePhaseHarmonicStage_sourceProduct] _ = 1 := by rw [unconditionalMatchedVerifierTensor_norm, unconditionalConjugatePureVector_norm, ψ_unit, unconditionalActualFairSourcePhaseHarmonicWork_norm phases (Nat.mul_pos grid harmonic)] norm_num change quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × IntegratorActualC485RetainedIndex 1 P N d L j) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m y) x y ⊗ₖ (1 : Matrix (IntegratorActualC485RetainedIndex 1 P N d L j) (IntegratorActualC485RetainedIndex 1 P N d L j) ℂ))) (unconditionalMatchedVerifierTensor stage retained) = ‖unconditionalMatchedVerifierTensor stage retained‖ ^ 2 * value rw [unconditionalMatchedVerifierEffect_tensor_quadratic, selected_born, unconditionalMatchedVerifierTensor_norm_sq, stage_unit] ring theorem unconditionalActualFairSourceSupportedBorn {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) (a₀ : A) (b₀ : B) (h : ExactLocallySampleableTuple X Y A B D) (supported : exactLocallySampleableLaw G n S D h ≠ 0) {P N L m : ℕ} (phases : 0 < P) (grid : 0 < N) (harmonic : 0 < m) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (j : Fin L) : quadraticExpectation (integratorActualC485WinningEffect G n S D a₀ b₀ (P := P) (N := N) (m := m) j h.2.1 h.2.2.1) (integratorActualC485SourceVector (B := P) (N := N) (m := m) width schedule (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) (exactSourceTuplePsi G n S D h) j) = ‖integratorActualC485SourceVector (B := P) (N := N) (m := m) width schedule (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) (exactSourceTuplePsi G n S D h) j‖ ^ 2 * exactSourceConditionalWinningProbability G n S D h := by classical exact unconditionalActualFairSourceOuterBorn_of_base G n S D a₀ b₀ phases grid harmonic width schedule (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) (exactSourceTuplePsi G n S D h) (exactSourceTuplePsi_norm G n S D h) j h.2.1 h.2.2.1 (exactSourceConditionalWinningProbability G n S D h) (unconditionalActualFairSourceBaseSupportedBorn G n S D positive a₀ b₀ h supported) end noncomputable section open scoped BigOperators Kronecker ComplexOrder MatrixOrder attribute [local instance] Classical.propDecidable theorem unconditionalActualRetainedPOVM_ext {C ι : Type*} [Fintype C] [Fintype ι] [DecidableEq ι] (P Q : POVM C ι) (same : ∀ (a : C) (i j : ι), P.effect a i j = Q.effect a i j) : P = Q := by cases P with | mk pe pp pc => cases Q with | mk qe qp qc => have effect : pe = qe := by funext a apply Matrix.ext intro i j exact same a i j cases effect rfl theorem unconditionalPhysicalOneScaleActualGlobalFiberPOVM_nested {C : Type*} [Fintype C] {P N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex 1 P ≃ Fin P × R) (j : Fin L) (source : POVM C (Fin d)) : directDSVActualReindexedRetainedPOVM (physical8OneScaleActualGlobalFiberEquiv (N := N) (d := d) (m := m) phaseSplit j) source = directDSVActualReindexedRetainedPOVM (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv phaseSplit j) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) source) := by classical apply unconditionalActualRetainedPOVM_ext intro a i k let outer : UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m ≃ UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSourceFlagControlledRetainedIndex (N := N) (d := d) j R := unconditionalSourcePhysicalCleanedFullLocalIndexEquiv phaseSplit j let inner : UnconditionalSelectedCopyLocalIndex P d N m ≃ Fin d × (Fin P × Fin (N * m)) := physical8SelectedGlobalTargetWorkEquiv P N d m by_cases selected : (inner (outer i).1).2 = (inner (outer k).1).2 · by_cases retained : (outer i).2 = (outer k).2 · simp [directDSVActualReindexedRetainedPOVM_effect, physical8OneScaleActualGlobalFiberEquiv, Equiv.prodAssoc_apply, outer, inner, selected, retained] · simp [directDSVActualReindexedRetainedPOVM_effect, physical8OneScaleActualGlobalFiberEquiv, Equiv.prodAssoc_apply, outer, inner, selected, retained] · by_cases retained : (outer i).2 = (outer k).2 · simp [directDSVActualReindexedRetainedPOVM_effect, physical8OneScaleActualGlobalFiberEquiv, Equiv.prodAssoc_apply, outer, inner, selected, retained] · simp [directDSVActualReindexedRetainedPOVM_effect, physical8OneScaleActualGlobalFiberEquiv, Equiv.prodAssoc_apply, outer, inner, selected, retained] theorem unconditionalPhysicalOneScaleOriginalFlagPOVM_succ_nested {C Z : Type*} [Fintype C] [DecidableEq C] {P N d L m : ℕ} {R : Type} [Fintype R] [DecidableEq R] (phaseSplit : DSVDensityRationalPublicMultiscalePhaseIndex 1 P ≃ Fin P × R) (default : C) (source : Z → POVM C (Fin d)) (j : Fin L) (x : Z) : physical8OneScaleOriginalFlagPOVM (N := N) (d := d) (m := m) phaseSplit default source j.succ x = directDSVActualReindexedRetainedPOVM (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv phaseSplit j) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (source x)) := by change directDSVActualReindexedRetainedPOVM (physical8OneScaleActualGlobalFiberEquiv (N := N) (d := d) (m := m) phaseSplit j) (source x) = _ exact unconditionalPhysicalOneScaleActualGlobalFiberPOVM_nested phaseSplit j (source x) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable theorem unconditionalSelectedGaugeRetainedPOVMNaturality_effect {C : Type} [Fintype C] {P N d m : ℕ} (basis : Matrix.unitaryGroup (Fin d) ℂ) (source : POVM C (Fin d)) (a : C) : (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM basis source)).effect a = (unitaryConjugatePOVM (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P basis) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) source)).effect a := by classical ext p q rcases p with ⟨⟨φ, i⟩, k⟩ rcases q with ⟨⟨ψ, j⟩, l⟩ by_cases phase : φ = ψ <;> by_cases work : k = l <;> simp [directDSVActualReindexedRetainedPOVM_effect, physical8SelectedGlobalTargetWorkEquiv, unitaryConjugatePOVM, Matrix.mul_apply, Matrix.conjTranspose_apply, Fintype.sum_sigma, Fintype.sum_prod_type, unconditionalMixedConjugateSigmaAtomLift_apply, mul_assoc, ite_and, phase, work, eq_comm] theorem unconditionalSelectedGaugeRetainedPOVMNaturality {C : Type} [Fintype C] {P N d m : ℕ} (basis : Matrix.unitaryGroup (Fin d) ℂ) (source : POVM C (Fin d)) : directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM basis source) = unitaryConjugatePOVM (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P basis) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) source) := by classical apply unconditionalActualRetainedPOVM_ext intro a i j exact congrArg (fun M => M i j) (unconditionalSelectedGaugeRetainedPOVMNaturality_effect (P := P) (N := N) (m := m) basis source a) end noncomputable section open WithLp Matrix open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable theorem unconditionalActualFairSourceSelectedRetainedWinningEffectGauge {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {P N d m : ℕ} (G : Game X Y A B) (alice bob : Matrix.unitaryGroup (Fin d) ℂ) (PA : POVM A (Fin d)) (PB : POVM B (Fin d)) (x : X) (y : Y) : let e := physical8SelectedGlobalTargetWorkEquiv P N d m let U := unconditionalMixedConjugateSigmaAtomLift (m := N * m) P alice let V := unconditionalMixedConjugateSigmaAtomLift (m := N * m) P bob directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM e (unitaryConjugatePOVM alice PA)) (directDSVActualReindexedRetainedPOVM e (unitaryConjugatePOVM bob PB)) x y = (((U : Matrix _ _ ℂ) ⊗ₖ (V : Matrix _ _ ℂ))ᴴ * directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM e PA) (directDSVActualReindexedRetainedPOVM e PB) x y * ((U : Matrix _ _ ℂ) ⊗ₖ (V : Matrix _ _ ℂ))) := by classical dsimp only rw [unconditionalSelectedGaugeRetainedPOVMNaturality, unconditionalSelectedGaugeRetainedPOVMNaturality] unfold directDSVActualLocalPOVMWinningEffect simp_rw [unitaryConjugatePOVM_jointEffect] simp [Finset.mul_sum, Finset.sum_mul] theorem unconditionalActualFairSourceSelectedRetainedWinningBornGauge {X Y A B τ : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype τ] [DecidableEq τ] {P N d m : ℕ} (G : Game X Y A B) (alice bob : Matrix.unitaryGroup (Fin d) ℂ) (PA : POVM A (Fin d)) (PB : POVM B (Fin d)) (x : X) (y : Y) (z : EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × τ)) : let e := physical8SelectedGlobalTargetWorkEquiv P N d m let U := unconditionalMixedConjugateSigmaAtomLift (m := N * m) P alice let V := unconditionalMixedConjugateSigmaAtomLift (m := N * m) P bob quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × τ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM e (unitaryConjugatePOVM alice PA)) (directDSVActualReindexedRetainedPOVM e (unitaryConjugatePOVM bob PB)) x y ⊗ₖ (1 : Matrix τ τ ℂ))) z = quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × τ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM e PA) (directDSVActualReindexedRetainedPOVM e PB) x y ⊗ₖ (1 : Matrix τ τ ℂ))) (unconditionalMixedConjugateSelectedBranchLocalAction U V z) := by classical dsimp only rw [unconditionalActualFairSourceSelectedRetainedWinningEffectGauge] let UA := unconditionalMixedConjugateSigmaAtomLift (m := N * m) P alice let UB := unconditionalMixedConjugateSigmaAtomLift (m := N * m) P bob let e := physical8SelectedGlobalTargetWorkEquiv P N d m let selected : Type := UnconditionalSelectedCopyLocalIndex P d N m let E : Matrix (selected × selected) (selected × selected) ℂ := directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM e PA) (directDSVActualReindexedRetainedPOVM e PB) x y let K : Matrix (selected × selected) (selected × selected) ℂ := (UA : Matrix selected selected ℂ) ⊗ₖ (UB : Matrix selected selected ℂ) let W : Matrix ((selected × selected) × τ) ((selected × selected) × τ) ℂ := K ⊗ₖ (1 : Matrix τ τ ℂ) have transport : (Kᴴ * E * K) ⊗ₖ (1 : Matrix τ τ ℂ) = Wᴴ * (E ⊗ₖ (1 : Matrix τ τ ℂ)) * W := by calc (Kᴴ * E * K) ⊗ₖ (1 : Matrix τ τ ℂ) = (Kᴴ ⊗ₖ (1 : Matrix τ τ ℂ)) * (E ⊗ₖ (1 : Matrix τ τ ℂ)) * (K ⊗ₖ (1 : Matrix τ τ ℂ)) := by rw [← Matrix.mul_kronecker_mul, ← Matrix.mul_kronecker_mul] simp _ = Wᴴ * (E ⊗ₖ (1 : Matrix τ τ ℂ)) * W := by simp [W, Matrix.conjTranspose_kronecker] change quadraticExpectation (Matrix.toEuclideanCLM (n := (selected × selected) × τ) (𝕜 := ℂ) ((Kᴴ * E * K) ⊗ₖ (1 : Matrix τ τ ℂ))) z = quadraticExpectation (Matrix.toEuclideanCLM (n := (selected × selected) × τ) (𝕜 := ℂ) (E ⊗ₖ (1 : Matrix τ τ ℂ))) (unconditionalMixedConjugateSelectedBranchLocalAction UA UB z) rw [transport] exact (rectangular_matrix_quadratic_compression W (E ⊗ₖ (1 : Matrix τ τ ℂ)) z).symm end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable theorem unconditionalActualC485RetainedPureWorkReindexBorn {s t v : Type} [Fintype s] [DecidableEq s] [Fintype t] [DecidableEq t] [Fintype v] [DecidableEq v] (e : t ≃ v) (winning : Matrix s s ℂ) (z : EuclideanSpace ℂ (s × t)) : quadraticExpectation (Matrix.toEuclideanCLM (n := s × t) (𝕜 := ℂ) (winning ⊗ₖ (1 : Matrix t t ℂ))) z = quadraticExpectation (Matrix.toEuclideanCLM (n := s × v) (𝕜 := ℂ) (winning ⊗ₖ (1 : Matrix v v ℂ))) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl s) e) z) := by classical let whole : s × t ≃ s × v := Equiv.prodCongr (Equiv.refl s) e have actual_identity : Matrix.reindex whole.symm whole.symm (winning ⊗ₖ (1 : Matrix v v ℂ)) = winning ⊗ₖ (1 : Matrix t t ℂ) := by ext ⟨i, a⟩ ⟨j, b⟩ by_cases same : a = b · subst b simp [whole, Matrix.reindex_apply, Matrix.kroneckerMap_apply] · have different : e a ≠ e b := fun h => same (e.injective h) simp [whole, Matrix.reindex_apply, Matrix.kroneckerMap_apply, same, different] rw [← actual_identity] exact directDSVActualReindexedWinningEffect_quadratic whole (winning ⊗ₖ (1 : Matrix v v ℂ)) z def unconditionalActualC485RetainedHistoryPairEquiv {P N d L : ℕ} (j : Fin L) : (UnconditionalSourceFlagControlledRetainedIndex (N := N) (d := d) j (UnconditionalActualCanonicalRetainedPhaseIndex 1 P) × UnconditionalSourceFlagControlledRetainedIndex (N := N) (d := d) j (UnconditionalActualCanonicalRetainedPhaseIndex 1 P)) ≃ IntegratorActualC485RetainedIndex 1 P N d L j := unconditionalActualFixedSourceRetainedHistoryPairEquiv (N := N) (d := d) (R := UnconditionalActualCanonicalRetainedPhaseIndex 1 P) j theorem unconditionalActualC485FullBilateralWorkRegroup {P N d L m : ℕ} (j : Fin L) (z : EuclideanSpace ℂ (UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m × UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N d L m)) : LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) (unconditionalActualC485RetainedHistoryPairEquiv (P := P) (N := N) (d := d) j)) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv (N := N) (d := d) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) j) (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv (N := N) (d := d) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) j)) z) = unconditionalSourcePhysicalCleanedFullBilateralStateIsometry (unconditionalActualOneScaleFixedSourcePhaseSplit P) j z := by ext q rfl end noncomputable section open WithLp open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalWeightedClippedMatchedVerifierAndMassLoss {I K : Type*} [Fintype I] [Fintype K] (weight : I → ℝ) (weight_nonnegative : ∀ i, 0 ≤ weight i) (weight_normalized : (∑ i : I, weight i) = 1) (win : I → ℝ) (win_bounded : ∀ i, win i ≤ 1) {H : I × K → Type*} [∀ p, NormedAddCommGroup (H p)] [∀ p, InnerProductSpace ℂ (H p)] (effect : (p : I × K) → (H p →L[ℂ] H p)) (contraction : ∀ p, ‖effect p‖ ≤ 1) (actual canonical source : (p : I × K) → H p) (actual_mass : (∑ i : I, weight i * ∑ k : K, ‖actual (i, k)‖ ^ 2) ≤ 1) (canonical_mass : (∑ i : I, weight i * ∑ k : K, ‖canonical (i, k)‖ ^ 2) ≤ 1) (canonical_row_mass : ∀ i : I, (∑ k : K, ‖canonical (i, k)‖ ^ 2) ≤ 1) (same_work_mass : ∀ (i : I) (k : K), ‖source (i, k)‖ = ‖canonical (i, k)‖) (supported_born : ∀ (i : I), weight i ≠ 0 → ∀ k : K, quadraticExpectation (effect (i, k)) (source (i, k)) = ‖source (i, k)‖ ^ 2 * win i) (Δclean Δclip bad : ℝ) (clean_deviation : (∑ i : I, weight i * ∑ k : K, ‖actual (i, k) - canonical (i, k)‖ ^ 2) ≤ Δclean) (clip_deviation : (∑ i : I, weight i * ∑ k : K, ‖canonical (i, k) - source (i, k)‖ ^ 2) ≤ Δclip) (actual_success : 1 - bad ≤ ∑ i : I, weight i * ∑ k : K, ‖actual (i, k)‖ ^ 2) : (∑ i : I, weight i * win i) - bad - 4 * Real.sqrt Δclean - 2 * Real.sqrt Δclip ≤ ∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (actual (i, k)) := by classical let pairWeight : I × K → ℝ := fun p => weight p.1 have pair_nonnegative (p : I × K) : 0 ≤ pairWeight p := weight_nonnegative p.1 have pair_actual_mass : (∑ p : I × K, pairWeight p * ‖actual p‖ ^ 2) ≤ 1 := by simpa [pairWeight, Fintype.sum_prod_type, Finset.mul_sum] using actual_mass have pair_canonical_mass : (∑ p : I × K, pairWeight p * ‖canonical p‖ ^ 2) ≤ 1 := by simpa [pairWeight, Fintype.sum_prod_type, Finset.mul_sum] using canonical_mass have source_mass : (∑ i : I, weight i * ∑ k : K, ‖source (i, k)‖ ^ 2) ≤ 1 := by simpa only [same_work_mass] using canonical_mass have pair_source_mass : (∑ p : I × K, pairWeight p * ‖source p‖ ^ 2) ≤ 1 := by simpa [pairWeight, Fintype.sum_prod_type, Finset.mul_sum] using source_mass have pair_clean_deviation : (∑ p : I × K, pairWeight p * ‖actual p - canonical p‖ ^ 2) ≤ Δclean := by simpa [pairWeight, Fintype.sum_prod_type, Finset.mul_sum] using clean_deviation have pair_clip_deviation : (∑ p : I × K, pairWeight p * ‖canonical p - source p‖ ^ 2) ≤ Δclip := by simpa [pairWeight, Fintype.sum_prod_type, Finset.mul_sum] using clip_deviation have clean_verifier_gap : |(∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (actual (i, k))) - (∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (canonical (i, k)))| ≤ 2 * Real.sqrt Δclean := by simpa [pairWeight, Fintype.sum_prod_type, Finset.mul_sum] using (unconditionalMatchedVerifierAggregate_dependent_le pairWeight pair_nonnegative effect contraction actual canonical pair_actual_mass pair_canonical_mass Δclean pair_clean_deviation) have clip_verifier_gap : |(∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (canonical (i, k))) - (∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (source (i, k)))| ≤ 2 * Real.sqrt Δclip := by simpa [pairWeight, Fintype.sum_prod_type, Finset.mul_sum] using (unconditionalMatchedVerifierAggregate_dependent_le pairWeight pair_nonnegative effect contraction canonical source pair_canonical_mass pair_source_mass Δclip pair_clip_deviation) have identity_expectation (p : I × K) (v : H p) : quadraticExpectation (ContinuousLinearMap.id ℂ (H p)) v = ‖v‖ ^ 2 := by unfold quadraticExpectation change (⟪v, v⟫_ℂ).re = ‖v‖ ^ 2 exact (norm_sq_eq_re_inner (𝕜 := ℂ) v).symm have clean_mass_gap : |(∑ i : I, weight i * ∑ k : K, ‖actual (i, k)‖ ^ 2) - (∑ i : I, weight i * ∑ k : K, ‖canonical (i, k)‖ ^ 2)| ≤ 2 * Real.sqrt Δclean := by have bounded := unconditionalMatchedVerifierAggregate_dependent_le pairWeight pair_nonnegative (fun p => ContinuousLinearMap.id ℂ (H p)) (fun _ => ContinuousLinearMap.norm_id_le) actual canonical pair_actual_mass pair_canonical_mass Δclean pair_clean_deviation simpa [pairWeight, Fintype.sum_prod_type, Finset.mul_sum, identity_expectation] using bounded have source_row_mass (i : I) : (∑ k : K, ‖source (i, k)‖ ^ 2) ≤ 1 := by simpa only [same_work_mass] using canonical_row_mass i have ideal_payoff : (∑ i : I, weight i * win i) - (1 - ∑ i : I, weight i * ∑ k : K, ‖source (i, k)‖ ^ 2) ≤ ∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (source (i, k)) := by have born : (∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (source (i, k))) = ∑ i : I, weight i * ((∑ k : K, ‖source (i, k)‖ ^ 2) * win i) := by apply Finset.sum_congr rfl intro i _ by_cases zero : weight i = 0 · simp [zero] · congr 1 simp_rw [supported_born i zero] rw [Finset.sum_mul] rw [born] have lost_mass : (∑ i : I, weight i * (1 - ∑ k : K, ‖source (i, k)‖ ^ 2)) = 1 - ∑ i : I, weight i * ∑ k : K, ‖source (i, k)‖ ^ 2 := by calc (∑ i : I, weight i * (1 - ∑ k : K, ‖source (i, k)‖ ^ 2)) = (∑ i : I, weight i) - ∑ i : I, weight i * ∑ k : K, ‖source (i, k)‖ ^ 2 := by rw [← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i _ ring _ = _ := by rw [weight_normalized] calc (∑ i : I, weight i * win i) - (1 - ∑ i : I, weight i * ∑ k : K, ‖source (i, k)‖ ^ 2) = ∑ i : I, weight i * (win i - (1 - ∑ k : K, ‖source (i, k)‖ ^ 2)) := by rw [← lost_mass, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro i _ ring _ ≤ ∑ i : I, weight i * ((∑ k : K, ‖source (i, k)‖ ^ 2) * win i) := by apply Finset.sum_le_sum intro i _ apply mul_le_mul_of_nonneg_left _ (weight_nonnegative i) have loss := mul_nonneg (sub_nonneg.mpr (source_row_mass i)) (sub_nonneg.mpr (win_bounded i)) nlinarith have clean_verifier_signed : (∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (canonical (i, k))) - (∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (actual (i, k))) ≤ 2 * Real.sqrt Δclean := by exact (le_abs_self _).trans (by simpa [abs_sub_comm] using clean_verifier_gap) have clip_verifier_signed : (∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (source (i, k))) - (∑ i : I, weight i * ∑ k : K, quadraticExpectation (effect (i, k)) (canonical (i, k))) ≤ 2 * Real.sqrt Δclip := by exact (le_abs_self _).trans (by simpa [abs_sub_comm] using clip_verifier_gap) have clean_mass_signed : (∑ i : I, weight i * ∑ k : K, ‖actual (i, k)‖ ^ 2) - (∑ i : I, weight i * ∑ k : K, ‖source (i, k)‖ ^ 2) ≤ 2 * Real.sqrt Δclean := by simpa only [same_work_mass] using ((le_abs_self _).trans clean_mass_gap) linarith end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable theorem unconditionalFairPhysicalFlaggedStoppingTransfer {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (denominator_positive : 0 < denominator) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (rational_normalized : ∀ index, (∑ history, numerator index history) = denominator) (support_preserving : ∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) {L : ℕ} {ι : Fin (L + 1) → Type} [∀ r, Fintype (ι r)] [∀ r, DecidableEq (ι r)] (PA : ExactSourceSharedFlag X Y A B D denominator → (r : Fin (L + 1)) → X → POVM A (ι r)) (PB : ExactSourceSharedFlag X Y A B D denominator → (r : Fin (L + 1)) → Y → POVM B (ι r)) (U : ExactSourceSharedFlag X Y A B D denominator → X → Matrix.unitaryGroup (Σ r : Fin (L + 1), ι r) ℂ) (V : ExactSourceSharedFlag X Y A B D denominator → Y → Matrix.unitaryGroup (Σ r : Fin (L + 1), ι r) ℂ) (z : ExactSourceSharedFlag X Y A B D denominator → EuclideanSpace ℂ ((Σ r : Fin (L + 1), ι r) × (Σ r : Fin (L + 1), ι r))) (z_normalized : ∀ flag, ‖z flag‖ = 1) (matched : ExactSourceSharedFlag X Y A B D denominator × (X × Y) → Bool) {K : Type*} [Fintype K] {H : ExactLocallySampleableTuple X Y A B D × K → Type*} [∀ p, NormedAddCommGroup (H p)] [∀ p, InnerProductSpace ℂ (H p)] (effect : (p : ExactLocallySampleableTuple X Y A B D × K) → (H p →L[ℂ] H p)) (contraction : ∀ p, ‖effect p‖ ≤ 1) (actual canonical source : (p : ExactLocallySampleableTuple X Y A B D × K) → H p) (actual_mass : (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * ∑ k : K, ‖actual (h, k)‖ ^ 2) ≤ 1) (canonical_mass : (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * ∑ k : K, ‖canonical (h, k)‖ ^ 2) ≤ 1) (canonical_row_mass : ∀ h : ExactLocallySampleableTuple X Y A B D, (∑ k : K, ‖canonical (h, k)‖ ^ 2) ≤ 1) (same_work_mass : ∀ (h : ExactLocallySampleableTuple X Y A B D) (k : K), ‖source (h, k)‖ = ‖canonical (h, k)‖) (supported_born : ∀ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h ≠ 0 → ∀ k : K, quadraticExpectation (effect (h, k)) (source (h, k)) = ‖source (h, k)‖ ^ 2 * exactSourceConditionalWinningProbability G n S D h) (epsilon lam deviation clipping bad : ℝ) (clean_deviation : (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * ∑ k : K, ‖actual (h, k) - canonical (h, k)‖ ^ 2) ≤ deviation) (clip_deviation : (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * ∑ k : K, ‖canonical (h, k) - source (h, k)‖ ^ 2) ≤ clipping) (actual_success : 1 - bad ≤ ∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * ∑ k : K, ‖actual (h, k)‖ ^ 2) (history_born_nonnegative : ∀ h : ExactLocallySampleableTuple X Y A B D, 0 ≤ ∑ k : K, quadraticExpectation (effect (h, k)) (actual (h, k))) (history_born_bounded : ∀ h : ExactLocallySampleableTuple X Y A B D, (∑ k : K, quadraticExpectation (effect (h, k)) (actual (h, k))) ≤ 1) (source_failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < epsilon / 2) (total_variation : QuantumParallelRepetition.Pinsker.finiteTotalVariation (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactSourceAliceFlagCoupling G n S D denominator numerator nonempty) ≤ lam) (mismatch : (∑ outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y), flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator) outcome * if matched outcome then 0 else 1) ≤ 4 * lam) (matched_physical_branch : ∀ (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y), matched (flag, (x, y)) = true → (∑ k : K, quadraticExpectation (effect (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y)), k)) (actual (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y)), k))) ≤ ∑ j : Fin L, quadraticExpectation (Matrix.toEuclideanCLM (n := ι j.succ × ι j.succ) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G (PA flag) (PB flag) j.succ j.succ x y)) (actualStoppingBranchVector (actualStoppingQuestionLocalAction (U flag x) (V flag y) (z flag)) j.succ j.succ)) : 1 - epsilon / 2 - 5 * lam - (bad + 4 * Real.sqrt deviation + 2 * Real.sqrt clipping) ≤ (pureFlaggedStrategy G (exactSourceSharedFlagWeight D denominator) (exactSourceSharedFlagWeight_nonneg D denominator) (exactSourceSharedFlagWeight_sum D remaining denominator) z z_normalized (fun flag x => unitaryConjugatePOVM (U flag x) (dependentBlockPOVM (fun r => PA flag r x))) (fun flag y => unitaryConjugatePOVM (V flag y) (dependentBlockPOVM (fun r => PB flag r y)))).winProbability := by classical let weight : ExactSourceSharedFlag X Y A B D denominator → ℝ := exactSourceSharedFlagWeight D denominator let p : ExactSourceSharedFlag X Y A B D denominator × (X × Y) → ℝ := flaggedQuestionWeight G weight let q : ExactSourceSharedFlag X Y A B D denominator × (X × Y) → ℝ := exactSourceAliceFlagCoupling G n S D denominator numerator nonempty let history : ExactSourceSharedFlag X Y A B D denominator × (X × Y) → ExactLocallySampleableTuple X Y A B D := exactSourceAliceSampleTuple D denominator numerator nonempty let physical : ExactLocallySampleableTuple X Y A B D → ℝ := fun h => ∑ k : K, quadraticExpectation (effect (h, k)) (actual (h, k)) let flagPhysical : ExactSourceSharedFlag X Y A B D denominator × (X × Y) → ℝ := fun outcome => physical (history outcome) have weight_nonnegative : ∀ flag, 0 ≤ weight flag := exactSourceSharedFlagWeight_nonneg D denominator have weight_normalized : (∑ flag, weight flag) = 1 := exactSourceSharedFlagWeight_sum D remaining denominator have p_normalized : (∑ outcome, p outcome) = 1 := flaggedQuestionWeight_sum G weight weight_normalized have q_normalized : (∑ outcome, q outcome) = 1 := exactSourceAliceFlagCoupling_sum G n S D remaining positive base denominator denominator_positive numerator rational_normalized support_preserving nonempty have fair_verifier := unconditionalWeightedClippedMatchedVerifierAndMassLoss (exactLocallySampleableLaw G n S D) (exactLocallySampleableLaw_nonneg G n S D positive) (exactLocallySampleableLaw_sum G n S D remaining positive) (exactSourceConditionalWinningProbability G n S D) (fun h => (exactSourceConditionalWinningProbability_bounds G n S D positive h).2) effect contraction actual canonical source actual_mass canonical_mass canonical_row_mass same_work_mass supported_born deviation clipping bad clean_deviation clip_deviation actual_success have fair_win : 1 - epsilon / 2 ≤ ∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * exactSourceConditionalWinningProbability G n S D h := (exactSourceConditionalWinningProbability_gt_of_uniform_failure G n S D remaining positive source_failure).le have pushforward : (∑ outcome, q outcome * flagPhysical outcome) = ∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * physical h := by simpa [q, flagPhysical, history] using (exactSourceAliceFlagCoupling_expectation G n S D remaining positive base denominator denominator_positive numerator rational_normalized support_preserving nonempty physical) have flagPhysical_nonnegative (outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y)) : 0 ≤ flagPhysical outcome := history_born_nonnegative (history outcome) have flagPhysical_bounded (outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y)) : flagPhysical outcome ≤ 1 := history_born_bounded (history outcome) have variation : QuantumParallelRepetition.Pinsker.finiteTotalVariation p q ≤ lam := by simpa [p, q, weight] using total_variation have transferred := winning_expectation_transfer p q flagPhysical p_normalized q_normalized flagPhysical_nonnegative flagPhysical_bounded have p_nonnegative (outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y)) : 0 ≤ p outcome := flaggedQuestionWeight_nonneg G weight weight_nonnegative outcome have discarded := matched_payoff_discard_le p flagPhysical p_nonnegative flagPhysical_bounded matched have mismatch' : (∑ outcome, p outcome * if matched outcome then 0 else 1) ≤ 4 * lam := by simpa [p, weight] using mismatch have physical_transfer : 1 - epsilon / 2 - 5 * lam - (bad + 4 * Real.sqrt deviation + 2 * Real.sqrt clipping) ≤ ∑ outcome, p outcome * if matched outcome then flagPhysical outcome else 0 := by rw [← pushforward] at fair_verifier change (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * exactSourceConditionalWinningProbability G n S D h) - bad - 4 * Real.sqrt deviation - 2 * Real.sqrt clipping ≤ ∑ outcome, q outcome * flagPhysical outcome at fair_verifier linarith let stop : ExactSourceSharedFlag X Y A B D denominator × (X × Y) → ℝ := fun outcome => ∑ j : Fin L, quadraticExpectation (Matrix.toEuclideanCLM (n := ι j.succ × ι j.succ) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G (PA outcome.1) (PB outcome.1) j.succ j.succ outcome.2.1 outcome.2.2)) (actualStoppingBranchVector (actualStoppingQuestionLocalAction (U outcome.1 outcome.2.1) (V outcome.1 outcome.2.2) (z outcome.1)) j.succ j.succ) have stop_nonnegative (outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y)) : 0 ≤ stop outcome := by unfold stop apply Finset.sum_nonneg intro j _ exact actualStoppingBranchBorn_nonneg G (PA outcome.1) (PB outcome.1) (actualStoppingQuestionLocalAction (U outcome.1 outcome.2.1) (V outcome.1 outcome.2.2) (z outcome.1)) j.succ j.succ outcome.2.1 outcome.2.2 have matched_stop : (∑ outcome, p outcome * if matched outcome then flagPhysical outcome else 0) ≤ ∑ outcome, p outcome * stop outcome := by apply Finset.sum_le_sum intro outcome _ apply mul_le_mul_of_nonneg_left _ (p_nonnegative outcome) by_cases matching : matched outcome = true · simp only [matching, ite_true] rcases outcome with ⟨flag, x, y⟩ exact matched_physical_branch flag x y matching · have false_match : matched outcome = false := Bool.eq_false_of_not_eq_true matching simp only [false_match, Bool.false_eq] exact stop_nonnegative outcome have physical_stopping := actualStoppingQuestionLocalFlaggedWinningProbability_ge_matched G weight weight_nonnegative weight_normalized PA PB U V z z_normalized have reindex : (∑ outcome, p outcome * stop outcome) = ∑ flag, weight flag * (∑ x : X, ∑ y : Y, G.questionWeight x y * ∑ j : Fin L, quadraticExpectation (Matrix.toEuclideanCLM (n := ι j.succ × ι j.succ) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G (PA flag) (PB flag) j.succ j.succ x y)) (actualStoppingBranchVector (actualStoppingQuestionLocalAction (U flag x) (V flag y) (z flag)) j.succ j.succ)) := by simp only [p, flaggedQuestionWeight, stop, Fintype.sum_prod_type] simp_rw [Finset.mul_sum] apply Finset.sum_congr rfl intro flag _ apply Finset.sum_congr rfl intro x _ apply Finset.sum_congr rfl intro y _ ring_nf change 1 - epsilon / 2 - 5 * lam - (bad + 4 * Real.sqrt deviation + 2 * Real.sqrt clipping) ≤ (pureFlaggedStrategy G weight weight_nonnegative weight_normalized z z_normalized (fun flag x => unitaryConjugatePOVM (U flag x) (dependentBlockPOVM (fun r => PA flag r x))) (fun flag y => unitaryConjugatePOVM (V flag y) (dependentBlockPOVM (fun r => PB flag r y)))).winProbability rw [reindex] at matched_stop exact physical_transfer.trans (matched_stop.trans physical_stopping) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace def unconditionalActualLocalPOVMLosingEffect {X Y A B s t : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (G : Game X Y A B) (PA : POVM A s) (PB : POVM B t) (x : X) (y : Y) : Matrix (s × t) (s × t) ℂ := ∑ a : A, ∑ b : B, if G.predicate x y a b = true then 0 else PA.effect a ⊗ₖ PB.effect b theorem unconditionalActualLocalPOVMWinningEffect_posSemidef {X Y A B s t : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (G : Game X Y A B) (PA : POVM A s) (PB : POVM B t) (x : X) (y : Y) : (directDSVActualLocalPOVMWinningEffect G PA PB x y).PosSemidef := by classical apply Matrix.nonneg_iff_posSemidef.mp unfold directDSVActualLocalPOVMWinningEffect apply Finset.sum_nonneg intro a _ apply Finset.sum_nonneg intro b _ split · exact ((PA.positive a).kronecker (PB.positive b)).nonneg · exact le_rfl theorem unconditionalActualLocalPOVMLosingEffect_posSemidef {X Y A B s t : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (G : Game X Y A B) (PA : POVM A s) (PB : POVM B t) (x : X) (y : Y) : (unconditionalActualLocalPOVMLosingEffect G PA PB x y).PosSemidef := by classical apply Matrix.nonneg_iff_posSemidef.mp unfold unconditionalActualLocalPOVMLosingEffect apply Finset.sum_nonneg intro a _ apply Finset.sum_nonneg intro b _ split · exact le_rfl · exact ((PA.positive a).kronecker (PB.positive b)).nonneg theorem unconditionalActualLocalPOVMWinningEffect_add_losingEffect {X Y A B s t : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (G : Game X Y A B) (PA : POVM A s) (PB : POVM B t) (x : X) (y : Y) : directDSVActualLocalPOVMWinningEffect G PA PB x y + unconditionalActualLocalPOVMLosingEffect G PA PB x y = 1 := by classical change (∑ a : A, ∑ b : B, if G.predicate x y a b = true then PA.effect a ⊗ₖ PB.effect b else 0) + (∑ a : A, ∑ b : B, if G.predicate x y a b = true then 0 else PA.effect a ⊗ₖ PB.effect b) = 1 calc _ = ∑ a : A, ∑ b : B, PA.effect a ⊗ₖ PB.effect b := by rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro a _ rw [← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro b _ split <;> simp _ = (∑ a : A, PA.effect a) ⊗ₖ (∑ b : B, PB.effect b) := by ext ⟨i, j⟩ ⟨k, l⟩ simp only [Matrix.sum_apply, Matrix.kroneckerMap_apply] rw [Finset.sum_mul] simp_rw [Finset.mul_sum] _ = 1 := by rw [PA.complete, PB.complete] exact Matrix.one_kronecker_one theorem unconditionalActualLocalPOVMWinningEffect_complement_posSemidef {X Y A B s t : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [DecidableEq s] [DecidableEq t] (G : Game X Y A B) (PA : POVM A s) (PB : POVM B t) (x : X) (y : Y) : (1 - directDSVActualLocalPOVMWinningEffect G PA PB x y).PosSemidef := by have complete := unconditionalActualLocalPOVMWinningEffect_add_losingEffect G PA PB x y have partition : 1 - directDSVActualLocalPOVMWinningEffect G PA PB x y = unconditionalActualLocalPOVMLosingEffect G PA PB x y := by calc _ = (directDSVActualLocalPOVMWinningEffect G PA PB x y + unconditionalActualLocalPOVMLosingEffect G PA PB x y) - directDSVActualLocalPOVMWinningEffect G PA PB x y := by rw [complete] _ = _ := by abel rw [partition] exact unconditionalActualLocalPOVMLosingEffect_posSemidef G PA PB x y theorem unconditionalActualFairSourceVerifier_isPositive {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (j : Fin L) (x : X) (y : Y) : (integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j x y).IsPositive := by classical unfold integratorActualC485WinningEffect apply matrixEffectCLM_isPositive apply unconditionalMatchedVerifierEffect_tensor_posSemidef exact unconditionalActualLocalPOVMWinningEffect_posSemidef G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m y) x y theorem unconditionalActualFairSourceVerifier_complement_isPositive {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (j : Fin L) (x : X) (y : Y) : (1 - integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j x y).IsPositive := by classical unfold integratorActualC485WinningEffect apply matrixEffectCLM_complement_isPositive apply unconditionalMatchedVerifierEffect_tensor_complement_posSemidef exact unconditionalActualLocalPOVMWinningEffect_complement_posSemidef G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m y) x y theorem unconditionalActualFairSourceVerifier_norm_le_one {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (j : Fin L) (x : X) (y : Y) : ‖integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j x y‖ ≤ 1 := by classical unfold integratorActualC485WinningEffect apply unconditionalMatchedVerifierEffect_tensor_norm_le_one · exact unconditionalActualLocalPOVMWinningEffect_posSemidef G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m y) x y · exact unconditionalActualLocalPOVMWinningEffect_complement_posSemidef G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m y) x y theorem unconditionalActualFairSourceVerifier_born_nonnegative {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (j : Fin L) (x : X) (y : Y) (z : IntegratorActualC485BranchSpace 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m j) : 0 ≤ quadraticExpectation (integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j x y) z := positive_quadraticExpectation_nonneg _ (unconditionalActualFairSourceVerifier_isPositive G n S D a₀ b₀ j x y) z theorem unconditionalActualFairSourceVerifier_born_le_mass {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (j : Fin L) (x : X) (y : Y) (z : IntegratorActualC485BranchSpace 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m j) : quadraticExpectation (integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j x y) z ≤ ‖z‖ ^ 2 := positive_complement_quadraticExpectation_le _ (unconditionalActualFairSourceVerifier_complement_isPositive G n S D a₀ b₀ j x y) z theorem unconditionalActualFairSourceVerifier_historyBorn_bounds {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (actual : (h : ExactLocallySampleableTuple X Y A B D) → (j : Fin L) → IntegratorActualC485BranchSpace 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m j) (actual_row_mass : ∀ h : ExactLocallySampleableTuple X Y A B D, (∑ j : Fin L, ‖actual h j‖ ^ 2) ≤ 1) (h : ExactLocallySampleableTuple X Y A B D) : 0 ≤ (∑ j : Fin L, quadraticExpectation (integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j h.2.1 h.2.2.1) (actual h j)) ∧ (∑ j : Fin L, quadraticExpectation (integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j h.2.1 h.2.2.1) (actual h j)) ≤ 1 := by constructor · apply Finset.sum_nonneg intro j _ exact unconditionalActualFairSourceVerifier_born_nonnegative G n S D a₀ b₀ j h.2.1 h.2.2.1 (actual h j) · calc _ ≤ ∑ j : Fin L, ‖actual h j‖ ^ 2 := by apply Finset.sum_le_sum intro j _ exact unconditionalActualFairSourceVerifier_born_le_mass G n S D a₀ b₀ j h.2.1 h.2.2.1 (actual h j) _ ≤ 1 := actual_row_mass h theorem unconditionalActualFairSourceVerifier_historyBorn_nonnegative {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (actual : (h : ExactLocallySampleableTuple X Y A B D) → (j : Fin L) → IntegratorActualC485BranchSpace 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m j) (actual_row_mass : ∀ h : ExactLocallySampleableTuple X Y A B D, (∑ j : Fin L, ‖actual h j‖ ^ 2) ≤ 1) (h : ExactLocallySampleableTuple X Y A B D) : 0 ≤ (∑ j : Fin L, quadraticExpectation (integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j h.2.1 h.2.2.1) (actual h j)) := (unconditionalActualFairSourceVerifier_historyBorn_bounds G n S D a₀ b₀ actual actual_row_mass h).1 theorem unconditionalActualFairSourceVerifier_historyBorn_bounded {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (actual : (h : ExactLocallySampleableTuple X Y A B D) → (j : Fin L) → IntegratorActualC485BranchSpace 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m j) (actual_row_mass : ∀ h : ExactLocallySampleableTuple X Y A B D, (∑ j : Fin L, ‖actual h j‖ ^ 2) ≤ 1) (h : ExactLocallySampleableTuple X Y A B D) : (∑ j : Fin L, quadraticExpectation (integratorActualC485WinningEffect (P := P) (N := N) (m := m) G n S D a₀ b₀ j h.2.1 h.2.2.1) (actual h j)) ≤ 1 := (unconditionalActualFairSourceVerifier_historyBorn_bounds G n S D a₀ b₀ actual actual_row_mass h).2 def unconditionalActualC485FairSourceDiagonalWork {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (w : ℝ) (N P : ℕ) {L : ℕ} (schedule : Fin L → Fin 1) (u : ExactLocallySampleableTuple X Y A B D) (j : Fin L) : EuclideanSpace ℂ (IntegratorActualC485RetainedIndex 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L j) := integratorActualC485NormalizedDiagonalWork (S := 1) (B := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (fun _ : Fin 1 => w) schedule (unconditionalExactFairGammaUnit G n S D u) (exactGlobalHistoryFinPhi G n S D u.2.2.2 u.2.2.1) j def unconditionalActualC485FairSourceClipEnergy {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) {w : ℝ} {N P L m : ℕ} (width : 0 < w) (grid : 0 < N) (fine : (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) / (N : ℝ) < 1 / (w + 1)) (schedule : Fin L → Fin 1) : ℝ := ∑ u : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D u * ∑ j : Fin L, ‖unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState P (unconditionalConjugatePureVector (exactSourceTuplePsi G n S D u)) (fun _ _ _ => embezzlementState (N * m))) (unconditionalActualC485FairSourceDiagonalWork G n S D w N P schedule u j) - unconditionalMatchedVerifierTensor (dSVDensityRationalPublicBucketCoherentPhaseSigmaState P (unconditionalConjugatePureVector (dSVDensityRationalCanonicalAcceptedUnitTarget width grid fine (unconditionalExactFairGammaUnit G n S D u)).val) (fun _ _ _ => embezzlementState (N * m))) (unconditionalActualC485FairSourceDiagonalWork G n S D w N P schedule u j)‖ ^ 2 theorem unconditionalActualC485FairSourceDiagonalWork_row {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) {w : ℝ} {N P L m : ℕ} (width : 0 < w) (grid : 0 < N) (dimension : 0 < Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (phases : 0 < P) (harmonic : 0 < m) (schedule : Fin L → Fin 1) (u : ExactLocallySampleableTuple X Y A B D) : (∑ j : Fin L, ‖unconditionalActualC485FairSourceDiagonalWork G n S D w N P schedule u j‖ ^ 2) ≤ 1 := by exact unconditionalActualC485NormalizedDiagonalWork_mass_sum_le_one (S := 1) (B := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (m := m) phases grid dimension harmonic (fun _ : Fin 1 => w) (fun _ => width) schedule (unconditionalExactFairGammaUnit G n S D u) (exactGlobalHistoryFinPhi G n S D u.2.2.2 u.2.2.1) theorem unconditionalActualC485FairSourceClipEnergy_le {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (source_positive : 0 < repeatedPostselectionMass G n S D) {w : ℝ} {N P L m : ℕ} (width : 0 < w) (grid : 0 < N) (dimension : 0 < Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (fine : (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) / (N : ℝ) < 1 / (w + 1)) (phases : 0 < P) (harmonic : 0 < m) (schedule : Fin L → Fin 1) : unconditionalActualC485FairSourceClipEnergy (P := P) (m := m) G n S D width grid fine schedule ≤ 16 * martingaleRate G n S D + 8 * (1 / w + (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) * w / (N : ℝ)) := by exact unconditionalExactFairStoppedPhaseHarmonicClippedUnit_le G n S D remaining source_positive width grid fine phases (Nat.mul_pos grid harmonic) (fun p => unconditionalActualC485FairSourceDiagonalWork G n S D w N P schedule p.1 p.2) (fun u => unconditionalActualC485FairSourceDiagonalWork_row (m := m) G n S D width grid dimension phases harmonic schedule u) theorem unconditionalActualC485FairSourceClipEnergy_le_budget {X Y A B : Type*} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (source_positive : 0 < repeatedPostselectionMass G n S D) {w δ : ℝ} {N P L m : ℕ} (width : 0 < w) (grid : 0 < N) (dimension : 0 < Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (fine : (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) / (N : ℝ) < 1 / (w + 1)) (phases : 0 < P) (harmonic : 0 < m) (schedule : Fin L → Fin 1) (scalar : 1 / w + (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) * w / (N : ℝ) ≤ 3 * δ / 2) : unconditionalActualC485FairSourceClipEnergy (P := P) (m := m) G n S D width grid fine schedule ≤ 16 * martingaleRate G n S D + 8 * (3 * δ / 2) := by exact (unconditionalActualC485FairSourceClipEnergy_le (P := P) (m := m) G n S D remaining source_positive width grid dimension fine phases harmonic schedule).trans (by gcongr) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable theorem unconditionalActualFairSelectedLocalAction_norm_sq {ι τ : Type} [Fintype ι] [DecidableEq ι] [Fintype τ] [DecidableEq τ] (U V : Matrix.unitaryGroup ι ℂ) (z : EuclideanSpace ℂ ((ι × ι) × τ)) : ‖unconditionalMixedConjugateSelectedBranchLocalAction U V z‖ ^ 2 = ‖z‖ ^ 2 := by classical let M : Matrix ((ι × ι) × τ) ((ι × ι) × τ) ℂ := (unconditionalMixedConjugateSelectedBranchUnitary (τ := τ) U V : Matrix _ _ ℂ) have gram : M.conjTranspose * M = 1 := by simpa [M, Matrix.star_eq_conjTranspose] using (Matrix.mem_unitaryGroup_iff'.mp (unconditionalMixedConjugateSelectedBranchUnitary (τ := τ) U V).property) change ‖toLp 2 (M.mulVec (ofLp z))‖ ^ 2 = ‖z‖ ^ 2 rw [rectangular_matrix_mulVec_norm_sq, gram] simp [quadraticExpectation, ← Complex.ofReal_pow] theorem unconditionalActualFairCleanedVector_norm_sq {S B N d L m : Nat} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (Q : Nat) (A C : Fin B → Option Nat → Matrix.unitaryGroup (Fin (N * m)) ℂ) (j : Fin L) : ‖integratorActualC485CleanedVector Q width schedule ξ ζ A C j‖ ^ 2 = dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ j.val * dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ j.val := by letI : DecidableEq (IntegratorActualC485RetainedIndex S B N d L j) := FinEnum.decEq unfold integratorActualC485CleanedVector rw [unconditionalActualFairSelectedLocalAction_norm_sq] exact unconditionalSelectedCopyCleanedMatchedBranch_norm_sq phases grid harmonic width width_positive schedule ξ ζ Q A C j (unconditionalActualCanonicalRetainedPhaseTail (S := S) (B := B) (N := N) (d := d) (L := L) j) (integratorActualCanonicalRetainedPhaseTail_norm phases grid dimension j) theorem unconditionalActualFairCleanedRow_eq_stoppedSuccess {S B N d L m : Nat} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (Q : Nat) (A C : Fin B → Option Nat → Matrix.unitaryGroup (Fin (N * m)) ℂ) : (∑ j : Fin L, ‖integratorActualC485CleanedVector Q width schedule ξ ζ A C j‖ ^ 2) = dSVDensityRationalHeterogeneousPhysicalStoppedSuccessMass N width schedule ξ ζ := by simp_rw [unconditionalActualFairCleanedVector_norm_sq phases grid dimension harmonic width width_positive schedule ξ ζ Q A C] unfold dSVDensityRationalHeterogeneousPhysicalStoppedSuccessMass simpa using (Fin.sum_univ_eq_sum_range (fun k : Nat => dSVDensityRationalHeterogeneousPhysicalSurvival N width schedule ξ ζ k * dSVDensityRationalHeterogeneousPhysicalStageSuccess N width schedule ξ ζ k) L) theorem unconditionalActualFairCleanedRow_le_one {S B N d L m : Nat} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (Q : Nat) (A C : Fin B → Option Nat → Matrix.unitaryGroup (Fin (N * m)) ℂ) : (∑ j : Fin L, ‖integratorActualC485CleanedVector Q width schedule ξ ζ A C j‖ ^ 2) ≤ 1 := by rw [unconditionalActualFairCleanedRow_eq_stoppedSuccess phases grid dimension harmonic width width_positive schedule ξ ζ Q A C] have partition := dSVDensityRationalHeterogeneousPhysicalStopped_mass_partition grid dimension width schedule ξ ζ have asynchronous := dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass_nonneg N width schedule ξ ζ have terminal := dSVDensityRationalHeterogeneousPhysicalTerminalMass_nonneg N width schedule ξ ζ linarith theorem unconditionalActualFairWeightedCleanedMass_le_one {I : Type} [Fintype I] {S B N d L m : Nat} (weight : I → ℝ) (weight_nonnegative : ∀ h, 0 ≤ weight h) (weight_normalized : (∑ h : I, weight h) = 1) (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : I → BipartiteUnitVector d) (Q : Nat) (A C : Fin B → Option Nat → Matrix.unitaryGroup (Fin (N * m)) ℂ) : (∑ h : I, weight h * ∑ j : Fin L, ‖integratorActualC485CleanedVector Q width schedule (ξ h) (ζ h) A C j‖ ^ 2) ≤ 1 := by calc _ ≤ ∑ h : I, weight h * 1 := by apply Finset.sum_le_sum intro h _ exact mul_le_mul_of_nonneg_left (unconditionalActualFairCleanedRow_le_one phases grid dimension harmonic width width_positive schedule (ξ h) (ζ h) Q A C) (weight_nonnegative h) _ = 1 := by simpa using weight_normalized theorem unconditionalActualFairWeightedStoppedSuccess {I : Type} [Fintype I] {S B N d L m : Nat} (weight : I → ℝ) (weight_normalized : (∑ h : I, weight h) = 1) (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : I → BipartiteUnitVector d) (Q : Nat) (A C : Fin B → Option Nat → Matrix.unitaryGroup (Fin (N * m)) ℂ) (async terminal : ℝ) (asynchronous_bound : (∑ h : I, weight h * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ h) (ζ h)) ≤ async) (terminal_bound : (∑ h : I, weight h * dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule (ξ h) (ζ h)) ≤ terminal) : 1 - (async + terminal) ≤ ∑ h : I, weight h * ∑ j : Fin L, ‖integratorActualC485CleanedVector Q width schedule (ξ h) (ζ h) A C j‖ ^ 2 := by have partition : (∑ h : I, weight h * dSVDensityRationalHeterogeneousPhysicalStoppedSuccessMass N width schedule (ξ h) (ζ h)) + (∑ h : I, weight h * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ h) (ζ h)) + (∑ h : I, weight h * dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule (ξ h) (ζ h)) = 1 := by calc _ = ∑ h : I, weight h * (dSVDensityRationalHeterogeneousPhysicalStoppedSuccessMass N width schedule (ξ h) (ζ h) + dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ h) (ζ h) + dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule (ξ h) (ζ h)) := by simp_rw [mul_add, Finset.sum_add_distrib] _ = ∑ h : I, weight h := by apply Finset.sum_congr rfl intro h _ rw [dSVDensityRationalHeterogeneousPhysicalStopped_mass_partition grid dimension width schedule (ξ h) (ζ h)] ring _ = 1 := weight_normalized simp_rw [unconditionalActualFairCleanedRow_eq_stoppedSuccess phases grid dimension harmonic width width_positive schedule _ _ Q A C] linarith end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable theorem unconditionalActualFairCanonicalVector_norm_sq {S B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (harmonic : 0 < m) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (j : Fin L) (positive : 0 < width (schedule j)) (fine : (d : ℝ) / (N : ℝ) < 1 / (width (schedule j) + 1)) : ‖integratorActualC485CanonicalVector (B := B) (m := m) schedule ξ ζ j positive grid fine‖ ^ 2 = ‖integratorActualC485NormalizedDiagonalWork (B := B) (N := N) width schedule ξ ζ j‖ ^ 2 := by unfold integratorActualC485CanonicalVector rw [unconditionalMatchedVerifierTensor_norm_sq, unconditionalSelectedCopy_coherentPhaseConstantWork_norm_sq phases, unconditionalConjugatePureVector_norm_sq, (dSVDensityRationalCanonicalAcceptedUnitTarget positive grid fine ξ).property, embezzlementState_norm (N * m) (Nat.mul_pos grid harmonic)] ring theorem unconditionalActualFairCanonicalRow_le_one {S B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (fine : ∀ s, (d : ℝ) / (N : ℝ) < 1 / (width s + 1)) : (∑ j : Fin L, ‖integratorActualC485CanonicalVector (B := B) (m := m) schedule ξ ζ j (width_positive (schedule j)) grid (fine (schedule j))‖ ^ 2) ≤ 1 := by calc _ = ∑ j : Fin L, ‖integratorActualC485NormalizedDiagonalWork (B := B) (N := N) width schedule ξ ζ j‖ ^ 2 := by apply Finset.sum_congr rfl intro j _ exact unconditionalActualFairCanonicalVector_norm_sq phases grid harmonic width schedule ξ ζ j (width_positive (schedule j)) (fine (schedule j)) _ ≤ 1 := unconditionalActualC485NormalizedDiagonalWork_mass_sum_le_one (m := m) phases grid dimension harmonic width width_positive schedule ξ ζ theorem unconditionalActualFairWeightedCanonicalMass_le_one {I : Type} [Fintype I] {S B N d L m : ℕ} (weight : I → ℝ) (weight_nonnegative : ∀ h, 0 ≤ weight h) (weight_normalized : (∑ h : I, weight h) = 1) (phases : 0 < B) (grid : 0 < N) (dimension : 0 < d) (harmonic : 0 < m) (width : Fin S → ℝ) (width_positive : ∀ s, 0 < width s) (schedule : Fin L → Fin S) (ξ ζ : I → BipartiteUnitVector d) (fine : ∀ s, (d : ℝ) / (N : ℝ) < 1 / (width s + 1)) : (∑ h : I, weight h * ∑ j : Fin L, ‖integratorActualC485CanonicalVector (B := B) (m := m) schedule (ξ h) (ζ h) j (width_positive (schedule j)) grid (fine (schedule j))‖ ^ 2) ≤ 1 := by calc _ ≤ ∑ h : I, weight h * 1 := by apply Finset.sum_le_sum intro h _ exact mul_le_mul_of_nonneg_left (unconditionalActualFairCanonicalRow_le_one phases grid dimension harmonic width width_positive schedule (ξ h) (ζ h) fine) (weight_nonnegative h) _ = 1 := by simpa using weight_normalized end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace attribute [local instance] Classical.propDecidable theorem unconditionalActualFairSourceVector_norm_sq {S B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (harmonic : 0 < m) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (ψ : EuclideanSpace ℂ (Fin d × Fin d)) (unit : ‖ψ‖ = 1) (j : Fin L) : ‖integratorActualC485SourceVector (S := S) (B := B) (N := N) (d := d) (L := L) (m := m) width schedule ξ ζ ψ j‖ ^ 2 = ‖integratorActualC485NormalizedDiagonalWork (S := S) (B := B) (N := N) (d := d) (L := L) width schedule ξ ζ j‖ ^ 2 := by unfold integratorActualC485SourceVector rw [unconditionalMatchedVerifierTensor_norm_sq, unconditionalSelectedCopy_coherentPhaseConstantWork_norm_sq phases, unconditionalConjugatePureVector_norm_sq, unit, embezzlementState_norm (N * m) (Nat.mul_pos grid harmonic)] ring theorem unconditionalActualFairSourceCanonicalVector_norm_sq {S B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (harmonic : 0 < m) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (ψ : EuclideanSpace ℂ (Fin d × Fin d)) (unit : ‖ψ‖ = 1) (j : Fin L) (positive : 0 < width (schedule j)) (fine : (d : ℝ) / (N : ℝ) < 1 / (width (schedule j) + 1)) : ‖integratorActualC485SourceVector (S := S) (B := B) (N := N) (d := d) (L := L) (m := m) width schedule ξ ζ ψ j‖ ^ 2 = ‖integratorActualC485CanonicalVector (S := S) (B := B) (N := N) (d := d) (L := L) (m := m) (width := width) schedule ξ ζ j positive grid fine‖ ^ 2 := by rw [unconditionalActualFairSourceVector_norm_sq phases grid harmonic width schedule ξ ζ ψ unit j, unconditionalActualFairCanonicalVector_norm_sq phases grid harmonic width schedule ξ ζ j positive fine] theorem unconditionalActualFairSourceCanonicalVector_norm {S B N d L m : ℕ} (phases : 0 < B) (grid : 0 < N) (harmonic : 0 < m) (width : Fin S → ℝ) (schedule : Fin L → Fin S) (ξ ζ : BipartiteUnitVector d) (ψ : EuclideanSpace ℂ (Fin d × Fin d)) (unit : ‖ψ‖ = 1) (j : Fin L) (positive : 0 < width (schedule j)) (fine : (d : ℝ) / (N : ℝ) < 1 / (width (schedule j) + 1)) : ‖integratorActualC485SourceVector (S := S) (B := B) (N := N) (d := d) (L := L) (m := m) width schedule ξ ζ ψ j‖ = ‖integratorActualC485CanonicalVector (S := S) (B := B) (N := N) (d := d) (L := L) (m := m) (width := width) schedule ξ ζ j positive grid fine‖ := by have squared := unconditionalActualFairSourceCanonicalVector_norm_sq phases grid harmonic width schedule ξ ζ ψ unit j positive fine nlinarith [ norm_nonneg (integratorActualC485SourceVector (S := S) (B := B) (N := N) (d := d) (L := L) (m := m) width schedule ξ ζ ψ j), norm_nonneg (integratorActualC485CanonicalVector (S := S) (B := B) (N := N) (d := d) (L := L) (m := m) (width := width) schedule ξ ζ j positive grid fine)] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling open QuantumParallelRepetition.Pinsker attribute [local instance] Classical.propDecidable theorem unconditionalActualSourceSamplerBounds {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (gamma : ℝ) (gamma_positive : 0 < gamma) : ∃ (denominator : ℕ), 0 < denominator ∧ ∃ numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ, (∀ index, (∑ history, numerator index history) = denominator) ∧ (∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) ∧ ∃ nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty, QuantumParallelRepetition.Pinsker.finiteTotalVariation (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactSourceAliceFlagCoupling G n S D denominator numerator nonempty) ≤ exactSourcePinskerRate G n S D + gamma ∧ (∑ outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y), flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator) outcome * if exactSourcePermutationMatched D denominator numerator nonempty outcome then 0 else 1) ≤ 4 * (exactSourcePinskerRate G n S D + gamma) := by classical obtain ⟨denominator, denominator_positive, numerator, numerator_normalized, _approximation, preserves, nonempty, rounded_alice, _rounded_bob, sampler_mismatch⟩ := exact_source_equation_twenty_seven_support_preserving_unconditional G n S D remaining positive base gamma_positive refine ⟨denominator, denominator_positive, numerator, numerator_normalized, preserves, nonempty, ?_, ?_⟩ · rw [exactSourceAliceFlagCoupling_totalVariation G n S D remaining positive base denominator denominator_positive numerator numerator_normalized preserves nonempty, finiteTotalVariation_comm] exact rounded_alice · exact exactSourceSharedFlag_mismatch_le G n D denominator numerator nonempty sampler_mismatch end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalSourcePhysicalSameGridWeightedStoppingLedger {d N : ℕ} (dimension : 0 < d) (grid : 0 < N) (w δ : ℝ) (large : 1 ≤ w) (precision : 0 < δ) (bounded : δ ≤ 1) (grid_budget : 2 * (w + 1) * ((d : ℝ) / N) ≤ δ) (t : ℝ) (t_positive : 0 < t) (t_bounded : t ≤ 1) (rho : ℝ) (rho_positive : 0 < rho) {ι : Type} [Fintype ι] (weight : ι → ℝ) (weight_nonnegative : ∀ i, 0 ≤ weight i) (weight_normalized : (∑ i, weight i) = 1) (ξ ζ : ι → BipartiteUnitVector d) (eta : ℝ) (source_energy : (∑ i, weight i * ‖(ξ i).val - (ζ i).val‖ ^ 2) ≤ 32 * eta) : ∃ L B Q m : ℕ, 0 < L ∧ 0 < B ∧ 0 < Q ∧ 0 < m ∧ ∃ A C : Fin B → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ, let width : Fin 1 → ℝ := fun _ => w let schedule : Fin L → Fin 1 := fun _ => 0 (∀ i, dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ i) (ζ i) ≤ 8 * Real.sqrt 2 * ‖(ξ i).val - (ζ i).val‖ + δ) ∧ (∀ i, dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule (ξ i) (ζ i) ≤ δ ^ 2) ∧ ((∑ i, weight i * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ i) (ζ i)) ≤ 64 * Real.sqrt eta + δ) ∧ ((∑ i, weight i * dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule (ξ i) (ζ i)) ≤ δ ^ 2) ∧ ((∑ i, weight i * dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q m width schedule (ξ i) (ζ i) A C) ≤ (34 / t) * (64 * Real.sqrt eta + δ) + 4 * rho ^ 2 + (16 * (Real.exp 1 - 1) + 4) * t) := by classical have w_nonnegative : 0 ≤ w := by linarith obtain ⟨L, horizon_positive, tail⟩ := dSVDensityRationalHeterogeneousPhysical_exists_positive_horizon dimension w_nonnegative precision obtain ⟨B, Q, m, phases, resolution, harmonic, A, C, selected⟩ := exists_proofUnconditionalStoppedCommonPrefixBalancedHazard grid dimension t t_positive t_bounded rho rho_positive refine ⟨L, B, Q, m, horizon_positive, phases, resolution, harmonic, A, C, ?_⟩ let width : Fin 1 → ℝ := fun _ => w let schedule : Fin L → Fin 1 := fun _ => 0 have width_large : ∀ s : Fin 1, 1 ≤ width s := by intro s exact large have upper : ∀ s : Fin 1, width s ≤ w := by intro s exact le_rfl have fine : ∀ s : Fin 1, (d : ℝ) / N ≤ 1 / (2 * (width s + 1)) := by intro s have denominator : 0 < 2 * (width s + 1) := by dsimp [width] linarith apply (le_div_iff₀ denominator).mpr dsimp [width] nlinarith [grid_budget, bounded] have asynchronous (i : ι) : dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ i) (ζ i) ≤ 8 * Real.sqrt 2 * ‖(ξ i).val - (ζ i).val‖ + δ := by calc _ ≤ 8 * Real.sqrt 2 * ‖(ξ i).val - (ζ i).val‖ + 2 * (w + 1) * ((d : ℝ) / N) := dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass_le_targetDistance grid dimension width width_large fine upper w_nonnegative schedule (ξ i) (ζ i) _ ≤ _ := by linarith have terminal (i : ι) : dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule (ξ i) (ζ i) ≤ δ ^ 2 := dSVDensityRationalHeterogeneousPhysicalTerminalMass_le_horizon grid dimension width width_large fine w_nonnegative upper tail schedule (ξ i) (ζ i) have mean_asynchronous : (∑ i, weight i * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ i) (ζ i)) ≤ 64 * Real.sqrt eta + δ := unconditionalLiterature_weightedAsynchronous_le weight (fun i => ‖(ξ i).val - (ζ i).val‖) (fun i => dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ i) (ζ i)) weight_nonnegative weight_normalized (fun _ => norm_nonneg _) eta δ source_energy asynchronous have mean_terminal : (∑ i, weight i * dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule (ξ i) (ζ i)) ≤ δ ^ 2 := by calc _ ≤ ∑ i, weight i * δ ^ 2 := by apply Finset.sum_le_sum intro i _ exact mul_le_mul_of_nonneg_left (terminal i) (weight_nonnegative i) _ = (∑ i, weight i) * δ ^ 2 := by rw [Finset.sum_mul] _ = δ ^ 2 := by rw [weight_normalized, one_mul] have pointwise (i : ι) : dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q m width schedule (ξ i) (ζ i) A C ≤ (34 / t) * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ i) (ζ i) + (4 * rho ^ 2 + (16 * (Real.exp 1 - 1) + 4) * t) := by have actual := selected width schedule (ξ i) (ζ i) rw [dSVDensityRationalHeterogeneousActualAsynchronousFlagMass_eq_stoppedAsynchronousMass grid dimension width schedule (ξ i) (ζ i)] at actual linarith have mean_hazard := unconditionalSelectedCopy_weightedAffine weight (fun i => dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q m width schedule (ξ i) (ζ i) A C) (fun i => dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (ξ i) (ζ i)) weight_nonnegative weight_normalized (34 / t) (4 * rho ^ 2 + (16 * (Real.exp 1 - 1) + 4) * t) pointwise dsimp only refine ⟨asynchronous, terminal, mean_asynchronous, mean_terminal, ?_⟩ have scaled := mul_le_mul_of_nonneg_left mean_asynchronous (show 0 ≤ (34 : ℝ) / t by positivity) linarith end noncomputable section private theorem unconditionalSmallSource_eta_le_one (eta alpha : ℝ) (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (small : 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) ≤ 1) : eta ≤ 1 := by have delta_nonnegative : 0 ≤ alpha ^ (1 / 3 : ℝ) := Real.rpow_nonneg alpha_positive.le _ have root_nonnegative := Real.sqrt_nonneg eta have root_square := Real.sq_sqrt eta_nonnegative nlinarith private theorem unconditionalSmallSource_eta_scaled_root (eta : ℝ) (eta_nonnegative : 0 ≤ eta) : eta ^ (1 / 12 : ℝ) ≤ (32 * eta) ^ (1 / 12 : ℝ) := by apply Real.rpow_le_rpow eta_nonnegative · nlinarith · norm_num private theorem unconditionalSmallSource_root_estimates (eta alpha : ℝ) (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (small : 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) ≤ 1) : let δ := alpha ^ (1 / 3 : ℝ) let R := alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ) 0 ≤ R ∧ Real.sqrt eta ≤ R ∧ δ ≤ R ∧ δ ^ 2 ≤ R ∧ Real.sqrt δ ≤ R := by dsimp only let δ : ℝ := alpha ^ (1 / 3 : ℝ) let R : ℝ := alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ) have delta_nonnegative : 0 ≤ δ := Real.rpow_nonneg alpha_positive.le _ have delta_bounded : δ ≤ 1 := Real.rpow_le_one alpha_positive.le alpha_bounded (by norm_num) have alpha_root_nonnegative : 0 ≤ alpha ^ (1 / 12 : ℝ) := Real.rpow_nonneg alpha_positive.le _ have scaled_nonnegative : 0 ≤ (32 * eta) ^ (1 / 12 : ℝ) := Real.rpow_nonneg (by positivity) _ have root_nonnegative : 0 ≤ R := add_nonneg alpha_root_nonnegative scaled_nonnegative have eta_bounded := unconditionalSmallSource_eta_le_one eta alpha eta_nonnegative alpha_positive small have eta_scaled := unconditionalSmallSource_eta_scaled_root eta eta_nonnegative have eta_root : Real.sqrt eta ≤ eta ^ (1 / 12 : ℝ) := by rw [Real.sqrt_eq_rpow] exact Real.rpow_le_rpow_of_exponent_ge' eta_nonnegative eta_bounded (by norm_num : (0 : ℝ) ≤ 1 / 12) (by norm_num : (1 / 12 : ℝ) ≤ 1 / 2) have eta_bound : Real.sqrt eta ≤ R := by dsimp [R] linarith have delta_root : δ ≤ alpha ^ (1 / 12 : ℝ) := by dsimp [δ] exact Real.rpow_le_rpow_of_exponent_ge' alpha_positive.le alpha_bounded (by norm_num : (0 : ℝ) ≤ 1 / 12) (by norm_num : (1 / 12 : ℝ) ≤ 1 / 3) have delta_bound : δ ≤ R := by dsimp [R] linarith have delta_sq_bound : δ ^ 2 ≤ R := by nlinarith [mul_nonneg delta_nonnegative (sub_nonneg.mpr delta_bounded)] have delta_sqrt_eq : Real.sqrt δ = alpha ^ (1 / 6 : ℝ) := by dsimp [δ] rw [Real.sqrt_eq_rpow, ← Real.rpow_mul alpha_positive.le] norm_num have delta_sqrt_bound : Real.sqrt δ ≤ R := by rw [delta_sqrt_eq] have root_compare : alpha ^ (1 / 6 : ℝ) ≤ alpha ^ (1 / 12 : ℝ) := Real.rpow_le_rpow_of_exponent_ge' alpha_positive.le alpha_bounded (by norm_num : (0 : ℝ) ≤ 1 / 12) (by norm_num : (1 / 12 : ℝ) ≤ 1 / 6) dsimp [R] linarith exact ⟨root_nonnegative, eta_bound, delta_bound, delta_sq_bound, delta_sqrt_bound⟩ private theorem unconditionalSmallSource_clipping_sqrt_le (eta alpha clipping : ℝ) (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (small : 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) ≤ 1) (actual_clipping : clipping ≤ 16 * eta + 8 * (3 * alpha ^ (1 / 3 : ℝ) / 2)) : Real.sqrt clipping ≤ 8 * (alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ)) := by let δ : ℝ := alpha ^ (1 / 3 : ℝ) let R : ℝ := alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ) have bounds := unconditionalSmallSource_root_estimates eta alpha eta_nonnegative alpha_positive alpha_bounded small change 0 ≤ R ∧ Real.sqrt eta ≤ R ∧ δ ≤ R ∧ δ ^ 2 ≤ R ∧ Real.sqrt δ ≤ R at bounds have delta_nonnegative : 0 ≤ δ := Real.rpow_nonneg alpha_positive.le _ have clip_bound : clipping ≤ 16 * eta + 12 * δ := by change clipping ≤ 16 * eta + 8 * (3 * δ / 2) at actual_clipping nlinarith have clip_base_nonnegative : 0 ≤ 16 * eta + 12 * δ := by positivity have clip_sqrt_base : Real.sqrt (16 * eta + 12 * δ) ≤ 4 * Real.sqrt eta + 4 * Real.sqrt δ := by have eta_square := Real.sq_sqrt eta_nonnegative have delta_square := Real.sq_sqrt delta_nonnegative have clip_square := Real.sq_sqrt clip_base_nonnegative have cross := mul_nonneg (Real.sqrt_nonneg eta) (Real.sqrt_nonneg δ) have clip_root_nonnegative := Real.sqrt_nonneg (16 * eta + 12 * δ) have eta_root_nonnegative := Real.sqrt_nonneg eta have delta_root_nonnegative := Real.sqrt_nonneg δ nlinarith change Real.sqrt clipping ≤ 8 * R calc Real.sqrt clipping ≤ Real.sqrt (16 * eta + 12 * δ) := Real.sqrt_le_sqrt clip_bound _ ≤ 4 * Real.sqrt eta + 4 * Real.sqrt δ := clip_sqrt_base _ ≤ 8 * R := by linarith [bounds.2.1, bounds.2.2.2.2] private theorem unconditionalSmallSource_deviation_sqrt_le (eta alpha deviation : ℝ) (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (small : 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) ≤ 1) (actual_deviation : deviation ≤ (34 / Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) : Real.sqrt deviation ≤ (4 * Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) + 2) * (alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ)) := by let k : ℝ := 4 * Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) + 2 let R : ℝ := alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ) have k_nonnegative : 0 ≤ k := by dsimp [k] positivity have scaled := unconditionalSmallSource_eta_scaled_root eta eta_nonnegative have envelope := unconditionalPrefactor_smallHazard_twelfthRoot_le eta_nonnegative alpha_positive small change Real.sqrt deviation ≤ k * R calc Real.sqrt deviation ≤ Real.sqrt ((34 / Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) := Real.sqrt_le_sqrt actual_deviation _ ≤ k * (eta ^ (1 / 12 : ℝ) + alpha ^ (1 / 12 : ℝ)) := by simpa [k] using envelope _ ≤ k * R := by apply mul_le_mul_of_nonneg_left _ k_nonnegative dsimp [R] linarith theorem unconditionalSmallSourcePhysicalLoss (K eta alpha deviation clipping : ℝ) (constant : 1024 + 8 * (4 * Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) + 2) ≤ K) (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (small : 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) ≤ 1) (actual_deviation : deviation ≤ (34 / Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) (actual_clipping : clipping ≤ 16 * eta + 8 * (3 * alpha ^ (1 / 3 : ℝ) / 2)) : (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2) + 4 * Real.sqrt deviation + 4 * Real.sqrt clipping ≤ K * (alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ)) := by let δ : ℝ := alpha ^ (1 / 3 : ℝ) let R : ℝ := alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ) let k : ℝ := 4 * Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) + 2 have bounds := unconditionalSmallSource_root_estimates eta alpha eta_nonnegative alpha_positive alpha_bounded small change 0 ≤ R ∧ Real.sqrt eta ≤ R ∧ δ ≤ R ∧ δ ^ 2 ≤ R ∧ Real.sqrt δ ≤ R at bounds have R_nonnegative := bounds.1 have eta_sqrt_le_R := bounds.2.1 have delta_le_R := bounds.2.2.1 have delta_sq_le_R := bounds.2.2.2.1 have clip_sqrt_le := unconditionalSmallSource_clipping_sqrt_le eta alpha clipping eta_nonnegative alpha_positive alpha_bounded small actual_clipping change Real.sqrt clipping ≤ 8 * R at clip_sqrt_le have k_nonnegative : 0 ≤ k := by dsimp [k] positivity have deviation_sqrt_le := unconditionalSmallSource_deviation_sqrt_le eta alpha deviation eta_nonnegative alpha_positive small actual_deviation change Real.sqrt deviation ≤ k * R at deviation_sqrt_le have source_loss : 64 * Real.sqrt eta + δ + δ ^ 2 ≤ 66 * R := by nlinarith change (64 * Real.sqrt eta + δ + δ ^ 2) + 4 * Real.sqrt deviation + 4 * Real.sqrt clipping ≤ K * R calc (64 * Real.sqrt eta + δ + δ ^ 2) + 4 * Real.sqrt deviation + 4 * Real.sqrt clipping ≤ 66 * R + 4 * (k * R) + 4 * (8 * R) := by linarith _ ≤ (1024 + 8 * k) * R := by nlinarith [mul_nonneg k_nonnegative R_nonnegative] _ ≤ K * R := by apply mul_le_mul_of_nonneg_right _ R_nonnegative simpa [k] using constant theorem unconditionalSmallSourcePhysicalRoundedLower (K eta alpha deviation clipping epsilon lam actual : ℝ) (constant : 1024 + 8 * (4 * Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) + 2) ≤ K) (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (small : 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) ≤ 1) (actual_deviation : deviation ≤ (34 / Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ))) (actual_clipping : clipping ≤ 16 * eta + 8 * (3 * alpha ^ (1 / 3 : ℝ) / 2)) (lam_nonnegative : 0 ≤ lam) (actual_original_verifier : 1 - epsilon / 2 - 5 * lam - ((64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2) + 4 * Real.sqrt deviation + 4 * Real.sqrt clipping + 2 * Real.sqrt (8 * eta)) ≤ actual) : roundedWinningLowerBound epsilon K alpha eta lam ≤ actual := by let R : ℝ := alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ) have loss := unconditionalSmallSourcePhysicalLoss K eta alpha deviation clipping constant eta_nonnegative alpha_positive alpha_bounded small actual_deviation actual_clipping have K_nonnegative : 0 ≤ K := by have root_nonnegative := Real.sqrt_nonneg (34 + unconditionalPrefactorBucketCoefficient) linarith have R_nonnegative : 0 ≤ R := by dsimp [R] exact add_nonneg (Real.rpow_nonneg alpha_positive.le _) (Real.rpow_nonneg (by positivity) _) have ceiling_nonnegative : 0 ≤ universalErrorCeiling K := by unfold universalErrorCeiling have root_nonnegative := Real.rpow_nonneg (by norm_num : (0 : ℝ) ≤ 2) (1 / 6 : ℝ) nlinarith [mul_nonneg K_nonnegative (show 0 ≤ 1 + (2 : ℝ) ^ (1 / 6 : ℝ) by positivity)] have transfer_nonnegative : 0 ≤ universalErrorCeiling K * lam := mul_nonneg ceiling_nonnegative lam_nonnegative have quantum_nonnegative : 0 ≤ K * R := mul_nonneg K_nonnegative R_nonnegative change (64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2) + 4 * Real.sqrt deviation + 4 * Real.sqrt clipping ≤ K * R at loss unfold roundedWinningLowerBound totalSamplingLoss change 1 - epsilon / 2 - (5 * lam + 2 * (K * R + Real.sqrt (8 * eta) + universalErrorCeiling K * lam)) ≤ actual nlinarith end noncomputable section variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem pdfGreedyCeilingHorizon_le (n : ℕ) (τ d : ℝ) (threshold : 0 < τ) (small : d ≤ τ / 2) : ⌈d * (n : ℝ) / τ⌉₊ ≤ n := by apply Nat.ceil_le.mpr apply (div_le_iff₀ threshold).mpr have actual := mul_le_mul_of_nonneg_right small (Nat.cast_nonneg n : (0 : ℝ) ≤ n) nlinarith theorem pdfGreedyCeilingHorizon_pow_le_exp (n : ℕ) (τ d : ℝ) (threshold : 0 < τ) (at_most_one : τ ≤ 1) : (1 - τ) ^ ⌈d * (n : ℝ) / τ⌉₊ ≤ Real.exp (-d * (n : ℝ)) := by let T : ℕ := ⌈d * (n : ℝ) / τ⌉₊ have base_nonnegative : 0 ≤ 1 - τ := sub_nonneg.mpr at_most_one have base_le : 1 - τ ≤ Real.exp (-τ) := by have actual := Real.add_one_le_exp (-τ) linarith have ceiling : d * (n : ℝ) / τ ≤ (T : ℝ) := by exact Nat.le_ceil (d * (n : ℝ) / τ) have exponent : -τ * (T : ℝ) ≤ -d * (n : ℝ) := by have cleared := (div_le_iff₀ threshold).mp ceiling nlinarith change (1 - τ) ^ T ≤ Real.exp (-d * (n : ℝ)) calc (1 - τ) ^ T ≤ Real.exp (-τ) ^ T := by exact pow_le_pow_left₀ base_nonnegative base_le T _ = Real.exp (-τ * (T : ℝ)) := by rw [← Real.exp_nat_mul] congr 1 ring _ ≤ Real.exp (-d * (n : ℝ)) := Real.exp_le_exp.mpr exponent theorem pdfGreedyCard_lt_of_ceil (k n : ℕ) (τ d : ℝ) (below : k < ⌈d * (n : ℝ) / τ⌉₊) : (k : ℝ) < d * (n : ℝ) / τ := Nat.lt_ceil.mp below theorem pdfQuantitativeGreedyConditioning (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (τ d θ : ℝ) (_n_positive : 0 < n) (threshold : 0 < τ) (threshold_lt_one : τ < 1) (_rate_positive : 0 < d) (rate_small : d ≤ τ / 2) (above_exponential : Real.exp (-d * (n : ℝ)) < θ) (realized : θ ≤ S.winProbability) : ∃ D : Finset (Fin n), (D.card : ℝ) < d * (n : ℝ) / τ ∧ (n : ℝ) / 2 < ((Finset.univ \ D).card : ℝ) ∧ θ ≤ repeatedPostselectionMass G n S D ∧ S.winProbability ≤ repeatedPostselectionMass G n S D ∧ 0 < repeatedPostselectionMass G n S D ∧ 0 < (Finset.univ \ D).card ∧ uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < τ := by let T : ℕ := ⌈d * (n : ℝ) / τ⌉₊ have winning : 0 < S.winProbability := lt_of_lt_of_le ((Real.exp_pos _).trans above_exponential) realized have legal : T ≤ n := pdfGreedyCeilingHorizon_le n τ d threshold rate_small have terminal : (1 - τ) ^ T < S.winProbability := lt_of_le_of_lt (pdfGreedyCeilingHorizon_pow_le_exp n τ d threshold threshold_lt_one.le) (above_exponential.trans_le realized) obtain ⟨D, selected, floor, positive, remaining, failure⟩ := repeatedStrategy_exists_conditioning G n S winning threshold threshold_lt_one.le legal terminal have strict_card : (D.card : ℝ) < d * (n : ℝ) / τ := pdfGreedyCard_lt_of_ceil D.card n τ d selected have half_rate : d * (n : ℝ) / τ ≤ (n : ℝ) / 2 := by apply (div_le_iff₀ threshold).mpr have actual := mul_le_mul_of_nonneg_right rate_small (Nat.cast_nonneg n : (0 : ℝ) ≤ n) nlinarith have selected_le : D.card ≤ n := by have actual := Finset.card_le_card (Finset.subset_univ D) simpa using actual have remaining_real : ((Finset.univ \ D).card : ℝ) = (n : ℝ) - (D.card : ℝ) := by rw [remainingCoordinates_card, Nat.cast_sub selected_le] have more_than_half : (n : ℝ) / 2 < ((Finset.univ \ D).card : ℝ) := by rw [remaining_real] nlinarith exact ⟨D, strict_card, more_than_half, realized.trans floor, floor, positive, remaining, failure⟩ end noncomputable section def pdfUniversalRate (B : ℝ) : ℝ := 1 / (8 * (4 * B) ^ 12) def pdfGapRate (B ε ell : ℝ) : ℝ := pdfUniversalRate B * ε ^ 13 / (ε + ell) def pdfConditioningTolerance (ε : ℝ) : ℝ := ε / 4 def pdfCatalystAccuracy (K ε : ℝ) : ℝ := (ε / (16 * K)) ^ 12 theorem pdfUniversalRate_pos {B : ℝ} (positive : 0 < B) : 0 < pdfUniversalRate B := by unfold pdfUniversalRate positivity theorem pdfGapRate_pos {B ε ell : ℝ} (constant : 0 < B) (gap : 0 < ε) (alphabet : 0 ≤ ell) : 0 < pdfGapRate B ε ell := by unfold pdfGapRate have universal := pdfUniversalRate_pos constant positivity theorem pdfGapRate_eq_scaled_twelfth_power {B ε ell : ℝ} (constant : 0 < B) (gap : 0 < ε) (alphabet : 0 ≤ ell) : pdfGapRate B ε ell = ε / (8 * (ε + ell)) * (ε / (4 * B)) ^ 12 := by have nonzero : B ≠ 0 := ne_of_gt constant have denominator : ε + ell ≠ 0 := ne_of_gt (by linarith) unfold pdfGapRate pdfUniversalRate field_simp theorem pdfGapBase_le_gap {B ε : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) : 0 < ε / (4 * B) ∧ ε / (4 * B) ≤ ε := by have denominator : 0 < 4 * B := by nlinarith constructor · exact div_pos gap denominator · apply (div_le_iff₀ denominator).2 nlinarith theorem pdfGapBase_twelfth_le_gap {B ε : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) (unit : ε ≤ 1) : (ε / (4 * B)) ^ 12 ≤ ε := by obtain ⟨nonnegative, bounded⟩ := pdfGapBase_le_gap constant gap calc (ε / (4 * B)) ^ 12 ≤ ε ^ 12 := pow_le_pow_left₀ nonnegative.le bounded 12 _ = ε * ε ^ 11 := by ring _ ≤ ε * 1 := mul_le_mul_of_nonneg_left (pow_le_one₀ gap.le unit) gap.le _ = ε := by ring theorem pdfGapBase_twelfth_le_one {B ε : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) (unit : ε ≤ 1) : (ε / (4 * B)) ^ 12 ≤ 1 := (pdfGapBase_twelfth_le_gap constant gap unit).trans unit theorem pdfGapRate_le_gap_div_eight {B ε ell : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) (unit : ε ≤ 1) (alphabet : 0 ≤ ell) : pdfGapRate B ε ell ≤ ε / 8 := by have Bpositive : 0 < B := lt_of_lt_of_le (by norm_num) constant have denominator : 0 < ε + ell := by linarith have fraction : ε / (ε + ell) ≤ 1 := by apply (div_le_iff₀ denominator).2 linarith have root := pdfGapBase_twelfth_le_gap constant gap unit rw [pdfGapRate_eq_scaled_twelfth_power Bpositive gap alphabet] have nonnegative : 0 ≤ (ε / (4 * B)) ^ 12 := by positivity calc ε / (8 * (ε + ell)) * (ε / (4 * B)) ^ 12 = (ε / (ε + ell)) * (ε / (4 * B)) ^ 12 / 8 := by field_simp [ne_of_gt denominator, ne_of_gt Bpositive] _ ≤ 1 * ε / 8 := by gcongr _ = ε / 8 := by ring theorem pdfConditioningTolerance_bounds {ε : ℝ} (gap : 0 < ε) (unit : ε ≤ 1) : 0 < pdfConditioningTolerance ε ∧ pdfConditioningTolerance ε ≤ 1 / 4 := by unfold pdfConditioningTolerance constructor <;> nlinarith theorem pdfGapRate_le_half_conditioningTolerance {B ε ell : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) (unit : ε ≤ 1) (alphabet : 0 ≤ ell) : pdfGapRate B ε ell ≤ pdfConditioningTolerance ε / 2 := by have exact_rate := pdfGapRate_le_gap_div_eight constant gap unit alphabet calc pdfGapRate B ε ell ≤ ε / 8 := exact_rate _ = pdfConditioningTolerance ε / 2 := by unfold pdfConditioningTolerance ring theorem pdfGapRate_entropy_factor {B ε ell : ℝ} (constant : 0 < B) (gap : 0 < ε) (alphabet : 0 ≤ ell) : 2 * pdfGapRate B ε ell * (1 + 4 * ell / ε) = (ε / (4 * B)) ^ 12 * ((ε + 4 * ell) / (4 * (ε + ell))) := by have nonzero : B ≠ 0 := ne_of_gt constant have gap_nonzero : ε ≠ 0 := ne_of_gt gap have denominator : ε + ell ≠ 0 := ne_of_gt (by linarith) rw [pdfGapRate_eq_scaled_twelfth_power constant gap alphabet] field_simp ring theorem pdfAlphabetEntropyFactor_le_one {ε ell : ℝ} (gap : 0 < ε) (alphabet : 0 ≤ ell) : (ε + 4 * ell) / (4 * (ε + ell)) ≤ 1 := by have denominator : 0 < 4 * (ε + ell) := by positivity apply (div_le_iff₀ denominator).2 nlinarith theorem pdfGapRate_entropy_le_twelfth_power {B ε ell : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) (alphabet : 0 ≤ ell) : 2 * pdfGapRate B ε ell * (1 + 4 * ell / ε) ≤ (ε / (4 * B)) ^ 12 := by have Bpositive : 0 < B := lt_of_lt_of_le (by norm_num) constant rw [pdfGapRate_entropy_factor Bpositive gap alphabet] have nonnegative : 0 ≤ (ε / (4 * B)) ^ 12 := by positivity calc (ε / (4 * B)) ^ 12 * ((ε + 4 * ell) / (4 * (ε + ell))) ≤ (ε / (4 * B)) ^ 12 * 1 := mul_le_mul_of_nonneg_left (pdfAlphabetEntropyFactor_le_one gap alphabet) nonnegative _ = _ := by ring theorem pdfCatalystAccuracy_bounds {K ε : ℝ} (constant : 1 ≤ K) (gap : 0 < ε) (unit : ε ≤ 1) : 0 < pdfCatalystAccuracy K ε ∧ pdfCatalystAccuracy K ε ≤ 1 := by have denominator : 0 < 16 * K := by nlinarith have ratio : 0 < ε / (16 * K) := div_pos gap denominator have bounded : ε / (16 * K) ≤ 1 := by apply (div_le_iff₀ denominator).2 nlinarith unfold pdfCatalystAccuracy exact ⟨pow_pos ratio 12, pow_le_one₀ ratio.le bounded⟩ theorem pdfQuantitativeEntropyRate_lt {n m k : ℕ} {t d τ ell : ℝ} (length : 0 < n) (rate : 0 < d) (tolerance : 0 < τ) (alphabet : 0 ≤ ell) (remaining : (n : ℝ) / 2 < (m : ℝ)) (postselection : t < d * (n : ℝ)) (conditioned : (k : ℝ) < d * (n : ℝ) / τ) : (t + (k : ℝ) * ell) / (m : ℝ) < 2 * d * (1 + ell / τ) := by have length_real : (0 : ℝ) < (n : ℝ) := by exact_mod_cast length have mpositive : (0 : ℝ) < (m : ℝ) := by nlinarith have ratio_nonnegative : 0 ≤ ell / τ := div_nonneg alphabet tolerance.le have factor : 0 < d * (1 + ell / τ) := by exact mul_pos rate (by linarith) have alphabet_bound : (k : ℝ) * ell ≤ (d * (n : ℝ) / τ) * ell := mul_le_mul_of_nonneg_right (le_of_lt conditioned) alphabet have numerator : t + (k : ℝ) * ell < d * (n : ℝ) * (1 + ell / τ) := by calc t + (k : ℝ) * ell < d * (n : ℝ) + (d * (n : ℝ) / τ) * ell := add_lt_add_of_lt_of_le postselection alphabet_bound _ = d * (n : ℝ) * (1 + ell / τ) := by ring apply (div_lt_iff₀ mpositive).2 have horizon : (n : ℝ) < 2 * (m : ℝ) := by nlinarith have scaled := mul_lt_mul_of_pos_left horizon factor nlinarith theorem pdfQuantitativeEntropyRate_lt_twelfth_power {B ε ell : ℝ} {n m k : ℕ} {t : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) (unit : ε ≤ 1) (alphabet : 0 ≤ ell) (length : 0 < n) (remaining : (n : ℝ) / 2 < (m : ℝ)) (postselection : t < pdfGapRate B ε ell * (n : ℝ)) (conditioned : (k : ℝ) < pdfGapRate B ε ell * (n : ℝ) / pdfConditioningTolerance ε) : (t + (k : ℝ) * ell) / (m : ℝ) < (ε / (4 * B)) ^ 12 := by have Bpositive : 0 < B := lt_of_lt_of_le (by norm_num) constant have dpositive := pdfGapRate_pos Bpositive gap alphabet have taupositive : 0 < pdfConditioningTolerance ε := (pdfConditioningTolerance_bounds gap unit).1 have entropy := pdfQuantitativeEntropyRate_lt length dpositive taupositive alphabet remaining postselection conditioned have rewrite : 2 * pdfGapRate B ε ell * (1 + ell / pdfConditioningTolerance ε) = 2 * pdfGapRate B ε ell * (1 + 4 * ell / ε) := by unfold pdfConditioningTolerance have nonzero : ε ≠ 0 := ne_of_gt gap field_simp rw [rewrite] at entropy exact lt_of_lt_of_le entropy (pdfGapRate_entropy_le_twelfth_power constant gap alphabet) theorem pdfCatalystAccuracy_twelfth_root {K ε : ℝ} (constant : 1 ≤ K) (gap : 0 < ε) : (pdfCatalystAccuracy K ε) ^ (1 / 12 : ℝ) = ε / (16 * K) := by have denominator : 0 < 16 * K := by nlinarith have base : 0 ≤ ε / (16 * K) := (div_pos gap denominator).le unfold pdfCatalystAccuracy simpa [one_div] using (Real.pow_rpow_inv_natCast base (by norm_num : (12 : ℕ) ≠ 0)) theorem pdfGapBase_twelfth_root {B ε : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) : ((ε / (4 * B)) ^ (12 : ℕ)) ^ (1 / 12 : ℝ) = ε / (4 * B) := by have base : 0 ≤ ε / (4 * B) := (pdfGapBase_le_gap constant gap).1.le simpa [one_div] using (Real.pow_rpow_inv_natCast base (by norm_num : (12 : ℕ) ≠ 0)) theorem pdfEntropyRoot_lt_gapBase {B ε η : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) (entropy : 0 ≤ η) (small : η < (ε / (4 * B)) ^ (12 : ℕ)) : η ^ (1 / 12 : ℝ) < ε / (4 * B) := by calc η ^ (1 / 12 : ℝ) < ((ε / (4 * B)) ^ (12 : ℕ)) ^ (1 / 12 : ℝ) := Real.rpow_lt_rpow entropy small (by norm_num) _ = ε / (4 * B) := pdfGapBase_twelfth_root constant gap theorem pdfEntropyRoundingLoss_lt_gapQuarter {B ε η : ℝ} (constant : 1 ≤ B) (gap : 0 < ε) (entropy : 0 ≤ η) (small : η < (ε / (4 * B)) ^ (12 : ℕ)) : B * η ^ (1 / 12 : ℝ) < ε / 4 := by have coefficient : 0 < B := by linarith calc B * η ^ (1 / 12 : ℝ) < B * (ε / (4 * B)) := mul_lt_mul_of_pos_left (pdfEntropyRoot_lt_gapBase constant gap entropy small) coefficient _ = ε / 4 := by field_simp theorem pdfCatalystAccuracy_samplingLoss {K ε : ℝ} (constant : 1 ≤ K) (gap : 0 < ε) : 2 * K * (pdfCatalystAccuracy K ε) ^ (1 / 12 : ℝ) = ε / 8 := by have coefficient : 0 < K := by linarith rw [pdfCatalystAccuracy_twelfth_root constant gap] field_simp norm_num end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace def pdfRoundingCoefficient (K : ℝ) : ℝ := (5 + 2 * universalErrorCeiling K) * Real.sqrt (3 / 2 : ℝ) + 2 * K * (32 : ℝ) ^ (1 / 12 : ℝ) + 2 * Real.sqrt 8 theorem pdfUniversalErrorCeiling_pos {K : ℝ} (constant : 1 ≤ K) : 0 < universalErrorCeiling K := by have nonnegative : 0 ≤ K := by linarith unfold universalErrorCeiling positivity theorem pdfRoundingCoefficient_two_le {K : ℝ} (constant : 1 ≤ K) : 2 ≤ pdfRoundingCoefficient K := by have nonnegative : 0 ≤ K := by linarith have ceiling_nonnegative : 0 ≤ universalErrorCeiling K := (pdfUniversalErrorCeiling_pos constant).le have first_nonnegative : 0 ≤ (5 + 2 * universalErrorCeiling K) * Real.sqrt (3 / 2 : ℝ) := by positivity have quantum_nonnegative : 0 ≤ 2 * K * (32 : ℝ) ^ (1 / 12 : ℝ) := by positivity have eight : 1 ≤ Real.sqrt (8 : ℝ) := Real.one_le_sqrt.mpr (by norm_num) unfold pdfRoundingCoefficient nlinarith theorem pdfRoundingCoefficient_one_le {K : ℝ} (constant : 1 ≤ K) : 1 ≤ pdfRoundingCoefficient K := by have lower := pdfRoundingCoefficient_two_le constant linarith end noncomputable section theorem pdfSqrt_le_twelfthRoot {eta : ℝ} (nonnegative : 0 ≤ eta) (bounded : eta ≤ 1) : Real.sqrt eta ≤ eta ^ (1 / 12 : ℝ) := by rw [Real.sqrt_eq_rpow] exact Real.rpow_le_rpow_of_exponent_ge' nonnegative bounded (by norm_num) (by norm_num) theorem pdfPinskerRoot_le_twelfthRoot {eta kappa : ℝ} (nonnegative : 0 ≤ eta) (bounded : eta ≤ 1) (pinsker : kappa ≤ Real.sqrt ((3 / 2 : ℝ) * eta)) : kappa ≤ Real.sqrt (3 / 2 : ℝ) * eta ^ (1 / 12 : ℝ) := by calc kappa ≤ Real.sqrt ((3 / 2 : ℝ) * eta) := pinsker _ = Real.sqrt (3 / 2 : ℝ) * Real.sqrt eta := by rw [Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 3 / 2)] _ ≤ Real.sqrt (3 / 2 : ℝ) * eta ^ (1 / 12 : ℝ) := mul_le_mul_of_nonneg_left (pdfSqrt_le_twelfthRoot nonnegative bounded) (Real.sqrt_nonneg _) theorem pdfSqrtEight_le_twelfthRoot {eta : ℝ} (nonnegative : 0 ≤ eta) (bounded : eta ≤ 1) : Real.sqrt (8 * eta) ≤ Real.sqrt (8 : ℝ) * eta ^ (1 / 12 : ℝ) := by calc Real.sqrt (8 * eta) = Real.sqrt (8 : ℝ) * Real.sqrt eta := by rw [Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 8)] _ ≤ Real.sqrt (8 : ℝ) * eta ^ (1 / 12 : ℝ) := mul_le_mul_of_nonneg_left (pdfSqrt_le_twelfthRoot nonnegative bounded) (Real.sqrt_nonneg _) theorem pdfQuantitativeRoundingLoss {K alpha eta kappa gamma : ℝ} (constant : 0 ≤ K) (nonnegative : 0 ≤ eta) (bounded : eta ≤ 1) (pinsker : kappa ≤ Real.sqrt ((3 / 2 : ℝ) * eta)) : totalSamplingLoss K alpha eta (kappa + gamma) ≤ 2 * K * alpha ^ (1 / 12 : ℝ) + pdfRoundingCoefficient K * eta ^ (1 / 12 : ℝ) + (5 + 2 * universalErrorCeiling K) * gamma := by have ceiling : 0 ≤ universalErrorCeiling K := by unfold universalErrorCeiling positivity have classical_coefficient : 0 ≤ 5 + 2 * universalErrorCeiling K := by nlinarith have pinsker_bound := pdfPinskerRoot_le_twelfthRoot nonnegative bounded pinsker have weighted_pinsker : (5 + 2 * universalErrorCeiling K) * kappa ≤ (5 + 2 * universalErrorCeiling K) * (Real.sqrt (3 / 2 : ℝ) * eta ^ (1 / 12 : ℝ)) := mul_le_mul_of_nonneg_left pinsker_bound classical_coefficient have sqrt_bound := pdfSqrtEight_le_twelfthRoot nonnegative bounded have weighted_sqrt : 2 * Real.sqrt (8 * eta) ≤ 2 * (Real.sqrt (8 : ℝ) * eta ^ (1 / 12 : ℝ)) := mul_le_mul_of_nonneg_left sqrt_bound (by norm_num) have source_bounds := add_le_add weighted_pinsker weighted_sqrt calc totalSamplingLoss K alpha eta (kappa + gamma) = 2 * K * alpha ^ (1 / 12 : ℝ) + ((5 + 2 * universalErrorCeiling K) * kappa + 2 * Real.sqrt (8 * eta)) + 2 * K * ((32 : ℝ) ^ (1 / 12 : ℝ) * eta ^ (1 / 12 : ℝ)) + (5 + 2 * universalErrorCeiling K) * gamma := by unfold totalSamplingLoss rw [Real.mul_rpow (by norm_num : (0 : ℝ) ≤ 32) nonnegative] ring _ ≤ 2 * K * alpha ^ (1 / 12 : ℝ) + ((5 + 2 * universalErrorCeiling K) * (Real.sqrt (3 / 2 : ℝ) * eta ^ (1 / 12 : ℝ)) + 2 * (Real.sqrt (8 : ℝ) * eta ^ (1 / 12 : ℝ))) + 2 * K * ((32 : ℝ) ^ (1 / 12 : ℝ) * eta ^ (1 / 12 : ℝ)) + (5 + 2 * universalErrorCeiling K) * gamma := by gcongr _ = 2 * K * alpha ^ (1 / 12 : ℝ) + pdfRoundingCoefficient K * eta ^ (1 / 12 : ℝ) + (5 + 2 * universalErrorCeiling K) * gamma := by unfold pdfRoundingCoefficient ring variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] end noncomputable section variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem pdfExistsRepeatedStrategyAboveExponential (G : Game X Y A B) (n : ℕ) (d : ℝ) (failure : Real.exp (-d * (n : ℝ)) < repeatedEntangledValue G n) : ∃ S : Strategy (G.repeat n), Real.exp (-d * (n : ℝ)) < S.winProbability := exists_repeatedStrategy_of_lt_entangledValue G (Real.exp_pos _) failure theorem pdfFixedExponentialBound_of_sourceEquationTwentyNine (G : Game X Y A B) (n : ℕ) (d : ℝ) (construct : ∀ S : Strategy (G.repeat n), Real.exp (-d * (n : ℝ)) < S.winProbability → ∃ (rounded : Strategy G) (K₀ α η lam : ℝ), roundedWinningLowerBound (1 - entangledValue G) K₀ α η lam ≤ rounded.winProbability ∧ totalSamplingLoss K₀ α η lam < (1 - entangledValue G) / 2) : repeatedEntangledValue G n ≤ Real.exp (-d * (n : ℝ)) := by by_contra not_bound have failure : Real.exp (-d * (n : ℝ)) < repeatedEntangledValue G n := lt_of_not_ge not_bound obtain ⟨S, winning⟩ := pdfExistsRepeatedStrategyAboveExponential G n d failure obtain ⟨rounded, K₀, α, η, lam, bound, error⟩ := construct S winning exact source_equation_twenty_nine_contradiction G rounded K₀ α η lam bound error end noncomputable section open scoped BigOperators variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] theorem entangledValue_eq_zero_of_strategyWinProbability_eq_zero (G : Game X Y A B) (hzero : ∀ S : Strategy G, S.winProbability = 0) : entangledValue G = 0 := by apply le_antisymm _ (entangledValue_nonneg G) unfold entangledValue by_cases hnonempty : (Set.range (Strategy.winProbability (G := G))).Nonempty · apply csSup_le hnonempty rintro _ ⟨S, rfl⟩ exact le_of_eq (hzero S) · rw [Set.not_nonempty_iff_eq_empty.mp hnonempty, Real.sSup_empty] end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder attribute [local instance] Classical.propDecidable variable {X Y A B : Type*} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] def pdfConstantDensity : DensityMatrix (PUnit × PUnit) where matrix := 1 positive := Matrix.PosSemidef.one trace_one := by simp [Matrix.trace] def pdfConstantPOVM {C : Type*} [Fintype C] (answer : C) : POVM C PUnit := by classical exact { effect := fun c => if c = answer then 1 else 0 positive := by intro c split_ifs · exact Matrix.PosSemidef.one · exact Matrix.PosSemidef.zero complete := by simp } def pdfConstantStrategy (G : Game X Y A B) (a : A) (b : B) : Strategy G := by classical exact { Alice := PUnit Bob := PUnit state := pdfConstantDensity aliceMeasurement := fun _ => pdfConstantPOVM a bobMeasurement := fun _ => pdfConstantPOVM b } theorem pdfConstantStrategy_outcomeProbability (G : Game X Y A B) (a : A) (b : B) (x : X) (y : Y) (a' : A) (b' : B) : (pdfConstantStrategy G a b).outcomeProbability x y a' b' = if a' = a ∧ b' = b then 1 else 0 := by classical change (Matrix.trace ((1 : Matrix (PUnit × PUnit) (PUnit × PUnit) ℂ) * ((if a' = a then (1 : Matrix PUnit PUnit ℂ) else 0) ⊗ₖ (if b' = b then (1 : Matrix PUnit PUnit ℂ) else 0)))).re = _ by_cases alice : a' = a <;> by_cases bob : b' = b <;> simp [alice, bob, Matrix.trace_one] theorem pdfConstantStrategy_winProbability (G : Game X Y A B) (a : A) (b : B) : (pdfConstantStrategy G a b).winProbability = ∑ x : X, ∑ y : Y, if G.predicate x y a b = true then G.questionWeight x y else 0 := by classical have accepted_outcome (x : X) (y : Y) (a' : A) (b' : B) : (if G.predicate x y a' b' = true then (if a' = a ∧ b' = b then (1 : ℝ) else 0) else 0) = if a' = a then if b' = b then if G.predicate x y a b = true then 1 else 0 else 0 else 0 := by by_cases alice : a' = a <;> by_cases bob : b' = b <;> simp_all unfold Strategy.winProbability simp_rw [pdfConstantStrategy_outcomeProbability] simp_rw [accepted_outcome] simp [mul_ite] theorem pdfQuestionWeight_le_constantStrategy (G : Game X Y A B) (x : X) (y : Y) (a : A) (b : B) (accepted : G.predicate x y a b = true) : G.questionWeight x y ≤ (pdfConstantStrategy G a b).winProbability := by classical rw [pdfConstantStrategy_winProbability] calc G.questionWeight x y = if G.predicate x y a b = true then G.questionWeight x y else 0 := by simp [accepted] _ ≤ ∑ y' : Y, if G.predicate x y' a b = true then G.questionWeight x y' else 0 := by exact Finset.single_le_sum (f := fun y' : Y => if G.predicate x y' a b = true then G.questionWeight x y' else 0) (fun y' _ => by split_ifs <;> simp [G.weight_nonneg]) (Finset.mem_univ y) _ ≤ ∑ x' : X, ∑ y' : Y, if G.predicate x' y' a b = true then G.questionWeight x' y' else 0 := by exact Finset.single_le_sum (f := fun x' : X => ∑ y' : Y, if G.predicate x' y' a b = true then G.questionWeight x' y' else 0) (fun x' _ => Finset.sum_nonneg (fun y' _ => by split_ifs <;> simp [G.weight_nonneg])) (Finset.mem_univ x) theorem pdfPredicate_not_accepted_of_entangledValue_eq_zero (G : Game X Y A B) (zero : entangledValue G = 0) (x : X) (y : Y) (a : A) (b : B) (supported : 0 < G.questionWeight x y) : G.predicate x y a b ≠ true := by intro accepted have lower := pdfQuestionWeight_le_constantStrategy G x y a b accepted have upper : (pdfConstantStrategy G a b).winProbability ≤ entangledValue G := by unfold entangledValue exact le_csSup (winProbabilities_bddAbove G) ⟨pdfConstantStrategy G a b, rfl⟩ linarith theorem pdfRepeatedEntangledValue_eq_zero_of_entangledValue_eq_zero (G : Game X Y A B) (zero : entangledValue G = 0) {n : ℕ} (positive : 0 < n) : repeatedEntangledValue G n = 0 := by classical let i : Fin n := ⟨0, positive⟩ apply entangledValue_eq_zero_of_strategyWinProbability_eq_zero (G.repeat n) intro S unfold Strategy.winProbability apply Finset.sum_eq_zero intro xs _ apply Finset.sum_eq_zero intro ys _ by_cases zero_weight : (G.repeat n).questionWeight xs ys = 0 · change (G.repeat n).questionWeight xs ys * _ = 0 rw [zero_weight, zero_mul] · have local_nonzero : G.questionWeight (xs i) (ys i) ≠ 0 := by intro local_zero apply zero_weight rw [Game.repeat_questionWeight] exact Finset.prod_eq_zero (Finset.mem_univ i) local_zero have supported : 0 < G.questionWeight (xs i) (ys i) := lt_of_le_of_ne (G.weight_nonneg (xs i) (ys i)) local_nonzero.symm have never (as : Fin n → A) (bs : Fin n → B) : (G.repeat n).predicate xs ys as bs ≠ true := by intro accepted exact pdfPredicate_not_accepted_of_entangledValue_eq_zero G zero (xs i) (ys i) (as i) (bs i) supported ((Game.repeat_predicate_eq_true G n xs ys as bs).mp accepted i) simp [never] end noncomputable section theorem pdfAlphabetEntropy_nonneg {A B : Type} [Fintype A] [Fintype B] (alice : Nonempty A) (bob : Nonempty B) : 0 ≤ Real.log ((Fintype.card A : ℝ) * (Fintype.card B : ℝ)) := by have alice_card : 0 < Fintype.card A := Fintype.card_pos_iff.mpr alice have bob_card : 0 < Fintype.card B := Fintype.card_pos_iff.mpr bob have alice_real : (1 : ℝ) ≤ (Fintype.card A : ℝ) := by exact_mod_cast alice_card have bob_real : (1 : ℝ) ≤ (Fintype.card B : ℝ) := by exact_mod_cast bob_card apply Real.log_nonneg nlinarith [mul_nonneg (sub_nonneg.mpr alice_real) (sub_nonneg.mpr bob_real)] theorem pdfGap_le_one {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) : 1 - entangledValue G ≤ 1 := by have nonnegative := entangledValue_nonneg G linarith theorem pdfPostselectionLogCost_lt_of_exponential {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (d : ℝ) (above : Real.exp (-d * (n : ℝ)) < repeatedPostselectionMass G n S D) : postselectionLogCost G n S D < d * (n : ℝ) := by have logarithm := Real.log_lt_log (Real.exp_pos (-d * (n : ℝ))) above rw [Real.log_exp] at logarithm unfold postselectionLogCost rw [one_div, Real.log_inv] linarith theorem pdfPinskerRate_le_sqrt_martingaleRate {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (positive : 0 < repeatedPostselectionMass G n S D) : exactSourcePinskerRate G n S D ≤ Real.sqrt ((3 / 2 : ℝ) * martingaleRate G n S D) := by unfold exactSourcePinskerRate apply Real.sqrt_le_sqrt have information := exactSourceClassicalInformationRate_le_three_martingaleRate G n S D positive nlinarith theorem pdfActualMartingaleRate_lt_twelfth_power {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (Bqs ε ell : ℝ) (constant : 1 ≤ Bqs) (gap : 0 < ε) (unit : ε ≤ 1) (alphabet : 0 ≤ ell) (alphabet_eq : ell = Real.log ((Fintype.card A : ℝ) * (Fintype.card B : ℝ))) (length : 0 < n) (remaining : (n : ℝ) / 2 < ((Finset.univ \ D).card : ℝ)) (above : Real.exp (-pdfGapRate Bqs ε ell * (n : ℝ)) < repeatedPostselectionMass G n S D) (conditioned : (D.card : ℝ) < pdfGapRate Bqs ε ell * (n : ℝ) / pdfConditioningTolerance ε) : martingaleRate G n S D < (ε / (4 * Bqs)) ^ 12 := by have postselection := pdfPostselectionLogCost_lt_of_exponential G n S D (pdfGapRate Bqs ε ell) above have actual := pdfQuantitativeEntropyRate_lt_twelfth_power constant gap unit alphabet length remaining postselection conditioned simpa [martingaleRate, answerLogCost, alphabet_eq] using actual theorem pdfFullQuantitativeSamplingLoss {K ε eta kappa : ℝ} (constant : 1 ≤ K) (gap : 0 < ε) (unit : ε ≤ 1) (entropy : 0 ≤ eta) (small : eta < (ε / (4 * pdfRoundingCoefficient K)) ^ (12 : ℕ)) (pinsker : kappa ≤ Real.sqrt ((3 / 2 : ℝ) * eta)) : totalSamplingLoss K (pdfCatalystAccuracy K ε) eta (kappa + ε / (16 * (5 + 2 * universalErrorCeiling K))) < ε / 2 := by have coefficient : 1 ≤ pdfRoundingCoefficient K := pdfRoundingCoefficient_one_le constant have bounded : eta ≤ 1 := small.le.trans (pdfGapBase_twelfth_le_one coefficient gap unit) have loss := pdfQuantitativeRoundingLoss (K := K) (alpha := pdfCatalystAccuracy K ε) (eta := eta) (kappa := kappa) (gamma := ε / (16 * (5 + 2 * universalErrorCeiling K))) (by linarith) entropy bounded pinsker have entropy_loss : pdfRoundingCoefficient K * eta ^ (1 / 12 : ℝ) < ε / 4 := pdfEntropyRoundingLoss_lt_gapQuarter coefficient gap entropy small have catalyst_loss : 2 * K * (pdfCatalystAccuracy K ε) ^ (1 / 12 : ℝ) = ε / 8 := pdfCatalystAccuracy_samplingLoss constant gap have ceiling : 0 < universalErrorCeiling K := pdfUniversalErrorCeiling_pos constant have gamma_loss : (5 + 2 * universalErrorCeiling K) * (ε / (16 * (5 + 2 * universalErrorCeiling K))) = ε / 16 := by field_simp linarith theorem pdf_distributionUniformExponential_of_uniform_source_rounding (rounding : ∃ K : ℝ, 1 ≤ K ∧ ∀ {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)), 0 < (Finset.univ \ D).card → 0 < repeatedPostselectionMass G n S D → ∀ (alpha gamma : ℝ), 0 < alpha → alpha ≤ 1 → 0 < gamma → uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2 → ∃ rounded : Strategy G, roundedWinningLowerBound (1 - entangledValue G) K alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability) : ∃ c : ℝ, 0 < c ∧ ∀ {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B), Nonempty A → Nonempty B → 0 < 1 - entangledValue G → ∀ n : ℕ, 0 < n → repeatedEntangledValue G n ≤ Real.exp (-(c * ((1 - entangledValue G) ^ 13 / ((1 - entangledValue G) + Real.log ((Fintype.card A : ℝ) * (Fintype.card B : ℝ))))) * (n : ℝ)) := by obtain ⟨K, constant, round⟩ := rounding let Bqs : ℝ := pdfRoundingCoefficient K have coefficient : 1 ≤ Bqs := pdfRoundingCoefficient_one_le constant refine ⟨pdfUniversalRate Bqs, pdfUniversalRate_pos (by linarith), ?_⟩ intro X Y A B _ _ _ _ G alice bob game_gap n length by_cases zero : entangledValue G = 0 · rw [pdfRepeatedEntangledValue_eq_zero_of_entangledValue_eq_zero G zero length] exact (Real.exp_pos _).le · let ε : ℝ := 1 - entangledValue G let ell : ℝ := Real.log ((Fintype.card A : ℝ) * (Fintype.card B : ℝ)) let d : ℝ := pdfGapRate Bqs ε ell let τ : ℝ := pdfConditioningTolerance ε have gap : 0 < ε := by simpa [ε] using game_gap have unit : ε ≤ 1 := by simpa [ε] using pdfGap_le_one G have alphabet : 0 ≤ ell := by exact pdfAlphabetEntropy_nonneg alice bob have tolerance := pdfConditioningTolerance_bounds gap unit have tolerance_positive : 0 < τ := tolerance.1 have tolerance_lt_one : τ < 1 := by have at_most := tolerance.2 dsimp [τ] linarith have rate_positive : 0 < d := pdfGapRate_pos (by linarith) gap alphabet have rate_small : d ≤ τ / 2 := pdfGapRate_le_half_conditioningTolerance coefficient gap unit alphabet have exponential : repeatedEntangledValue G n ≤ Real.exp (-d * (n : ℝ)) := by apply pdfFixedExponentialBound_of_sourceEquationTwentyNine G n d intro S winning obtain ⟨D, selected, remaining_real, postselection_floor, _strategy_floor, positive, remaining, failure⟩ := pdfQuantitativeGreedyConditioning G n S τ d S.winProbability length tolerance_positive tolerance_lt_one rate_positive rate_small winning (le_refl _) have above : Real.exp (-d * (n : ℝ)) < repeatedPostselectionMass G n S D := winning.trans_le postselection_floor have small : martingaleRate G n S D < (ε / (4 * Bqs)) ^ (12 : ℕ) := by apply pdfActualMartingaleRate_lt_twelfth_power G n S D Bqs ε ell coefficient gap unit alphabet (by rfl) length remaining_real · exact above · exact selected have entropy : 0 ≤ martingaleRate G n S D := martingaleRate_nonneg G n S D remaining positive have pinsker : exactSourcePinskerRate G n S D ≤ Real.sqrt ((3 / 2 : ℝ) * martingaleRate G n S D) := pdfPinskerRate_le_sqrt_martingaleRate G n S D positive let alpha : ℝ := pdfCatalystAccuracy K ε let gamma : ℝ := ε / (16 * (5 + 2 * universalErrorCeiling K)) have alpha_bounds := pdfCatalystAccuracy_bounds constant gap unit have alpha_positive : 0 < alpha := alpha_bounds.1 have alpha_at_most_one : alpha ≤ 1 := alpha_bounds.2 have ceiling : 0 < universalErrorCeiling K := pdfUniversalErrorCeiling_pos constant have gamma_positive : 0 < gamma := by dsimp [gamma] positivity have source_failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2 := by change uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < ε / 2 have actual : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < ε / 4 := by simpa [τ, pdfConditioningTolerance] using failure linarith obtain ⟨rounded, rounded_bound⟩ := round G n S D remaining positive alpha gamma alpha_positive alpha_at_most_one gamma_positive source_failure refine ⟨rounded, K, alpha, martingaleRate G n S D, exactSourcePinskerRate G n S D + gamma, rounded_bound, ?_⟩ have actual_loss := pdfFullQuantitativeSamplingLoss constant gap unit entropy (show martingaleRate G n S D < (ε / (4 * pdfRoundingCoefficient K)) ^ (12 : ℕ) by simpa [Bqs] using small) pinsker change totalSamplingLoss K alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) < (1 - entangledValue G) / 2 simpa [alpha, gamma, ε] using actual_loss simpa [d, pdfGapRate, ε, ell, div_eq_mul_inv, mul_assoc] using exponential end noncomputable section open scoped BigOperators ComplexOrder Kronecker MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable def unconditionalSourcePhysicalRoundingUniversalConstant : ℝ := 1024 + 8 * (4 * Real.sqrt (34 + unconditionalPrefactorBucketCoefficient) + 2) theorem unconditionalSourcePhysicalRoundingUniversalConstant_ge : 128 ≤ unconditionalSourcePhysicalRoundingUniversalConstant := by unfold unconditionalSourcePhysicalRoundingUniversalConstant nlinarith [Real.sqrt_nonneg (34 + unconditionalPrefactorBucketCoefficient)] theorem unconditionalSourcePhysicalRounding_exists_sourceSampler {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (gamma : ℝ) (gamma_positive : 0 < gamma) : ∃ (base : ExactHistoryFlag X Y A B D) (denominator : ℕ), 0 < denominator ∧ ∃ numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ, (∀ index, (∑ history, numerator index history) = denominator) ∧ (∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) ∧ ∃ nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty, QuantumParallelRepetition.Pinsker.finiteTotalVariation (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactSourceAliceFlagCoupling G n S D denominator numerator nonempty) ≤ exactSourcePinskerRate G n S D + gamma ∧ (∑ outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y), flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator) outcome * if exactSourcePermutationMatched D denominator numerator nonempty outcome then 0 else 1) ≤ 4 * (exactSourcePinskerRate G n S D + gamma) := by classical let base : ExactHistoryFlag X Y A B D := Classical.choice (exactSourceHistoryFlag_nonempty_of_positive G n S D remaining positive) exact ⟨base, unconditionalActualSourceSamplerBounds G n S D remaining positive base gamma gamma_positive⟩ theorem unconditionalSourcePhysicalRounding_fairTargetEnergy {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) : (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * ‖(exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1).val - (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1).val‖ ^ 2) ≤ 32 * martingaleRate G n S D := by have distance := exactSourceStateDistanceBound_of_positive G n S D remaining positive simpa [exactSourceTupleGamma, exactSourceTuplePhi] using (exactSourceEquationTwentyOne_of_fifteen G n S D positive (martingaleRate G n S D) distance) theorem unconditionalSourcePhysicalRounding_exists_fairStoppingHazard {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (alpha : ℝ) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (small : 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1) : ∃ (w : ℝ) (N L B' Q m : ℕ), 1 ≤ w ∧ 0 < N ∧ 0 < L ∧ 0 < B' ∧ 0 < Q ∧ 0 < m ∧ 2 * (w + 1) * ((Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) / N) ≤ alpha ^ (1 / 3 : ℝ) ∧ (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) / (N : ℝ) < 1 / (w + 1) ∧ (1 / w + (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) * w / (N : ℝ) ≤ 3 * alpha ^ (1 / 3 : ℝ) / 2) ∧ ∃ UA UB : Fin B' → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ, let width : Fin 1 → ℝ := fun _ => w let schedule : Fin L → Fin 1 := fun _ => 0 let eta : ℝ := martingaleRate G n S D let delta : ℝ := alpha ^ (1 / 3 : ℝ) let t : ℝ := Real.sqrt (64 * Real.sqrt eta + delta) let rho : ℝ := alpha ^ (1 / 12 : ℝ) (∀ ξ : BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)), ‖ξ.val - dSVDensityRationalCanonicalAcceptedTarget w N ξ‖ ^ 2 ≤ 3 * delta / 2) ∧ ((∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N width schedule (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1)) ≤ 64 * Real.sqrt eta + delta) ∧ ((∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousPhysicalTerminalMass N width schedule (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1)) ≤ delta ^ 2) ∧ ((∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q m width schedule (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) UA UB) ≤ (34 / t) * (64 * Real.sqrt eta + delta) + 4 * rho ^ 2 + unconditionalPrefactorBucketCoefficient * t) := by classical let d : ℕ := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) have dimension : 0 < d := exactGlobalHistoryLocalIndex_card_pos G n S D let eta : ℝ := martingaleRate G n S D let delta : ℝ := alpha ^ (1 / 3 : ℝ) let t : ℝ := Real.sqrt (64 * Real.sqrt eta + delta) let rho : ℝ := alpha ^ (1 / 12 : ℝ) have eta_nonnegative : 0 ≤ eta := martingaleRate_nonneg G n S D remaining positive have delta_positive : 0 < delta := Real.rpow_pos_of_pos alpha_positive _ have delta_bounded : delta ≤ 1 := Real.rpow_le_one alpha_positive.le alpha_bounded (by norm_num) have t_positive : 0 < t := by dsimp [t] apply Real.sqrt_pos.2 nlinarith [Real.sqrt_nonneg eta] have t_bounded : t ≤ 1 := by dsimp [t] have bound : 64 * Real.sqrt eta + delta ≤ 1 := by simpa [eta, delta] using small nlinarith [Real.sqrt_nonneg (64 * Real.sqrt eta + delta), Real.sq_sqrt (show 0 ≤ 64 * Real.sqrt eta + delta by positivity)] have rho_positive : 0 < rho := Real.rpow_pos_of_pos alpha_positive _ obtain ⟨w, N, width_large, grid, budget, scalar, canonical, _⟩ := unconditionalExactSourceScalarClipping d dimension alpha alpha_positive alpha_bounded have precision_budget : 2 * (w + 1) * ((d : ℝ) / N) ≤ delta := by simpa [delta] using budget have grid_fine : (d : ℝ) / (N : ℝ) < 1 / (w + 1) := by apply (lt_div_iff₀ (show 0 < w + 1 by linarith only [width_large])).2 nlinarith only [precision_budget, delta_bounded] let law : ExactLocallySampleableTuple X Y A B D → ℝ := exactLocallySampleableLaw G n S D let gamma : ExactLocallySampleableTuple X Y A B D → BipartiteUnitVector d := fun h => exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1 let phi : ExactLocallySampleableTuple X Y A B D → BipartiteUnitVector d := fun h => exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1 have energy : (∑ h : ExactLocallySampleableTuple X Y A B D, law h * ‖(gamma h).val - (phi h).val‖ ^ 2) ≤ 32 * eta := by simpa [law, gamma, phi, eta] using unconditionalSourcePhysicalRounding_fairTargetEnergy G n S D remaining positive obtain ⟨L, B', Q, m, horizon, phases, resolution, harmonic, UA, UB, _pointwise, _tail, asynchronous, terminal, hazard⟩ := unconditionalSourcePhysicalSameGridWeightedStoppingLedger dimension grid w delta width_large delta_positive delta_bounded (by simpa [delta] using budget) t t_positive t_bounded rho rho_positive law (exactLocallySampleableLaw_nonneg G n S D positive) (exactLocallySampleableLaw_sum G n S D remaining positive) gamma phi eta energy refine ⟨w, N, L, B', Q, m, width_large, grid, horizon, phases, resolution, harmonic, ?_, ?_, ?_, UA, UB, ?_⟩ · exact budget · exact grid_fine · exact scalar dsimp only refine ⟨?_, ?_, ?_, ?_⟩ · exact canonical · exact asynchronous · exact terminal · change (∑ h : ExactLocallySampleableTuple X Y A B D, law h * dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q m (fun _ : Fin 1 => w) (fun _ : Fin L => 0) (gamma h) (phi h) UA UB) ≤ (34 / t) * (64 * Real.sqrt eta + delta) + 4 * rho ^ 2 + unconditionalPrefactorBucketCoefficient * t simpa only [unconditionalPrefactorBucketCoefficient] using hazard theorem unconditionalSourcePhysicalRounding_largeVerifierBound (K eta alpha lam epsilon : ℝ) (constant : 128 ≤ K) (eta_nonnegative : 0 ≤ eta) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (lam_nonnegative : 0 ≤ lam) (epsilon_nonnegative : 0 ≤ epsilon) (large : 1 < 64 * Real.sqrt eta + alpha ^ (1 / 3 : ℝ)) : roundedWinningLowerBound epsilon K alpha eta lam ≤ 0 := by have eta_root_nonnegative : 0 ≤ eta ^ (1 / 12 : ℝ) := Real.rpow_nonneg eta_nonnegative _ have alpha_root_nonnegative : 0 ≤ alpha ^ (1 / 12 : ℝ) := Real.rpow_nonneg alpha_positive.le _ have scaled_nonnegative : 0 ≤ (32 * eta) ^ (1 / 12 : ℝ) := Real.rpow_nonneg (by positivity) _ have root_scaled : eta ^ (1 / 12 : ℝ) ≤ (32 * eta) ^ (1 / 12 : ℝ) := by apply Real.rpow_le_rpow eta_nonnegative · nlinarith · norm_num have root_sum_nonnegative : 0 ≤ eta ^ (1 / 12 : ℝ) + alpha ^ (1 / 12 : ℝ) := add_nonneg eta_root_nonnegative alpha_root_nonnegative have constant_nonnegative : 0 ≤ K := by linarith have universal_nonnegative : 0 ≤ universalErrorCeiling K := by unfold universalErrorCeiling positivity have hazard := unconditionalPrefactor_largeVerifier_twelfthRoot_le eta_nonnegative alpha_positive alpha_bounded large have quantum : 2 ≤ K * (alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ)) := by calc (2 : ℝ) ≤ 128 * (eta ^ (1 / 12 : ℝ) + alpha ^ (1 / 12 : ℝ)) := hazard _ ≤ K * (alpha ^ (1 / 12 : ℝ) + (32 * eta) ^ (1 / 12 : ℝ)) := by apply mul_le_mul constant · linarith · exact root_sum_nonnegative · exact constant_nonnegative have lam_error : 0 ≤ universalErrorCeiling K * lam := mul_nonneg universal_nonnegative lam_nonnegative have sqrt_error : 0 ≤ Real.sqrt (8 * eta) := Real.sqrt_nonneg _ unfold roundedWinningLowerBound totalSamplingLoss nlinarith theorem unconditionalSourcePhysicalRounding_exists_large {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (K alpha gamma : ℝ) (constant : 128 ≤ K) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (gamma_positive : 0 < gamma) (large : 1 < 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) : ∃ rounded : Strategy G, roundedWinningLowerBound (1 - entangledValue G) K alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability := by classical obtain ⟨alice, bob⟩ := exactSourceAnswerTypes_nonempty_of_remaining G n S D remaining let rounded : Strategy G := pdfConstantStrategy G (Classical.choice alice) (Classical.choice bob) refine ⟨rounded, ?_⟩ have eta_nonnegative := martingaleRate_nonneg G n S D remaining positive have epsilon_nonnegative : 0 ≤ 1 - entangledValue G := by linarith [entangledValue_le_one G] have pinsker_nonnegative : 0 ≤ exactSourcePinskerRate G n S D := by unfold exactSourcePinskerRate positivity have source_bound := unconditionalSourcePhysicalRounding_largeVerifierBound K (martingaleRate G n S D) alpha (exactSourcePinskerRate G n S D + gamma) (1 - entangledValue G) constant eta_nonnegative alpha_positive alpha_bounded (by linarith) epsilon_nonnegative large exact source_bound.trans rounded.winProbability_nonneg theorem unconditionalSourcePhysicalRounding_smallRoundedLower {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (alpha gamma deviation clipping : ℝ) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (gamma_positive : 0 < gamma) (small : 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1) (actual_deviation : deviation ≤ (34 / Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) (actual_clipping : clipping ≤ 16 * martingaleRate G n S D + 8 * (3 * alpha ^ (1 / 3 : ℝ) / 2)) (rounded : Strategy G) (actual_original_verifier : 1 - (1 - entangledValue G) / 2 - 5 * (exactSourcePinskerRate G n S D + gamma) - ((64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2) + 4 * Real.sqrt deviation + 4 * Real.sqrt clipping + 2 * Real.sqrt (8 * martingaleRate G n S D)) ≤ rounded.winProbability) : roundedWinningLowerBound (1 - entangledValue G) unconditionalSourcePhysicalRoundingUniversalConstant alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability := by apply unconditionalSmallSourcePhysicalRoundedLower unconditionalSourcePhysicalRoundingUniversalConstant (martingaleRate G n S D) alpha deviation clipping (1 - entangledValue G) (exactSourcePinskerRate G n S D + gamma) rounded.winProbability · unfold unconditionalSourcePhysicalRoundingUniversalConstant exact le_rfl · exact martingaleRate_nonneg G n S D remaining positive · exact alpha_positive · exact alpha_bounded · exact small · exact actual_deviation · exact actual_clipping · have pinsker_nonnegative : 0 ≤ exactSourcePinskerRate G n S D := by unfold exactSourcePinskerRate positivity linarith · exact actual_original_verifier theorem unconditionalSourcePhysicalRounding_smallRoundedLower_of_stoppedVerifier {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (alpha gamma deviation clipping : ℝ) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (gamma_positive : 0 < gamma) (small : 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1) (actual_deviation : deviation ≤ (34 / Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) (actual_clipping : clipping ≤ 16 * martingaleRate G n S D + 8 * (3 * alpha ^ (1 / 3 : ℝ) / 2)) (rounded : Strategy G) (stopped_verifier : 1 - (1 - entangledValue G) / 2 - 5 * (exactSourcePinskerRate G n S D + gamma) - ((64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2) + 4 * Real.sqrt deviation + 2 * Real.sqrt clipping) ≤ rounded.winProbability) : roundedWinningLowerBound (1 - entangledValue G) unconditionalSourcePhysicalRoundingUniversalConstant alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability := by apply unconditionalSourcePhysicalRounding_smallRoundedLower G n S D remaining positive alpha gamma deviation clipping alpha_positive alpha_bounded gamma_positive small actual_deviation actual_clipping rounded nlinarith [Real.sqrt_nonneg clipping, Real.sqrt_nonneg (8 * martingaleRate G n S D)] theorem unconditionalSourceOneGameRounding_uniform_of_small (small_rounding : ∀ {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)), 0 < (Finset.univ \ D).card → 0 < repeatedPostselectionMass G n S D → ∀ (alpha gamma : ℝ), 0 < alpha → alpha ≤ 1 → 0 < gamma → 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1 → uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2 → ∃ rounded : Strategy G, roundedWinningLowerBound (1 - entangledValue G) unconditionalSourcePhysicalRoundingUniversalConstant alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability) : ∃ K : ℝ, 1 ≤ K ∧ ∀ {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)), 0 < (Finset.univ \ D).card → 0 < repeatedPostselectionMass G n S D → ∀ (alpha gamma : ℝ), 0 < alpha → alpha ≤ 1 → 0 < gamma → uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2 → ∃ rounded : Strategy G, roundedWinningLowerBound (1 - entangledValue G) K alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability := by refine ⟨unconditionalSourcePhysicalRoundingUniversalConstant, ?_, ?_⟩ · linarith [unconditionalSourcePhysicalRoundingUniversalConstant_ge] intro X Y A B _ _ _ _ G n S D remaining positive alpha gamma alpha_positive alpha_bounded gamma_positive failure by_cases small : 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1 · exact small_rounding G n S D remaining positive alpha gamma alpha_positive alpha_bounded gamma_positive small failure · exact unconditionalSourcePhysicalRounding_exists_large G n S D remaining positive unconditionalSourcePhysicalRoundingUniversalConstant alpha gamma unconditionalSourcePhysicalRoundingUniversalConstant_ge alpha_positive alpha_bounded gamma_positive (lt_of_not_ge small) end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalActualC485GenericRetainedWinningBorn {X Y A B s t u v ι κ : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype s] [Fintype t] [Fintype u] [Fintype v] [Fintype ι] [Fintype κ] [DecidableEq s] [DecidableEq t] [DecidableEq u] [DecidableEq v] [DecidableEq ι] [DecidableEq κ] (G : Game X Y A B) (eA : ι ≃ s × t) (eB : κ ≃ u × v) (PA : POVM A s) (PB : POVM B u) (x : X) (y : Y) (z : EuclideanSpace ℂ (ι × κ)) : quadraticExpectation (Matrix.toEuclideanCLM (n := ι × κ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM eA PA) (directDSVActualReindexedRetainedPOVM eB PB) x y)) z = quadraticExpectation (Matrix.toEuclideanCLM (n := (s × u) × (t × v)) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G PA PB x y ⊗ₖ (1 : Matrix (t × v) (t × v) ℂ))) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z) := by rw [directDSVActualReindexedRetainedPOVMWinningEffect, directDSVActualReindexedWinningEffect_quadratic] theorem unconditionalActualC485GenericSelectedWinningRegroupGauge {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {P N d m : ℕ} {ι κ R T : Type} [Fintype ι] [Fintype κ] [Fintype R] [Fintype T] [DecidableEq ι] [DecidableEq κ] [DecidableEq R] [DecidableEq T] (G : Game X Y A B) (alice bob : Matrix.unitaryGroup (Fin d) ℂ) (PA : POVM A (Fin d)) (PB : POVM B (Fin d)) (eA : ι ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (eB : κ ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (pair : R × R ≃ T) (x : X) (y : Y) (z : EuclideanSpace ℂ (ι × κ)) : let selected := UnconditionalSelectedCopyLocalIndex P d N m let stage := physical8SelectedGlobalTargetWorkEquiv P N d m let gaugedAlice := directDSVActualReindexedRetainedPOVM stage (unitaryConjugatePOVM alice PA) let gaugedBob := directDSVActualReindexedRetainedPOVM stage (unitaryConjugatePOVM bob PB) let plainAlice := directDSVActualReindexedRetainedPOVM stage PA let plainBob := directDSVActualReindexedRetainedPOVM stage PB let regrouped := LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (selected × selected)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z) quadraticExpectation (Matrix.toEuclideanCLM (n := ι × κ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM eA gaugedAlice) (directDSVActualReindexedRetainedPOVM eB gaugedBob) x y)) z = quadraticExpectation (Matrix.toEuclideanCLM (n := (selected × selected) × T) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G plainAlice plainBob x y ⊗ₖ (1 : Matrix T T ℂ))) (unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P alice) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P bob) regrouped) := by dsimp only calc _ = quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × (R × R)) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM alice PA)) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM bob PB)) x y ⊗ₖ (1 : Matrix (R × R) (R × R) ℂ))) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z) := unconditionalActualC485GenericRetainedWinningBorn G eA eB (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM alice PA)) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM bob PB)) x y z _ = quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM alice PA)) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM bob PB)) x y ⊗ₖ (1 : Matrix T T ℂ))) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z)) := unconditionalActualC485RetainedPureWorkReindexBorn pair (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM alice PA)) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM bob PB)) x y) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z) _ = _ := unconditionalActualFairSourceSelectedRetainedWinningBornGauge G alice bob PA PB x y (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z)) theorem unconditionalActualC485GenericDecodedWinningBorn {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {P N d m : ℕ} {ι κ R T : Type} [Fintype ι] [Fintype κ] [Fintype R] [Fintype T] [DecidableEq ι] [DecidableEq κ] [DecidableEq R] [DecidableEq T] (G : Game X Y A B) (alice bob : Matrix.unitaryGroup (Fin d) ℂ) (PA : POVM A (Fin d)) (PB : POVM B (Fin d)) (eA : ι ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (eB : κ ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (pair : R × R ≃ T) (x : X) (y : Y) (z : EuclideanSpace ℂ (ι × κ)) (actual : EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T)) (decoded : unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P alice) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P bob) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z)) = actual) : let selected := UnconditionalSelectedCopyLocalIndex P d N m let stage := physical8SelectedGlobalTargetWorkEquiv P N d m quadraticExpectation (Matrix.toEuclideanCLM (n := (selected × selected) × T) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM stage PA) (directDSVActualReindexedRetainedPOVM stage PB) x y ⊗ₖ (1 : Matrix T T ℂ))) actual = quadraticExpectation (Matrix.toEuclideanCLM (n := ι × κ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM eA (directDSVActualReindexedRetainedPOVM stage (unitaryConjugatePOVM alice PA))) (directDSVActualReindexedRetainedPOVM eB (directDSVActualReindexedRetainedPOVM stage (unitaryConjugatePOVM bob PB))) x y)) z := by dsimp only have physical := unconditionalActualC485GenericSelectedWinningRegroupGauge G alice bob PA PB eA eB pair x y z dsimp only at physical rw [decoded] at physical exact physical.symm theorem unconditionalActualC485SourceSelectedDecodedWinningBorn {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {P N d m : ℕ} {ι κ R T : Type} [Fintype ι] [Fintype κ] [Fintype R] [Fintype T] [DecidableEq ι] [DecidableEq κ] [DecidableEq R] [DecidableEq T] (G : Game X Y A B) (alice bob : Matrix.unitaryGroup (Fin d) ℂ) (PA : POVM A (Fin d)) (PB : POVM B (Fin d)) (selectedA : POVM A (UnconditionalSelectedCopyLocalIndex P d N m)) (selectedB : POVM B (UnconditionalSelectedCopyLocalIndex P d N m)) (selectedA_eq : selectedA = directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) PA) (selectedB_eq : selectedB = directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) PB) (eA : ι ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (eB : κ ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (pair : R × R ≃ T) (x : X) (y : Y) (z : EuclideanSpace ℂ (ι × κ)) (actual : EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T)) (decoded : unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P alice) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P bob) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z)) = actual) : quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G selectedA selectedB x y ⊗ₖ (1 : Matrix T T ℂ))) actual = quadraticExpectation (Matrix.toEuclideanCLM (n := ι × κ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G (directDSVActualReindexedRetainedPOVM eA (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM alice PA))) (directDSVActualReindexedRetainedPOVM eB (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM bob PB))) x y)) z := by subst selectedA subst selectedB exact unconditionalActualC485GenericDecodedWinningBorn G alice bob PA PB eA eB pair x y z actual decoded theorem unconditionalActualC485CompleteDecodedPhysicalBorn {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {P N d m : ℕ} {ι κ R T : Type} [Fintype ι] [Fintype κ] [Fintype R] [Fintype T] [DecidableEq ι] [DecidableEq κ] [DecidableEq R] [DecidableEq T] (G : Game X Y A B) (alice bob : Matrix.unitaryGroup (Fin d) ℂ) (PA : POVM A (Fin d)) (PB : POVM B (Fin d)) (selectedA : POVM A (UnconditionalSelectedCopyLocalIndex P d N m)) (selectedB : POVM B (UnconditionalSelectedCopyLocalIndex P d N m)) (selectedA_eq : selectedA = directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) PA) (selectedB_eq : selectedB = directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) PB) (eA : ι ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (eB : κ ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (pair : R × R ≃ T) (rawA : POVM A ι) (rawB : POVM B κ) (rawA_eq : rawA = directDSVActualReindexedRetainedPOVM eA (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM alice PA))) (rawB_eq : rawB = directDSVActualReindexedRetainedPOVM eB (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM bob PB))) (x : X) (y : Y) (z : EuclideanSpace ℂ (ι × κ)) (source cleaned : EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T)) (source_eq : source = cleaned) (decoded : unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P alice) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P bob) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z)) = cleaned) : quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G selectedA selectedB x y ⊗ₖ (1 : Matrix T T ℂ))) source = quadraticExpectation (Matrix.toEuclideanCLM (n := ι × κ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G rawA rawB x y)) z := by subst rawA subst rawB calc _ = quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G selectedA selectedB x y ⊗ₖ (1 : Matrix T T ℂ))) cleaned := congrArg (fun v : EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T) => quadraticExpectation (Matrix.toEuclideanCLM (n := (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G selectedA selectedB x y ⊗ₖ (1 : Matrix T T ℂ))) v) source_eq _ = _ := unconditionalActualC485SourceSelectedDecodedWinningBorn G alice bob PA PB selectedA selectedB selectedA_eq selectedB_eq eA eB pair x y z cleaned decoded end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling def unconditionalActualFairSourceAliceTarget {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) : ExactSourceSharedFlag X Y A B D denominator → X → BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) := fun flag x => exactGlobalHistoryFinGamma G n S D (exactSourceAlicePermutationHistory D denominator numerator nonempty flag x) x def unconditionalActualFairSourceBobTarget {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) : ExactSourceSharedFlag X Y A B D denominator → Y → BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) := fun flag y => exactGlobalHistoryFinPhi G n S D (exactSourceBobPermutationHistory D denominator numerator nonempty flag y) y def unconditionalActualFairSourceAliceFlagPOVM {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (a₀ : A) (P N L m : ℕ) : ExactSourceSharedFlag X Y A B D denominator → Fin (L + 1) → X → POVM A (UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m) := by classical intro flag exact physical8OneScaleOriginalFlagPOVM (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) a₀ (fun x => unitaryConjugatePOVM (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty flag x))) (integratorActualC485SourceAlicePOVM G n S D a₀ x)) def unconditionalActualFairSourceBobFlagPOVM {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (b₀ : B) (P N L m : ℕ) : ExactSourceSharedFlag X Y A B D denominator → Fin (L + 1) → Y → POVM B (UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m) := by classical intro flag exact physical8OneScaleOriginalFlagPOVM (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) b₀ (fun y => unitaryConjugatePOVM (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty flag y))) (integratorActualC485SourceBobPOVM G n S D b₀ y)) def unconditionalActualFairSourceAliceStoppingUnitary {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (cleanup : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : ExactSourceSharedFlag X Y A B D denominator → X → Matrix.unitaryGroup (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m) ℂ := by classical exact physical8OneScaleActualAliceStoppingUnitary (P := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule (unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty) cleanup def unconditionalActualFairSourceBobStoppingUnitary {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (cleanup : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) : ExactSourceSharedFlag X Y A B D denominator → Y → Matrix.unitaryGroup (Σ _ : Fin (L + 1), UnconditionalSourcePhysicalStoppingPhaseFiber 1 P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) L m) ℂ := by classical exact physical8OneScaleActualBobStoppingUnitary (P := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) Q width schedule (unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty) cleanup theorem unconditionalActualFairSourceAliceFlagPOVM_succ_nested {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [decA : DecidableEq A] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (a₀ : A) {P N L m : ℕ} (flag : ExactSourceSharedFlag X Y A B D denominator) (j : Fin L) (x : X) : unconditionalActualFairSourceAliceFlagPOVM G n S D denominator numerator nonempty a₀ P N L m flag j.succ x = directDSVActualReindexedRetainedPOVM (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) j) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) m) (unitaryConjugatePOVM (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty flag x))) (integratorActualC485SourceAlicePOVM G n S D a₀ x))) := by classical have same_instance : decA = Classical.decEq A := Subsingleton.elim _ _ cases same_instance change physical8OneScaleOriginalFlagPOVM (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) a₀ (fun q => unitaryConjugatePOVM (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty flag q))) (integratorActualC485SourceAlicePOVM G n S D a₀ q)) j.succ x = _ exact unconditionalPhysicalOneScaleOriginalFlagPOVM_succ_nested (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) a₀ (fun q => unitaryConjugatePOVM (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty flag q))) (integratorActualC485SourceAlicePOVM G n S D a₀ q)) j x theorem unconditionalActualFairSourceBobFlagPOVM_succ_nested {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [decB : DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (b₀ : B) {P N L m : ℕ} (flag : ExactSourceSharedFlag X Y A B D denominator) (j : Fin L) (y : Y) : unconditionalActualFairSourceBobFlagPOVM G n S D denominator numerator nonempty b₀ P N L m flag j.succ y = directDSVActualReindexedRetainedPOVM (unconditionalSourcePhysicalCleanedFullLocalIndexEquiv (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) j) (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N (Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) m) (unitaryConjugatePOVM (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty flag y))) (integratorActualC485SourceBobPOVM G n S D b₀ y))) := by classical have same_instance : decB = Classical.decEq B := Subsingleton.elim _ _ cases same_instance change physical8OneScaleOriginalFlagPOVM (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) b₀ (fun q => unitaryConjugatePOVM (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty flag q))) (integratorActualC485SourceBobPOVM G n S D b₀ q)) j.succ y = _ exact unconditionalPhysicalOneScaleOriginalFlagPOVM_succ_nested (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (m := m) (unconditionalActualOneScaleFixedSourcePhaseSplit P) b₀ (fun q => unitaryConjugatePOVM (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty flag q))) (integratorActualC485SourceBobPOVM G n S D b₀ q)) j y end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace theorem unconditionalActualPairedDecodedMatchedCleanedVector {F X Y : Type} {P N d L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (ξ : F → X → BipartiteUnitVector d) (ζ : F → Y → BipartiteUnitVector d) (A C : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (grid : 0 < N) (flag : F) (x : X) (y : Y) (j : Fin L) (positive : 0 < width (schedule j)) : let phase := unconditionalActualOneScaleFixedSourcePhaseSplit P let outer := unconditionalSourcePhysicalCleanedFullLocalIndexEquiv (N := N) (d := d) (m := m) phase j let pair := unconditionalActualC485RetainedHistoryPairEquiv (P := P) (N := N) (d := d) j let stopped := actualStoppingBranchVector (actualStoppingQuestionLocalAction (physical8OneScaleActualAliceStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) phase Q width schedule ξ A flag x) (physical8OneScaleActualBobStoppingUnitary (P := P) (N := N) (d := d) (L := L) (m := m) phase Q width schedule ζ C flag y) (unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m)) j.succ j.succ unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P (conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (ξ flag x)))) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P (conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (ζ flag y)))) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv outer outer) stopped)) = integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := d) (L := L) (m := m) Q width schedule (ξ flag x) (ζ flag y) A C j := by dsimp only rw [unconditionalActualC485FullBilateralWorkRegroup] exact unconditionalActualOneScaleDecodedMatchedCleanedVector Q width schedule ξ ζ A C grid flag x y j positive end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling def unconditionalActualC485SelectedVerifierBorn {X Y A B ι T : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype ι] [DecidableEq ι] [Fintype T] [DecidableEq T] (G : Game X Y A B) (PA : POVM A ι) (PB : POVM B ι) (x : X) (y : Y) (z : EuclideanSpace ℂ ((ι × ι) × T)) : ℝ := quadraticExpectation (Matrix.toEuclideanCLM (n := (ι × ι) × T) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G PA PB x y ⊗ₖ (1 : Matrix T T ℂ))) z def unconditionalActualC485RawPhysicalVerifierBorn {X Y A B ι κ : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [Fintype ι] [DecidableEq ι] [Fintype κ] [DecidableEq κ] (G : Game X Y A B) (PA : POVM A ι) (PB : POVM B κ) (x : X) (y : Y) (z : EuclideanSpace ℂ (ι × κ)) : ℝ := quadraticExpectation (Matrix.toEuclideanCLM (n := ι × κ) (𝕜 := ℂ) (directDSVActualLocalPOVMWinningEffect G PA PB x y)) z theorem unconditionalActualC485CompleteDecodedScalarBorn {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {P N d m : ℕ} {ι κ R T : Type} [Fintype ι] [Fintype κ] [Fintype R] [Fintype T] [DecidableEq ι] [DecidableEq κ] [DecidableEq R] [DecidableEq T] (G : Game X Y A B) (alice bob : Matrix.unitaryGroup (Fin d) ℂ) (PA : POVM A (Fin d)) (PB : POVM B (Fin d)) (selectedA : POVM A (UnconditionalSelectedCopyLocalIndex P d N m)) (selectedB : POVM B (UnconditionalSelectedCopyLocalIndex P d N m)) (selectedA_eq : selectedA = directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) PA) (selectedB_eq : selectedB = directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) PB) (eA : ι ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (eB : κ ≃ UnconditionalSelectedCopyLocalIndex P d N m × R) (pair : R × R ≃ T) (rawA : POVM A ι) (rawB : POVM B κ) (rawA_eq : rawA = directDSVActualReindexedRetainedPOVM eA (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM alice PA))) (rawB_eq : rawB = directDSVActualReindexedRetainedPOVM eB (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM bob PB))) (x : X) (y : Y) (z : EuclideanSpace ℂ (ι × κ)) (source cleaned : EuclideanSpace ℂ ((UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m) × T)) (source_eq : source = cleaned) (decoded : unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P alice) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P bob) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv eA eB) z)) = cleaned) : unconditionalActualC485SelectedVerifierBorn G selectedA selectedB x y source = unconditionalActualC485RawPhysicalVerifierBorn G rawA rawB x y z := by exact unconditionalActualC485CompleteDecodedPhysicalBorn G alice bob PA PB selectedA selectedB selectedA_eq selectedB_eq eA eB pair rawA rawB rawA_eq rawB_eq x y z source cleaned source_eq decoded def unconditionalActualFairSourceHistoryStopBorn {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (UA UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (h : ExactLocallySampleableTuple X Y A B D) (j : Fin L) : ℝ := quadraticExpectation (integratorActualC485WinningEffect (P := P) (N := N) (L := L) (m := m) G n S D a₀ b₀ j h.2.1 h.2.2.1) (integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (m := m) Q width schedule (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) UA UB j) def unconditionalActualFairSourcePhysicalStopBorn {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (a₀ : A) (b₀ : B) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (UA UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) (j : Fin L) : ℝ := by let d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) let PA := unconditionalActualFairSourceAliceFlagPOVM G n S D denominator numerator nonempty a₀ P N L m flag let PB := unconditionalActualFairSourceBobFlagPOVM G n S D denominator numerator nonempty b₀ P N L m flag let U := unconditionalActualFairSourceAliceStoppingUnitary (P := P) (N := N) (L := L) (m := m) G n S D denominator numerator nonempty Q width schedule UA flag x let V := unconditionalActualFairSourceBobStoppingUnitary (P := P) (N := N) (L := L) (m := m) G n S D denominator numerator nonempty Q width schedule UB flag y exact unconditionalActualC485RawPhysicalVerifierBorn G (PA j.succ x) (PB j.succ y) x y (actualStoppingBranchVector (actualStoppingQuestionLocalAction U V (unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m)) j.succ j.succ) theorem unconditionalActualFairSourceHistoryStopBorn_eq_selected {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (a₀ : A) (b₀ : B) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (UA UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (h : ExactLocallySampleableTuple X Y A B D) (j : Fin L) : unconditionalActualFairSourceHistoryStopBorn G n S D a₀ b₀ Q width schedule UA UB h j = unconditionalActualC485SelectedVerifierBorn G (integratorActualC485SelectedAlicePOVM G n S D a₀ P N m h.2.1) (integratorActualC485SelectedBobPOVM G n S D b₀ P N m h.2.2.1) h.2.1 h.2.2.1 (integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (m := m) Q width schedule (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) UA UB j) := by classical rfl theorem unconditionalActualFairSourcePhysicalStopBorn_eq_raw {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (a₀ : A) (b₀ : B) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (UA UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) (j : Fin L) : let d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) let PA := unconditionalActualFairSourceAliceFlagPOVM G n S D denominator numerator nonempty a₀ P N L m flag let PB := unconditionalActualFairSourceBobFlagPOVM G n S D denominator numerator nonempty b₀ P N L m flag let stopped := actualStoppingBranchVector (actualStoppingQuestionLocalAction (unconditionalActualFairSourceAliceStoppingUnitary (P := P) (N := N) (L := L) (m := m) G n S D denominator numerator nonempty Q width schedule UA flag x) (unconditionalActualFairSourceBobStoppingUnitary (P := P) (N := N) (L := L) (m := m) G n S D denominator numerator nonempty Q width schedule UB flag y) (unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m)) j.succ j.succ unconditionalActualFairSourcePhysicalStopBorn G n S D denominator numerator nonempty a₀ b₀ Q width schedule UA UB flag x y j = unconditionalActualC485RawPhysicalVerifierBorn G (PA j.succ x) (PB j.succ y) x y stopped := by classical dsimp only rfl theorem unconditionalActualFairSourceMatchedHistoryGamma {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) : unconditionalExactFairGammaUnit G n S D (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y))) = unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty flag x := by rw [unconditionalExactFairGammaUnit_eq_global] exact (unconditionalFairMatchedFlag_aliceTarget_eq_aliceSample G n S D denominator numerator nonempty flag x y).symm theorem unconditionalActualFairSourceMatchedHistoryPhi {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) (matching : exactSourcePermutationMatched D denominator numerator nonempty (flag, (x, y)) = true) : exactGlobalHistoryFinPhi G n S D (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y))).2.2.2 y = unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty flag y := by exact (unconditionalFairMatchedFlag_bobTarget_eq_aliceSample G n S D denominator numerator nonempty flag x y matching).symm theorem unconditionalActualFairSourceMatchedHistoryCleanedVector {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (UA UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) (matching : exactSourcePermutationMatched D denominator numerator nonempty (flag, (x, y)) = true) (j : Fin L) : let h := exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y)) integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (m := m) Q width schedule (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) UA UB j = integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (m := m) Q width schedule (unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty flag x) (unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty flag y) UA UB j := by dsimp only exact congrArg₂ (fun (u v : BipartiteUnitVector (Fintype.card (ExactGlobalHistoryLocalIndex G n S D))) => integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := Fintype.card (ExactGlobalHistoryLocalIndex G n S D)) (L := L) (m := m) Q width schedule u v UA UB j) (unconditionalActualFairSourceMatchedHistoryGamma G n S D denominator numerator nonempty flag x y) (unconditionalActualFairSourceMatchedHistoryPhi G n S D denominator numerator nonempty flag x y matching) theorem unconditionalActualFairSourcePhysicalStopBornWitness {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (a₀ : A) (b₀ : B) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (UA UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (grid : 0 < N) (width_positive : ∀ s : Fin 1, 0 < width s) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) (matching : exactSourcePermutationMatched D denominator numerator nonempty (flag, (x, y)) = true) (j : Fin L) : unconditionalActualFairSourceHistoryStopBorn G n S D a₀ b₀ Q width schedule UA UB (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y))) j = unconditionalActualFairSourcePhysicalStopBorn G n S D denominator numerator nonempty a₀ b₀ Q width schedule UA UB flag x y j := by classical let d : ℕ := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) let h := exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y)) let targetA := unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty let targetB := unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty let phase := unconditionalActualOneScaleFixedSourcePhaseSplit P let sourceA := integratorActualC485SourceAlicePOVM G n S D a₀ x let sourceB := integratorActualC485SourceBobPOVM G n S D b₀ y let atomA : Matrix.unitaryGroup (Fin d) ℂ := conjugateUnitary (dSVDensityRationalCanonicalAliceBasis (targetA flag x)) let atomB : Matrix.unitaryGroup (Fin d) ℂ := conjugateUnitary (dSVUniformDensityThresholdLeftBobBasis (targetB flag y)) let outer := unconditionalSourcePhysicalCleanedFullLocalIndexEquiv (N := N) (d := d) (m := m) phase j let pair := unconditionalActualC485RetainedHistoryPairEquiv (P := P) (N := N) (d := d) j let selectedA := integratorActualC485SelectedAlicePOVM G n S D a₀ P N m x let selectedB := integratorActualC485SelectedBobPOVM G n S D b₀ P N m y have selectedA_eq : selectedA = directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) sourceA := by rfl have selectedB_eq : selectedB = directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) sourceB := by rfl let rawA := unconditionalActualFairSourceAliceFlagPOVM G n S D denominator numerator nonempty a₀ P N L m flag j.succ x let rawB := unconditionalActualFairSourceBobFlagPOVM G n S D denominator numerator nonempty b₀ P N L m flag j.succ y have rawA_eq : rawA = directDSVActualReindexedRetainedPOVM outer (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM atomA sourceA)) := by simpa only [rawA, outer, phase, atomA, sourceA, targetA, d] using (unconditionalActualFairSourceAliceFlagPOVM_succ_nested G n S D denominator numerator nonempty a₀ (P := P) (N := N) (L := L) (m := m) flag j x) have rawB_eq : rawB = directDSVActualReindexedRetainedPOVM outer (directDSVActualReindexedRetainedPOVM (physical8SelectedGlobalTargetWorkEquiv P N d m) (unitaryConjugatePOVM atomB sourceB)) := by simpa only [rawB, outer, phase, atomB, sourceB, targetB, d] using (unconditionalActualFairSourceBobFlagPOVM_succ_nested G n S D denominator numerator nonempty b₀ (P := P) (N := N) (L := L) (m := m) flag j y) let source := integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := d) (L := L) (m := m) Q width schedule (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) UA UB j let cleaned := integratorActualC485CleanedVector (S := 1) (B := P) (N := N) (d := d) (L := L) (m := m) Q width schedule (targetA flag x) (targetB flag y) UA UB j have source_eq : source = cleaned := by exact unconditionalActualFairSourceMatchedHistoryCleanedVector G n S D denominator numerator nonempty Q width schedule UA UB flag x y matching j let stopped := actualStoppingBranchVector (actualStoppingQuestionLocalAction (unconditionalActualFairSourceAliceStoppingUnitary (P := P) (N := N) (L := L) (m := m) G n S D denominator numerator nonempty Q width schedule UA flag x) (unconditionalActualFairSourceBobStoppingUnitary (P := P) (N := N) (L := L) (m := m) G n S D denominator numerator nonempty Q width schedule UB flag y) (unconditionalSourcePhysicalCleanedStoppingFixedSource 1 P N d L m)) j.succ j.succ have decoded : unconditionalMixedConjugateSelectedBranchLocalAction (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P atomA) (unconditionalMixedConjugateSigmaAtomLift (m := N * m) P atomB) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (Equiv.prodCongr (Equiv.refl (UnconditionalSelectedCopyLocalIndex P d N m × UnconditionalSelectedCopyLocalIndex P d N m)) pair) (LinearIsometryEquiv.piLpCongrLeft 2 ℂ ℂ (directDSVActualBilateralRetainedIndexEquiv outer outer) stopped)) = cleaned := by simpa only [phase, stopped, cleaned, atomA, atomB, targetA, targetB, unconditionalActualFairSourceAliceStoppingUnitary, unconditionalActualFairSourceBobStoppingUnitary] using (unconditionalActualPairedDecodedMatchedCleanedVector Q width schedule (unconditionalActualFairSourceAliceTarget G n S D denominator numerator nonempty) (unconditionalActualFairSourceBobTarget G n S D denominator numerator nonempty) UA UB grid flag x y j (width_positive (schedule j))) have source_born : unconditionalActualFairSourceHistoryStopBorn G n S D a₀ b₀ Q width schedule UA UB h j = unconditionalActualC485SelectedVerifierBorn G selectedA selectedB x y source := by exact unconditionalActualFairSourceHistoryStopBorn_eq_selected G n S D a₀ b₀ Q width schedule UA UB h j have raw_born : unconditionalActualFairSourcePhysicalStopBorn G n S D denominator numerator nonempty a₀ b₀ Q width schedule UA UB flag x y j = unconditionalActualC485RawPhysicalVerifierBorn G rawA rawB x y stopped := by exact unconditionalActualFairSourcePhysicalStopBorn_eq_raw G n S D denominator numerator nonempty a₀ b₀ Q width schedule UA UB flag x y j calc unconditionalActualFairSourceHistoryStopBorn G n S D a₀ b₀ Q width schedule UA UB h j = unconditionalActualC485SelectedVerifierBorn G selectedA selectedB x y source := source_born _ = unconditionalActualC485RawPhysicalVerifierBorn G rawA rawB x y stopped := unconditionalActualC485CompleteDecodedScalarBorn G atomA atomB sourceA sourceB selectedA selectedB selectedA_eq selectedB_eq outer outer pair rawA rawB rawA_eq rawB_eq x y stopped source cleaned source_eq decoded _ = unconditionalActualFairSourcePhysicalStopBorn G n S D denominator numerator nonempty a₀ b₀ Q width schedule UA UB flag x y j := raw_born.symm theorem unconditionalActualFairSourcePhysicalBranchWitness {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] [DecidableEq A] [DecidableEq B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (denominator : ℕ) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) (a₀ : A) (b₀ : B) {P N L m : ℕ} (Q : ℕ) (width : Fin 1 → ℝ) (schedule : Fin L → Fin 1) (UA UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ) (grid : 0 < N) (width_positive : ∀ s : Fin 1, 0 < width s) (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y) (matching : exactSourcePermutationMatched D denominator numerator nonempty (flag, (x, y)) = true) : (∑ j : Fin L, unconditionalActualFairSourceHistoryStopBorn G n S D a₀ b₀ Q width schedule UA UB (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y))) j) = ∑ j : Fin L, unconditionalActualFairSourcePhysicalStopBorn G n S D denominator numerator nonempty a₀ b₀ Q width schedule UA UB flag x y j := by apply Finset.sum_congr rfl intro j _ exact unconditionalActualFairSourcePhysicalStopBornWitness G n S D denominator numerator nonempty a₀ b₀ Q width schedule UA UB grid width_positive flag x y matching j end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable structure UnconditionalActualFairSourceSamplerData {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (gamma : ℝ) where base : ExactHistoryFlag X Y A B D denominator : ℕ denominator_positive : 0 < denominator numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ rational_normalized : ∀ index, (∑ history, numerator index history) = denominator support_preserving : ∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty total_variation : QuantumParallelRepetition.Pinsker.finiteTotalVariation (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactSourceAliceFlagCoupling G n S D denominator numerator nonempty) ≤ exactSourcePinskerRate G n S D + gamma mismatch : (∑ outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y), flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator) outcome * if exactSourcePermutationMatched D denominator numerator nonempty outcome then 0 else 1) ≤ 4 * (exactSourcePinskerRate G n S D + gamma) theorem unconditionalActualFairSourceSamplerData_of_positive {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (gamma : ℝ) (gamma_positive : 0 < gamma) : Nonempty (UnconditionalActualFairSourceSamplerData G n S D gamma) := by obtain ⟨base, denominator, denominator_positive, numerator, rational_normalized, support_preserving, nonempty, total_variation, mismatch⟩ := unconditionalSourcePhysicalRounding_exists_sourceSampler G n S D remaining positive gamma gamma_positive exact ⟨⟨base, denominator, denominator_positive, numerator, rational_normalized, support_preserving, nonempty, total_variation, mismatch⟩⟩ structure UnconditionalActualFairSourceStoppingHazardData {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (alpha : ℝ) where w : ℝ N : ℕ L : ℕ P : ℕ Q : ℕ m : ℕ width_large : 1 ≤ w grid : 0 < N phases : 0 < P harmonic : 0 < m fine : (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) / (N : ℝ) < 1 / (w + 1) scalar : 1 / w + (Fintype.card (ExactGlobalHistoryLocalIndex G n S D) : ℝ) * w / (N : ℝ) ≤ 3 * alpha ^ (1 / 3 : ℝ) / 2 UA : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ UB : Fin P → Option ℕ → Matrix.unitaryGroup (Fin (N * m)) ℂ asynchronous : (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass N (fun _ : Fin 1 => w) (fun _ : Fin L => 0) (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1)) ≤ 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) terminal : (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousPhysicalTerminalMass N (fun _ : Fin 1 => w) (fun _ : Fin L => 0) (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1)) ≤ (alpha ^ (1 / 3 : ℝ)) ^ 2 hazard : (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard Q m (fun _ : Fin 1 => w) (fun _ : Fin L => 0) (exactGlobalHistoryFinGamma G n S D h.2.2.2 h.2.1) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) UA UB) ≤ (34 / Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) theorem unconditionalActualFairSourceStoppingHazardData_of_positive {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (alpha : ℝ) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (small : 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1) : Nonempty (UnconditionalActualFairSourceStoppingHazardData G n S D alpha) := by obtain ⟨w, N, L, P, Q, m, width_large, grid, horizon, phases, resolution, harmonic, precision, fine, scalar, UA, UB, canonical, asynchronous, terminal, hazard⟩ := unconditionalSourcePhysicalRounding_exists_fairStoppingHazard G n S D remaining positive alpha alpha_positive alpha_bounded small refine ⟨{ w := w N := N L := L P := P Q := Q m := m width_large := width_large grid := grid phases := phases harmonic := harmonic fine := fine scalar := scalar UA := UA UB := UB asynchronous := ?_ terminal := ?_ hazard := ?_ }⟩ · simpa only using asynchronous · simpa only using terminal · simpa only using hazard end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable structure UnconditionalActualFairCachedStoppedAnalyticLedger {I K : Type} [Fintype I] [Fintype K] {H : I × K → Type} [∀ p, NormedAddCommGroup (H p)] [∀ p, InnerProductSpace ℂ (H p)] (law : I → ℝ) (actual canonical source : (p : I × K) → H p) (deviation clipping bad : ℝ) : Prop where actual_mass : (∑ h : I, law h * ∑ j : K, ‖actual (h, j)‖ ^ 2) ≤ 1 canonical_mass : (∑ h : I, law h * ∑ j : K, ‖canonical (h, j)‖ ^ 2) ≤ 1 canonical_row_mass : ∀ h : I, (∑ j : K, ‖canonical (h, j)‖ ^ 2) ≤ 1 same_work_mass : ∀ (h : I) (j : K), ‖source (h, j)‖ = ‖canonical (h, j)‖ clean_deviation : (∑ h : I, law h * ∑ j : K, ‖actual (h, j) - canonical (h, j)‖ ^ 2) ≤ deviation clip_deviation : (∑ h : I, law h * ∑ j : K, ‖canonical (h, j) - source (h, j)‖ ^ 2) ≤ clipping actual_success : 1 - bad ≤ ∑ h : I, law h * ∑ j : K, ‖actual (h, j)‖ ^ 2 structure UnconditionalActualFairCachedSourceVerifierLedger {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) {K : Type} [Fintype K] {H : ExactLocallySampleableTuple X Y A B D × K → Type} [∀ p, NormedAddCommGroup (H p)] [∀ p, InnerProductSpace ℂ (H p)] (effect : (p : ExactLocallySampleableTuple X Y A B D × K) → (H p →L[ℂ] H p)) (actual source : (p : ExactLocallySampleableTuple X Y A B D × K) → H p) : Prop where contraction : ∀ p, ‖effect p‖ ≤ 1 supported_born : ∀ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h ≠ 0 → ∀ j : K, quadraticExpectation (effect (h, j)) (source (h, j)) = ‖source (h, j)‖ ^ 2 * exactSourceConditionalWinningProbability G n S D h history_born_nonnegative : ∀ h : ExactLocallySampleableTuple X Y A B D, 0 ≤ ∑ j : K, quadraticExpectation (effect (h, j)) (actual (h, j)) history_born_bounded : ∀ h : ExactLocallySampleableTuple X Y A B D, (∑ j : K, quadraticExpectation (effect (h, j)) (actual (h, j))) ≤ 1 theorem unconditionalActualFairCachedLedgerStoppingTransfer {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (base : ExactHistoryFlag X Y A B D) (denominator : ℕ) (denominator_positive : 0 < denominator) (numerator : ExactLocalSamplerIndex X Y D → ExactHistoryFlag X Y A B D → ℕ) (rational_normalized : ∀ index, (∑ history, numerator index history) = denominator) (support_preserving : ∀ index history, 0 < exactLocalConditionalFamily D base (exactLocallySampleableLaw G n S D) index history → 0 < numerator index history) (nonempty : ∀ index, (rationalMarked denominator (numerator index)).Nonempty) {L : ℕ} {ι : Fin (L + 1) → Type} [∀ r, Fintype (ι r)] [∀ r, DecidableEq (ι r)] (PA : ExactSourceSharedFlag X Y A B D denominator → (r : Fin (L + 1)) → X → POVM A (ι r)) (PB : ExactSourceSharedFlag X Y A B D denominator → (r : Fin (L + 1)) → Y → POVM B (ι r)) (U : ExactSourceSharedFlag X Y A B D denominator → X → Matrix.unitaryGroup (Σ r : Fin (L + 1), ι r) ℂ) (V : ExactSourceSharedFlag X Y A B D denominator → Y → Matrix.unitaryGroup (Σ r : Fin (L + 1), ι r) ℂ) (z : ExactSourceSharedFlag X Y A B D denominator → EuclideanSpace ℂ ((Σ r : Fin (L + 1), ι r) × (Σ r : Fin (L + 1), ι r))) (z_normalized : ∀ flag, ‖z flag‖ = 1) (matched : ExactSourceSharedFlag X Y A B D denominator × (X × Y) → Bool) {K : Type} [Fintype K] {H : ExactLocallySampleableTuple X Y A B D × K → Type} [∀ p, NormedAddCommGroup (H p)] [∀ p, InnerProductSpace ℂ (H p)] (effect : (p : ExactLocallySampleableTuple X Y A B D × K) → (H p →L[ℂ] H p)) (actual canonical source : (p : ExactLocallySampleableTuple X Y A B D × K) → H p) (epsilon lam deviation clipping bad : ℝ) (analytic : UnconditionalActualFairCachedStoppedAnalyticLedger (exactLocallySampleableLaw G n S D) actual canonical source deviation clipping bad) (verifier : UnconditionalActualFairCachedSourceVerifierLedger G n S D effect actual source) (source_failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < epsilon / 2) (total_variation : QuantumParallelRepetition.Pinsker.finiteTotalVariation (flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator)) (exactSourceAliceFlagCoupling G n S D denominator numerator nonempty) ≤ lam) (mismatch : (∑ outcome : ExactSourceSharedFlag X Y A B D denominator × (X × Y), flaggedQuestionWeight G (exactSourceSharedFlagWeight D denominator) outcome * if matched outcome then 0 else 1) ≤ 4 * lam) (matched_physical_branch : ∀ (flag : ExactSourceSharedFlag X Y A B D denominator) (x : X) (y : Y), matched (flag, (x, y)) = true → (∑ k : K, quadraticExpectation (effect (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y)), k)) (actual (exactSourceAliceSampleTuple D denominator numerator nonempty (flag, (x, y)), k))) ≤ ∑ j : Fin L, quadraticExpectation (Matrix.toEuclideanCLM (n := ι j.succ × ι j.succ) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G (PA flag) (PB flag) j.succ j.succ x y)) (actualStoppingBranchVector (actualStoppingQuestionLocalAction (U flag x) (V flag y) (z flag)) j.succ j.succ)) : 1 - epsilon / 2 - 5 * lam - (bad + 4 * Real.sqrt deviation + 2 * Real.sqrt clipping) ≤ (pureFlaggedStrategy G (exactSourceSharedFlagWeight D denominator) (exactSourceSharedFlagWeight_nonneg D denominator) (exactSourceSharedFlagWeight_sum D remaining denominator) z z_normalized (fun flag x => unitaryConjugatePOVM (U flag x) (dependentBlockPOVM (fun r => PA flag r x))) (fun flag y => unitaryConjugatePOVM (V flag y) (dependentBlockPOVM (fun r => PB flag r y)))).winProbability := by exact unconditionalFairPhysicalFlaggedStoppingTransfer G n S D remaining positive base denominator denominator_positive numerator rational_normalized support_preserving nonempty PA PB U V z z_normalized matched effect verifier.contraction actual canonical source analytic.actual_mass analytic.canonical_mass analytic.canonical_row_mass analytic.same_work_mass verifier.supported_born epsilon lam deviation clipping bad analytic.clean_deviation analytic.clip_deviation analytic.actual_success verifier.history_born_nonnegative verifier.history_born_bounded source_failure total_variation mismatch matched_physical_branch end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable structure UnconditionalActualFairSourceRoundingContext {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (alpha gamma : ℝ) where remaining : 0 < (Finset.univ \ D).card positive : 0 < repeatedPostselectionMass G n S D failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2 sampler : UnconditionalActualFairSourceSamplerData G n S D gamma stopping : UnconditionalActualFairSourceStoppingHazardData G n S D alpha def unconditionalActualFairSourceRoundingContext_of_positive {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (alpha gamma : ℝ) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (gamma_positive : 0 < gamma) (small : 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1) (failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2) : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma := by classical exact { remaining := remaining positive := positive failure := failure sampler := Classical.choice (unconditionalActualFairSourceSamplerData_of_positive G n S D remaining positive gamma gamma_positive) stopping := Classical.choice (unconditionalActualFairSourceStoppingHazardData_of_positive G n S D remaining positive alpha alpha_positive alpha_bounded small) } namespace UnconditionalActualFairSourceRoundingContext variable {X Y A B : Type} variable [Fintype X] [Fintype Y] [Fintype A] [Fintype B] variable {G : Game X Y A B} {n : ℕ} {S : Strategy (G.repeat n)} variable {D : Finset (Fin n)} {alpha gamma : ℝ} def d (_c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : ℕ := Fintype.card (ExactGlobalHistoryLocalIndex G n S D) theorem dimension_pos (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : 0 < d c := exactGlobalHistoryLocalIndex_card_pos G n S D def width (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : Fin 1 → ℝ := fun _ => c.stopping.w def schedule (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : Fin c.stopping.L → Fin 1 := fun _ => 0 theorem width_positive (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : 0 < c.stopping.w := by linarith [c.stopping.width_large] theorem width_all (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : ∀ s : Fin 1, 0 < width c s := by intro s exact width_positive c theorem fine_all (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : ∀ s : Fin 1, (d c : ℝ) / (c.stopping.N : ℝ) < 1 / (width c s + 1) := by intro s exact c.stopping.fine abbrev sourceIndex (_c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : Type := ExactLocallySampleableTuple X Y A B D def law (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : sourceIndex c → ℝ := exactLocallySampleableLaw G n S D def gammaVector (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : sourceIndex c → BipartiteUnitVector (d c) := fun h => unconditionalExactFairGammaUnit G n S D h def phiVector (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : sourceIndex c → BipartiteUnitVector (d c) := fun h => exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1 def psiVector (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : sourceIndex c → EuclideanSpace ℂ (Fin (d c) × Fin (d c)) := fun h => exactSourceTuplePsi G n S D h abbrev branchSpace (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) (p : sourceIndex c × Fin c.stopping.L) : Type := IntegratorActualC485BranchSpace 1 c.stopping.P c.stopping.N (d c) c.stopping.L c.stopping.m p.2 def actual (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) (p : sourceIndex c × Fin c.stopping.L) : branchSpace c p := integratorActualC485CleanedVector (S := 1) (B := c.stopping.P) (N := c.stopping.N) (d := d c) (L := c.stopping.L) (m := c.stopping.m) c.stopping.Q (width c) (schedule c) (gammaVector c p.1) (phiVector c p.1) c.stopping.UA c.stopping.UB p.2 def canonical (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) (p : sourceIndex c × Fin c.stopping.L) : branchSpace c p := integratorActualC485CanonicalVector (S := 1) (B := c.stopping.P) (N := c.stopping.N) (d := d c) (L := c.stopping.L) (m := c.stopping.m) (width := width c) (schedule c) (gammaVector c p.1) (phiVector c p.1) p.2 (width_all c (schedule c p.2)) c.stopping.grid (fine_all c (schedule c p.2)) def source (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) (p : sourceIndex c × Fin c.stopping.L) : branchSpace c p := integratorActualC485SourceVector (S := 1) (B := c.stopping.P) (N := c.stopping.N) (d := d c) (L := c.stopping.L) (m := c.stopping.m) (width c) (schedule c) (gammaVector c p.1) (phiVector c p.1) (psiVector c p.1) p.2 theorem answerNonempty (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : Nonempty A ∧ Nonempty B := exactSourceAnswerTypes_nonempty_of_remaining G n S D c.remaining def aliceDefault (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : A := Classical.choice (answerNonempty c).1 def bobDefault (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : B := Classical.choice (answerNonempty c).2 def effect (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) (p : sourceIndex c × Fin c.stopping.L) : branchSpace c p →L[ℂ] branchSpace c p := integratorActualC485WinningEffect (P := c.stopping.P) (N := c.stopping.N) (m := c.stopping.m) G n S D (aliceDefault c) (bobDefault c) p.2 p.1.2.1 p.1.2.2.1 def deviation (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : ℝ := ∑ h : sourceIndex c, law c h * ∑ j : Fin c.stopping.L, ‖actual c (h, j) - canonical c (h, j)‖ ^ 2 def clipping (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : ℝ := unconditionalActualC485FairSourceClipEnergy (P := c.stopping.P) (m := c.stopping.m) G n S D (width_positive c) c.stopping.grid c.stopping.fine (schedule c) def bad (_c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : ℝ := 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2 abbrev flag (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : Type := ExactSourceSharedFlag X Y A B D c.sampler.denominator abbrev fiber (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : Type := UnconditionalSourcePhysicalStoppingPhaseFiber 1 c.stopping.P c.stopping.N (d c) c.stopping.L c.stopping.m def PA (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : flag c → Fin (c.stopping.L + 1) → X → POVM A (fiber c) := by classical exact unconditionalActualFairSourceAliceFlagPOVM G n S D c.sampler.denominator c.sampler.numerator c.sampler.nonempty (aliceDefault c) c.stopping.P c.stopping.N c.stopping.L c.stopping.m def PB (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : flag c → Fin (c.stopping.L + 1) → Y → POVM B (fiber c) := by classical exact unconditionalActualFairSourceBobFlagPOVM G n S D c.sampler.denominator c.sampler.numerator c.sampler.nonempty (bobDefault c) c.stopping.P c.stopping.N c.stopping.L c.stopping.m def U (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : flag c → X → Matrix.unitaryGroup (Σ _ : Fin (c.stopping.L + 1), fiber c) ℂ := unconditionalActualFairSourceAliceStoppingUnitary G n S D c.sampler.denominator c.sampler.numerator c.sampler.nonempty c.stopping.Q (width c) (schedule c) c.stopping.UA def V (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : flag c → Y → Matrix.unitaryGroup (Σ _ : Fin (c.stopping.L + 1), fiber c) ℂ := unconditionalActualFairSourceBobStoppingUnitary G n S D c.sampler.denominator c.sampler.numerator c.sampler.nonempty c.stopping.Q (width c) (schedule c) c.stopping.UB def prepared (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : flag c → EuclideanSpace ℂ ((Σ _ : Fin (c.stopping.L + 1), fiber c) × (Σ _ : Fin (c.stopping.L + 1), fiber c)) := fun _ => unconditionalSourcePhysicalCleanedStoppingFixedSource 1 c.stopping.P c.stopping.N (d c) c.stopping.L c.stopping.m theorem prepared_normalized (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : ∀ f : flag c, ‖prepared c f‖ = 1 := by intro f exact unconditionalSourcePhysicalCleanedStoppingFixedSource_norm c.stopping.phases c.stopping.grid (dimension_pos c) c.stopping.harmonic def rounded (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : Strategy G := unconditionalOneScaleActualSourceFlaggedStrategy G n S D c.remaining c.sampler.denominator c.sampler.numerator c.sampler.nonempty c.stopping.w c.stopping.N c.stopping.L c.stopping.P c.stopping.Q c.stopping.m c.stopping.phases c.stopping.grid c.stopping.harmonic c.stopping.UA c.stopping.UB end UnconditionalActualFairSourceRoundingContext end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling open UnconditionalActualFairSourceRoundingContext attribute [local instance] Classical.propDecidable theorem unconditionalActualFairSourceRoundingContext_actualRow {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} {n : ℕ} {S : Strategy (G.repeat n)} {D : Finset (Fin n)} {alpha gamma : ℝ} (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) (h : ExactLocallySampleableTuple X Y A B D) : (∑ j : Fin c.stopping.L, ‖actual c (h, j)‖ ^ 2) ≤ 1 := by exact unconditionalActualFairCleanedRow_le_one c.stopping.phases c.stopping.grid (dimension_pos c) c.stopping.harmonic (width c) (width_all c) (schedule c) (gammaVector c h) (phiVector c h) c.stopping.Q c.stopping.UA c.stopping.UB theorem unconditionalActualFairSourceRoundingContext_clippingBound {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} {n : ℕ} {S : Strategy (G.repeat n)} {D : Finset (Fin n)} {alpha gamma : ℝ} (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : clipping c ≤ 16 * martingaleRate G n S D + 8 * (3 * alpha ^ (1 / 3 : ℝ) / 2) := by exact unconditionalActualC485FairSourceClipEnergy_le_budget (P := c.stopping.P) (m := c.stopping.m) G n S D c.remaining c.positive (width_positive c) c.stopping.grid (dimension_pos c) c.stopping.fine c.stopping.phases c.stopping.harmonic (schedule c) c.stopping.scalar theorem unconditionalActualFairSourceRoundingContext_cleanBound {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} {n : ℕ} {S : Strategy (G.repeat n)} {D : Finset (Fin n)} {alpha gamma : ℝ} (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : deviation c ≤ (34 / Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) := by have identification := unconditionalActualC485WeightedCleanDeviation_eq_hazard (law c) c.stopping.Q (width c) (schedule c) (gammaVector c) (phiVector c) c.stopping.UA c.stopping.UB (width_all c) c.stopping.phases c.stopping.grid (dimension_pos c) (fine_all c) have fair_hazard : (∑ h : ExactLocallySampleableTuple X Y A B D, law c h * dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard c.stopping.Q c.stopping.m (width c) (schedule c) (gammaVector c h) (phiVector c h) c.stopping.UA c.stopping.UB) ≤ (34 / Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) := by change (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard c.stopping.Q c.stopping.m (fun _ : Fin 1 => c.stopping.w) (fun _ : Fin c.stopping.L => 0) (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) c.stopping.UA c.stopping.UB) ≤ _ simpa only [unconditionalExactFairGammaUnit_eq_global] using c.stopping.hazard calc deviation c = (∑ h : ExactLocallySampleableTuple X Y A B D, law c h * dSVDensityRationalHeterogeneousStoppedCommonPrefixHazard c.stopping.Q c.stopping.m (width c) (schedule c) (gammaVector c h) (phiVector c h) c.stopping.UA c.stopping.UB) := by simpa only [deviation, actual, canonical] using identification _ ≤ _ := fair_hazard theorem unconditionalActualFairSourceRoundingContext_analyticLedger {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} {n : ℕ} {S : Strategy (G.repeat n)} {D : Finset (Fin n)} {alpha gamma : ℝ} (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : UnconditionalActualFairCachedStoppedAnalyticLedger (law c) (actual c) (canonical c) (source c) (deviation c) (clipping c) (bad c) := by refine ⟨?_, ?_, ?_, ?_, ?_, ?_, ?_⟩ · exact unconditionalActualFairWeightedCleanedMass_le_one (law c) (exactLocallySampleableLaw_nonneg G n S D c.positive) (exactLocallySampleableLaw_sum G n S D c.remaining c.positive) c.stopping.phases c.stopping.grid (dimension_pos c) c.stopping.harmonic (width c) (width_all c) (schedule c) (gammaVector c) (phiVector c) c.stopping.Q c.stopping.UA c.stopping.UB · exact unconditionalActualFairWeightedCanonicalMass_le_one (law c) (exactLocallySampleableLaw_nonneg G n S D c.positive) (exactLocallySampleableLaw_sum G n S D c.remaining c.positive) c.stopping.phases c.stopping.grid (dimension_pos c) c.stopping.harmonic (width c) (width_all c) (schedule c) (gammaVector c) (phiVector c) (fine_all c) · intro h exact unconditionalActualFairCanonicalRow_le_one c.stopping.phases c.stopping.grid (dimension_pos c) c.stopping.harmonic (width c) (width_all c) (schedule c) (gammaVector c h) (phiVector c h) (fine_all c) · intro h j exact unconditionalActualFairSourceCanonicalVector_norm c.stopping.phases c.stopping.grid c.stopping.harmonic (width c) (schedule c) (gammaVector c h) (phiVector c h) (psiVector c h) (exactSourceTuplePsi_norm G n S D h) j (width_all c (schedule c j)) (fine_all c (schedule c j)) · exact le_refl (deviation c) · change (∑ h : ExactLocallySampleableTuple X Y A B D, law c h * ∑ j : Fin c.stopping.L, ‖canonical c (h, j) - source c (h, j)‖ ^ 2) ≤ unconditionalActualC485FairSourceClipEnergy (P := c.stopping.P) (m := c.stopping.m) G n S D (width_positive c) c.stopping.grid c.stopping.fine (schedule c) unfold unconditionalActualC485FairSourceClipEnergy apply le_of_eq apply Finset.sum_congr rfl intro h _ congr 1 apply Finset.sum_congr rfl intro j _ change ‖canonical c (h, j) - source c (h, j)‖ ^ 2 = ‖source c (h, j) - canonical c (h, j)‖ ^ 2 rw [norm_sub_rev] · have async : (∑ h : ExactLocallySampleableTuple X Y A B D, law c h * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass c.stopping.N (width c) (schedule c) (gammaVector c h) (phiVector c h)) ≤ 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) := by change (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousPhysicalStoppedAsynchronousMass c.stopping.N (fun _ : Fin 1 => c.stopping.w) (fun _ : Fin c.stopping.L => 0) (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1)) ≤ _ simpa only [unconditionalExactFairGammaUnit_eq_global] using c.stopping.asynchronous have finish : (∑ h : ExactLocallySampleableTuple X Y A B D, law c h * dSVDensityRationalHeterogeneousPhysicalTerminalMass c.stopping.N (width c) (schedule c) (gammaVector c h) (phiVector c h)) ≤ (alpha ^ (1 / 3 : ℝ)) ^ 2 := by change (∑ h : ExactLocallySampleableTuple X Y A B D, exactLocallySampleableLaw G n S D h * dSVDensityRationalHeterogeneousPhysicalTerminalMass c.stopping.N (fun _ : Fin 1 => c.stopping.w) (fun _ : Fin c.stopping.L => 0) (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1)) ≤ _ simpa only [unconditionalExactFairGammaUnit_eq_global] using c.stopping.terminal exact unconditionalActualFairWeightedStoppedSuccess (law c) (exactLocallySampleableLaw_sum G n S D c.remaining c.positive) c.stopping.phases c.stopping.grid (dimension_pos c) c.stopping.harmonic (width c) (width_all c) (schedule c) (gammaVector c) (phiVector c) c.stopping.Q c.stopping.UA c.stopping.UB (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) ((alpha ^ (1 / 3 : ℝ)) ^ 2) async finish end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable theorem unconditionalActualFairSourceRoundingContext_verifierLedger {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} {n : ℕ} {S : Strategy (G.repeat n)} {D : Finset (Fin n)} {alpha gamma : ℝ} (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : UnconditionalActualFairCachedSourceVerifierLedger G n S D c.effect c.actual c.source := by classical refine ⟨?_, ?_, ?_, ?_⟩ · intro p exact unconditionalActualFairSourceVerifier_norm_le_one G n S D c.aliceDefault c.bobDefault p.2 p.1.2.1 p.1.2.2.1 · intro h supported j change quadraticExpectation (integratorActualC485WinningEffect (P := c.stopping.P) (N := c.stopping.N) (m := c.stopping.m) G n S D c.aliceDefault c.bobDefault j h.2.1 h.2.2.1) (integratorActualC485SourceVector (S := 1) (B := c.stopping.P) (N := c.stopping.N) (d := c.d) (L := c.stopping.L) (m := c.stopping.m) c.width c.schedule (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) (exactSourceTuplePsi G n S D h) j) = ‖integratorActualC485SourceVector (S := 1) (B := c.stopping.P) (N := c.stopping.N) (d := c.d) (L := c.stopping.L) (m := c.stopping.m) c.width c.schedule (unconditionalExactFairGammaUnit G n S D h) (exactGlobalHistoryFinPhi G n S D h.2.2.2 h.2.2.1) (exactSourceTuplePsi G n S D h) j‖ ^ 2 * exactSourceConditionalWinningProbability G n S D h rw [unconditionalExactFairGammaUnit_eq_global] exact unconditionalActualFairSourceSupportedBorn G n S D c.positive c.aliceDefault c.bobDefault h supported c.stopping.phases c.stopping.grid c.stopping.harmonic c.width c.schedule j · intro h exact unconditionalActualFairSourceVerifier_historyBorn_nonnegative G n S D c.aliceDefault c.bobDefault (fun h j => c.actual (h, j)) (unconditionalActualFairSourceRoundingContext_actualRow c) h · intro h exact unconditionalActualFairSourceVerifier_historyBorn_bounded G n S D c.aliceDefault c.bobDefault (fun h j => c.actual (h, j)) (unconditionalActualFairSourceRoundingContext_actualRow c) h theorem unconditionalActualFairSourceRoundingContext_physicalBranch {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} {n : ℕ} {S : Strategy (G.repeat n)} {D : Finset (Fin n)} {alpha gamma : ℝ} (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) (flag : ExactSourceSharedFlag X Y A B D c.sampler.denominator) (x : X) (y : Y) (matching : exactSourcePermutationMatched D c.sampler.denominator c.sampler.numerator c.sampler.nonempty (flag, (x, y)) = true) : (∑ j : Fin c.stopping.L, quadraticExpectation (c.effect (exactSourceAliceSampleTuple D c.sampler.denominator c.sampler.numerator c.sampler.nonempty (flag, (x, y)), j)) (c.actual (exactSourceAliceSampleTuple D c.sampler.denominator c.sampler.numerator c.sampler.nonempty (flag, (x, y)), j))) ≤ ∑ j : Fin c.stopping.L, quadraticExpectation (Matrix.toEuclideanCLM (n := c.fiber × c.fiber) (𝕜 := ℂ) (actualStoppingBranchWinningEffect G (c.PA flag) (c.PB flag) j.succ j.succ x y)) (actualStoppingBranchVector (actualStoppingQuestionLocalAction (c.U flag x) (c.V flag y) (c.prepared flag)) j.succ j.succ) := by classical apply le_of_eq change (∑ j : Fin c.stopping.L, unconditionalActualFairSourceHistoryStopBorn G n S D c.aliceDefault c.bobDefault c.stopping.Q c.width c.schedule c.stopping.UA c.stopping.UB (exactSourceAliceSampleTuple D c.sampler.denominator c.sampler.numerator c.sampler.nonempty (flag, (x, y))) j) = ∑ j : Fin c.stopping.L, unconditionalActualFairSourcePhysicalStopBorn G n S D c.sampler.denominator c.sampler.numerator c.sampler.nonempty c.aliceDefault c.bobDefault c.stopping.Q c.width c.schedule c.stopping.UA c.stopping.UB flag x y j exact unconditionalActualFairSourcePhysicalBranchWitness G n S D c.sampler.denominator c.sampler.numerator c.sampler.nonempty c.aliceDefault c.bobDefault c.stopping.Q c.width c.schedule c.stopping.UA c.stopping.UB c.stopping.grid c.width_all flag x y matching theorem unconditionalActualFairSourceRoundingContext_stoppedVerifier {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] {G : Game X Y A B} {n : ℕ} {S : Strategy (G.repeat n)} {D : Finset (Fin n)} {alpha gamma : ℝ} (c : UnconditionalActualFairSourceRoundingContext G n S D alpha gamma) : 1 - (1 - entangledValue G) / 2 - 5 * (exactSourcePinskerRate G n S D + gamma) - ((64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2) + 4 * Real.sqrt c.deviation + 2 * Real.sqrt c.clipping) ≤ c.rounded.winProbability := by classical have stopped := unconditionalActualFairCachedLedgerStoppingTransfer G n S D c.remaining c.positive c.sampler.base c.sampler.denominator c.sampler.denominator_positive c.sampler.numerator c.sampler.rational_normalized c.sampler.support_preserving c.sampler.nonempty c.PA c.PB c.U c.V c.prepared c.prepared_normalized (exactSourcePermutationMatched D c.sampler.denominator c.sampler.numerator c.sampler.nonempty) c.effect c.actual c.canonical c.source (1 - entangledValue G) (exactSourcePinskerRate G n S D + gamma) c.deviation c.clipping c.bad (unconditionalActualFairSourceRoundingContext_analyticLedger c) (unconditionalActualFairSourceRoundingContext_verifierLedger c) c.failure c.sampler.total_variation c.sampler.mismatch (fun flag x y matching => unconditionalActualFairSourceRoundingContext_physicalBranch c flag x y matching) change 1 - (1 - entangledValue G) / 2 - 5 * (exactSourcePinskerRate G n S D + gamma) - ((64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2) + 4 * Real.sqrt c.deviation + 2 * Real.sqrt c.clipping) ≤ c.rounded.winProbability at stopped exact stopped end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling attribute [local instance] Classical.propDecidable theorem unconditionalActualFairSourceRoundingData_exists_stoppedVerifier {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (alpha gamma : ℝ) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (gamma_positive : 0 < gamma) (small : 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1) (failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2) : ∃ (deviation clipping : ℝ) (rounded : Strategy G), (deviation ≤ (34 / Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) * (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ)) + 4 * (alpha ^ (1 / 12 : ℝ)) ^ 2 + unconditionalPrefactorBucketCoefficient * Real.sqrt (64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ))) ∧ (clipping ≤ 16 * martingaleRate G n S D + 8 * (3 * alpha ^ (1 / 3 : ℝ) / 2)) ∧ (1 - (1 - entangledValue G) / 2 - 5 * (exactSourcePinskerRate G n S D + gamma) - ((64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) + (alpha ^ (1 / 3 : ℝ)) ^ 2) + 4 * Real.sqrt deviation + 2 * Real.sqrt clipping) ≤ rounded.winProbability) := by classical let context := unconditionalActualFairSourceRoundingContext_of_positive G n S D remaining positive alpha gamma alpha_positive alpha_bounded gamma_positive small failure exact ⟨ UnconditionalActualFairSourceRoundingContext.deviation context, UnconditionalActualFairSourceRoundingContext.clipping context, UnconditionalActualFairSourceRoundingContext.rounded context, unconditionalActualFairSourceRoundingContext_cleanBound context, unconditionalActualFairSourceRoundingContext_clippingBound context, unconditionalActualFairSourceRoundingContext_stoppedVerifier context⟩ end noncomputable section open WithLp open scoped BigOperators Kronecker ComplexOrder MatrixOrder Matrix.Norms.L2Operator InnerProductSpace open QuantumParallelRepetition.ClassicalSampling theorem unconditionalSourcePhysicalRounding_exists_small {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)) (remaining : 0 < (Finset.univ \ D).card) (positive : 0 < repeatedPostselectionMass G n S D) (alpha gamma : ℝ) (alpha_positive : 0 < alpha) (alpha_bounded : alpha ≤ 1) (gamma_positive : 0 < gamma) (small : 64 * Real.sqrt (martingaleRate G n S D) + alpha ^ (1 / 3 : ℝ) ≤ 1) (failure : uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2) : ∃ rounded : Strategy G, roundedWinningLowerBound (1 - entangledValue G) unconditionalSourcePhysicalRoundingUniversalConstant alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability := by obtain ⟨deviation, clipping, rounded, deviation_bound, clipping_bound, stopped⟩ := unconditionalActualFairSourceRoundingData_exists_stoppedVerifier G n S D remaining positive alpha gamma alpha_positive alpha_bounded gamma_positive small failure refine ⟨rounded, ?_⟩ exact unconditionalSourcePhysicalRounding_smallRoundedLower_of_stoppedVerifier G n S D remaining positive alpha gamma deviation clipping alpha_positive alpha_bounded gamma_positive small deviation_bound clipping_bound rounded stopped theorem unconditionalSourceOneGameRounding_uniform : ∃ K : ℝ, 1 ≤ K ∧ ∀ {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) (n : ℕ) (S : Strategy (G.repeat n)) (D : Finset (Fin n)), 0 < (Finset.univ \ D).card → 0 < repeatedPostselectionMass G n S D → ∀ (alpha gamma : ℝ), 0 < alpha → alpha ≤ 1 → 0 < gamma → uniformRemainingFailure (strategyEventLaw (G.repeat n) S) (repeatedCoordinateWin G n) D < (1 - entangledValue G) / 2 → ∃ rounded : Strategy G, roundedWinningLowerBound (1 - entangledValue G) K alpha (martingaleRate G n S D) (exactSourcePinskerRate G n S D + gamma) ≤ rounded.winProbability := unconditionalSourceOneGameRounding_uniform_of_small unconditionalSourcePhysicalRounding_exists_small end noncomputable section theorem pdf_distributionUniformExponential_unconditional : ∃ c : ℝ, 0 < c ∧ ∀ {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B), Nonempty A → Nonempty B → 0 < 1 - entangledValue G → ∀ n : ℕ, 0 < n → repeatedEntangledValue G n ≤ Real.exp (-(c * ((1 - entangledValue G) ^ 13 / ((1 - entangledValue G) + Real.log ((Fintype.card A : ℝ) * (Fintype.card B : ℝ))))) * (n : ℝ)) := pdf_distributionUniformExponential_of_uniform_source_rounding unconditionalSourceOneGameRounding_uniform theorem exactSourceOneGameRounding_unconditional {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) : ExactSourceOneGameRounding G := by obtain ⟨K, constant, round⟩ := unconditionalSourceOneGameRounding_uniform refine ⟨K, le_trans (by norm_num : (0 : ℝ) ≤ 1) constant, ?_⟩ exact round G theorem exact_standardQuantumParallelRepetition_unconditional {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) : StandardQuantumParallelRepetition G := exact_standardQuantumParallelRepetition_of_source_rounding G (exactSourceOneGameRounding_unconditional G) theorem distributionUniformExponential : ∃ c : ℝ, 0 < c ∧ ∀ {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B), Nonempty A → Nonempty B → 0 < 1 - entangledValue G → ∀ n : ℕ, 0 < n → repeatedEntangledValue G n ≤ Real.exp (-(c * ((1 - entangledValue G) ^ 13 / ((1 - entangledValue G) + Real.log ((Fintype.card A : ℝ) * (Fintype.card B : ℝ))))) * (n : ℝ)) := pdf_distributionUniformExponential_unconditional theorem standardQuantumParallelRepetition {X Y A B : Type} [Fintype X] [Fintype Y] [Fintype A] [Fintype B] (G : Game X Y A B) : StandardQuantumParallelRepetition G := exact_standardQuantumParallelRepetition_unconditional G end end QuantumParallelRepetition