1lab icon indicating copy to clipboard operation
1lab copied to clipboard

`is-total-order` is not a property

Open TOTBWF opened this issue 1 year ago • 5 comments

Currently, the definition of is-total-order is

record is-total-order {o ℓ} (P : Poset o ℓ) : Type (o ⊔ ℓ) where
  open Poset P public

  field
    compare         : ∀ x y → (x ≤ y) ⊎ (y ≤ x)

This is not a property: in a discrete order, this is equivalent to a function compare : P -> P -> Bool. This can be fixed by truncating the result of compare; note that we can still compute meets and joins, as those are properties!

TOTBWF avatar Mar 05 '25 14:03 TOTBWF

let's rename it instead of truncating. the things you want to do with a decidable total order are things like sorting which it would be very inconvenient to prove that a sorting is unique and then like do choice over the list to get all the possible comparisons upfront or something

plt-amy avatar Mar 05 '25 15:03 plt-amy

Can we use (x ≤ y) ⊎ (y < x) instead, where y < x is y ≤ x × y ≠ x? That is a proposition and is probably usable for sorting? I'm not sure if it's (logically) equivalent to what we have now, though. EDIT: probably not, unless the underlying set is discrete.

ncfavier avatar Mar 05 '25 15:03 ncfavier

If that still lets you compute meets and joins then I guess that works because is-total-order is only used for that and the definition of is-decidable-total-order which implies discreteness (and that's what you'd (i did) use in a sorting algorithm)

plt-amy avatar Mar 05 '25 16:03 plt-amy

Is src/Order/Total.lagda.md the only file to change ? Because if so there is only 8 lines to change and 1 to add to use this new definition (see this commit)

Seiryn21 avatar Mar 20 '25 10:03 Seiryn21

Why not compare : ∀ x y → (x ≤ y) ∗ (y ≤ x), where _∗_ is as defined in Homotopy.Join? This is equivalent to ∥ (x ≤ y) ⊎ (y ≤ x) ∥, but has a more convenient universal property.

finegeometer avatar Aug 06 '25 23:08 finegeometer