@@ -48,6 +48,7 @@ data Tactic = Attack
48 | Intro Name
48 | Intro Name
49 | Forall Name Raw
49 | Forall Name Raw
50 | PatVar Name
50 | PatVar Name
51 | Focus Name
52 | Focus Name
52 | MoveLast Name
53 | MoveLast Name
53 | ProofState
54 | ProofState
@@ -223,7 +224,7 @@ intro n ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
223 Bind y (Pi s) t -> let t' = instantiate (P Bound n s) (pToV y t) in
224 Bind y (Pi s) t -> let t' = instantiate (P Bound n s) (pToV y t) in
224 return $ Bind n (Lam s) (Bind x (Hole t') (P Bound x t'))
225 return $ Bind n (Lam s) (Bind x (Hole t') (P Bound x t'))
225 _ -> fail "Nothing to introduce"
226 _ -> fail "Nothing to introduce"
226−intro ctxt env _ _ = fail "Can't introduce here."
227+intro n ctxt env _ = fail "Can't introduce here."
228forall :: Name -> Raw -> RunTactic
229forall :: Name -> Raw -> RunTactic
229forall n ty ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
230forall n ty ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
@@ -231,12 +232,20 @@ forall n ty ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
231 lift $ isSet ctxt env tyt
232 lift $ isSet ctxt env tyt
232 lift $ isSet ctxt env t
233 lift $ isSet ctxt env t
233 return $ Bind n (Pi tyv) (Bind x (Hole t) (P Bound x t))
234 return $ Bind n (Pi tyv) (Bind x (Hole t) (P Bound x t))
235+forall n ty ctxt env _ = fail "Can't pi bind here"
235patvar :: Name -> RunTactic
237patvar :: Name -> RunTactic
236patvar n ctxt env (Bind x (Hole t) sc) =
238patvar n ctxt env (Bind x (Hole t) sc) =
237 do action (\ps -> ps { holes = holes ps \\ [x] })
239 do action (\ps -> ps { holes = holes ps \\ [x] })
238 return $ Bind n (PVar t) (instantiate (P Bound n t) (pToV x sc))
240 return $ Bind n (PVar t) (instantiate (P Bound n t) (pToV x sc))
242+patbind :: Name -> Raw -> RunTactic
243+patbind n ty ctxt env (Bind x (Hole t) (P _ x' _)) | x == x' =
244+ do (tyv, tyt) <- lift $ check ctxt env ty
245+ lift $ isSet ctxt env tyt
246+ return $ Bind n (PVar tyv) (Bind x (Hole t) (P Bound x t))
247+patbind n ty ctxt env _ = fail "Can't pattern bind here"
240compute :: RunTactic
249compute :: RunTactic
241compute ctxt env (Bind x (Hole ty) sc) =
250compute ctxt env (Bind x (Hole ty) sc) =
242 do return $ Bind x (Hole (normalise ctxt env ty)) sc
251 do return $ Bind x (Hole (normalise ctxt env ty)) sc
@@ -336,6 +345,7 @@ process t h = tactic (Just h) (mktac t)
336 mktac (Intro n) = intro n
345 mktac (Intro n) = intro n
337 mktac (Forall n t) = forall n t
346 mktac (Forall n t) = forall n t
338 mktac (PatVar n) = patvar n
347 mktac (PatVar n) = patvar n
348+ mktac (PatBind n t) = patbind n t
339 mktac (CheckIn r) = check_in r
349 mktac (CheckIn r) = check_in r
340 mktac (EvalIn r) = eval_in r
350 mktac (EvalIn r) = eval_in r
341 mktac (Focus n) = focus n
351 mktac (Focus n) = focus n