File size: 2,827 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | import Mathlib
import OAI.Probability.BinarySweep.SparseBounds.FewSparseBases
namespace OAI
noncomputable section
open scoped BigOperators Classical
namespace BinaryCoordinateSweeps
open GridSplit
lemma balanced_counts (b : β) (hb : 2 β€ b) : βm n : β,
b=m+n β§ 1 β€ m β§ 1 β€ n β§ m < b β§ n < b β§ m β€ 2*n β§ n β€ 2*m := by
refine β¨b/2,b-b/2,by omega,by omega,by omega,by omega,by omega,by omega,by omegaβ©
lemma balanced_grid_bounds {m n r : β} (bits : Fin (m+n) β β)
(hm : 1 β€ m) (hn : 1 β€ n) (hmn : m β€ 2*n) (hnm : n β€ 2*m)
(hd : βj,r β€ bits j β§ bits j β€ 2*r) (hr : 400000000 β€ (r:β)*Real.log 2) :
1 β€ Real.log (gridSize (leftBits bits)) β§ 1 β€ Real.log (gridSize (rightBits bits)) β§
Real.log (gridSize (leftBits bits)) β€ (4/5:β)*Real.log (gridSize bits) β§
Real.log (gridSize (rightBits bits)) β€ (4/5:β)*Real.log (gridSize bits) β§
Real.log 4*(m+n) β€ (1/1000:β)*Real.log (gridSize bits) := by
have hl := grid_log_lower (fun j : Fin m => (hd (j.castAdd n)).1)
have hr' := grid_log_lower (fun j : Fin n => (hd (j.natAdd m)).1)
have hlu := grid_log_upper (fun j : Fin m => (hd (j.castAdd n)).2)
have hru := grid_log_upper (fun j : Fin n => (hd (j.natAdd m)).2)
change (m:β)*((r:β)*Real.log 2) β€ Real.log (gridSize (leftBits bits)) at hl
change (n:β)*((r:β)*Real.log 2) β€ Real.log (gridSize (rightBits bits)) at hr'
change Real.log (gridSize (leftBits bits)) β€ (m:β)*(2*r*Real.log 2) at hlu
change Real.log (gridSize (rightBits bits)) β€ (n:β)*(2*r*Real.log 2) at hru
have hsum : Real.log (gridSize bits)=Real.log (gridSize (leftBits bits))+Real.log (gridSize (rightBits bits)) := by
rw [size_split,Nat.cast_mul]
exact Real.log_mul (by exact_mod_cast (gridSize_pos (leftBits bits)).ne')
(by exact_mod_cast (gridSize_pos (rightBits bits)).ne')
have hmR : (1:β) β€ m := by exact_mod_cast hm
have hnR : (1:β) β€ n := by exact_mod_cast hn
have hmnR : (m:β) β€ 2*n := by exact_mod_cast hmn
have hnmR : (n:β) β€ 2*m := by exact_mod_cast hnm
have hscale : 0 β€ (r:β)*Real.log 2 := by linarith
have hmnl := mul_le_mul_of_nonneg_right hmnR hscale
have hnml := mul_le_mul_of_nonneg_right hnmR hscale
have hm1 := mul_le_mul_of_nonneg_right hmR hscale
have hn1 := mul_le_mul_of_nonneg_right hnR hscale
have haxes := grid_log_lower (fun j => (hd j).1)
have hlog4 : Real.log 4 β€ 4 := (Real.log_le_sub_one_of_pos (by norm_num : (0:β)<4)).trans (by norm_num)
have hbR : (0:β) β€ m+n := by positivity
have hax := mul_le_mul_of_nonneg_right hlog4 hbR
have hsc := mul_le_mul_of_nonneg_left hr hbR
push_cast at haxes
refine β¨by nlinarith,by nlinarith,by nlinarith,by nlinarith,by nlinarithβ©
end BinaryCoordinateSweeps
end
end OAI
|