@@ -23,6 +23,7 @@ data ProofState = PS { thname :: Name,
2323 pterm :: Term, -- current proof term
2424 ptype :: Type, -- original goal
2525 unified :: (Name, [(Name, Term)]),
26+ solved :: Maybe (Name, Term),
2627 problems :: Fails,
2728 injective :: [(Term, Term, Term)],
2829 deferred :: [Name], -- names we'll need to define
@@ -70,8 +71,8 @@ data Tactic = Attack
7071-- Some utilites on proof and tactic states
7172
7273instance Show ProofState where
73− show (PS nm [] _ tm _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
74− show (PS nm (h:hs) _ tm _ _ _ _ i _ _ ctxt _ _)
74+ show (PS nm [] _ tm _ _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
75+ show (PS nm (h:hs) _ tm _ _ _ _ _ i _ _ ctxt _ _)
7576 = let OK g = goal (Just h) tm
7677 wkenv = premises g in
7778 "Other goals: " ++ show hs ++ "\n" ++
@@ -128,7 +129,8 @@ addLog str = action (\ps -> ps { plog = plog ps ++ str ++ "\n" })
128129newProof :: Name -> Context -> Type -> ProofState
129130newProof n ctxt ty = let h = holeName 0
130131 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 [] []
132134 [] []
133135 Nothing ctxt "" False
134136
@@ -302,6 +304,7 @@ solve ctxt env (Bind x (Guess ty val) sc)
302304 | pureTerm val = do ps <- get
303305 let (uh, uns) = unified ps
304306 action (\ps -> ps { holes = holes ps \\ [x],
307+ solved = Just (x, val),
305308 -- unified = (uh, uns ++ [(x, val)]),
306309 instances = instances ps \\ [x] })
307310 return $ {- Bind x (Let ty val) sc -} instantiate val (pToV x sc)
@@ -461,7 +464,8 @@ processTactic Undo ps = case previous ps of
461464processTactic EndUnify ps
462465 = let (h, ns) = unified ps
463466 ns' = map (\ (n, t) -> (n, updateSolved ns t)) ns
464− tm' = updateSolved ns' (pterm ps)
467+ tm' = -- trace ("Updating " ++ show ns' ++ " in " ++ show (pterm ps)) $
468+ updateSolved ns' (pterm ps)
465469 probs' = updateProblems ns' (problems ps) in
466470 case probs' of
467471 [] -> return (ps { pterm = tm',
@@ -477,7 +481,12 @@ processTactic t ps
477481 = case holes ps of
478482 [] -> fail "Nothing to fill in."
479483 (h:_) -> do ps' <- execStateT (process t h) ps
480− return (ps' { previous = Just ps, plog = "" }, plog ps')
484+ let pterm' = case solved ps' of
485+ Just s -> updateSolved [s] (pterm ps')
486+ _ -> pterm ps'
487+ return (ps' { pterm = pterm',
488+ solved = Nothing,
489+ previous = Just ps, plog = "" }, plog ps')
481490
482491process :: Tactic -> Name -> StateT TState TC ()
483492process EndUnify _