@@ -1,6 +1,11 @@
11{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
22
3−module ProofState where
3+{- Implements a proof state, some primitive tactics for manipulating
4+ proofs, and some high level commands for introducing new theorems,
5+ evaluation/checking inside the proof system, etc. --}
6+
7+module ProofState(ProofState(..), newProof,
8+ Tactic(..), processTactic) where
49
510import Typecheck
611import Evaluate
@@ -25,12 +30,6 @@ data Goal = GD { premises :: Env,
2530 goalType :: Binder Term
2631 }
2732
28−data Command = Theorem Name Raw
29− | Eval Raw
30− | Quit
31− | Print Name
32− | Tac Tactic
33−
3433data Tactic = Attack
3534 | Claim Name Raw
3635 | Fill Raw
@@ -41,6 +40,7 @@ data Tactic = Attack
4140 | EvalIn Raw
4241 | CheckIn Raw
4342 | Intro Name
43+ | Forall Name Raw
4444 | Focus Name
4545 | ProofState
4646 | QED
@@ -154,6 +154,7 @@ focus :: Name -> RunTactic
154154focus n ctxt env t = do action (FocusGoal n)
155155 return t
156156
157+-- Hmmm. YAGNI?
157158regret :: RunTactic
158159regret = undefined
159160
@@ -194,6 +195,14 @@ intro n ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
194195 _ -> fail "Nothing to introduce"
195196intro ctxt env _ _ = fail "Can't introduce here."
196197
198+forall :: Name -> Raw -> RunTactic
199+forall n ty ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
200+ do (tyv, tyt) <- lift $ check ctxt env ty
201+ lift $ isSet ctxt env tyt
202+ lift $ isSet ctxt env t
203+ return $ Bind n (Pi tyv) (Bind x (Hole t) (P Bound x t))
204+
205+
197206compute :: RunTactic
198207compute ctxt env (Bind x (Hole ty) sc) =
199208 do return $ Bind x (Hole (normalise ctxt env ty)) sc
@@ -256,8 +265,6 @@ processTactic t ps
256265 updateSolved xs (App f a) = App (updateSolved xs f) (updateSolved xs a)
257266 updateSolved xs t = t
258267
259−
260−
261268process :: Tactic -> Name -> ProofState -> StateT TState TC ProofState
262269process t h ps = tactic (Just h) ps (context ps) (mktac t)
263270 where mktac Attack = attack
@@ -268,6 +275,7 @@ process t h ps = tactic (Just h) ps (context ps) (mktac t)
268275 mktac Solve = solve
269276 mktac Compute = compute
270277 mktac (Intro n) = intro n
278+ mktac (Forall n t) = forall n t
271279 mktac (CheckIn r) = check_in r
272280 mktac (EvalIn r) = eval_in r
273281 mktac (Focus n) = focus n