|
|
@ -22,6 +22,8 @@ import qualified Presyntax.Presyntax as P |
|
|
|
import Syntax |
|
|
|
|
|
|
|
import System.IO.Unsafe |
|
|
|
import Syntax.Pretty (prettyTm) |
|
|
|
import GHC.Stack (HasCallStack) |
|
|
|
|
|
|
|
wiType :: WiredIn -> NFType |
|
|
|
wiType WiType = VType |
|
|
@ -201,16 +203,17 @@ inot = \case |
|
|
|
x -> VINot x |
|
|
|
|
|
|
|
ielim :: Value -> Value -> Value -> Value -> NFEndp -> Value |
|
|
|
ielim _line _left _right fn i = |
|
|
|
ielim line left right fn i = |
|
|
|
case force fn of |
|
|
|
VLine _ _ _ fun -> fun @@ i |
|
|
|
x -> case i of |
|
|
|
VI1 -> _right |
|
|
|
VI0 -> _left |
|
|
|
VI1 -> right |
|
|
|
VI0 -> left |
|
|
|
_ -> case x of |
|
|
|
VNe n sp -> VNe n (sp Seq.:|> PIElim _line _left _right i) |
|
|
|
VSystem map -> VSystem (fmap (flip (ielim _line _left _right) i) map) |
|
|
|
_ -> error $ "can't ielim " ++ show fn |
|
|
|
VNe n sp -> VNe n (sp Seq.:|> PIElim line left right i) |
|
|
|
VSystem map -> VSystem (fmap (flip (ielim line left right) i) map) |
|
|
|
VInc (VPath _ _ _) _ u -> ielim line left right u i |
|
|
|
_ -> error $ "can't ielim " ++ show (prettyTm (quote fn)) |
|
|
|
|
|
|
|
outS :: NFSort -> NFEndp -> Value -> Value -> Value |
|
|
|
outS _ (force -> VI1) u _ = u @@ VItIsOne |
|
|
@ -219,10 +222,10 @@ outS _ _phi _ (VInc _ _ x) = x |
|
|
|
outS _ VI0 _ x = x |
|
|
|
|
|
|
|
outS a phi u (VNe x sp) = VNe x (sp Seq.:|> POuc a phi u) |
|
|
|
outS _ _ _ v = error $ "can't outS " ++ show v |
|
|
|
outS _ _ _ v = error $ "can't outS " ++ show (prettyTm (quote v)) |
|
|
|
|
|
|
|
-- Composition |
|
|
|
comp :: NFLine -> NFEndp -> Value -> Value -> Value |
|
|
|
comp :: HasCallStack => NFLine -> NFEndp -> Value -> Value -> Value |
|
|
|
comp _ VI1 u _ = u @@ VI1 @@ VItIsOne |
|
|
|
comp a psi@phi u (compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
|
case force $ a @@ VVar (Bound (T.pack "i") 0) of |
|
|
@ -246,8 +249,8 @@ comp a psi@phi u (compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
|
|
|
|
|
w i = fill (fun dom) phi (system \i isone -> vProj1 (u @@ i @@ isone)) (VInc (dom VI0) phi (vProj1 a0)) i |
|
|
|
c1 = comp (fun dom) phi (system \i isone -> vProj1 (u @@ i @@ isone)) (VInc (dom VI0) phi (vProj1 a0)) |
|
|
|
c2 = comp (fun (($ w VI1) . rng)) phi (system \i isone -> vProj1 (u @@ i @@ isone)) (VInc (rng VI0 (dom VI0)) phi (vProj2 a0)) |
|
|
|
in |
|
|
|
c2 = comp (fun \x -> rng x (w x)) phi (system \i isone -> vProj2 (u @@ i @@ isone)) (VInc (rng VI0 (w VI0)) phi (vProj2 a0)) |
|
|
|
in |
|
|
|
VPair c1 c2 |
|
|
|
|
|
|
|
VPath{} -> |
|
|
@ -309,7 +312,7 @@ comp a psi@phi u (compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
|
-- fibrancy structure of the booleans is trivial |
|
|
|
VBool{} -> a0 |
|
|
|
|
|
|
|
_ -> VComp a phi u a0 |
|
|
|
_ -> VComp a phi u (VInc (a @@ VI0) phi a0) |
|
|
|
|
|
|
|
compOutS :: NFSort -> NFEndp -> Value -> Value -> Value |
|
|
|
compOutS _ _hi _0 vl@VComp{} = vl |
|
|
@ -380,17 +383,17 @@ pres tyT tyA f phi t t0 = (VInc pathT phi (VLine (tyA VI1) c1 c2 (line path)), p |
|
|
|
|
|
|
|
path j = comp (fun tyA) (phi `ior` j) (system \i _ -> f i @@ (v i)) a0 |
|
|
|
|
|
|
|
opEquiv :: Value -> Value -> Value -> NFEndp -> Value -> Value -> Value -> (Value, NFSort, Value) |
|
|
|
opEquiv :: HasCallStack => Value -> Value -> Value -> NFEndp -> Value -> Value -> Value -> (Value, NFSort, Value) |
|
|
|
opEquiv aT tT f phi t p a = (VInc ty phi v, ty, fun \u -> VPair (t @@ u) (p @@ u)) where |
|
|
|
fn = vProj1 f |
|
|
|
ty = exists' "f" tT \x -> VPath (line (const aT)) a (fn @@ x) |
|
|
|
v = contr ty (vProj2 f @@ a) phi (\u -> VPair (t @@ u) (p @@ u)) |
|
|
|
|
|
|
|
contr :: Value -> Value -> NFEndp -> (Value -> Value) -> Value |
|
|
|
contr :: HasCallStack => Value -> Value -> NFEndp -> (Value -> Value) -> Value |
|
|
|
contr a aC phi u = |
|
|
|
comp (line (const a)) |
|
|
|
phi |
|
|
|
(system \i is1 -> ielim (line (const a)) a (vProj1 (u is1)) (vProj2 (u is1)) i) |
|
|
|
(system \i is1 -> ielim (line (const a)) (vProj1 aC) (u is1) (vProj2 aC @@ u is1) i) |
|
|
|
(vProj1 aC) |
|
|
|
|
|
|
|
makeEquiv :: (NFEndp -> Value) -> Value |
|
|
|