File size: 5,339 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | import OAI.Combinatorics.EditApproximation.Geometry.RoundedGroupStates
import OAI.Combinatorics.EditApproximation.Definitions
namespace OAI
/-! Every actual unskipped rounded group input belongs to a common
small endpoint list determined by the cell, child and envelope label. -/
namespace EditApproximation
theorem groupRoundSpacing_pos (exponent : β) (h : β) : 0 < groupRoundSpacing exponent h := by
apply Nat.ceil_pos.mpr
exact lt_of_lt_of_le zero_lt_one (le_max_left _ _)
theorem groupRoundSpacing_envelope_bound (exponent : β) (h : β) :
h β€ (2 : β) ^ exponent * groupRoundSpacing exponent h := by
have hpow : (0 : β) < (2 : β) ^ exponent := by positivity
have hceil : (2 : β) ^ (-(exponent : β€)) * h β€ (groupRoundSpacing exponent h : β) :=
(le_max_right _ _).trans (Nat.le_ceil _)
have hmul := mul_le_mul_of_nonneg_left hceil hpow.le
rw [zpow_neg, zpow_natCast] at hmul
simpa only [β mul_assoc, mul_inv_cancelβ hpow.ne', one_mul] using hmul
theorem bandRoundSpacing_group_spacing {ny M : β} (exponent b : β)
(band : List (Fin M β TargetInterval ny)) (initial : Fin M β TargetInterval ny β β)
(i : Fin M) (h : β) (henvelope : bandChildEnvelope b band initial i = h) :
bandRoundSpacing exponent b band initial i = groupRoundSpacing exponent h := by
have heq := bandRoundSpacing_exact exponent b band initial i
rw [henvelope] at heq
have hceil := congrArg (fun r : β => βrββ) heq
simpa only [Nat.ceil_natCast, groupRoundSpacing] using hceil
theorem gridStateBox_sound {n g radius lo hi : β} (hg : 0 < g) (r : TargetInterval n)
(hr : r β gridStateBox n g radius lo hi) :
Nat.dist lo r.lo β€ radius β§ Nat.dist hi r.hi β€ radius β§ g β£ r.lo β§ g β£ r.hi := by
obtain β¨s, hs, hrβ© := List.mem_flatMap.mp hr
obtain β¨t, ht, hmakeβ© := List.mem_filterMap.mp hr
have heq : r.lo = s β§ r.hi = t := by
unfold makeTargetState at hmake
split_ifs at hmake with hvalid
cases hmake
exact β¨rfl, rflβ©
rw [β heq.1] at hs
rw [β heq.2] at ht
have hlo := gridPointsBetween_sound hg hs
have hhi := gridPointsBetween_sound hg ht
refine β¨?_, ?_, hlo.2.2, hhi.2.2β© <;> unfold Nat.dist <;> omega
theorem actual_rounded_group_input_mem {Ξ± : Type*} (source target : List Ξ±) {M b P exponent : β}
(parent : TargetInterval source.length) (tau a : β) (F : β)
(parentInitial : TargetInterval target.length β β)
(child initial : Fin M β TargetInterval target.length β β) (cell : β Γ β)
(member : UnskippedBand source target parent b P exponent tau F child initial)
(hb : 1 β€ b)
(hcenter : member.center β cellRepresentativeStates target.length P F b a parentInitial
((2 : β) ^ (-(exponent : β€))) cell)
(i : Fin M) (h : β) (henvelope : member.envelope i = h) :
member.rounded i β groupRoundedStateList source target parent b exponent cell i h := by
have hspacing := bandRoundSpacing_group_spacing exponent b member.actions initial i h henvelope
have hgrid : groupRoundSpacing exponent h β£ (member.rounded i).lo β§
groupRoundSpacing exponent h β£ (member.rounded i).hi := by
simpa only [UnskippedBand.rounded, canonicalRoundedBandAction, roundedBandAction, hspacing] using
roundInterval_on_grid (bandRoundSpacing exponent b member.actions initial i)
(member.actions.head member.nonempty i)
have hwide : member.rounded i β wideChildStateList parent member.center b P i :=
finiteAssignments_sound M (wideChildStateList parent member.center b P) member.rounded member.wide_guard i
have hwideFirst := (gridStateBox_sound (by unfold seedGridSpacing; omega) (member.rounded i) hwide).1
have htheta : 0 β€ (2 : β) ^ (-(exponent : β€)) β§ (2 : β) ^ (-(exponent : β€)) β€ 1 := by
refine β¨(zpow_pos (by norm_num : (0 : β) < 2) _).le, ?_β©
rw [zpow_neg, zpow_natCast]
exact inv_le_one_of_one_leβ (one_le_powβ (by norm_num : (1 : β) β€ 2))
have hfirst := wide_firstEndpoint_near_cell cell (by unfold seedGridSpacing; omega) htheta hb
member.center (member.rounded i) ((sourceChild parent i).lo - parent.lo)
(List.mem_filter.mp hcenter).1 hwideFirst
have hgap := member.imbalance_guard i
change |rationalStateGap _ _ (member.rounded i)| β€ 2 * member.envelope i at hgap
rw [henvelope] at hgap
unfold rationalStateGap at hgap
have hgapDistance := lengthGap_guard_distance (member.rounded i)
(substring source (sourceChild parent i).lo (sourceChild parent i).hi).length h hgap
unfold groupRoundedStateList
apply gridGapStates_complete (groupRoundSpacing_pos exponent h) _ _ hgapDistance hgrid
simpa only [mul_assoc] using hfirst
theorem groupRoundedStateList_length {Ξ± : Type*} (source target : List Ξ±) {M : β}
(parent : TargetInterval source.length) (b exponent : β) (cell : β Γ β)
(i : Fin M) (h : β) (hh : 0 < h) :
((groupRoundedStateList source target parent b exponent cell i h).length : β) β€
208 * ((2 : β) ^ exponent) ^ 2 * (1 + b / h) := by
exact gridGapStates_rounded_count _ _ _ _ b h ((2 : β) ^ exponent)
(groupRoundSpacing_pos exponent h) hh (one_le_powβ (by norm_num : (1 : β) β€ 2))
(groupRoundSpacing_envelope_bound exponent h)
end EditApproximation
end OAI
|