module Order.Instances.Disjoint where

Indexed coproducts of posets🔗

If is a family of partial orders indexed by a set then we can equip the with a “fibrewise” partial order: this is the coproduct of these orders in the category of posets.

The indexed coproduct is a special case of the lexicographic sum where the base poset is discrete. It means that there is no non-trivial relationship across fibres.

  Disjoint : Poset _ _
  Disjoint = Lexical-sum (Discᵢ I) F
  injᵖ : (i :  I )  Monotone (F i) (Disjoint I F)
  injᵖ = lexical-sum-injᵖ {I = Discᵢ I} {F = F}

The name Disjoint is justified by the observation that each of the coprojections injᴾ is actually an order embedding. This identifies each factor with its image in

  injᵖ-is-order-embedding
    :  i  is-order-embedding (F i) (Disjoint I F) (apply (injᵖ i))
  injᵖ-is-order-embedding =
    lexical-sum-injᵖ-is-order-embedding {I = Discᵢ I} {F = F}

To complete the construction of the coproduct, we have the following function for mapping out, by cases:

  matchᵖ
    :  {o } {R : Poset o }
     (∀ i  Monotone (F i) R)
     Monotone (Disjoint I F) R
  matchᵖ cases .hom    (i , x)       = cases i # x
  matchᵖ cases .pres-≤ (reflᵢ , x≤y) =
    cases _ .pres-≤ (x≤y reflᵢ)

Straightforward calculations finish the proof that has all set-indexed coproducts.

Posets-has-set-indexed-coproducts
  :  {o  κ} (I : Set κ)
   has-coproducts-indexed-by (Posets (o  κ) (  κ))  I 
Posets-has-set-indexed-coproducts I F = mk where
  mk : Indexed-coproduct (Posets _ _) F
  mk .ΣF = Disjoint I F
  mk .ι  = injᵖ
  mk .has-is-ic .match      = matchᵖ
  mk .has-is-ic .commute    = trivial!
  mk .has-is-ic .unique f p = ext λ i x  p i #ₚ x

Binary coproducts are a special case of indexed coproducts🔗

⊎≡Disjoint-bool :  {o } (P Q : Poset o )  P ⊎ᵖ Q  Disjoint (el! Bool) (if_then P else Q)
⊎≡Disjoint-bool P Q = Poset-path λ where
  .to    match⊎ᵖ (injᵖ true) (injᵖ false)
  .from  matchᵖ (Bool-elim _ inlᵖ inrᵖ)
  .inverses .invl  ext λ where
    true  x  refl
    false x  refl
  .inverses .invr  ext λ where
    (inl x)  refl
    (inr x)  refl