@@ -524,17 +524,22 @@ data Accessibility = Public | Frozen | Hidden
525data Totality = Total [Int] -- well-founded arguments
525data Totality = Total [Int] -- well-founded arguments
526 | Partial PReason
526 | Partial PReason
527 deriving Eq
528 deriving Eq
529data PReason = Other [Name] | Itself | NotCovering | NotPositive | UseUndef Name
530data PReason = Other [Name] | Itself | NotCovering | NotPositive | UseUndef Name
530 deriving (Show, Eq)
532 deriving (Show, Eq)
532instance Show Totality where
534instance Show Totality where
533 show (Total args)= "Total, " ++ show args ++ " decreasing arguments"
535 show (Total args)= "Total, " ++ show args ++ " decreasing arguments"
536+ show Unchecked = "not yet checked for totality"
534− show (Partial Itself) = "not total as it is not well founded"
537+ show (Partial Itself) = "possibly not total as it is not well founded"
535 show (Partial NotCovering) = "not total as there are missing cases"
538 show (Partial NotCovering) = "not total as there are missing cases"
536 show (Partial NotPositive) = "not strictly positive"
539 show (Partial NotPositive) = "not strictly positive"
537− show (Partial (Other ns)) = "not total due to: " ++ showSep ", " (map show ns)
540+ show (Partial (Other ns)) = "possibly not total due to: " ++ showSep ", " (map show ns)
541+ show (Partial (Mutual ns)) = "possibly not total due to mutual recursive path " ++
542+ showSep " --> " (map show ns)
540deriving instance Binary Accessibility
545deriving instance Binary Accessibility
@@ -562,7 +567,7 @@ veval ctxt env t = evalState (eval ctxt emptyContext env t []) ()
562addToCtxt :: Name -> Term -> Type -> Context -> Context
567addToCtxt :: Name -> Term -> Type -> Context -> Context
563addToCtxt n tm ty uctxt
568addToCtxt n tm ty uctxt
564 = let ctxt = definitions uctxt
569 = let ctxt = definitions uctxt
565− ctxt' = addDef n (Function ty tm, Public, Total []) ctxt in
570+ ctxt' = addDef n (Function ty tm, Public, Unchecked) ctxt in
566 uctxt { definitions = ctxt' }
571 uctxt { definitions = ctxt' }
568setAccess :: Name -> Accessibility -> Context -> Context
573setAccess :: Name -> Accessibility -> Context -> Context
@@ -579,13 +584,13 @@ setTotal n t uctxt
580addCtxtDef :: Name -> Def -> Context -> Context
585addCtxtDef :: Name -> Def -> Context -> Context
581addCtxtDef n d c = let ctxt = definitions c
586addCtxtDef n d c = let ctxt = definitions c
582− ctxt' = addDef n (d, Public, Total []) ctxt in
587+ ctxt' = addDef n (d, Public, Unchecked) ctxt in
583 c { definitions = ctxt' }
588 c { definitions = ctxt' }
585addTyDecl :: Name -> Type -> Context -> Context
590addTyDecl :: Name -> Type -> Context -> Context
586addTyDecl n ty uctxt
591addTyDecl n ty uctxt
587 = let ctxt = definitions uctxt
592 = let ctxt = definitions uctxt
588− ctxt' = addDef n (TyDecl Ref ty, Public, Total []) ctxt in
593+ ctxt' = addDef n (TyDecl Ref ty, Public, Unchecked) ctxt in
589 uctxt { definitions = ctxt' }
594 uctxt { definitions = ctxt' }
591addDatatype :: Datatype Name -> Context -> Context
596addDatatype :: Datatype Name -> Context -> Context
@@ -593,14 +598,14 @@ addDatatype (Data n tag ty cons) uctxt
593 = let ctxt = definitions uctxt
598 = let ctxt = definitions uctxt
594 ty' = normalise uctxt [] ty
599 ty' = normalise uctxt [] ty
595 ctxt' = addCons 0 cons (addDef n
600 ctxt' = addCons 0 cons (addDef n
596− (TyDecl (TCon tag (arity ty')) ty, Public, Total []) ctxt) in
601+ (TyDecl (TCon tag (arity ty')) ty, Public, Unchecked) ctxt) in
597 uctxt { definitions = ctxt' }
602 uctxt { definitions = ctxt' }
599 addCons tag [] ctxt = ctxt
604 addCons tag [] ctxt = ctxt
600 addCons tag ((n, ty) : cons) ctxt
605 addCons tag ((n, ty) : cons) ctxt
601 = let ty' = normalise uctxt [] ty in
606 = let ty' = normalise uctxt [] ty in
602 addCons (tag+1) cons (addDef n
607 addCons (tag+1) cons (addDef n
603− (TyDecl (DCon tag (arity ty')) ty, Public, Total []) ctxt)
608+ (TyDecl (DCon tag (arity ty')) ty, Public, Unchecked) ctxt)
605addCasedef :: Name -> Bool -> Bool -> Bool -> [(Term, Term)] -> [(Term, Term)] ->
610addCasedef :: Name -> Bool -> Bool -> Bool -> [(Term, Term)] -> [(Term, Term)] ->
606 Type -> Context -> Context
611 Type -> Context -> Context
@@ -612,7 +617,7 @@ addCasedef n alwaysInline tcase covering ps psrt ty uctxt
612 (CaseDef args sc _, CaseDef args' sc' _) ->
617 (CaseDef args sc _, CaseDef args' sc' _) ->
613 let inl = alwaysInline in
618 let inl = alwaysInline in
614 addDef n (CaseOp inl ty ps args sc args' sc',
619 addDef n (CaseOp inl ty ps args sc args' sc',
615− Public, Total []) ctxt in
620+ Public, Unchecked) ctxt in
616 uctxt { definitions = ctxt' }
621 uctxt { definitions = ctxt' }
617 where simpl [] = []
622 where simpl [] = []
618 simpl ((l,r) : xs) = (l, simplify uctxt [] r) : simpl xs
623 simpl ((l,r) : xs) = (l, simplify uctxt [] r) : simpl xs
@@ -620,7 +625,7 @@ addCasedef n alwaysInline tcase covering ps psrt ty uctxt
620addOperator :: Name -> Type -> Int -> ([Value] -> Maybe Value) -> Context -> Context
625addOperator :: Name -> Type -> Int -> ([Value] -> Maybe Value) -> Context -> Context
621addOperator n ty a op uctxt
626addOperator n ty a op uctxt
622 = let ctxt = definitions uctxt
627 = let ctxt = definitions uctxt
623− ctxt' = addDef n (Operator ty a op, Public, Total []) ctxt in
628+ ctxt' = addDef n (Operator ty a op, Public, Unchecked) ctxt in
624 uctxt { definitions = ctxt' }
629 uctxt { definitions = ctxt' }
626tfst (a, _, _) = a
631tfst (a, _, _) = a