@@ -4,7 +4,7 @@
44 proofs, and some high level commands for introducing new theorems,
55 evaluation/checking inside the proof system, etc. --}
66
7−module ProofState(ProofState(..), newProof, envAtFocus,
7+module ProofState(ProofState(..), newProof, envAtFocus, goalAtFocus,
88 Tactic(..), processTactic) where
99
1010import Typecheck
@@ -42,13 +42,14 @@ data Tactic = Attack
4242 | Intro Name
4343 | Forall Name Raw
4444 | Focus Name
45+ | MoveLast Name
4546 | ProofState
4647 | QED
47−-- Next: add 'EvalHere' and 'CheckHere' tactics
4848
4949data TacticAction = AddGoal Name -- add a new goal, solve immediately
5050 | NextGoal Name -- add a new goal, solve it after current one
5151 | FocusGoal Name -- focus on this goal next
52+ | MoveGoal Name -- move this goal to the end of the hole queue
5253 | Solved Name
5354 | AlsoSolved Name Term -- goals solved by unification
5455 | Log String
@@ -111,6 +112,11 @@ envAtFocus ps
111112 return (premises g)
112113 | otherwise = fail "No holes"
113114
115+goalAtFocus :: ProofState -> TC Type
116+goalAtFocus ps
117+ | not $ null (holes ps) = do g <- goal (Just (head (holes ps))) (pterm ps)
118+ return (binderTy (goalType g))
119+
114120goal :: Hole -> Term -> TC Goal
115121goal h tm = g [] tm where
116122 g env (Bind n b sc) | hole b && same h n = return $ GD env b
@@ -160,6 +166,10 @@ focus :: Name -> RunTactic
160166focus n ctxt env t = do action (FocusGoal n)
161167 return t
162168
169+movelast :: Name -> RunTactic
170+movelast n ctxt env t = do action (MoveGoal n)
171+ return t
172+
163173-- Hmmm. YAGNI?
164174regret :: RunTactic
165175regret = undefined
@@ -257,6 +267,7 @@ processTactic t ps
257267 goals g (AddGoal n : xs) = goals (n : g) xs
258268 goals (g:gs) (NextGoal n : xs) = goals (g : n : gs) xs
259269 goals g (FocusGoal n : xs) = goals (n : (g \\ [n])) xs
270+ goals g (MoveGoal n : xs) = goals ((g \\ [n]) ++ [n]) xs
260271 goals g (Solved n : xs) = goals (g \\ [n]) xs
261272 goals g (AlsoSolved n tm : xs) = goals (g \\ [n]) xs
262273 goals g (_ : xs) = goals g xs
@@ -265,8 +276,9 @@ processTactic t ps
265276 getSolved (AlsoSolved n tm : xs) = (n, tm) : getSolved xs
266277 getSolved (_ : xs) = getSolved xs
267278
268− updateSolved xs (Bind n b t)
279+ updateSolved xs (Bind n b@(Hole _) t)
269280 | Just v <- lookup n xs = Bind n (Let (binderTy b) v) (updateSolved xs t)
281+ updateSolved xs (Bind n b t)
270282 | otherwise = Bind n (fmap (updateSolved xs) b) (updateSolved xs t)
271283 updateSolved xs (App f a) = App (updateSolved xs f) (updateSolved xs a)
272284 updateSolved xs t = t
@@ -285,3 +297,4 @@ process t h ps = tactic (Just h) ps (context ps) (mktac t)
285297 mktac (CheckIn r) = check_in r
286298 mktac (EvalIn r) = eval_in r
287299 mktac (Focus n) = focus n
300+ mktac (MoveLast n) = movelast n