@@ -36,7 +36,7 @@ toplevel = EInfo [] emptyContext id Nothing
36-- Also find deferred names in the term and their types
36-- Also find deferred names in the term and their types
38build :: IState -> ElabInfo -> Bool -> Name -> PTerm ->
38build :: IState -> ElabInfo -> Bool -> Name -> PTerm ->
39− ElabD (Term, [(Name, (Int, Type))], [PDecl])
39+ ElabD (Term, [(Name, (Int, Maybe Name, Type))], [PDecl])
40build ist info pattern fn tm
40build ist info pattern fn tm
41 = do elab ist info pattern False fn tm
41 = do elab ist info pattern False fn tm
42 ivs <- get_instances
42 ivs <- get_instances
@@ -64,7 +64,7 @@ build ist info pattern fn tm
64 ((_,_,_,e):es) -> lift (Error e)
64 ((_,_,_,e):es) -> lift (Error e)
65 is <- getAux
65 is <- getAux
66 tt <- get_term
66 tt <- get_term
67− let (tm, ds) = runState (collectDeferred tt) []
67+ let (tm, ds) = runState (collectDeferred (Just fn) tt) []
68 log <- getLog
68 log <- getLog
69 if (log /= "") then trace log $ return (tm, ds, is)
69 if (log /= "") then trace log $ return (tm, ds, is)
70 else return (tm, ds, is)
70 else return (tm, ds, is)
@@ -74,7 +74,7 @@ build ist info pattern fn tm
74-- know about yet on the LHS of a pattern def)
74-- know about yet on the LHS of a pattern def)
76buildTC :: IState -> ElabInfo -> Bool -> Bool -> Name -> PTerm ->
76buildTC :: IState -> ElabInfo -> Bool -> Bool -> Name -> PTerm ->
77− ElabD (Term, [(Name, (Int, Type))], [PDecl])
77+ ElabD (Term, [(Name, (Int, Maybe Name, Type))], [PDecl])
78buildTC ist info pattern tcgen fn tm
78buildTC ist info pattern tcgen fn tm
79 = do elab ist info pattern tcgen fn tm
79 = do elab ist info pattern tcgen fn tm
80 probs <- get_probs
80 probs <- get_probs
@@ -84,7 +84,7 @@ buildTC ist info pattern tcgen fn tm
84 ((_,_,_,e):es) -> lift (Error e)
84 ((_,_,_,e):es) -> lift (Error e)
85 is <- getAux
85 is <- getAux
86 tt <- get_term
86 tt <- get_term
87− let (tm, ds) = runState (collectDeferred tt) []
87+ let (tm, ds) = runState (collectDeferred (Just fn) tt) []
88 log <- getLog
88 log <- getLog
89 if (log /= "") then trace log $ return (tm, ds, is)
89 if (log /= "") then trace log $ return (tm, ds, is)
90 else return (tm, ds, is)
90 else return (tm, ds, is)
@@ -646,8 +646,8 @@ findInstances ist t
647trivial' ist
647trivial' ist
648 = trivial (elab ist toplevel False False (MN 0 "tac")) ist
648 = trivial (elab ist toplevel False False (MN 0 "tac")) ist
649−proofSearch' ist n
649+proofSearch' ist top n
650− = proofSearch (elab ist toplevel False False (MN 0 "tac")) n ist
650+ = proofSearch (elab ist toplevel False False (MN 0 "tac")) top n ist
653resolveTC :: Int -> Name -> IState -> ElabD ()
653resolveTC :: Int -> Name -> IState -> ElabD ()
@@ -736,21 +736,22 @@ resolveTC depth fn ist
736 where isImp (PImp p _ _ _ _ _) = (True, p)
736 where isImp (PImp p _ _ _ _ _) = (True, p)
737 isImp arg = (False, priority arg)
737 isImp arg = (False, priority arg)
739+collectDeferred :: Maybe Name ->
739−collectDeferred :: Term -> State [(Name, (Int, Type))] Term
740+ Term -> State [(Name, (Int, Maybe Name, Type))] Term
740−collectDeferred (Bind n (GHole i t) app) =
741+collectDeferred top (Bind n (GHole i t) app) =
741 do ds <- get
742 do ds <- get
742− when (not (n `elem` map fst ds)) $ put ((n, (i, t)) : ds)
743+ when (not (n `elem` map fst ds)) $ put ((n, (i, top, t)) : ds)
743− collectDeferred app
744+ collectDeferred top app
744−collectDeferred (Bind n b t) = do b' <- cdb b
745+collectDeferred top (Bind n b t) = do b' <- cdb b
745− t' <- collectDeferred t
746+ t' <- collectDeferred top t
746− return (Bind n b' t')
747+ return (Bind n b' t')
748− cdb (Let t v) = liftM2 Let (collectDeferred t) (collectDeferred v)
749+ cdb (Let t v) = liftM2 Let (collectDeferred top t) (collectDeferred top v)
749− cdb (Guess t v) = liftM2 Guess (collectDeferred t) (collectDeferred v)
750+ cdb (Guess t v) = liftM2 Guess (collectDeferred top t) (collectDeferred top v)
750− cdb b = do ty' <- collectDeferred (binderTy b)
751+ cdb b = do ty' <- collectDeferred top (binderTy b)
751 return (b { binderTy = ty' })
752 return (b { binderTy = ty' })
752−collectDeferred (App f a) = liftM2 App (collectDeferred f) (collectDeferred a)
753+collectDeferred top (App f a) = liftM2 App (collectDeferred top f) (collectDeferred top a)
753−collectDeferred t = return t
754+collectDeferred top t = return t
755-- Running tactics directly
756-- Running tactics directly
756-- if a tactic adds unification problems, return an error
757-- if a tactic adds unification problems, return an error
@@ -862,7 +863,7 @@ runTac autoSolve ist tac
862 when autoSolve solveAll
863 when autoSolve solveAll
863 runT Compute = compute
864 runT Compute = compute
864 runT Trivial = do trivial' ist; when autoSolve solveAll
865 runT Trivial = do trivial' ist; when autoSolve solveAll
865− runT (ProofSearch n) = do proofSearch' ist n; when autoSolve solveAll
866+ runT (ProofSearch top n) = do proofSearch' ist top n; when autoSolve solveAll
866 runT (Focus n) = focus n
867 runT (Focus n) = focus n
867 runT Solve = solve
868 runT Solve = solve
868 runT (Try l r) = do try' (runT l) (runT r) True
869 runT (Try l r) = do try' (runT l) (runT r) True