diff --git a/data/problems/k-user-gaussian-interference-channel.yaml b/data/problems/k-user-gaussian-interference-channel.yaml new file mode 100644 index 0000000..9df805e --- /dev/null +++ b/data/problems/k-user-gaussian-interference-channel.yaml @@ -0,0 +1,83 @@ +# Copyright 2026 The Capacity Atlas Authors +# SPDX-License-Identifier: CC-BY-4.0 +id: k-user-gaussian-interference-channel +title: K-user Gaussian interference channel +status: partially-solved +updated: '2026-10-12' +summary: Independent transmitters on a fully connected fading interference channel achieve K/2 sum degrees of freedom with global causal channel knowledge. +tags: + model: [interference] + features: [continuous-alphabet, gaussian, additive-noise, causal-state, power-constraint, multiple-unicast] + quantity: [capacity] + knowledge: [bounds] +parameters: +- symbol: K + description: Number of transmitter–receiver pairs. + range: K\ge2 +- symbol: P + description: Total average transmit power across all users. + range: P\ge0 +model: + input: Transmitter j sends a complex scalar \(X_j(t)\) carrying its own independent uniform message. + output: Receiver i observes \(Y_i(t)\) and decodes its own message. + law: \(Y_i(t)=\sum_{j=1}^K H_{ij}(t)X_j(t)+Z_i(t)\), where the noise is independent circular complex Gaussian with \(\mathbb E|Z_i(t)|^2=1\). + assumptions: + - The coefficients are independent across links and times, with a common nonatomic law supported on \(0 Gaussian.Interference.sumCapacity μ K P / Real.logb 2 P) + atTop (𝓝 ((K : ℝ) / 2)) := + Gaussian.Interference.sum_degrees_of_freedom μ hK hmin_pos hmax_nonneg hfading + +end CapacityAtlas.Claims diff --git a/lean/CapacityAtlas/Tests/GaussianInterference.lean b/lean/CapacityAtlas/Tests/GaussianInterference.lean new file mode 100644 index 0000000..9742723 --- /dev/null +++ b/lean/CapacityAtlas/Tests/GaussianInterference.lean @@ -0,0 +1,94 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.BasicFacts + +open MeasureTheory +open scoped BigOperators + +namespace CapacityAtlas.Tests + +private def interferenceMessageCounts : Fin 2 → ℕ := ![2, 3] + +private def firstInterferenceMessage (i : Fin 2) : Fin (interferenceMessageCounts i) := + ⟨0, by fin_cases i <;> decide⟩ + +private def interferenceTestCode : Gaussian.Interference.Code 2 1 where + messages := interferenceMessageCounts + messages_pos i := by fin_cases i <;> decide + encode := fun i _ _ _ => if i = 0 then 1 else Complex.I + encode_measurable _ _ _ := measurable_const + encode_causal _ _ _ _ _ _ := rfl + decode i := + { apply := fun _ => firstInterferenceMessage i + measurable_fiber m := by + change MeasurableSet {_x | firstInterferenceMessage i = m} + by_cases h : firstInterferenceMessage i = m <;> simp [h] } + +@[capacity_test] +theorem interference_power_shared_across_users (μ : Measure ℂ) [IsProbabilityMeasure μ] : + Gaussian.Interference.PowerAdmissible μ 2 interferenceTestCode ∧ + ¬Gaussian.Interference.PowerAdmissible μ 1 interferenceTestCode := by + have he (m : interferenceTestCode.Message) (H : Gaussian.Interference.StateBlock 2 1) : + Gaussian.Interference.energy interferenceTestCode m H = 2 := by + simp only [Gaussian.Interference.energy, Fin.sum_univ_one, Fin.sum_univ_two] + change ‖(1 : ℂ)‖ ^ 2 + ‖Complex.I‖ ^ 2 = 2 + norm_num + have hint (m : interferenceTestCode.Message) : + Integrable (Gaussian.Interference.energy interferenceTestCode m) + (Gaussian.Interference.stateLaw μ 2 1) := by + simp_rw [show Gaussian.Interference.energy interferenceTestCode m = fun _ => 2 from funext (he m)] + exact integrable_const _ + have hc : Fintype.card interferenceTestCode.Message = 6 := by + change Fintype.card ((i : Fin 2) → Fin (interferenceMessageCounts i)) = 6 + rw [Fintype.card_pi] + norm_num [interferenceMessageCounts, Fin.prod_univ_succ] + have hv : (∏ i, (interferenceTestCode.messages i : ℝ))⁻¹ * + (∑ m, ∫ H, Gaussian.Interference.energy interferenceTestCode m H + ∂Gaussian.Interference.stateLaw μ 2 1) = 2 := by + simp_rw [he] + norm_num [hc, interferenceTestCode, interferenceMessageCounts, Fin.prod_univ_succ] + simp only [Gaussian.Interference.PowerAdmissible, hint, hv] + norm_num + +@[capacity_test] +theorem interference_joint_error (μ : Measure ℂ) [IsProbabilityMeasure μ] : + Gaussian.Interference.error μ interferenceTestCode = (5 / 6 : ℝ) := by + classical + have he (m : interferenceTestCode.Message) : + Gaussian.Interference.errorEvent interferenceTestCode m = + if m = firstInterferenceMessage then ∅ else Set.univ := by + ext hz + change (∃ i, firstInterferenceMessage i ≠ m i) ↔ + hz ∈ if m = firstInterferenceMessage then ∅ else Set.univ + by_cases h : m = firstInterferenceMessage + · subst m + simp + · have hi : ∃ i, firstInterferenceMessage i ≠ m i := by + by_contra hn + push Not at hn + exact h (funext hn).symm + simp [h, hi] + have hc : Fintype.card interferenceTestCode.Message = 6 := by + change Fintype.card ((i : Fin 2) → Fin (interferenceMessageCounts i)) = 6 + rw [Fintype.card_pi] + norm_num [interferenceMessageCounts, Fin.prod_univ_succ] + unfold Gaussian.Interference.error + simp_rw [he] + simp only [apply_ite, measure_empty, measure_univ, ENNReal.toReal_zero, ENNReal.toReal_one] + have hs : (∑ m : interferenceTestCode.Message, + if m = firstInterferenceMessage then (0 : ℝ) else 1) = 5 := by + calc + _ = ∑ m : interferenceTestCode.Message, + (1 - if m = firstInterferenceMessage then (1 : ℝ) else 0) := by + apply Finset.sum_congr rfl + intro m _ + split_ifs <;> norm_num + _ = 5 := by norm_num [Finset.sum_sub_distrib, hc] + rw [hs] + norm_num [interferenceTestCode, interferenceMessageCounts, Fin.prod_univ_succ] + +end CapacityAtlas.Tests diff --git a/lean/CapacityAtlasForMathlib.lean b/lean/CapacityAtlasForMathlib.lean index bbdb09a..0e27a15 100644 --- a/lean/CapacityAtlasForMathlib.lean +++ b/lean/CapacityAtlasForMathlib.lean @@ -95,3 +95,4 @@ import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.BlockEntr import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.Converse import CapacityAtlasForMathlib.InformationTheory.GaussianMIMOBroadcast.Achievability import CapacityAtlasForMathlib.Network.WirelessTransport.Capacity +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Capacity diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Achievability.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Achievability.lean new file mode 100644 index 0000000..7cdaa4d --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Achievability.lean @@ -0,0 +1,72 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.QAMInformation +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.BlockAchievability +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.BasicFacts + +open MeasureTheory Filter +open scoped BigOperators Topology + +namespace CapacityAtlas.Gaussian.Interference + +theorem qam_sum_lower (μ : Measure ℂ) [IsProbabilityMeasure μ] [NullSingletonClass μ] + {K n q : ℕ} (hq : 0 < q) (δ : ℝ) (hδ : 0 < δ) (M : ℝ) + (hM : ∀ᵐ h ∂μ, ‖h‖ ≤ M) {ε : ℝ} + (hε : (environmentLaw μ K n).real (noiseBad δ) ≤ ε) + (hB : BddAbove {s | ∃ R ∈ capacityRegion μ K + (qamPowerFactor K n M δ * (q : ℝ) ^ 2), s = ∑ i, R i}) : + K * ((((1 - ε) * (2 * Fintype.card (Box (Fin K) n) * Real.log q) - Real.log 2) / + Real.log 2) / extensionLength K n - 1) ≤ + sumCapacity μ K (qamPowerFactor K n M δ * (q : ℝ) ^ 2) := by + letI : NeZero q := ⟨hq.ne'⟩ + let r := (((1 - ε) * (2 * Fintype.card (Box (Fin K) n) * Real.log q) - Real.log 2) / + Real.log 2) / extensionLength K n - 1 + change (K : ℝ) * r ≤ _ + by_cases hr : r ≤ 0 + · exact (mul_nonpos_of_nonneg_of_nonpos (Nat.cast_nonneg K) hr).trans + (sumCapacity_nonneg hB) + · have hL : (0 : ℝ) < extensionLength K n := by + exact_mod_cast extensionLength_pos K n + have hP : 0 ≤ qamPowerFactor K n M δ * (q : ℝ) ^ 2 := by + unfold qamPowerFactor + positivity + have hR := (qamScheme μ hq δ hδ M hM).capacityRegion_of_lt + (extensionLength_pos K n) hP (fun _ => r) (fun _ => (lt_of_not_ge hr).le) (by + intro i + have hi := div_le_div_of_nonneg_right (qam_information_lower μ hq δ hδ hε i) hL.le + change r < (qamChannel μ (n := n) hq δ i).informationCapacityBits / extensionLength K n + dsimp [r] + linarith) + simpa only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + using sum_le_sumCapacity hB hR + +/-- Fixed spacing gives a quadratic power grid with arbitrarily small Fano loss. -/ +theorem exists_quadratic_grid_lower (μ : Measure ℂ) [IsProbabilityMeasure μ] + [NullSingletonClass μ] {K : ℕ} (hK : 0 < K) (M : ℝ) + (hM : ∀ᵐ h ∂μ, ‖h‖ ≤ M) + (hB : ∀ P, BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i}) + {n : ℕ} (hn : 0 < n) {ε : ℝ} (hε : 0 < ε) : + ∃ C : ℝ, 0 < C ∧ ∃ b : ℝ, ∀ᶠ q : ℕ in atTop, + (K * (1 - ε) * 2 * Fintype.card (Box (Fin K) n) / extensionLength K n) * Real.log q - b ≤ + sumCapacity μ K (C * (q : ℝ) ^ 2) * Real.log 2 := by + obtain ⟨δ, hδ, he⟩ := exists_qam_spacing μ K n hε + refine ⟨qamPowerFactor K n M δ, qamPowerFactor_pos hK hn M δ hδ, + K * (Real.log 2 / extensionLength K n + Real.log 2), ?_⟩ + filter_upwards [eventually_gt_atTop 0] with q hq + have h := mul_le_mul_of_nonneg_right + (qam_sum_lower μ hq δ hδ M hM he.le (hB _)) (Real.log_nonneg (by norm_num : (1 : ℝ) ≤ 2)) + have hL : (extensionLength K n : ℝ) ≠ 0 := by + exact_mod_cast (extensionLength_pos K n).ne' + have hlog : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num : (1 : ℝ) < 2)).ne' + calc + _ = K * ((((1 - ε) * (2 * Fintype.card (Box (Fin K) n) * Real.log q) - Real.log 2) / + Real.log 2) / extensionLength K n - 1) * Real.log 2 := by + field_simp + ring + _ ≤ _ := h + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Alignment.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Alignment.lean new file mode 100644 index 0000000..7e91a4f --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Alignment.lean @@ -0,0 +1,106 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Monomials +import Mathlib.LinearAlgebra.Matrix.NonsingularInverse +import Mathlib.LinearAlgebra.Matrix.ToLin + +open scoped BigOperators Matrix + +namespace CapacityAtlas.Gaussian.Interference + +variable {U R : Type*} [Fintype U] [DecidableEq U] [Field R] {n : ℕ} + +abbrev FadingBlock (U : Type*) [DecidableEq U] (n : ℕ) (R : Type*) := + Columns U n → U × U → R + +def decodingMatrix (h : FadingBlock U n R) (i : U) : + Matrix (Columns U n) (Columns U n) R := + fun r ↦ Sum.elim (fun a ↦ h r (i, i) * beam (h r) a) (beam (h r)) + +theorem eval_decodingPolynomial (h : FadingBlock U n R) (i : U) : + MvPolynomial.eval (fun p ↦ h p.1 p.2) (decodingPolynomial (n := n) i) = + (decodingMatrix h i).det := by + classical + change (MvPolynomial.eval (fun p ↦ h p.1 p.2)) + (Matrix.det (MonomialEvaluation.matrix (columnExponent i))) = _ + rw [RingHom.map_det] + congr 1 + ext r c + exact (MonomialEvaluation.eval_matrix _ _ r c).trans (eval_column _ _ _) + +noncomputable def decoder (h : FadingBlock U n R) (i : U) : + (Columns U n → R) →ₗ[R] (Box U n → R) := + LinearMap.pi (fun a ↦ (LinearMap.proj (Sum.inl a)).comp + (decodingMatrix h i)⁻¹.mulVecLin) + +theorem decoder_column (h : FadingBlock U n R) (i : U) + (hi : (decodingMatrix h i).det ≠ 0) (c : Columns U n) (a : Box U n) : + decoder h i ((decodingMatrix h i).col c) a = + (Pi.single c (1 : R) : Columns U n → R) (Sum.inl a) := by + change ((decodingMatrix h i)⁻¹ *ᵥ (decodingMatrix h i).col c) (Sum.inl a) = _ + rw [← Matrix.mulVec_single_one, Matrix.mulVec_mulVec, + Matrix.nonsing_inv_mul _ (isUnit_iff_ne_zero.mpr hi), Matrix.one_mulVec] + +def receivedColumn (h : FadingBlock U n R) (i u : U) (a : Box U n) : + Columns U n → R := fun r ↦ h r (i, u) * beam (h r) a + +theorem receivedColumn_self (h : FadingBlock U n R) (i : U) (a : Box U n) : + receivedColumn h i i a = (decodingMatrix h i).col (Sum.inl a) := rfl + +theorem receivedColumn_other (h : FadingBlock U n R) (i u : U) (hiu : i ≠ u) + (a : Box U n) : + receivedColumn h i u a = + (decodingMatrix h i).col (Sum.inr (shifted a ⟨(i, u), hiu⟩)) := by + funext r + exact (beam_shifted (h r) a ⟨(i, u), hiu⟩).symm + +theorem decoder_receivedColumn (h : FadingBlock U n R) (i : U) + (hi : (decodingMatrix h i).det ≠ 0) (u : U) (a : Box U n) : + decoder h i (receivedColumn h i u a) = if i = u then Pi.single a 1 else 0 := by + ext b + by_cases hiu : i = u + · subst u + rw [receivedColumn_self, decoder_column h i hi] + simp [Pi.single_apply] + · rw [receivedColumn_other h i u hiu, decoder_column h i hi] + simp [hiu] + +def transmitted (h : FadingBlock U n R) (x : Box U n → R) : Columns U n → R := + fun r ↦ ∑ a, beam (h r) a * x a + +def received (h : FadingBlock U n R) (x : U → Box U n → R) (i : U) : + Columns U n → R := fun r ↦ ∑ u, h r (i, u) * transmitted h (x u) r + +theorem received_eq_sum (h : FadingBlock U n R) (x : U → Box U n → R) (i : U) : + received h x i = ∑ u, ∑ a, x u a • receivedColumn h i u a := by + ext r + simp only [received, transmitted, Finset.sum_apply, Pi.smul_apply, smul_eq_mul, + receivedColumn, Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + apply Finset.sum_congr rfl + intro a _ + ring + +/-- Every desired stream is recovered while every other transmitter is canceled. -/ +theorem decoder_received (h : FadingBlock U n R) (i : U) + (hi : (decodingMatrix h i).det ≠ 0) (x : U → Box U n → R) : + decoder h i (received h x i) = x i := by + classical + rw [received_eq_sum] + simp_rw [map_sum, map_smul, decoder_receivedColumn h i hi] + ext a + simp only [ite_apply, Finset.sum_apply, Pi.smul_apply, smul_eq_mul, Pi.zero_apply] + simp [Pi.single_apply] + +theorem decoder_received_add_noise (h : FadingBlock U n R) (i : U) + (hi : (decodingMatrix h i).det ≠ 0) (x : U → Box U n → R) + (z : Columns U n → R) : + decoder h i (received h x i + z) = x i + decoder h i z := by + rw [map_add, decoder_received h i hi] + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentBounds.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentBounds.lean new file mode 100644 index 0000000..7d23ccf --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentBounds.lean @@ -0,0 +1,89 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.AlignmentMeasure +import Mathlib.Analysis.SpecificLimits.Basic + +open scoped BigOperators +open Filter Topology + +namespace CapacityAtlas.Gaussian.Interference + +variable {U : Type*} [Fintype U] [DecidableEq U] {n : ℕ} + +omit [Fintype U] in +theorem beamExponent_le (a : Box U n) (p : U × U) : beamExponent a p ≤ n := by + unfold beamExponent + split_ifs with hp + · exact (a ⟨p, hp⟩).isLt.le + · exact Nat.zero_le _ + +def beamBound (U : Type*) [Fintype U] (n : ℕ) (M : ℝ) : ℝ := + (max 1 M) ^ (n * Fintype.card (U × U)) + +omit [DecidableEq U] in +theorem beamBound_pos (M : ℝ) : 0 < beamBound U n M := by + unfold beamBound + positivity + +theorem norm_beam_le (h : U × U → ℂ) (M : ℝ) (hh : ∀ p, ‖h p‖ ≤ M) + (a : Box U n) : ‖beam h a‖ ≤ beamBound U n M := by + classical + unfold beam beamBound + rw [norm_prod] + calc + _ ≤ ∏ _ : U × U, (max 1 M) ^ n := by + apply Finset.prod_le_prod + · intro p _ + exact norm_nonneg _ + · intro p _ + rw [norm_pow] + calc + _ ≤ (max 1 M) ^ beamExponent a p := by + gcongr + exact (hh p).trans (le_max_right _ _) + _ ≤ (max 1 M) ^ n := by + exact pow_le_pow_right₀ (le_max_left _ _) (beamExponent_le a p) + _ = (max 1 M) ^ (n * Fintype.card (U × U)) := by + simp [← pow_mul] + +theorem norm_transmitted_le (h : FadingBlock U n ℂ) (M Q : ℝ) + (hh : ∀ r p, ‖h r p‖ ≤ M) + (x : Box U n → ℂ) (hx : ∀ a, ‖x a‖ ≤ Q) (r : Columns U n) : + ‖transmitted h x r‖ ≤ Fintype.card (Box U n) * beamBound U n M * Q := by + classical + calc + _ ≤ ∑ a, ‖beam (h r) a * x a‖ := norm_sum_le _ _ + _ ≤ ∑ _ : Box U n, beamBound U n M * Q := by + apply Finset.sum_le_sum + intro a _ + rw [norm_mul] + exact mul_le_mul (norm_beam_le _ M (hh r) a) (hx a) (norm_nonneg _) + (beamBound_pos M).le + _ = _ := by simp [mul_assoc] + +theorem monomial_fraction_tendsto (g : ℕ) : + Tendsto (fun n : ℕ ↦ (n : ℝ) ^ g / ((n : ℝ) ^ g + ((n : ℝ) + 1) ^ g)) + atTop (𝓝 (1 / 2 : ℝ)) := by + have ht : Tendsto (fun n : ℕ ↦ ((n : ℝ) / ((n : ℝ) + 1)) ^ g) atTop (𝓝 1) := by + simpa using (tendsto_natCast_div_add_atTop (1 : ℝ)).pow g + have hf := ht.div (ht.add tendsto_const_nhds) (by norm_num : (1 : ℝ) + 1 ≠ 0) + convert hf using 1 + · funext n + have hp : 0 < ((n : ℝ) + 1) ^ g := by positivity + have hs : 0 < (n : ℝ) ^ g + ((n : ℝ) + 1) ^ g := by positivity + dsimp only [Pi.div_apply] + rw [div_pow] + field_simp + · norm_num + +theorem stream_fraction_tendsto : + Tendsto (fun n : ℕ ↦ (Fintype.card (Box U n) : ℝ) / Fintype.card (Columns U n)) + atTop (𝓝 (1 / 2 : ℝ)) := by + simpa only [card_box, card_columns, Nat.cast_pow, Nat.cast_add, Nat.cast_one] using + monomial_fraction_tendsto (Fintype.card (Cross U)) + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentChannel.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentChannel.lean new file mode 100644 index 0000000..0a87344 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentChannel.lean @@ -0,0 +1,127 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Basic +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.AlignmentBounds +import Mathlib.Probability.ProductMeasure + +open MeasureTheory ProbabilityTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +def extensionLength (K n : ℕ) : ℕ := Fintype.card (Columns (Fin K) n) + +theorem extensionLength_pos (K n : ℕ) : 0 < extensionLength K n := by + rw [extensionLength, card_columns] + have hp : 0 < (n + 1) ^ Fintype.card (Cross (Fin K)) := Nat.pow_pos (by omega) + omega + +noncomputable def slotEquiv (K n : ℕ) : Columns (Fin K) n ≃ Fin (extensionLength K n) := + Fintype.equivFin _ + +noncomputable def stateFading {K n : ℕ} (H : StateBlock K (extensionLength K n)) : + FadingBlock (Fin K) n ℂ := fun c p ↦ H (slotEquiv K n c) p.1 p.2 + +noncomputable def flatState {K n : ℕ} (H : StateBlock K (extensionLength K n)) : + Columns (Fin K) n × (Fin K × Fin K) → ℂ := fun p ↦ stateFading H p.1 p.2 + +theorem measurePreserving_flatState (μ : Measure ℂ) [IsProbabilityMeasure μ] (K n : ℕ) : + MeasurePreserving (flatState (K := K) (n := n)) (stateLaw μ K (extensionLength K n)) + (Measure.pi fun _ ↦ μ) := by + let U := Fin K + let C := Columns U n + have h₁ := measurePreserving_piCongrLeft + (fun _ : Fin (extensionLength K n) ↦ Measure.pi fun _ : U ↦ Measure.pi fun _ : U ↦ μ) + (slotEquiv K n) + have h₂ : MeasurePreserving (MeasurableEquiv.curry U U ℂ).symm + (Measure.pi fun _ : U ↦ Measure.pi fun _ : U ↦ μ) + (Measure.pi fun _ : U × U ↦ μ) := + ⟨by fun_prop, by simpa only [Measure.infinitePi_eq_pi] using + Measure.infinitePi_map_curry_symm (fun _ : U ↦ fun _ : U ↦ μ)⟩ + have h₃ := measurePreserving_pi + (fun _ : C ↦ Measure.pi fun _ : U ↦ Measure.pi fun _ : U ↦ μ) + (fun _ : C ↦ Measure.pi fun _ : U × U ↦ μ) (fun _ ↦ h₂) + have h₄ : MeasurePreserving (MeasurableEquiv.curry C (U × U) ℂ).symm + (Measure.pi fun _ : C ↦ Measure.pi fun _ : U × U ↦ μ) + (Measure.pi fun _ : C × (U × U) ↦ μ) := + ⟨by fun_prop, by simpa only [Measure.infinitePi_eq_pi] using + Measure.infinitePi_map_curry_symm (fun _ : C ↦ fun _ : U × U ↦ μ)⟩ + exact h₄.comp (h₃.comp h₁.symm) + +theorem ae_stateFading_nonsingular (μ : Measure ℂ) [IsProbabilityMeasure μ] + [NullSingletonClass μ] (K n : ℕ) : + ∀ᵐ H ∂stateLaw μ K (extensionLength K n), ∀ i : Fin K, + (decodingMatrix (stateFading H) i).det ≠ 0 := + (measurePreserving_flatState μ K n).quasiMeasurePreserving.ae + (ae_decodingMatrix_nonsingular (fun _ ↦ μ)) + +noncomputable def alignedTransmit {K n : ℕ} (H : StateBlock K (extensionLength K n)) + (x : Box (Fin K) n → ℂ) (t : Fin (extensionLength K n)) : ℂ := + transmitted (stateFading H) x ((slotEquiv K n).symm t) + +theorem alignedTransmit_current {K n : ℕ} (H : StateBlock K (extensionLength K n)) + (x : Box (Fin K) n → ℂ) (t : Fin (extensionLength K n)) : + alignedTransmit H x t = ∑ a, beam (fun p : Fin K × Fin K ↦ H t p.1 p.2) a * x a := by + unfold alignedTransmit transmitted stateFading + simp only [Equiv.apply_symm_apply] + +theorem alignedTransmit_causal {K n : ℕ} (H H' : StateBlock K (extensionLength K n)) + (x : Box (Fin K) n → ℂ) (t : Fin (extensionLength K n)) (hh : H t = H' t) : + alignedTransmit H x t = alignedTransmit H' x t := by + simp only [alignedTransmit_current, hh] + +theorem measurable_alignedTransmit {K n : ℕ} (x : Box (Fin K) n → ℂ) + (t : Fin (extensionLength K n)) : + Measurable (fun H : StateBlock K (extensionLength K n) ↦ alignedTransmit H x t) := by + simp only [alignedTransmit_current, beam] + fun_prop + +theorem norm_alignedTransmit_le {K n : ℕ} (H : StateBlock K (extensionLength K n)) + (M Q : ℝ) (hh : ∀ t i j, ‖H t i j‖ ≤ M) (x : Box (Fin K) n → ℂ) + (hx : ∀ a, ‖x a‖ ≤ Q) (t : Fin (extensionLength K n)) : + ‖alignedTransmit H x t‖ ≤ Fintype.card (Box (Fin K) n) * beamBound (Fin K) n M * Q := + norm_transmitted_le (stateFading H) M Q (fun _ _ ↦ hh _ _ _) x hx _ + +noncomputable def alignedDecode {K n : ℕ} (H : StateBlock K (extensionLength K n)) + (i : Fin K) (y : Fin (extensionLength K n) → ℂ) : Box (Fin K) n → ℂ := + decoder (stateFading H) i (fun c ↦ y (slotEquiv K n c)) + +theorem measurable_alignedDecode {K n : ℕ} (i : Fin K) (a : Box (Fin K) n) : + Measurable (fun hy : StateBlock K (extensionLength K n) × + (Fin (extensionLength K n) → ℂ) ↦ alignedDecode hy.1 i hy.2 a) := by + unfold alignedDecode + have hm : Measurable (fun hy : StateBlock K (extensionLength K n) × + (Fin (extensionLength K n) → ℂ) ↦ + (stateFading hy.1, fun c ↦ hy.2 (slotEquiv K n c))) := by + apply Measurable.prodMk + · apply measurable_pi_lambda + intro c + apply measurable_pi_lambda + intro p + exact (measurable_pi_apply p.2).comp ((measurable_pi_apply p.1).comp + ((measurable_pi_apply (slotEquiv K n c)).comp measurable_fst)) + · apply measurable_pi_lambda + intro c + exact (measurable_pi_apply (slotEquiv K n c)).comp measurable_snd + have hc := (measurable_decoder_apply (U := Fin K) (n := n) i a).comp hm + exact hc + +theorem alignedDecode_signal_add_noise {K n : ℕ} (H : StateBlock K (extensionLength K n)) + (i : Fin K) (hi : (decodingMatrix (stateFading H) i).det ≠ 0) + (x : Fin K → Box (Fin K) n → ℂ) (z : Fin (extensionLength K n) → ℂ) : + alignedDecode H i (fun t ↦ (∑ j, H t i j * alignedTransmit H (x j) t) + z t) = + x i + alignedDecode H i z := by + unfold alignedDecode + have he : (fun c ↦ (∑ j, H (slotEquiv K n c) i j * + alignedTransmit H (x j) (slotEquiv K n c)) + z (slotEquiv K n c)) = + received (stateFading H) x i + fun c ↦ z (slotEquiv K n c) := by + ext c + simp [received, stateFading, alignedTransmit] + rw [he] + exact decoder_received_add_noise _ i hi x _ + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentMeasure.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentMeasure.lean new file mode 100644 index 0000000..200da1e --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AlignmentMeasure.lean @@ -0,0 +1,82 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Alignment +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.PolynomialMeasure +import Mathlib.Topology.Instances.Matrix + +open scoped BigOperators Matrix +open MeasureTheory + +namespace CapacityAtlas.Gaussian.Interference + +variable {U : Type*} [Fintype U] [DecidableEq U] {n : ℕ} + +theorem continuous_beam (a : Box U n) : Continuous (fun h : U × U → ℂ ↦ beam h a) := by + unfold beam + fun_prop + +theorem continuous_decodingMatrix (i : U) : + Continuous (fun h : FadingBlock U n ℂ ↦ decodingMatrix h i) := by + apply continuous_pi + intro r + apply continuous_pi + intro c + cases c with + | inl a => + change Continuous (fun h : FadingBlock U n ℂ ↦ h r (i, i) * beam (h r) a) + unfold beam + fun_prop + | inr a => + change Continuous (fun h : FadingBlock U n ℂ ↦ beam (h r) a) + exact (continuous_beam a).comp (continuous_apply r) + +noncomputable local instance : MeasurableSpace (Matrix (Columns U n) (Columns U n) ℂ) := + inferInstanceAs (MeasurableSpace (Columns U n → Columns U n → ℂ)) + +local instance : BorelSpace (Matrix (Columns U n) (Columns U n) ℂ) := + inferInstanceAs (BorelSpace (Columns U n → Columns U n → ℂ)) + +theorem measurable_inverse_decodingMatrix (i : U) : + Measurable (fun h : FadingBlock U n ℂ ↦ (decodingMatrix h i)⁻¹) := by + simp only [Matrix.inv_def, Ring.inverse_eq_inv] + exact (continuous_decodingMatrix i).matrix_det.measurable.inv.smul + (continuous_decodingMatrix i).matrix_adjugate.measurable + +theorem measurable_decoder_apply (i : U) (a : Box U n) : + Measurable (fun hy : FadingBlock U n ℂ × (Columns U n → ℂ) ↦ + decoder hy.1 i hy.2 a) := by + change Measurable (fun hy : FadingBlock U n ℂ × (Columns U n → ℂ) ↦ + ∑ r, ((decodingMatrix hy.1 i)⁻¹) (Sum.inl a) r * hy.2 r) + apply Finset.measurable_sum + intro r _ + exact ((measurable_pi_apply r).comp + ((measurable_pi_apply (Sum.inl a)).comp + ((measurable_inverse_decodingMatrix i).comp measurable_fst))).mul + ((measurable_pi_apply r).comp measurable_snd) + +/-- All receivers' desired and interference columns are independent almost surely. -/ +theorem ae_decodingMatrix_nonsingular + (μ : Columns U n × (U × U) → Measure ℂ) + [∀ p, IsProbabilityMeasure (μ p)] [∀ p, NullSingletonClass (μ p)] : + ∀ᵐ h ∂Measure.pi μ, ∀ i : U, + (decodingMatrix (fun r p ↦ h (r, p)) i).det ≠ 0 := by + rw [ae_all_iff] + intro i + filter_upwards [ae_eval_ne_zero (decodingPolynomial (n := n) i) + (decodingPolynomial_ne_zero i) μ] with h hh + exact (eval_decodingPolynomial (fun r p ↦ h (r, p)) i) ▸ hh + +theorem ae_decoder_received_add_noise + (μ : Columns U n × (U × U) → Measure ℂ) + [∀ p, IsProbabilityMeasure (μ p)] [∀ p, NullSingletonClass (μ p)] : + ∀ᵐ h ∂Measure.pi μ, ∀ (i : U) (x : U → Box U n → ℂ) (z : Columns U n → ℂ), + decoder (fun r p ↦ h (r, p)) i (received (fun r p ↦ h (r, p)) x i + z) = + x i + decoder (fun r p ↦ h (r, p)) i z := by + filter_upwards [ae_decodingMatrix_nonsingular μ] with h hh + exact fun i x z ↦ decoder_received_add_noise _ i (hh i) x z + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AsymptoticSqueeze.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AsymptoticSqueeze.lean new file mode 100644 index 0000000..a498e0d --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/AsymptoticSqueeze.lean @@ -0,0 +1,63 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.AlignmentChannel +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.LogarithmicInterpolation +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.ConverseAsymptotics + +open Filter Topology + +namespace CapacityAtlas.Gaussian.Interference + +theorem alignment_slope_tendsto (K : ℕ) : + Tendsto (fun n : ℕ ↦ (K : ℝ) * (1 - 1 / ((n : ℝ) + 1)) * + ((Fintype.card (Box (Fin K) n) : ℝ) / extensionLength K n)) + atTop (𝓝 ((K : ℝ) / 2)) := by + have hε : Tendsto (fun n : ℕ ↦ (1 : ℝ) - 1 / ((n : ℝ) + 1)) atTop (𝓝 1) := by + simpa using tendsto_const_nhds.sub (tendsto_one_div_add_atTop_nhds_zero_nat (𝕜 := ℝ)) + have hr := stream_fraction_tendsto (U := Fin K) + convert (hε.const_mul (K : ℝ)).mul hr using 1 <;> simp [extensionLength, div_eq_mul_inv] + +/-- Matching alignment slopes and the Gaussian logarithmic upper bound determine the prelog. -/ +theorem prelog_of_alignment_grid {K : ℕ} {F : ℝ → ℝ} (hF : Monotone F) + {c : ℝ} (hc : 0 < c) + (hupper : ∀ᶠ P : ℝ in atTop, F P ≤ (K : ℝ) / 2 * Real.log (1 + c * P)) + (hlower : ∀ n : ℕ, 0 < n → ∀ ε : ℝ, 0 < ε → + ∃ C : ℝ, 0 < C ∧ ∃ b : ℝ, ∀ᶠ q : ℕ in atTop, + ((K : ℝ) * (1 - ε) * 2 * Fintype.card (Box (Fin K) n) / + extensionLength K n) * Real.log q - b ≤ F (C * (q : ℝ) ^ 2)) : + Tendsto (fun P : ℝ ↦ F P / Real.log P) atTop (𝓝 ((K : ℝ) / 2)) := by + rw [tendsto_order] + constructor + · intro a ha + obtain ⟨d, had, hdk⟩ := exists_between ha + have hs := (alignment_slope_tendsto K).eventually (isOpen_Ioi.mem_nhds hdk) + obtain ⟨n, hn, hdn⟩ := ((eventually_ge_atTop (1 : ℕ)).and hs).exists + have heps : 0 < (1 : ℝ) / ((n : ℝ) + 1) := by positivity + obtain ⟨C, hC, b, hgrid⟩ := hlower n (by omega) _ heps + have hd : d < + ((K : ℝ) * (1 - 1 / ((n : ℝ) + 1)) * 2 * Fintype.card (Box (Fin K) n) / + extensionLength K n) / 2 := by + have heq : + ((K : ℝ) * (1 - 1 / ((n : ℝ) + 1)) * 2 * Fintype.card (Box (Fin K) n) / + extensionLength K n) / 2 = + (K : ℝ) * (1 - 1 / ((n : ℝ) + 1)) * + ((Fintype.card (Box (Fin K) n) : ℝ) / extensionLength K n) := by ring + rw [heq] + exact hdn + filter_upwards [eventually_lower_bound_of_quadratic_grid hF hC hd hgrid] with P hP + exact had.trans_le hP + · intro b hb + have hlim : Tendsto (fun P : ℝ ↦ (K : ℝ) / 2 * + (Real.log (1 + c * P) / Real.log P)) atTop (𝓝 ((K : ℝ) / 2)) := by + simpa using (log_affine_div_log_tendsto hc).const_mul ((K : ℝ) / 2) + filter_upwards [hupper, hlim.eventually (isOpen_Iio.mem_nhds hb), + eventually_gt_atTop (1 : ℝ)] with P hup hbP hP + apply lt_of_le_of_lt _ hbP + simpa only [mul_div_assoc] using + div_le_div_of_nonneg_right hup (Real.log_pos hP).le + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Basic.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Basic.lean new file mode 100644 index 0000000..3d1bcce --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Basic.lean @@ -0,0 +1,128 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianOperational +import Mathlib.Probability.Distributions.Gaussian.Multivariate +import Mathlib.Analysis.Complex.Basic +import CapacityAtlasUtil + +open MeasureTheory ProbabilityTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +abbrev State (K : ℕ) := Fin K → Fin K → ℂ +abbrev StateBlock (K n : ℕ) := Fin n → State K +abbrev Noise (K n : ℕ) := Fin K → Fin n → EuclideanSpace ℝ (Fin 2) + +/-- All directed channel coefficients, including direct links, are sampled independently. -/ +noncomputable def stateLaw (μ : Measure ℂ) (K n : ℕ) : Measure (StateBlock K n) := + Measure.pi fun _ : Fin n => Measure.pi fun _ : Fin K => Measure.pi fun _ : Fin K => μ + +instance (μ : Measure ℂ) [IsProbabilityMeasure μ] (K n : ℕ) : + IsProbabilityMeasure (stateLaw μ K n) := by unfold stateLaw; infer_instance + +def complexNoise (z : EuclideanSpace ℝ (Fin 2)) : ℂ := z 0 + z 1 * Complex.I + +/-- Independent real and imaginary noise coordinates each have variance one half. -/ +noncomputable def blockNoise (K n : ℕ) : Measure (Noise K n) := + Measure.pi fun _ : Fin K => Measure.pi fun _ : Fin n => + multivariateGaussian 0 ((1 / 2 : ℝ) • (1 : Matrix (Fin 2) (Fin 2) ℝ)) + +instance (K n : ℕ) : IsProbabilityMeasure (blockNoise K n) := by + unfold blockNoise + infer_instance + +/-- Encoders know their own messages and the channel history through the current use. -/ +@[capacity_problem "k-user-gaussian-interference-channel", capacity_definition] +structure Code (K n : ℕ) where + messages : Fin K → ℕ + messages_pos : ∀ i, 0 < messages i + encode : (i : Fin K) → Fin (messages i) → StateBlock K n → Fin n → ℂ + encode_measurable : ∀ i m t, Measurable fun H => encode i m H t + encode_causal : ∀ i m t H H', (∀ s, s ≤ t → H s = H' s) → + encode i m H t = encode i m H' t + decode : (i : Fin K) → Decoder (StateBlock K n × (Fin n → ℂ)) (messages i) + +variable {K n : ℕ} + +abbrev Code.Message (c : Code K n) := (i : Fin K) → Fin (c.messages i) + +def output (c : Code K n) (m : c.Message) (H : StateBlock K n) (z : Noise K n) + (i : Fin K) : Fin n → ℂ := + fun t => (∑ j, H t i j * c.encode j (m j) H t) + complexNoise (z i t) + +@[fun_prop] +theorem measurable_output (c : Code K n) (m : c.Message) (i : Fin K) : + Measurable fun hz : StateBlock K n × Noise K n => output c m hz.1 hz.2 i := by + unfold output complexNoise + apply measurable_pi_lambda + intro t + apply Measurable.add + · apply Finset.measurable_sum + intro j _ + have hcoef : Measurable fun hz : StateBlock K n × Noise K n => hz.1 t i j := by + fun_prop + exact hcoef.mul ((c.encode_measurable j (m j) t).comp measurable_fst) + · fun_prop + +noncomputable def energy (c : Code K n) (m : c.Message) (H : StateBlock K n) : ℝ := + ∑ t, ∑ i, ‖c.encode i (m i) H t‖ ^ 2 + +/-- One power budget, averaged over the independent uniform messages and fading. -/ +def PowerAdmissible (μ : Measure ℂ) (P : ℝ) (c : Code K n) : Prop := + (∀ m, Integrable (energy c m) (stateLaw μ K n)) ∧ + (∏ i, (c.messages i : ℝ))⁻¹ * + (∑ m, ∫ H, energy c m H ∂stateLaw μ K n) ≤ (n : ℝ) * P + +def errorEvent (c : Code K n) (m : c.Message) : Set (StateBlock K n × Noise K n) := + {hz | ∃ i, (c.decode i).apply (hz.1, output c m hz.1 hz.2 i) ≠ m i} + +theorem measurableSet_errorEvent (c : Code K n) (m : c.Message) : + MeasurableSet (errorEvent c m) := by + unfold errorEvent + simp only [Set.setOf_exists] + apply MeasurableSet.iUnion + intro i + exact (((c.decode i).measurable_fiber (m i)).preimage + (measurable_fst.prodMk (measurable_output c m i))).compl + +noncomputable def error (μ : Measure ℂ) (c : Code K n) : ℝ := + (∏ i, (c.messages i : ℝ))⁻¹ * ∑ m, + (((stateLaw μ K n).prod (blockNoise K n)) (errorEvent c m)).toReal + +noncomputable def rates (c : Code K n) (i : Fin K) : ℝ := + Operational.messageRate (c.messages i) n + +@[capacity_problem "k-user-gaussian-interference-channel", capacity_definition] +noncomputable def capacityRegion (μ : Measure ℂ) (K : ℕ) (P : ℝ) : Set (Fin K → ℝ) := + Operational.achievableVectorRegion (Code K) (fun _ c => PowerAdmissible μ P c) + (fun _ c => error μ c) (fun _ c => rates c) + +@[capacity_problem "k-user-gaussian-interference-channel", capacity_definition] +noncomputable def sumCapacity (μ : Measure ℂ) (K : ℕ) (P : ℝ) : ℝ := + sSup {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} + +theorem error_nonneg (μ : Measure ℂ) (c : Code K n) : 0 ≤ error μ c := by + unfold error + positivity + +theorem error_le_one (μ : Measure ℂ) [IsProbabilityMeasure μ] (c : Code K n) : + error μ c ≤ 1 := by + have hpos : 0 < ∏ i, (c.messages i : ℝ) := + Finset.prod_pos fun i _ => Nat.cast_pos.mpr (c.messages_pos i) + unfold error + calc + _ ≤ (∏ i, (c.messages i : ℝ))⁻¹ * ∑ _ : c.Message, (1 : ℝ) := by + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr hpos.le) + exact Finset.sum_le_sum fun _ _ => measureReal_le_one + _ = 1 := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] + have hc : (Fintype.card c.Message : ℝ) = ∏ i, (c.messages i : ℝ) := by + simp [Code.Message, Fintype.card_pi] + rw [hc, inv_mul_cancel₀ hpos.ne'] + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BasicFacts.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BasicFacts.lean new file mode 100644 index 0000000..f777362 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BasicFacts.lean @@ -0,0 +1,147 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Basic + +open MeasureTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +def silentCode (K n : ℕ) : Code K n where + messages := fun _ ↦ 1 + messages_pos := fun _ ↦ Nat.zero_lt_one + encode := fun _ _ _ _ ↦ 0 + encode_measurable := fun _ _ _ ↦ measurable_const + encode_causal := fun _ _ _ _ _ _ ↦ rfl + decode := fun _ ↦ + { apply := fun _ ↦ 0 + measurable_fiber := by intro m; simp [Subsingleton.elim m 0] } + +theorem silentCode_powerAdmissible (μ : Measure ℂ) {K n : ℕ} {P : ℝ} (hP : 0 ≤ P) : + PowerAdmissible μ P (silentCode K n) := by + constructor + · intro m + have he : energy (silentCode K n) m = fun _ ↦ 0 := by + funext H + simp [energy, silentCode] + rw [he] + exact integrable_zero _ _ _ + · simpa [energy, silentCode] using mul_nonneg (Nat.cast_nonneg n) hP + +theorem silentCode_error (μ : Measure ℂ) (K n : ℕ) : error μ (silentCode K n) = 0 := by + have hevent (m : (silentCode K n).Message) : errorEvent (silentCode K n) m = ∅ := by + ext hz + simp only [errorEvent, Set.mem_setOf_eq, Set.mem_empty_iff_false, iff_false, + not_exists, not_not] + intro i + change (0 : Fin 1) = m i + exact Subsingleton.elim _ _ + simp [error, hevent] + +theorem silentCode_rates (K n : ℕ) : rates (silentCode K n) = 0 := by + ext i + simp [rates, silentCode, Operational.messageRate] + +theorem zero_mem_capacityRegion (μ : Measure ℂ) (K : ℕ) {P : ℝ} (hP : 0 ≤ P) : + (0 : Fin K → ℝ) ∈ capacityRegion μ K P := by + refine ⟨fun _ ↦ le_rfl, fun ε hε ↦ ⟨1, Nat.zero_lt_one, fun n _ ↦ ?_⟩⟩ + refine ⟨silentCode K n, silentCode_powerAdmissible μ hP, ?_, ?_⟩ + · simpa only [silentCode_error] using hε.le + · intro i + simpa only [silentCode_rates, Pi.zero_apply, zero_sub] using neg_nonpos.mpr hε.le + +theorem PowerAdmissible.mono {μ : Measure ℂ} {K n : ℕ} {P P' : ℝ} {c : Code K n} + (h : PowerAdmissible μ P c) (hPP' : P ≤ P') : PowerAdmissible μ P' c := + ⟨h.1, h.2.trans (mul_le_mul_of_nonneg_left hPP' (Nat.cast_nonneg n))⟩ + +theorem capacityRegion_mono (μ : Measure ℂ) (K : ℕ) {P P' : ℝ} (hPP' : P ≤ P') : + capacityRegion μ K P ⊆ capacityRegion μ K P' := by + rintro R ⟨hR, hcodes⟩ + refine ⟨hR, fun ε hε ↦ ?_⟩ + obtain ⟨N, hN, hc⟩ := hcodes ε hε + refine ⟨N, hN, fun n hn ↦ ?_⟩ + obtain ⟨c, hP, he, hr⟩ := hc n hn + exact ⟨c, hP.mono hPP', he, hr⟩ + +theorem capacityRegion_nonneg {μ : Measure ℂ} {K : ℕ} {P : ℝ} {R : Fin K → ℝ} + (hR : R ∈ capacityRegion μ K P) (i : Fin K) : 0 ≤ R i := hR.1 i + +theorem PowerAdmissible.power_nonneg {μ : Measure ℂ} {K n : ℕ} {P : ℝ} {c : Code K n} + (h : PowerAdmissible μ P c) (hn : 0 < n) : 0 ≤ P := by + have he : 0 ≤ (∏ i, (c.messages i : ℝ))⁻¹ * + (∑ m, ∫ H, energy c m H ∂stateLaw μ K n) := by + apply mul_nonneg + · positivity + · apply Finset.sum_nonneg + intro m _ + apply integral_nonneg + intro H + unfold energy + positivity + have hnp : 0 ≤ (n : ℝ) * P := he.trans h.2 + exact nonneg_of_mul_nonneg_right hnp (Nat.cast_pos.mpr hn) + +theorem capacityRegion_eq_empty_of_neg {μ : Measure ℂ} {K : ℕ} {P : ℝ} (hP : P < 0) : + capacityRegion μ K P = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro R hR + obtain ⟨N, hN, hc⟩ := hR.2 1 zero_lt_one + obtain ⟨c, hpower, _, _⟩ := hc N le_rfl + exact (not_le_of_gt hP) (hpower.power_nonneg hN) + +theorem sumCapacity_eq_zero_of_neg {μ : Measure ℂ} {K : ℕ} {P : ℝ} (hP : P < 0) : + sumCapacity μ K P = 0 := by + simp [sumCapacity, capacityRegion_eq_empty_of_neg hP, Real.sSup_empty] + +theorem sumRates_bddAbove_of_bound {μ : Measure ℂ} {K : ℕ} {P B : ℝ} + (hB : ∀ R ∈ capacityRegion μ K P, ∑ i, R i ≤ B) : + BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} := by + refine ⟨B, ?_⟩ + rintro s ⟨R, hR, rfl⟩ + exact hB R hR + +theorem sum_le_sumCapacity {μ : Measure ℂ} {K : ℕ} {P : ℝ} + (hB : BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i}) + {R : Fin K → ℝ} (hR : R ∈ capacityRegion μ K P) : + ∑ i, R i ≤ sumCapacity μ K P := le_csSup hB ⟨R, hR, rfl⟩ + +theorem sumCapacity_nonneg {μ : Measure ℂ} {K : ℕ} {P : ℝ} + (hB : BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i}) : + 0 ≤ sumCapacity μ K P := by + classical + by_cases hne : ({s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} : Set ℝ).Nonempty + · obtain ⟨s, R, hR, rfl⟩ := hne + exact (Finset.sum_nonneg (fun i _ ↦ hR.1 i)).trans (sum_le_sumCapacity hB hR) + · have he : ({s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} : Set ℝ) = ∅ := + Set.not_nonempty_iff_eq_empty.mp hne + simp [sumCapacity, he, Real.sSup_empty] + +theorem sumCapacity_le {μ : Measure ℂ} {K : ℕ} {P B : ℝ} (hP : 0 ≤ P) + (hB : ∀ R ∈ capacityRegion μ K P, ∑ i, R i ≤ B) : sumCapacity μ K P ≤ B := by + apply csSup_le + · refine ⟨0, 0, zero_mem_capacityRegion μ K hP, ?_⟩ + simp + · rintro s ⟨R, hR, rfl⟩ + exact hB R hR + +theorem sumCapacity_mono {μ : Measure ℂ} {K : ℕ} {P P' : ℝ} (hPP' : P ≤ P') + (hB : BddAbove {s | ∃ R ∈ capacityRegion μ K P', s = ∑ i, R i}) : + sumCapacity μ K P ≤ sumCapacity μ K P' := by + classical + by_cases hne : ({s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} : Set ℝ).Nonempty + · apply csSup_le_csSup hB hne + rintro s ⟨R, hR, hs⟩ + exact ⟨R, capacityRegion_mono μ K hPP' hR, hs⟩ + · have he : ({s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} : Set ℝ) = ∅ := + Set.not_nonempty_iff_eq_empty.mp hne + simpa [sumCapacity, he, Real.sSup_empty] using sumCapacity_nonneg hB + +theorem monotone_sumCapacity (μ : Measure ℂ) (K : ℕ) + (hB : ∀ P, BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i}) : + Monotone (sumCapacity μ K) := fun _ P' hPP' ↦ sumCapacity_mono hPP' (hB P') + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockAchievability.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockAchievability.lean new file mode 100644 index 0000000..8afe616 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockAchievability.lean @@ -0,0 +1,81 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.BlockCoding +import Mathlib.Algebra.Order.Floor.Semifield + +open MeasureTheory ProbabilityTheory Filter +open scoped BigOperators Topology + +namespace CapacityAtlas.Gaussian.Interference.BlockScheme + +private theorem tendsto_block_fraction (L : ℕ) : + Tendsto (fun n : ℕ => ((n / L : ℕ) : ℝ) / n) atTop (𝓝 ((L : ℝ)⁻¹)) := by + have h := (tendsto_nat_floor_mul_div_atTop (R := ℝ) + (a := (L : ℝ)⁻¹) (by positivity)).comp tendsto_natCast_atTop_atTop + simpa only [Function.comp_def, mul_comm (L : ℝ)⁻¹, ← div_eq_mul_inv, + Nat.floor_div_eq_div] using h + +variable {μ : Measure ℂ} [IsProbabilityMeasure μ] {K L : ℕ} {P : ℝ} {A : Type*} +variable [Fintype A] [MeasurableSpace A] [MeasurableSingletonClass A] [Nonempty A] +variable (S : BlockScheme μ K L P A) + +/-- Independent finite outer codes preserve the physical model, including every large blocklength. -/ +theorem capacityRegion_of_lt (hL : 0 < L) (hP : 0 ≤ P) (R : Fin K → ℝ) + (hR : ∀ i, 0 ≤ R i) + (hcap : ∀ i, R i < (S.channel i).informationCapacityBits / L) : + R ∈ capacityRegion μ K P := by + classical + refine ⟨hR, fun ε hε => ?_⟩ + let η := ε / (K + 1 : ℕ) + have hη : 0 < η := div_pos hε (by positivity) + have hcodes : ∀ i : Fin K, ∃ N : ℕ, 0 < N ∧ ∀ b, N ≤ b → + ∃ c : FiniteChannel.BlockCode (S.channel i) b, + c.averageErrorProbability ≤ η ∧ (L : ℝ) * R i ≤ c.rate := by + intro i + apply (S.channel i).achievableRate_of_lt_informationCapacityBits + (rate := (L : ℝ) * R i) + · have h := (lt_div_iff₀ (by exact_mod_cast hL : 0 < (L : ℝ))).mp (hcap i) + simpa only [mul_comm] using h + · exact hη + choose N hN hc using hcodes + have hlengths : ∀ᶠ n : ℕ in atTop, ∀ i, N i ≤ n / L := by + apply eventually_all.mpr + intro i + exact (Nat.tendsto_div_const_atTop hL.ne').eventually (eventually_ge_atTop (N i)) + have hrates : ∀ᶠ n : ℕ in atTop, ∀ i, + R i - ε ≤ ((n / L : ℕ) : ℝ) / n * ((L : ℝ) * R i) := by + apply eventually_all.mpr + intro i + have ht := (tendsto_block_fraction L).mul_const ((L : ℝ) * R i) + have he : (L : ℝ)⁻¹ * ((L : ℝ) * R i) = R i := by + rw [← mul_assoc, inv_mul_cancel₀ (by exact_mod_cast hL.ne'), one_mul] + rw [he] at ht + exact (ht.eventually (eventually_gt_nhds (by linarith : R i - ε < R i))).mono + fun _ hn => hn.le + have hpos : ∀ᶠ n : ℕ in atTop, 0 < n / L := + (Nat.tendsto_div_const_atTop hL.ne').eventually (eventually_gt_atTop 0) + obtain ⟨N₀, hN₀⟩ := eventually_atTop.mp (hlengths.and (hrates.and hpos)) + refine ⟨max N₀ 1, by omega, fun n hn => ?_⟩ + obtain ⟨hncodes, hnrates, hnpos⟩ := hN₀ n (le_trans (le_max_left _ _) hn) + choose c he hr using fun i => hc i (n / L) (hncodes i) + let hpad : n / L * L ≤ n := Nat.div_mul_le_self n L + refine ⟨S.concat hpad c, S.concat_powerAdmissible hpad hP c, ?_, fun i => ?_⟩ + · calc + error μ (S.concat hpad c) ≤ ∑ i, (c i).averageErrorProbability := + S.concat_error_le hpad c + _ ≤ ∑ _ : Fin K, η := Finset.sum_le_sum fun i _ => he i + _ ≤ ε := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] + dsimp [η] + rw [← mul_div_assoc, div_le_iff₀ (by positivity : 0 < ((K + 1 : ℕ) : ℝ))] + norm_num only [Nat.cast_add, Nat.cast_one] + nlinarith + · change R i - ε ≤ rates (S.concat hpad c) i + rw [S.concat_rates hpad hnpos c i] + exact (hnrates i).trans (mul_le_mul_of_nonneg_left (hr i) (by positivity)) + +end CapacityAtlas.Gaussian.Interference.BlockScheme diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockCoding.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockCoding.lean new file mode 100644 index 0000000..3ba9ffb --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockCoding.lean @@ -0,0 +1,223 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.BlockScheme + +open MeasureTheory ProbabilityTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference.BlockScheme + +variable {μ : Measure ℂ} [IsProbabilityMeasure μ] {K L : ℕ} {P : ℝ} {A : Type*} +variable [Fintype A] [MeasurableSpace A] [MeasurableSingletonClass A] +variable (S : BlockScheme μ K L P A) + +omit [IsProbabilityMeasure μ] in +theorem concat_energy {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (m : (i : Fin K) → Fin (c i).messageCount) (H : StateBlock K n) : + energy (S.concat h c) m H = + ∑ s, ∑ t, ∑ i, + ‖S.encode i ((c i).encode (m i) s) (takeStateBlocks h H s) t‖ ^ 2 := by + classical + let f : Fin n → ℝ := fun t => ∑ i, ‖S.concatEncode h c i (m i) H t‖ ^ 2 + have hs : ∑ t ∈ Finset.univ.image (blockPosition h), f t = ∑ t, f t := by + apply Finset.sum_subset (Finset.subset_univ _) + intro t _ ht + have ht' : ¬∃ p, blockPosition h p = t := by simpa only [Finset.mem_image, + Finset.mem_univ, true_and] using ht + simp [f, S.concatEncode_outside h c _ _ _ t ht'] + change (∑ t, f t) = _ + rw [← hs, Finset.sum_image (fun _ _ _ _ hp => blockPosition_injective h hp)] + simp only [f, S.concatEncode_at, Fintype.sum_prod_type] + +theorem concat_ae_energy_le {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (m : (i : Fin K) → Fin (c i).messageCount) : + ∀ᵐ H ∂stateLaw μ K n, energy (S.concat h c) m H ≤ (b * L : ℕ) * P := by + have hblock : ∀ s : Fin b, ∀ᵐ H ∂stateLaw μ K n, + (∑ t, ∑ i, ‖S.encode i ((c i).encode (m i) s) (takeStateBlocks h H s) t‖ ^ 2) + ≤ (L : ℝ) * P := by + intro s + exact ((measurePreserving_eval (fun _ : Fin b => stateLaw μ K L) s).comp + (measurePreserving_takeStateBlocks μ h)).quasiMeasurePreserving.ae + (S.power (fun i => (c i).encode (m i) s)) + filter_upwards [ae_all_iff.mpr hblock] with H hH + rw [S.concat_energy] + calc + _ ≤ ∑ _ : Fin b, (L : ℝ) * P := Finset.sum_le_sum fun s _ => hH s + _ = (b * L : ℕ) * P := by simp [mul_assoc] + +theorem concat_powerAdmissible {b n : ℕ} (h : b * L ≤ n) (hP : 0 ≤ P) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) : + PowerAdmissible μ P (S.concat h c) := by + classical + have hbound (m : (S.concat h c).Message) : + ∀ᵐ H ∂stateLaw μ K n, energy (S.concat h c) m H ≤ (n : ℝ) * P := + (S.concat_ae_energy_le h c m).mono fun _ hm => hm.trans + (mul_le_mul_of_nonneg_right (by exact_mod_cast h) hP) + have hint (m : (S.concat h c).Message) : Integrable (energy (S.concat h c) m) + (stateLaw μ K n) := by + refine (integrable_const ((n : ℝ) * P)).mono_nonneg ?_ ?_ (hbound m) + · apply Measurable.aestronglyMeasurable + unfold energy + fun_prop + · exact Filter.Eventually.of_forall fun _ => Finset.sum_nonneg fun _ _ => + Finset.sum_nonneg fun _ _ => sq_nonneg _ + refine ⟨hint, ?_⟩ + have hp : 0 < ∏ i, ((S.concat h c).messages i : ℝ) := + Finset.prod_pos fun i _ => Nat.cast_pos.mpr ((S.concat h c).messages_pos i) + calc + _ ≤ (∏ i, ((S.concat h c).messages i : ℝ))⁻¹ * + ∑ _ : (S.concat h c).Message, (n : ℝ) * P := by + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr hp.le) + apply Finset.sum_le_sum + intro m _ + simpa only [integral_const, probReal_univ, one_smul] using + integral_mono_ae (hint m) (integrable_const ((n : ℝ) * P)) (hbound m) + _ = (n : ℝ) * P := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + have hc : (Fintype.card (S.concat h c).Message : ℝ) = + ∏ i, ((S.concat h c).messages i : ℝ) := by simp [Code.Message, Fintype.card_pi] + rw [hc, ← mul_assoc, inv_mul_cancel₀ hp.ne', one_mul] + +omit [IsProbabilityMeasure μ] in +theorem concat_observe {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (m : (i : Fin K) → Fin (c i).messageCount) (H : StateBlock K n) (z : Noise K n) + (i : Fin K) : + ((S.concat h c).decode i).apply (H, Interference.output (S.concat h c) m H z i) = + (c i).decode (fun s => S.observe (fun j => (c j).encode (m j) s) i + (takeStateBlocks h H s, takeNoiseBlocks h z s)) := by + apply congrArg (c i).decode + funext s + congr 2 + funext t + simp only [Interference.output, concat, concatEncode_at, output, takeNoiseBlocks, + takeStateBlocks] + +theorem concat_word_law {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (m : (i : Fin K) → Fin (c i).messageCount) (i : Fin K) : + MeasurePreserving (fun hz : StateBlock K n × Noise K n => + fun s => S.observe (fun j => (c j).encode (m j) s) i + (takeStateBlocks h hz.1 s, takeNoiseBlocks h hz.2 s)) + ((stateLaw μ K n).prod (blockNoise K n)) + (((S.channel i).block b).toPMF ((c i).encode (m i))).toMeasure := by + have hrows := (measurePreserving_pi _ _ (fun s : Fin b => + S.observe_law (fun j => (c j).encode (m j) s) i)).comp + (measurePreserving_takeBlocks μ h) + have heq : (Measure.pi fun s : Fin b => + ((S.channel i).toPMF ((c i).encode (m i) s)).toMeasure) = + (((S.channel i).block b).toPMF ((c i).encode (m i))).toMeasure := by + classical + apply Measure.ext_of_singleton + intro y + simp only [Measure.pi_singleton, PMF.toMeasure_apply_singleton _ _ + (measurableSet_singleton _), FiniteChannel.toPMF_apply, + FiniteChannel.block_transition] + exact (ENNReal.ofReal_prod_of_nonneg fun s _ => (S.channel i).nonnegative _ _).symm + rw [← heq] + exact hrows + +theorem concat_receiver_error {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (m : (i : Fin K) → Fin (c i).messageCount) (i : Fin K) : + (((stateLaw μ K n).prod (blockNoise K n)) + {hz | ((S.concat h c).decode i).apply + (hz.1, Interference.output (S.concat h c) m hz.1 hz.2 i) ≠ m i}).toReal = + (c i).toOneShotCode.errorProbability (m i) := by + classical + simp_rw [S.concat_observe] + change (((stateLaw μ K n).prod (blockNoise K n)) + {hz | (c i).decode (fun s => S.observe (fun j => (c j).encode (m j) s) i + (takeStateBlocks h hz.1 s, takeNoiseBlocks h hz.2 s)) ≠ m i}).toReal = _ + have hm := S.concat_word_law h c m i + have he := hm.measure_preimage (s := {y | (c i).decode y ≠ m i}) (by measurability) + change (((stateLaw μ K n).prod (blockNoise K n)) + ((fun hz => fun s => S.observe (fun j => (c j).encode (m j) s) i + (takeStateBlocks h hz.1 s, takeNoiseBlocks h hz.2 s)) ⁻¹' + {y | (c i).decode y ≠ m i})).toReal = _ + rw [he] + rw [PMF.toMeasure_apply_fintype] + rw [CapacityAtlas.OneShotCode.errorProbability_eq_sum_decode_ne] + simp only [Set.indicator_apply, Set.mem_setOf_eq, FiniteChannel.toPMF_apply] + rw [ENNReal.toReal_sum (fun _ _ => by split_ifs <;> simp)] + apply Finset.sum_congr rfl + intro y _ + change (if (c i).decode y ≠ m i then + ENNReal.ofReal (((S.channel i).block b).transition ((c i).encode (m i)) y) else 0).toReal = + if (c i).decode y ≠ m i then + ((S.channel i).block b).transition ((c i).encode (m i)) y else 0 + split_ifs + · exact ENNReal.toReal_ofReal (((S.channel i).block b).nonnegative _ _) + · rfl + +private theorem average_pi_coordinate {I : Type*} [Fintype I] [DecidableEq I] + (M : I → Type*) [∀ i, Fintype (M i)] [∀ i, Nonempty (M i)] + (i : I) (f : M i → ℝ) : + (∏ j, (Fintype.card (M j) : ℝ))⁻¹ * (∑ m : (j : I) → M j, f (m i)) = + (Fintype.card (M i) : ℝ)⁻¹ * ∑ a, f a := by + classical + let e := Equiv.piSplitAt i M + have hc : (∏ j, (Fintype.card (M j) : ℝ)) = + (Fintype.card (M i) : ℝ) * + (Fintype.card ((j : {j // j ≠ i}) → M j) : ℝ) := by + have h := Fintype.card_congr e + simpa only [Fintype.card_pi, Fintype.card_prod, Nat.cast_mul, Nat.cast_prod] using + congrArg (fun n : ℕ => (n : ℝ)) h + have hs : (∑ m : (j : I) → M j, f (m i)) = + (Fintype.card ((j : {j // j ≠ i}) → M j) : ℝ) * ∑ a, f a := by + rw [← e.symm.sum_comp (fun m => f (m i)), Fintype.sum_prod_type] + simp [e, Equiv.piSplitAt, Finset.mul_sum] + rw [hc, hs] + have hn : (Fintype.card ((j : {j // j ≠ i}) → M j) : ℝ) ≠ 0 := by + exact_mod_cast Fintype.card_ne_zero + field_simp + +theorem concat_error_le {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) : + error μ (S.concat h c) ≤ ∑ i, (c i).averageErrorProbability := by + classical + letI (i : Fin K) : Nonempty (Fin (c i).messageCount) := + Fin.pos_iff_nonempty.mp (c i).messageCount_pos + have hmsg (m : (S.concat h c).Message) : + (((stateLaw μ K n).prod (blockNoise K n)) (errorEvent (S.concat h c) m)).toReal ≤ + ∑ i, (c i).toOneShotCode.errorProbability (m i) := by + unfold errorEvent + simp only [Set.setOf_exists] + exact (measureReal_iUnion_fintype_le _).trans_eq + (Finset.sum_congr rfl fun i _ => S.concat_receiver_error h c m i) + unfold error + calc + _ ≤ (∏ i, ((S.concat h c).messages i : ℝ))⁻¹ * + ∑ m : (S.concat h c).Message, ∑ i, (c i).toOneShotCode.errorProbability (m i) := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun m _ => hmsg m) (by positivity) + _ = ∑ i, (c i).averageErrorProbability := by + rw [Finset.sum_comm, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + change (∏ j, ((c j).messageCount : ℝ))⁻¹ * + (∑ m : (j : Fin K) → Fin (c j).messageCount, + (c i).toOneShotCode.errorProbability (m i)) = _ + have havg := average_pi_coordinate (fun j => Fin (c j).messageCount) i + (c i).toOneShotCode.errorProbability + simp only [Fintype.card_fin] at havg + rw [havg] + simpa only [Fintype.card_fin, FiniteChannel.BlockCode.averageErrorProbability] using + (CapacityAtlas.OneShotCode.averageErrorProbability_eq (c i).toOneShotCode).symm + +omit [IsProbabilityMeasure μ] in +theorem concat_rates {b n : ℕ} (h : b * L ≤ n) (hb : 0 < b) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) (i : Fin K) : + rates (S.concat h c) i = (b : ℝ) / n * (c i).rate := by + unfold rates Operational.messageRate FiniteChannel.BlockCode.rate + change Real.logb 2 ((c i).messageCount : ℝ) / n = _ + have hb' : (b : ℝ) ≠ 0 := by exact_mod_cast hb.ne' + field_simp + + +end CapacityAtlas.Gaussian.Interference.BlockScheme diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockSampling.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockSampling.lean new file mode 100644 index 0000000..280dae1 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockSampling.lean @@ -0,0 +1,106 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Basic +import Mathlib.Probability.Independence.InfinitePi + +open MeasureTheory ProbabilityTheory + +namespace CapacityAtlas.Gaussian.Interference + +theorem measurePreserving_pi_select {α S T : Type*} [MeasurableSpace α] + [Fintype S] [Fintype T] (ν : Measure α) [IsProbabilityMeasure ν] + (f : S → T) (hf : Function.Injective f) : + MeasurePreserving (fun x : T → α => x ∘ f) + (Measure.pi fun _ : T => ν) (Measure.pi fun _ : S => ν) := by + classical + refine ⟨by fun_prop, ?_⟩ + have hind : iIndepFun (fun t (x : T → α) => x t) (Measure.pi fun _ : T => ν) := + iIndepFun_pi fun _ => measurable_id.aemeasurable + have h := (hind.precomp hf).map_fun_eq_pi_map + (fun i => (measurable_pi_apply (f i)).aemeasurable) + simpa only [Function.comp_def, (measurePreserving_eval (fun _ : T => ν) _).map_eq] using h + +theorem measurePreserving_pi_curry {α S T : Type*} [MeasurableSpace α] + [Fintype S] [Fintype T] (ν : S → T → Measure α) + [∀ s t, IsProbabilityMeasure (ν s t)] : + MeasurePreserving (fun x : S × T → α => fun s t => x (s, t)) + (Measure.pi fun p : S × T => ν p.1 p.2) + (Measure.pi fun s => Measure.pi fun t => ν s t) := by + refine ⟨by fun_prop, ?_⟩ + convert Measure.infinitePi_map_curry ν using 1 <;> + simp only [Measure.infinitePi_eq_pi] + rfl + +theorem measurePreserving_pi_uncurry {α S T : Type*} [MeasurableSpace α] + [Fintype S] [Fintype T] (ν : S → T → Measure α) + [∀ s t, IsProbabilityMeasure (ν s t)] : + MeasurePreserving (fun x : S → T → α => fun p : S × T => x p.1 p.2) + (Measure.pi fun s => Measure.pi fun t => ν s t) + (Measure.pi fun p : S × T => ν p.1 p.2) := by + refine ⟨by fun_prop, ?_⟩ + convert Measure.infinitePi_map_curry_symm ν using 1 <;> + simp only [Measure.infinitePi_eq_pi] + rfl + +theorem measurePreserving_pi_swap {α S T : Type*} [MeasurableSpace α] + [Fintype S] [Fintype T] (ν : Measure α) [IsProbabilityMeasure ν] : + MeasurePreserving (fun x : S → T → α => fun t s => x s t) + (Measure.pi fun _ : S => Measure.pi fun _ : T => ν) + (Measure.pi fun _ : T => Measure.pi fun _ : S => ν) := by + have hf := measurePreserving_pi_uncurry (fun _ : S => fun _ : T => ν) + have hs := measurePreserving_pi_select ν (Prod.swap : T × S → S × T) + (Equiv.prodComm T S).injective + exact (measurePreserving_pi_curry (fun _ : T => fun _ : S => ν)).comp (hs.comp hf) + +def blockPosition {b L n : ℕ} (h : b * L ≤ n) (p : Fin b × Fin L) : Fin n := + Fin.castLE h (finProdFinEquiv p) + +theorem blockPosition_injective {b L n : ℕ} (h : b * L ≤ n) : + Function.Injective (blockPosition h) := by + exact (Fin.castLE_injective h).comp finProdFinEquiv.injective + +def takeStateBlocks {K b L n : ℕ} (h : b * L ≤ n) (H : StateBlock K n) : + Fin b → StateBlock K L := fun s t => H (blockPosition h (s, t)) + +def takeNoiseBlocks {K b L n : ℕ} (h : b * L ≤ n) (z : Noise K n) : + Fin b → Noise K L := fun s i t => z i (blockPosition h (s, t)) + +theorem measurePreserving_takeStateBlocks (μ : Measure ℂ) [IsProbabilityMeasure μ] + {K b L n : ℕ} (h : b * L ≤ n) : + MeasurePreserving (takeStateBlocks (K := K) h) (stateLaw μ K n) + (Measure.pi fun _ : Fin b => stateLaw μ K L) := by + exact (measurePreserving_pi_curry (fun _ : Fin b => fun _ : Fin L => + Measure.pi fun _ : Fin K => Measure.pi fun _ : Fin K => μ)).comp + (measurePreserving_pi_select _ (blockPosition h) (blockPosition_injective h)) + +theorem measurePreserving_takeNoiseBlocks {K b L n : ℕ} (h : b * L ≤ n) : + MeasurePreserving (takeNoiseBlocks (K := K) h) (blockNoise K n) + (Measure.pi fun _ : Fin b => blockNoise K L) := by + let ν := multivariateGaussian (0 : EuclideanSpace ℝ (Fin 2)) + ((1 / 2 : ℝ) • (1 : Matrix (Fin 2) (Fin 2) ℝ)) + have ht : MeasurePreserving (fun z : Fin n → EuclideanSpace ℝ (Fin 2) => + fun s t => z (blockPosition h (s, t))) + (Measure.pi fun _ : Fin n => ν) + (Measure.pi fun _ : Fin b => Measure.pi fun _ : Fin L => ν) := + (measurePreserving_pi_curry (fun _ : Fin b => fun _ : Fin L => ν)).comp + (measurePreserving_pi_select ν (blockPosition h) (blockPosition_injective h)) + exact (measurePreserving_pi_swap (S := Fin K) (T := Fin b) + (Measure.pi fun _ : Fin L => ν)).comp + (measurePreserving_pi _ _ (fun _ : Fin K => ht)) + +theorem measurePreserving_takeBlocks (μ : Measure ℂ) [IsProbabilityMeasure μ] + {K b L n : ℕ} (h : b * L ≤ n) : + MeasurePreserving (fun hz : StateBlock K n × Noise K n => + fun s => (takeStateBlocks h hz.1 s, takeNoiseBlocks h hz.2 s)) + ((stateLaw μ K n).prod (blockNoise K n)) + (Measure.pi fun _ : Fin b => (stateLaw μ K L).prod (blockNoise K L)) := by + exact (measurePreserving_arrowProdEquivProdArrow (StateBlock K L) (Noise K L) (Fin b) + (fun _ => stateLaw μ K L) (fun _ => blockNoise K L)).symm.comp + ((measurePreserving_takeStateBlocks μ h).prod + (measurePreserving_takeNoiseBlocks h)) + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockScheme.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockScheme.lean new file mode 100644 index 0000000..7a5a332 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/BlockScheme.lean @@ -0,0 +1,143 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.BlockSampling +import CapacityAtlasForMathlib.InformationTheory.FiniteChannel.PMF +import CapacityAtlasForMathlib.InformationTheory.RandomCoding + +open MeasureTheory ProbabilityTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +structure BlockScheme (μ : Measure ℂ) (K L : ℕ) (P : ℝ) (A : Type*) + [Fintype A] [MeasurableSpace A] where + encode : Fin K → A → StateBlock K L → Fin L → ℂ + encode_measurable : ∀ i a t, Measurable fun H => encode i a H t + encode_causal : ∀ i a t H H', (∀ s, s ≤ t → H s = H' s) → + encode i a H t = encode i a H' t + decode : Fin K → (StateBlock K L × (Fin L → ℂ)) → A + decode_measurable : ∀ i, Measurable (decode i) + channel : Fin K → FiniteChannel A A + row_law : ∀ (a : Fin K → A) i b, + ((stateLaw μ K L).prod (blockNoise K L)) + {hz | decode i (hz.1, fun t => + (∑ j, hz.1 t i j * encode j (a j) hz.1 t) + complexNoise (hz.2 i t)) = b} = + ENNReal.ofReal ((channel i).transition (a i) b) + power : ∀ a : Fin K → A, ∀ᵐ H ∂stateLaw μ K L, + (∑ t, ∑ i, ‖encode i (a i) H t‖ ^ 2) ≤ (L : ℝ) * P + +namespace BlockScheme + +variable {μ : Measure ℂ} {K L : ℕ} {P : ℝ} {A : Type*} +variable [Fintype A] [MeasurableSpace A] +variable (S : BlockScheme μ K L P A) + +def output (a : Fin K → A) (H : StateBlock K L) (z : Noise K L) + (i : Fin K) : Fin L → ℂ := + fun t => (∑ j, H t i j * S.encode j (a j) H t) + complexNoise (z i t) + +@[fun_prop] +theorem measurable_output (a : Fin K → A) (i : Fin K) : + Measurable fun hz : StateBlock K L × Noise K L => S.output a hz.1 hz.2 i := by + apply measurable_pi_lambda + intro t + apply Measurable.add + · apply Finset.measurable_sum + intro j _ + exact (by fun_prop : Measurable fun hz : StateBlock K L × Noise K L => hz.1 t i j).mul + ((S.encode_measurable j (a j) t).comp measurable_fst) + · unfold complexNoise + fun_prop + +def observe (a : Fin K → A) (i : Fin K) (hz : StateBlock K L × Noise K L) : A := + S.decode i (hz.1, S.output a hz.1 hz.2 i) + +@[fun_prop] +theorem measurable_observe (a : Fin K → A) (i : Fin K) : Measurable (S.observe a i) := + (S.decode_measurable i).comp (measurable_fst.prodMk (S.measurable_output a i)) + +theorem observe_law [MeasurableSingletonClass A] (a : Fin K → A) (i : Fin K) : + MeasurePreserving (S.observe a i) ((stateLaw μ K L).prod (blockNoise K L)) + ((S.channel i).toPMF (a i)).toMeasure := by + classical + refine ⟨S.measurable_observe a i, ?_⟩ + apply Measure.ext_of_singleton + intro b + rw [Measure.map_apply (S.measurable_observe a i) (measurableSet_singleton b)] + rw [PMF.toMeasure_apply_singleton _ _ (measurableSet_singleton b)] + exact S.row_law a i b + +noncomputable def concatEncode {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (i : Fin K) (m : Fin (c i).messageCount) (H : StateBlock K n) : Fin n → ℂ := + Function.extend (blockPosition h) + (fun p => S.encode i ((c i).encode m p.1) (takeStateBlocks h H p.1) p.2) 0 + +theorem concatEncode_at {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (i : Fin K) (m : Fin (c i).messageCount) (H : StateBlock K n) (p : Fin b × Fin L) : + S.concatEncode h c i m H (blockPosition h p) = + S.encode i ((c i).encode m p.1) (takeStateBlocks h H p.1) p.2 := + (blockPosition_injective h).extend_apply _ _ _ + +theorem concatEncode_outside {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (i : Fin K) (m : Fin (c i).messageCount) (H : StateBlock K n) (t : Fin n) + (ht : ¬∃ p, blockPosition h p = t) : S.concatEncode h c i m H t = 0 := + Function.extend_apply' _ _ _ ht + +@[fun_prop] +theorem measurable_concatEncode {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (i : Fin K) (m : Fin (c i).messageCount) (t : Fin n) : + Measurable fun H => S.concatEncode h c i m H t := by + by_cases ht : ∃ p, blockPosition h p = t + · obtain ⟨p, rfl⟩ := ht + simp only [S.concatEncode_at] + exact (S.encode_measurable i ((c i).encode m p.1) p.2).comp (by + unfold takeStateBlocks + fun_prop) + · simp only [S.concatEncode_outside h c i m _ t ht] + exact measurable_const + +theorem concatEncode_causal {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) + (i : Fin K) (m : Fin (c i).messageCount) (t : Fin n) (H H' : StateBlock K n) + (hh : ∀ s, s ≤ t → H s = H' s) : + S.concatEncode h c i m H t = S.concatEncode h c i m H' t := by + by_cases ht : ∃ p, blockPosition h p = t + · obtain ⟨p, rfl⟩ := ht + simp only [S.concatEncode_at] + apply S.encode_causal + intro s hs + apply hh + change s.val + L * p.1.val ≤ p.2.val + L * p.1.val + exact Nat.add_le_add_right hs _ + · rw [S.concatEncode_outside h c i m H t ht, S.concatEncode_outside h c i m H' t ht] + +noncomputable def concat [MeasurableSingletonClass A] {b n : ℕ} (h : b * L ≤ n) + (c : ∀ i, FiniteChannel.BlockCode (S.channel i) b) : Code K n where + messages i := (c i).messageCount + messages_pos i := (c i).messageCount_pos + encode := S.concatEncode h c + encode_measurable := S.measurable_concatEncode h c + encode_causal := S.concatEncode_causal h c + decode i := + { apply := fun hy => (c i).decode fun s => S.decode i + (takeStateBlocks h hy.1 s, fun t => hy.2 (blockPosition h (s, t))) + measurable_fiber := fun m => by + apply (measurableSet_singleton m).preimage + apply (measurable_of_countable (c i).decode).comp + apply measurable_pi_lambda + intro s + apply (S.decode_measurable i).comp + unfold takeStateBlocks + fun_prop } + +end BlockScheme + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Capacity.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Capacity.lean new file mode 100644 index 0000000..6906ee1 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Capacity.lean @@ -0,0 +1,52 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Achievability +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.CapacityConverse +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.AsymptoticSqueeze + +open MeasureTheory Filter +open scoped Topology + +namespace CapacityAtlas.Gaussian.Interference + +/-- The fully connected time-varying interference channel has K/2 sum degrees of freedom. -/ +theorem sum_degrees_of_freedom (μ : Measure ℂ) [IsProbabilityMeasure μ] [NullSingletonClass μ] + {K : ℕ} (hK : 2 ≤ K) {L U : ℝ} (hL : 0 < L) (hU : 0 ≤ U) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) : + Tendsto (fun P : ℝ ↦ sumCapacity μ K P / Real.logb 2 P) + atTop (𝓝 ((K : ℝ) / 2)) := by + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hUp : 0 < U := annulus_upper_pos μ hL hμ + let F : ℝ → ℝ := fun P ↦ sumCapacity μ K P * Real.log 2 + have hmono : Monotone F := fun P P' h ↦ + mul_le_mul_of_nonneg_right (sumCapacity_monotone μ hL hU hμ hK h) hlog.le + have hc : 0 < U ^ 2 / converseNoise L U := by + exact div_pos (sq_pos_of_pos hUp) (converseNoise_pos hL) + have hupper : ∀ᶠ P : ℝ in atTop, + F P ≤ (K : ℝ) / 2 * Real.log (1 + (U ^ 2 / converseNoise L U) * P) := by + filter_upwards [eventually_ge_atTop (0 : ℝ)] with P hP + have hp := mul_le_mul_of_nonneg_right (sumCapacity_converse μ hL hU hP hμ hK) hlog.le + change F P ≤ _ at hp + convert hp using 1 + rw [Real.logb] + have he : 1 + U ^ 2 * P / converseNoise L U = + 1 + (U ^ 2 / converseNoise L U) * P := by ring + rw [he] + field_simp + have hlower : ∀ n : ℕ, 0 < n → ∀ ε : ℝ, 0 < ε → + ∃ C : ℝ, 0 < C ∧ ∃ b : ℝ, ∀ᶠ q : ℕ in atTop, + ((K : ℝ) * (1 - ε) * 2 * Fintype.card (Box (Fin K) n) / + extensionLength K n) * Real.log q - b ≤ F (C * (q : ℝ) ^ 2) := by + intro n hn ε hε + exact exists_quadratic_grid_lower μ (by omega) U + (hμ.mono fun _ h ↦ h.2) (sumRates_bddAbove_all μ hL hU hμ hK) hn hε + have hpre := prelog_of_alignment_grid hmono hc hupper hlower + convert hpre using 1 + funext P + simp only [Real.logb, F, div_div_eq_mul_div] + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CapacityConverse.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CapacityConverse.lean new file mode 100644 index 0000000..48612c8 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CapacityConverse.lean @@ -0,0 +1,115 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.CodeConverse +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.BasicFacts +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.ConverseAsymptotics + +open MeasureTheory ProbabilityTheory Filter +open scoped BigOperators ENNReal Topology + +namespace CapacityAtlas.Gaussian.Interference + +theorem rates_nonneg {K n : ℕ} (c : Code K n) (i : Fin K) : 0 ≤ rates c i := by + unfold rates Operational.messageRate + apply div_nonneg _ (Nat.cast_nonneg n) + exact Real.logb_nonneg (by norm_num) (by exact_mod_cast c.messages_pos i) + +theorem code_pair_rates_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) + {K n : ℕ} (hn : 0 < n) (c : Code K n) (hc : PowerAdmissible μ P c) + (i j : Fin K) (hij : i ≠ j) : + (1 - error μ c) * (rates c i + rates c j) ≤ + Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) + 2 / n := by + have hf := code_pair_converse μ hL hU hP hμ c hc i j hij + have hnR : (0 : ℝ) < n := Nat.cast_pos.mpr hn + have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) + have hd := div_le_div_of_nonneg_right hf (mul_pos hnR hlog).le + calc + _ = ((1 - error μ c) * (Real.log (c.messages i) + Real.log (c.messages j))) / + ((n : ℝ) * Real.log 2) := by unfold rates Operational.messageRate Real.logb; ring + _ ≤ _ := hd + _ = _ := by + unfold Real.logb + field_simp + +theorem capacityRegion_pair_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) + {K : ℕ} {R : Fin K → ℝ} (hR : R ∈ capacityRegion μ K P) + (i j : Fin K) (hij : i ≠ j) : + R i + R j ≤ Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) := by + let B := Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) + have heps (ε : ℝ) (hε : 0 < ε) (hε1 : ε < 1) : + (1 - ε) * (R i + R j - 2 * ε) ≤ B := by + obtain ⟨N, hN, hcodes⟩ := hR.2 ε hε + have hlim : Tendsto (fun n : ℕ ↦ B + 2 / (n : ℝ)) atTop (𝓝 B) := by + simpa only [div_eq_mul_inv, mul_zero, add_zero] using tendsto_const_nhds.add + (tendsto_const_nhds.mul (tendsto_inv_atTop_nhds_zero_nat (𝕜 := ℝ))) + apply ge_of_tendsto hlim + filter_upwards [eventually_ge_atTop N] with n hn + obtain ⟨c, hc, herr, hrates⟩ := hcodes n hn + have hrate : R i + R j - 2 * ε ≤ rates c i + rates c j := by + linarith [hrates i, hrates j] + have hscaled := mul_le_mul_of_nonneg_left hrate (sub_pos.mpr hε1).le + have herrscaled := mul_le_mul_of_nonneg_right (sub_le_sub_left herr 1) + (add_nonneg (rates_nonneg c i) (rates_nonneg c j)) + have hb := code_pair_rates_bound μ hL hU hP hμ (hN.trans_le hn) c hc i j hij + dsimp only [B] + nlinarith + have hlim : Tendsto (fun ε : ℝ ↦ (1 - ε) * (R i + R j - 2 * ε)) + (𝓝[>] 0) (𝓝 (R i + R j)) := by + have h : Continuous (fun ε : ℝ ↦ (1 - ε) * (R i + R j - 2 * ε)) := by fun_prop + simpa using h.continuousAt.tendsto.mono_left + (show 𝓝[>] (0 : ℝ) ≤ 𝓝 0 from inf_le_left) + apply le_of_tendsto hlim + filter_upwards [self_mem_nhdsWithin, + eventually_lt_nhds (show (0 : ℝ) < 1 by norm_num) |>.filter_mono inf_le_left] + with ε hε hε1 + exact heps ε hε hε1 + +theorem capacityRegion_sum_bound (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) + {K : ℕ} (hK : 2 ≤ K) {R : Fin K → ℝ} (hR : R ∈ capacityRegion μ K P) : + (∑ i, R i) ≤ (K : ℝ) / 2 * Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) := + sum_le_of_pair_bounds hK R _ (fun i j hij ↦ capacityRegion_pair_bound μ hL hU hP hμ hR i j hij) + +theorem sumCapacity_converse (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) : + sumCapacity μ K P ≤ + (K : ℝ) / 2 * Real.logb 2 (1 + U ^ 2 * P / converseNoise L U) := + sumCapacity_le hP (fun _ hR ↦ capacityRegion_sum_bound μ hL hU hP hμ hK hR) + +theorem sumRates_bddAbove (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) : + BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} := + sumRates_bddAbove_of_bound (fun _ hR ↦ capacityRegion_sum_bound μ hL hU hP hμ hK hR) + +theorem sumRates_bddAbove_all (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U : ℝ} (hL : 0 < L) (hU : 0 ≤ U) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) (P : ℝ) : + BddAbove {s | ∃ R ∈ capacityRegion μ K P, s = ∑ i, R i} := by + obtain ⟨B, hB⟩ := sumRates_bddAbove μ hL hU (le_max_right P 0) hμ hK + refine ⟨B, ?_⟩ + rintro s ⟨R, hR, rfl⟩ + exact hB ⟨R, capacityRegion_mono μ K (le_max_left P 0) hR, rfl⟩ + +theorem sumCapacity_monotone (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U : ℝ} (hL : 0 < L) (hU : 0 ≤ U) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) {K : ℕ} (hK : 2 ≤ K) : + Monotone (sumCapacity μ K) := + monotone_sumCapacity μ K (sumRates_bddAbove_all μ hL hU hμ hK) + +theorem annulus_upper_pos (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U : ℝ} (hL : 0 < L) (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) : 0 < U := by + obtain ⟨z, hz⟩ := hμ.exists + exact (hL.trans_le hz.1).trans_le hz.2 + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeConverse.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeConverse.lean new file mode 100644 index 0000000..f63c378 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeConverse.lean @@ -0,0 +1,108 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.ConverseEnergy + +open MeasureTheory ProbabilityTheory Matrix +open scoped BigOperators ENNReal + +namespace CapacityAtlas.Gaussian.Interference + +noncomputable def converseNoise (L U : ℝ) : ℝ := L ^ 2 / (2 * (L ^ 2 + U ^ 2)) + +theorem converseNoise_pos {L U : ℝ} (hL : 0 < L) : 0 < converseNoise L U := by + unfold converseNoise + positivity + +theorem converseNoise_le_half {L U : ℝ} (hL : 0 < L) : converseNoise L U ≤ 1 / 2 := by + unfold converseNoise + rw [div_le_iff₀ (by positivity : 0 < 2 * (L ^ 2 + U ^ 2))] + nlinarith [sq_nonneg U] + +theorem converseNoise_ratio_bound {L U : ℝ} (hL : 0 < L) (hU : 0 ≤ U) + {a b : ℂ} (ha : ‖a‖ ≤ U) (hb : L ≤ ‖b‖) : + converseNoise L U * ‖a / b‖ ^ 2 ≤ 1 / 2 := by + have hbpos : 0 < ‖b‖ := hL.trans_le hb + have hr : ‖a / b‖ ≤ U / L := by + rw [norm_div, div_le_div_iff₀ hbpos hL] + nlinarith + have hs : ‖a / b‖ ^ 2 ≤ (U / L) ^ 2 := by gcongr + have hh : converseNoise L U * (U / L) ^ 2 ≤ 1 / 2 := by + unfold converseNoise + rw [div_pow] + have hsq : L ^ 2 ≠ 0 := pow_ne_zero _ hL.ne' + have heq : L ^ 2 / (2 * (L ^ 2 + U ^ 2)) * (U ^ 2 / L ^ 2) = + U ^ 2 / (2 * (L ^ 2 + U ^ 2)) := by field_simp + rw [heq, div_le_iff₀ (by positivity : 0 < 2 * (L ^ 2 + U ^ 2))] + nlinarith [sq_nonneg L] + exact (mul_le_mul_of_nonneg_left hs (converseNoise_pos hL).le).trans hh + +theorem stateLaw_ae_annulus (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U : ℝ} (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) (K n : ℕ) : + ∀ᵐ H ∂stateLaw μ K n, ∀ t i j, L ≤ ‖H t i j‖ ∧ ‖H t i j‖ ≤ U := by + apply ae_all_iff.mpr + intro t + apply ae_all_iff.mpr + intro i + apply ae_all_iff.mpr + intro j + have hrow := (Measure.tendsto_eval_ae_ae (μ := fun _ : Fin K ↦ μ) (i := j)).eventually hμ + have hmatrix := (Measure.tendsto_eval_ae_ae + (μ := fun _ : Fin K ↦ Measure.pi fun _ : Fin K ↦ μ) (i := i)).eventually hrow + exact (Measure.tendsto_eval_ae_ae + (μ := fun _ : Fin n ↦ Measure.pi fun _ : Fin K ↦ Measure.pi fun _ : Fin K ↦ μ) + (i := t)).eventually hmatrix + +theorem code_pair_converse (μ : Measure ℂ) [IsProbabilityMeasure μ] + {L U P : ℝ} (hL : 0 < L) (hU : 0 ≤ U) (hP : 0 ≤ P) + (hμ : ∀ᵐ z ∂μ, L ≤ ‖z‖ ∧ ‖z‖ ≤ U) + {K n : ℕ} (c : Code K n) (hc : PowerAdmissible μ P c) + (i j : Fin K) (hij : i ≠ j) : + (1 - error μ c) * (Real.log (c.messages i) + Real.log (c.messages j)) ≤ + (n : ℝ) * Real.log (1 + U ^ 2 * P / converseNoise L U) + 2 * Real.log 2 := by + let e := converseNoise L U + let t := e + U ^ 2 * P + have he : 0 < e := converseNoise_pos hL + have ht : 0 < t := by dsimp [t]; positivity + have hstate := stateLaw_ae_annulus μ hμ K n + have hupper : ∀ᵐ H ∂stateLaw μ K n, + (∀ s, ‖H s i i‖ ≤ U) ∧ (∀ s, ‖H s i j‖ ≤ U) := by + filter_upwards [hstate] with H hh + exact ⟨fun s ↦ (hh s i i).2, fun s ↦ (hh s i j).2⟩ + have hienergy := integrable_messageAverage μ c (fun m H ↦ pairEnergy c H i j m) + (integrable_pairEnergy μ c hc hU i j hij hupper) + have hierror (k : Fin K) := integrable_messageAverage μ c + (fun m H ↦ receiverErrorAt c m H k) (fun m ↦ integrable_receiverErrorAt μ c m k) + have herror (k : Fin K) : + (∫ H, ∫ m, receiverErrorAt c m H k ∂messageLaw c ∂stateLaw μ K n) ≤ error μ c := by + rw [integral_state_messageAverage μ c _ (fun m ↦ integrable_receiverErrorAt μ c m k)] + exact average_receiverErrorAt_le_error μ c k + have henergy : (∫ H, ∫ m, pairEnergy c H i j m ∂messageLaw c ∂stateLaw μ K n) ≤ + 2 * n * (t - e) := by + convert integral_pairEnergy_le μ c hc hU i j hij hupper using 1 + dsimp [t] + ring + have hpointwise : ∀ᵐ H ∂stateLaw μ K n, + Real.log (c.messages i) + Real.log (c.messages j) ≤ + (n : ℝ) * Real.log (t / e) + + ((2 * n : ℝ) * e + (∫ m, pairEnergy c H i j m ∂messageLaw c)) / (2 * t) - + n + 2 * Real.log 2 + + (∫ m, receiverErrorAt c m H i ∂messageLaw c) * Real.log (c.messages i) + + (∫ m, receiverErrorAt c m H j ∂messageLaw c) * Real.log (c.messages j) := by + filter_upwards [hstate] with H hh + apply code_pair_fano_at_state c H i j hij + (fun s ↦ norm_pos_iff.mp (hL.trans_le (hh s i j).1)) he ht (converseNoise_le_half hL) + intro s + exact converseNoise_ratio_bound hL hU (hh s j j).2 (hh s i j).1 + have hlog (k : Fin K) : 0 ≤ Real.log (c.messages k) := + Real.log_nonneg (by exact_mod_cast c.messages_pos k) + have hf := pair_bound_of_integrated_energy (stateLaw μ K n) ht (hlog i) (hlog j) + hienergy (hierror i) (hierror j) henergy (herror i) (herror j) hpointwise + have heq : t / e = 1 + U ^ 2 * P / e := by dsimp [t]; field_simp + rw [heq] at hf + exact hf + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeLaws.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeLaws.lean new file mode 100644 index 0000000..51e49b6 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodeLaws.lean @@ -0,0 +1,159 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Basic +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Realification +import Mathlib.Probability.Distributions.Uniform +import Mathlib.MeasureTheory.Integral.Prod + +open MeasureTheory ProbabilityTheory Matrix +open scoped ENNReal BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +noncomputable def uniformFinLaw (m : ℕ) (hm : 0 < m) : Measure (Fin m) := + letI : Nonempty (Fin m) := ⟨⟨0, hm⟩⟩ + (PMF.uniformOfFintype (Fin m)).toMeasure + +instance (m : ℕ) (hm : 0 < m) : IsProbabilityMeasure (uniformFinLaw m hm) := by + unfold uniformFinLaw + infer_instance + +theorem uniformFinLaw_singleton (m : ℕ) (hm : 0 < m) (a : Fin m) : + uniformFinLaw m hm {a} = (m : ℝ≥0∞)⁻¹ := by + simp [uniformFinLaw] + +variable {K n : ℕ} + +noncomputable def messageLaw (c : Code K n) : Measure c.Message := + Measure.pi fun i ↦ uniformFinLaw (c.messages i) (c.messages_pos i) + +instance (c : Code K n) : IsProbabilityMeasure (messageLaw c) := by + unfold messageLaw + infer_instance + +theorem messageLaw_real_singleton (c : Code K n) (m : c.Message) : + (messageLaw c).real {m} = (∏ i, (c.messages i : ℝ))⁻¹ := by + simp only [Measure.real, messageLaw, Measure.pi_singleton, uniformFinLaw_singleton, + ENNReal.toReal_prod, ENNReal.toReal_inv, ENNReal.toReal_natCast] + rw [Finset.prod_inv_distrib] + +theorem integral_messageLaw (c : Code K n) (f : c.Message → ℝ) : + (∫ m, f m ∂messageLaw c) = (∏ i, (c.messages i : ℝ))⁻¹ * ∑ m, f m := by + rw [integral_fintype Integrable.of_finite] + simp only [messageLaw_real_singleton, smul_eq_mul, ← Finset.mul_sum] + +noncomputable def receiverMean (c : Code K n) (m : c.Message) (H : StateBlock K n) + (i : Fin K) : EuclideanSpace ℝ (Fin 2 × Fin n) := + realBlock fun t ↦ ∑ j, H t i j * c.encode j (m j) H t + +def receiverEvent (c : Code K n) (m : c.Message) (i : Fin K) : + Set (StateBlock K n × Noise K n) := + {hz | (c.decode i).apply (hz.1, output c m hz.1 hz.2 i) ≠ m i} + +theorem measurableSet_receiverEvent (c : Code K n) (m : c.Message) (i : Fin K) : + MeasurableSet (receiverEvent c m i) := + (((c.decode i).measurable_fiber (m i)).preimage + (measurable_fst.prodMk (measurable_output c m i))).compl + +noncomputable def receiverErrorAt (c : Code K n) (m : c.Message) (H : StateBlock K n) + (i : Fin K) : ℝ := + (blockNoise K n).real (Prod.mk H ⁻¹' receiverEvent c m i) + +theorem measurable_receiverErrorAt (c : Code K n) (m : c.Message) (i : Fin K) : + Measurable fun H ↦ receiverErrorAt c m H i := + (measurable_measure_prodMk_left (measurableSet_receiverEvent c m i)).ennreal_toReal + +theorem integrable_receiverErrorAt (μ : Measure ℂ) [IsProbabilityMeasure μ] + (c : Code K n) (m : c.Message) (i : Fin K) : + Integrable (fun H ↦ receiverErrorAt c m H i) (stateLaw μ K n) := by + apply Integrable.mono' (integrable_const (1 : ℝ)) + (measurable_receiverErrorAt c m i).aestronglyMeasurable + filter_upwards with H + unfold receiverErrorAt + rw [Real.norm_eq_abs, abs_of_nonneg measureReal_nonneg] + exact measureReal_le_one + +theorem integral_receiverErrorAt (μ : Measure ℂ) [IsProbabilityMeasure μ] + (c : Code K n) (m : c.Message) (i : Fin K) : + (∫ H, receiverErrorAt c m H i ∂stateLaw μ K n) = + ((stateLaw μ K n).prod (blockNoise K n)).real (receiverEvent c m i) := by + rw [Measure.real, Measure.prod_apply (measurableSet_receiverEvent c m i)] + exact integral_toReal + (measurable_measure_prodMk_left (measurableSet_receiverEvent c m i)).aemeasurable + (Filter.Eventually.of_forall fun _ ↦ measure_lt_top _ _) + +theorem average_receiverErrorAt_le_error (μ : Measure ℂ) [IsProbabilityMeasure μ] + (c : Code K n) (i : Fin K) : + (∫ m, ∫ H, receiverErrorAt c m H i ∂stateLaw μ K n ∂messageLaw c) ≤ error μ c := by + rw [integral_messageLaw] + unfold error + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Finset.sum_le_sum + intro m _ + rw [integral_receiverErrorAt] + exact measureReal_mono (fun _ hh ↦ ⟨i, hh⟩) (measure_ne_top _ _) + +theorem blockNoise_map_flatten_receiver (i : Fin K) : + (blockNoise K n).map (fun z ↦ flattenGaussianBlock (z i)) = + multivariateGaussian 0 ((1 / 2 : ℝ) • + (1 : Matrix (Fin 2 × Fin n) (Fin 2 × Fin n) ℝ)) := by + change (blockNoise K n).map (flattenGaussianBlock ∘ fun z ↦ z i) = _ + rw [← Measure.map_map measurable_flattenGaussianBlock (measurable_pi_apply i)] + have hproj : (blockNoise K n).map (fun z ↦ z i) = + Measure.pi fun _ : Fin n ↦ multivariateGaussian 0 + ((1 / 2 : ℝ) • (1 : Matrix (Fin 2) (Fin 2) ℝ)) := + (measurePreserving_eval (fun _ : Fin K ↦ Measure.pi fun _ : Fin n ↦ + multivariateGaussian 0 ((1 / 2 : ℝ) • (1 : Matrix (Fin 2) (Fin 2) ℝ))) i).map_eq + rw [hproj, + map_flatten_pi_multivariateGaussian_zero _ + (fun _ ↦ (PosDef.one.smul (by norm_num : (0 : ℝ) < 1 / 2)).posSemidef)] + congr 1 + change blockDiagonal ((1 / 2 : ℝ) • (1 : Fin n → Matrix (Fin 2) (Fin 2) ℝ)) = _ + rw [blockDiagonal_smul, blockDiagonal_one] + +theorem realBlock_output (c : Code K n) (m : c.Message) (H : StateBlock K n) + (z : Noise K n) (i : Fin K) : + realBlock (output c m H z i) = receiverMean c m H i + flattenGaussianBlock (z i) := by + change realBlock ((fun t ↦ ∑ j, H t i j * c.encode j (m j) H t) + + fun t ↦ complexNoise (z i t)) = _ + rw [realBlock_add] + congr 1 + change realBlock (fun t ↦ Complex.orthonormalBasisOneI.repr.symm (z i t)) = _ + unfold realBlock + simp only [LinearIsometryEquiv.apply_symm_apply] + +theorem blockNoise_map_realBlock_output (c : Code K n) (m : c.Message) + (H : StateBlock K n) (i : Fin K) : + (blockNoise K n).map (fun z ↦ realBlock (output c m H z i)) = + multivariateGaussian (receiverMean c m H i) ((1 / 2 : ℝ) • + (1 : Matrix (Fin 2 × Fin n) (Fin 2 × Fin n) ℝ)) := by + simp_rw [realBlock_output] + change (blockNoise K n).map ((fun y ↦ receiverMean c m H i + y) ∘ + fun z ↦ flattenGaussianBlock (z i)) = _ + rw [← Measure.map_map (by fun_prop) + (show Measurable (fun z : Noise K n ↦ flattenGaussianBlock (z i)) from + measurable_flattenGaussianBlock.comp (measurable_pi_apply i)), + blockNoise_map_flatten_receiver, multivariateGaussian_map_const_add, add_zero] + +theorem receiverErrorAt_eq_gaussian (c : Code K n) (m : c.Message) + (H : StateBlock K n) (i : Fin K) : + receiverErrorAt c m H i = + (multivariateGaussian (receiverMean c m H i) ((1 / 2 : ℝ) • + (1 : Matrix (Fin 2 × Fin n) (Fin 2 × Fin n) ℝ))).real + {y | (c.decode i).apply (H, complexBlock y) ≠ m i} := by + rw [← blockNoise_map_realBlock_output] + have hm : Measurable fun z : Noise K n ↦ realBlock (output c m H z i) := + measurable_realBlock.comp ((measurable_output c m i).comp measurable_prodMk_left) + have hs : MeasurableSet {y : EuclideanSpace ℝ (Fin 2 × Fin n) | + (c.decode i).apply (H, complexBlock y) ≠ m i} := + (((c.decode i).measurable_fiber (m i)).preimage + (measurable_const.prodMk measurable_complexBlock)).compl + rw [Measure.real, Measure.map_apply hm hs] + simp only [Set.preimage_setOf_eq, complexBlock_realBlock] + rfl + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodePair.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodePair.lean new file mode 100644 index 0000000..42c5597 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/CodePair.lean @@ -0,0 +1,93 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.PairMessages +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Genie + +open MeasureTheory ProbabilityTheory Matrix +open scoped BigOperators ENNReal + +namespace CapacityAtlas.Gaussian.Interference + +variable {K n : ℕ} + +noncomputable def pairEnergy (c : Code K n) (H : StateBlock K n) (i j : Fin K) + (m : c.Message) : ℝ := + ‖userSignal c H i i (m i) + userSignal c H i j (m j)‖ ^ 2 + +theorem code_pair_fano_given_other_messages (c : Code K n) (H : StateBlock K n) + (m : c.Message) (i j : Fin K) (hij : i ≠ j) + (hcross : ∀ s, H s i j ≠ 0) {e t : ℝ} (he : 0 < e) (ht : 0 < t) + (hehalf : e ≤ 1 / 2) + (hres : ∀ s, e * ‖H s j j / H s i j‖ ^ 2 ≤ 1 / 2) : + Real.log (c.messages i) + Real.log (c.messages j) ≤ + (n : ℝ) * Real.log (t / e) + + ((2 * n : ℝ) * e + (∫ a, ∫ b, + pairEnergy c H i j (pairMessage c m i j a b) + ∂uniformFinLaw (c.messages j) (c.messages_pos j) + ∂uniformFinLaw (c.messages i) (c.messages_pos i))) / (2 * t) - n + 2 * Real.log 2 + + (∫ a, ∫ b, receiverErrorAt c (pairMessage c m i j a b) H i + ∂uniformFinLaw (c.messages j) (c.messages_pos j) + ∂uniformFinLaw (c.messages i) (c.messages_pos i)) * Real.log (c.messages i) + + (∫ a, ∫ b, receiverErrorAt c (pairMessage c m i j a b) H j + ∂uniformFinLaw (c.messages j) (c.messages_pos j) + ∂uniformFinLaw (c.messages i) (c.messages_pos i)) * Real.log (c.messages j) := by + letI : Nonempty (Fin (c.messages i)) := ⟨⟨0, c.messages_pos i⟩⟩ + letI : Nonempty (Fin (c.messages j)) := ⟨⟨0, c.messages_pos j⟩⟩ + have hd (k : Fin K) : Measurable fun y : EuclideanSpace ℝ (Fin 2 × Fin n) ↦ + (c.decode k).apply (H, complexBlock y) := + (measurable_to_countable' (c.decode k).measurable_fiber).comp + (measurable_const.prodMk measurable_complexBlock) + have hf := twoUser_linear_gaussian_fano + (uniformFinLaw (c.messages i) (c.messages_pos i)) + (uniformFinLaw (c.messages j) (c.messages_pos j)) + (userSignal c H i i) (userSignal c H j i) (userSignal c H i j) + (pairBackground c m H i i j) (pairBackground c m H j i j) + (complexBlockMatrix fun s ↦ H s j j / H s i j) he ht hehalf + (complexBlockMatrix_residual_posSemidef _ e (1 / 2) hres) + (fun y ↦ (c.decode i).apply (H, complexBlock y)) (hd i) + (fun y ↦ (c.decode j).apply (H, complexBlock y)) (hd j) + (fun a ↦ by simpa using uniformFinLaw_singleton _ _ a) + (fun b ↦ by simpa using uniformFinLaw_singleton _ _ b) + simp_rw [userSignal_transfer c H i j j hcross, + ← receiverMean_pairMessage c m H i i j hij, + ← receiverMean_pairMessage c m H j i j hij] at hf + have hri (a : Fin (c.messages i)) (b : Fin (c.messages j)) := + receiverErrorAt_eq_gaussian c (pairMessage c m i j a b) H i + have hrj (a : Fin (c.messages i)) (b : Fin (c.messages j)) := + receiverErrorAt_eq_gaussian c (pairMessage c m i j a b) H j + simp only [pairMessage_left c m i j hij] at hri + simp only [pairMessage_right] at hrj + simp_rw [← hri, ← hrj] at hf + rw [integral_prod _ Integrable.of_finite] at hf + simpa only [Fintype.card_fin, Fintype.card_prod, Nat.cast_mul, Nat.cast_ofNat, + mul_div_cancel_left₀ _ (by norm_num : (2 : ℝ) ≠ 0), pairEnergy, + pairMessage_left c m i j hij, pairMessage_right] using hf + +theorem code_pair_fano_at_state (c : Code K n) (H : StateBlock K n) + (i j : Fin K) (hij : i ≠ j) + (hcross : ∀ s, H s i j ≠ 0) {e t : ℝ} (he : 0 < e) (ht : 0 < t) + (hehalf : e ≤ 1 / 2) + (hres : ∀ s, e * ‖H s j j / H s i j‖ ^ 2 ≤ 1 / 2) : + Real.log (c.messages i) + Real.log (c.messages j) ≤ + (n : ℝ) * Real.log (t / e) + + ((2 * n : ℝ) * e + (∫ m, pairEnergy c H i j m ∂messageLaw c)) / (2 * t) - + n + 2 * Real.log 2 + + (∫ m, receiverErrorAt c m H i ∂messageLaw c) * Real.log (c.messages i) + + (∫ m, receiverErrorAt c m H j ∂messageLaw c) * Real.log (c.messages j) := by + have hf := integral_mono (μ := messageLaw c) + (integrable_const (Real.log (c.messages i) + Real.log (c.messages j))) + Integrable.of_finite + (fun m ↦ code_pair_fano_given_other_messages c H m i j hij hcross he ht hehalf hres) + simp only [integral_add Integrable.of_finite Integrable.of_finite, + integral_sub Integrable.of_finite Integrable.of_finite, + integral_div, integral_mul_const, integral_const, probReal_univ, one_smul, + integral_pairMessage] at hf + rw [integral_pairMessage c i j (fun m ↦ receiverErrorAt c m H i), + integral_pairMessage c i j (fun m ↦ receiverErrorAt c m H j)] at hf + exact hf + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseAsymptotics.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseAsymptotics.lean new file mode 100644 index 0000000..d4fc1b1 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseAsymptotics.lean @@ -0,0 +1,73 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import Mathlib.Analysis.SpecificLimits.Basic +import Mathlib.Analysis.SpecialFunctions.Log.Base + +open scoped BigOperators +open Filter Topology + +namespace CapacityAtlas.Gaussian.Interference + +theorem sum_le_of_pair_bounds {K : ℕ} (hK : 2 ≤ K) (R : Fin K → ℝ) (B : ℝ) + (h : ∀ i j, i ≠ j → R i + R j ≤ B) : ∑ i, R i ≤ (K : ℝ) / 2 * B := by + have hp : ∑ i, ∑ j, (R i + R j) ≤ + ∑ i, ∑ j, (if i = j then 2 * R i else B) := by + apply Finset.sum_le_sum + intro i _ + apply Finset.sum_le_sum + intro j _ + split_ifs with hij + · subst j + linarith + · exact h i j hij + have hrow (i : Fin K) : + (∑ j, if i = j then 2 * R i else B) = (K : ℝ) * B + (2 * R i - B) := by + calc + _ = ∑ j, (B + if i = j then 2 * R i - B else 0) := by + apply Finset.sum_congr rfl + intro j _ + split_ifs <;> ring + _ = _ := by simp [Finset.sum_add_distrib] + simp only [hrow, Finset.sum_add_distrib, Finset.sum_sub_distrib, Finset.sum_const, + Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, ← Finset.mul_sum] at hp + have hKr : (2 : ℝ) ≤ K := by exact_mod_cast hK + have hm : 0 < (K : ℝ) - 1 := by linarith + have hh : ((K : ℝ) - 1) * (2 * (∑ i, R i) - K * B) ≤ 0 := by nlinarith [hp] + have hz : 2 * (∑ i, R i) - K * B ≤ 0 := + le_of_not_gt (fun hz ↦ not_le_of_gt (mul_pos hm hz) hh) + nlinarith + +theorem log_affine_div_log_tendsto {a : ℝ} (ha : 0 < a) : + Tendsto (fun P : ℝ ↦ Real.log (1 + a * P) / Real.log P) atTop (𝓝 1) := by + have ht : Tendsto (fun P : ℝ ↦ a + 1 / P) atTop (𝓝 a) := by + have h : Tendsto (fun P : ℝ ↦ 1 / P) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop tendsto_id + simpa using tendsto_const_nhds.add h + have hl : Tendsto (fun P : ℝ ↦ Real.log (a + 1 / P)) atTop (𝓝 (Real.log a)) := by + simpa only [Function.comp_def] using (Real.continuousAt_log ha.ne').tendsto.comp ht + have he := hl.div_atTop Real.tendsto_log_atTop + have hf : Tendsto (fun P : ℝ ↦ 1 + Real.log (a + 1 / P) / Real.log P) + atTop (𝓝 1) := by simpa using tendsto_const_nhds.add he + apply hf.congr' + filter_upwards [eventually_gt_atTop (1 : ℝ)] with P hP + have hp : 0 < P := by linarith + have hn : 0 < a + 1 / P := by positivity + have heq : 1 + a * P = (a + 1 / P) * P := by field_simp; ring + rw [heq, Real.log_mul hn.ne' hp.ne'] + field_simp [ne_of_gt (Real.log_pos hP)] + ring + +theorem logb_affine_div_logb_tendsto {a : ℝ} (ha : 0 < a) : + Tendsto (fun P : ℝ ↦ Real.logb 2 (1 + a * P) / Real.logb 2 P) atTop (𝓝 1) := by + convert log_affine_div_log_tendsto ha using 1 + funext P + simp only [Real.logb] + by_cases hp : Real.log P = 0 + · simp [hp] + · field_simp [hp, ne_of_gt (Real.log_pos (by norm_num : (1 : ℝ) < 2))] + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseEnergy.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseEnergy.lean new file mode 100644 index 0000000..35c4bc5 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/ConverseEnergy.lean @@ -0,0 +1,113 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.CodePair + +open MeasureTheory ProbabilityTheory Matrix +open scoped BigOperators ENNReal + +namespace CapacityAtlas.Gaussian.Interference + +variable {K n : ℕ} + +theorem measurable_userSignal (c : Code K n) (r i : Fin K) (a : Fin (c.messages i)) : + Measurable fun H ↦ userSignal c H r i a := by + apply measurable_realBlock.comp + apply measurable_pi_lambda + intro t + exact (by fun_prop : Measurable fun H : StateBlock K n ↦ H t r i).mul + (c.encode_measurable i a t) + +theorem measurable_pairEnergy (c : Code K n) (i j : Fin K) (m : c.Message) : + Measurable fun H ↦ pairEnergy c H i j m := + ((measurable_userSignal c i i (m i)).add + (measurable_userSignal c i j (m j))).norm.pow_const 2 + +theorem pairEnergy_nonneg (c : Code K n) (H : StateBlock K n) (i j : Fin K) + (m : c.Message) : 0 ≤ pairEnergy c H i j m := sq_nonneg _ + +theorem pairEnergy_le_energy (c : Code K n) (H : StateBlock K n) (i j : Fin K) + (hij : i ≠ j) (m : c.Message) {U : ℝ} (_hU : 0 ≤ U) + (hHi : ∀ s, ‖H s i i‖ ≤ U) (hHj : ∀ s, ‖H s i j‖ ≤ U) : + pairEnergy c H i j m ≤ 2 * U ^ 2 * energy c m H := by + unfold pairEnergy userSignal + rw [← realBlock_add, norm_realBlock_sq] + unfold energy + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro s _ + simp only [Pi.add_apply] + have hnorm (x y : ℂ) : ‖x + y‖ ^ 2 ≤ 2 * (‖x‖ ^ 2 + ‖y‖ ^ 2) := by + have h := norm_add_le x y + nlinarith [norm_nonneg (x + y), norm_nonneg x, norm_nonneg y, + sq_nonneg (‖x‖ - ‖y‖)] + have hi : ‖H s i i * c.encode i (m i) H s‖ ^ 2 ≤ + U ^ 2 * ‖c.encode i (m i) H s‖ ^ 2 := by + rw [norm_mul, mul_pow] + gcongr + exact hHi s + have hj : ‖H s i j * c.encode j (m j) H s‖ ^ 2 ≤ + U ^ 2 * ‖c.encode j (m j) H s‖ ^ 2 := by + rw [norm_mul, mul_pow] + gcongr + exact hHj s + have hs : ‖c.encode i (m i) H s‖ ^ 2 + ‖c.encode j (m j) H s‖ ^ 2 ≤ + ∑ k, ‖c.encode k (m k) H s‖ ^ 2 := by + have hsub := Finset.sum_le_sum_of_subset_of_nonneg + (s := {i, j}) (t := Finset.univ) (f := fun k ↦ ‖c.encode k (m k) H s‖ ^ 2) + (Finset.subset_univ _) (fun k _ _ ↦ sq_nonneg _) + simpa [hij] using hsub + have hscale := mul_le_mul_of_nonneg_left hs (sq_nonneg U) + have h := hnorm (H s i i * c.encode i (m i) H s) (H s i j * c.encode j (m j) H s) + nlinarith + +theorem integrable_pairEnergy (μ : Measure ℂ) (c : Code K n) {P U : ℝ} + (hc : PowerAdmissible μ P c) (hU : 0 ≤ U) (i j : Fin K) (hij : i ≠ j) + (hH : ∀ᵐ H ∂stateLaw μ K n, (∀ s, ‖H s i i‖ ≤ U) ∧ (∀ s, ‖H s i j‖ ≤ U)) + (m : c.Message) : Integrable (fun H ↦ pairEnergy c H i j m) (stateLaw μ K n) := by + apply Integrable.mono' ((hc.1 m).const_mul (2 * U ^ 2)) + (measurable_pairEnergy c i j m).aestronglyMeasurable + filter_upwards [hH] with H hh + rw [Real.norm_eq_abs, abs_of_nonneg (pairEnergy_nonneg c H i j m)] + exact pairEnergy_le_energy c H i j hij m hU hh.1 hh.2 + +theorem integrable_messageAverage (μ : Measure ℂ) (c : Code K n) + (f : c.Message → StateBlock K n → ℝ) + (hf : ∀ m, Integrable (f m) (stateLaw μ K n)) : + Integrable (fun H ↦ ∫ m, f m H ∂messageLaw c) (stateLaw μ K n) := by + simp_rw [integral_messageLaw] + exact (integrable_finsetSum Finset.univ (fun m _ ↦ hf m)).const_mul _ + +theorem integral_state_messageAverage (μ : Measure ℂ) (c : Code K n) + (f : c.Message → StateBlock K n → ℝ) + (hf : ∀ m, Integrable (f m) (stateLaw μ K n)) : + (∫ H, ∫ m, f m H ∂messageLaw c ∂stateLaw μ K n) = + ∫ m, ∫ H, f m H ∂stateLaw μ K n ∂messageLaw c := by + simp_rw [integral_messageLaw] + rw [integral_const_mul, integral_finsetSum Finset.univ (fun m _ ↦ hf m)] + +theorem integral_pairEnergy_le (μ : Measure ℂ) (c : Code K n) {P U : ℝ} + (hc : PowerAdmissible μ P c) (hU : 0 ≤ U) (i j : Fin K) (hij : i ≠ j) + (hH : ∀ᵐ H ∂stateLaw μ K n, (∀ s, ‖H s i i‖ ≤ U) ∧ (∀ s, ‖H s i j‖ ≤ U)) : + (∫ H, ∫ m, pairEnergy c H i j m ∂messageLaw c ∂stateLaw μ K n) ≤ + 2 * U ^ 2 * ((n : ℝ) * P) := by + have hp (m : c.Message) := integrable_pairEnergy μ c hc hU i j hij hH m + rw [integral_state_messageAverage μ c _ hp, integral_messageLaw] + have hi (m : c.Message) : (∫ H, pairEnergy c H i j m ∂stateLaw μ K n) ≤ + 2 * U ^ 2 * (∫ H, energy c m H ∂stateLaw μ K n) := by + rw [← integral_const_mul] + apply integral_mono_ae (hp m) ((hc.1 m).const_mul _) + filter_upwards [hH] with H hh + exact pairEnergy_le_energy c H i j hij m hU hh.1 hh.2 + calc + _ ≤ (∏ i, (c.messages i : ℝ))⁻¹ * + ∑ m, 2 * U ^ 2 * (∫ H, energy c m H ∂stateLaw μ K n) := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun m _ ↦ hi m) (by positivity) + _ = 2 * U ^ 2 * ((∏ i, (c.messages i : ℝ))⁻¹ * + ∑ m, ∫ H, energy c m H ∂stateLaw μ K n) := by rw [← Finset.mul_sum]; ring + _ ≤ _ := mul_le_mul_of_nonneg_left hc.2 (by positivity) + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/FiniteObservation.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/FiniteObservation.lean new file mode 100644 index 0000000..13396b5 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/FiniteObservation.lean @@ -0,0 +1,61 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.FiniteChannel.PMF +import CapacityAtlasForMathlib.InformationTheory.CodingConverse +import Mathlib.MeasureTheory.Measure.Real + +open MeasureTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +noncomputable section + +def observedChannel {Ω A : Type*} [MeasurableSpace Ω] [Fintype A] + [MeasurableSpace A] [MeasurableSingletonClass A] + (ν : Measure Ω) [IsProbabilityMeasure ν] (f : A → Ω → A) + (hf : ∀ a, Measurable (f a)) : FiniteChannel A A := + FiniteChannel.ofRows fun a => + letI : IsProbabilityMeasure (ν.map (f a)) := + Measure.isProbabilityMeasure_map (hf a).aemeasurable + FiniteDistribution.ofPMF (ν.map (f a)).toPMF + +theorem observedChannel_transition {Ω A : Type*} [MeasurableSpace Ω] [Fintype A] + [MeasurableSpace A] [MeasurableSingletonClass A] + (ν : Measure Ω) [IsProbabilityMeasure ν] (f : A → Ω → A) + (hf : ∀ a, Measurable (f a)) (a b : A) : + (observedChannel ν f hf).transition a b = ν.real {ω | f a ω = b} := by + simp only [observedChannel, FiniteChannel.ofRows_transition, + FiniteDistribution.ofPMF_apply, Measure.toPMF_apply, Measure.real] + rw [Measure.map_apply (hf a) (measurableSet_singleton b)] + rfl + +theorem finite_fano_lower {A : Type*} [Fintype A] [Nonempty A] + (W : FiniteChannel A A) {ε : ℝ} (hε : ∀ a, 1 - W.transition a a ≤ ε) : + (1 - ε) * Real.log (Fintype.card A) - Real.log 2 ≤ + W.mutualInformation (FiniteDistribution.uniform A) := by + classical + let c : OneShotCode W A := ⟨id, id⟩ + have hc : c.averageErrorProbability ≤ ε := by + rw [OneShotCode.averageErrorProbability_eq] + have hcard : (0 : ℝ) < Fintype.card A := by exact_mod_cast Fintype.card_pos + calc + _ ≤ (Fintype.card A : ℝ)⁻¹ * ∑ _ : A, ε := by + gcongr with a + simpa [c, OneShotCode.errorProbability, OneShotCode.successProbability] using hε a + _ = ε := by simp [hcard.ne'] + have hf := FiniteChannel.fano_uniform W id + change Real.log (Fintype.card A) ≤ + W.mutualInformation (FiniteDistribution.uniform A) + Real.log 2 + + c.averageErrorProbability * Real.log (Fintype.card A) at hf + have hlog : 0 ≤ Real.log (Fintype.card A) := + Real.log_nonneg (by exact_mod_cast Fintype.card_pos (α := A)) + nlinarith [mul_le_mul_of_nonneg_right hc hlog] + +end + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Genie.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Genie.lean new file mode 100644 index 0000000..549dd96 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Genie.lean @@ -0,0 +1,64 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.PairwiseBound + +open MeasureTheory ProbabilityTheory InformationTheory Matrix +open scoped ENNReal + +namespace CapacityAtlas.Gaussian.Interference + +variable {A B ι : Type*} + [Fintype A] [Fintype B] [Nonempty A] [Nonempty B] + [MeasurableSpace A] [MeasurableSpace B] + [MeasurableSingletonClass A] [MeasurableSingletonClass B] + [Fintype ι] [DecidableEq ι] + +/-- The second receiver's interfering coefficient is invertible in the physical application; +`H` transfers its contribution at receiver one to its contribution at receiver two. -/ +theorem twoUser_linear_gaussian_fano + (μ : Measure A) [IsProbabilityMeasure μ] (ν : Measure B) [IsProbabilityMeasure ν] + (u u' : A → EuclideanSpace ℝ ι) (v : B → EuclideanSpace ℝ ι) + (c₁ c₂ : EuclideanSpace ℝ ι) (H : Matrix ι ι ℝ) + {e t q : ℝ} (he : 0 < e) (ht : 0 < t) (heq : e ≤ q) + (hres : (q • 1 - H * (e • 1) * H.transpose).PosSemidef) + (d₁ : EuclideanSpace ℝ ι → A) (hd₁ : Measurable d₁) + (d₂ : EuclideanSpace ℝ ι → B) (hd₂ : Measurable d₂) + (hμ : ∀ a, μ {a} = (Fintype.card A : ℝ≥0∞)⁻¹) + (hν : ∀ b, ν {b} = (Fintype.card B : ℝ≥0∞)⁻¹) : + Real.log (Fintype.card A) + Real.log (Fintype.card B) ≤ + (Fintype.card ι : ℝ) / 2 * Real.log (t / e) + + ((Fintype.card ι : ℝ) * e + (∫ p : A × B, ‖u p.1 + v p.2‖ ^ 2 ∂μ.prod ν)) / + (2 * t) - (Fintype.card ι : ℝ) / 2 + 2 * Real.log 2 + + (∫ a, ∫ b, (multivariateGaussian (u a + v b + c₁) (q • 1)).real + {y | d₁ y ≠ a} ∂ν ∂μ) * Real.log (Fintype.card A) + + (∫ a, ∫ b, (multivariateGaussian (u' a + H.toEuclideanLin (v b) + c₂) (q • 1)).real + {z | d₂ z ≠ b} ∂ν ∂μ) * Real.log (Fintype.card B) := by + let η₁ := affineGaussianKernel (1 : Matrix ι ι ℝ) c₁ ((q - e) • 1) + let η₂ := fun a ↦ affineGaussianKernel H + (u' a + c₂ - H.toEuclideanLin (u a)) (q • 1 - H * (e • 1) * H.transpose) + have hr₁ (a : A) (b : B) : η₁ ∘ₘ multivariateGaussian (u a + v b) (e • 1) = + multivariateGaussian (u a + v b + c₁) (q • 1) := by + rw [affineGaussianKernel_comp 1 c₁ _ (PosSemidef.one.smul (sub_nonneg.mpr heq)) + _ _ (PosDef.one.smul he).posSemidef] + congr 1 + · simp only [Matrix.toLpLin_apply, Matrix.one_mulVec, WithLp.toLp_ofLp] + abel + · simp only [transpose_one, one_mul, mul_one, ← add_smul] + congr 1 + ring + have hr₂ (a : A) (b : B) : η₂ a ∘ₘ multivariateGaussian (u a + v b) (e • 1) = + multivariateGaussian (u' a + H.toEuclideanLin (v b) + c₂) (q • 1) := by + rw [affineGaussianKernel_residual H _ _ _ (PosDef.one.smul he).posSemidef hres] + congr 1 + rw [map_add] + abel + have hf := twoUser_gaussian_fano_isotropic μ ν (fun a b ↦ u a + v b) he ht + η₁ η₂ d₁ hd₁ (fun _ ↦ d₂) (fun _ ↦ hd₂) hμ hν + simp_rw [hr₁, hr₂] at hf + exact hf + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/LogarithmicInterpolation.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/LogarithmicInterpolation.lean new file mode 100644 index 0000000..d76b240 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/LogarithmicInterpolation.lean @@ -0,0 +1,81 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import Mathlib.Analysis.SpecificLimits.Basic +import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Analysis.SpecialFunctions.Sqrt + +open Filter Topology + +namespace CapacityAtlas.Gaussian.Interference + +noncomputable def qamOrder (C P : ℝ) : ℕ := ⌊Real.sqrt (P / C)⌋₊ + +theorem qamOrder_tendsto {C : ℝ} (hC : 0 < C) : + Tendsto (qamOrder C) atTop atTop := by + exact tendsto_nat_floor_atTop.comp + (Real.tendsto_sqrt_atTop.comp (tendsto_id.atTop_div_const hC)) + +theorem qamOrder_power_le {C P : ℝ} (hC : 0 < C) (hP : 0 ≤ P) : + C * (qamOrder C P : ℝ) ^ 2 ≤ P := by + have hq : (qamOrder C P : ℝ) ≤ Real.sqrt (P / C) := Nat.floor_le (Real.sqrt_nonneg _) + have hs := Real.sq_sqrt (div_nonneg hP hC.le) + have hq0 : (0 : ℝ) ≤ qamOrder C P := Nat.cast_nonneg _ + have hp : (qamOrder C P : ℝ) ^ 2 ≤ P / C := by nlinarith [Real.sqrt_nonneg (P / C)] + simpa only [mul_comm] using (le_div_iff₀ hC).mp hp + +theorem log_qamOrder_div_log_tendsto {C : ℝ} (hC : 0 < C) : + Tendsto (fun P : ℝ ↦ Real.log (qamOrder C P) / Real.log P) atTop (𝓝 (1 / 2 : ℝ)) := by + have hs : Tendsto (fun P : ℝ ↦ Real.sqrt (P / C)) atTop atTop := + Real.tendsto_sqrt_atTop.comp (tendsto_id.atTop_div_const hC) + have hr : Tendsto (fun P : ℝ ↦ (qamOrder C P : ℝ) / Real.sqrt (P / C)) + atTop (𝓝 1) := tendsto_nat_floor_div_atTop.comp hs + have hl : Tendsto (fun P : ℝ ↦ Real.log ((qamOrder C P : ℝ) / Real.sqrt (P / C))) + atTop (𝓝 0) := by + simpa only [Function.comp_def, Real.log_one] using + (Real.continuousAt_log (by norm_num : (1 : ℝ) ≠ 0)).tendsto.comp hr + have he := hl.div_atTop Real.tendsto_log_atTop + have hc : Tendsto (fun P : ℝ ↦ Real.log C / Real.log P) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop Real.tendsto_log_atTop + have hf : Tendsto (fun P : ℝ ↦ (1 / 2 : ℝ) - (Real.log C / Real.log P) / 2 + + Real.log ((qamOrder C P : ℝ) / Real.sqrt (P / C)) / Real.log P) + atTop (𝓝 (1 / 2 : ℝ)) := by + convert (tendsto_const_nhds.sub (hc.div_const 2)).add he using 1 + norm_num + apply hf.congr' + filter_upwards [eventually_gt_atTop (1 : ℝ), + (qamOrder_tendsto hC).eventually_ge_atTop 1] with P hP hq + have hPn : P ≠ 0 := by linarith + have hq0 : (qamOrder C P : ℝ) ≠ 0 := by exact_mod_cast (by omega : qamOrder C P ≠ 0) + have hs0 : Real.sqrt (P / C) ≠ 0 := ne_of_gt (Real.sqrt_pos.2 (div_pos (by linarith) hC)) + rw [Real.log_div hq0 hs0, Real.log_sqrt (div_nonneg (by linarith) hC.le), + Real.log_div hPn hC.ne'] + have hlP : Real.log P ≠ 0 := ne_of_gt (Real.log_pos hP) + field_simp + ring + +/-- A lower bound at quadratic powers extends to every sufficiently large power. -/ +theorem eventually_lower_bound_of_quadratic_grid {F : ℝ → ℝ} (hF : Monotone F) + {C a b d : ℝ} (hC : 0 < C) (hd : d < a / 2) + (hb : ∀ᶠ q : ℕ in atTop, a * Real.log q - b ≤ F (C * (q : ℝ) ^ 2)) : + ∀ᶠ P : ℝ in atTop, d ≤ F P / Real.log P := by + have hlim : Tendsto + (fun P : ℝ ↦ (a * Real.log (qamOrder C P) - b) / Real.log P) + atTop (𝓝 (a / 2)) := by + have h₁ := (log_qamOrder_div_log_tendsto hC).const_mul a + have h₂ : Tendsto (fun P : ℝ ↦ b / Real.log P) atTop (𝓝 0) := + tendsto_const_nhds.div_atTop Real.tendsto_log_atTop + convert h₁.sub h₂ using 1 + · funext P + ring + · simp [div_eq_mul_inv] + filter_upwards [hlim.eventually (isOpen_Ioi.mem_nhds hd), (qamOrder_tendsto hC).eventually hb, + eventually_gt_atTop (1 : ℝ)] with P hdP hbP hP + apply hdP.le.trans + apply div_le_div_of_nonneg_right _ (Real.log_pos hP).le + exact hbP.trans (hF (qamOrder_power_le hC (by linarith))) + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Monomials.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Monomials.lean new file mode 100644 index 0000000..9c382ee --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Monomials.lean @@ -0,0 +1,141 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.LinearAlgebra.MonomialEvaluation +import Mathlib.Data.Fintype.Card + +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +variable (U : Type*) [Fintype U] [DecidableEq U] + +abbrev Cross := {p : U × U // p.1 ≠ p.2} + +abbrev Box (n : ℕ) := Cross U → Fin n + +abbrev Columns (n : ℕ) := Box U n ⊕ Box U (n + 1) + +variable {U} + +def beamExponent {n : ℕ} (a : Box U n) (p : U × U) : ℕ := + if h : p.1 ≠ p.2 then (a ⟨p, h⟩).val else 0 + +omit [Fintype U] in +@[simp] theorem beamExponent_cross {n : ℕ} (a : Box U n) (p : Cross U) : + beamExponent a p.val = (a p).val := by simp [beamExponent, p.property] + +omit [Fintype U] in +@[simp] theorem beamExponent_diag {n : ℕ} (a : Box U n) (i : U) : + beamExponent a (i, i) = 0 := by simp [beamExponent] + +def columnExponent {n : ℕ} (i : U) : Columns U n → U × U → ℕ + | Sum.inl a, p => beamExponent a p + if p = (i, i) then 1 else 0 + | Sum.inr a, p => beamExponent a p + +omit [Fintype U] in +theorem columnExponent_injective {n : ℕ} (i : U) : + Function.Injective (columnExponent (n := n) i) := by + intro a b hab + cases a with + | inl a => + cases b with + | inl b => + congr 1 + funext p + apply Fin.ext + have h := congrFun hab p.val + have hp : p.val ≠ (i, i) := by intro hp; exact p.property (by rw [hp]) + simpa [columnExponent, hp] using h + | inr b => + have h := congrFun hab (i, i) + simp [columnExponent] at h + | inr a => + cases b with + | inl b => + have h := congrFun hab (i, i) + simp [columnExponent] at h + | inr b => + congr 1 + funext p + apply Fin.ext + have h := congrFun hab p.val + simpa [columnExponent] using h + +def shifted {n : ℕ} (a : Box U n) (p : Cross U) : Box U (n + 1) := + fun q ↦ ⟨(a q).val + if q = p then 1 else 0, by + split_ifs <;> have := (a q).isLt <;> omega⟩ + +omit [Fintype U] in +theorem shifted_exponent {n : ℕ} (a : Box U n) (p : Cross U) (q : U × U) : + beamExponent (shifted a p) q = beamExponent a q + if q = p.val then 1 else 0 := by + by_cases hq : q.1 = q.2 + · have hp : q ≠ p.val := by intro hp; exact p.property (hp ▸ hq) + simp [beamExponent, hq, hp] + · simp only [beamExponent, dif_pos hq, shifted, Subtype.ext_iff] + +variable {R : Type*} [CommRing R] + +def beam {n : ℕ} (h : U × U → R) (a : Box U n) : R := + ∏ p, h p ^ beamExponent a p + +theorem beam_shifted {n : ℕ} (h : U × U → R) (a : Box U n) (p : Cross U) : + beam h (shifted a p) = h p.val * beam h a := by + classical + simp only [beam, shifted_exponent, pow_add, Finset.prod_mul_distrib] + have ht : (∏ q, h q ^ (if q = p.val then 1 else 0 : ℕ)) = h p.val := by + rw [Finset.prod_eq_single p.val] + · simp + · intro q _ hq + simp [hq] + · simp + rw [ht, mul_comm] + +theorem eval_column {n : ℕ} (h : U × U → R) (i : U) (a : Columns U n) : + (∏ p, h p ^ columnExponent i a p) = + Sum.elim (fun a ↦ h (i, i) * beam h a) (beam h) a := by + classical + cases a with + | inl a => + simp only [columnExponent, pow_add, Finset.prod_mul_distrib, Sum.elim_inl] + have ht : (∏ q, h q ^ (if q = (i, i) then 1 else 0 : ℕ)) = h (i, i) := by + rw [Finset.prod_eq_single (i, i)] + · simp + · intro q _ hq + simp [hq] + · simp + rw [ht, mul_comm] + rfl + | inr a => rfl + +noncomputable def decodingPolynomial {n : ℕ} (i : U) : + MvPolynomial (Columns U n × (U × U)) R := + Matrix.det (MonomialEvaluation.matrix (columnExponent (n := n) i)) + +theorem decodingPolynomial_ne_zero [Nontrivial R] {n : ℕ} (i : U) : + decodingPolynomial (R := R) (n := n) i ≠ 0 := + MonomialEvaluation.determinant_ne_zero _ (columnExponent_injective i) + +theorem card_cross : Fintype.card (Cross U) = Fintype.card U * (Fintype.card U - 1) := by + classical + let e : {p : U × U // p.1 = p.2} ≃ U := + { toFun := fun p ↦ p.val.1 + invFun := fun i ↦ ⟨(i, i), rfl⟩ + left_inv := by rintro ⟨⟨i, j⟩, hij⟩; cases hij; rfl + right_inv := fun _ ↦ rfl } + have he := Fintype.card_congr e + change Fintype.card {p : U × U // ¬p.1 = p.2} = _ + rw [Fintype.card_subtype_compl, Fintype.card_prod, he, Nat.mul_sub_left_distrib, + Nat.mul_one] + +theorem card_box (n : ℕ) : Fintype.card (Box U n) = n ^ Fintype.card (Cross U) := by + simp [Box] + +theorem card_columns (n : ℕ) : Fintype.card (Columns U n) = + n ^ Fintype.card (Cross U) + (n + 1) ^ Fintype.card (Cross U) := by + simp [Columns] + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/NoiseTail.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/NoiseTail.lean new file mode 100644 index 0000000..e4dc6f8 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/NoiseTail.lean @@ -0,0 +1,50 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Quantization +import Mathlib.MeasureTheory.Measure.Real +import Mathlib.MeasureTheory.Constructions.BorelSpace.Metric + +open MeasureTheory Filter +open scoped BigOperators Topology + +namespace CapacityAtlas.Gaussian.Interference + +/-- Finite-valued measurable noise has arbitrarily small tails; no moment bound is needed. -/ +theorem exists_noise_bound {Ω A : Type*} [MeasurableSpace Ω] [Fintype A] + (ν : Measure Ω) [IsFiniteMeasure ν] (ξ : Ω → A → ℂ) + (hξ : ∀ a, Measurable fun ω => ξ ω a) {ε : ℝ} (hε : 0 < ε) : + ∃ b : ℝ, 0 < b ∧ ν.real {ω | ∃ a, b ≤ ‖ξ ω a‖} < ε := by + classical + let f : Ω → ℝ := fun ω => ∑ a, ‖ξ ω a‖ + have hf : Measurable f := Finset.measurable_sum _ fun a _ => (hξ a).norm + let s : ℕ → Set Ω := fun n => {ω | (n : ℝ) ≤ f ω} + have hs : ∀ n, MeasurableSet (s n) := fun n => measurableSet_le measurable_const hf + have hmono : Antitone s := by + intro n m hnm ω hω + exact (show (n : ℝ) ≤ m by exact_mod_cast hnm).trans hω + have hempty : ⋂ n, s n = ∅ := by + apply Set.eq_empty_iff_forall_notMem.mpr + intro ω hω + obtain ⟨n, hn⟩ := exists_nat_gt (f ω) + exact (not_le_of_gt hn) (Set.mem_iInter.mp hω n) + have ht : Tendsto (fun n => ν (s n)) atTop (𝓝 0) := by + simpa only [hempty, measure_empty, Function.comp_def] using + tendsto_measure_iInter_atTop (fun n => (hs n).nullMeasurableSet) + hmono ⟨0, measure_ne_top _ _⟩ + have hreal : Tendsto (fun n => ν.real (s n)) atTop (𝓝 0) := by + simpa only [Measure.real, ENNReal.toReal_zero, Function.comp_def] using + (ENNReal.tendsto_toReal ENNReal.zero_ne_top).comp ht + obtain ⟨n, hn⟩ := (hreal.eventually (gt_mem_nhds hε)).exists + refine ⟨n + 1, by positivity, lt_of_le_of_lt ?_ hn⟩ + refine measureReal_mono ?_ (measure_ne_top _ _) + rintro ω ⟨a, ha⟩ + have hsum : ‖ξ ω a‖ ≤ f ω := + Finset.single_le_sum (fun a _ => norm_nonneg (ξ ω a)) (Finset.mem_univ a) + change (n : ℝ) ≤ f ω + linarith + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PairMessages.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PairMessages.lean new file mode 100644 index 0000000..80a12f5 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PairMessages.lean @@ -0,0 +1,87 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.CodeLaws +import CapacityAtlasForMathlib.MeasureTheory.PiResampling + +open MeasureTheory ProbabilityTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +variable {K n : ℕ} + +def pairMessage (c : Code K n) (m : c.Message) (i j : Fin K) + (a : Fin (c.messages i)) (b : Fin (c.messages j)) : c.Message := + Function.update (Function.update m i a) j b + +@[simp] theorem pairMessage_left (c : Code K n) (m : c.Message) (i j : Fin K) + (hij : i ≠ j) (a : Fin (c.messages i)) (b : Fin (c.messages j)) : + pairMessage c m i j a b i = a := by simp [pairMessage, hij] + +@[simp] theorem pairMessage_right (c : Code K n) (m : c.Message) (i j : Fin K) + (a : Fin (c.messages i)) (b : Fin (c.messages j)) : + pairMessage c m i j a b j = b := by simp [pairMessage] + +theorem integral_pairMessage (c : Code K n) (i j : Fin K) (f : c.Message → ℝ) : + (∫ m, ∫ a, ∫ b, f (pairMessage c m i j a b) + ∂uniformFinLaw (c.messages j) (c.messages_pos j) + ∂uniformFinLaw (c.messages i) (c.messages_pos i) ∂messageLaw c) = + ∫ m, f m ∂messageLaw c := by + unfold pairMessage messageLaw + rw [integral_integral_swap Integrable.of_finite] + have hi := integral_updateProduct + (fun k ↦ uniformFinLaw (c.messages k) (c.messages_pos k)) i + (fun m ↦ ∫ b, f (Function.update m j b) + ∂uniformFinLaw (c.messages j) (c.messages_pos j)) + rw [hi, integral_integral_swap Integrable.of_finite] + exact integral_updateProduct + (fun k ↦ uniformFinLaw (c.messages k) (c.messages_pos k)) j f + +noncomputable def userSignal (c : Code K n) (H : StateBlock K n) (r i : Fin K) + (a : Fin (c.messages i)) : EuclideanSpace ℝ (Fin 2 × Fin n) := + realBlock fun t ↦ H t r i * c.encode i a H t + +noncomputable def pairBackground (c : Code K n) (m : c.Message) (H : StateBlock K n) + (r i j : Fin K) : EuclideanSpace ℝ (Fin 2 × Fin n) := + realBlock fun t ↦ ∑ k, if k = i ∨ k = j then 0 else H t r k * c.encode k (m k) H t + +theorem receiverMean_pairMessage (c : Code K n) (m : c.Message) (H : StateBlock K n) + (r i j : Fin K) (hij : i ≠ j) (a : Fin (c.messages i)) (b : Fin (c.messages j)) : + receiverMean c (pairMessage c m i j a b) H r = + userSignal c H r i a + userSignal c H r j b + pairBackground c m H r i j := by + unfold receiverMean userSignal pairBackground + rw [← realBlock_add, ← realBlock_add] + congr 1 + ext t + have hs : (∑ k, H t r k * c.encode k (pairMessage c m i j a b k) H t) = + ∑ k, ((if k = i then H t r i * c.encode i a H t else 0) + + (if k = j then H t r j * c.encode j b H t else 0) + + (if k = i ∨ k = j then 0 else H t r k * c.encode k (m k) H t)) := by + apply Finset.sum_congr rfl + intro k _ + by_cases hki : k = i + · subst k + simp [hij] + · by_cases hkj : k = j + · subst k + simp [hij.symm] + · simp [pairMessage, hki, hkj] + rw [hs] + simp only [Finset.sum_add_distrib, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte, + Pi.add_apply] + +theorem userSignal_transfer (c : Code K n) (H : StateBlock K n) (r s i : Fin K) + (hH : ∀ t, H t r i ≠ 0) (a : Fin (c.messages i)) : + (complexBlockMatrix (fun t ↦ H t s i / H t r i)).toEuclideanLin (userSignal c H r i a) = + userSignal c H s i a := by + unfold userSignal + rw [complexBlockMatrix_apply] + congr 1 + ext t + field_simp [hH t] + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PairwiseBound.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PairwiseBound.lean new file mode 100644 index 0000000..e9dd27b --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PairwiseBound.lean @@ -0,0 +1,84 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.StateInformation +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.Postprocess + +open MeasureTheory ProbabilityTheory InformationTheory Matrix +open scoped ENNReal + +namespace CapacityAtlas.Gaussian.Interference + +open MeasureInformation + +variable {A B Y Z ι : Type*} + [Fintype A] [Fintype B] [Nonempty A] [Nonempty B] + [MeasurableSpace A] [MeasurableSpace B] + [MeasurableSingletonClass A] [MeasurableSingletonClass B] + [MeasurableSpace Y] [MeasurableSpace Z] [Fintype ι] [DecidableEq ι] + +theorem twoUser_gaussian_fano_isotropic + (μ : Measure A) [IsProbabilityMeasure μ] (ν : Measure B) [IsProbabilityMeasure ν] + (m : A → B → EuclideanSpace ℝ ι) {e t : ℝ} (he : 0 < e) (ht : 0 < t) + (η₁ : Kernel (EuclideanSpace ℝ ι) Y) [IsMarkovKernel η₁] + (η₂ : A → Kernel (EuclideanSpace ℝ ι) Z) [∀ a, IsMarkovKernel (η₂ a)] + (d₁ : Y → A) (hd₁ : Measurable d₁) + (d₂ : A → Z → B) (hd₂ : ∀ a, Measurable (d₂ a)) + (hμ : ∀ a, μ {a} = (Fintype.card A : ℝ≥0∞)⁻¹) + (hν : ∀ b, ν {b} = (Fintype.card B : ℝ≥0∞)⁻¹) : + Real.log (Fintype.card A) + Real.log (Fintype.card B) ≤ + (Fintype.card ι : ℝ) / 2 * Real.log (t / e) + + ((Fintype.card ι : ℝ) * e + (∫ p : A × B, ‖m p.1 p.2‖ ^ 2 ∂μ.prod ν)) / + (2 * t) - (Fintype.card ι : ℝ) / 2 + 2 * Real.log 2 + + (∫ a, ∫ b, (η₁ ∘ₘ multivariateGaussian (m a b) (e • 1)).real + {y | d₁ y ≠ a} ∂ν ∂μ) * Real.log (Fintype.card A) + + (∫ a, ∫ b, (η₂ a ∘ₘ multivariateGaussian (m a b) (e • 1)).real + {z | d₂ a z ≠ b} ∂ν ∂μ) * Real.log (Fintype.card B) := by + have h := twoUser_gaussian_fano_reference μ ν m (e • 1) (t • 1) + (PosDef.one.smul he) (PosDef.one.smul ht) η₁ η₂ d₁ hd₁ d₂ hd₂ hμ hν + simp_rw [log_det_scalar_matrix, trace_inverse_scalar, scalar_inverse_quadratic] at h + rw [integral_const_mul] at h + convert h using 1 + rw [Real.log_div ht.ne' he.ne'] + field_simp + ring + +/-- Integrating the pair converse with a power-matched reference cancels the energy term. -/ +theorem pair_bound_of_integrated_energy {S : Type*} [MeasurableSpace S] + (σ : Measure S) [IsProbabilityMeasure σ] + {n : ℕ} {e t L₁ L₂ ε : ℝ} (ht : 0 < t) + (hL₁ : 0 ≤ L₁) (hL₂ : 0 ≤ L₂) + {energy error₁ error₂ : S → ℝ} + (henergy : Integrable energy σ) (herr₁ : Integrable error₁ σ) + (herr₂ : Integrable error₂ σ) + (hpower : (∫ s, energy s ∂σ) ≤ 2 * n * (t - e)) + (herror₁ : (∫ s, error₁ s ∂σ) ≤ ε) (herror₂ : (∫ s, error₂ s ∂σ) ≤ ε) + (hpointwise : ∀ᵐ s ∂σ, + L₁ + L₂ ≤ (n : ℝ) * Real.log (t / e) + + ((2 * n : ℝ) * e + energy s) / (2 * t) - n + 2 * Real.log 2 + + error₁ s * L₁ + error₂ s * L₂) : + (1 - ε) * (L₁ + L₂) ≤ (n : ℝ) * Real.log (t / e) + 2 * Real.log 2 := by + have hi : Integrable (fun s ↦ energy s / (2 * t)) σ := henergy.div_const _ + have hp : ∀ᵐ s ∂σ, + L₁ + L₂ ≤ ((n : ℝ) * Real.log (t / e) + (2 * n : ℝ) * e / (2 * t) - n + + 2 * Real.log 2) + energy s / (2 * t) + error₁ s * L₁ + error₂ s * L₂ := by + filter_upwards [hpointwise] with s hs + convert hs using 1 + ring + have hf := integrate_fano_energy σ hi herr₁ herr₂ hp + rw [integral_div] at hf + have hec : (2 * n : ℝ) * e / (2 * t) - n + + (∫ s, energy s ∂σ) / (2 * t) ≤ 0 := by + have hh := (div_le_div_of_nonneg_right hpower (by positivity : 0 ≤ 2 * t)) + have hid : (2 * n : ℝ) * e / (2 * t) - n + 2 * n * (t - e) / (2 * t) = 0 := by + field_simp + ring + linarith + have her₁ := mul_le_mul_of_nonneg_right herror₁ hL₁ + have her₂ := mul_le_mul_of_nonneg_right herror₂ hL₂ + nlinarith + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PolynomialMeasure.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PolynomialMeasure.lean new file mode 100644 index 0000000..ed6ecc3 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/PolynomialMeasure.lean @@ -0,0 +1,99 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import Mathlib.Algebra.MvPolynomial.Funext +import Mathlib.MeasureTheory.Constructions.Pi +import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex +import Mathlib.Topology.Algebra.MvPolynomial +import Mathlib.MeasureTheory.Measure.Typeclasses.NullSingletonClass +import Mathlib.Analysis.Complex.Basic + +open MeasureTheory + +namespace CapacityAtlas.Gaussian.Interference + +private theorem polynomial_ae_eval_ne_zero (p : Polynomial ℂ) (hp : p ≠ 0) + (μ : Measure ℂ) [NullSingletonClass μ] : ∀ᵐ x ∂μ, p.eval x ≠ 0 := by + simpa only [Polynomial.IsRoot, Set.mem_setOf_eq] using + (Polynomial.finite_setOf_isRoot hp).countable.ae_notMem μ + +private theorem ae_eval_ne_zero_fin {n : ℕ} (p : MvPolynomial (Fin n) ℂ) (hp : p ≠ 0) + (μ : Fin n → Measure ℂ) [∀ i, IsProbabilityMeasure (μ i)] + [∀ i, NullSingletonClass (μ i)] : + ∀ᵐ x ∂Measure.pi μ, MvPolynomial.eval x p ≠ 0 := by + classical + induction n with + | zero => + filter_upwards [] with x hx + apply hp + apply MvPolynomial.funext + intro y + simpa only [Subsingleton.elim y x, map_zero] using hx + | succ n ih => + let q := MvPolynomial.finSuccEquiv ℂ n p + have hq : q ≠ 0 := by + exact fun h => hp ((MvPolynomial.finSuccEquiv ℂ n).injective + (h.trans (map_zero _).symm)) + let k := q.natDegree + have hk : q.coeff k ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr hq + have htail := ih (q.coeff k) hk (fun i => μ i.succ) + have hc : Continuous (fun z : ℂ × (Fin n → ℂ) => + (Fin.cons z.1 z.2 : Fin (n + 1) → ℂ)) := by + apply continuous_pi + intro i + refine Fin.cases ?_ (fun j => ?_) i + · exact continuous_fst + · exact (continuous_apply j).comp continuous_snd + have hm : MeasurableSet {z : ℂ × (Fin n → ℂ) | + MvPolynomial.eval (Fin.cons z.1 z.2) p ≠ 0} := by + exact (isClosed_eq ((MvPolynomial.continuous_eval p).comp hc) + continuous_const).measurableSet.compl + have hinner : ∀ᵐ x ∂Measure.pi (fun i => μ i.succ), + ∀ᵐ y ∂μ 0, MvPolynomial.eval (Fin.cons y x) p ≠ 0 := by + filter_upwards [htail] with x hx + have hmap : q.map (MvPolynomial.eval x) ≠ 0 := by + intro h + have := congrArg (fun r : Polynomial ℂ => r.coeff k) h + exact hx (by simpa only [Polynomial.coeff_map, Polynomial.coeff_zero] using this) + simpa only [MvPolynomial.eval_eq_eval_mv_eval', q] using + polynomial_ae_eval_ne_zero (q.map (MvPolynomial.eval x)) hmap (μ 0) + have hprod : ∀ᵐ z ∂(μ 0).prod (Measure.pi (fun i => μ i.succ)), + MvPolynomial.eval (Fin.cons z.1 z.2) p ≠ 0 := (Measure.ae_prod_iff_ae_ae hm).mpr + ((Measure.ae_ae_comm hm).mpr hinner) + have hmp := measurePreserving_piFinSuccAbove μ (0 : Fin (n + 1)) + simp only [Fin.succAbove_zero] at hmp + have h := hmp.quasiMeasurePreserving.ae hprod + filter_upwards [h] with x hx + change MvPolynomial.eval (Fin.cons (x 0) (fun j => x j.succ)) p ≠ 0 at hx + have hcons : (Fin.cons (x 0) (fun j => x j.succ) : Fin (n + 1) → ℂ) = x := by + funext i + refine Fin.cases ?_ (fun j => ?_) i <;> simp + rwa [hcons] at hx + +/-- Independent nonatomic coordinates avoid every nonzero complex polynomial almost surely. -/ +theorem ae_eval_ne_zero {ι : Type*} [Fintype ι] (p : MvPolynomial ι ℂ) (hp : p ≠ 0) + (μ : ι → Measure ℂ) [∀ i, IsProbabilityMeasure (μ i)] + [∀ i, NullSingletonClass (μ i)] : + ∀ᵐ x ∂Measure.pi μ, MvPolynomial.eval x p ≠ 0 := by + classical + let e := (Fintype.equivFin ι).symm + let q := MvPolynomial.rename e.symm p + have hq : q ≠ 0 := by + intro h + apply hp + exact (MvPolynomial.rename_injective e.symm e.symm.injective) + (h.trans (map_zero _).symm) + have h := ae_eval_ne_zero_fin q hq (fun i => μ (e i)) + have h' := (measurePreserving_piCongrLeft μ e).symm.quasiMeasurePreserving.ae h + simp only [q, MvPolynomial.eval_rename] at h' + filter_upwards [h'] with x hx + have heq : (MeasurableEquiv.piCongrLeft (fun _ : ι => ℂ) e).symm x ∘ e.symm = x := by + funext j + change x (e (e.symm j)) = x j + rw [Equiv.apply_symm_apply] + rwa [heq] at hx + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Postprocess.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Postprocess.lean new file mode 100644 index 0000000..70160fe --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Postprocess.lean @@ -0,0 +1,72 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.Probability.GaussianBlocks +import CapacityAtlasForMathlib.InformationTheory.GaussianMixtureEntropyBounds + +open MeasureTheory ProbabilityTheory Matrix +open scoped ENNReal + +namespace CapacityAtlas.Gaussian.Interference + +variable {ι ο : Type*} [Fintype ι] [Fintype ο] [DecidableEq ι] [DecidableEq ο] + +noncomputable def affineGaussianKernel (H : Matrix ο ι ℝ) + (c : EuclideanSpace ℝ ο) (R : Matrix ο ο ℝ) : + Kernel (EuclideanSpace ℝ ι) (EuclideanSpace ℝ ο) := + (gaussianChannel H R).map (fun y ↦ c + y) + +instance (H : Matrix ο ι ℝ) (c : EuclideanSpace ℝ ο) (R : Matrix ο ο ℝ) : + IsMarkovKernel (affineGaussianKernel H c R) := by + unfold affineGaussianKernel + exact Kernel.IsMarkovKernel.map _ (by fun_prop) + +theorem affineGaussianKernel_comp (H : Matrix ο ι ℝ) + (c : EuclideanSpace ℝ ο) (R : Matrix ο ο ℝ) (hR : R.PosSemidef) + (m : EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosSemidef) : + affineGaussianKernel H c R ∘ₘ multivariateGaussian m N = + multivariateGaussian (c + H.toEuclideanLin m) (R + H * N * H.transpose) := by + rw [affineGaussianKernel, ← Measure.map_comp _ _ (by fun_prop), + gaussianChannel_comp_multivariateGaussian H R hR m N hN, + multivariateGaussian_map_const_add] + +theorem affineGaussianKernel_residual (H : Matrix ο ι ℝ) + (c : EuclideanSpace ℝ ο) (N : Matrix ι ι ℝ) (T : Matrix ο ο ℝ) + (hN : N.PosSemidef) (hR : (T - H * N * H.transpose).PosSemidef) + (m : EuclideanSpace ℝ ι) : + affineGaussianKernel H c (T - H * N * H.transpose) ∘ₘ multivariateGaussian m N = + multivariateGaussian (c + H.toEuclideanLin m) T := by + rw [affineGaussianKernel_comp H c _ hR m N hN, sub_add_cancel] + +theorem inv_scalar_matrix (t : ℝ) : + (t • (1 : Matrix ι ι ℝ))⁻¹ = t⁻¹ • (1 : Matrix ι ι ℝ) := by + by_cases ht : t = 0 + · simp [ht] + · apply Matrix.inv_eq_left_inv + simp [ht] + +theorem scalar_inverse_quadratic (t : ℝ) (x : EuclideanSpace ℝ ι) : + x ⬝ᵥ (t • (1 : Matrix ι ι ℝ))⁻¹ *ᵥ x = t⁻¹ * ‖x‖ ^ 2 := by + rw [inv_scalar_matrix] + simp only [smul_mulVec, one_mulVec, EuclideanSpace.real_norm_sq_eq, + dotProduct, Pi.smul_apply, smul_eq_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro i _ + ring + +theorem trace_inverse_scalar (t s : ℝ) : + trace ((t • (1 : Matrix ι ι ℝ))⁻¹ * (s • 1)) = + (Fintype.card ι : ℝ) * s / t := by + rw [inv_scalar_matrix] + simp only [Matrix.smul_mul, Matrix.mul_smul, one_mul, smul_smul, + trace_smul, trace_one, smul_eq_mul] + ring + +theorem log_det_scalar_matrix (t : ℝ) : + Real.log (t • (1 : Matrix ι ι ℝ)).det = (Fintype.card ι : ℝ) * Real.log t := by + rw [det_smul, det_one, mul_one, Real.log_pow] + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/QAMInformation.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/QAMInformation.lean new file mode 100644 index 0000000..de593a5 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/QAMInformation.lean @@ -0,0 +1,78 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.QAMScheme + +open MeasureTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +noncomputable section + +def noiseBad {K n : ℕ} (δ : ℝ) : Set (Environment K n) := + {hz | ∃ i s, δ / 2 ≤ ‖effectiveNoise i hz s‖} + +theorem exists_qam_spacing (μ : Measure ℂ) [IsProbabilityMeasure μ] (K n : ℕ) + {ε : ℝ} (hε : 0 < ε) : + ∃ δ : ℝ, 0 < δ ∧ (environmentLaw μ K n).real (noiseBad δ) < ε := by + obtain ⟨b, hb, he⟩ := exists_noise_bound (environmentLaw μ K n) + (fun hz (p : Fin K × Box (Fin K) n) => effectiveNoise p.1 hz p.2) + (fun p => measurable_effectiveNoise p.1 p.2) hε + refine ⟨2 * b, by positivity, ?_⟩ + simpa only [noiseBad, mul_div_cancel_left₀ _ (by norm_num : (2 : ℝ) ≠ 0), + Prod.exists] using he + +theorem qam_error_le_noise (μ : Measure ℂ) [IsProbabilityMeasure μ] {K n q : ℕ} + (hq : 0 < q) (δ : ℝ) (hδ : 0 < δ) (i : Fin K) (a : StreamAlphabet K n q) : + 1 - (qamChannel μ hq δ i).transition a a ≤ + (environmentLaw μ K n).real (noiseBad δ) := by + classical + rw [qamChannel, observedChannel_transition] + have hm : MeasurableSet {hz : Environment K n | qamObserve hq δ i a hz = a} := + (measurable_qamObserve hq δ i a) (measurableSet_singleton a) + rw [← probReal_univ (μ := environmentLaw μ K n), ← measureReal_compl hm] + refine measureReal_mono ?_ (measure_ne_top _ _) + intro hz hhz + by_contra hn + apply hhz + funext s + apply quantizeComplex_correct hq hδ + exact lt_of_not_ge fun hs => hn ⟨i, s, hs⟩ + +theorem log_card_streamAlphabet {K n q : ℕ} (hq : 0 < q) : + Real.log (Fintype.card (StreamAlphabet K n q)) = + 2 * Fintype.card (Box (Fin K) n) * Real.log q := by + have hq0 : (q : ℝ) ≠ 0 := by exact_mod_cast hq.ne' + simp only [StreamAlphabet, QAM, Fintype.card_fun, Fintype.card_prod, + Fintype.card_fin, Nat.cast_pow, Nat.cast_mul, Real.log_pow, Real.log_mul hq0 hq0] + ring + +theorem qam_information_lower (μ : Measure ℂ) [IsProbabilityMeasure μ] {K n q : ℕ} + (hq : 0 < q) (δ : ℝ) (hδ : 0 < δ) {ε : ℝ} + (hε : (environmentLaw μ K n).real (noiseBad δ) ≤ ε) (i : Fin K) : + ((1 - ε) * (2 * Fintype.card (Box (Fin K) n) * Real.log q) - Real.log 2) / + Real.log 2 ≤ (qamChannel μ (n := n) hq δ i).informationCapacityBits := by + letI : NeZero q := ⟨hq.ne'⟩ + have hf := finite_fano_lower (qamChannel μ (n := n) hq δ i) + (fun a => (qam_error_le_noise μ hq δ hδ i a).trans hε) + rw [log_card_streamAlphabet hq] at hf + exact (div_le_div_of_nonneg_right hf (Real.log_nonneg (by norm_num))).trans + ((qamChannel μ hq δ i).mutualInformationBits_le_informationCapacityBits + (FiniteDistribution.uniform _)) + +theorem qamPowerFactor_pos {K n : ℕ} (hK : 0 < K) (hn : 0 < n) (M δ : ℝ) + (hδ : 0 < δ) : 0 < qamPowerFactor K n M δ := by + have hc : 0 < Fintype.card (Box (Fin K) n) := by + rw [card_box] + positivity + have hb := beamBound_pos (U := Fin K) (n := n) M + unfold qamPowerFactor + positivity + +end + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/QAMScheme.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/QAMScheme.lean new file mode 100644 index 0000000..9989cb6 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/QAMScheme.lean @@ -0,0 +1,156 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.AlignmentChannel +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.BlockScheme +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.FiniteObservation +import CapacityAtlasForMathlib.InformationTheory.GaussianInterference.NoiseTail + +open MeasureTheory +open scoped BigOperators + +namespace CapacityAtlas.Gaussian.Interference + +noncomputable section + +abbrev StreamAlphabet (K n q : ℕ) := Box (Fin K) n → QAM q + +abbrev Environment (K n : ℕ) := + StateBlock K (extensionLength K n) × Noise K (extensionLength K n) + +def environmentLaw (μ : Measure ℂ) (K n : ℕ) : Measure (Environment K n) := + (stateLaw μ K (extensionLength K n)).prod (blockNoise K (extensionLength K n)) + +instance environmentLaw_probability (μ : Measure ℂ) [IsProbabilityMeasure μ] (K n : ℕ) : + IsProbabilityMeasure (environmentLaw μ K n) := by + unfold environmentLaw + infer_instance + +def effectiveNoise {K n : ℕ} (i : Fin K) (hz : Environment K n) : Box (Fin K) n → ℂ := + alignedDecode hz.1 i (fun t => complexNoise (hz.2 i t)) + +theorem measurable_effectiveNoise {K n : ℕ} (i : Fin K) (a : Box (Fin K) n) : + Measurable fun hz : Environment K n => effectiveNoise i hz a := by + unfold effectiveNoise + have hn : Measurable fun z : Noise K (extensionLength K n) => + fun t => complexNoise (z i t) := by + unfold complexNoise + fun_prop + have hc := (measurable_alignedDecode i a).comp + (measurable_fst.prodMk (hn.comp measurable_snd)) + exact hc + +def qamStreams {K n q : ℕ} (δ : ℝ) (a : StreamAlphabet K n q) : Box (Fin K) n → ℂ := + fun s => (δ : ℂ) * qamValue (a s) + +def qamObserve {K n q : ℕ} (hq : 0 < q) (δ : ℝ) (i : Fin K) + (a : StreamAlphabet K n q) (hz : Environment K n) : StreamAlphabet K n q := + fun s => quantizeComplex q hq δ (qamStreams δ a s + effectiveNoise i hz s) + +theorem measurable_qamObserve {K n q : ℕ} (hq : 0 < q) (δ : ℝ) (i : Fin K) + (a : StreamAlphabet K n q) : Measurable (qamObserve hq δ i a) := by + apply measurable_pi_lambda + intro s + exact (measurable_quantizeComplex q hq δ).comp + (measurable_const.add (measurable_effectiveNoise i s)) + +def qamChannel (μ : Measure ℂ) [IsProbabilityMeasure μ] {K n q : ℕ} + (hq : 0 < q) (δ : ℝ) (i : Fin K) : FiniteChannel (StreamAlphabet K n q) + (StreamAlphabet K n q) := + observedChannel (environmentLaw μ K n) (qamObserve hq δ i) + (measurable_qamObserve hq δ i) + +def qamDecode {K n q : ℕ} (hq : 0 < q) (δ : ℝ) (i : Fin K) + (hy : StateBlock K (extensionLength K n) × (Fin (extensionLength K n) → ℂ)) : + StreamAlphabet K n q := fun s => quantizeComplex q hq δ (alignedDecode hy.1 i hy.2 s) + +theorem measurable_qamDecode {K n q : ℕ} (hq : 0 < q) (δ : ℝ) (i : Fin K) : + Measurable (qamDecode (n := n) hq δ i) := by + apply measurable_pi_lambda + intro s + exact (measurable_quantizeComplex q hq δ).comp (measurable_alignedDecode i s) + +def qamPowerFactor (K n : ℕ) (M δ : ℝ) : ℝ := + K * (2 * Fintype.card (Box (Fin K) n) * beamBound (Fin K) n M * δ) ^ 2 + +theorem ae_state_norm_le (μ : Measure ℂ) [IsProbabilityMeasure μ] {K L : ℕ} {M : ℝ} + (hM : ∀ᵐ h ∂μ, ‖h‖ ≤ M) : + ∀ᵐ H ∂stateLaw μ K L, ∀ t i j, ‖H t i j‖ ≤ M := by + unfold stateLaw + have hrow : ∀ᵐ h ∂Measure.pi (fun _ : Fin K ↦ μ), ∀ j, ‖h j‖ ≤ M := by + rw [ae_all_iff] + intro j + exact (Measure.quasiMeasurePreserving_eval (fun _ : Fin K ↦ μ) j).ae hM + have hmatrix : ∀ᵐ H ∂Measure.pi (fun _ : Fin K ↦ Measure.pi (fun _ : Fin K ↦ μ)), + ∀ i j, ‖H i j‖ ≤ M := by + rw [ae_all_iff] + intro i + exact (Measure.quasiMeasurePreserving_eval + (fun _ : Fin K ↦ Measure.pi (fun _ : Fin K ↦ μ)) i).ae hrow + rw [ae_all_iff] + intro t + exact (Measure.quasiMeasurePreserving_eval + (fun _ : Fin L ↦ Measure.pi (fun _ : Fin K ↦ Measure.pi (fun _ : Fin K ↦ μ))) t).ae hmatrix + +theorem qam_power_le {K n q : ℕ} (δ : ℝ) (hδ : 0 < δ) (M : ℝ) + (a : Fin K → StreamAlphabet K n q) (H : StateBlock K (extensionLength K n)) + (hH : ∀ t i j, ‖H t i j‖ ≤ M) : + (∑ t, ∑ i, ‖alignedTransmit H (qamStreams δ (a i)) t‖ ^ 2) ≤ + (extensionLength K n : ℝ) * (qamPowerFactor K n M δ * (q : ℝ) ^ 2) := by + have hb (i : Fin K) (t : Fin (extensionLength K n)) : + ‖alignedTransmit H (qamStreams δ (a i)) t‖ ≤ + Fintype.card (Box (Fin K) n) * beamBound (Fin K) n M * (δ * (2 * q)) := by + apply norm_transmitted_le + · intro r p + exact hH _ _ _ + · intro s + dsimp [qamStreams] + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_pos hδ] + exact mul_le_mul_of_nonneg_left (qamValue_norm_le _) hδ.le + calc + _ ≤ ∑ _ : Fin (extensionLength K n), ∑ _ : Fin K, + (Fintype.card (Box (Fin K) n) * beamBound (Fin K) n M * (δ * (2 * q))) ^ 2 := by + gcongr with t i + exact hb i t + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, + qamPowerFactor] + ring + +def qamScheme (μ : Measure ℂ) [IsProbabilityMeasure μ] [NullSingletonClass μ] + {K n q : ℕ} (hq : 0 < q) (δ : ℝ) (hδ : 0 < δ) (M : ℝ) + (hM : ∀ᵐ h ∂μ, ‖h‖ ≤ M) : + BlockScheme μ K (extensionLength K n) (qamPowerFactor K n M δ * (q : ℝ) ^ 2) + (StreamAlphabet K n q) where + encode _ a H := alignedTransmit H (qamStreams δ a) + encode_measurable _ a t := measurable_alignedTransmit (qamStreams δ a) t + encode_causal _ a t H H' hh := alignedTransmit_causal H H' (qamStreams δ a) t (hh t le_rfl) + decode := qamDecode hq δ + decode_measurable := measurable_qamDecode hq δ + channel := qamChannel μ hq δ + row_law a i b := by + rw [qamChannel, observedChannel_transition, Measure.real, + ENNReal.ofReal_toReal (measure_ne_top _ _)] + apply measure_congr + filter_upwards [Measure.quasiMeasurePreserving_fst.ae + (ae_stateFading_nonsingular μ K n)] with hz hhz + apply propext + change qamDecode hq δ i (hz.1, _) = b ↔ qamObserve hq δ i (a i) hz = b + have hd := alignedDecode_signal_add_noise hz.1 i (hhz i) + (fun j => qamStreams δ (a j)) (fun t => complexNoise (hz.2 i t)) + have he : qamDecode hq δ i + (hz.1, fun t ↦ (∑ j, hz.1 t i j * alignedTransmit hz.1 (qamStreams δ (a j)) t) + + complexNoise (hz.2 i t)) = qamObserve hq δ i (a i) hz := by + funext s + exact congrArg (quantizeComplex q hq δ) (congrFun hd s) + rw [he] + power a := by + filter_upwards [ae_state_norm_le μ hM] with H hH + exact qam_power_le δ hδ M a H hH + +end + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Quantization.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Quantization.lean new file mode 100644 index 0000000..7c4479f --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Quantization.lean @@ -0,0 +1,78 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import Mathlib.MeasureTheory.Function.Floor +import Mathlib.Analysis.Complex.Basic +import Mathlib.MeasureTheory.Constructions.BorelSpace.Complex +import Mathlib.Tactic + +open MeasureTheory + +namespace CapacityAtlas.Gaussian.Interference + +noncomputable section + +abbrev QAM (q : ℕ) := Fin q × Fin q + +def qamValue {q : ℕ} (a : QAM q) : ℂ := (a.1.val : ℂ) + (a.2.val : ℂ) * Complex.I + +def quantizeReal (q : ℕ) (hq : 0 < q) (x : ℝ) : Fin q := + ⟨min ⌊x + 1 / 2⌋₊ (q - 1), lt_of_le_of_lt (Nat.min_le_right _ _) (by omega)⟩ + +@[fun_prop] +theorem measurable_quantizeReal (q : ℕ) (hq : 0 < q) : Measurable (quantizeReal q hq) := by + let f : ℕ → Fin q := fun k => ⟨min k (q - 1), + lt_of_le_of_lt (Nat.min_le_right _ _) (by omega)⟩ + exact (measurable_of_countable f).comp + (measurable_id.add_const (1 / 2 : ℝ)).nat_floor + +theorem quantizeReal_correct {q : ℕ} (hq : 0 < q) (a : Fin q) {z : ℝ} + (hz : |z| < 1 / 2) : quantizeReal q hq ((a.val : ℝ) + z) = a := by + apply Fin.ext + have hh := abs_lt.mp hz + have hf : ⌊(a.val : ℝ) + z + 1 / 2⌋₊ = a.val := by + apply Nat.floor_eq_on_Ico + constructor <;> linarith + simp only [quantizeReal, hf] + exact min_eq_left (by omega) + +def quantizeComplex (q : ℕ) (hq : 0 < q) (δ : ℝ) (z : ℂ) : QAM q := + (quantizeReal q hq (z.re / δ), quantizeReal q hq (z.im / δ)) + +@[fun_prop] +theorem measurable_quantizeComplex (q : ℕ) (hq : 0 < q) (δ : ℝ) : + Measurable (quantizeComplex q hq δ) := by + unfold quantizeComplex + apply Measurable.prodMk <;> + exact (measurable_quantizeReal q hq).comp (by fun_prop) + +theorem quantizeComplex_correct {q : ℕ} (hq : 0 < q) {δ : ℝ} (hδ : 0 < δ) + (a : QAM q) {z : ℂ} (hz : ‖z‖ < δ / 2) : + quantizeComplex q hq δ ((δ : ℂ) * qamValue a + z) = a := by + have hre : |z.re / δ| < 1 / 2 := by + rw [abs_div, abs_of_pos hδ, div_lt_iff₀ hδ] + linarith [Complex.abs_re_le_norm z] + have him : |z.im / δ| < 1 / 2 := by + rw [abs_div, abs_of_pos hδ, div_lt_iff₀ hδ] + linarith [Complex.abs_im_le_norm z] + have hr : (((δ : ℂ) * qamValue a + z).re / δ) = (a.1.val : ℝ) + z.re / δ := by + simp [qamValue, add_div, hδ.ne'] + have hi : (((δ : ℂ) * qamValue a + z).im / δ) = (a.2.val : ℝ) + z.im / δ := by + simp [qamValue, add_div, hδ.ne'] + apply Prod.ext + · simpa only [quantizeComplex, hr] using quantizeReal_correct hq a.1 hre + · simpa only [quantizeComplex, hi] using quantizeReal_correct hq a.2 him + +theorem qamValue_norm_le {q : ℕ} (a : QAM q) : ‖qamValue a‖ ≤ 2 * (q : ℝ) := by + have ha : (a.1.val : ℝ) ≤ q := by exact_mod_cast a.1.isLt.le + have hb : (a.2.val : ℝ) ≤ q := by exact_mod_cast a.2.isLt.le + have h := norm_add_le (a.1.val : ℂ) ((a.2.val : ℂ) * Complex.I) + simp only [norm_mul, Complex.norm_natCast, Complex.norm_I, mul_one] at h + exact h.trans (by linarith) + +end + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Realification.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Realification.lean new file mode 100644 index 0000000..f7b74f2 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/Realification.lean @@ -0,0 +1,117 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.Probability.GaussianBlocks +import Mathlib.RingTheory.Complex + +open MeasureTheory ProbabilityTheory Matrix +open scoped BigOperators Matrix + +namespace CapacityAtlas.Gaussian.Interference + +def complexMatrix (z : ℂ) : Matrix (Fin 2) (Fin 2) ℝ := + !![z.re, -z.im; z.im, z.re] + +theorem complexMatrix_apply (z x : ℂ) : + (complexMatrix z).toEuclideanLin (Complex.orthonormalBasisOneI.repr x) = + Complex.orthonormalBasisOneI.repr (z * x) := by + ext i + fin_cases i <;> simp [complexMatrix, Matrix.toLpLin_apply, + Complex.mul_re, Complex.mul_im] <;> ring + +theorem complexMatrix_mul_transpose (z : ℂ) : + complexMatrix z * (complexMatrix z).transpose = ‖z‖ ^ 2 • 1 := by + ext i j + fin_cases i <;> fin_cases j <;> + simp [complexMatrix, Matrix.mul_apply, Fin.sum_univ_two, Complex.sq_norm, + Complex.normSq_apply] <;> ring + +variable {n : ℕ} + +def complexBlockMatrix (z : Fin n → ℂ) : + Matrix (Fin 2 × Fin n) (Fin 2 × Fin n) ℝ := + blockDiagonal (fun t ↦ complexMatrix (z t)) + +noncomputable def realBlock (x : Fin n → ℂ) : EuclideanSpace ℝ (Fin 2 × Fin n) := + flattenGaussianBlock (fun t ↦ Complex.orthonormalBasisOneI.repr (x t)) + +noncomputable def complexBlock (x : EuclideanSpace ℝ (Fin 2 × Fin n)) : Fin n → ℂ := + fun t ↦ Complex.orthonormalBasisOneI.repr.symm (unflattenGaussianBlock x t) + +@[simp] theorem complexBlock_realBlock (x : Fin n → ℂ) : complexBlock (realBlock x) = x := by + ext t + unfold complexBlock realBlock + simp only [unflatten_flattenGaussianBlock, LinearIsometryEquiv.symm_apply_apply] + +@[simp] theorem realBlock_complexBlock (x : EuclideanSpace ℝ (Fin 2 × Fin n)) : + realBlock (complexBlock x) = x := by + unfold complexBlock realBlock + simp only [LinearIsometryEquiv.apply_symm_apply, flatten_unflattenGaussianBlock] + +@[fun_prop] theorem measurable_realBlock : Measurable (@realBlock n) := by + unfold realBlock + exact measurable_flattenGaussianBlock.comp + (measurable_pi_lambda _ fun t ↦ + Complex.orthonormalBasisOneI.repr.continuous.measurable.comp (measurable_pi_apply t)) + +@[fun_prop] theorem measurable_complexBlock : Measurable (@complexBlock n) := by + unfold complexBlock + apply measurable_pi_lambda + intro t + exact Complex.orthonormalBasisOneI.repr.symm.continuous.measurable.comp + ((measurable_pi_apply t).comp measurable_unflattenGaussianBlock) + +theorem realBlock_add (x y : Fin n → ℂ) : realBlock (x + y) = realBlock x + realBlock y := by + ext ⟨i, t⟩ + simp [realBlock, flattenGaussianBlock] + +theorem complexBlockMatrix_apply (z x : Fin n → ℂ) : + (complexBlockMatrix z).toEuclideanLin (realBlock x) = + realBlock (fun t ↦ z t * x t) := by + ext ⟨i, t⟩ + change ((blockDiagonal (fun t ↦ complexMatrix (z t))) *ᵥ + fun p ↦ Complex.orthonormalBasisOneI.repr (x p.2) p.1) (i, t) = _ + rw [blockDiagonal_mulVec_apply] + exact congrArg (fun y : EuclideanSpace ℝ (Fin 2) ↦ y i) (complexMatrix_apply (z t) (x t)) + +theorem norm_realBlock_sq (x : Fin n → ℂ) : ‖realBlock x‖ ^ 2 = ∑ t, ‖x t‖ ^ 2 := by + simp only [realBlock, EuclideanSpace.real_norm_sq_eq, flattenGaussianBlock, + Fintype.sum_prod_type] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro t _ + rw [← EuclideanSpace.real_norm_sq_eq, LinearIsometryEquiv.norm_map] + +theorem complexBlockMatrix_mul_transpose (z : Fin n → ℂ) : + complexBlockMatrix z * (complexBlockMatrix z).transpose = + blockDiagonal (fun t ↦ ‖z t‖ ^ 2 • (1 : Matrix (Fin 2) (Fin 2) ℝ)) := by + simp only [complexBlockMatrix, blockDiagonal_transpose, ← blockDiagonal_mul, + complexMatrix_mul_transpose] + +theorem complexBlockMatrix_scalar_covariance (z : Fin n → ℂ) (e : ℝ) : + complexBlockMatrix z * (e • 1) * (complexBlockMatrix z).transpose = + blockDiagonal (fun t ↦ (e * ‖z t‖ ^ 2) • (1 : Matrix (Fin 2) (Fin 2) ℝ)) := by + rw [Matrix.mul_smul, mul_one, Matrix.smul_mul, complexBlockMatrix_mul_transpose, + ← blockDiagonal_smul] + congr 1 + funext t + exact smul_smul e (‖z t‖ ^ 2) (1 : Matrix (Fin 2) (Fin 2) ℝ) + +theorem complexBlockMatrix_residual_posSemidef (z : Fin n → ℂ) (e v : ℝ) + (h : ∀ t, e * ‖z t‖ ^ 2 ≤ v) : + (v • 1 - complexBlockMatrix z * (e • 1) * (complexBlockMatrix z).transpose).PosSemidef := by + rw [complexBlockMatrix_scalar_covariance] + have hv : v • (1 : Matrix (Fin 2 × Fin n) (Fin 2 × Fin n) ℝ) = + blockDiagonal (fun _ : Fin n ↦ v • (1 : Matrix (Fin 2) (Fin 2) ℝ)) := by + change v • 1 = blockDiagonal (v • (1 : Fin n → Matrix (Fin 2) (Fin 2) ℝ)) + rw [blockDiagonal_smul, blockDiagonal_one] + rw [hv, ← blockDiagonal_sub] + apply posSemidef_blockDiagonal + intro t + simp only [Pi.sub_apply, ← sub_smul] + exact PosSemidef.one.smul (sub_nonneg.mpr (h t)) + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/StateInformation.lean b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/StateInformation.lean new file mode 100644 index 0000000..5302ee7 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/InformationTheory/GaussianInterference/StateInformation.lean @@ -0,0 +1,134 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import CapacityAtlasForMathlib.InformationTheory.GaussianMixtureEntropyBounds + +open MeasureTheory ProbabilityTheory InformationTheory Matrix +open scoped ENNReal + +namespace CapacityAtlas.Gaussian.Interference + +open MeasureInformation + +variable {A B Y Z ι : Type*} + [Fintype A] [Fintype B] [Nonempty A] [Nonempty B] + [MeasurableSpace A] [MeasurableSpace B] + [MeasurableSingletonClass A] [MeasurableSingletonClass B] + [MeasurableSpace Y] [MeasurableSpace Z] [Fintype ι] [DecidableEq ι] + +/-- Two independent messages observed through a common Gaussian mixture, with a genie +giving the first message to the second decoder. -/ +theorem twoUser_gaussian_fano + (μ : Measure A) [IsProbabilityMeasure μ] (ν : Measure B) [IsProbabilityMeasure ν] + (m : A → B → EuclideanSpace ℝ ι) (N : Matrix ι ι ℝ) (hN : N.PosDef) + (η₁ : Kernel (EuclideanSpace ℝ ι) Y) [IsMarkovKernel η₁] + (η₂ : A → Kernel (EuclideanSpace ℝ ι) Z) [∀ a, IsMarkovKernel (η₂ a)] + (d₁ : Y → A) (hd₁ : Measurable d₁) + (d₂ : A → Z → B) (hd₂ : ∀ a, Measurable (d₂ a)) + (hμ : ∀ a, μ {a} = (Fintype.card A : ℝ≥0∞)⁻¹) + (hν : ∀ b, ν {b} = (Fintype.card B : ℝ≥0∞)⁻¹) : + Real.log (Fintype.card A) + Real.log (Fintype.card B) ≤ + entropyWith (gaussianCodebookKernel (fun p : A × B ↦ m p.1 p.2) N ∘ₘ μ.prod ν) + volume - entropyWith (multivariateGaussian 0 N) volume + 2 * Real.log 2 + + (∫ a, ∫ b, (η₁ ∘ₘ multivariateGaussian (m a b) N).real + {y | d₁ y ≠ a} ∂ν ∂μ) * Real.log (Fintype.card A) + + (∫ a, ∫ b, (η₂ a ∘ₘ multivariateGaussian (m a b) N).real + {z | d₂ a z ≠ b} ∂ν ∂μ) * Real.log (Fintype.card B) := by + let κ₁ := gaussianMarginalCodebookKernel ν m N + have hf₁ := fano_uniform_joint_log (μ ⊗ₘ (η₁ ∘ₖ κ₁)) hd₁ + (fun a ↦ by simpa only [Measure.fst_compProd] using hμ a) + have hi₁ : (mutualInfo (μ ⊗ₘ (η₁ ∘ₖ κ₁))).toReal ≤ + (mutualInfo (μ ⊗ₘ κ₁)).toReal := + ENNReal.toReal_mono + (mutualInfo_ne_top_of_uniform (μ ⊗ₘ κ₁) + (fun a ↦ by simpa only [Measure.fst_compProd] using hμ a)) + (mutualInfo_kernel_comp_le μ κ₁ η₁) + rw [decodingError_postprocess_gaussianMarginalCodebookKernel μ ν m N η₁ d₁ hd₁] at hf₁ + rw [mutualInfo_gaussianMarginalCodebookKernel μ ν m N hN] at hi₁ + have hf₂ (a : A) : + Real.log (Fintype.card B) ≤ + entropyWith (gaussianCodebookKernel (m a) N ∘ₘ ν) volume - + entropyWith (multivariateGaussian 0 N) volume + Real.log 2 + + (∫ b, (η₂ a ∘ₘ multivariateGaussian (m a b) N).real + {z | d₂ a z ≠ b} ∂ν) * Real.log (Fintype.card B) := by + let κ₂ := gaussianCodebookKernel (m a) N + have hf := fano_uniform_joint_log (ν ⊗ₘ (η₂ a ∘ₖ κ₂)) (hd₂ a) + (fun b ↦ by simpa only [Measure.fst_compProd] using hν b) + have hi : (mutualInfo (ν ⊗ₘ (η₂ a ∘ₖ κ₂))).toReal ≤ + (mutualInfo (ν ⊗ₘ κ₂)).toReal := + ENNReal.toReal_mono + (mutualInfo_ne_top_of_uniform (ν ⊗ₘ κ₂) + (fun b ↦ by simpa only [Measure.fst_compProd] using hν b)) + (mutualInfo_kernel_comp_le ν κ₂ (η₂ a)) + rw [mutualInfo_gaussianMixture_eq_entropy_sub ν κ₂ (m a) N hN (fun _ ↦ rfl)] at hi + have he : decodingError (ν ⊗ₘ (η₂ a ∘ₖ κ₂)) (d₂ a) = + ∫ b, (η₂ a ∘ₘ multivariateGaussian (m a b) N).real + {z | d₂ a z ≠ b} ∂ν := by + have hs : MeasurableSet {p : B × Z | d₂ a p.2 ≠ p.1} := + (measurableSet_eq_fun ((hd₂ a).comp measurable_snd) measurable_fst).compl + unfold decodingError + rw [real_compProd_finite ν _ _ hs] + rfl + rw [he] at hf + linarith + have hsum := integral_mono (μ := μ) (integrable_const (Real.log (Fintype.card B))) + Integrable.of_finite hf₂ + simp only [integral_const, probReal_univ, one_smul, + integral_add Integrable.of_finite Integrable.of_finite, + integral_sub Integrable.of_finite Integrable.of_finite, integral_mul_const] at hsum + linarith + +/-- A fixed Gaussian reference turns the two-message converse into an energy bound. -/ +theorem twoUser_gaussian_fano_reference + (μ : Measure A) [IsProbabilityMeasure μ] (ν : Measure B) [IsProbabilityMeasure ν] + (m : A → B → EuclideanSpace ℝ ι) (N T : Matrix ι ι ℝ) + (hN : N.PosDef) (hT : T.PosDef) + (η₁ : Kernel (EuclideanSpace ℝ ι) Y) [IsMarkovKernel η₁] + (η₂ : A → Kernel (EuclideanSpace ℝ ι) Z) [∀ a, IsMarkovKernel (η₂ a)] + (d₁ : Y → A) (hd₁ : Measurable d₁) + (d₂ : A → Z → B) (hd₂ : ∀ a, Measurable (d₂ a)) + (hμ : ∀ a, μ {a} = (Fintype.card A : ℝ≥0∞)⁻¹) + (hν : ∀ b, ν {b} = (Fintype.card B : ℝ≥0∞)⁻¹) : + Real.log (Fintype.card A) + Real.log (Fintype.card B) ≤ + (Real.log T.det - Real.log N.det) / 2 + + (trace (T⁻¹ * N) + (∫ p : A × B, + m p.1 p.2 ⬝ᵥ T⁻¹ *ᵥ m p.1 p.2 ∂μ.prod ν) - Fintype.card ι) / 2 + + 2 * Real.log 2 + + (∫ a, ∫ b, (η₁ ∘ₘ multivariateGaussian (m a b) N).real + {y | d₁ y ≠ a} ∂ν ∂μ) * Real.log (Fintype.card A) + + (∫ a, ∫ b, (η₂ a ∘ₘ multivariateGaussian (m a b) N).real + {z | d₂ a z ≠ b} ∂ν ∂μ) * Real.log (Fintype.card B) := by + have hf := twoUser_gaussian_fano μ ν m N hN η₁ η₂ d₁ hd₁ d₂ hd₂ hμ hν + have he := entropyWith_gaussianCodebook_le_reference (μ.prod ν) + (fun p : A × B ↦ m p.1 p.2) N T hN hT + rw [entropyWith_multivariateGaussian 0 N hN] at hf + rw [entropyWith_multivariateGaussian 0 T hT] at he + linarith + +/-- Integrate a pointwise code bound over the channel state. No state entropy is needed. -/ +theorem integrate_fano_energy {S : Type*} [MeasurableSpace S] + (σ : Measure S) [IsProbabilityMeasure σ] + {L₁ L₂ C : ℝ} {energy error₁ error₂ : S → ℝ} + (henergy : Integrable energy σ) (herr₁ : Integrable error₁ σ) + (herr₂ : Integrable error₂ σ) + (hpointwise : ∀ᵐ s ∂σ, + L₁ + L₂ ≤ C + energy s + error₁ s * L₁ + error₂ s * L₂) : + L₁ + L₂ ≤ C + (∫ s, energy s ∂σ) + + (∫ s, error₁ s ∂σ) * L₁ + (∫ s, error₂ s ∂σ) * L₂ := by + have h := integral_mono_ae (integrable_const (L₁ + L₂)) + (((integrable_const C).add henergy).add (herr₁.mul_const L₁) |>.add + (herr₂.mul_const L₂)) hpointwise + change (∫ _ : S, L₁ + L₂ ∂σ) ≤ + ∫ s, C + energy s + error₁ s * L₁ + error₂ s * L₂ ∂σ at h + rw [integral_add (f := fun s ↦ C + energy s + error₁ s * L₁) + (g := fun s ↦ error₂ s * L₂) (((integrable_const C).add henergy).add + (herr₁.mul_const L₁)) (herr₂.mul_const L₂), + integral_add (f := fun s ↦ C + energy s) (g := fun s ↦ error₁ s * L₁) + ((integrable_const C).add henergy) (herr₁.mul_const L₁), + integral_add (f := fun _ ↦ C) (g := energy) (integrable_const C) henergy] at h + simpa only [integral_const, probReal_univ, one_smul, integral_mul_const] using h + +end CapacityAtlas.Gaussian.Interference diff --git a/lean/CapacityAtlasForMathlib/LinearAlgebra/MonomialEvaluation.lean b/lean/CapacityAtlasForMathlib/LinearAlgebra/MonomialEvaluation.lean new file mode 100644 index 0000000..2108233 --- /dev/null +++ b/lean/CapacityAtlasForMathlib/LinearAlgebra/MonomialEvaluation.lean @@ -0,0 +1,100 @@ +/- +Copyright 2026 The Capacity Atlas Authors +Licensed under the Apache License, Version 2.0 (the "License"). +See https://www.apache.org/licenses/LICENSE-2.0 +-/ + +import Mathlib.Algebra.MvPolynomial.Eval +import Mathlib.LinearAlgebra.Matrix.Determinant.Basic + +open scoped BigOperators + +namespace CapacityAtlas.MonomialEvaluation + +variable {C V R : Type*} [Fintype C] [Fintype V] [DecidableEq C] + [CommRing R] + +/-- The variables belonging to one row of a monomial evaluation matrix. -/ +noncomputable def rowExponent (r : C) (e : V → ℕ) : C × V →₀ ℕ := + Finsupp.equivFunOnFinite.symm (fun p ↦ if p.1 = r then e p.2 else 0) + +@[simp] theorem rowExponent_apply (r s : C) (e : V → ℕ) (v : V) : + rowExponent r e (s, v) = if s = r then e v else 0 := rfl + +/-- Distinct rows have separate indeterminates. -/ +noncomputable def matrix (e : C → V → ℕ) : Matrix C C (MvPolynomial (C × V) R) := + fun r c ↦ MvPolynomial.monomial (rowExponent r (e c)) 1 + +noncomputable def permutationExponent (e : C → V → ℕ) (p : Equiv.Perm C) : + C × V →₀ ℕ := + ∑ c, rowExponent (p c) (e c) + +theorem permutationExponent_apply (e : C → V → ℕ) (p : Equiv.Perm C) + (r : C) (v : V) : permutationExponent e p (r, v) = e (p.symm r) v := by + classical + simp only [permutationExponent, Finsupp.coe_finsetSum, Finset.sum_apply, rowExponent_apply] + rw [Finset.sum_eq_single (p.symm r)] + · simp + · intro c _ hc + have h : r ≠ p c := by + intro h + apply hc + exact p.injective (by simpa using h.symm) + simp [h] + · simp + +theorem permutationExponent_injective {e : C → V → ℕ} (he : Function.Injective e) : + Function.Injective (permutationExponent e) := by + intro p q hpq + have h : p.symm = q.symm := by + ext r + apply he + funext v + simpa only [permutationExponent_apply] using congrArg (fun d ↦ d (r, v)) hpq + exact inv_injective h + +theorem product_entry (e : C → V → ℕ) (p : Equiv.Perm C) : + (∏ c, matrix (R := R) e (p c) c) = + MvPolynomial.monomial (permutationExponent e p) 1 := by + classical + simpa only [matrix, permutationExponent] using + (MvPolynomial.monomial_sum_one (R := R) Finset.univ + (fun c ↦ rowExponent (p c) (e c))).symm + +/-- The identity permutation contributes a coefficient that no other permutation can cancel. -/ +theorem coefficient_det (e : C → V → ℕ) (he : Function.Injective e) : + MvPolynomial.coeff (permutationExponent e 1) (Matrix.det (matrix (R := R) e)) = 1 := by + classical + rw [Matrix.det_apply, MvPolynomial.coeff_sum] + simp_rw [product_entry, MvPolynomial.coeff_smul, MvPolynomial.coeff_monomial] + rw [Finset.sum_eq_single 1] + · simp + · intro p _ hp + have h : permutationExponent e p ≠ permutationExponent e 1 := + fun h ↦ hp (permutationExponent_injective he h) + simp [h] + · simp + +/-- A square matrix evaluating distinct monomials at independent rows has a nonzero +determinant polynomial. -/ +theorem determinant_ne_zero [Nontrivial R] (e : C → V → ℕ) + (he : Function.Injective e) : Matrix.det (matrix (R := R) e) ≠ 0 := by + intro h + have hc := coefficient_det (R := R) e he + rw [h, MvPolynomial.coeff_zero] at hc + exact zero_ne_one hc + +theorem eval_matrix (e : C → V → ℕ) (x : C × V → R) (r c : C) : + MvPolynomial.eval x (matrix (R := R) e r c) = ∏ v, x (r, v) ^ e c v := by + classical + simp only [matrix, MvPolynomial.eval_monomial, one_mul] + rw [Finsupp.prod_fintype] + · simp only [Fintype.prod_prod_type, rowExponent_apply] + rw [Finset.prod_eq_single r] + · simp + · intro s _ hs + simp [hs] + · simp + · simp + +end CapacityAtlas.MonomialEvaluation diff --git a/tests/test_data.py b/tests/test_data.py index 66e097f..2cd2047 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -212,6 +212,7 @@ def test_registered_statement_inventory_matches_expected_problems() -> None: "general-relay-channel", "general-two-receiver-broadcast-channel", "general-two-user-interference-channel", + "k-user-gaussian-interference-channel", "less-noisy-broadcast-channel", "modulo-additive-two-way-channel", "more-capable-broadcast-channel",