|
@ -216,7 +216,7 @@ outS _ _ _ v = error $ "can't outS " ++ show (prettyTm (quote v)) |
|
|
comp :: HasCallStack => NFLine -> NFEndp -> Value -> Value -> Value |
|
|
comp :: HasCallStack => NFLine -> NFEndp -> Value -> Value -> Value |
|
|
comp _a VI1 u _a0 = u @@ VI1 @@ VItIsOne |
|
|
comp _a VI1 u _a0 = u @@ VI1 @@ VItIsOne |
|
|
comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
case force $ a @@ VVar compVar of |
|
|
|
|
|
|
|
|
case force (a @@ VVar name) of |
|
|
VPi{} -> |
|
|
VPi{} -> |
|
|
let |
|
|
let |
|
|
plic i = let VPi p _ _ = force (a @@ i) in p |
|
|
plic i = let VPi p _ _ = force (a @@ i) in p |
|
@ -263,9 +263,9 @@ comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
in |
|
|
in |
|
|
let |
|
|
let |
|
|
base i = let VGlueTy b _ _ _ = forceAndGlue (fam @@ i) in b |
|
|
base i = let VGlueTy b _ _ _ = forceAndGlue (fam @@ i) in b |
|
|
phi i = substitute (Map.singleton compVar i) thePhi |
|
|
|
|
|
types i = substitute (Map.singleton compVar i) theTypes @@ VItIsOne |
|
|
|
|
|
equivs i = substitute (Map.singleton compVar i) theEquivs |
|
|
|
|
|
|
|
|
phi i = substitute (Map.singleton name i) thePhi |
|
|
|
|
|
types i = substitute (Map.singleton name i) theTypes @@ VItIsOne |
|
|
|
|
|
equivs i = substitute (Map.singleton name i) theEquivs |
|
|
|
|
|
|
|
|
a i u = unglue (base i) (phi i) (types i @@ u) (equivs i) (b @@ i @@ u) |
|
|
a i u = unglue (base i) (phi i) (types i @@ u) (equivs i) (b @@ i @@ u) |
|
|
a0 = unglue (base VI0) (phi VI0) (types VI0) (equivs VI0) b0 |
|
|
a0 = unglue (base VI0) (phi VI0) (types VI0) (equivs VI0) b0 |
|
@ -295,7 +295,7 @@ comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
in b1 |
|
|
in b1 |
|
|
|
|
|
|
|
|
VType -> VGlueTy a0 phi (fun' "is1" \is1 -> u @@ VI1 @@ is1) |
|
|
VType -> VGlueTy a0 phi (fun' "is1" \is1 -> u @@ VI1 @@ is1) |
|
|
(fun' "is1" \_ -> mapVSystem makeEquiv (u @@ VVar equivVar @@ VItIsOne)) |
|
|
|
|
|
|
|
|
(fun' "is1" \_ -> mapVSystem (makeEquiv equivVar) (u @@ VVar equivVar @@ VItIsOne)) |
|
|
|
|
|
|
|
|
VNe (HData False _) Seq.Empty -> a0 |
|
|
VNe (HData False _) Seq.Empty -> a0 |
|
|
VNe (HData False _) args -> |
|
|
VNe (HData False _) args -> |
|
@ -303,13 +303,19 @@ comp a psi@phi u incA0@(compOutS (a @@ VI1) phi (u @@ VI1 @@ VItIsOne) -> a0) = |
|
|
VNe (HCon con_type con_name) con_args -> |
|
|
VNe (HCon con_type con_name) con_args -> |
|
|
VNe (HCon con_type con_name) $ compConArgs (length args) (a @@) con_type con_args phi u |
|
|
VNe (HCon con_type con_name) $ compConArgs (length args) (a @@) con_type con_args phi u |
|
|
_ -> VComp a phi u (VInc (a @@ VI0) phi a0) |
|
|
_ -> VComp a phi u (VInc (a @@ VI0) phi a0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VNe (HData True _) args -> compHIT (length args) (a @@) phi u incA0 |
|
|
VNe (HData True _) args -> compHIT (length args) (a @@) phi u incA0 |
|
|
|
|
|
|
|
|
VLam{} -> error $ "comp VLam " ++ show (prettyTm (quote a)) |
|
|
VLam{} -> error $ "comp VLam " ++ show (prettyTm (quote a)) |
|
|
sys@VSystem{} -> error $ "comp VSystem: " ++ show (prettyTm (quote sys)) |
|
|
sys@VSystem{} -> error $ "comp VSystem: " ++ show (prettyTm (quote sys)) |
|
|
|
|
|
|
|
|
_ -> VComp a phi u (VInc (a @@ VI0) phi a0) |
|
|
_ -> VComp a phi u (VInc (a @@ VI0) phi a0) |
|
|
|
|
|
where |
|
|
|
|
|
{-# NOINLINE name #-} |
|
|
|
|
|
name = unsafePerformIO newName |
|
|
|
|
|
|
|
|
|
|
|
{-# NOINLINE equivVar #-} |
|
|
|
|
|
equivVar = unsafePerformIO newName |
|
|
|
|
|
|
|
|
mapVSystem :: (Value -> Value) -> Value -> Value |
|
|
mapVSystem :: (Value -> Value) -> Value -> Value |
|
|
mapVSystem f (VSystem fs) = VSystem (fmap f fs) |
|
|
mapVSystem f (VSystem fs) = VSystem (fmap f fs) |
|
@ -321,7 +327,12 @@ forceAndGlue v = |
|
|
v@VGlueTy{} -> v |
|
|
v@VGlueTy{} -> v |
|
|
y -> VGlueTy y VI1 (fun (const y)) (fun (const (idEquiv y))) |
|
|
y -> VGlueTy y VI1 (fun (const y)) (fun (const (idEquiv y))) |
|
|
|
|
|
|
|
|
compHIT :: Int -> (NFEndp -> NFSort) -> NFEndp -> Value -> Value -> Value |
|
|
|
|
|
|
|
|
compHIT :: HasCallStack => Int -> (NFEndp -> NFSort) -> NFEndp -> Value -> Value -> Value |
|
|
|
|
|
compHIT 0 a phi u a0 = |
|
|
|
|
|
case phi of |
|
|
|
|
|
VI1 -> u @@ VI1 @@ VItIsOne |
|
|
|
|
|
VI0 -> compOutS (a VI0) phi u a0 |
|
|
|
|
|
_ -> VHComp (a VI0) phi u a0 |
|
|
compHIT _ a phi u a0 = error $ unlines |
|
|
compHIT _ a phi u a0 = error $ unlines |
|
|
[ "*** TODO: composition for HIT: " |
|
|
[ "*** TODO: composition for HIT: " |
|
|
, "domain = " ++ show (prettyTm (quote (zonk (fun a)))) |
|
|
, "domain = " ++ show (prettyTm (quote (zonk (fun a)))) |
|
@ -357,6 +368,9 @@ compConArgs total_args fam = go total_args where |
|
|
|
|
|
|
|
|
smuggle x = VNe (HData False typeArgument) (Seq.singleton (PApp P.Ex x)) |
|
|
smuggle x = VNe (HData False typeArgument) (Seq.singleton (PApp P.Ex x)) |
|
|
|
|
|
|
|
|
|
|
|
typeArgument = unsafePerformIO newName |
|
|
|
|
|
{-# NOINLINE typeArgument #-} |
|
|
|
|
|
|
|
|
compOutS :: HasCallStack => NFSort -> NFEndp -> Value -> Value -> Value |
|
|
compOutS :: HasCallStack => NFSort -> NFEndp -> Value -> Value -> Value |
|
|
compOutS a b c d = compOutS a b c (force d) where |
|
|
compOutS a b c d = compOutS a b c (force d) where |
|
|
compOutS _ _hi _0 vl@VComp{} = vl |
|
|
compOutS _ _hi _0 vl@VComp{} = vl |
|
@ -447,10 +461,10 @@ contr a aC phi u = |
|
|
transp :: (NFEndp -> Value) -> Value -> Value |
|
|
transp :: (NFEndp -> Value) -> Value -> Value |
|
|
transp line a0 = comp (fun line) VI0 (system \_ _ -> VSystem mempty) (VInc (line VI0) VI0 a0) |
|
|
transp line a0 = comp (fun line) VI0 (system \_ _ -> VSystem mempty) (VInc (line VI0) VI0 a0) |
|
|
|
|
|
|
|
|
makeEquiv :: Value -> Value |
|
|
|
|
|
makeEquiv argh = VPair f $ fun \y -> VPair (fib y) (fun \u -> p (vProj1 u) (vProj2 u) y) |
|
|
|
|
|
|
|
|
makeEquiv :: Name -> Value -> Value |
|
|
|
|
|
makeEquiv var vne = VPair f $ fun \y -> VPair (fib y) (fun \u -> p (vProj1 u) (vProj2 u) y) |
|
|
where |
|
|
where |
|
|
line = fun \i -> substitute (Map.singleton equivVar (inot i)) argh |
|
|
|
|
|
|
|
|
line = fun \i -> substitute (Map.singleton var (inot i)) vne |
|
|
a = line @@ VI0 |
|
|
a = line @@ VI0 |
|
|
b = line @@ VI1 |
|
|
b = line @@ VI1 |
|
|
|
|
|
|
|
@ -487,14 +501,4 @@ idEquiv a = VPair idfun idisequiv where |
|
|
VLine (fun (const a)) y (vProj1 u) $ fun \j -> |
|
|
VLine (fun (const a)) y (vProj1 u) $ fun \j -> |
|
|
ielim (fun (const a)) y y (vProj2 u) (iand i j) |
|
|
ielim (fun (const a)) y y (vProj2 u) (iand i j) |
|
|
|
|
|
|
|
|
id_fiber y = VPair y (VLine a y y (fun (const y))) |
|
|
|
|
|
|
|
|
|
|
|
-- magic variables (:vomit:) |
|
|
|
|
|
compVar :: Name -- direction of composition |
|
|
|
|
|
compVar = Bound (T.pack "_comp_dir") (negate 1) |
|
|
|
|
|
|
|
|
|
|
|
equivVar :: Name -- direction of equivalence |
|
|
|
|
|
equivVar = Bound (T.pack "_equiv_dir") (negate 2) |
|
|
|
|
|
|
|
|
|
|
|
typeArgument :: Name -- marker for type arguments in composition |
|
|
|
|
|
typeArgument = Bound (T.pack "_comp_con_tyarg") (negate 3) |
|
|
|
|
|
|
|
|
id_fiber y = VPair y (VLine a y y (fun (const y))) |