@@ -1,6 +1,11 @@
1{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
1{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances #-}
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. --}
3−module ProofState where
7+module ProofState(ProofState(..), newProof,
8+ Tactic(..), processTactic) where
5import Typecheck
10import Typecheck
6import Evaluate
11import Evaluate
@@ -25,12 +30,6 @@ data Goal = GD { premises :: Env,
25 goalType :: Binder Term
30 goalType :: Binder Term
28−data Command = Theorem Name Raw
34data Tactic = Attack
33data Tactic = Attack
35 | Claim Name Raw
34 | Claim Name Raw
36 | Fill Raw
35 | Fill Raw
@@ -41,6 +40,7 @@ data Tactic = Attack
41 | EvalIn Raw
40 | EvalIn Raw
42 | CheckIn Raw
41 | CheckIn Raw
43 | Intro Name
42 | Intro Name
44 | Focus Name
44 | Focus Name
45 | ProofState
45 | ProofState
@@ -154,6 +154,7 @@ focus :: Name -> RunTactic
154focus n ctxt env t = do action (FocusGoal n)
154focus n ctxt env t = do action (FocusGoal n)
155 return t
155 return t
157regret :: RunTactic
158regret :: RunTactic
158regret = undefined
159regret = undefined
@@ -194,6 +195,14 @@ intro n ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
194 _ -> fail "Nothing to introduce"
195 _ -> fail "Nothing to introduce"
195intro ctxt env _ _ = fail "Can't introduce here."
196intro ctxt env _ _ = fail "Can't introduce here."
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))
197compute :: RunTactic
206compute :: RunTactic
198compute ctxt env (Bind x (Hole ty) sc) =
207compute ctxt env (Bind x (Hole ty) sc) =
199 do return $ Bind x (Hole (normalise ctxt env ty)) sc
208 do return $ Bind x (Hole (normalise ctxt env ty)) sc
@@ -256,8 +265,6 @@ processTactic t ps
256 updateSolved xs (App f a) = App (updateSolved xs f) (updateSolved xs a)
265 updateSolved xs (App f a) = App (updateSolved xs f) (updateSolved xs a)
257 updateSolved xs t = t
266 updateSolved xs t = t
261process :: Tactic -> Name -> ProofState -> StateT TState TC ProofState
268process :: Tactic -> Name -> ProofState -> StateT TState TC ProofState
262process t h ps = tactic (Just h) ps (context ps) (mktac t)
269process t h ps = tactic (Just h) ps (context ps) (mktac t)
263 where mktac Attack = attack
270 where mktac Attack = attack
@@ -268,6 +275,7 @@ process t h ps = tactic (Just h) ps (context ps) (mktac t)
268 mktac Solve = solve
275 mktac Solve = solve
269 mktac Compute = compute
276 mktac Compute = compute
270 mktac (Intro n) = intro n
277 mktac (Intro n) = intro n
278+ mktac (Forall n t) = forall n t
271 mktac (CheckIn r) = check_in r
279 mktac (CheckIn r) = check_in r
272 mktac (EvalIn r) = eval_in r
280 mktac (EvalIn r) = eval_in r
273 mktac (Focus n) = focus n
281 mktac (Focus n) = focus n