| [ IDENT "whd" ] -> `Whd
| [ IDENT "normalize" ] -> `Normalize ]
];
+ pattern_spec: [
+ [ hyp_paths =
+ OPT [
+ paths = LIST1 [ id = IDENT ; SYMBOL ":" ; path = term -> (id,path) ]
+ SEP SYMBOL ";";
+ SYMBOL <:unicode<vdash>> ->
+ paths ];
+ goal_path = OPT term ->
+ let hyp_paths = match hyp_paths with None -> [] | Some l -> l in
+ (hyp_paths, goal_path) ]
+ ];
+ direction: [
+ [ IDENT "left" -> `Left
+ | SYMBOL ">" -> `Left
+ | IDENT "right" -> `Right
+ | SYMBOL "<" -> `Right ]
+ ];
tactic: [
[ [ IDENT "absurd" ]; t = tactic_term ->
TacticAst.Absurd (loc, t)
where = IDENT ; SYMBOL <:unicode<def>> ; t = tactic_term ->
TacticAst.LetIn (loc, t, where)
| kind = reduction_kind;
- pat = OPT [
- "in"; pat = [ IDENT "goal" -> `Goal | IDENT "hyp" -> `Everywhere ] ->
- pat
- ];
- terms = LIST0 term SEP SYMBOL "," ->
- (match (pat, terms) with
- | None, [] -> TacticAst.Reduce (loc, kind, None)
- | None, terms -> TacticAst.Reduce (loc, kind, Some (terms, `Goal))
- | Some pat, [] -> fail loc "Missing term [list]"
- | Some pat, terms -> TacticAst.Reduce (loc, kind, Some (terms, pat)))
- | kind = reduction_kind; where = IDENT ; IDENT "at" ; pat = term ->
- TacticAst.ReduceAt (loc, kind, where, pat)
+ p = OPT [ "in" ; p = pattern_spec -> p ] ->
+ let p = match p with None -> [], None | Some p -> p in
+ TacticAst.Reduce (loc, kind, p)
| [ IDENT "reflexivity" ] ->
TacticAst.Reflexivity loc
| [ IDENT "replace" ];
t1 = tactic_term; "with"; t2 = tactic_term ->
TacticAst.Replace (loc, t1, t2)
- | [ IDENT "rewrite" ; IDENT "left" ] ; t = term ->
- TacticAst.Rewrite (loc,`Left, t, None)
- | [ IDENT "rewrite" ; IDENT "right" ] ; t = term ->
- TacticAst.Rewrite (loc,`Right, t, None)
- (* TODO Replace_pattern *)
+ | IDENT "rewrite" ; d = direction; t = term ;
+ p = OPT [ "in"; p = pattern_spec -> p ] ->
+ let p = match p with None -> [], None | Some p -> p in
+ TacticAst.Rewrite (loc, d, t, p)
| [ IDENT "right" ] -> TacticAst.Right loc
| [ IDENT "ring" ] -> TacticAst.Ring loc
| [ IDENT "split" ] -> TacticAst.Split loc