cfahlgren1's picture
download
raw
26.2 kB
import OAI.Analysis.NodalLength.Lattice
namespace OAI
noncomputable section
open scoped ContDiff Bundle ENNReal
open Bundle Manifold MeasureTheory
open scoped ContDiff ENNReal Topology
open MeasureTheory Filter Set
open scoped Topology ENNReal
open MeasureTheory Filter Set
open scoped Topology ENNReal ContDiff
open MeasureTheory Filter Set
open scoped Topology ENNReal ContDiff
open MeasureTheory Filter Set
open scoped Topology ENNReal ContDiff
open MeasureTheory Filter Set
open scoped Topology ContDiff
open Filter Set
open scoped Topology ContDiff
open Filter Set
open scoped Topology ENNReal
open Filter Set MeasureTheory TopologicalSpace
open scoped Topology ContDiff
open Filter Set
open scoped Topology ENNReal
open Filter Set MeasureTheory TopologicalSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory TopologicalSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory Laplacian
open scoped Topology ENNReal ContDiff ComplexConjugate
open Filter Set MeasureTheory Laplacian
open scoped Topology ENNReal ContDiff ComplexConjugate
open Filter Set MeasureTheory Laplacian
open scoped Topology ENNReal NNReal
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal
open Set MeasureTheory Filter
open scoped Topology ENNReal
open Filter Set MeasureTheory
open scoped Topology ENNReal
open Filter Set MeasureTheory
open scoped Topology ENNReal
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ContDiff Laplacian
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory
open scoped Topology ENNReal ContDiff CompactlySupported
open Set MeasureTheory
open scoped Topology ENNReal ContDiff CompactlySupported
open Set MeasureTheory
open scoped Topology ENNReal ContDiff CompactlySupported
open Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ContDiff Laplacian
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff Convolution
open Filter Set MeasureTheory
open scoped Topology ContDiff Convolution
open Filter Set MeasureTheory
open scoped Topology ContDiff Convolution
open Filter Set MeasureTheory
open scoped Topology ContDiff Convolution
open Filter Set MeasureTheory
open scoped Topology ContDiff Convolution
open Filter Set MeasureTheory
open scoped Topology ContDiff Convolution ENNReal
open Filter Set MeasureTheory
open scoped Topology ContDiff ENNReal
open Filter Set MeasureTheory
open scoped Topology ContDiff ENNReal
open Filter Set MeasureTheory
open scoped Topology ContDiff ENNReal
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff ENNReal
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff ENNReal
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory Function
open scoped Topology
open Filter Set MeasureTheory
open scoped Topology ENNReal
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal
open Filter Set MeasureTheory
open scoped Topology ENNReal
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped BigOperators
open Filter Set MeasureTheory
open scoped BigOperators
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff Convolution
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology
open Filter Set MeasureTheory
open scoped Topology ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff BigOperators
open Filter Set MeasureTheory InnerProductSpace
open scoped Topology ENNReal ContDiff BigOperators
open Filter Set MeasureTheory InnerProductSpace
open scoped BigOperators
open MeasureTheory
open scoped BigOperators
open Set MeasureTheory
open scoped BigOperators
open scoped Classical
open scoped BigOperators Topology ENNReal
open Set MeasureTheory
open scoped BigOperators
open scoped Topology ENNReal ContDiff
open Filter Set MeasureTheory InnerProductSpace
open scoped BigOperators Classical Topology
open Filter Set MeasureTheory
open scoped BigOperators Classical Topology
open Filter Set MeasureTheory
open scoped BigOperators
open Set
open scoped BigOperators Topology
open Set MeasureTheory
open scoped BigOperators
open Set
open scoped BigOperators symmDiff
open Set
namespace SharpNodal.Grid
@[ext] structure Cell where
level : ℕ
pos : Point
deriving DecidableEq
def Cell.side (A : ℕ) (Q : Cell) : ℕ := A^Q.level
def Cell.points (A : ℕ) (Q : Cell) : Finset Point := square (Q.side A) Q.pos
def Cell.near (A D : ℕ) (Q : Cell) : Finset Point := neighborhood D (Q.side A) Q.pos
@[simp] lemma Cell.card_points (A : ℕ) (Q : Cell) : (Q.points A).card=(Q.side A)^2 := card_square _ _
@[simp] lemma Cell.card_near (A D : ℕ) (Q : Cell) : (Q.near A D).card=((2*D+1)*Q.side A)^2 := card_neighborhood _ _ _
lemma Cell.side_pos {A : ℕ} (hA : 0<A) (Q : Cell) : 0<Q.side A := pow_pos hA _
lemma Cell.side_mono {A : ℕ} (hA : 1≤A) {Q F : Cell} (h : Q.level≤F.level) : Q.side A≤F.side A :=
Nat.pow_le_pow_right hA h
lemma square_subset_iff {s t : ℕ} (hs : 0<s) {p q : Point} :
square s p⊆square t q ↔ ∀i,q i*t≤p i*s ∧ (p i+1)*s≤(q i+1)*t := by
have hs' : (0:ℤ)<s := by exact_mod_cast hs
constructor
· intro h i
have hlo : (fun j =>p j*s)∈square s p := mem_square.mpr (fun j =>by constructor <;> nlinarith)
have hhi : (fun j =>(p j+1)*s-1)∈square s p := mem_square.mpr (fun j =>by constructor <;> nlinarith)
exact ⟨(mem_square.mp (h hlo) i).1,by have hh:=(mem_square.mp (h hhi) i).2; omega⟩
· intro h z hz
apply mem_square.mpr
intro i
exact ⟨(h i).1.trans (mem_square.mp hz i).1,(mem_square.mp hz i).2.trans_le (h i).2⟩
lemma neighborhood_mono {s t D : ℕ} {p q : Point} (hst : s≤t)
(hbox : ∀i,q i*t≤p i*s ∧ (p i+1)*s≤(q i+1)*t) :
neighborhood D s p⊆neighborhood D t q := by
have hst' : (s:ℤ)≤t := by exact_mod_cast hst
have hD : (0:ℤ)≤D := Int.natCast_nonneg D
apply box_mono <;> intro i <;> have hh:=hbox i <;> nlinarith
lemma Cell.near_mono {A D : ℕ} (hA : 0<A) {Q F : Cell}
(hlevel : Q.level≤F.level) (hsub : Q.points A⊆F.points A) : Q.near A D⊆F.near A D := by
exact neighborhood_mono (Q.side_mono hA hlevel)
((square_subset_iff (Q.side_pos hA)).mp hsub)
lemma Cell.div_of_mem {A : ℕ} (hA : 0<A) {Q : Cell} {z : Point} (hz : z∈Q.points A)
{n : ℕ} (hn : Q.level≤n) (i : Fin 2) : z i/(A:ℤ)^n=Q.pos i/(A:ℤ)^(n-Q.level) := by
have hh:=((mem_square_div (Q.side_pos hA)).mp hz) i
have he : n=Q.level+(n-Q.level) := by omega
rw [he,pow_add,←Int.ediv_ediv_of_nonneg (by positivity : (0:ℤ)≤(A:ℤ)^Q.level)]
simpa only [Nat.add_sub_cancel_left,Cell.side,Nat.cast_pow] using congrArg (fun x : ℤ =>x/(A:ℤ)^(n-Q.level)) hh
lemma Cell.subset_of_intersection {A : ℕ} (hA : 0<A) {Q F : Cell}
(hlevel : Q.level≤F.level) {z : Point} (hzQ : z∈Q.points A) (hzF : z∈F.points A) :
Q.points A⊆F.points A := by
intro y hy
apply (mem_square_div (F.side_pos hA)).mpr
intro i
have hy':=Q.div_of_mem hA hy hlevel i
have hz':=Q.div_of_mem hA hzQ hlevel i
have hf:=((mem_square_div (F.side_pos hA)).mp hzF) i
simpa only [Cell.side,Nat.cast_pow] using hy'.trans (hz'.symm.trans hf)
lemma Cell.subset_or_disjoint {A : ℕ} (hA : 0<A) {Q F : Cell}
(hlevel : Q.level≤F.level) : Q.points A⊆F.points A ∨ Disjoint (Q.points A) (F.points A) := by
by_cases hh : Disjoint (Q.points A) (F.points A)
· exact Or.inr hh
· obtain ⟨z,hzQ,hzF⟩:=Finset.not_disjoint_iff.mp hh
exact Or.inl (Cell.subset_of_intersection hA hlevel hzQ hzF)
lemma Cell.equal_level_eq_of_intersection {A : ℕ} (hA : 0<A) {Q F : Cell}
(hlevel : Q.level=F.level) {z : Point} (hzQ : z∈Q.points A) (hzF : z∈F.points A) : Q=F := by
have hp : Q.pos=F.pos := by
funext i
have hq:=((mem_square_div (Q.side_pos hA)).mp hzQ) i
have hf:=((mem_square_div (F.side_pos hA)).mp hzF) i
rw [Cell.side,hlevel] at hq
exact hq.symm.trans hf
exact Cell.ext hlevel hp
lemma square_subset_large_neighborhood {s t D : ℕ} {p q : Point} (hst : s≤t)
{y : Point} (hy : y∈neighborhood D s p) (hy' : y∈neighborhood D t q) :
square s p⊆neighborhood (2*D+1) t q := by
have hst' : (s:ℤ)≤t := by exact_mod_cast hst
have hD : (0:ℤ)≤D := Int.natCast_nonneg D
intro z hz
apply mem_neighborhood.mpr
intro i
have h1:=mem_neighborhood.mp hy i
have h2:=mem_neighborhood.mp hy' i
have h3:=mem_square.mp hz i
push_cast
constructor <;> nlinarith
end SharpNodal.Grid
namespace SharpNodal.Grid
def Cell.ancestors (A : ℕ) (F : Finset Cell) (Q : Cell) : Finset Cell :=
F.filter (fun P =>Q.level<P.level ∧ Q.points A⊆P.points A)
def Cell.rank (A : ℕ) (F : Finset Cell) (Q : Cell) : ℕ := 1+(Q.ancestors A F).card
def Cell.largerAt (A : ℕ) (F : Finset Cell) (Q : Cell) (x : Point) : Finset Cell :=
F.filter (fun P =>Q.level<P.level ∧ x∈P.points A)
def Cell.smallerAt (A : ℕ) (F : Finset Cell) (Q : Cell) (x : Point) : Finset Cell :=
F.filter (fun P =>P.level<Q.level ∧ x∈P.points A)
def Cell.mismatch (A : ℕ) (F : Finset Cell) (Q : Cell) (x : Point) : ℕ :=
(Q.ancestors A F ∆ Q.largerAt A F x).card
def totalAt (A : ℕ) (F : Finset Cell) (x : Point) : ℕ := (F.filter (fun Q =>x∈Q.points A)).card
lemma Cell.rank_strict {A : ℕ} {F : Finset Cell} {Q P : Cell} (hP : P∈F)
(hlev : Q.level<P.level) (hsub : Q.points A⊆P.points A) : P.rank A F<Q.rank A F := by
have hsubset : P.ancestors A F⊆Q.ancestors A F := by
intro S hS
rcases Finset.mem_filter.mp hS with ⟨hS,hlevS,hsubS⟩
exact Finset.mem_filter.mpr ⟨hS,hlev.trans hlevS,hsub.trans hsubS⟩
have hne : P.ancestors A F≠Q.ancestors A F := by
intro he
have hh:P∈Q.ancestors A F := Finset.mem_filter.mpr ⟨hP,hlev,hsub⟩
rw [←he] at hh
exact (lt_irrefl P.level) (Finset.mem_filter.mp hh).2.1
have hc:=Finset.card_lt_card (Finset.ssubset_iff_subset_ne.mpr ⟨hsubset,hne⟩)
exact Nat.add_lt_add_left hc 1
lemma Cell.same_rank_disjoint {A : ℕ} (hA : 0<A) {F : Finset Cell} {Q P : Cell}
(hQ : Q∈F) (hP : P∈F) (hr : Q.rank A F=P.rank A F) (hne : Q≠P) :
Disjoint (Q.points A) (P.points A) := by
apply Finset.disjoint_left.mpr
intro z hzQ hzP
rcases lt_trichotomy Q.level P.level with hlev|hlev|hlev
· have hh:=Cell.rank_strict hP hlev (Cell.subset_of_intersection hA hlev.le hzQ hzP)
omega
· exact hne (Cell.equal_level_eq_of_intersection hA hlev hzQ hzP)
· have hh:=Cell.rank_strict hQ hlev (Cell.subset_of_intersection hA hlev.le hzP hzQ)
omega
lemma card_le_add_symmDiff {X : Type*} [DecidableEq X] (S T : Finset X) :
S.card≤T.card+(S ∆ T).card := by
have hsub : S⊆T∪(S ∆ T) := by
intro x hx
by_cases ht:x∈T
· exact Finset.mem_union_left _ ht
· exact Finset.mem_union_right _ (by simp [Finset.mem_symmDiff,hx,ht])
exact (Finset.card_le_card hsub).trans (Finset.card_union_le _ _)
lemma Cell.rank_control {A J : ℕ} (hA : 0<A) (F : Finset Cell) (Q : Cell) (x : Point)
(hsmall : (Q.smallerAt A F x).card≤J) :
Q.rank A F≤totalAt A F x+Q.mismatch A F x+J+1 ∧
totalAt A F x≤Q.rank A F+Q.mismatch A F x+J+1 := by
have ha:=card_le_add_symmDiff (Q.ancestors A F) (Q.largerAt A F x)
have hb:=card_le_add_symmDiff (Q.largerAt A F x) (Q.ancestors A F)
rw [symmDiff_comm] at hb
let Equal:=F.filter (fun P =>Q.level=P.level ∧ x∈P.points A)
have he : Equal.card≤1 := by
apply Finset.card_le_one.mpr
intro P hP S hS
rcases Finset.mem_filter.mp hP with ⟨_,hP,hxP⟩
rcases Finset.mem_filter.mp hS with ⟨_,hS,hxS⟩
exact Cell.equal_level_eq_of_intersection hA (hP.symm.trans hS) hxP hxS
have hsum : totalAt A F x=(Q.largerAt A F x).card+Equal.card+(Q.smallerAt A F x).card := by
simp only [totalAt,Cell.largerAt,Cell.smallerAt,Equal,Finset.card_eq_sum_ones,Finset.sum_filter]
rw [←Finset.sum_add_distrib,←Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro P hP
by_cases hx : x∈P.points A
· simp only [hx,and_true,ite_true]
split_ifs <;> omega
· simp only [hx,and_false,ite_false,add_zero]
dsimp only [Cell.rank,Cell.mismatch]
omega
end SharpNodal.Grid
noncomputable section
open scoped BigOperators
open Set
namespace SharpNodal.Grid
theorem finite_greedy {Q X : Type*} [DecidableEq Q] [DecidableEq X]
(F : Finset Q) (size : Q → ℕ) (B : Q → Finset X)
(hB : ∀q∈F,(B q).Nonempty) :
∃S : Finset Q,S⊆F ∧ (S : Set Q).Pairwise (fun q p =>Disjoint (B q) (B p)) ∧
∀q∈F,∃p∈S,size q ≤ size p ∧ ¬Disjoint (B q) (B p) := by
classical
induction F using Finset.strongInductionOn with
| _ F ih =>
by_cases hF : F.Nonempty
· obtain ⟨p,hp,hmax⟩:=Finset.exists_max_image F size hF
let G:=F.filter (fun q =>Disjoint (B q) (B p))
have hGp : p∉G := by
intro hh
have hd:Disjoint (B p) (B p):=(Finset.mem_filter.mp hh).2
obtain ⟨x,hx⟩:=hB p hp
exact Finset.disjoint_left.mp hd hx hx
have hGF : G⊂F := Finset.ssubset_iff_subset_ne.mpr ⟨Finset.filter_subset _ _,by
intro he
exact hGp (he.symm ▸ hp)⟩
obtain ⟨S,hSG,hdis,hcover⟩:=ih G hGF (fun q hq =>hB q (Finset.mem_filter.mp hq).1)
refine ⟨insert p S,?_,?_,?_⟩
· intro q hq
rcases Finset.mem_insert.mp hq with rfl|hq
· exact hp
· exact (Finset.mem_filter.mp (hSG hq)).1
· intro q hq q' hq' hne
by_cases he : q=p
· subst q
have hqS : q'∈S := (Finset.mem_insert.mp hq').resolve_left (Ne.symm hne)
exact ((Finset.mem_filter.mp (hSG hqS)).2).symm
· have hqS : q∈S := (Finset.mem_insert.mp hq).resolve_left he
by_cases he' : q'=p
· subst q'
exact (Finset.mem_filter.mp (hSG hqS)).2
· have hq'S : q'∈S := (Finset.mem_insert.mp hq').resolve_left he'
exact hdis hqS hq'S hne
· intro q hq
by_cases hqG : q∈G
· obtain ⟨q',hq',hs,hd⟩:=hcover q hqG
exact ⟨q',Finset.mem_insert_of_mem hq',hs,hd⟩
· refine ⟨p,Finset.mem_insert_self _ _,hmax q hq,?_⟩
exact fun hd =>hqG (Finset.mem_filter.mpr ⟨hq,hd⟩)
· have he : F=∅ := Finset.not_nonempty_iff_eq_empty.mp hF
subst F
exact ⟨∅,by simp,by simp,by simp⟩
lemma disjoint_cover_card {Q X : Type*} [DecidableEq Q] [DecidableEq X]
(F S : Finset Q) (C B : Q → Finset X)
(hdis : (F : Set Q).Pairwise (fun q p =>Disjoint (C q) (C p)))
(hcover : ∀q∈F,∃p∈S,C q⊆B p) :
(∑q∈F,(C q).card)≤∑p∈S,(B p).card := by
calc
_=(F.biUnion C).card := (Finset.card_biUnion hdis).symm
_≤(S.biUnion B).card := Finset.card_le_card (by
intro x hx
obtain ⟨q,hq,hx⟩:=Finset.mem_biUnion.mp hx
obtain ⟨p,hp,hsub⟩:=hcover q hq
exact Finset.mem_biUnion.mpr ⟨p,hp,hsub hx⟩)
_≤_ := Finset.card_biUnion_le
end SharpNodal.Grid
namespace SharpNodal.Grid
theorem rank_selection {A D : ℕ} (hA : 0<A) (F : Finset Cell) :
∃S : Finset Cell,S⊆F ∧
(∀Q∈S,∀P∈S,Q.rank A F=P.rank A F → Q≠P → Disjoint (Q.near A D) (P.near A D)) ∧
(∑Q∈F,(Q.points A).card)≤(4*D+3)^2*∑Q∈S,(Q.points A).card := by
classical
let R:=F.image (Cell.rank A F)
let Fr : ℕ → Finset Cell := fun n =>F.filter (fun Q =>Q.rank A F=n)
have hchoose (n : ℕ) := finite_greedy (Fr n) Cell.level (Cell.near A D) (fun Q _ =>
Finset.card_pos.mp (by rw [Cell.card_near]; exact pow_pos (Nat.mul_pos (by omega) (Q.side_pos hA)) 2))
choose S hsub hdis hcover using hchoose
let T:=R.biUnion S
have hTF : T⊆F := by
intro Q hQ
obtain ⟨r,hr,hQ⟩:=Finset.mem_biUnion.mp hQ
exact (Finset.mem_filter.mp (hsub r hQ)).1
have hTin (Q : Cell) (hQ : Q∈T) : Q∈S (Q.rank A F) := by
obtain ⟨r,hr,hQ⟩:=Finset.mem_biUnion.mp hQ
have he:= (Finset.mem_filter.mp (hsub r hQ)).2
exact he.symm ▸ hQ
have hSS : (R : Set ℕ).Pairwise (fun r s =>Disjoint (S r) (S s)) := by
intro r hr s hs hne
apply Finset.disjoint_left.mpr
intro Q hQ hQ'
have he:=(Finset.mem_filter.mp (hsub r hQ)).2
have he':=(Finset.mem_filter.mp (hsub s hQ')).2
exact hne (he.symm.trans he')
have hbound (r : ℕ) : (∑Q∈Fr r,(Q.points A).card)≤(4*D+3)^2*∑Q∈S r,(Q.points A).card := by
have hpd : (Fr r : Set Cell).Pairwise (fun Q P =>Disjoint (Q.points A) (P.points A)) := by
intro Q hQ P hP hne
rcases Finset.mem_filter.mp hQ with ⟨hQ,hrQ⟩
rcases Finset.mem_filter.mp hP with ⟨hP,hrP⟩
exact Cell.same_rank_disjoint hA hQ hP (hrQ.trans hrP.symm) hne
have hh:=disjoint_cover_card (Fr r) (S r) (Cell.points A) (Cell.near A (2*D+1)) hpd (by
intro Q hQ
obtain ⟨P,hP,hlev,hmeet⟩:=hcover r Q hQ
obtain ⟨y,hyQ,hyP⟩:=Finset.not_disjoint_iff.mp hmeet
exact ⟨P,hP,square_subset_large_neighborhood (Q.side_mono hA hlev) hyQ hyP⟩)
convert hh using 1
rw [Finset.mul_sum]
apply Finset.sum_congr rfl
intro Q hQ
rw [Cell.card_near,Cell.card_points]
ring
refine ⟨T,hTF,?_,?_⟩
· intro Q hQ P hP hr hne
apply hdis (Q.rank A F) (hTin Q hQ) _ hne
rw [hr]
exact hTin P hP
· have hfib:=Finset.sum_fiberwise_of_maps_to (s:=F) (t:=R)
(fun Q hQ =>Finset.mem_image_of_mem (Cell.rank A F) hQ) (fun Q =>(Q.points A).card)
calc
_=∑r∈R,∑Q∈Fr r,(Q.points A).card := hfib.symm
_≤∑r∈R,(4*D+3)^2*∑Q∈S r,(Q.points A).card := Finset.sum_le_sum (fun r _ =>hbound r)
_=(4*D+3)^2*∑r∈R,∑Q∈S r,(Q.points A).card := (Finset.mul_sum _ _ _).symm
_=_ := by rw [←Finset.sum_biUnion hSS]
end SharpNodal.Grid
namespace SharpNodal.Grid
def expanded (s h : ℕ) (p : Point) : Finset Point :=
box (fun i =>p i*s-h) (fun i =>(p i+1)*s+h)
def strip (s h : ℕ) (p : Point) (i : Fin 2) (upper : Bool) : Finset Point :=
box (fun j =>if upper && decide (j=i) then (p j+1)*s-h else p j*s-h)
(fun j =>if !upper && decide (j=i) then p j*s+h else (p j+1)*s+h)
def border (s h : ℕ) (p : Point) : Finset Point :=
(Finset.univ : Finset (Fin 2 × Bool)).biUnion (fun ib =>strip s h p ib.1 ib.2)
lemma card_strip (s h : ℕ) (p : Point) (i : Fin 2) (upper : Bool) :
(strip s h p i upper).card=2*h*(s+2*h) := by
have hlow (j : Fin 2) : (p j*(s:ℤ)+h-(p j*s-h)).toNat=2*h := by
have he:p j*(s:ℤ)+h-(p j*s-h)=((2*h:ℕ):ℤ) := by push_cast; ring
rw [he,Int.toNat_natCast]
have hhigh (j : Fin 2) : ((p j+1)*(s:ℤ)+h-((p j+1)*s-h)).toNat=2*h := by
have he:(p j+1)*(s:ℤ)+h-((p j+1)*s-h)=((2*h:ℕ):ℤ) := by push_cast; ring
rw [he,Int.toNat_natCast]
have hfull (j : Fin 2) : ((p j+1)*(s:ℤ)+h-(p j*s-h)).toNat=s+2*h := by
have he:(p j+1)*(s:ℤ)+h-(p j*s-h)=((s+2*h:ℕ):ℤ) := by push_cast; ring
rw [he,Int.toNat_natCast]
rw [strip,card_box,Fin.prod_univ_two]
fin_cases i <;> cases upper
· change (p 0*(s:ℤ)+h-(p 0*s-h)).toNat * ((p 1+1)*(s:ℤ)+h-(p 1*s-h)).toNat = _
rw [hlow,hfull]
· change ((p 0+1)*(s:ℤ)+h-((p 0+1)*s-h)).toNat * ((p 1+1)*(s:ℤ)+h-(p 1*s-h)).toNat = _
rw [hhigh,hfull]
· change ((p 0+1)*(s:ℤ)+h-(p 0*s-h)).toNat * (p 1*(s:ℤ)+h-(p 1*s-h)).toNat = _
rw [hfull,hlow,mul_comm]
· change ((p 0+1)*(s:ℤ)+h-(p 0*s-h)).toNat * ((p 1+1)*(s:ℤ)+h-((p 1+1)*s-h)).toNat = _
rw [hfull,hhigh,mul_comm]
lemma card_border_le (s h : ℕ) (p : Point) : (border s h p).card≤8*s*h+16*h^2 := by
calc
_≤∑ib : Fin 2 × Bool,(strip s h p ib.1 ib.2).card := Finset.card_biUnion_le
_=8*s*h+16*h^2 := by simp only [card_strip,Finset.sum_const,Finset.card_univ,Fintype.card_prod,Fintype.card_fin,Fintype.card_bool,smul_eq_mul]; ring
lemma mem_border_of {s h : ℕ} {p z : Point} (hz : z∈expanded s h p)
(hedge : ∃i,z i<p i*s+h ∨ (p i+1)*s-h≤z i) : z∈border s h p := by
obtain ⟨i,hi⟩:=hedge
rcases hi with hi|hi
· apply Finset.mem_biUnion.mpr
refine ⟨(i,false),Finset.mem_univ _,?_⟩
apply mem_box.mpr
intro j
have hh:=mem_box.mp hz j
simp only [Bool.false_and,Bool.not_false,Bool.true_and,Bool.false_eq_true,ite_false,decide_eq_true_eq]
by_cases hji:j=i
· subst j
simp only [↓reduceIte]
exact ⟨hh.1,hi⟩
· simp only [hji,↓reduceIte]
exact hh
· apply Finset.mem_biUnion.mpr
refine ⟨(i,true),Finset.mem_univ _,?_⟩
apply mem_box.mpr
intro j
have hh:=mem_box.mp hz j
simp only [Bool.true_and,Bool.not_true,Bool.false_and,Bool.false_eq_true,ite_false,decide_eq_true_eq]
by_cases hji:j=i
· subst j
simp only [↓reduceIte]
exact ⟨hi,hh.2⟩
· simp only [hji,↓reduceIte]
exact hh
lemma square_subset_expanded (s h : ℕ) (p : Point) : square s p⊆expanded s h p := by
apply box_mono <;> intro i <;> omega
lemma Cell.mismatch_collar {A D : ℕ} (hA : 0<A) {Q F : Cell} (hlev : Q.level≤F.level)
{y : Point} (hy : y∈Q.near A D)
(hmis : (Q.points A⊆F.points A ∧ y∉F.points A) ∨
(¬Q.points A⊆F.points A ∧ y∈F.points A)) :
Q.points A⊆border (F.side A) ((D+1)*Q.side A) F.pos := by
let s:=Q.side A
let t:=F.side A
have hs : (0:ℤ)<s := by exact_mod_cast Q.side_pos hA
have ht : (0:ℤ)<t := by exact_mod_cast F.side_pos hA
have hD : (0:ℤ)≤D := Int.natCast_nonneg D
have hy' : ∀i,(Q.pos i-D)*s≤y i ∧ y i<(Q.pos i+1+D)*s := mem_neighborhood.mp hy
intro z hz
have hz' : ∀i,Q.pos i*s≤z i ∧ z i<(Q.pos i+1)*s := mem_square.mp hz
apply mem_border_of
· rcases hmis with ⟨hsub,hout⟩|⟨hnsub,hin⟩
· exact square_subset_expanded _ _ _ (hsub hz)
· apply mem_box.mpr
intro i
have hin':=mem_square.mp hin i
have h1:=hy' i
have h2:=hz' i
change F.pos i*t-((D+1)*s:ℕ)≤z i ∧ z i<(F.pos i+1)*t+((D+1)*s:ℕ)
push_cast
constructor <;> nlinarith
· rcases hmis with ⟨hsub,hout⟩|⟨hnsub,hin⟩
· have hout' : ¬∀i,F.pos i*t≤y i ∧ y i<(F.pos i+1)*t := by simpa only [Cell.points,mem_square] using hout
obtain ⟨i,hi⟩:=not_forall.mp hout'
refine ⟨i,?_⟩
have h1:=hy' i
have h2:=hz' i
change z i<F.pos i*t+((D+1)*s:ℕ) ∨ (F.pos i+1)*t-((D+1)*s:ℕ)≤z i
push_cast
by_cases hh : y i<F.pos i*t
· exact Or.inl (by nlinarith)
· have hh' : (F.pos i+1)*t≤y i := by omega
exact Or.inr (by nlinarith)
· have hdis:= (Cell.subset_or_disjoint hA hlev).resolve_left hnsub
have hzout : z∉F.points A := fun hzF =>Finset.disjoint_left.mp hdis hz hzF
have hzout' : ¬∀i,F.pos i*t≤z i ∧ z i<(F.pos i+1)*t := by simpa only [Cell.points,mem_square] using hzout
obtain ⟨i,hi⟩:=not_forall.mp hzout'
refine ⟨i,?_⟩
change z i<F.pos i*t+((D+1)*s:ℕ) ∨ (F.pos i+1)*t-((D+1)*s:ℕ)≤z i
have hh : (0:ℤ)≤((D+1)*s:ℕ) := Int.natCast_nonneg _
omega
end SharpNodal.Grid
end
end
end OAI

Xet Storage Details

Size:
26.2 kB
·
Xet hash:
a49bea3eb4256070badd1dcafc1a24000673db18325ec1552bd001f60db2454d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.