Zulip Chat Archive
Stream: Is there code for X?
Topic: Case by ordering in linear order
Daniel Weber (Aug 09 2024 at 04:34):
I have three elements, x, y, z
of a LinearOrder, and I want to split to the 6 cases x ≤ y ≤ z
, x ≤ z ≤ y
, ...
What's the nicest way to do this?
Yaël Dillies (Aug 09 2024 at 06:12):
obtain hxy | hyx := le_or_lt x y <;> obtain hyz | hzy := le_or_lt y z <;> obtain hzx | hxz := le_or_lt z x
, then eliminate the 2 out of 8 cases that are impossible
Daniel Weber (Aug 09 2024 at 06:13):
What's that notation for obtain
?
Yaël Dillies (Aug 09 2024 at 06:15):
The "I just woke up" notation :see_no_evil:
Daniel Weber (Aug 09 2024 at 06:38):
Ah, alright. Thanks
Eric Wieser (Aug 09 2024 at 08:20):
An le_total3
lemma would be reasonable in mathlib, right?
Eric Wieser (Aug 09 2024 at 08:21):
Alternatively, I wonder if a lemma that's says ∃ l' ∈ l.permutations, l.Sorted
would be useful, then you could invoke that with [x, y, z]
Daniel Weber (Aug 09 2024 at 08:26):
There's docs#List.perm_mergeSort and docs#List.sorted_mergeSort, but wouldn't it be really inconvenient to use that?
Last updated: May 02 2025 at 03:31 UTC