module wip.inst where

open import 1Lab.Prelude
open import Data.Set.Coequaliser
open import Data.Bool
open import Data.Sum

postulate
  sup :  {} {I : Type (lsuc )} (T : I  Prop )  Prop 
  sup-coproj :  {} {I : Type (lsuc )} {F : I  Prop } (i : I)   F i    sup F 
  sup-match
    :  { ℓ′} {I : Type (lsuc )} {F : I  Prop } {Q : Prop ℓ′}
     (∀ i   F i    Q )   sup F    Q 

resize :  {}  Prop (lsuc )  Prop 
resize P = sup {I =  P } λ _  Lift _  , λ _ _ _  lift tt

test :  {}  is-equiv (resize {})
test {} = is-iso→is-equiv (iso lift′ p q) where
  lift′ :  {}  Prop   Prop (lsuc )
  lift′ P = Lift _  P  , Lift-is-hlevel 1 (P .is-tr)

  p :  (x : Prop )  sup _  x
  p x = n-ua $ prop-ext (sup _ .is-tr) (x .is-tr)
    (sup-match {I = Lift _  x } {Q = x}  (lift x) _  x))
    λ x  sup-coproj (lift x) (lift tt)

  q :  (x : Prop (lsuc ))  _  x
  q x = n-ua $ prop-ext (Lift-is-hlevel 1 (sup _ .is-tr)) (x .is-tr)
     (lift m)  sup-match {Q = x}  i _  i) m)
    λ o  lift (sup-coproj o (lift tt))

module _ {} {A : Set } {P :  A   Prop } where
  rel :  A   Bool  Bool  Type 
  rel a false false = Lift _ 
  rel a false true =  P a 
  rel a true false =  P a 
  rel a true true = Lift _ 

  open import Cat.Prelude
  open import Cat.Instances.Discrete
  open import Cat.Instances.Sets.Cocomplete
  open import Cat.Instances.Shape.Join
  open import Cat.Instances.Shape.Terminal
  open import Cat.Diagram.Everything

  open Functor
  open Initial
  open Cocone
  open Cocone-hom

  diagram′ : Functor (⊤Cat  Disc′ A) (Sets )
  diagram′ .F₀ (inl tt) = Lift _ Bool , Lift-is-hlevel 2 Bool-is-set
  diagram′ .F₀ (inr x) = (Bool / rel x) , squash
  diagram′ .F₁ {inl x} {inl x₁} f a = a
  diagram′ .F₁ {inl x} {inr x₁} f a = inc (Lift.lower a)
  diagram′ .F₁ {inr x} {inr x₁} f a = subst  e  Bool / rel e) (Lift.lower f) a
  diagram′ .F-id {inl x} = refl
  diagram′ .F-id {inr x} = funext λ _  transport-refl _
  diagram′ .F-∘ {inl x} {inl x₁} {inl x₂} f g = refl
  diagram′ .F-∘ {inl x} {inl x₁} {inr x₂} f g = refl
  diagram′ .F-∘ {inl x} {inr x₁} {inr x₂} f g = refl
  diagram′ .F-∘ {inr x} {inr x₁} {inr x₂} f g = funext $ λ a 
    subst-∙  e  Bool / rel e) (Lift.lower g) (Lift.lower f) a

  colim : Colimit diagram′
  colim = Sets-is-cocomplete {o = } diagram′

  test′ : Bool   colim .bot .coapex 
  test′ x = inc (inl tt , lift x)