@@ -524,17 +524,22 @@ data Accessibility = Public | Frozen | Hidden
524524
525525data Totality = Total [Int] -- well-founded arguments
526526 | Partial PReason
527+ | Unchecked
527528 deriving Eq
528529
529530data PReason = Other [Name] | Itself | NotCovering | NotPositive | UseUndef Name
531+ | Mutual [Name]
530532 deriving (Show, Eq)
531533
532534instance Show Totality where
533535 show (Total args)= "Total, " ++ show args ++ " decreasing arguments"
534− show (Partial Itself) = "not total as it is not well founded"
536+ show Unchecked = "not yet checked for totality"
537+ show (Partial Itself) = "possibly not total as it is not well founded"
535538 show (Partial NotCovering) = "not total as there are missing cases"
536539 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)
538543
539544{-!
540545deriving instance Binary Accessibility
@@ -562,7 +567,7 @@ veval ctxt env t = evalState (eval ctxt emptyContext env t []) ()
562567addToCtxt :: Name -> Term -> Type -> Context -> Context
563568addToCtxt n tm ty uctxt
564569 = 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
566571 uctxt { definitions = ctxt' }
567572
568573setAccess :: Name -> Accessibility -> Context -> Context
@@ -579,13 +584,13 @@ setTotal n t uctxt
579584
580585addCtxtDef :: Name -> Def -> Context -> Context
581586addCtxtDef 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
583588 c { definitions = ctxt' }
584589
585590addTyDecl :: Name -> Type -> Context -> Context
586591addTyDecl n ty uctxt
587592 = 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
589594 uctxt { definitions = ctxt' }
590595
591596addDatatype :: Datatype Name -> Context -> Context
@@ -593,14 +598,14 @@ addDatatype (Data n tag ty cons) uctxt
593598 = let ctxt = definitions uctxt
594599 ty' = normalise uctxt [] ty
595600 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
597602 uctxt { definitions = ctxt' }
598603 where
599604 addCons tag [] ctxt = ctxt
600605 addCons tag ((n, ty) : cons) ctxt
601606 = let ty' = normalise uctxt [] ty in
602607 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)
604609
605610addCasedef :: Name -> Bool -> Bool -> Bool -> [(Term, Term)] -> [(Term, Term)] ->
606611 Type -> Context -> Context
@@ -612,7 +617,7 @@ addCasedef n alwaysInline tcase covering ps psrt ty uctxt
612617 (CaseDef args sc _, CaseDef args' sc' _) ->
613618 let inl = alwaysInline in
614619 addDef n (CaseOp inl ty ps args sc args' sc',
615− Public, Total []) ctxt in
620+ Public, Unchecked) ctxt in
616621 uctxt { definitions = ctxt' }
617622 where simpl [] = []
618623 simpl ((l,r) : xs) = (l, simplify uctxt [] r) : simpl xs
@@ -620,7 +625,7 @@ addCasedef n alwaysInline tcase covering ps psrt ty uctxt
620625addOperator :: Name -> Type -> Int -> ([Value] -> Maybe Value) -> Context -> Context
621626addOperator n ty a op uctxt
622627 = 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
624629 uctxt { definitions = ctxt' }
625630
626631tfst (a, _, _) = a