math / data /lean /OAI /Probability /LatticeSurface /Geometry /TriangularCover.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
6.55 kB
import Mathlib
namespace OAI
open Set MeasureTheory
noncomputable section
namespace TriangularLipschitz
abbrev Vertex := β„€ Γ— β„€
def Adj (x y : Vertex) : Prop :=
y = (x.1 + 1, x.2) ∨ y = (x.1 - 1, x.2) ∨
y = (x.1, x.2 + 1) ∨ y = (x.1, x.2 - 1) ∨
y = (x.1 + 1, x.2 - 1) ∨ y = (x.1 - 1, x.2 + 1)
def boxIndex (β„“ : β„•) (x : Vertex) : Vertex := (x.1 / (β„“:β„€), x.2 / (β„“:β„€))
def centralBox (β„“ : β„•) (z : Vertex) : Finset Vertex :=
Finset.Ico (z.1 * β„“) ((z.1+1)*β„“) Γ—Λ’ Finset.Ico (z.2*β„“) ((z.2+1)*β„“)
lemma centralBox_card (β„“ : β„•) (z : Vertex) : (centralBox β„“ z).card = β„“^2 := by
simp [centralBox, Finset.card_product, Int.card_Ico, add_mul]
ring
lemma boxIndex_mem (β„“ : β„•) (hβ„“ : 0 < β„“) (x : Vertex) : x ∈ centralBox β„“ (boxIndex β„“ x) := by
have hp : (0:β„€) < β„“ := by exact_mod_cast hβ„“
have h1 := Int.emod_nonneg x.1 (ne_of_gt hp)
have h2 := Int.emod_lt_of_pos x.1 hp
have h3 := Int.emod_nonneg x.2 (ne_of_gt hp)
have h4 := Int.emod_lt_of_pos x.2 hp
have e1 := Int.emod_add_ediv_mul x.1 (β„“:β„€)
have e2 := Int.emod_add_ediv_mul x.2 (β„“:β„€)
simp only [centralBox, boxIndex, Finset.mem_product, Finset.mem_Ico]
constructor <;> constructor <;> nlinarith
lemma ediv_neighbor (a b : β„€) (β„“ : β„•) (hβ„“ : 0 < β„“) (hab : |a-b| ≀ 1) :
|a/(β„“:β„€) - b/(β„“:β„€)| ≀ 1 := by
have hp : (1:β„€) ≀ β„“ := by exact_mod_cast hβ„“
have hma := Int.emod_nonneg a (by omega : (β„“:β„€) β‰  0)
have hmb := Int.emod_nonneg b (by omega : (β„“:β„€) β‰  0)
have hLa := Int.emod_lt_of_pos a (by omega : (0:β„€) < β„“)
have hLb := Int.emod_lt_of_pos b (by omega : (0:β„€) < β„“)
have ea := Int.emod_add_ediv_mul a (β„“:β„€)
have eb := Int.emod_add_ediv_mul b (β„“:β„€)
rw [abs_le] at hab ⊒
constructor
Β· by_contra hh
have hd : a/(β„“:β„€) - b/(β„“:β„€) ≀ -2 := by omega
have hm := mul_le_mul_of_nonneg_right hd (by omega : (0:β„€) ≀ β„“)
nlinarith
Β· by_contra hh
have hd : 2 ≀ a/(β„“:β„€) - b/(β„“:β„€) := by omega
have hm := mul_le_mul_of_nonneg_right hd (by omega : (0:β„€) ≀ β„“)
nlinarith
lemma adj_boxIndex (β„“ : β„•) (hβ„“ : 0 < β„“) {x y : Vertex} (hxy : Adj x y) :
|(boxIndex β„“ x).1-(boxIndex β„“ y).1| ≀ 1 ∧
|(boxIndex β„“ x).2-(boxIndex β„“ y).2| ≀ 1 := by
have hc : |x.1-y.1| ≀ 1 ∧ |x.2-y.2| ≀ 1 := by
rcases x with ⟨a,b⟩; rcases y with ⟨c,d⟩
simp only [Adj, Prod.mk.injEq] at hxy
simp only [abs_le]
omega
exact ⟨ediv_neighbor _ _ β„“ hβ„“ hc.1, ediv_neighbor _ _ β„“ hβ„“ hc.2⟩
def boxNeighborSet (z : Vertex) : Finset Vertex :=
((Finset.Icc (z.1-1) (z.1+1)) Γ—Λ’ (Finset.Icc (z.2-1) (z.2+1))).erase z
lemma boxNeighborSet_card (z : Vertex) : (boxNeighborSet z).card = 8 := by
have hz : z ∈ ((Finset.Icc (z.1-1) (z.1+1)) Γ—Λ’ (Finset.Icc (z.2-1) (z.2+1))) := by
simp
rw [boxNeighborSet, Finset.card_erase_of_mem hz, Finset.card_product]
simp only [Int.card_Icc]
norm_num [show z.1+1+1-(z.1-1) = 3 by ring, show z.2+1+1-(z.2-1) = 3 by ring]
lemma mem_boxNeighborSet {z w : Vertex} : w ∈ boxNeighborSet z ↔
w β‰  z ∧ |z.1-w.1| ≀ 1 ∧ |z.2-w.2| ≀ 1 := by
simp only [boxNeighborSet, Finset.mem_erase, Finset.mem_product, Finset.mem_Icc, abs_le]
constructor <;> intro h <;> exact ⟨h.1,by omega,by omega⟩
variable {V : Type*} [Fintype V] [DecidableEq V]
noncomputable def boxSet (loc : V β†ͺ Vertex) (β„“ : β„•) : Finset Vertex :=
Finset.univ.image (fun x => boxIndex β„“ (loc x))
abbrev Boxes (loc : V β†ͺ Vertex) (β„“ : β„•) := {z : Vertex // z ∈ boxSet loc β„“}
noncomputable def boxMap (loc : V β†ͺ Vertex) (β„“ : β„•) (x : V) : Boxes loc β„“ :=
⟨boxIndex β„“ (loc x), Finset.mem_image.mpr ⟨x, Finset.mem_univ _, rfl⟩⟩
noncomputable def coverGraph (loc : V β†ͺ Vertex) (β„“ : β„•) : SimpleGraph (Boxes loc β„“) where
Adj z w := w.1 ∈ boxNeighborSet z.1
symm := ⟨by
intro z w hz
rw [mem_boxNeighborSet] at hz ⊒
exact ⟨hz.1.symm, by simpa [abs_sub_comm] using hz.2.1,
by simpa [abs_sub_comm] using hz.2.2⟩⟩
loopless := ⟨by intro z hz; exact (mem_boxNeighborSet.mp hz).1 rfl⟩
omit [DecidableEq V] in
lemma boxMap_adjacent (loc : V β†ͺ Vertex) (β„“ : β„•) (hβ„“ : 0 < β„“)
{x y : V} (hxy : Adj (loc x) (loc y)) :
boxMap loc β„“ x = boxMap loc β„“ y ∨
(coverGraph loc β„“).Adj (boxMap loc β„“ x) (boxMap loc β„“ y) := by
by_cases he : boxIndex β„“ (loc x) = boxIndex β„“ (loc y)
Β· exact Or.inl (Subtype.ext he)
Β· exact Or.inr ((mem_boxNeighborSet).mpr ⟨Ne.symm he, adj_boxIndex β„“ hβ„“ hxy⟩)
omit [DecidableEq V] in
lemma boxMap_fiber (loc : V β†ͺ Vertex) (β„“ : β„•) (hβ„“ : 0 < β„“) (w : Boxes loc β„“) :
(Finset.univ.filter fun x => boxMap loc β„“ x = w).card ≀ β„“^2 := by
classical
rw [← centralBox_card β„“ w]
apply Finset.card_le_card_of_injOn loc
Β· intro x hx
have he := (Finset.mem_filter.mp hx).2
have he' : boxIndex β„“ (loc x) = w := congrArg Subtype.val he
rw [← he']
exact boxIndex_mem β„“ hβ„“ (loc x)
Β· exact fun _ _ _ _ h => loc.injective h
noncomputable def coverNeighbors (loc : V β†ͺ Vertex) (β„“ : β„•) (w : Boxes loc β„“) :
Finset (Boxes loc β„“) := by
classical
exact Finset.univ.filter fun z => (coverGraph loc β„“).Adj w z
omit [DecidableEq V] in
lemma coverGraph_degree (loc : V β†ͺ Vertex) (β„“ : β„•) (w : Boxes loc β„“) :
(coverNeighbors loc β„“ w).card ≀ 8 := by
classical
rw [coverNeighbors, ← boxNeighborSet_card w]
apply Finset.card_le_card_of_injOn Subtype.val
Β· intro x hx
exact (Finset.mem_filter.mp hx).2
Β· exact fun _ _ _ _ h => Subtype.ext h
def steps : Finset Vertex := {(1,0),(-1,0),(0,1),(0,-1),(1,-1),(-1,1)}
lemma steps_card : steps.card = 6 := by decide
lemma adj_iff_steps (x y : Vertex) : Adj x y ↔ y - x ∈ steps := by
rcases x with ⟨a,b⟩; rcases y with ⟨c,d⟩
simp only [Adj, steps, Finset.mem_insert, Finset.mem_singleton, Prod.mk.injEq,
Prod.sub_def]
omega
omit [Fintype V] [DecidableEq V] in
lemma finite_graph_degree (loc : V β†ͺ Vertex) (G : SimpleGraph V)
(hG : βˆ€ x y, G.Adj x y β†’ Adj (loc x) (loc y)) (x : V)
(T : Finset V) (hT : βˆ€ y ∈ T, G.Adj x y) : T.card ≀ 6 := by
rw [← steps_card]
apply Finset.card_le_card_of_injOn (fun y => loc y - loc x)
Β· intro y hy
exact (adj_iff_steps _ _).mp (hG x y (hT y hy))
Β· intro y hy z hz he
apply loc.injective
exact sub_left_injective he
end TriangularLipschitz
end
end OAI