Zulip Chat Archive
Stream: Is there code for X?
Topic: Preorder on Option
Wrenna Robson (Dec 19 2023 at 17:32):
Does Option have any kind of preorder relationship defined (assuming the underlying type does)? I've run myself into a mild pickle through assuming it did but I'm not sure it does.
Mario Carneiro (Dec 19 2023 at 17:36):
See docs#WithTop and docs#WithBot
Mario Carneiro (Dec 19 2023 at 17:37):
depending on whether you want none
to be at the top or bottom
Eric Wieser (Dec 19 2023 at 18:11):
I guess you could put an order on Option X
that has none
as incomparable?
Wrenna Robson (Dec 19 2023 at 18:27):
Yeah, that's what I was assuming.
Wrenna Robson (Dec 19 2023 at 18:27):
Or hoping for.
Wrenna Robson (Dec 19 2023 at 18:27):
Oddly there is an LT instance defined? But it isn't much use.
Wrenna Robson (Dec 19 2023 at 18:50):
But what I want is
instance (priority := 10) le [LE α] : LE (Option α) := ⟨Option.Rel (. ≤ .)⟩
instance (priority := 10) lt [LT α] : LT (Option α) := ⟨Option.Rel (. < .)⟩
(and then ideally a preorder...)
Wrenna Robson (Dec 19 2023 at 19:07):
Wait no. I want that for LE, for LT I don't because obviously Bot should not be LT itself as then you can't make a Preorder
Wrenna Robson (Dec 19 2023 at 19:08):
Urrrgh. That might be a day's work buggered if this is a challenge. I assumed (given that < worked!) that it would just nicely inherit the structure.
Yaël Dillies (Dec 19 2023 at 19:09):
Just define a < b ↔ a ≤ b ∧ ¬ b ≤ a
Wrenna Robson (Dec 19 2023 at 19:09):
Sure, that's what I want.
Wrenna Robson (Dec 19 2023 at 19:10):
But obviously if it doesn't already exist there will be lots of fiddly lemmas to sort.
Last updated: Dec 20 2023 at 11:08 UTC