BinaryTable.lean
1module2public import SubentropyCertificates.BinaryLogIntervals34/-! Exact rational witnesses for the binary entries in Table 1. -/5@[expose] public section6noncomputable section7open Set8namespace SubentropyCertificates.BinaryIntervals9open SubentropyCertificates.LogEnclosure SubentropyCertificates.ClassicalCurve10open SubentropyCertificates.Discrimination SubentropyCertificates.SmallOverlap1112private theorem bound_between (s : Icc (0:ℝ) 1) {l u : ℝ} (hl : l ∈ Icc 0 (uniformError 0))13 (hu : u ∈ Icc 0 (uniformError 0)) (hlo : phi 0 l ≤ conditionalCurve s)14 (hup : conditionalCurve s < phi 0 u) : l ≤ subentropyBound s ∧ subentropyBound s < u := by15 have hb := phiInverse_mem 0 _ (conditionalCurve_mem s)16 change subentropyBound s ∈ Icc 0 (uniformError 0) at hb17 rw [← phi_bound s] at hlo hup18 exact ⟨((phi_strictMono 0).le_iff_le hl hb).mp hlo,((phi_strictMono 0).lt_iff_lt hb hu).mp hup⟩1920private theorem round_bound (n a b : ℕ) {s l u : ℚ}21 (hs : 0 < s) (hs1 : s < 1) (hlo : 0 < l) (hlu : l < u) (hu : u < 1/2)22 (ha : 1 ≤ 2^a*((1-s)/2)) (hb : 1 ≤ 2^b*l) (hb' : 1 ≤ 2^b*u)23 (hleft : phiHi n b l ≤ logLower n 2 - 1/2 - phiHi n a ((1-s)/2))24 (hright : logUpper n 2 - 1/2 - phiLo n a ((1-s)/2) < phiLo n b u) :25 ∀ h : (s:ℝ) ∈ Icc 0 1, (l:ℝ) ≤ subentropyBound ⟨s,h⟩ ∧ subentropyBound ⟨s,h⟩ < u := by26 intro h27 have hl := (binary_interval n b hlo (lt_trans hlu hu) hb).228 have hr := (binary_interval n b (lt_trans hlo hlu) hu hb').129 have hf := binary_interval n a (u:=(1-s)/2) (by linarith) (by linarith) ha30 have h2 := rational_log_bounds n (y:=2) (by norm_num)31 have ha' := (Rat.cast_le (K:=ℝ)).mpr hleft32 have hb'' := (Rat.cast_lt (K:=ℝ)).mpr hright33 have htop := phi_uniform_endpoint 034 norm_num [uniformError,harmonic_succ,harmonic_zero] at htop35 have hc : (u:ℝ) < 1/2 := by36 have hc' : (u:ℝ) < ((1/2:ℚ):ℝ) := Rat.cast_lt.mpr hu37 simpa using hc'38 have hr0 : 0 < (l:ℝ) := by exact_mod_cast hlo39 have hlu' : (l:ℝ) < u := by exact_mod_cast hlu40 apply bound_between41 · norm_num [uniformError]; constructor <;> linarith42 · norm_num [uniformError]; constructor <;> linarith43 · unfold conditionalCurve44 push_cast at ha' hf h245 linarith [hf.2,h2.1]46 · unfold conditionalCurve47 push_cast at hb'' hf h248 linarith [hf.1,h2.2]4950def binaryRow (i : Fin 4) : ℚ × ℚ × ℚ × ℚ × ℕ × ℕ :=51 ![(1/4, 1588/100000, 1562/100000, 1097/100000, 2, 7),52 (1/2, 6699/100000, 6250/100000, 4957/100000, 2, 5),53 (4/5, 20000/100000, 16000/100000, 16664/100000, 4, 3),54 (19/20, 34388/100000, 22562/100000, 31592/100000, 6, 2)] i5556private theorem row_data (i : Fin 4) :57 let (s,e,m,l,a,b) := binaryRow i58 let u := l+1/10000059 0 < s ∧ s < 1 ∧ 0 < l ∧ l < u ∧ u < 1/2 ∧60 1 ≤ 2^a*((1-s)/2) ∧ 1 ≤ 2^b*l ∧ 1 ≤ 2^b*u ∧61 phiHi 20 b l ≤ logLower 20 2 - 1/2 - phiHi 20 a ((1-s)/2) ∧62 logUpper 20 2 - 1/2 - phiLo 20 a ((1-s)/2) < phiLo 20 b u ∧63 m ≤ s^2/4 ∧ s^2/4 < m+1/100000 ∧64 0 < 1-2*(e+1/200000) ∧ (1-2*(e+1/200000))^2 < 1-s^2 ∧65 1-s^2 < (1-2*(e-1/200000))^2 := by66 fin_cases i <;> decide +kernel6768/-- Every interior row has the stated nearest error and the two stated downward69roundings. The inverse bound is evaluated on its physical domain. -/70theorem binary_table_interior (i : Fin 4) :71 let (s,e,m,l,_,_) := binaryRow i72 ∃ hs : (s:ℝ) ∈ Icc 0 1, |errorCurve s - (e:ℝ)| < 1/200000 ∧73 (m:ℝ) ≤ (s:ℝ)^2/4 ∧ (s:ℝ)^2/4 < (m:ℝ)+1/100000 ∧74 (l:ℝ) ≤ subentropyBound ⟨s,hs⟩ ∧ subentropyBound ⟨s,hs⟩ < (l:ℝ)+1/100000 := by75 have data := row_data i76 generalize hrow : binaryRow i = row at data ⊢77 obtain ⟨s,e,m,l,a,b⟩ := row78 dsimp only at data ⊢79 obtain ⟨hs0,hs1,hl,hlu,hu,ha,hb,hb',hleft,hright,hm,hm',he,h₀,h₁⟩ := data80 have hs : (s:ℝ) ∈ Icc 0 1 := by81 exact ⟨(show 0 < (s:ℝ) by exact_mod_cast hs0).le,(show (s:ℝ) < 1 by exact_mod_cast hs1).le⟩82 have hi := round_bound 20 a b hs0 hs1 hl hlu hu ha hb hb' hleft hright hs83 have hpos : 0 < (1:ℝ)-2*((e:ℝ)+1/200000) := by simpa using (Rat.cast_lt (K:=ℝ)).mpr he84 have hsmall : ((1:ℝ)-2*((e:ℝ)+1/200000))^2 < 1-(s:ℝ)^2 := by simpa using (Rat.cast_lt (K:=ℝ)).mpr h₀85 have hlarge : 1-(s:ℝ)^2 < ((1:ℝ)-2*((e:ℝ)-1/200000))^2 := by simpa using (Rat.cast_lt (K:=ℝ)).mpr h₁86 have hn : 0 ≤ 1-(s:ℝ)^2 := by nlinarith [sq_nonneg ((1:ℝ)-2*((e:ℝ)+1/200000))]87 have hh := Real.sq_sqrt hn88 have hp := Real.sqrt_nonneg (1-(s:ℝ)^2)89 refine ⟨hs, ?_, ?_, ?_, hi.1, ?_⟩90 · unfold errorCurve91 rw [abs_lt]92 constructor <;> nlinarith93 · exact_mod_cast hm94 · simpa using (Rat.cast_lt (K:=ℝ)).mpr hm'95 · push_cast at hi96 exact hi.29798/-- The exact optimal error, fidelity bound and subentropy bound at both endpoints. -/99theorem binary_table_endpoints :100 errorCurve 0 = 0 ∧ errorCurve 1 = 1/2 ∧101 ((0:ℝ)^2/4 = 0 ∧ (1:ℝ)^2/4 = 1/4) ∧102 subentropyBound ⟨0,by norm_num⟩ = 0 ∧ subentropyBound ⟨1,by norm_num⟩ = 1/2 := by103 have he0 : errorCurve 0 = 0 := by norm_num [errorCurve]104 have he1 : errorCurve 1 = 1/2 := by norm_num [errorCurve]105 have b0 := bound_nonneg_le_error (⟨0,by norm_num⟩ : Icc (0:ℝ) 1)106 have hu : uniformError 0 = 1/2 := by norm_num [uniformError]107 refine ⟨he0,he1,by norm_num,le_antisymm (b0.2.trans he0.le) b0.1,?_⟩108 have hb := phi_bound (⟨1,by norm_num⟩ : Icc (0:ℝ) 1)109 have hcond : conditionalCurve 1 = phi 0 (1/2) := by norm_num [conditionalCurve,phi_zero]110 exact phi_preimage_unique 0 (phiInverse_mem 0 _ _) (by rw [hu]; norm_num) (hb.trans hcond)111112end SubentropyCertificates.BinaryIntervals
Axioms used
Choose a statement to see which axioms its proof uses.