Zulip Chat Archive
Stream: mathlib4
Topic: dedup and eraseDup
Wrenna Robson (Oct 11 2025 at 11:59):
Why does Batteries have List.eraseDup and Mathlib have List.dedup, which are virtually identical, but as far as I can tell we don't have a theorem even linking the two?
Wrenna Robson (Oct 11 2025 at 12:00):
We also have List.eraseDups which... seems to do the same thing as eraseDup?
Wrenna Robson (Oct 11 2025 at 12:01):
Indeed I think List.pwFilter and List.eraseDupsBy might be virtually the same as well...
Ruben Van de Velde (Oct 11 2025 at 12:02):
One in core, one in batteries, one in mathlib. Sounds sensible, right? :sweat_smile:
Wrenna Robson (Oct 11 2025 at 12:02):
I take the perhaps controversial view that we should only have one of these ;)
Ruben Van de Velde (Oct 11 2025 at 12:04):
Two of them claim to be defined as pwFilter (≠), but one claims the last is kept and one that the first is kept
Ruben Van de Velde (Oct 11 2025 at 12:05):
Also core and batteries use BEq and mathlib DecidableEq
Wrenna Robson (Oct 11 2025 at 12:05):
Yes, although pwFilter uses DecidableEq again in Batteries.
Ruben Van de Velde (Oct 11 2025 at 12:05):
I wonder if the change to make BEq and DecidableEq play nicer together ever landed
Wrenna Robson (Oct 11 2025 at 12:06):
I think it does seem to...
Eric Wieser (Oct 11 2025 at 12:07):
I thought it didn't, and we had to change Decidable to be a subtype of Bool for that to work
Wrenna Robson (Oct 11 2025 at 12:07):
Looking at the definition of pwFilter, I think in practice it will drop the first element that duplicates a later element in the list.
Ruben Van de Velde (Oct 11 2025 at 12:07):
Anyway, I agree at least the one in batteries should be deprecated
Ruben Van de Velde (Oct 11 2025 at 12:08):
https://github.com/leanprover/lean4/pull/8309 ?
Last updated: Dec 20 2025 at 21:32 UTC