@@ -423,7 +423,15 @@ buildSCG' ist pats args = nub $ concatMap scgPat pats where
423 | not (f `elem` pvs) = [(f, [])]
423 | not (f `elem` pvs) = [(f, [])]
424 findCalls _ _ _ = []
424 findCalls _ _ _ = []
426+ expandToArity n args
427+ = case lookupTy n (tt_ctxt ist) of
428+ [ty] -> expand 0 (normalise (tt_ctxt ist) [] ty) args
430+ where expand i (Bind n (Pi _) sc) (x : xs) = x : expand (i + 1) sc xs
431+ expand i (Bind n (Pi _) sc) [] = Just (i, Same) : expand (i + 1) sc []
426− mkChange n args pargs = [(n, sizes args)]
434+ mkChange n args pargs = [(n, expandToArity n (sizes args))]
428 sizes [] = []
436 sizes [] = []
429 sizes (a : as) = checkSize a pargs 0 : sizes as
437 sizes (a : as) = checkSize a pargs 0 : sizes as
@@ -574,12 +582,16 @@ checkSizeChange n = do
574 -- thread, then the function terminates
582 -- thread, then the function terminates
575 -- also need to checks functions called are all total
583 -- also need to checks functions called are all total
576 -- (Unchecked is okay as we'll spot problems here)
584 -- (Unchecked is okay as we'll spot problems here)
577− let tot = map (checkMP ist (length (argsdef cg))) ms
585+ let tot = map (checkMP ist (getArity ist n)) ms
578 logLvl 4 $ "Generated " ++ show (length tot) ++ " paths"
586 logLvl 4 $ "Generated " ++ show (length tot) ++ " paths"
579 logLvl 6 $ "Paths for " ++ show n ++ " yield " ++ (show tot)
587 logLvl 6 $ "Paths for " ++ show n ++ " yield " ++ (show tot)
580 return (noPartial tot)
588 return (noPartial tot)
581 [] -> do logLvl 5 $ "No paths for " ++ show n
589 [] -> do logLvl 5 $ "No paths for " ++ show n
582 return Unchecked
590 return Unchecked
591+ where getArity ist n
592+ = case lookupTy n (tt_ctxt ist) of
593+ [ty] -> arity (normalise (tt_ctxt ist) [] ty)
594+ _ -> error "Can't happen: checkSizeChange.getArity"
584type MultiPath = [SCGEntry]
596type MultiPath = [SCGEntry]
@@ -609,7 +621,9 @@ mkMultiPaths ist path cg
610checkMP :: IState -> Int -> MultiPath -> Totality
622checkMP :: IState -> Int -> MultiPath -> Totality
611checkMP ist i mp = if i > 0
623checkMP ist i mp = if i > 0
612− then collapse (map (tryPath 0 [] mp) [0..i-1])
624+ then let paths = (map (tryPath 0 [] mp) [0..i-1]) in
625+-- trace ("Paths " ++ show paths) $
613 else tryPath 0 [] mp 0
627 else tryPath 0 [] mp 0
615 tryPath' d path mp arg
629 tryPath' d path mp arg
@@ -635,12 +649,15 @@ checkMP ist i mp = if i > 0
635 | Just d <- lookup e path
649 | Just d <- lookup e path
636 = if desc > 0
650 = if desc > 0
637 then -- trace ("Descent " ++ show (desc - d) ++ " "
651 then -- trace ("Descent " ++ show (desc - d) ++ " "
638− -- ++ show (path, e)) $
652+ -- ++ show (path, e)) $
640 else Partial (Mutual (map (fst . fst) path ++ [f]))
654 else Partial (Mutual (map (fst . fst) path ++ [f]))
641 | [Unchecked] <- lookupTotal f (tt_ctxt ist) =
655 | [Unchecked] <- lookupTotal f (tt_ctxt ist) =
642− let argspos = collapseNothing (zip nextargs [0..]) in
656+ let argspos = case collapseNothing (zip nextargs [0..]) of
643− collapse' Unchecked $
657+ [] -> [(Nothing, 0)]
659+-- trace (show (argspos, nextargs, path)) $
644 do (a, pos) <- argspos
661 do (a, pos) <- argspos
645 case a of
662 case a of
646 Nothing -> -- don't know, but if the
663 Nothing -> -- don't know, but if the
@@ -662,7 +679,10 @@ checkMP ist i mp = if i > 0
663 _ -> trace ("Shouldn't happen " ++ show e) $
680 _ -> trace ("Shouldn't happen " ++ show e) $
664 return (Partial Itself)
681 return (Partial Itself)
665− else return Unchecked
682+ else return Unchecked in
683+-- trace (show (desc, argspos, path, es, pathres)) $
684+ collapse' Unchecked pathres
666 | [Total a] <- lookupTotal f (tt_ctxt ist) = Total a
686 | [Total a] <- lookupTotal f (tt_ctxt ist) = Total a
667 | [Partial _] <- lookupTotal f (tt_ctxt ist) = Partial (Other [f])
687 | [Partial _] <- lookupTotal f (tt_ctxt ist) = Partial (Other [f])
668 | otherwise = Unchecked
688 | otherwise = Unchecked
@@ -671,8 +691,8 @@ allNothing xs = null (collapseNothing (zip xs [0..]))
672collapseNothing ((Nothing, _) : xs)
692collapseNothing ((Nothing, _) : xs)
673 = filter (\ (x, _) -> case x of
693 = filter (\ (x, _) -> case x of
674− Nothing -> False
694+ Nothing -> False
675− _ -> True) xs
695+ _ -> True) xs
676collapseNothing (x : xs) = x : collapseNothing xs
696collapseNothing (x : xs) = x : collapseNothing xs
677collapseNothing [] = []
697collapseNothing [] = []