@@ -23,6 +23,7 @@ data ProofState = PS { thname :: Name,
23 pterm :: Term, -- current proof term
23 pterm :: Term, -- current proof term
24 ptype :: Type, -- original goal
24 ptype :: Type, -- original goal
25 unified :: (Name, [(Name, Term)]),
25 unified :: (Name, [(Name, Term)]),
26+ solved :: Maybe (Name, Term),
26 problems :: Fails,
27 problems :: Fails,
27 injective :: [(Term, Term, Term)],
28 injective :: [(Term, Term, Term)],
28 deferred :: [Name], -- names we'll need to define
29 deferred :: [Name], -- names we'll need to define
@@ -70,8 +71,8 @@ data Tactic = Attack
70-- Some utilites on proof and tactic states
71-- Some utilites on proof and tactic states
72instance Show ProofState where
73instance Show ProofState where
73− show (PS nm [] _ tm _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
74+ show (PS nm [] _ tm _ _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
74− show (PS nm (h:hs) _ tm _ _ _ _ i _ _ ctxt _ _)
75+ show (PS nm (h:hs) _ tm _ _ _ _ _ i _ _ ctxt _ _)
75 = let OK g = goal (Just h) tm
76 = let OK g = goal (Just h) tm
76 wkenv = premises g in
77 wkenv = premises g in
77 "Other goals: " ++ show hs ++ "\n" ++
78 "Other goals: " ++ show hs ++ "\n" ++
@@ -128,7 +129,8 @@ addLog str = action (\ps -> ps { plog = plog ps ++ str ++ "\n" })
128newProof :: Name -> Context -> Type -> ProofState
129newProof :: Name -> Context -> Type -> ProofState
129newProof n ctxt ty = let h = holeName 0
130newProof n ctxt ty = let h = holeName 0
130 ty' = vToP ty in
131 ty' = vToP ty in
131− PS n [h] 1 (Bind h (Hole ty') (P Bound h ty')) ty (h, []) [] []
132+ PS n [h] 1 (Bind h (Hole ty') (P Bound h ty')) ty (h, [])
133 Nothing ctxt "" False
135 Nothing ctxt "" False
@@ -302,6 +304,7 @@ solve ctxt env (Bind x (Guess ty val) sc)
302 | pureTerm val = do ps <- get
304 | pureTerm val = do ps <- get
303 let (uh, uns) = unified ps
305 let (uh, uns) = unified ps
304 action (\ps -> ps { holes = holes ps \\ [x],
306 action (\ps -> ps { holes = holes ps \\ [x],
307+ solved = Just (x, val),
305 -- unified = (uh, uns ++ [(x, val)]),
308 -- unified = (uh, uns ++ [(x, val)]),
306 instances = instances ps \\ [x] })
309 instances = instances ps \\ [x] })
307 return $ {- Bind x (Let ty val) sc -} instantiate val (pToV x sc)
310 return $ {- Bind x (Let ty val) sc -} instantiate val (pToV x sc)
@@ -461,7 +464,8 @@ processTactic Undo ps = case previous ps of
461processTactic EndUnify ps
464processTactic EndUnify ps
462 = let (h, ns) = unified ps
465 = let (h, ns) = unified ps
463 ns' = map (\ (n, t) -> (n, updateSolved ns t)) ns
466 ns' = map (\ (n, t) -> (n, updateSolved ns t)) ns
467+ tm' = -- trace ("Updating " ++ show ns' ++ " in " ++ show (pterm ps)) $
464− tm' = updateSolved ns' (pterm ps)
468+ updateSolved ns' (pterm ps)
465 probs' = updateProblems ns' (problems ps) in
469 probs' = updateProblems ns' (problems ps) in
466 case probs' of
470 case probs' of
467 [] -> return (ps { pterm = tm',
471 [] -> return (ps { pterm = tm',
@@ -477,7 +481,12 @@ processTactic t ps
477 = case holes ps of
481 = case holes ps of
478 [] -> fail "Nothing to fill in."
482 [] -> fail "Nothing to fill in."
479 (h:_) -> do ps' <- execStateT (process t h) ps
483 (h:_) -> do ps' <- execStateT (process t h) ps
484+ let pterm' = case solved ps' of
485+ Just s -> updateSolved [s] (pterm ps')
487+ return (ps' { pterm = pterm',
480− return (ps' { previous = Just ps, plog = "" }, plog ps')
489+ previous = Just ps, plog = "" }, plog ps')
482process :: Tactic -> Name -> StateT TState TC ()
491process :: Tactic -> Name -> StateT TState TC ()
483process EndUnify _
492process EndUnify _