math / data /lean /OAI /Analysis /CircleDomains /Transfer /GraphGridCells.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.75 kB
import OAI.Analysis.CircleDomains.Topology.EqualScaleCellSeparation
namespace OAI
/-! Equal-scale three-dimensional cells, colored by sixteen residues
in each coordinate. Enlarged balls in one color are disjoint. -/
open Set Function Metric
noncomputable section
namespace CircleDomainRigidity
abbrev GraphGridColor := (Fin 16 Γ— Fin 16) Γ— Fin 16
abbrev GraphGridIndex := (β„€ Γ— β„€) Γ— β„€
abbrev GraphSpace := (ℝ Γ— ℝ) Γ— ℝ
def graphGridInterval (r : Fin 16) (k : β„€) (s : ℝ) : Set ℝ :=
Icc ((16*(k:ℝ)+(r:β„•))*s) ((16*(k:ℝ)+(r:β„•)+1)*s)
def graphGridCell (r : GraphGridColor) (k : GraphGridIndex) (s : ℝ) : Set GraphSpace :=
(graphGridInterval r.1.1 k.1.1 s Γ—Λ’ graphGridInterval r.1.2 k.1.2 s) Γ—Λ’
graphGridInterval r.2 k.2 s
lemma graphGridCell_dist_gt {s : ℝ} (hs : 0 < s) (r : GraphGridColor)
{k l : GraphGridIndex} (hkl : k β‰  l) {x y : GraphSpace}
(hx : x ∈ graphGridCell r k s) (hy : y ∈ graphGridCell r l s) :
8*s < dist x y := by
by_cases hβ‚€ : k.1.1 = l.1.1
Β· by_cases h₁ : k.1.2 = l.1.2
Β· have hβ‚‚ : k.2 β‰  l.2 := by
intro h
exact hkl (Prod.ext (Prod.ext hβ‚€ h₁) h)
have hh := equal_scale_cell_separation hs hβ‚‚ (r.2:β„•) hx.2 hy.2
exact hh.trans_le (by
rw [Prod.dist_eq,Real.dist_eq]
exact le_max_right _ _)
Β· have hh := equal_scale_cell_separation hs h₁ (r.1.2:β„•) hx.1.2 hy.1.2
exact hh.trans_le (by
rw [Prod.dist_eq,Prod.dist_eq,Real.dist_eq]
exact (le_max_right _ _).trans (le_max_left _ _))
Β· have hh := equal_scale_cell_separation hs hβ‚€ (r.1.1:β„•) hx.1.1 hy.1.1
exact hh.trans_le (by
rw [Prod.dist_eq,Prod.dist_eq,Real.dist_eq]
exact (le_max_left _ _).trans (le_max_left _ _))
lemma graphGridCell_enlarged_disjoint {s : ℝ} (hs : 0 < s) (r : GraphGridColor)
{k l : GraphGridIndex} (hkl : k β‰  l) {x y : GraphSpace}
(hx : x ∈ graphGridCell r k s) (hy : y ∈ graphGridCell r l s) :
Disjoint (closedBall x (4*s)) (closedBall y (4*s)) := by
apply Set.disjoint_left.mpr
intro z hzx hzy
have ht := dist_triangle x z y
rw [dist_comm x z] at ht
have hle : dist x y ≀ 8*s := by
linarith [mem_closedBall.mp hzx, mem_closedBall.mp hzy]
exact (not_lt_of_ge hle) (graphGridCell_dist_gt hs r hkl hx hy)
lemma exists_graphGridInterval {s : ℝ} (hs : 0 < s) (x : ℝ) :
βˆƒ (r : Fin 16) (k : β„€), x ∈ graphGridInterval r k s := by
let n : β„€ := Int.floor (x/s)
have hn0 : 0 ≀ n % 16 := Int.emod_nonneg _ (by norm_num)
have hn16 : n % 16 < 16 := Int.emod_lt_of_pos _ (by norm_num)
let r : Fin 16 := ⟨(n%16).toNat,by omega⟩
refine ⟨r,n/16,?_⟩
have he : (16:ℝ)*(n/16:β„€)+(r:β„•) = (n:ℝ) := by
have hr : ((r:β„•):ℝ) = ((n%16:β„€):ℝ) := by
dsimp only [r]
exact_mod_cast (Int.natCast_toNat_eq_self.mpr hn0)
rw [hr]
have hh : (16:β„€)*(n/16)+n%16 = n := by simpa only [add_comm] using Int.emod_add_mul_ediv n 16
exact_mod_cast hh
change (16*(n/16:β„€)+(r:β„•))*s ≀ x ∧ x ≀ (16*(n/16:β„€)+(r:β„•)+1)*s
rw [he]
have hlo := (le_div_iffβ‚€ hs).mp (Int.floor_le (x/s))
have hhi := (div_lt_iffβ‚€ hs).mp (Int.lt_floor_add_one (x/s))
exact ⟨hlo,hhi.le⟩
lemma exists_graphGridCell {s : ℝ} (hs : 0 < s) (x : GraphSpace) :
βˆƒ (r : GraphGridColor) (k : GraphGridIndex), x ∈ graphGridCell r k s := by
obtain ⟨rβ‚€,kβ‚€,hβ‚€βŸ© := exists_graphGridInterval hs x.1.1
obtain ⟨r₁,k₁,hβ‚βŸ© := exists_graphGridInterval hs x.1.2
obtain ⟨rβ‚‚,kβ‚‚,hβ‚‚βŸ© := exists_graphGridInterval hs x.2
exact ⟨((rβ‚€,r₁),rβ‚‚),((kβ‚€,k₁),kβ‚‚),⟨⟨hβ‚€,hβ‚βŸ©,hβ‚‚βŸ©βŸ©
lemma graphGridCell_dist_le {s : ℝ} (r : GraphGridColor) (k : GraphGridIndex)
{x y : GraphSpace} (hx : x ∈ graphGridCell r k s) (hy : y ∈ graphGridCell r k s) :
dist x y ≀ s := by
have hcoord {a x y : ℝ} (hx : x ∈ Icc a (a+s)) (hy : y ∈ Icc a (a+s)) :
|x-y| ≀ s := abs_le.mpr ⟨by linarith [hx.1,hy.2],by linarith [hx.2,hy.1]⟩
have hβ‚€ := hcoord (a := (16*(k.1.1:ℝ)+(r.1.1:β„•))*s)
(by simpa only [graphGridInterval,add_mul,one_mul] using hx.1.1)
(by simpa only [graphGridInterval,add_mul,one_mul] using hy.1.1)
have h₁ := hcoord (a := (16*(k.1.2:ℝ)+(r.1.2:β„•))*s)
(by simpa only [graphGridInterval,add_mul,one_mul] using hx.1.2)
(by simpa only [graphGridInterval,add_mul,one_mul] using hy.1.2)
have hβ‚‚ := hcoord (a := (16*(k.2:ℝ)+(r.2:β„•))*s)
(by simpa only [graphGridInterval,add_mul,one_mul] using hx.2)
(by simpa only [graphGridInterval,add_mul,one_mul] using hy.2)
simpa only [Prod.dist_eq,Real.dist_eq,max_le_iff] using And.intro (And.intro hβ‚€ h₁) hβ‚‚
end CircleDomainRigidity
end
end OAI