@@ -22,6 +22,7 @@ data ProofState = PS { thname :: Name,
22 nextname :: Int, -- name supply
22 nextname :: Int, -- name supply
23 pterm :: Term, -- current proof term
23 pterm :: Term, -- current proof term
24 ptype :: Type, -- original goal
24 ptype :: Type, -- original goal
25+ defer :: [(Name, Type)], -- names we'll need to define
25 previous :: Maybe ProofState, -- for undo
26 previous :: Maybe ProofState, -- for undo
26 context :: Context,
27 context :: Context,
27 done :: Bool
28 done :: Bool
@@ -60,8 +61,8 @@ data TacticAction = AddGoal Name -- add a new goal, solve immediately
60-- Some utilites on proof and tactic states
61-- Some utilites on proof and tactic states
62instance Show ProofState where
63instance Show ProofState where
63− show (PS nm [] _ tm _ _ _ _) = show nm ++ ": no more goals"
64+ show (PS nm [] _ tm _ _ _ _ _) = show nm ++ ": no more goals"
64− show (PS nm (h:hs) _ tm _ i_ ctxt _)
65+ show (PS nm (h:hs) _ tm _ i _ ctxt _)
65 = let OK g = goal (Just h) tm
66 = let OK g = goal (Just h) tm
66 wkenv = premises g in
67 wkenv = premises g in
67 showPs wkenv (reverse wkenv) ++ "\n" ++
68 showPs wkenv (reverse wkenv) ++ "\n" ++
@@ -103,7 +104,8 @@ action a = do (n, ts) <- get
103newProof :: Name -> Context -> Type -> ProofState
104newProof :: Name -> Context -> Type -> ProofState
104newProof n ctxt ty = let h = holeName 0
105newProof n ctxt ty = let h = holeName 0
105 ty' = vToP ty in
106 ty' = vToP ty in
106− PS n [h] 1 (Bind h (Hole ty') (P Bound h ty')) ty Nothing ctxt False
107+ PS n [h] 1 (Bind h (Hole ty') (P Bound h ty')) ty []
108type TState = (Int, [TacticAction])
110type TState = (Int, [TacticAction])
109type RunTactic = Context -> Env -> Term -> StateT TState TC Term
111type RunTactic = Context -> Env -> Term -> StateT TState TC Term
@@ -250,7 +252,6 @@ eval_in t ctxt env tm =
250 showEnv env valty'))
252 showEnv env valty'))
251 return tm
253 return tm
254processTactic :: Tactic -> ProofState -> TC (ProofState, String)
255processTactic :: Tactic -> ProofState -> TC (ProofState, String)
255processTactic QED ps = case holes ps of
256processTactic QED ps = case holes ps of
256 [] -> let tm = finalise (pterm ps) in
257 [] -> let tm = finalise (pterm ps) in
@@ -291,7 +292,7 @@ processTactic t ps
291 getSolved (_ : xs) = getSolved xs
292 getSolved (_ : xs) = getSolved xs
293 updateSolved xs (Bind n b@(Hole _) t)
294 updateSolved xs (Bind n b@(Hole _) t)
294− | Just v <- lookup n xs = Bind n (Let (binderTy b) v) (updateSolved xs t)
295+ | Just v <- lookup n xs = instantiate v (pToV n (updateSolved xs t))
295 updateSolved xs (Bind n b t)
296 updateSolved xs (Bind n b t)
296 | otherwise = Bind n (fmap (updateSolved xs) b) (updateSolved xs t)
297 | otherwise = Bind n (fmap (updateSolved xs) b) (updateSolved xs t)
297 updateSolved xs (App f a) = App (updateSolved xs f) (updateSolved xs a)
298 updateSolved xs (App f a) = App (updateSolved xs f) (updateSolved xs a)