|
@ -64,7 +64,7 @@ check env (P.Lam s b) expected = do |
|
|
pure (PathI (quote a) (quote x) (quote y) s bd) |
|
|
pure (PathI (quote a) (quote x) (quote y) s bd) |
|
|
|
|
|
|
|
|
check env (P.Let v t d b) expected = do |
|
|
check env (P.Let v t d b) expected = do |
|
|
ty <- check env t VType |
|
|
|
|
|
|
|
|
ty <- check env t VTypeω |
|
|
let ty' = eval env ty |
|
|
let ty' = eval env ty |
|
|
d <- check env d ty' |
|
|
d <- check env d ty' |
|
|
let d' = eval env d |
|
|
let d' = eval env d |
|
@ -84,7 +84,7 @@ check env (P.Partial fs) ty = do |
|
|
let ourFaces = Systems.faces formula |
|
|
let ourFaces = Systems.faces formula |
|
|
extentFaces = Systems.faces extent |
|
|
extentFaces = Systems.faces extent |
|
|
|
|
|
|
|
|
unless (formula == extent) $ |
|
|
|
|
|
|
|
|
unless (toDNF formula == toDNF extent) $ |
|
|
throwIO $ IncompleteSystem formula extent |
|
|
throwIO $ IncompleteSystem formula extent |
|
|
|
|
|
|
|
|
let range = formulaToTm $ toDNF formula |
|
|
let range = formulaToTm $ toDNF formula |
|
@ -164,21 +164,35 @@ infer env (P.App f x) = do |
|
|
pure (PathP (quote a) (quote ai0) (quote ai1) fun arg, a @@ arg') |
|
|
pure (PathP (quote a) (quote ai0) (quote ai1) fun arg, a @@ arg') |
|
|
|
|
|
|
|
|
infer env (P.Pi s d r) = do |
|
|
infer env (P.Pi s d r) = do |
|
|
dom <- check env d VType |
|
|
|
|
|
|
|
|
(dom, ty) <- infer env d |
|
|
|
|
|
case ty of |
|
|
|
|
|
VType -> pure VType |
|
|
|
|
|
VTypeω -> pure VTypeω |
|
|
|
|
|
_ -> throwIO . UnifyError $ NotSort ty |
|
|
let d' = eval env dom |
|
|
let d' = eval env dom |
|
|
rng <- check env { names = Map.insert s (d', VVar s) (names env) } r VType |
|
|
|
|
|
pure (Pi s dom rng, VType) |
|
|
|
|
|
|
|
|
(rng, rng_t) <- infer env { names = Map.insert s (d', VVar s) (names env) } r |
|
|
|
|
|
case ty of |
|
|
|
|
|
VType -> pure VType |
|
|
|
|
|
VTypeω -> pure VTypeω |
|
|
|
|
|
_ -> throwIO . UnifyError $ NotSort ty |
|
|
|
|
|
pure (Pi s dom rng, rng_t) |
|
|
|
|
|
|
|
|
infer env (P.Sigma s d r) = do |
|
|
infer env (P.Sigma s d r) = do |
|
|
dom <- check env d VType |
|
|
|
|
|
|
|
|
(dom, ty) <- infer env d |
|
|
|
|
|
rng_t <- |
|
|
|
|
|
case ty of |
|
|
|
|
|
VType -> pure VType |
|
|
|
|
|
VTypeω -> pure VTypeω |
|
|
|
|
|
_ -> throwIO . UnifyError $ NotSort ty |
|
|
let d' = eval env dom |
|
|
let d' = eval env dom |
|
|
rng <- check env { names = Map.insert s (d', VVar s) (names env) } r VType |
|
|
|
|
|
pure (Sigma s dom rng, VType) |
|
|
|
|
|
|
|
|
rng <- check env { names = Map.insert s (d', VVar s) (names env) } r rng_t |
|
|
|
|
|
pure (Sigma s dom rng, rng_t) |
|
|
|
|
|
|
|
|
infer env P.Type = pure (Type, VType) |
|
|
|
|
|
infer env P.I = pure (I, VType) |
|
|
|
|
|
infer env P.I0 = pure (I0, VI) |
|
|
|
|
|
infer env P.I1 = pure (I1, VI) |
|
|
|
|
|
|
|
|
infer env P.Type = pure (Type, VType) |
|
|
|
|
|
infer env P.Typeω = pure (Typeω, VTypeω) |
|
|
|
|
|
infer env P.I = pure (I, VTypeω) |
|
|
|
|
|
infer env P.I0 = pure (I0, VI) |
|
|
|
|
|
infer env P.I1 = pure (I1, VI) |
|
|
|
|
|
|
|
|
infer env (P.Cut e t) = do |
|
|
infer env (P.Cut e t) = do |
|
|
t <- check env t VType |
|
|
t <- check env t VType |
|
@ -211,7 +225,7 @@ infer env P.PartialT = do |
|
|
Lam "A" Type $ |
|
|
Lam "A" Type $ |
|
|
Partial (Var "r") (Var "A") |
|
|
Partial (Var "r") (Var "A") |
|
|
, VPi "I" VI \i -> |
|
|
, VPi "I" VI \i -> |
|
|
VPi "A" VType (const VType)) |
|
|
|
|
|
|
|
|
VPi "A" VType (const VTypeω)) |
|
|
|
|
|
|
|
|
infer env P.Comp = do |
|
|
infer env P.Comp = do |
|
|
let u_t a r = VPi "i" VI \i -> VPartial r (a @@ i) |
|
|
let u_t a r = VPi "i" VI \i -> VPartial r (a @@ i) |
|
@ -244,7 +258,7 @@ infer env (P.INot x) = (, VI) . INot <$> check env x VI |
|
|
infer env P.Lam{} = error "can't infer type for lambda" |
|
|
infer env P.Lam{} = error "can't infer type for lambda" |
|
|
|
|
|
|
|
|
infer env (P.Let v t d b) = do |
|
|
infer env (P.Let v t d b) = do |
|
|
ty <- check env t VType |
|
|
|
|
|
|
|
|
ty <- check env t VTypeω |
|
|
let ty' = eval env ty |
|
|
let ty' = eval env ty |
|
|
d <- check env d ty' |
|
|
d <- check env d ty' |
|
|
let d' = eval env d |
|
|
let d' = eval env d |
|
@ -285,4 +299,4 @@ checkFormula env (P.Is1 x) = |
|
|
Nothing -> throwIO (NotInScope x) |
|
|
Nothing -> throwIO (NotInScope x) |
|
|
|
|
|
|
|
|
index_t :: Value |
|
|
index_t :: Value |
|
|
index_t = VPi "_" VI (const VType) |
|
|
|
|
|
|
|
|
index_t = VPi "_" VI (const VTypeω) |