TernaryTable.lean
1module2public import SubentropyCertificates.TernaryIntervals3public import SubentropyCertificates.CyclicTable45/-! Five-decimal enclosures for the cyclic ensemble. -/6@[expose] public section7noncomputable section8open Set9namespace SubentropyCertificates.TernaryIntervals10open SubentropyCertificates.Cyclic SubentropyCertificates.ClassicalCurve11open SubentropyCertificates.Discrimination SubentropyCertificates.LogEnclosure1213def row (i : Fin 4) : ℚ × ℚ × ℚ × ℚ × ℕ × ℕ :=14 ![(1/100,52801/100000,24639/100000,48126/100000,7,3),15 (1/20,35049/100000,18298/100000,28014/100000,5,3),16 (1/10,22288/100000,12121/100000,15987/100000,4,4),17 (1/5,7145/100000,3896/100000,4323/100000,3,6)] i1819private def usable (k : ℕ) (b : ℚ) : Prop :=20 0 < b ∧ b < 1/3 ∧ 1 ≤ 2*(1-2*b) ∧ 1 ≤ 2^k*b ∧ 1 ≤ weight b2122private instance (k : ℕ) (b : ℚ) : Decidable (usable k b) := by unfold usable; infer_instance2324private theorem interval_of (n k : ℕ) (b : ℚ) (h : usable k b) :25 (lo n k b:ℝ) ≤ phi 1 (2*(b:ℝ)) ∧ phi 1 (2*(b:ℝ)) ≤ (hi n k b:ℝ) :=26 ternary_interval n k h.1 h.2.1 h.2.2.1 h.2.2.2.1 h.2.2.2.22728private def rowTest (r e q l : ℚ) (a b : ℕ) : Prop :=29 let u := l+1/10000030 let L := logLower 24 3 - 5/6 - hi 24 a r31 let U := logUpper 24 3 - 5/6 - lo 24 a r32 usable a r ∧ usable b (l/2) ∧ usable b (u/2) ∧33 q ≤ L ∧ U < q+1/100000 ∧ hi 24 b (l/2) ≤ L ∧ U < lo 24 b (u/2) ∧34 0 < 2-2*r-3*(e+1/200000) ∧ (2-2*r-3*(e+1/200000))^2 < 16*r*(1-2*r) ∧35 16*r*(1-2*r) < (2-2*r-3*(e-1/200000))^2 ∧ 0 < 2-2*r-3*(e-1/200000)3637private instance (r e q l : ℚ) (a b : ℕ) : Decidable (rowTest r e q l a b) := by38 unfold rowTest; infer_instance3940private theorem row_witness (i : Fin 4) :41 let (r,e,q,l,a,b) := row i42 rowTest r e q l a b := by43 fin_cases i <;> decide +kernel4445private theorem error_enclosure {r e : ℚ} (hr : 0 < r) (hr' : r < 1/3)46 (hp : 0 < 2-2*r-3*(e+1/200000))47 (hl : (2-2*r-3*(e+1/200000))^2 < 16*r*(1-2*r))48 (hh : 16*r*(1-2*r) < (2-2*r-3*(e-1/200000))^2)49 (hp' : 0 < 2-2*r-3*(e-1/200000)) :50 |tableError r - (e:ℝ)| < 1/200000 := by51 have h0 : 0 ≤ (r:ℝ) := by exact_mod_cast hr.le52 have h1 : 0 ≤ 1-2*(r:ℝ) := by53 have : (r:ℝ) < 1/3 := by simpa using (Rat.cast_lt (K:=ℝ)).mpr hr'54 linarith55 let x := Real.sqrt (1-2*(r:ℝ)) * Real.sqrt (r:ℝ)56 have hx : 0 ≤ x := mul_nonneg (Real.sqrt_nonneg _) (Real.sqrt_nonneg _)57 have he : x^2 = (1-2*(r:ℝ))*(r:ℝ) := by rw [show x^2 = _ from mul_pow _ _ 2,Real.sq_sqrt h1,Real.sq_sqrt h0]58 have hv : tableError r = (2-2*(r:ℝ)-4*x)/3 := by59 unfold tableError60 dsimp [x]61 nlinarith [Real.sq_sqrt h1,Real.sq_sqrt h0]62 have hll := (Rat.cast_lt (K:=ℝ)).mpr hl63 have hhh := (Rat.cast_lt (K:=ℝ)).mpr hh64 have hpp := (Rat.cast_lt (K:=ℝ)).mpr hp'65 have hpn := (Rat.cast_lt (K:=ℝ)).mpr hp66 push_cast at hll hhh hpp hpn67 rw [hv,abs_lt]68 constructor <;> nlinarith6970/-- Table A1's four interior rows, including nearest rounding for the error and both floors.71The optimal error and linear bound are identified with the physical ensemble in cyclic_table_values. -/72theorem cyclic_table_interior (i : Fin 4) :73 let (r,e,q,l,_,_) := row i74 |tableError r - (e:ℝ)| < 1/200000 ∧75 (q:ℝ) ≤ tableQ r ∧ tableQ r < (q:ℝ)+1/100000 ∧76 ∃ h, (l:ℝ) ≤ phiInverse 1 (tableQ r) h ∧ phiInverse 1 (tableQ r) h < (l:ℝ)+1/100000 := by77 have data := row_witness i78 generalize hd : row i = values at data ⊢79 obtain ⟨r,e,q,l,a,b⟩ := values80 dsimp only at data ⊢81 obtain ⟨hr,hl,hu,hq,hq',hiL,hiU,hp1,hp2,hp3,hp4⟩ := data82 have hx := error_enclosure hr.1 hr.2.1 hp1 hp2 hp3 hp483 have h1 := interval_of 24 a r hr84 have h2 := interval_of 24 b (l/2) hl85 have h3 := interval_of 24 b ((l+1/100000)/2) hu86 have hlog := rational_log_bounds 24 (y:=3) (by norm_num)87 have htop := phi_uniform_endpoint 188 norm_num [harmonic_succ,harmonic_zero] at htop89 have htop' : phi 1 (uniformError 1) = Real.log 3-5/6 := by linarith90 have hq0 := (Rat.cast_le (K:=ℝ)).mpr hq91 have hq1 := (Rat.cast_lt (K:=ℝ)).mpr hq'92 have hlow := (Rat.cast_le (K:=ℝ)).mpr hiL93 have hhigh := (Rat.cast_lt (K:=ℝ)).mpr hiU94 push_cast at hlog hq0 hq1 hlow hhigh h2 h395 have hqLo : (q:ℝ) ≤ tableQ r := by unfold tableQ; rw [htop']; linarith [hlog.1,h1.2]96 have hqHi : tableQ r < (q:ℝ)+1/100000 := by unfold tableQ; rw [htop']; linarith [hlog.2,h1.1]97 have hL : phi 1 (l:ℝ) ≤ tableQ r := by98 unfold tableQ; rw [htop']99 rw [show 2*((l:ℝ)/2) = (l:ℝ) by ring] at h2100 linarith [h2.2,h1.2,hlog.1]101 have hU : tableQ r < phi 1 ((l:ℝ)+1/100000) := by102 unfold tableQ; rw [htop']103 rw [show 2*(((l:ℝ)+1/100000)/2) = (l:ℝ)+1/100000 by ring] at h3104 linarith [h3.1,h1.1,hlog.2]105 have hb (v : ℚ) (h : usable b (v/2)) : (v:ℝ) ∈ Icc 0 (uniformError 1) := by106 have z := (Rat.cast_lt (K:=ℝ)).mpr h.1107 have t := (Rat.cast_lt (K:=ℝ)).mpr h.2.1108 push_cast at z t109 change 0 ≤ (v:ℝ) ∧ (v:ℝ) ≤ uniformError 1110 rw [show uniformError 1 = 2/3 by norm_num [uniformError]]111 constructor <;> linarith only [z,t]112 have ml := hb l hl113 have mu := hb (l+1/100000) hu114 push_cast at mu115 have hdom : tableQ r ∈ curveRange 1 := by116 constructor117 · exact (phi_maps_to_curveRange 1 ml).1.trans hL118 · exact hU.le.trans (phi_maps_to_curveRange 1 mu).2119 have hbnd := phiInverse_mem 1 _ hdom120 rw [← phi_phiInverse 1 _ hdom] at hL hU121 exact ⟨hx,hqLo,hqHi,hdom,((phi_strictMono 1).le_iff_le ml hbnd).mp hL,122 ((phi_strictMono 1).lt_iff_lt hbnd mu).mp hU⟩123124/-- The endpoint r=0 has a non-rational linear bound. Its displayed five-place floor is exact. -/125theorem cyclic_table_zero_floor : 26527/100000 ≤ tableQ 0 ∧ tableQ 0 < 26528/100000 := by126 rw [cyclic_table_endpoints.2.2.1]127 have h := rational_log_bounds 24 (y:=3) (by norm_num)128 have hl : (26527/100000:ℚ) ≤ logLower 24 3 -5/6 := by decide +kernel129 have hu : logUpper 24 3-5/6 < (26528/100000:ℚ) := by decide +kernel130 have hl' := (Rat.cast_le (K:=ℝ)).mpr hl131 have hu' := (Rat.cast_lt (K:=ℝ)).mpr hu132 push_cast at h hl' hu'133 constructor <;> linarith [h.1,h.2]134135end SubentropyCertificates.TernaryIntervals
Axioms used
Choose a statement to see which axioms its proof uses.