Derivative.Basics.Path

{-# OPTIONS --safe #-}
module Derivative.Basics.Path where

open import Derivative.Prelude

import      Cubical.Core.Primitives as Primitives
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Equiv.Properties

private
  variable
     : Level
    A B : Type 

hcompᴵ : (φ : I) (u :  i  Partial (φ  ~ i) A)  A
hcompᴵ {A} φ u = Primitives.hcomp {φ = φ} sys base module hcomp where
  base : A
  base = u i0 1=1
  {-# INLINE base #-}

  sys : I  Partial φ A
  sys i (φ = i1) = u i 1=1

compᴵ : (A : I  Type ) (φ : I) (u :  i  Partial (φ  ~ i) (A i))  A i1
compᴵ A φ u = Primitives.comp A {φ = φ} sys base module comp where
  base : A i0
  base = u i0 1=1
  {-# INLINE base #-}

  sys : (i : I)  Partial φ (A i)
  sys i (φ = i1) = u i 1=1

∂ᴵ : I  I
∂ᴵ i = i  ~ i

Jᴰ :  { ℓ'} {A : I  Type }
   (x : A i0)
   (P :  {i : I}  (y : A i)  PathP  j  A (i  j)) x y  Type ℓ')
   (d : P x refl)
   {y : A i1} (p : PathP A x y)  P y p
Jᴰ _ P d p = transport  i  P (p i) λ j  p (i  j)) d

doubleCompPathP : (B : A  Type )
   {x y z w : A}
   {p : x  y} {q : y  z} {r : z  w} {s : x  w}
   (filler : Square (sym p) r q s)
   {xᴰ : B x} {yᴰ : B y} {zᴰ : B z} {wᴰ : B w}
   (pᴰ : PathP  i  B (p i)) xᴰ yᴰ)
   (qᴰ : PathP  i  B (q i)) yᴰ zᴰ)
   (rᴰ : PathP  i  B (r i)) zᴰ wᴰ)
   PathP  i  B (s i)) xᴰ wᴰ
doubleCompPathP B filler pᴰ qᴰ rᴰ i =
  compᴵ  j  B (filler i j)) (∂ᴵ i)
  λ where
    j (i = i0)  pᴰ (~ j)
    j (i = i1)  rᴰ j
    j (j = i0)  qᴰ i

neqCongEquiv : {a b : A} {x y : B}
   (a  b)  (x  y)
   (a  b)  (x  y)
neqCongEquiv e = preCompEquiv (invEquiv e)