Download data/lean/OAI/Probability/LatticeSurface/Coercivity/GridTraceGeometry.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.07 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LatticeSurface/Coercivity/GridTraceGeometry.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/LatticeSurface/Coercivity/GridTraceGeometry.lean
-
curl -L -o GridTraceGeometry.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/LatticeSurface/Coercivity/GridTraceGeometry.lean
6.07 kB
| import Mathlib | |
| import OAI.Probability.LatticeSurface.Coercivity.GridTrace | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators | |
| namespace GridTrace | |
| namespace NatGrid | |
| end NatGrid | |
| end GridTrace | |
| namespace GridTrace.NatGrid | |
| def lo (x : Vertex) (r : β) : Vertex := (x.1-r,x.2-r) | |
| def hi (N : β) (x : Vertex) (r : β) : Vertex := (min N (x.1+r),min N (x.2+r)) | |
| def box (N : β) (x : Vertex) (r : β) : Finset Vertex := rect (lo x r) (hi N x r) | |
| def square (N : β) : Finset Vertex := rect (0,0) (N,N) | |
| abbrev Edge := Vertex β Vertex | |
| def edges (l u : Vertex) : Finset Edge := | |
| ((Finset.Ico l.1 u.1) ΓΛ’ (Finset.Icc l.2 u.2)).disjSum | |
| ((Finset.Icc l.1 u.1) ΓΛ’ (Finset.Ico l.2 u.2)) | |
| def edgeGrad (v : Vertex β β) : Edge β β | |
| | .inl (i,j) => |v (i+1,j)-v (i,j)| | |
| | .inr (i,j) => |v (i,j+1)-v (i,j)| | |
| def anchor : Edge β Vertex | |
| | .inl x => x | |
| | .inr x => x | |
| lemma square_mem {N : β} {x : Vertex} : x β square N β x.1 β€ N β§ x.2 β€ N := by | |
| simp [square,rect] | |
| lemma mem_box_iff {N r : β} {x y : Vertex} : | |
| y β box N x r β y.1 β€ N β§ y.2 β€ N β§ | |
| y.1 β€ x.1+r β§ x.1 β€ y.1+r β§ y.2 β€ x.2+r β§ x.2 β€ y.2+r := by | |
| simp only [box,rect,lo,hi,Finset.mem_product,Finset.mem_Icc,le_min_iff] | |
| omega | |
| lemma box_self {N : β} {x : Vertex} (hx : x β square N) (r : β) : x β box N x r := by | |
| rw [mem_box_iff] | |
| have hx := square_mem.mp hx | |
| omega | |
| lemma box_subset {N r s : β} {x : Vertex} (hrs : r β€ s) : box N x r β box N x s := by | |
| intro y hy | |
| rw [mem_box_iff] at hy β’ | |
| omega | |
| lemma box_subset_square (N : β) (x : Vertex) (r : β) : box N x r β square N := by | |
| intro y hy | |
| exact square_mem.mpr β¨(mem_box_iff.mp hy).1,(mem_box_iff.mp hy).2.1β© | |
| lemma box_zero {N : β} {x : Vertex} (hx : x β square N) : box N x 0 = {x} := by | |
| ext y | |
| rw [mem_box_iff,Finset.mem_singleton] | |
| have hx := square_mem.mp hx | |
| constructor | |
| Β· intro h | |
| exact Prod.ext (by omega) (by omega) | |
| Β· rintro rfl;omega | |
| lemma box_full {N r : β} {x : Vertex} (hx : x β square N) (hr : N β€ r) : | |
| box N x r = square N := by | |
| ext y | |
| rw [mem_box_iff,square_mem] | |
| have hx := square_mem.mp hx | |
| omega | |
| lemma side_lower {N x r : β} (hx : x β€ N) (hr : r β€ N) : | |
| r+1 β€ (Finset.Icc (x-r) (min N (x+r))).card := by | |
| rw [Nat.card_Icc] | |
| omega | |
| lemma side_upper (N x r : β) : | |
| (Finset.Icc (x-r) (min N (x+r))).card β€ 2*r+1 := by | |
| rw [Nat.card_Icc] | |
| omega | |
| lemma box_card_lower {N r : β} {x : Vertex} (hx : x β square N) (hr : r β€ N) : | |
| (r+1)^2 β€ (box N x r).card := by | |
| have hx := square_mem.mp hx | |
| simpa [box,rect,lo,hi,pow_two] using Nat.mul_le_mul (side_lower hx.1 hr) (side_lower hx.2 hr) | |
| lemma edges_sum (v : Vertex β β) (l u : Vertex) : | |
| β e β edges l u, edgeGrad v e = gradβ v l u+gradβ v l u := by | |
| simp [edges,Finset.sum_disjSum,Finset.sum_product,edgeGrad,gradβ,gradβ] | |
| lemma edges_subset {l u l' u' : Vertex} (hl1 : l'.1 β€ l.1) (hl2 : l'.2 β€ l.2) | |
| (hu1 : u.1 β€ u'.1) (hu2 : u.2 β€ u'.2) : edges l u β edges l' u' := by | |
| intro e he | |
| cases e with | |
| | inl e => | |
| simp only [edges,Finset.inl_mem_disjSum,Finset.mem_product,Finset.mem_Ico,Finset.mem_Icc] at he β’ | |
| omega | |
| | inr e => | |
| simp only [edges,Finset.inr_mem_disjSum,Finset.mem_product,Finset.mem_Ico,Finset.mem_Icc] at he β’ | |
| omega | |
| lemma box_edges_subset (N : β) (x : Vertex) (r : β) : | |
| edges (lo x r) (hi N x r) β edges (0,0) (N,N) := by | |
| apply edges_subset <;> simp [lo,hi] | |
| lemma anchor_mem_rect {l u : Vertex} {e : Edge} (he : e β edges l u) : anchor e β rect l u := by | |
| cases e with | |
| | inl e => | |
| simp only [edges,Finset.inl_mem_disjSum,Finset.mem_product,Finset.mem_Ico,Finset.mem_Icc] at he | |
| exact Finset.mem_product.mpr β¨Finset.mem_Icc.mpr β¨he.1.1,he.1.2.leβ©,by simpa [anchor] using he.2β© | |
| | inr e => | |
| simp only [edges,Finset.inr_mem_disjSum,Finset.mem_product,Finset.mem_Ico,Finset.mem_Icc] at he | |
| exact Finset.mem_product.mpr β¨by simpa [anchor] using he.1,Finset.mem_Icc.mpr β¨he.2.1,he.2.2.leβ©β© | |
| lemma edges_card_bound (N : β) (x : Vertex) (r : β) : | |
| (edges (lo x r) (hi N x r)).card β€ 2*(2*r+1)^2 := by | |
| have hx := side_upper N x.1 r | |
| have hy := side_upper N x.2 r | |
| have hx' : (Finset.Ico (x.1-r) (min N (x.1+r))).card β€ 2*r+1 := by | |
| exact (Finset.card_le_card (by intro i hi;exact Finset.mem_Icc.mpr β¨(Finset.mem_Ico.mp hi).1,(Finset.mem_Ico.mp hi).2.leβ©)).trans hx | |
| have hy' : (Finset.Ico (x.2-r) (min N (x.2+r))).card β€ 2*r+1 := by | |
| exact (Finset.card_le_card (by intro i hi;exact Finset.mem_Icc.mpr β¨(Finset.mem_Ico.mp hi).1,(Finset.mem_Ico.mp hi).2.leβ©)).trans hy | |
| simp only [edges,lo,hi,Finset.card_disjSum,Finset.card_product] | |
| nlinarith [Nat.mul_le_mul hx' hy, Nat.mul_le_mul hx hy'] | |
| lemma dyadic_step (v : Vertex β β) {N : β} {x : Vertex} (hx : x β square N) | |
| (s : β) (hs : 1 β€ s) (hsN : s β€ N) : | |
| |avg (box N x (s-1)) v-avg (box N x (2*s-1)) v| β€ | |
| (4/(s:β))*(β e β edges (lo x (2*s-1)) (hi N x (2*s-1)), edgeGrad v e) := by | |
| have hA : (box N x (s-1)).Nonempty := β¨x,box_self hx _β© | |
| have hcard : (s:β)^2 β€ ((box N x (s-1)).card:β) := by | |
| have h := box_card_lower hx (show s-1 β€ N by omega) | |
| have he : s-1+1=s := by omega | |
| rw [he] at h | |
| exact_mod_cast h | |
| have hside (i : β) : ((Finset.Icc (i-(2*s-1)) (min N (i+(2*s-1)))).card:β) β€ 4*s := by | |
| have h := side_upper N i (2*s-1) | |
| have hh : 2*(2*s-1)+1 β€ 4*s := by omega | |
| exact_mod_cast h.trans hh | |
| have hsp : (0:β) < s := by exact_mod_cast hs | |
| have hc : (0:β) < (box N x (s-1)).card := Nat.cast_pos.mpr (Finset.card_pos.mpr hA) | |
| have h := rect_avg_bound v (lo x (2*s-1)) (hi N x (2*s-1)) | |
| (box N x (s-1)) hA (box_subset (by omega)) (4*s) (hside x.1) (hside x.2) | |
| rw [β edges_sum] at h | |
| exact h.trans (mul_le_mul_of_nonneg_right (by | |
| apply (div_le_div_iffβ hc hsp).mpr | |
| nlinarith) (Finset.sum_nonneg (fun e _ => by cases e <;> exact abs_nonneg _))) | |
| end GridTrace.NatGrid | |
| end | |
| end OAI | |