@@ -4,7 +4,7 @@
4 proofs, and some high level commands for introducing new theorems,
4 proofs, and some high level commands for introducing new theorems,
5 evaluation/checking inside the proof system, etc. --}
5 evaluation/checking inside the proof system, etc. --}
7−module ProofState(ProofState(..), newProof,
7+module ProofState(ProofState(..), newProof, envAtFocus,
8 Tactic(..), processTactic) where
8 Tactic(..), processTactic) where
10import Typecheck
10import Typecheck
@@ -58,7 +58,7 @@ data TacticAction = AddGoal Name -- add a new goal, solve immediately
58instance Show ProofState where
58instance Show ProofState where
59 show (PS nm [] _ tm _ _ _) = show nm ++ ": no more goals"
59 show (PS nm [] _ tm _ _ _) = show nm ++ ": no more goals"
60 show (PS nm (h:hs) _ tm _ ctxt _)
60 show (PS nm (h:hs) _ tm _ ctxt _)
61− = let OK g = goal (Just h) tm ctxt
61+ = let OK g = goal (Just h) tm
62 wkenv = premises g in
62 wkenv = premises g in
63 showPs wkenv (reverse wkenv) ++ "\n" ++
63 showPs wkenv (reverse wkenv) ++ "\n" ++
64 "-------------------------------- (" ++ show nm ++
64 "-------------------------------- (" ++ show nm ++
@@ -105,8 +105,14 @@ type TState = (Int, [TacticAction])
105type RunTactic = Context -> Env -> Term -> StateT TState TC Term
105type RunTactic = Context -> Env -> Term -> StateT TState TC Term
106type Hole = Maybe Name -- Nothing = default hole, first in list in proof state
106type Hole = Maybe Name -- Nothing = default hole, first in list in proof state
108+envAtFocus :: ProofState -> TC Env
110+ | not $ null (holes ps) = do g <- goal (Just (head (holes ps))) (pterm ps)
112+ | otherwise = fail "No holes"
108−goal :: Hole -> Term -> Context -> TC Goal
114+goal :: Hole -> Term -> TC Goal
109−goal h tm ctxt = g [] tm where
115+goal h tm = g [] tm where
110 g env (Bind n b sc) | hole b && same h n = return $ GD env b
116 g env (Bind n b sc) | hole b && same h n = return $ GD env b
111 | otherwise
117 | otherwise
112 = gb env b `mplus` g ((n, b):env) sc
118 = gb env b `mplus` g ((n, b):env) sc