Skip to content

feat(ForMathlib): index-image diameter bound (2/4) - #14

Merged
riccardobrasca merged 3 commits into
masterfrom
idx-2
Jul 9, 2026
Merged

riccardobrasca merged 3 commits into
masterfrom
idx-2

Conversation

@CBirkbeck

@CBirkbeck CBirkbeck commented Jun 18, 2026 •

Copy link
Copy Markdown
Owner

Adds the ceiling-subadditivity helper ceil_natCast_mul_le_ceil_natCast_mul_add (introduced here, next to its first use per @xroblot's review) and ncard_index_image_le_of_diam_le: a set of diameter ≤ r meets at most (2⌈n·r⌉₊ + 1)ᵈ cells of the n⁻¹ℤ^ι grid.

Builds green on the v4.31.0-rc1 / mathlib-master pin.

🤖 Generated with Claude Code


Stacked on 1/4. Adds the ceiling-subadditivity helper `ceil_natCast_mul_le_ceil_natCast_mul_add`
(introduced here, next to its first use) and `ncard_index_image_le_of_diam_le`: a set of diameter
`≤ r` meets at most `(2⌈n·r⌉₊ + 1)ᵈ` grid cells.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@xroblot

xroblot commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Merge with master

/-- **Bounded-diameter cell incidence.** A set `T ⊆ ι → ℝ` of diameter `≤ r` meets at most
`(2⌈n·r⌉₊ + 1)ᵈ` cells of the `n⁻¹ℤ^ι` grid, i.e. its `index n`-image has at most that many
points. (Here `ι → ℝ` carries the sup metric, so a cube of side `1/n` has diameter `1/n`.) -/
theorem ncard_index_image_le_of_diam_le (n : ℕ) [NeZero n] {T : Set (ι → ℝ)} {r : ℝ}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is NeZero n really needed? Same for hr.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in fcf600f (and 22b3aac on development) — neither is needed:

  • NeZero n: mathlib defines unitPartition.index for every n (index_apply is even stated for an arbitrary m : ℕ with no instance), and at n = 0 the statement is trivially true — index 0 x = fun _ ↦ -1, so the image has at most one point while the RHS is 1. The one proof covers it uniformly, no case split needed.
  • hr : 0 ≤ r: once T is nonempty it follows from the diameter hypothesis (Metric.diam_nonneg.trans hdiam), and the empty case was already discharged by simp. It is now a have inside the proof.

(After the master merge the lemma also carries its own [Fintype ι] binder — the section-level instance was generalised away during the #13 review.)

@riccardobrasca

Copy link
Copy Markdown
Collaborator

Can you have a look at my comment?

Also, isn't this PR to merge into master?

CBirkbeck and others added 2 commits July 9, 2026 09:20
- ncard_index_image_le_of_diam_le: NeZero n is unneeded (index is total
  and the n = 0 bound is trivially true); 0 <= r now derived inside the
  proof via Metric.diam_nonneg once T is nonempty (riccardobrasca, PR 14)
- lemma now carries [Fintype i] itself since the master merge removed
  the section-level instance (generalised away in the PR 13 review)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@CBirkbeck
CBirkbeck changed the base branch from idx-1 to master July 9, 2026 08:27
@CBirkbeck

Copy link
Copy Markdown
Owner Author

Both done:

CBirkbeck added a commit that referenced this pull request Jul 9, 2026
…o [Finite ι]

Per @xroblot's review (PR #13): put each private helper next to its first use, and
weaken `setFinite`'s hypothesis.

- `setFinite_index_image_of_isBounded` now takes `[Finite ι]`, recovering `Fintype`
  via `Fintype.ofFinite` inside the proof — dropping the
  `set_option linter.unusedFintypeInType false` workaround (the conclusion never
  mentions `Fintype.card`).
- `ceil_natCast_mul_le_ceil_natCast_mul_add` moved next to its only consumer
  `ncard_index_image_le_of_diam_le`; `abs_sub_le_one_div_of_ceil_natCast_mul_eq`
  next to `ncard_index_image_chart_le`. This re-slices the stack so each helper lands
  in the PR that first uses it (#14, #15) instead of #13.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@riccardobrasca
riccardobrasca merged commit 28f3842 into master Jul 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants