Skip to content

Commit 61be1c3

Browse files
Vilin97claude
andcommitted
feat(Topology/Algebra/Order/Floor): regular grid helpers
Add four lemmas about regular grids `{[a + n * h, a + (n + 1) * h]}` with step size `h > 0`, parameterized over a `Field K` with `FloorSemiring`: - `Nat.floor_div_eq_of_mem_Ico`: `t ∈ Ico (a + n*h) (a + (n+1)*h) → ⌊(t-a)/h⌋₊ = n` - `mem_Ico_Nat_floor_div`: `a ≤ t → t ∈ Ico (a + ⌊(t-a)/h⌋₊*h) ...` - `locallyFinite_Icc_grid`: the grid `Icc (a+n*h) (a+(n+1)*h)` is locally finite - `ContinuousOn.of_Icc_grid`: cell-wise continuity implies continuity on `Ici a` These are used in the forward Euler convergence proof: https://github.com/Vilin97/forward_euler Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 78457cc commit 61be1c3

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Mathlib/Topology/Algebra/Order/Floor.lean

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,54 @@ theorem ContinuousOn.comp_fract'' {f : α → β} (h : ContinuousOn f I) (hf : f
233233
Continuous (f ∘ fract) :=
234234
ContinuousOn.comp_fract (h.comp continuousOn_snd fun _x hx => (mem_prod.mp hx).2) continuous_id
235235
fun _ => hf
236+
237+
/-!
238+
## Regular grids and `Nat.floor`
239+
240+
These results relate `⌊(t - a) / h⌋₊` to membership in a regular grid of intervals
241+
`[a + n * h, a + (n + 1) * h)` with step size `h > 0`. They are used, for example,
242+
to construct piecewise linear interpolations and prove their continuity.
243+
-/
244+
245+
section RegularGrid
246+
247+
variable {K : Type*} [Field K] [LinearOrder K] [FloorSemiring K] [IsStrictOrderedRing K]
248+
249+
/-- If `t ∈ [a + n * h, a + (n + 1) * h)` and `0 < h`, then `⌊(t - a) / h⌋₊ = n`. -/
250+
theorem Nat.floor_div_eq_of_mem_Ico {h : K} (hh : 0 < h) {a : K}
251+
{n : ℕ} {t : K} (ht : t ∈ Ico (a + n * h) (a + (n + 1) * h)) :
252+
⌊(t - a) / h⌋₊ = n := by
253+
refine Nat.floor_eq_on_Ico n _ ⟨?_, ?_⟩ <;>
254+
(first | rw [le_div_iff₀ hh] | rw [div_lt_iff₀ hh]) <;> linarith [ht.1, ht.2]
255+
256+
/-- If `0 < h` and `a ≤ t`, then `t` lies in the floor interval
257+
`[a + ⌊(t - a) / h⌋₊ * h, a + (⌊(t - a) / h⌋₊ + 1) * h)`. -/
258+
theorem mem_Ico_Nat_floor_div {h : K} (hh : 0 < h) {a t : K} (hat : a ≤ t) :
259+
t ∈ Ico (a + ⌊(t - a) / h⌋₊ * h) (a + (↑⌊(t - a) / h⌋₊ + 1) * h) := by
260+
constructor <;> nlinarith [Nat.floor_le (div_nonneg (sub_nonneg.mpr hat) hh.le),
261+
Nat.lt_floor_add_one ((t - a) / h), mul_div_cancel₀ (t - a) hh.ne']
262+
263+
variable [TopologicalSpace K] [OrderTopology K]
264+
265+
/-- The regular grid of closed intervals `[a + n * h, a + (n + 1) * h]` is locally finite. -/
266+
theorem locallyFinite_Icc_grid {h : K} (hh : 0 < h) (a : K) :
267+
LocallyFinite fun n : ℕ => Icc (a + n * h) (a + (↑n + 1) * h) := by
268+
intro x
269+
refine ⟨Ioo (x - h) (x + h), Ioo_mem_nhds (by linarith) (by linarith),
270+
(finite_Icc (⌊(x - h - a) / h⌋₊) (⌈(x + h - a) / h⌉₊)).subset ?_⟩
271+
rintro n ⟨z, ⟨hz1, hz2⟩, hz3, hz4⟩
272+
refine ⟨Nat.lt_add_one_iff.mp ((Nat.floor_lt' (by linarith)).mpr ?_),
273+
Nat.cast_le.mp ((?_ : (n : K) ≤ _).trans (Nat.le_ceil _))⟩ <;>
274+
(first | rw [div_lt_iff₀ hh] | rw [le_div_iff₀ hh]) <;> push_cast <;> nlinarith
275+
276+
/-- A function continuous on each cell `[a + n * h, a + (n + 1) * h]` is continuous
277+
on `[a, ∞)`. -/
278+
theorem ContinuousOn.of_Icc_grid {E : Type*} [TopologicalSpace E]
279+
{f : K → E} {h : K} (hh : 0 < h) {a : K}
280+
(hf : ∀ n : ℕ, ContinuousOn f (Icc (a + n * h) (a + (n + 1) * h))) :
281+
ContinuousOn f (Ici a) :=
282+
((locallyFinite_Icc_grid hh a).continuousOn_iUnion (fun _ => isClosed_Icc) (hf ·)).mono
283+
fun t (hat : a ≤ t) =>
284+
mem_iUnion.mpr ⟨_, Ico_subset_Icc_self (mem_Ico_Nat_floor_div hh hat)⟩
285+
286+
end RegularGrid

0 commit comments

Comments
 (0)