module public import SubentropyCertificates.CalibratedCurveContinuity public import SubentropyCertificates.CalibratedMonotonicity public import SubentropyCertificates.CalibratedMeasurementCurve public import Mathlib.Topology.Order.IntermediateValue /-! The inverse of the calibrated curve on the admissible error interval in Proposition 25. -/ @[expose] public section noncomputable section open Set open scoped BigOperators namespace SubentropyCertificates.AncillaCalibration open D5.S3.Quantum.Foundation.FiniteStateChannel (DensityState) open D5.S3.Quantum.Information.PartialTraceMutualInformation (productState) open D5.S3.Quantum.Subentropy.ClassicalQuantumGram (conditionalSubentropy) open D5.S3.Quantum.Subentropy.GuessingProbability (pGuess) open SubentropyCertificates.ClassicalCurve open SubentropyCertificates.Discrimination variable {C : Type*} [Fintype C] [DecidableEq C] /-- The closed interval of subentropy values attained by the calibrated error curve. -/ def calibratedCurveRange (ν : DensityState C) (m : ℕ) : Set ℝ := Icc 0 (calibratedPhi ν m (uniformError m)) /-- The calibrated curve maps the admissible error interval bijectively onto its full range. -/ theorem calibratedPhi_bijOn (ν : DensityState C) (m : ℕ) : BijOn (calibratedPhi ν m) (Icc 0 (uniformError m)) (calibratedCurveRange ν m) := by have hmono := calibratedPhi_strictMono ν m have h0 : (0 : ℝ) ∈ Icc 0 (uniformError m) := ⟨le_rfl, (uniformError_mem m).1⟩ have hmax : uniformError m ∈ Icc 0 (uniformError m) := ⟨(uniformError_mem m).1, le_rfl⟩ refine ⟨?_, hmono.injOn, ?_⟩ · intro e he have h := hmono.monotoneOn h0 he he.1 rw [calibratedPhi_zero] at h exact ⟨h, hmono.monotoneOn he hmax he.2⟩ · have hsub : Icc 0 (uniformError m) ⊆ Icc (0 : ℝ) 1 := fun _ he ↦ ⟨he.1, he.2.trans (uniformError_mem m).2⟩ simpa only [calibratedCurveRange, calibratedPhi_zero] using ((calibratedPhi_continuousOn ν m).mono hsub).surjOn_Icc h0 hmax /-- The inverse at any subentropy value in the closed range of the calibrated curve. -/ def calibratedPhiInverse (ν : DensityState C) (m : ℕ) (q : ℝ) (hq : q ∈ calibratedCurveRange ν m) : ℝ := Classical.choose ((calibratedPhi_bijOn ν m).surjOn hq) /-- The inverse returns an admissible error whose image is exactly the supplied value. -/ theorem calibratedPhiInverse_spec (ν : DensityState C) (m : ℕ) (q : ℝ) (hq : q ∈ calibratedCurveRange ν m) : calibratedPhiInverse ν m q hq ∈ Icc 0 (uniformError m) ∧ calibratedPhi ν m (calibratedPhiInverse ν m q hq) = q := Classical.choose_spec ((calibratedPhi_bijOn ν m).surjOn hq) /-- Inverting the value at any admissible error recovers that error, including the endpoints. -/ theorem calibratedPhiInverse_phi (ν : DensityState C) (m : ℕ) (e : ℝ) (he : e ∈ Icc 0 (uniformError m)) : calibratedPhiInverse ν m (calibratedPhi ν m e) ((calibratedPhi_bijOn ν m).mapsTo he) = e := by obtain ⟨hmem, hval⟩ := calibratedPhiInverse_spec ν m _ ((calibratedPhi_bijOn ν m).mapsTo he) exact (calibratedPhi_strictMono ν m).injOn hmem he hval /-- Comparing an inverse value to an admissible error is equivalent to comparing curve values. -/ theorem calibratedPhiInverse_le_iff (ν : DensityState C) (m : ℕ) {q e : ℝ} (hq : q ∈ calibratedCurveRange ν m) (he : e ∈ Icc 0 (uniformError m)) : calibratedPhiInverse ν m q hq ≤ e ↔ q ≤ calibratedPhi ν m e := by obtain ⟨hmem, hval⟩ := calibratedPhiInverse_spec ν m q hq have h := ((calibratedPhi_strictMono ν m).le_iff_le hmem he).symm rwa [hval] at h variable {X B : Type*} [Fintype X] [DecidableEq X] [Fintype B] [DecidableEq B] /-- Every independently extended ensemble supplies an argument in the calibrated inverse domain. -/ theorem conditional_product_mem_calibratedRange (ν : DensityState C) (m : ℕ) (hn : Fintype.card X = m + 2) (p : X → ℝ) (hp : ∀ x, 0 ≤ p x) (hs : ∑ x, p x = 1) (ρ : X → DensityState B) : conditionalSubentropy p hp hs (fun x ↦ productState (ρ x) ν) ∈ calibratedCurveRange ν m := by have he := optimal_error_range m hn p hp hs ρ exact ⟨(optimal_discrimination_bound m hn p hp hs (fun x ↦ productState (ρ x) ν)).1, (ancilla_optimal_curve_bound ν m hn p hp hs ρ).trans ((calibratedPhi_bijOn ν m).mapsTo he).2⟩ /-- Proposition 25: inverting the extended conditional subentropy bounds the optimal guessing error of the original ensemble for every fixed independent ancillary density. -/ theorem ancilla_inverse_discrimination_bound (ν : DensityState C) (m : ℕ) (hn : Fintype.card X = m + 2) (p : X → ℝ) (hp : ∀ x, 0 ≤ p x) (hs : ∑ x, p x = 1) (ρ : X → DensityState B) : calibratedPhiInverse ν m (conditionalSubentropy p hp hs (fun x ↦ productState (ρ x) ν)) (conditional_product_mem_calibratedRange ν m hn p hp hs ρ) ≤ 1 - pGuess p ρ := (calibratedPhiInverse_le_iff ν m _ (optimal_error_range m hn p hp hs ρ)).2 (ancilla_optimal_curve_bound ν m hn p hp hs ρ) end SubentropyCertificates.AncillaCalibration