support (VCon _ vs) = support vs
support (VPCon _ a vs phi) = support (a,vs,phi)
support (VVar _ v) = support v
- support (VUndef _ v) = support v
support (VApp u v) = support (u,v)
support (VLam _ u v) = support (u,v)
support (VAppFormula u phi) = support (u,phi)
VCon c vs -> VCon c (acti vs)
VPCon c a vs phi -> pcon c (acti a) (acti vs) (acti phi)
VVar x v -> VVar x (acti v)
- VUndef x v -> VUndef x (acti v)
VAppFormula u psi -> acti u @@ acti psi
VApp u v -> app (acti u) (acti v)
VLam x t u -> VLam x (acti t) (acti u)
VCon c vs -> VCon c (sw vs)
VPCon c a vs phi -> VPCon c (sw a) (sw vs) (sw phi)
VVar x v -> VVar x (sw v)
- VUndef x v -> VUndef x (sw v)
VAppFormula u psi -> VAppFormula (sw u) (sw psi)
VApp u v -> VApp (sw u) (sw v)
VLam x u v -> VLam x (sw u) (sw v)
U -> VU
App r s -> app (eval rho r) (eval rho s)
Var i -> look i rho
- Undef l t -> VUndef l (eval rho t)
Pi t@(Lam _ a _) -> VPi (eval rho a) (eval rho t)
Lam{} -> Ter v rho
Sigma t@(Lam _ a _) -> VSigma (eval rho a) (eval rho t)
CompElem a es u us -> compElem (eval rho a) (evalSystem rho es) (eval rho u)
(evalSystem rho us)
ElimComp a es u -> elimComp (eval rho a) (evalSystem rho es) (eval rho u)
+ _ -> error $ "Cannot evaluate " ++ show v
evalFormula :: Env -> Formula -> Formula
evalFormula rho phi = case phi of
inferType :: Val -> Val
inferType v = case v of
VVar _ t -> t
- VUndef _ t -> t
+ Ter (Undef _ t) rho -> eval rho t
VFst t -> case inferType t of
VSigma a _ -> a
ty -> error $ "inferType: expected Sigma type for " ++ show v
in conv (k+1) (app u' v) (eval (Upd e (x,v)) u)
(Ter (Split _ p _ _) e,Ter (Split _ p' _ _) e') -> (p == p') && conv k e e'
(Ter (Sum p _ _) e,Ter (Sum p' _ _) e') -> (p == p') && conv k e e'
- (VUndef p _,VUndef p' _) -> p == p'
+ (Ter (Undef p _) e,Ter (Undef p' _) e') -> p == p' && conv k e e'
(VPi u v,VPi u' v') ->
let w = mkVar k u
in conv k u u' && conv (k+1) (app v w) (app v' w)