import YM.Bid.Energy /-! # Pre-L pricing for the shell test against the flat output Strengthening in L necessary for the Hessian gap/inverse. Adapted from `YM.Work.E02` which has the mathematical argument for this stronger L-control (uses `planting`), but only provides the theorem with an existential *after* L; its lemmas are file-private. Preserve that file unchanged. Would propose factoring these common lemmas/exporting pre-L from there after integration. -/ set_option autoImplicit false noncomputable section namespace YM.Push.Uniform open Function Lattice Wilson RG Axial Tree Precision Pressure Pressure.Stores Bid open scoped BigOperators Matrix.Norms.Frobenius variable {G : Gauge} {c f : Side} private lemma wider {x : Cover} {t r : ℕ} (h : x ∈ box t) (e : t ≤ r) : x ∈ box r := by obtain ⟨ha,hb⟩ := box_test.mp h exact box_test.mpr ⟨fun i => le_trans (neg_le_neg (by exact_mod_cast e)) (ha i), fun i => le_trans (hb i) (by exact_mod_cast e)⟩ private lemma box_next {x : Cover} {r : ℕ} (h : x ∈ box r) (d : Step) : x + d.vec ∈ box (r+1) := by obtain ⟨ha,hb⟩ := box_test.mp h rw [box_test]; constructor <;> intro i all_goals have h₁ := ha i have h₂ := hb i unfold Step.vec; split <;> simp only [Pi.add_apply, Pi.neg_apply, step_apply] <;> split <;> omega private lemma read_le (U : CoverConfig G) (X : Finset Cover) (x : Cover) (d : Step) (hx : x ∈ X) (he : x + d.vec ∈ X) : G.chord (d.read U x) ≤ edges X U := by have h (y : Cover) (i : Axis) (hy : y ∈ X) (hi : y + step i ∈ X) : G.chord (U (y,i)) ≤ edges X U := calc _ = perEdge X U y i := by rw [perEdge, if_pos hi] _ ≤ ∑ j, perEdge X U y j := Finset.single_le_sum (fun j _ => per_nn X U y j) (Finset.mem_univ i) _ ≤ _ := Finset.single_le_sum (f := fun z => ∑ j, perEdge X U z j) (fun z _ => Finset.sum_nonneg (fun j _ => per_nn ..)) hy rcases d with ⟨i,b|b⟩ · exact h x i hx he change G.chord (U (x-step i,i))⁻¹ ≤ _ rw [G.chord_inv] apply h · simpa only [Step.vec, ↓reduceIte, sub_eq_add_neg] using he · rwa [sub_add_cancel] /-- Coarse bound by length times the *same* macro bill, including repeated steps. -/ private lemma walk_bound (U : CoverConfig G) (r t : ℕ) (x : Cover) (w : Walk) (hx : x ∈ box t) (he : t+w.length ≤ r) : stop x w ∈ box r ∧ G.chord (travel U x w) ≤ w.length * edges (box r) U := by induction w generalizing x t with | nil => exact ⟨wider hx (by simpa using he), by simp [travel]⟩ | cons d w ih => have hb := box_next hx d simp only [List.length_cons] at he obtain ⟨hs,h⟩ := ih (t+1) _ hb (by omega) refine ⟨hs, ?_⟩ rw [travel] apply (G.chord_triangle _ _).trans refine (add_le_add (read_le U (box r) x d (wider hx (by omega)) (wider hb (by omega))) h).trans_eq ?_ simp [add_mul, add_comm] /-- Hike transport is the identity on the actual slice. -/ private lemma on_hike {S : StepData c f} (F : Forest S.ratio) {U : Config G f} (h : SliceSet S F U) (x : Site f) : travel U x (F.hike x) = 1 := by induction x using Forest.hike.induct F with | case1 i hi ih => have he := h _ ((F.trunk_mem_iff _).mpr ⟨i,hi,rfl⟩) rw [Forest.hike, dif_pos hi, travel, ih] simp [Step.read, he] | case2 i hi => rw [Forest.hike, dif_neg hi, travel] -- Form a single possibly seam-crossing walk. No replacement of the forest. private lemma root_walk {S : StepData c f} (F : Forest S.ratio) (x : Site f) (a : Axis) (U : Config G f) (h : SliceSet S F U) : ∃ w : Walk, w.length ≤ 8*S.patch.L.val+1 ∧ stop (S.ratio.embed (S.ratio.parent x)) w = S.ratio.embed (S.ratio.parent (x+step a)) ∧ travel U (S.ratio.embed (S.ratio.parent x)) w = U (x,a) := by refine ⟨Lattice.reverse (F.hike x) ++ posDir a :: F.hike (x+step a), ?_, ?_, ?_⟩ · have hlen (y) : (F.hike y).length ≤ 4*S.patch.L.val := (F.hike_lower y).trans (F.bound y) simp only [Lattice.reverse, List.length_append, List.length_map, List.length_reverse, List.length_cons] have hx := hlen x have hh := hlen (x+step a) omega · rw [← F.hike_root x, stop_append, reverse_stop, stop, Step.vec_pos, F.hike_root] rw [← F.hike_root x, travel_append, travel_reverse, reverse_stop, travel, Step.pos_read, Step.vec_pos, on_hike F h, on_hike F h, mul_one, inv_one, one_mul] private lemma stop_at (w : Walk) (x : Cover) (b : Site f) : wrap f (stop x w)+b = stop (wrap f x+b) w := by rw [wrap_stop_cover] have he (w : Walk) (y : Site f) : stop y w + b = stop (y+b) w := by induction w generalizing y with | nil => rfl | cons i w ih => rw [stop,stop,ih,add_right_comm y] exact he w _ private lemma inj_macro (P : Patch) (f : Side) (he : 100*macroR P ≤ f.val) (x y : Cover) (hx : x ∈ box (macroR P)) (hy : y ∈ box (macroR P)) (eq : wrap f x = wrap f y) : x = y := by have h (x : Cover) (hx : x ∈ box (macroR P)) (i : Axis) : -(f.val : ℤ) < 2*x i ∧ 2*x i ≤ f.val := by have hf := f.property have h₁ := (box_test.mp hx).1 i have h₂ := (box_test.mp hx).2 i change 0 < f.val at hf omega exact wrap_injOn f (h x hx) (h y hy) eq private lemma pad_root (S : StepData c f) (C : ℝ) (H : Cover → G.El) (x : Site c) (y : Cover) (U : Config G f) (p : G.El) (t : S.Choices) (h : pad S C H x y U p t) : G.chord (H (centerRoot S.patch y)*p) ≤ C*(S.patch.L.val:ℝ)^2*port S x U := by have he : S.frames U t.1 (plank x y) S.patch.center=1 := by unfold StepData.frames Patch.frame split · exact (S.patch.min_exists _).choose_spec.1 simp let e (i : S.patch.Points) := p⁻¹ * S.frames U t.1 (plank x y) i * (H (i.val+centerRoot S.patch y))⁻¹ have hk : G.chord (e S.patch.center) ≤ C*(S.patch.L.val:ℝ)^2*port S x U := (Finset.single_le_sum (fun i _ => G.chord_nonneg (e i)) (Finset.mem_univ S.patch.center)).trans h unfold e at hk rwa [he, mul_one, show S.patch.center.val = 0 from rfl, zero_add, ← mul_inv_rev, G.chord_inv] at hk def linkCost (K : KernelChoices) (C D : ℝ) (L : Side) := let l := (L.val : ℝ) let α := 2*max 1 K.predictor_cut⁻¹ * (2*C+D) (8*l+1)*(D*l)+(C*l^2 + α/l^2 + C*l^2) lemma linkCost_pos (K : KernelChoices) {C D : ℝ} (hC : 0 intro j <;> unfold y <;> rw [step_apply] <;> split <;> norm_num have hb : z=Z := by apply inj_macro S.patch f he z Z hz · have hg : 0 + centerRoot S.patch y ∈ box (macroR S.patch) := shifted S.patch y hy (Finset.mem_image_of_mem _ (center_box S.patch.radius)) rwa [zero_add] at hg rw [hstep, show i+step a=plank i y by simp [plank,y,add_comm], offsets] at hwrap exact add_right_cancel hwrap have hx : G.chord (H 0 * p 0) ≤ C*l^2*s := by have h := pad_root S C H i 0 U (p 0) t (hp _ (center_box 2)) simp only [centerRoot, smul_zero] at h exact h have hend : G.chord (H Z * p y) ≤ C*l^2*s := by have h := pad_root S C H i y U (p y) t (hp _ hy) change G.chord (H Z * p y) ≤ _ at h exact h have hpr : G.chord ((p 0)⁻¹ * Q * p y) ≤ α/l^2*s := by have hy' : (0:Cover)+step a ∈ box 2 := by rw [zero_add]; exact hy have h := indicated S C D U i t 0 a (center_box 2) H _ _ (hp _ (center_box 2)) (hp _ hy') hH simp only [plank, map_zero, zero_add] at h -- keep prediction itself on this S and t change (S.patch.L.val:ℝ)^2 * G.chord ((p 0)⁻¹*Q*p y) ≤ _ at h rw [hk] at h apply le_of_mul_le_mul_left _ (show 0