@@ -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 injective :: [(Term, Term, Term)],
27 injective :: [(Term, Term, Term)],
27 deferred :: [Name], -- names we'll need to define
28 deferred :: [Name], -- names we'll need to define
28 instances :: [Name], -- instance arguments (for type classes)
29 instances :: [Name], -- instance arguments (for type classes)
@@ -69,8 +70,8 @@ data Tactic = Attack
69-- Some utilites on proof and tactic states
70-- Some utilites on proof and tactic states
71instance Show ProofState where
72instance Show ProofState where
72− show (PS nm [] _ tm _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
73+ show (PS nm [] _ tm _ _ _ _ _ _ _ _ _ _) = show nm ++ ": no more goals"
73− show (PS nm (h:hs) _ tm _ _ _ i _ _ ctxt _ _)
74+ show (PS nm (h:hs) _ tm _ _ _ _ i _ _ ctxt _ _)
74 = let OK g = goal (Just h) tm
75 = let OK g = goal (Just h) tm
75 wkenv = premises g in
76 wkenv = premises g in
76 "Other goals: " ++ show hs ++ "\n" ++
77 "Other goals: " ++ show hs ++ "\n" ++
@@ -106,7 +107,10 @@ unify' ctxt env topx topy = do (u, inj, fails) <- lift $ unify ctxt env topx top
106 addInj inj
107 addInj inj
107 case fails of
108 case fails of
108 [] -> return u
109 [] -> return u
109− ((_,_,err):_) -> lift $ tfail err
110+ err ->
112+ put (ps { problems = err ++ problems ps })
111getName :: Monad m => String -> StateT TState m Name
115getName :: Monad m => String -> StateT TState m Name
112getName tag = do ps <- get
116getName tag = do ps <- get
@@ -124,7 +128,7 @@ addLog str = action (\ps -> ps { plog = plog ps ++ str ++ "\n" })
124newProof :: Name -> Context -> Type -> ProofState
128newProof :: Name -> Context -> Type -> ProofState
125newProof n ctxt ty = let h = holeName 0
129newProof n ctxt ty = let h = holeName 0
126 ty' = vToP ty in
130 ty' = vToP ty in
127− PS n [h] 1 (Bind h (Hole ty') (P Bound h ty')) ty (h, []) []
131+ PS n [h] 1 (Bind h (Hole ty') (P Bound h ty')) ty (h, []) [] []
129 Nothing ctxt "" False
133 Nothing ctxt "" False
@@ -437,6 +441,12 @@ updateSolved xs (P _ n _)
437 | Just v <- lookup n xs = v
441 | Just v <- lookup n xs = v
438updateSolved xs t = t
442updateSolved xs t = t
444+updateProblems ns [] = []
445+updateProblems ns ((x, y, env, err) : ps) =
446+ let x' = updateSolved ns x
447+ y' = updateSolved ns y in
448+ (x',y',env,err) : updateProblems ns ps
440processTactic :: Tactic -> ProofState -> TC (ProofState, String)
450processTactic :: Tactic -> ProofState -> TC (ProofState, String)
441processTactic QED ps = case holes ps of
451processTactic QED ps = case holes ps of
442 [] -> do let tm = {- normalise (context ps) [] -} (pterm ps)
452 [] -> do let tm = {- normalise (context ps) [] -} (pterm ps)
@@ -448,13 +458,17 @@ processTactic ProofState ps = return (ps, showEnv [] (pterm ps))
448processTactic Undo ps = case previous ps of
458processTactic Undo ps = case previous ps of
449 Nothing -> fail "Nothing to undo."
459 Nothing -> fail "Nothing to undo."
450 Just pold -> return (pold, "")
460 Just pold -> return (pold, "")
451−processTactic EndUnify ps = let (h, ns) = unified ps
461+processTactic EndUnify ps
462+ = let (h, ns) = unified ps
452− tm' = updateSolved ns (pterm ps) in
463+ tm' = updateSolved ns (pterm ps)
464+ probs' = updateProblems ns (problems ps) in
453− return (ps { pterm = tm',
466+ [] -> return (ps { pterm = tm',
454− unified = (h, []),
467+ unified = (h, []),
455− injective = map (tmap (updateSolved ns))
468+ injective = map (tmap (updateSolved ns))
456− (injective ps),
469+ (injective ps),
457− holes = holes ps \\ map fst ns }, "")
470+ holes = holes ps \\ map fst ns }, "")
471+ errs@((_,_,_,err):_) -> tfail err
458processTactic (Reorder n) ps
472processTactic (Reorder n) ps
459 = do ps' <- execStateT (tactic (Just n) reorder_claims) ps
473 = do ps' <- execStateT (tactic (Just n) reorder_claims) ps
460 return (ps' { previous = Just ps, plog = "" }, plog ps')
474 return (ps' { previous = Just ps, plog = "" }, plog ps')