roseking's picture
Add lean source and binary files (part 67)
785c727 verified
Raw History Blame Contribute Delete
906 Bytes
8
abbrev Plane := RuledApproximation.Plane
10
def coarseCell (δ : ℝ) (z : ℤ × ℤ) : Set Plane :=
body · 2 lines
  {x | δ * (z.1 : ℝ) ≤ x 0 ∧ x 0 ≤ δ * ((z.1 : ℝ) + 1) ∧
       δ * (z.2 : ℝ) ≤ x 1 ∧ x 1 ≤ δ * ((z.2 : ℝ) + 1)}
14
def gridBound (δ B : ℝ) : ℤ := ⌈B / δ⌉
16
def indexRange (δ B : ℝ) : Finset ℤ :=
body · 1 line
  Finset.Icc (-gridBound δ B - 1) (gridBound δ B)
19
def candidates (δ B : ℝ) : Finset (ℤ × ℤ) :=
body · 1 line
  (indexRange δ B).product (indexRange δ B)
22
def coarseIndices (δ B : ℝ) (D : Set Plane) : Finset (ℤ × ℤ) := by
body · 2 lines
  classical
  exact (candidates δ B).filter (fun z => (D ∩ coarseCell δ z).Nonempty)
26
def coarseUnion (δ B : ℝ) (D : Set Plane) : Set Plane :=
body · 1 line
  ⋃ z ∈ coarseIndices δ B D, coarseCell δ z