Download data/lean/OAI/Combinatorics/EditApproximation/Geometry/CellGroupSelection.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 11.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Geometry/CellGroupSelection.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditApproximation/Geometry/CellGroupSelection.lean
-
curl -L -o CellGroupSelection.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Geometry/CellGroupSelection.lean
11.4 kB
| import OAI.Combinatorics.EditApproximation.Geometry.GroupCells | |
| import OAI.Combinatorics.EditApproximation.Geometry.BandGroupSampling | |
| import OAI.Combinatorics.EditApproximation.Numerics.RationalWideStep | |
| import OAI.Combinatorics.EditApproximation.Definitions | |
| namespace OAI | |
| /-! Literal unskipped groups of whole cells and their selected wide actions. -/ | |
| namespace EditApproximation | |
| open Finset | |
| theorem cellUnskippedBands_length_le {Ξ± : Type*} (source target : List Ξ±) {M : β} | |
| (parent : TargetInterval source.length) (b P F thetaExponent : β) (tau a : β) | |
| (parentInitial : TargetInterval target.length β β) | |
| (child initial : Fin M β TargetInterval target.length β β) (cell : β Γ β) | |
| (hb : β e : β, b = 2 ^ e) (hP : β e : β, P = 2 ^ e) : | |
| (cellUnskippedBands source target parent b P F thetaExponent tau a parentInitial child initial cell).length β€ | |
| (P + 1) ^ 2 := by | |
| have htheta : 0 β€ (2 : β) ^ (-(thetaExponent : β€)) β§ | |
| (2 : β) ^ (-(thetaExponent : β€)) β€ 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)) | |
| exact (List.length_filterMap_le _ _).trans | |
| (cellRepresentativeStates_length_le a parentInitial _ cell htheta hb hP) | |
| namespace UnskippedBand | |
| theorem canonicalRounded_congr {ny M : β} (thetaExponent b : β) | |
| (band band' : List (Fin M β TargetInterval ny)) (heq : band = band') | |
| (hnonempty : band β []) (hnonempty' : band' β []) | |
| (initial : Fin M β TargetInterval ny β β) : | |
| canonicalRoundedBandAction thetaExponent b band hnonempty initial = | |
| canonicalRoundedBandAction thetaExponent b band' hnonempty' initial := by | |
| cases heq | |
| rfl | |
| theorem rationalAction_wide_mem {Ξ± : Type*} {source target : List Ξ±} {M b P thetaExponent : β} | |
| {parent : TargetInterval source.length} {tau F : β} | |
| {child initial : Fin M β TargetInterval target.length β β} | |
| (member : UnskippedBand source target parent b P thetaExponent tau F child initial) | |
| (representatives : List (β Γ TargetInterval target.length)) (hrep : (b, member.center) β representatives) : | |
| member.rationalAction β rationalActualWideActions parent representatives P := by | |
| apply List.mem_flatMap.mpr | |
| exact β¨(b, member.center), hrep, List.mem_map.mpr β¨member.rounded, member.wide_guard, rflβ©β© | |
| theorem rounded_cost {Ξ± : Type*} {source target : List Ξ±} {M b P thetaExponent : β} | |
| {parent : TargetInterval source.length} {tau F : β} | |
| {child initial : Fin M β TargetInterval target.length β β} | |
| (member : UnskippedBand source target parent b P thetaExponent tau F child initial) | |
| (htau : 0 < tau) (value : Fin M β TargetInterval target.length β β) | |
| (action : Fin M β TargetInterval target.length) (haction : action β member.actions) | |
| (delta L : β) (hL : 0 β€ L) | |
| (hspatial : β i s t, value i s β€ (1 + delta) * value i t + L * targetEndpointDistance s t) : | |
| rationalEndpointActionValue member.center member.rounded value β€ | |
| (1 + delta) * (β i, value i (action i)) + | |
| (6 * L + 2) * (2 : β) ^ (-(thetaExponent : β€)) * β i, member.envelope i := by | |
| have hnonempty := member.nonempty | |
| by_cases hempty : wideActionList M parent member.center b P = [] | |
| Β· simp only [representativeBandActions, dite_eq_left hempty] at hnonempty | |
| exact False.elim (hnonempty rfl) | |
| Β· by_cases hZ : 0 < rationalWideActionMinimum parent member.center b P hempty child | |
| Β· have hband : member.actions = computedBandActions parent member.center b P tau | |
| ((2 : β) ^ (-(thetaExponent : β€))) | |
| (rationalStateGap (substring source parent.lo parent.hi) target member.center / | |
| rationalWideActionMinimum parent member.center b P hempty child) child := by | |
| simp only [actions, representativeBandActions, dite_eq_right hempty, ite_eq_left hZ] | |
| have hne : computedBandActions parent member.center b P tau | |
| ((2 : β) ^ (-(thetaExponent : β€))) | |
| (rationalStateGap (substring source parent.lo parent.hi) target member.center / | |
| rationalWideActionMinimum parent member.center b P hempty child) child β [] := by | |
| rw [β hband] | |
| exact member.nonempty | |
| have ha := haction | |
| rw [hband] at ha | |
| have hcost := canonicalRoundedBandAction_cost parent member.center thetaExponent b P tau _ htau | |
| child initial value hne action ha delta L hL hspatial | |
| have hround := canonicalRounded_congr thetaExponent b _ _ hband member.nonempty hne initial | |
| change member.rounded = _ at hround | |
| rw [hround] | |
| simpa only [envelope, hband] using hcost | |
| Β· simp only [representativeBandActions, dite_eq_right hempty, ite_eq_right hZ] at hnonempty | |
| exact False.elim (hnonempty rfl) | |
| end UnskippedBand | |
| theorem chooseCellGroupAction_wide_mem {Ξ± : Type*} (source target : List Ξ±) {M : β} | |
| (parent : TargetInterval source.length) (N b P F thetaExponent Q : β) (tau a : β) | |
| (parentInitial : TargetInterval target.length β β) | |
| (child initial value : Fin M β TargetInterval target.length β β) (cell : β Γ β) | |
| (draw : β scale : Fin (groupDyadicScales M b F).length, | |
| Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) β Fin M) | |
| (hb : b β dyadicScales N) (action : RationalBellmanAction | |
| (TargetInterval target.length) (Fin M Γ TargetInterval target.length) M) | |
| (hselected : chooseCellGroupAction source target parent b P F thetaExponent Q tau a | |
| parentInitial child initial value cell draw = some action) : | |
| action β rationalActualWideActions parent (representativeList N P F a parentInitial) P := by | |
| unfold chooseCellGroupAction at hselected | |
| dsimp only at hselected | |
| split_ifs at hselected with hempty | |
| have heq := Option.some.inj hselected | |
| rw [β heq] | |
| apply UnskippedBand.rationalAction_wide_mem | |
| apply cellRepresentativeStates_mem_representatives a parentInitial _ cell _ hb | |
| apply (unskippedBandList_mem_iff _ _).mp | |
| exact (chooseUnskippedGroup_spec Q value _ hempty draw).1 | |
| theorem group_rounding_coefficient {F L : β} (hF : 1 β€ F) (hL : 2 β€ L) : | |
| (6 * L + 2) * (64 * F) + 2 * L β€ 512 * L * F := by | |
| have hF0 : 0 β€ F := by linarith only [hF] | |
| have hL0 : 0 β€ L := by linarith only [hL] | |
| have hlarge := mul_le_mul_of_nonneg_right hL (mul_nonneg (by norm_num : (0 : β) β€ 64) hF0) | |
| have hcell := mul_le_mul_of_nonneg_left hF (mul_nonneg (by norm_num : (0 : β) β€ 2) hL0) | |
| have hprod := mul_nonneg hL0 hF0 | |
| nlinarith only [hlarge, hcell, hprod] | |
| /-- Estimated minimization in an actual whole cell gives the group cone | |
| bound simultaneously for every action of the specified member's band. -/ | |
| theorem chooseCellGroup_cone_bound {Ξ± : Type*} (source target : List Ξ±) {M : β} | |
| (parent : TargetInterval source.length) (b P F thetaExponent Q : β) (tau a : β) | |
| (parentInitial : TargetInterval target.length β β) | |
| (child initial value : Fin M β TargetInterval target.length β β) (cell : β Γ β) | |
| (hnonempty : cellUnskippedBands source target parent b P F thetaExponent tau a | |
| parentInitial child initial cell β []) | |
| (draw : β scale : Fin (groupDyadicScales M b F).length, | |
| Fin (groupSampleCount M Q b (groupDyadicScaleAt M b F scale)) β Fin M) | |
| (specified : UnskippedBand source target parent b P thetaExponent tau F child initial) | |
| (hspecified : specified β cellUnskippedBands source target parent b P F thetaExponent tau a | |
| parentInitial child initial cell) | |
| (delta L gamma : β) (hF : 1 β€ F) (hL : 2 β€ L) (htau : 0 < tau) | |
| (hspatial : β i s t, value i s β€ (1 + delta) * value i t + L * targetEndpointDistance s t) | |
| (haccurate : β member β cellUnskippedBands source target parent b P F thetaExponent tau a | |
| parentInitial child initial cell, | |
| |dyadicUnskippedGroupEstimate Q value member draw - | |
| rationalEndpointActionValue member.center member.rounded value| β€ gamma * b) | |
| (action : Fin M β TargetInterval target.length) (haction : action β specified.actions) | |
| (q : TargetInterval target.length) : | |
| let selected := chooseUnskippedGroup Q value | |
| (cellUnskippedBands source target parent b P F thetaExponent tau a parentInitial child initial cell) | |
| hnonempty draw | |
| rationalActionValue (fun q r => targetEndpointDistance q r) L (fun is => value is.1 is.2) q | |
| selected.rationalAction β€ | |
| L * targetEndpointDistance q specified.center + (1 + delta) * (β i, value i (action i)) + | |
| (2 * gamma + 512 * L * F * (2 : β) ^ (-(thetaExponent : β€))) * b := by | |
| let members := cellUnskippedBands source target parent b P F thetaExponent tau a | |
| parentInitial child initial cell | |
| let selected := chooseUnskippedGroup Q value members hnonempty draw | |
| have hselected : selected β members := (chooseUnskippedGroup_spec Q value members hnonempty draw).1 | |
| have hcost := chooseUnskippedGroup_cost_le Q value members hnonempty draw specified hspecified | |
| (gamma * b) haccurate | |
| change rationalEndpointActionValue selected.center selected.rounded value β€ | |
| rationalEndpointActionValue specified.center specified.rounded value + 2 * (gamma * b) at hcost | |
| have hrounded := specified.rounded_cost htau value action haction delta L (by linarith only [hL]) hspatial | |
| have hcenterCell (member : UnskippedBand source target parent b P thetaExponent tau F child initial) | |
| (hm : member β members) : member.center β | |
| cellTargetStates target.length (seedGridSpacing b P) ((2 : β) ^ (-(thetaExponent : β€)) * b) cell := by | |
| have hc := (unskippedBandList_mem_iff _ member).mp hm | |
| exact (List.mem_filter.mp hc).1 | |
| have hdiam := cellTargetStates_diameter cell (by unfold seedGridSpacing; omega) | |
| specified.center selected.center (hcenterCell specified hspecified) (hcenterCell selected hselected) | |
| have htriangle : (targetEndpointDistance q selected.center : β) β€ | |
| targetEndpointDistance q specified.center + targetEndpointDistance specified.center selected.center := by | |
| have h := targetEndpointDistance_triangle q specified.center selected.center | |
| have h' : (targetEndpointDistance q selected.center : β) β€ | |
| targetEndpointDistance specified.center selected.center + targetEndpointDistance q specified.center := by | |
| exact_mod_cast h | |
| simpa only [add_comm] using h' | |
| have hL0 : 0 β€ L := by linarith only [hL] | |
| have hdist := mul_le_mul_of_nonneg_left (htriangle.trans (add_le_add_right hdiam _)) hL0 | |
| have htheta : 0 β€ (2 : β) ^ (-(thetaExponent : β€)) := (zpow_pos (by norm_num : (0 : β) < 2) _).le | |
| have hsum := mul_le_mul_of_nonneg_left specified.sum_guard | |
| (mul_nonneg (by linarith only [hL0] : 0 β€ 6 * L + 2) htheta) | |
| change (6 * L + 2) * (2 : β) ^ (-(thetaExponent : β€)) * (β i, specified.envelope i) β€ | |
| (6 * L + 2) * (2 : β) ^ (-(thetaExponent : β€)) * (64 * F * b) at hsum | |
| have hcoef := mul_le_mul_of_nonneg_right (group_rounding_coefficient (F := (F : β)) (L := L) | |
| (by exact_mod_cast hF) hL) | |
| (mul_nonneg htheta (Nat.cast_nonneg (Ξ± := β) b)) | |
| dsimp only [rationalActionValue, UnskippedBand.rationalAction] | |
| dsimp only [rationalEndpointActionValue] at hcost hrounded | |
| nlinarith only [hcost, hrounded, hdist, hsum, hcoef] | |
| end EditApproximation | |
| end OAI | |