import InfoTheory.Problems.VariableLengthRdInfiniteDmax
import Mathlib.Analysis.SpecialFunctions.ImproperIntegrals
import Mathlib.InformationTheory.KullbackLeibler.DataProcessing
import Mathlib.MeasureTheory.Measure.Decomposition.RadonNikodym
/-!
# Certificate for `InfoTheory.Problems.VariableLengthRdInfiniteDmax`
The frozen statement asks whether, for an i.i.d. standard Cauchy(0, 1) source under quadratic
distortion `d(s, ŝ) = (s - ŝ)²`, variable-length lossy codes can asymptotically attain the
single-letter information rate-distortion function `R^{(I)}(D)` (in nats) for every `D > 0`.
## Certified (about exactly these objects)
* **Probability law normalization.** `cauchyPDF_pos`, `integral_cauchyPDF` (`∫ cauchyPDF = 1`),
`cauchyMeasure_isProbabilityMeasure`, and `cauchyMeasureN_isProbabilityMeasure`.
* **Infinite zero-rate distortion (`D_max = ∞`).** `cauchy_infinite_dmax`: for every constant
reconstruction `c : ℝ`, `∫⁻ s, ENNReal.ofReal ((s - c)²) ∂cauchyMeasure = ⊤`.
Moreover `cauchy_indep_infinite_distortion`: every independent coupling `cauchyMeasure.prod ν`
with any probability measure `ν` on `ℝ` has infinite expected squared error.
* **Uniform scalar quantizer achievability.** For every `D > 0`, the uniform scalar quantizer
with step `Δ = 2 √D` (`uniformQuantEnc`, `uniformQuantDec`) is measurable, achieves
`vlCodeDistortion 1 (uniformQuantEnc Δ) (uniformQuantDec Δ) ≤ ENNReal.ofReal D`, and has
finite discrete Shannon entropy `vlCodeEntropy 1 (uniformQuantEnc Δ) < ⊤`.
* **Finiteness of `R^{(I)}(D)`.** `cauchyInfoRD_le_quantizer` and `cauchyInfoRD_lt_top`: for
every `D > 0`, `cauchyInfoRD D ≤ vlCodeEntropy 1 (uniformQuantEnc (2 * Real.sqrt D)) < ⊤`
(via Mathlib's `InformationTheory.klDiv_map_le` and an explicit Radon–Nikodym density on
`ℝ × ℕ`), proving the `sInf` defining `cauchyInfoRD D` is finite and non-vacuous.
## Not certified
* Whether `H(W) = n R^{(I)}(D) + o(n)` is attainable as `n → ∞` (the open problem).
-/
open MeasureTheory
open scoped BigOperators ENNReal NNReal
namespace InfoTheory.Known.Certificates.VariableLengthRdInfiniteDmax
open InfoTheory.Problems.VariableLengthRdInfiniteDmax
/-! ### 1. Cauchy density and probability measure -/
theorem cauchyPDF_pos (s : ℝ) : 0 < cauchyPDF s := by
unfold cauchyPDF
have hpi : 0 < Real.pi := Real.pi_pos
have hden : 0 < 1 + s ^ 2 := by positivity
exact div_pos one_pos (mul_pos hpi hden)
lemma cauchyPDF_nonneg (s : ℝ) : 0 ≤ cauchyPDF s := (cauchyPDF_pos s).le
lemma cauchyPDF_eq_mul (s : ℝ) : cauchyPDF s = Real.pi⁻¹ * (1 + s ^ 2)⁻¹ := by
unfold cauchyPDF
rw [one_div, mul_inv]
lemma measurable_cauchyPDF : Measurable cauchyPDF := by
have h : cauchyPDF = fun s : ℝ => Real.pi⁻¹ * (1 + s ^ 2)⁻¹ := funext cauchyPDF_eq_mul
rw [h]
exact measurable_const.mul ((measurable_const.add (measurable_id.pow_const 2)).inv)
lemma integrable_cauchyPDF : Integrable cauchyPDF volume := by
have h : cauchyPDF = fun s : ℝ => Real.pi⁻¹ * (1 + s ^ 2)⁻¹ := funext cauchyPDF_eq_mul
rw [h]
exact integrable_inv_one_add_sq.const_mul Real.pi⁻¹
theorem integral_cauchyPDF : ∫ s : ℝ, cauchyPDF s = 1 := by
have h : cauchyPDF = fun s : ℝ => Real.pi⁻¹ * (1 + s ^ 2)⁻¹ := funext cauchyPDF_eq_mul
rw [h, integral_const_mul, integral_univ_inv_one_add_sq, inv_mul_cancel₀ Real.pi_pos.ne']
theorem cauchyMeasure_isProbabilityMeasure : IsProbabilityMeasure cauchyMeasure := by
refine ⟨?_⟩
unfold cauchyMeasure
rw [withDensity_apply _ MeasurableSet.univ, Measure.restrict_univ]
rw [← ofReal_integral_eq_lintegral_ofReal integrable_cauchyPDF
(ae_of_all _ cauchyPDF_nonneg), integral_cauchyPDF, ENNReal.ofReal_one]
local instance : IsProbabilityMeasure cauchyMeasure := cauchyMeasure_isProbabilityMeasure
theorem cauchyMeasureN_isProbabilityMeasure (n : ℕ) :
IsProbabilityMeasure (cauchyMeasureN n) := by
unfold cauchyMeasureN
infer_instance
local instance (n : ℕ) : IsProbabilityMeasure (cauchyMeasureN n) :=
cauchyMeasureN_isProbabilityMeasure n
/-! ### 2. Infinite zero-rate distortion (`D_max = ∞`) -/
/-- Every constant reconstruction `c : ℝ` incurs infinite expected squared error under
`Cauchy(0, 1)`, certifying `D_max = ∞`. -/
theorem cauchy_infinite_dmax (c : ℝ) :
∫⁻ s : ℝ, ENNReal.ofReal ((s - c) ^ 2) ∂cauchyMeasure = ⊤ := by
unfold cauchyMeasure
have hsq_m : Measurable (fun s : ℝ => ENNReal.ofReal ((s - c) ^ 2)) :=
((measurable_id.sub measurable_const).pow_const 2).ennreal_ofReal
rw [lintegral_withDensity_eq_lintegral_mul _ measurable_cauchyPDF.ennreal_ofReal hsq_m]
set M : ℝ := max (|c| + 1) 1 with hM
have hM1 : 1 ≤ M := le_max_right _ _
have hMc : |c| + 1 ≤ M := le_max_left _ _
set A : Set ℝ := Set.Ici (2 * M) with hA
have hA_meas : MeasurableSet A := measurableSet_Ici
set δ : ℝ := 1 / (8 * Real.pi) with hδ
have hδpos : 0 < δ := by
rw [hδ]; exact div_pos one_pos (mul_pos (by norm_num) Real.pi_pos)
have hlower : ∀ s ∈ A, ENNReal.ofReal δ ≤
ENNReal.ofReal (cauchyPDF s) * ENNReal.ofReal ((s - c) ^ 2) := by
intro s hs
rw [hA, Set.mem_Ici] at hs
have hs2 : 2 ≤ s := by linarith
have hs0 : 0 < s := by linarith
have hsc : s / 2 ≤ s - c := by
have hc : c ≤ |c| := le_abs_self c
linarith
have hsq1 : s ^ 2 / 4 ≤ (s - c) ^ 2 := by
nlinarith
have hsq2 : 1 + s ^ 2 ≤ 2 * s ^ 2 := by nlinarith
have hden : 0 < Real.pi * (1 + s ^ 2) := mul_pos Real.pi_pos (by positivity)
have hprod : δ ≤ cauchyPDF s * (s - c) ^ 2 := by
rw [hδ, cauchyPDF, one_div_mul_eq_div, div_le_div_iff₀ (by positivity) hden]
have hpi : 0 < Real.pi := Real.pi_pos
nlinarith
rw [← ENNReal.ofReal_mul (cauchyPDF_nonneg s)]
exact ENNReal.ofReal_le_ofReal hprod
have htop : ∫⁻ _ in A, ENNReal.ofReal δ = ⊤ := by
rw [setLIntegral_const, hA, Real.volume_Ici,
ENNReal.mul_top (ENNReal.ofReal_pos.mpr hδpos).ne']
refine top_unique ?_
calc ⊤ = ∫⁻ _ in A, ENNReal.ofReal δ := htop.symm
_ ≤ ∫⁻ s in A, ENNReal.ofReal (cauchyPDF s) * ENNReal.ofReal ((s - c) ^ 2) :=
setLIntegral_mono' hA_meas hlower
_ ≤ ∫⁻ s, ENNReal.ofReal (cauchyPDF s) * ENNReal.ofReal ((s - c) ^ 2) :=
setLIntegral_le_lintegral A _
/-- No independent coupling `cauchyMeasure.prod ν` (with `ν` a probability measure on `ℝ`)
achieves finite expected squared error. -/
theorem cauchy_indep_infinite_distortion (ν : Measure ℝ) [IsProbabilityMeasure ν] :
∫⁻ p : ℝ × ℝ, ENNReal.ofReal ((p.1 - p.2) ^ 2) ∂(cauchyMeasure.prod ν) = ⊤ := by
have hm : Measurable (fun p : ℝ × ℝ => ENNReal.ofReal ((p.1 - p.2) ^ 2)) :=
((measurable_fst.sub measurable_snd).pow_const 2).ennreal_ofReal
rw [lintegral_prod_symm _ hm.aemeasurable]
simp_rw [cauchy_infinite_dmax]
rw [lintegral_const, measure_univ, mul_one]
/-! ### 3. Uniform scalar quantizer: bijection `ℤ ↔ ℕ`, distortion, and finite entropy -/
/-- Standard zigzag bijection `ℤ → ℕ`: `0 ↦ 0, -1 ↦ 1, 1 ↦ 2, -2 ↦ 3, 2 ↦ 4, …`. -/
def zigZag (z : ℤ) : ℕ :=
if 0 ≤ z then 2 * z.toNat else 2 * (-z).toNat - 1
/-- Inverse of `zigZag`. -/
def unZigZag (k : ℕ) : ℤ :=
if k % 2 = 0 then (k / 2 : ℕ) else -((k / 2 + 1 : ℕ) : ℤ)
lemma unZigZag_zigZag (z : ℤ) : unZigZag (zigZag z) = z := by
unfold zigZag unZigZag
split_ifs <;> omega
lemma zigZag_unZigZag (k : ℕ) : zigZag (unZigZag k) = k := by
unfold zigZag unZigZag
split_ifs <;> omega
/-- Scalar uniform quantizer encoder with cell width `Δ > 0`. -/
noncomputable def scalarQuantEnc (Δ : ℝ) (s : ℝ) : ℕ :=
zigZag ⌊s / Δ⌋
/-- Scalar uniform quantizer decoder reconstructing cell centers. -/
noncomputable def scalarQuantDec (Δ : ℝ) (k : ℕ) : ℝ :=
((unZigZag k : ℝ) + 1 / 2) * Δ
/-- Blocklength-1 uniform quantizer encoder on `Fin 1 → ℝ`. -/
noncomputable def uniformQuantEnc (Δ : ℝ) (s : Fin 1 → ℝ) : ℕ :=
scalarQuantEnc Δ (s 0)
/-- Blocklength-1 uniform quantizer decoder `ℕ → Fin 1 → ℝ`. -/
noncomputable def uniformQuantDec (Δ : ℝ) (k : ℕ) : Fin 1 → ℝ :=
fun _ => scalarQuantDec Δ k
lemma scalarQuantEnc_preimage (Δ : ℝ) (hΔ : 0 < Δ) (k : ℕ) :
scalarQuantEnc Δ ⁻¹' {k} =
Set.Ico ((unZigZag k : ℝ) * Δ) (((unZigZag k : ℝ) + 1) * Δ) := by
ext s
simp only [Set.mem_preimage, Set.mem_singleton_iff, Set.mem_Ico, scalarQuantEnc]
constructor
· intro h
have hz : ⌊s / Δ⌋ = unZigZag k := by rw [← h, unZigZag_zigZag]
have h1 : (unZigZag k : ℝ) ≤ s / Δ := by rw [← hz]; exact Int.floor_le (s / Δ)
have h2 : s / Δ < (unZigZag k : ℝ) + 1 := by rw [← hz]; exact Int.lt_floor_add_one (s / Δ)
exact ⟨(le_div_iff₀ hΔ).mp h1, (div_lt_iff₀ hΔ).mp h2⟩
· rintro ⟨h1, h2⟩
have hz : ⌊s / Δ⌋ = unZigZag k :=
Int.floor_eq_iff.mpr ⟨(le_div_iff₀ hΔ).mpr h1, (div_lt_iff₀ hΔ).mpr h2⟩
rw [hz, zigZag_unZigZag]
lemma measurable_scalarQuantEnc {Δ : ℝ} (hΔ : 0 < Δ) : Measurable (scalarQuantEnc Δ) := by
refine measurable_to_countable' (fun k => ?_)
rw [scalarQuantEnc_preimage Δ hΔ k]
exact measurableSet_Ico
theorem uniformQuantEnc_measurable {Δ : ℝ} (hΔ : 0 < Δ) : Measurable (uniformQuantEnc Δ) :=
(measurable_scalarQuantEnc hΔ).comp (measurable_pi_apply 0)
lemma scalarQuant_sq_error_le {Δ : ℝ} (hΔ : 0 < Δ) (s : ℝ) :
(s - scalarQuantDec Δ (scalarQuantEnc Δ s)) ^ 2 ≤ Δ ^ 2 / 4 := by
unfold scalarQuantDec scalarQuantEnc
rw [unZigZag_zigZag]
have h1 : (⌊s / Δ⌋ : ℝ) ≤ s / Δ := Int.floor_le (s / Δ)
have h2 : s / Δ < (⌊s / Δ⌋ : ℝ) + 1 := Int.lt_floor_add_one (s / Δ)
have hlo : -(Δ / 2) ≤ s - ((⌊s / Δ⌋ : ℝ) + 1 / 2) * Δ := by
have : (⌊s / Δ⌋ : ℝ) * Δ ≤ s := (le_div_iff₀ hΔ).mp h1
linarith
have hhi : s - ((⌊s / Δ⌋ : ℝ) + 1 / 2) * Δ ≤ Δ / 2 := by
have : s < ((⌊s / Δ⌋ : ℝ) + 1) * Δ := (div_lt_iff₀ hΔ).mp h2
linarith
nlinarith
/-- For every `D > 0`, the uniform scalar quantizer of step `Δ = 2 √D` achieves average
per-letter quadratic distortion `≤ D`. -/
theorem uniformQuant_distortion_le {D : ℝ} (hD : 0 < D) :
vlCodeDistortion 1 (uniformQuantEnc (2 * Real.sqrt D)) (uniformQuantDec (2 * Real.sqrt D)) ≤
ENNReal.ofReal D := by
set Δ := 2 * Real.sqrt D with hΔdef
have hΔ : 0 < Δ := mul_pos two_pos (Real.sqrt_pos.mpr hD)
have hΔsq : Δ ^ 2 / 4 = D := by
rw [hΔdef]
have hsq : (Real.sqrt D) ^ 2 = D := Real.sq_sqrt hD.le
nlinarith
unfold vlCodeDistortion
simp only [Nat.cast_one, inv_one, one_mul, Fin.sum_univ_one]
calc ∫⁻ s : Fin 1 → ℝ,
ENNReal.ofReal ((s 0 - uniformQuantDec Δ (uniformQuantEnc Δ s) 0) ^ 2) ∂(cauchyMeasureN 1)
≤ ∫⁻ _ : Fin 1 → ℝ, ENNReal.ofReal D ∂(cauchyMeasureN 1) := by
refine lintegral_mono (fun s => ENNReal.ofReal_le_ofReal ?_)
simpa only [uniformQuantDec, uniformQuantEnc, hΔsq] using scalarQuant_sq_error_le hΔ (s 0)
_ = ENNReal.ofReal D := by rw [lintegral_const, measure_univ, mul_one]
/-- Cell probability under `cauchyMeasureN 1` equals the 1D Cauchy cell probability. -/
lemma cauchyMeasureN_one_uniformQuant (Δ : ℝ) (k : ℕ) :
cauchyMeasureN 1 (uniformQuantEnc Δ ⁻¹' {k}) =
cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k}) := by
have hpre : uniformQuantEnc Δ ⁻¹' {k} =
Set.univ.pi (fun _ : Fin 1 => scalarQuantEnc Δ ⁻¹' {k}) := by
ext s
simp [uniformQuantEnc, Set.mem_pi]
rw [hpre, cauchyMeasureN, Measure.pi_pi]
simp
/-- Elementary entropy tail bound: for `p ≥ 0`, `(if p ≤ 0 then 0 else -p ln p) ≤ 4 p^{3/4}`. -/
lemma negPLogP_le_four_rpow {p : ℝ} (hp : 0 ≤ p) :
(if p ≤ 0 then 0 else -p * Real.log p) ≤ 4 * p ^ ((3 : ℝ) / 4) := by
by_cases h0 : p ≤ 0
· simp only [h0, ↓reduceIte]
positivity
· simp only [h0, ↓reduceIte]
have hp_pos : 0 < p := lt_of_not_ge h0
have hu_pos : 0 < p ^ (-(1 : ℝ) / 4) := Real.rpow_pos_of_pos hp_pos _
have hlog_u : Real.log (p ^ (-(1 : ℝ) / 4)) ≤ p ^ (-(1 : ℝ) / 4) - 1 :=
Real.log_le_sub_one_of_pos hu_pos
rw [Real.log_rpow hp_pos] at hlog_u
have hneglog : -Real.log p ≤ 4 * p ^ (-(1 : ℝ) / 4) := by linarith
have hmul : -p * Real.log p ≤ p * (4 * p ^ (-(1 : ℝ) / 4)) := by
have := mul_le_mul_of_nonneg_left hneglog hp_pos.le
linarith
have hrpow : p * p ^ (-(1 : ℝ) / 4) = p ^ ((3 : ℝ) / 4) := by
conv_lhs => arg 1; rw [← Real.rpow_one p]
rw [← Real.rpow_add hp_pos]
norm_num
linarith
/-- Quadratic tail decay of Cauchy uniform-quantizer cell probabilities: for `k ≥ 4`,
`p_k ≤ 16 / (π Δ k²)`. -/
lemma scalarQuant_cell_prob_le {Δ : ℝ} (hΔ : 0 < Δ) {k : ℕ} (hk : 4 ≤ k) :
(cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal ≤
16 / (Real.pi * Δ * (k : ℝ) ^ 2) := by
rw [scalarQuantEnc_preimage Δ hΔ k]
set z : ℤ := unZigZag k with hz
set A : Set ℝ := Set.Ico ((z : ℝ) * Δ) (((z : ℝ) + 1) * Δ) with hA
have hk_pos : (0 : ℝ) < k := by exact_mod_cast (show 0 < k by omega)
have hs_sq : ∀ s ∈ A, ((k : ℝ) * Δ / 4) ^ 2 ≤ s ^ 2 := by
intro s hs
rw [hA, Set.mem_Ico] at hs
have hbound : (k : ℝ) / 4 ≤ |s| / Δ := by
unfold unZigZag at hz
by_cases heven : k % 2 = 0
· simp only [heven, ↓reduceIte] at hz
have hkz : (k : ℝ) / 4 ≤ (z : ℝ) := by
rw [hz, Int.cast_natCast]
have h2 : 2 * (k / 2) = k := by omega
have h2r : (2 : ℝ) * ((k / 2 : ℕ) : ℝ) = (k : ℝ) := by exact_mod_cast h2
linarith
have hs_nonneg : 0 ≤ s := by
have hz0 : (0 : ℝ) ≤ z := by linarith
nlinarith [hs.1]
rw [abs_of_nonneg hs_nonneg, le_div_iff₀ hΔ]
nlinarith [hs.1]
· simp only [heven, ↓reduceIte] at hz
have hkz : (k : ℝ) / 4 ≤ -(z : ℝ) - 1 := by
rw [hz, Int.cast_neg, Int.cast_natCast, Nat.cast_add, Nat.cast_one]
have h2 : 2 * (k / 2) + 1 = k := by omega
have h2r : (2 : ℝ) * ((k / 2 : ℕ) : ℝ) + 1 = (k : ℝ) := by exact_mod_cast h2
have hk4 : (4 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk
linarith
have hs_neg : s < 0 := by
have hz1 : (z : ℝ) + 1 ≤ -((k : ℝ) / 4) := by linarith
have : ((z : ℝ) + 1) * Δ < 0 := mul_neg_of_neg_of_pos (by linarith) hΔ
linarith [hs.2]
rw [abs_of_neg hs_neg, le_div_iff₀ hΔ]
nlinarith [hs.2]
have habs : (k : ℝ) * Δ / 4 ≤ |s| := by
have := (le_div_iff₀ hΔ).mp hbound
linarith
have h0 : 0 ≤ (k : ℝ) * Δ / 4 := by positivity
have hsq := mul_self_le_mul_self h0 habs
simpa only [sq, abs_mul_abs_self] using hsq
set B : ℝ := 16 / (Real.pi * Δ ^ 2 * (k : ℝ) ^ 2) with hB
have hB0 : 0 ≤ B := by positivity
have hpdf : ∀ s ∈ A, ENNReal.ofReal (cauchyPDF s) ≤ ENNReal.ofReal B := by
intro s hs
refine ENNReal.ofReal_le_ofReal ?_
have hsq := hs_sq s hs
have hden1 : ((k : ℝ) * Δ / 4) ^ 2 ≤ 1 + s ^ 2 := by linarith
have hden_pos : 0 < Real.pi * ((k : ℝ) * Δ / 4) ^ 2 := by positivity
unfold cauchyPDF
rw [hB]
have heq : 16 / (Real.pi * Δ ^ 2 * (k : ℝ) ^ 2) =
1 / (Real.pi * ((k : ℝ) * Δ / 4) ^ 2) := by
have h1 : Real.pi * ((k : ℝ) * Δ / 4) ^ 2 = Real.pi * Δ ^ 2 * (k : ℝ) ^ 2 / 16 := by ring
rw [h1, one_div_div]
rw [heq]
exact one_div_le_one_div_of_le hden_pos (mul_le_mul_of_nonneg_left hden1 Real.pi_pos.le)
have hmeas_le : cauchyMeasure A ≤ ENNReal.ofReal (B * Δ) := by
unfold cauchyMeasure
rw [withDensity_apply _ measurableSet_Ico]
calc ∫⁻ s in A, ENNReal.ofReal (cauchyPDF s)
≤ ∫⁻ _ in A, ENNReal.ofReal B := setLIntegral_mono' measurableSet_Ico hpdf
_ = ENNReal.ofReal B * volume A := setLIntegral_const A (ENNReal.ofReal B)
_ = ENNReal.ofReal B * ENNReal.ofReal Δ := by
rw [hA, Real.volume_Ico, show ((z : ℝ) + 1) * Δ - (z : ℝ) * Δ = Δ by ring]
_ = ENNReal.ofReal (B * Δ) := (ENNReal.ofReal_mul hB0).symm
have hBΔ : B * Δ = 16 / (Real.pi * Δ * (k : ℝ) ^ 2) := by
rw [hB, div_mul_eq_mul_div,
show Real.pi * Δ ^ 2 * (k : ℝ) ^ 2 = (Real.pi * Δ * (k : ℝ) ^ 2) * Δ by ring,
mul_div_mul_right _ _ hΔ.ne']
rw [← hBΔ]
exact ENNReal.toReal_le_of_le_ofReal (by positivity) hmeas_le
/-- Elementary telescoping proof that `∑_{n ≥ 0} ((n + 2) √(n + 2))⁻¹` is summable. -/
lemma summable_inv_mul_sqrt :
Summable (fun n : ℕ => (((n + 2 : ℕ) : ℝ) * Real.sqrt ((n + 2 : ℕ) : ℝ))⁻¹) := by
refine summable_of_sum_range_le (c := 2) (fun n => by positivity) (fun N => ?_)
have hterm : ∀ n : ℕ,
(((n + 2 : ℕ) : ℝ) * Real.sqrt ((n + 2 : ℕ) : ℝ))⁻¹ ≤
2 / Real.sqrt ((n : ℝ) + 1) - 2 / Real.sqrt ((n : ℝ) + 2) := by
intro n
set a := Real.sqrt ((n : ℝ) + 1) with ha
set b := Real.sqrt ((n : ℝ) + 2) with hb
have ha0 : 0 < a := Real.sqrt_pos.mpr (by positivity)
have hb0 : 0 < b := Real.sqrt_pos.mpr (by positivity)
have ha2 : a ^ 2 = (n : ℝ) + 1 := Real.sq_sqrt (by positivity)
have hb2 : b ^ 2 = (n : ℝ) + 2 := Real.sq_sqrt (by positivity)
have hab : a ≤ b := Real.sqrt_le_sqrt (by linarith)
have hcast : ((n + 2 : ℕ) : ℝ) = (n : ℝ) + 2 := by push_cast; ring
rw [hcast, ← hb, ← hb2]
have h1 : 2 / a - 2 / b = 2 * (b - a) / (a * b) := by
rw [div_sub_div _ _ ha0.ne' hb0.ne']
ring
rw [h1, inv_eq_one_div, div_le_div_iff₀ (by positivity) (by positivity)]
-- Need: `a * b ≤ 2 * (b - a) * (b ^ 2 * b)`
-- Since `(b - a) * (b + a) = b ^ 2 - a ^ 2 = 1`, multiply by `b + a > 0`:
-- Equivalent to `a * b * (b + a) ≤ 2 * (b ^ 2 * b)`, which holds since `a ≤ b`!
have hprod : (b - a) * (b + a) = 1 := by nlinarith
have hmul : a * b * (b + a) ≤ 2 * (b ^ 2 * b) := by nlinarith
have hkey : a * b * (b + a) ≤ 2 * (b - a) * (b ^ 2 * b) * (b + a) := by
calc a * b * (b + a) ≤ 2 * (b ^ 2 * b) := hmul
_ = 2 * ((b - a) * (b + a)) * (b ^ 2 * b) := by rw [hprod, mul_one]
_ = 2 * (b - a) * (b ^ 2 * b) * (b + a) := by ring
nlinarith
have htel : ∑ n ∈ Finset.range N,
(2 / Real.sqrt ((n : ℝ) + 1) - 2 / Real.sqrt ((n : ℝ) + 2)) =
2 / Real.sqrt (0 + 1) - 2 / Real.sqrt ((N : ℝ) + 1) := by
induction N with
| zero => simp
| succ N ih =>
rw [Finset.sum_range_succ, ih]
push_cast
rw [show (N : ℝ) + 1 + 1 = (N : ℝ) + 2 by ring]
ring
calc ∑ n ∈ Finset.range N, (((n + 2 : ℕ) : ℝ) * Real.sqrt ((n + 2 : ℕ) : ℝ))⁻¹
≤ ∑ n ∈ Finset.range N,
(2 / Real.sqrt ((n : ℝ) + 1) - 2 / Real.sqrt ((n : ℝ) + 2)) :=
Finset.sum_le_sum (fun n _ => hterm n)
_ = 2 / Real.sqrt (0 + 1) - 2 / Real.sqrt ((N : ℝ) + 1) := htel
_ ≤ 2 := by
have hpos : 0 ≤ 2 / Real.sqrt ((N : ℝ) + 1) := by positivity
simp only [zero_add, Real.sqrt_one, div_one]
linarith
/-- The scalar uniform quantizer entropy series is summable in `ℝ`. -/
lemma summable_scalarQuant_entropy {Δ : ℝ} (hΔ : 0 < Δ) :
Summable (fun k : ℕ =>
let p := (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal
if p ≤ 0 then 0 else -p * Real.log p) := by
set f : ℕ → ℝ := fun k =>
let p := (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal
if p ≤ 0 then 0 else -p * Real.log p
have hf_nonneg : ∀ k : ℕ, 0 ≤ f k := by
intro k
dsimp only [f]
split_ifs with h0
· exact le_rfl
· have hp_pos : 0 < (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal := lt_of_not_ge h0
have hp_le : (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal ≤ 1 := by
calc (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal
≤ (cauchyMeasure Set.univ).toReal :=
ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (Set.subset_univ _))
_ = 1 := by simp
have hlog : Real.log (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal ≤ 0 :=
Real.log_nonpos hp_pos.le hp_le
nlinarith
set C : ℝ := 16 / (Real.pi * Δ) with hC
have hC0 : 0 ≤ C := by positivity
set g : ℕ → ℝ := fun n =>
(4 * C ^ ((3 : ℝ) / 4)) * ((((n + 4 : ℕ) : ℝ) * Real.sqrt ((n + 4 : ℕ) : ℝ))⁻¹)
have hg_sum : Summable g := by
have h := (summable_nat_add_iff 2).mpr summable_inv_mul_sqrt
exact h.mul_left _
rw [← summable_nat_add_iff 4]
refine Summable.of_nonneg_of_le (fun n => hf_nonneg (n + 4)) (fun n => ?_) hg_sum
have hk4 : 4 ≤ n + 4 := Nat.le_add_left 4 n
have hk_pos : (0 : ℝ) < (n + 4 : ℕ) := by positivity
set p := (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {n + 4})).toReal
have hp0 : 0 ≤ p := ENNReal.toReal_nonneg
have hple : p ≤ C / ((n + 4 : ℕ) : ℝ) ^ 2 := by
have h := scalarQuant_cell_prob_le hΔ hk4
simpa only [hC, div_div] using h
calc f (n + 4) ≤ 4 * p ^ ((3 : ℝ) / 4) := negPLogP_le_four_rpow hp0
_ ≤ 4 * (C / ((n + 4 : ℕ) : ℝ) ^ 2) ^ ((3 : ℝ) / 4) := by
gcongr
_ = g n := by
dsimp only [g]
rw [Real.div_rpow hC0 (by positivity), ← Real.rpow_natCast ((n + 4 : ℕ) : ℝ) 2,
← Real.rpow_mul hk_pos.le]
simp only [Nat.cast_ofNat]
have hexp : ((n + 4 : ℕ) : ℝ) ^ ((2 : ℝ) * ((3 : ℝ) / 4)) =
((n + 4 : ℕ) : ℝ) * Real.sqrt ((n + 4 : ℕ) : ℝ) := by
rw [show (2 : ℝ) * ((3 : ℝ) / 4) = 1 + (1 : ℝ) / 2 by norm_num,
Real.rpow_add hk_pos, Real.rpow_one, Real.sqrt_eq_rpow]
rw [hexp, div_eq_mul_inv]
ring
/-- For every `Δ > 0`, the blocklength-1 uniform scalar quantizer has finite discrete Shannon
entropy (`vlCodeEntropy 1 (uniformQuantEnc Δ) < ⊤`). -/
theorem uniformQuant_entropy_lt_top {Δ : ℝ} (hΔ : 0 < Δ) :
vlCodeEntropy 1 (uniformQuantEnc Δ) < ⊤ := by
unfold vlCodeEntropy
simp_rw [cauchyMeasureN_one_uniformQuant Δ]
have hsum := summable_scalarQuant_entropy hΔ
have hnn : ∀ k : ℕ, 0 ≤
(let p := (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal
if p ≤ 0 then 0 else -p * Real.log p) := by
intro k
dsimp only
split_ifs with h0
· exact le_rfl
· have hp_pos : 0 < (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal := lt_of_not_ge h0
have hp_le : (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal ≤ 1 := by
calc (cauchyMeasure (scalarQuantEnc Δ ⁻¹' {k})).toReal
≤ (cauchyMeasure Set.univ).toReal :=
ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (Set.subset_univ _))
_ = 1 := by simp
have hlog := Real.log_nonpos hp_pos.le hp_le
nlinarith
rw [← ENNReal.ofReal_tsum_of_nonneg hnn hsum]
exact ENNReal.ofReal_lt_top
/-! ### 4. Finiteness of `cauchyInfoRD D` via `InformationTheory.klDiv` -/
lemma isProb_map {α β : Type*} [MeasurableSpace α] [MeasurableSpace β]
(μ : Measure α) [IsProbabilityMeasure μ] {f : α → β} (hf : Measurable f) :
IsProbabilityMeasure (μ.map f) :=
⟨by rw [Measure.map_apply hf MeasurableSet.univ, Set.preimage_univ, measure_univ]⟩
/-- Exact mutual information identity / upper bound for a discrete measurable encoder `enc : ℝ → ℕ`
applied to `cauchyMeasure`: the joint law `(S, enc(S))` satisfies
`klDiv μW νW ≤ vlCodeEntropy 1 (fun s => enc (s 0))`. -/
lemma klDiv_discrete_encoder_le {enc : ℝ → ℕ} (henc : Measurable enc)
(hsum : Summable (fun k : ℕ =>
let p := (cauchyMeasure (enc ⁻¹' {k})).toReal
if p ≤ 0 then 0 else -p * Real.log p)) :
InformationTheory.klDiv
(cauchyMeasure.map (fun s => (s, enc s)))
(cauchyMeasure.prod (cauchyMeasure.map enc)) ≤
∑' k : ℕ,
let p := (cauchyMeasure (enc ⁻¹' {k})).toReal
ENNReal.ofReal (if p ≤ 0 then 0 else -p * Real.log p) := by
classical
set μW : Measure (ℝ × ℕ) := cauchyMeasure.map (fun s => (s, enc s)) with hμW
set ρ : Measure ℕ := cauchyMeasure.map enc with hρ
set νW : Measure (ℝ × ℕ) := cauchyMeasure.prod ρ with hνW
have hpair : Measurable (fun s : ℝ => (s, enc s)) := measurable_id.prodMk henc
have : IsProbabilityMeasure μW := isProb_map cauchyMeasure hpair
have : IsProbabilityMeasure ρ := isProb_map cauchyMeasure henc
have : IsProbabilityMeasure νW := Measure.prod.instIsProbabilityMeasure cauchyMeasure ρ
set f : ℝ × ℕ → ℝ≥0∞ := fun p =>
if enc p.1 = p.2 then (cauchyMeasure (enc ⁻¹' {p.2}))⁻¹ else 0 with hfdef
have hf_meas : Measurable f := by
have hdiag : MeasurableSet { p : ℝ × ℕ | enc p.1 = p.2 } :=
measurableSet_eq_fun (henc.comp measurable_fst) measurable_snd
have hval : Measurable (fun p : ℝ × ℕ => (cauchyMeasure (enc ⁻¹' {p.2}))⁻¹) :=
(measurable_of_countable (fun k : ℕ => (cauchyMeasure (enc ⁻¹' {k}))⁻¹)).comp measurable_snd
exact Measurable.ite hdiag hval measurable_const
have hρ_sing : ∀ k : ℕ, ρ {k} = cauchyMeasure (enc ⁻¹' {k}) := fun k =>
Measure.map_apply henc (measurableSet_singleton k)
-- Null set of inputs landing in zero-probability cells
have hnull : ∀ᵐ s ∂cauchyMeasure, cauchyMeasure (enc ⁻¹' {enc s}) ≠ 0 := by
have hzero : cauchyMeasure (⋃ k ∈ { k : ℕ | cauchyMeasure (enc ⁻¹' {k}) = 0 },
enc ⁻¹' {k}) = 0 := by
rw [measure_biUnion_null_iff (Set.to_countable _)]
intro k hk
exact hk
rw [ae_iff]
refine measure_mono_null (fun s hs => ?_) hzero
simp only [Set.mem_ofPred_eq, not_not] at hs
exact Set.mem_biUnion hs rfl
-- Explicit Radon–Nikodym density: `μW = νW.withDensity f`
have hμW_eq : μW = νW.withDensity f := by
ext E hE
rw [withDensity_apply _ hE, ← lintegral_indicator hE, hνW,
lintegral_prod _ (hf_meas.indicator hE).aemeasurable]
have hinner : ∀ᵐ s ∂cauchyMeasure,
∫⁻ k, E.indicator f (s, k) ∂ρ =
(if (s, enc s) ∈ E then (1 : ℝ≥0∞) else 0) := by
filter_upwards [hnull] with s hs_ne
rw [lintegral_countable']
have hterm : ∀ k : ℕ, E.indicator f (s, k) * ρ {k} =
if k = enc s then (if (s, enc s) ∈ E then (1 : ℝ≥0∞) else 0) else 0 := by
intro k
by_cases hk : k = enc s
· subst hk
simp only [↓reduceIte, hρ_sing]
by_cases hmem : (s, enc s) ∈ E
· simp only [Set.indicator_of_mem hmem, hfdef, ↓reduceIte, hmem]
exact ENNReal.inv_mul_cancel hs_ne (measure_ne_top _ _)
· simp [hmem]
· have hne : enc s ≠ k := Ne.symm hk
simp only [hk, ↓reduceIte]
by_cases hmem : (s, k) ∈ E
· simp [Set.indicator_of_mem hmem, hfdef, hne]
· simp [Set.indicator_of_notMem hmem]
simp_rw [hterm, tsum_ite_eq]
rw [lintegral_congr_ae hinner]
have hpre : (fun s : ℝ => if (s, enc s) ∈ E then (1 : ℝ≥0∞) else 0) =
((fun s => (s, enc s)) ⁻¹' E).indicator (fun _ => (1 : ℝ≥0∞)) := by
ext s
simp [Set.indicator]
rw [hpre, lintegral_indicator (hpair hE), setLIntegral_one, hμW,
Measure.map_apply hpair hE]
have hac : μW ≪ νW := by
rw [hμW_eq]; exact withDensity_absolutelyContinuous νW f
have hrn_ν : μW.rnDeriv νW =ᵐ[νW] f := by
rw [hμW_eq]; exact Measure.rnDeriv_withDensity νW hf_meas
have hrn_μ : μW.rnDeriv νW =ᵐ[μW] f := hac hrn_ν
-- Express `llr μW νW` in terms of `f`
have hllr_ae : llr μW νW =ᵐ[μW] fun p => Real.log (f p).toReal := by
filter_upwards [hrn_μ] with p hp
simp only [llr_def, hp]
-- Pull back to `cauchyMeasure` along `s ↦ (s, enc s)`
set g : ℝ → ℝ := fun s =>
let p := (cauchyMeasure (enc ⁻¹' {enc s})).toReal
if p ≤ 0 then 0 else -Real.log p with hgdef
have hg_meas : Measurable g :=
(measurable_of_countable (fun k : ℕ =>
let p := (cauchyMeasure (enc ⁻¹' {k})).toReal
if p ≤ 0 then 0 else -Real.log p)).comp henc
have hg_nonneg : ∀ s, 0 ≤ g s := by
intro s
dsimp only [g]
split_ifs with h0
· exact le_rfl
· have hp_pos : 0 < (cauchyMeasure (enc ⁻¹' {enc s})).toReal := lt_of_not_ge h0
have hp_le : (cauchyMeasure (enc ⁻¹' {enc s})).toReal ≤ 1 := by
calc (cauchyMeasure (enc ⁻¹' {enc s})).toReal
≤ (cauchyMeasure Set.univ).toReal :=
ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (Set.subset_univ _))
_ = 1 := by simp
linarith [Real.log_nonpos hp_pos.le hp_le]
have hcomp_ae : (fun s => Real.log (f (s, enc s)).toReal) =ᵐ[cauchyMeasure] g := by
filter_upwards [hnull] with s hs_ne
have hfin : cauchyMeasure (enc ⁻¹' {enc s}) ≠ ⊤ := measure_ne_top _ _
have hp_pos : 0 < (cauchyMeasure (enc ⁻¹' {enc s})).toReal :=
ENNReal.toReal_pos hs_ne hfin
simp only [hfdef, ↓reduceIte, ENNReal.toReal_inv, Real.log_inv, hgdef,
not_le.mpr hp_pos]
-- Compute `∫⁻ s, ENNReal.ofReal (g s) ∂cauchyMeasure`
have hlint_g : ∫⁻ s, ENNReal.ofReal (g s) ∂cauchyMeasure =
∑' k : ℕ,
let p := (cauchyMeasure (enc ⁻¹' {k})).toReal
ENNReal.ofReal (if p ≤ 0 then 0 else -p * Real.log p) := by
have hunion : (Set.univ : Set ℝ) = ⋃ k : ℕ, enc ⁻¹' {k} := by
ext s; simp
have hdisj : Pairwise (Function.onFun Disjoint fun k : ℕ => enc ⁻¹' {k}) := by
intro i j hij
refine Set.disjoint_left.mpr (fun s hi hj => hij ?_)
simp only [Set.mem_preimage, Set.mem_singleton_iff] at hi hj
exact hi.symm.trans hj
rw [← setLIntegral_univ, hunion,
lintegral_iUnion (fun k => henc (measurableSet_singleton k)) hdisj]
refine tsum_congr (fun k => ?_)
have hcongr : ∀ s ∈ enc ⁻¹' {k}, ENNReal.ofReal (g s) =
ENNReal.ofReal (let p := (cauchyMeasure (enc ⁻¹' {k})).toReal
if p ≤ 0 then 0 else -Real.log p) := by
intro s hs
simp only [Set.mem_preimage, Set.mem_singleton_iff] at hs
simp only [hgdef, hs]
rw [setLIntegral_congr_fun (henc (measurableSet_singleton k)) hcongr, setLIntegral_const]
set p := (cauchyMeasure (enc ⁻¹' {k})).toReal with hpdef
have hfin : cauchyMeasure (enc ⁻¹' {k}) ≠ ⊤ := measure_ne_top _ _
have hmeas_eq : cauchyMeasure (enc ⁻¹' {k}) = ENNReal.ofReal p :=
(ENNReal.ofReal_toReal hfin).symm
rw [hmeas_eq]
by_cases hp0 : p ≤ 0
· simp [hp0]
· simp only [hp0, ↓reduceIte]
have hp_pos : 0 < p := lt_of_not_ge hp0
have hp_le : p ≤ 1 := by
calc p ≤ (cauchyMeasure Set.univ).toReal :=
ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (Set.subset_univ _))
_ = 1 := by simp
have hlog_nonneg : 0 ≤ -Real.log p := by linarith [Real.log_nonpos hp_pos.le hp_le]
rw [← ENNReal.ofReal_mul hlog_nonneg]
congr 1; ring
have hsum_nn : ∀ k : ℕ, 0 ≤
(let p := (cauchyMeasure (enc ⁻¹' {k})).toReal
if p ≤ 0 then 0 else -p * Real.log p) := by
intro k
dsimp only
split_ifs with h0
· exact le_rfl
· have hp_pos : 0 < (cauchyMeasure (enc ⁻¹' {k})).toReal := lt_of_not_ge h0
have hp_le : (cauchyMeasure (enc ⁻¹' {k})).toReal ≤ 1 := by
calc (cauchyMeasure (enc ⁻¹' {k})).toReal
≤ (cauchyMeasure Set.univ).toReal :=
ENNReal.toReal_mono (measure_ne_top _ _) (measure_mono (Set.subset_univ _))
_ = 1 := by simp
nlinarith [Real.log_nonpos hp_pos.le hp_le]
have hlint_lt_top : ∫⁻ s, ENNReal.ofReal (g s) ∂cauchyMeasure < ⊤ := by
rw [hlint_g, ← ENNReal.ofReal_tsum_of_nonneg hsum_nn hsum]
exact ENNReal.ofReal_lt_top
have hg_int : Integrable g cauchyMeasure := by
refine ⟨hg_meas.aestronglyMeasurable, ?_⟩
rw [hasFiniteIntegral_iff_ofReal (ae_of_all _ hg_nonneg)]
exact hlint_lt_top
have hlogf_meas : Measurable (fun p : ℝ × ℕ => Real.log (f p).toReal) :=
(hf_meas.ennreal_toReal).log
have hlogf_int : Integrable (fun p : ℝ × ℕ => Real.log (f p).toReal) μW := by
rw [hμW, integrable_map_measure hlogf_meas.aestronglyMeasurable hpair.aemeasurable]
exact hg_int.congr hcomp_ae.symm
have hllr_int : Integrable (llr μW νW) μW := hlogf_int.congr hllr_ae.symm
rw [InformationTheory.klDiv_of_ac_of_integrable hac hllr_int]
simp only [probReal_univ, add_sub_cancel_right]
rw [integral_congr_ae hllr_ae, hμW,
integral_map hpair.aemeasurable hlogf_meas.aestronglyMeasurable,
integral_congr_ae hcomp_ae,
ofReal_integral_eq_lintegral_ofReal hg_int (ae_of_all _ hg_nonneg), hlint_g]
/-- For every `D > 0`, the single-letter information rate-distortion function `cauchyInfoRD D`
is bounded above by the discrete entropy of the uniform scalar quantizer of step `2 √D`. -/
theorem cauchyInfoRD_le_quantizer {D : ℝ} (hD : 0 < D) :
cauchyInfoRD D ≤ vlCodeEntropy 1 (uniformQuantEnc (2 * Real.sqrt D)) := by
set Δ := 2 * Real.sqrt D with hΔdef
have hΔ : 0 < Δ := mul_pos two_pos (Real.sqrt_pos.mpr hD)
have hΔsq : Δ ^ 2 / 4 = D := by
rw [hΔdef]
have hsq : (Real.sqrt D) ^ 2 = D := Real.sq_sqrt hD.le
nlinarith
set enc := scalarQuantEnc Δ with hencdef
set dec := scalarQuantDec Δ with hdecdef
have henc_m : Measurable enc := measurable_scalarQuantEnc hΔ
have hdec_m : Measurable dec := measurable_of_countable dec
have hpair_m : Measurable (fun s : ℝ => (s, dec (enc s))) :=
measurable_id.prodMk (hdec_m.comp henc_m)
set μ : Measure (ℝ × ℝ) := cauchyMeasure.map (fun s => (s, dec (enc s))) with hμdef
have hμ_prob : IsProbabilityMeasure μ := isProb_map cauchyMeasure hpair_m
have hμ_fst : μ.map Prod.fst = cauchyMeasure := by
rw [hμdef, Measure.map_map measurable_fst hpair_m]
exact Measure.map_id
have hμ_dist : ∫⁻ p : ℝ × ℝ, ENNReal.ofReal ((p.1 - p.2) ^ 2) ∂μ ≤ ENNReal.ofReal D := by
have hdm : Measurable (fun p : ℝ × ℝ => ENNReal.ofReal ((p.1 - p.2) ^ 2)) :=
((measurable_fst.sub measurable_snd).pow_const 2).ennreal_ofReal
rw [hμdef, lintegral_map hdm hpair_m]
calc ∫⁻ s : ℝ, ENNReal.ofReal ((s - dec (enc s)) ^ 2) ∂cauchyMeasure
≤ ∫⁻ _ : ℝ, ENNReal.ofReal D ∂cauchyMeasure := by
refine lintegral_mono (fun s => ENNReal.ofReal_le_ofReal ?_)
rw [← hΔsq]
exact scalarQuant_sq_error_le hΔ s
_ = ENNReal.ofReal D := by rw [lintegral_const, measure_univ, mul_one]
-- Apply data processing inequality from `(S, enc(S))` to `(S, dec(enc(S)))`
set μW : Measure (ℝ × ℕ) := cauchyMeasure.map (fun s => (s, enc s)) with hμW
set νW : Measure (ℝ × ℕ) := cauchyMeasure.prod (cauchyMeasure.map enc) with hνW
have hmap_m : Measurable (Prod.map (id : ℝ → ℝ) dec) :=
measurable_id.prodMap hdec_m
have hpairW_m : Measurable (fun s : ℝ => (s, enc s)) := measurable_id.prodMk henc_m
have hμ_eq_map : μ = μW.map (Prod.map id dec) := by
rw [hμW, Measure.map_map hmap_m hpairW_m]
rfl
have hν_eq_map : cauchyMeasure.prod (μ.map Prod.snd) = νW.map (Prod.map id dec) := by
have : IsProbabilityMeasure (cauchyMeasure.map enc) :=
isProb_map cauchyMeasure henc_m
have hsnd : μ.map Prod.snd = (cauchyMeasure.map enc).map dec := by
rw [hμdef, Measure.map_map measurable_snd hpair_m, Measure.map_map hdec_m henc_m]
rfl
rw [hsnd, hνW, ← Measure.map_prod_map cauchyMeasure (cauchyMeasure.map enc)
measurable_id hdec_m, Measure.map_id]
have hkl_le : InformationTheory.klDiv μ (cauchyMeasure.prod (μ.map Prod.snd)) ≤
InformationTheory.klDiv μW νW := by
rw [hν_eq_map, hμ_eq_map]
exact InformationTheory.klDiv_map_le μW νW hmap_m
have hklW_le := klDiv_discrete_encoder_le henc_m (summable_scalarQuant_entropy hΔ)
have hent_eq :
(∑' k : ℕ,
let p := (cauchyMeasure (enc ⁻¹' {k})).toReal
ENNReal.ofReal (if p ≤ 0 then 0 else -p * Real.log p)) =
vlCodeEntropy 1 (uniformQuantEnc Δ) := by
unfold vlCodeEntropy
simp_rw [cauchyMeasureN_one_uniformQuant Δ]
rfl
calc cauchyInfoRD D
≤ InformationTheory.klDiv μ (cauchyMeasure.prod (μ.map Prod.snd)) :=
sInf_le ⟨μ, hμ_prob, hμ_fst, hμ_dist, rfl⟩
_ ≤ InformationTheory.klDiv μW νW := hkl_le
_ ≤ vlCodeEntropy 1 (uniformQuantEnc Δ) := by rwa [← hent_eq]
/-- For every `D > 0`, the single-letter information rate-distortion function `cauchyInfoRD D`
is strictly finite (`< ⊤`). -/
theorem cauchyInfoRD_lt_top {D : ℝ} (hD : 0 < D) : cauchyInfoRD D < ⊤ :=
lt_of_le_of_lt (cauchyInfoRD_le_quantizer hD)
(uniformQuant_entropy_lt_top (mul_pos two_pos (Real.sqrt_pos.mpr hD)))
end InfoTheory.Known.Certificates.VariableLengthRdInfiniteDmax