Zulip Chat Archive
Stream: batteries
Topic: eq_of_cmp_eq
Kim Morrison (Jan 18 2024 at 05:05):
I would like the typeclass
class FooCmp (cmp : α → α → Ordering) : Prop where
eq_of_cmp_eq : cmp x y = .eq → x = y
What should it be called?
James Gallicchio (Jan 18 2024 at 05:11):
in leancolls i started naming these like Lawful<class>.<property; I don't like it or recommend it but have no better suggestions than LawfulCmp.Eq :laughing:
Kim Morrison (Jan 18 2024 at 05:12):
The problem here is that it is only a small fraction of Lawful.
Kim Morrison (Jan 18 2024 at 05:12):
We already have TransCmp and OrientedCmp.
Mario Carneiro (Jan 18 2024 at 05:28):
AntisymmCmp?
Damiano Testa (Jan 18 2024 at 15:38):
Or InjectiveCmp? :upside_down:
Eric Wieser (Jan 18 2024 at 15:40):
DistinguishingCmp?
Eric Wieser (Jan 18 2024 at 15:41):
Do you really not want the typeclass to also require cmp x x = .eq at the same time?
James Gallicchio (Jan 18 2024 at 16:15):
It seems lake has a typeclass for this? docs#Lake.EqOfCmp
Eric Wieser (Jan 18 2024 at 16:51):
and docs#Lake.LawfulCmpEq is the version that has the other property I'm suggesting
Kim Morrison (Jan 19 2024 at 00:30):
Eric Wieser said:
Do you really not want the typeclass to also require
cmp x x = .eqat the same time?
So far I've been finding that when I need cmp x x = .eq, I needed OrientedCmp anyway, which implies this.
Kim Morrison (Jan 19 2024 at 00:30):
But sure, I wouldn't mind either way.
Last updated: May 02 2025 at 03:31 UTC