Zulip Chat Archive
Stream: mathlib4
Topic: toNat
Yury G. Kudryashov (Feb 26 2026 at 03:57):
TIL that we have docs#toNat that is
- in the root namespace
- abuses defeq between
Set XandX -> Propin all lemmas.
What should I do about it?
Eric Wieser (Feb 26 2026 at 04:07):
The defeq fix is easy, right?
Yury G. Kudryashov (Feb 26 2026 at 04:08):
I can fix it to operate on predicates, or I can change all the lemmas to use fun x => x \in s
Yury G. Kudryashov (Feb 26 2026 at 04:08):
I don't know which one makes more sense in this context.
Eric Wieser (Feb 26 2026 at 04:22):
Are there defeq abuses in the callers, or just the implementation?
Eric Wieser (Feb 26 2026 at 04:24):
To me
def toNat (s : Set α) : Set ℕ :=
(Encodable.decode · |>.getD default) ⁻¹' s
is the obvious correction
Yury G. Kudryashov (Feb 26 2026 at 04:44):
The next several lemmas abuse defeq because they feed sets to docs#ManyOneReducible
Yury G. Kudryashov (Feb 26 2026 at 04:46):
The file is authored by @Minchao Wu and @Mario Carneiro and IMHO lacks a useful module docstring.
Yury G. Kudryashov (Feb 26 2026 at 04:47):
BTW, all the docs talk about sets. Should I redefine ManyOneReducible to take sets instead?
Yury G. Kudryashov (Feb 28 2026 at 08:09):
@Mario Carneiro Should I change toNat and ManyOneReducible to deal with predicates or sets? Also, what would be good less generic name for toNat or a good namespace for it?
Last updated: Feb 28 2026 at 14:05 UTC