Zulip Chat Archive

Stream: Is there code for X?

Topic: Order on α ⊕ β


Yaël Dillies (Nov 27 2021 at 00:31):

Do we not have docs#sum.preorder, docs#sigma.preorder and alike?

Eric Rodriguez (Nov 27 2021 at 00:32):

what exactly what you expect for those instances? not sure there's an obvious choice

Mario Carneiro (Nov 27 2021 at 00:38):

there are two obvious choices. I think docs#sum.lex might exist

Adam Topaz (Nov 27 2021 at 00:49):

The following seems pretty canonical to me...

import order.basic

variables (α : Type*) (X : α  Type*) [preorder α] [ i, preorder (X i)]

inductive preorder_sigma : Π (a b : Σ i, X i), Prop
| fiber (a : α) (x y : X a) : x  y  preorder_sigma a,x a,y
| base (a b : α) (x : X a) (y : X b) : a < b  preorder_sigma a,x b,y
| trans (a b c) : preorder_sigma a b  preorder_sigma b c  preorder_sigma a c

instance : preorder (Σ i, X i) :=
{ le := λ a b, preorder_sigma _ _ a b,
  lt := _,
  le_refl := begin
    rintros a,x⟩,
    apply preorder_sigma.fiber,
    apply le_refl,
  end,
  le_trans := begin
    intros a b c h1 h2,
    apply preorder_sigma.trans,
    assumption'
  end }

Adam Topaz (Nov 27 2021 at 00:52):

And since α ⊕ β ≃ Σ (i : fin 2), if i = 0 then α else β with fin 2 having an order, it seems fairly clear what the order on the sum should be...

Eric Rodriguez (Nov 27 2021 at 00:52):

I agree with the sigma case, but I don't see why or.inl _ < or.inr _ should be the default at all.

Adam Topaz (Nov 27 2021 at 00:53):

The only argument is that "we read from left to write" (in English, at least)

Eric Rodriguez (Nov 27 2021 at 01:07):

Well, bool has a linear order, and if we do this the ltr way then we can upgrade docs#equiv.sum_equiv_sigma_bool to an orderiso

Eric Rodriguez (Nov 27 2021 at 01:07):

so I guess there is a case

Mario Carneiro (Nov 27 2021 at 02:05):

The second "obvious" order I was referring to is the one generated only from the fiber variant of that inductive

Mario Carneiro (Nov 27 2021 at 02:08):

it looks like you have described sigma.lex

Adam Topaz (Nov 27 2021 at 02:11):

Is that a thing? (Test: docs#sigma.lex )

Mario Carneiro (Nov 27 2021 at 02:24):

I think that inductive is transitive even without trans

Adam Topaz (Nov 27 2021 at 02:33):

Probably... I was lazy :wink:

Yaël Dillies (Nov 27 2021 at 09:04):

I'd have personally expected the disjoint union of the orders to be the default one (as it doesn't require an order on the index type) and the lexicographical one to be on a type alias/be accessible using a locale.

Yaël Dillies (Nov 27 2021 at 09:07):

Mario Carneiro said:

it looks like you have described sigma.lex

Hmm, I shall PR that then


Last updated: Dec 20 2023 at 11:08 UTC