|
|
@ -25,7 +25,7 @@ import Syntax.Pretty (prettyTm) |
|
|
|
import Syntax |
|
|
|
|
|
|
|
import System.IO.Unsafe |
|
|
|
import Debug.Trace (traceShowId, traceShow) |
|
|
|
import Syntax.Subst |
|
|
|
|
|
|
|
wiType :: WiredIn -> NFType |
|
|
|
wiType WiType = VType |
|
|
@ -211,16 +211,9 @@ outS _ _ _ v = error $ "can't outS " ++ show (prettyTm (quote v)) |
|
|
|
|
|
|
|
-- Composition |
|
|
|
comp :: NFLine -> NFEndp -> Value -> Value -> Value |
|
|
|
comp a VI1 u _ |
|
|
|
| not (isTyFam a) = u @@ VI1 @@ VItIsOne |
|
|
|
where |
|
|
|
isTyFam a = |
|
|
|
case force (a @@ VI0) of |
|
|
|
VType -> True |
|
|
|
_ -> False |
|
|
|
|
|
|
|
comp _a VI1 u _a0 = u @@ VI1 @@ VItIsOne |
|
|
|
comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
|
case force $ a @@ VVar (Bound (T.pack "i") 0) of |
|
|
|
case force $ a @@ VVar (Bound (T.pack "i") (negate 1)) of |
|
|
|
VPi{} -> |
|
|
|
let |
|
|
|
plic i = let VPi p _ _ = force (a @@ i) in p |
|
|
@ -240,10 +233,10 @@ comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
|
rng i = let VSigma _ (Closure _ r) = force (a @@ i) in r |
|
|
|
|
|
|
|
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)) |
|
|
|
-- c1 = comp (fun dom) phi (system \i isone -> vProj1 (u @@ i @@ isone)) (VInc (dom VI0) phi (vProj1 a0)) |
|
|
|
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 |
|
|
|
VPair (w VI1) c2 |
|
|
|
|
|
|
|
VPath{} -> |
|
|
|
let |
|
|
@ -259,17 +252,16 @@ comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
|
, (inot j, u' i)])) |
|
|
|
(VInc (a' VI0 @@ VI0 @@ j) phi (ielim (a' VI0 @@ VI0) (u' VI0) (v' VI0) a0 j)) |
|
|
|
|
|
|
|
VGlueTy{} -> |
|
|
|
VGlueTy theBase thePhi theTypes theEquivs -> |
|
|
|
let |
|
|
|
b = u |
|
|
|
b0 = a0 |
|
|
|
fam = a |
|
|
|
in |
|
|
|
let |
|
|
|
base i = let VGlueTy base _ _ _ = forceAndGlue (fam @@ i) in base |
|
|
|
phi i = let VGlueTy _ phi _ _ = forceAndGlue (fam @@ i) in phi |
|
|
|
types i = let VGlueTy _ _ types _ = forceAndGlue (fam @@ i) in types |
|
|
|
equivs i = let VGlueTy _ _ _ equivs = forceAndGlue (fam @@ i) in equivs |
|
|
|
base i = substitute (Map.singleton (Bound "i" (negate 1)) i) theBase |
|
|
|
phi i = substitute (Map.singleton (Bound "i" (negate 1)) i) thePhi |
|
|
|
types i = substitute (Map.singleton (Bound "i" (negate 1)) i) theTypes |
|
|
|
equivs i = substitute (Map.singleton (Bound "i" (negate 1)) i) theEquivs |
|
|
|
|
|
|
|
a i = fun \u -> unglue (base i) (phi i) (types i @@ u) (equivs i @@ u) (b @@ i @@ u) |
|
|
|
a0 = unglue (base VI0) (phi VI0) (types VI0) (equivs VI0) b0 |
|
|
@ -299,7 +291,7 @@ comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
|
in b1 |
|
|
|
|
|
|
|
VType -> VGlueTy a0 phi (fun \is1 -> u @@ VI1 @@ is1) |
|
|
|
(fun \i -> mkVSystem (Map.fromList [(phi, makeEquiv (\i -> u @@ inot i @@ VItIsOne))])) |
|
|
|
(fun \i -> mapVSystem makeEquiv (u @@ inot i @@ VItIsOne)) |
|
|
|
|
|
|
|
VNe (HData False _) args -> |
|
|
|
case force a0 of |
|
|
@ -311,6 +303,10 @@ comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
|
|
|
|
|
_ -> VComp a phi u (VInc (a @@ VI0) phi a0) |
|
|
|
|
|
|
|
mapVSystem :: (Value -> Value) -> Value -> Value |
|
|
|
mapVSystem f (VSystem fs) = VSystem (fmap f fs) |
|
|
|
mapVSystem f x = f x |
|
|
|
|
|
|
|
forceAndGlue :: Value -> Value |
|
|
|
forceAndGlue v = |
|
|
|
case force v of |
|
|
@ -357,17 +353,17 @@ compOutS :: NFSort -> NFEndp -> Value -> Value -> Value |
|
|
|
compOutS a b c d = compOutS a b c (force d) where |
|
|
|
compOutS _ _hi _0 vl@VComp{} = vl |
|
|
|
compOutS _ _hi _0 (VInc _ _ x) = x |
|
|
|
compOutS _ _ _ v = v |
|
|
|
compOutS a phi a0 v = outS a phi a0 v |
|
|
|
|
|
|
|
system :: (Value -> Value -> Value) -> Value |
|
|
|
system k = fun \i -> fun \isone -> k i isone |
|
|
|
system k = VLam P.Ex $ Closure (Bound "i" 0) \i -> VLam P.Ex $ Closure (Bound "phi" 0) \isone -> k i isone |
|
|
|
|
|
|
|
fill :: NFLine -> NFEndp -> Value -> Value -> NFEndp -> Value |
|
|
|
fill a phi u a0 j = |
|
|
|
comp (line \i -> a @@ (i `iand` j)) |
|
|
|
(phi `ior` inot j) |
|
|
|
(fun \i -> fun \isone -> mkVSystem (Map.fromList [ (phi, u @@ (i `iand` j) @@ isone) |
|
|
|
, (inot j, a0)])) |
|
|
|
(system \i isone -> mkVSystem (Map.fromList [ (phi, u @@ (i `iand` j) @@ isone) |
|
|
|
, (inot j, outS a phi (u @@ VI0) a0)])) |
|
|
|
a0 |
|
|
|
|
|
|
|
hComp :: NFSort -> NFEndp -> Value -> Value -> Value |
|
|
@ -440,9 +436,38 @@ contr a aC phi u = |
|
|
|
(system \i is1 -> ielim (line (const a)) (vProj1 aC) (u is1) (vProj2 aC @@ u is1) i) |
|
|
|
(vProj1 aC) |
|
|
|
|
|
|
|
makeEquiv :: (NFEndp -> Value) -> Value |
|
|
|
makeEquiv line = comp (fun \i -> equiv a (line i)) VI0 (system \_ _ -> VSystem mempty) (idEquiv a) where |
|
|
|
a = line VI0 |
|
|
|
transp :: (NFEndp -> Value) -> Value -> Value |
|
|
|
transp line a0 = comp (fun line) VI0 (system \_ _ -> VSystem mempty) (VInc (line VI0) VI0 a0) |
|
|
|
|
|
|
|
makeEquiv :: Value -> Value |
|
|
|
makeEquiv line = VPair f $ fun \y -> VPair (fib y) (fun \u -> p (vProj1 u) (vProj2 u) y) |
|
|
|
where |
|
|
|
a = line @@ VI0 |
|
|
|
b = line @@ VI1 |
|
|
|
|
|
|
|
f = fun \x -> transp (line @@) x |
|
|
|
g = fun \x -> transp ((line @@) . inot) x |
|
|
|
u i = fun \x -> fill line VI0 (system \_ _ -> mkVSystem mempty) x i |
|
|
|
v i = fun \x -> fill (fun ((line @@) . inot)) VI0 (system \_ _ -> mkVSystem mempty) x i |
|
|
|
|
|
|
|
fib y = VPair (g @@ y) (VLine b y (f @@ (g @@ y)) (fun (theta0 y VI1))) |
|
|
|
theta0 y i j = fill line (ior j (inot j)) (system \i _ -> mkVSystem (Map.fromList [(j, v i @@ y), (inot j, u i @@ (g @@ y))])) (VInc a (ior j (inot j)) (g @@ y)) i |
|
|
|
theta1 x beta y i j = |
|
|
|
fill (fun ((line @@) . inot)) |
|
|
|
(ior j (inot j)) |
|
|
|
(system \i _ -> mkVSystem (Map.fromList [ (inot j, v (inot i) @@ y) |
|
|
|
, (j, u (inot i) @@ x)])) |
|
|
|
(VInc b (ior j (inot j)) (ielim b y (f @@ x) beta y)) |
|
|
|
(inot i) |
|
|
|
omega x beta y = theta1 x beta y VI0 |
|
|
|
delta x beta y j k = comp line (ior k (ior (inot k) (ior j (inot j)))) |
|
|
|
(system \i _ -> mkVSystem (Map.fromList [ (inot k, theta0 y i j) |
|
|
|
, (k, theta1 x beta y i j) |
|
|
|
, (inot j, v i @@ y) |
|
|
|
, (j, u i @@ omega x beta y k)])) |
|
|
|
(VInc a (ior k (ior (inot k) (ior j (inot j)))) (omega x beta y (iand j k))) |
|
|
|
p x beta y = VLine (exists a \x -> VPath b y (f @@ x)) (fib y) (VPair x beta) $ fun \k -> |
|
|
|
VPair (omega x beta y k) (VLine (VPath b y (f @@ x)) (vProj2 (fib y)) beta $ fun \j -> delta x beta y j k) |
|
|
|
|
|
|
|
idEquiv :: NFSort -> Value |
|
|
|
idEquiv a = VPair idfun idisequiv where |
|
|
@ -453,4 +478,4 @@ idEquiv a = VPair idfun idisequiv where |
|
|
|
VLine (fun (const a)) y (vProj1 u) $ fun \j -> |
|
|
|
ielim (fun (const a)) y y (vProj2 u) (iand i j) |
|
|
|
|
|
|
|
id_fiber y = VPair y (VLine a y y (fun (const y))) |
|
|
|
id_fiber y = VPair y (VLine a y y (fun (const y))) |