module DPRLR.Simplicial.FunctionExtensionality where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism

open import DPRLR.Simplicial.Hom

private
  variable
     ℓA ℓB ℓX ℓP : Level
    A : Type ℓA
    B : A  Type ℓB
    X : Type ℓX

hom-happly :
  {f g : (x : A)  B x}
   f  g
   (x : A)  f x  g x
hom-happly h x = hom-map  f  f x) h

hom-funExt :
  {f g : (x : A)  B x}
   ((x : A)  f x  g x)
   f  g
hom-funExt h =
   i x  hom-path (h x) i)
  , funExt  x  left-endpoint (h x))
  , funExt  x  right-endpoint (h x))

hom-happly-Iso :
  {f g : (x : A)  B x}
   Iso (f  g) ((x : A)  f x  g x)
Iso.fun hom-happly-Iso =
  hom-happly
Iso.inv hom-happly-Iso =
  hom-funExt
Iso.rightInv hom-happly-Iso _ =
  refl
Iso.leftInv hom-happly-Iso _ =
  refl

hom-happly≃ :
  {f g : (x : A)  B x}
   (f  g)  ((x : A)  f x  g x)
hom-happly≃ =
  isoToEquiv hom-happly-Iso

HomPΠ-happly :
  {P : A  X  Type ℓP}
  {x y : A}
  {h : x  y}
  {u : (i : X)  P x i}
  {v : (i : X)  P y i}
    a  (i : X)  P a i)  u ≤[ h ] v
   (i : X)   a  P a i)  u i ≤[ h ] v i
HomPΠ-happly q i =
   j  q .fst j i)
  ,  j  q .snd .fst j i)
  ,  j  q .snd .snd j i)

HomPΠ :
  {P : A  X  Type ℓP}
  {x y : A}
  {h : x  y}
  {u : (i : X)  P x i}
  {v : (i : X)  P y i}
   ((i : X)   a  P a i)  u i ≤[ h ] v i)
    a  (i : X)  P a i)  u ≤[ h ] v
HomPΠ q =
   j i  q i .fst j)
  ,  j i  q i .snd .fst j)
  ,  j i  q i .snd .snd j)