module Order.Diagram.Join whereprivate variable
  o â : LevelJoinsđ
In the binary case, a least upper bound is called a join. A short computation shows that being a join is precisely being the lub of a family of two elements.
record is-join (P : Poset o â) (a b lub : â P â) : Type (o â â) where
  no-eta-equality
  open Poset P
  field
    lâ€join : a †lub
    râ€join : b †lub
    least  : (ub' : Ob) â a †ub' â b †ub' â lub †ub'
record Join (P : Poset o â) (a b : â P â) : Type (o â â) where
  no-eta-equality
  field
    lub : â P â
    has-join : is-join P a b lub
  open is-join has-join public
Has-joins : Poset o â â Type (o â â)
Has-joins P = â x y â Join P x y
open is-joinunquoteDecl H-Level-is-join = declare-record-hlevel 1 H-Level-is-join (quote is-join)
module _ {o â} {P : Poset o â} where
  open Poset P
  open is-lub
  open Lub  is-joinâis-lub : â {a b lub} â is-join P a b lub â is-lub P (if_then a else b) lub
  is-joinâis-lub join .famâ€lub true = join .lâ€join
  is-joinâis-lub join .famâ€lub false = join .râ€join
  is-joinâis-lub join .least ub' x = join .least ub' (x true) (x false)
  is-lubâis-join : â {a b lub} â is-lub P (if_then a else b) lub â is-join P a b lub
  is-lubâis-join lub .lâ€join = lub .famâ€lub true
  is-lubâis-join lub .râ€join = lub .famâ€lub false
  is-lubâis-join lub .least ub' a<ub' b<ub' = lub .least ub' λ where
    true  â a<ub'
    false â b<ub'  join-unique
    : â {a b x y}
    â is-join P a b x â is-join P a b y
    â x ⥠y
  join-unique {a} {b} {x} {y} p q =
    lub-unique (is-joinâis-lub p) (is-joinâis-lub q)
  Join-is-prop : â {a b} â is-prop (Join P a b)
  Join-is-prop p q i .Join.lub =
    join-unique (Join.has-join p) (Join.has-join q) i
  Join-is-prop {a = a} {b = b} p q i .Join.has-join =
    is-propâpathp {B = λ i â is-join P a b (join-unique (Join.has-join p) (Join.has-join q) i)}
      (λ i â hlevel 1)
      (Join.has-join p) (Join.has-join q) i
  instance
    H-Level-Join
      : â {a b} {n}
      â H-Level (Join P a b) (suc n)
    H-Level-Join = prop-instance Join-is-prop
  JoinâLub : â {a b} â Join P a b â Lub P (if_then a else b)
  JoinâLub join .Lub.lub = Join.lub join
  JoinâLub join .Lub.has-lub = is-joinâis-lub (Join.has-join join)
  LubâJoin : â {a b} â Lub P (if_then a else b) â Join P a b
  LubâJoin lub .Join.lub = Lub.lub lub
  LubâJoin lub .Join.has-join = is-lubâis-join (Lub.has-lub lub)
  is-joinâis-lub : â {a b lub : Ob} â is-equiv (is-joinâis-lub {a} {b} {lub})
  is-joinâis-lub = biimp-is-equiv! _ is-lubâis-join
  JoinâLub : â {a b} â is-equiv (JoinâLub {a} {b})
  JoinâLub = biimp-is-equiv! _ LubâJoinAn important lemma about joins is that, if then the least upper bound of and is just
  gtâis-join : â {a b} â a †b â is-join P a b b
  gtâis-join aâ€b .lâ€join = aâ€b
  gtâis-join aâ€b .râ€join = â€-refl
  gtâis-join aâ€b .least ub' _ bâ€ub' = bâ€ub'
  gt-join : â {a b l} â a †b â is-join P a b l â b ⥠l
  gt-join aâ€b l = join-unique (gtâis-join aâ€b) lAs coproductsđ
Joins are the âthinningâ of coproducts; Put another way, when we allow a set of relators, rather than insisting on a propositional relation, the concept of join needs to be refined to that of coproduct.
  open is-coproduct
  open Coproduct
  is-joinâcoproduct : â {a b lub : Ob} â is-join P a b lub â Coproduct (posetâcategory P) a b
  is-joinâcoproduct lub .coapex = _
  is-joinâcoproduct lub .Îčâ = lub .is-join.lâ€join
  is-joinâcoproduct lub .Îčâ = lub .is-join.râ€join
  is-joinâcoproduct lub .has-is-coproduct .[_,_] a<q b<q =
    lub .is-join.least _ a<q b<q
  is-joinâcoproduct lub .has-is-coproduct .[]âÎčâ = prop!
  is-joinâcoproduct lub .has-is-coproduct .[]âÎčâ = prop!
  is-joinâcoproduct lub .has-is-coproduct .unique _ _ = prop!