Skip to content
Snippets Groups Projects

Refactor and improve documentation of feed and efeed tactics

Merged Michael Sammler requested to merge msammler/feed_docs into master
+ 28
3
@@ -497,8 +497,13 @@ Tactic Notation "iter" tactic(tac) tactic(l) :=
@@ -497,8 +497,13 @@ Tactic Notation "iter" tactic(tac) tactic(l) :=
match l with ?x :: ?l => tac x || go l end in go l.
match l with ?x :: ?l => tac x || go l end in go l.
(** Given [H : A_1 → ... → A_n → B] (where each [A_i] is non-dependent), the
(** Given [H : A_1 → ... → A_n → B] (where each [A_i] is non-dependent), the
tactic [feed tac H tac_by] creates a subgoal for each [A_i] and calls [tac p]
tactic [feed tac H] creates a subgoal for each [A_i] and calls [tac p]
with the generated proof [p] of [B]. *)
with the generated proof [p] of [B].
 
 
For example, given [H : P → Q → R], [feed (fun p => pose proof p) H] creates the
 
subgoals [P] and [Q] and then executes [pose proof Hfeed] where [Hfeed : R],
 
which adds [R] to the context of the original goal.
 
*)
Tactic Notation "feed" tactic(tac) constr(H) :=
Tactic Notation "feed" tactic(tac) constr(H) :=
let rec go H :=
let rec go H :=
let T := type of H in
let T := type of H in
@@ -515,7 +520,12 @@ Tactic Notation "feed" tactic(tac) constr(H) :=
@@ -515,7 +520,12 @@ Tactic Notation "feed" tactic(tac) constr(H) :=
end in go H.
end in go H.
(** The tactic [efeed tac H] is similar to [feed], but it also instantiates
(** The tactic [efeed tac H] is similar to [feed], but it also instantiates
dependent premises of [H] with evars. *)
dependent premises of [H] with evars.
 
 
For example, given [H : ∀ x y, P x → Q y → R x y], [efeed H using (fun p => pose proof p)]
 
creates evars [?x] and [?y] for [x] and [y] and subgoals [P ?x] and [Q ?y] and
 
then executes [pose proof Hfeed] where [Hfeed : R ?x ?y], which adds [R ?x ?y]
 
to the context of the original goal. *)
Tactic Notation "efeed" constr(H) "using" tactic3(tac) "by" tactic3 (bytac) :=
Tactic Notation "efeed" constr(H) "using" tactic3(tac) "by" tactic3 (bytac) :=
let rec go H :=
let rec go H :=
let T := type of H in
let T := type of H in
@@ -548,15 +558,30 @@ Tactic Notation "feed" "specialize" hyp(H) :=
@@ -548,15 +558,30 @@ Tactic Notation "feed" "specialize" hyp(H) :=
Tactic Notation "efeed" "specialize" hyp(H) :=
Tactic Notation "efeed" "specialize" hyp(H) :=
efeed H using (fun p => specialize p).
efeed H using (fun p => specialize p).
 
Tactic Notation "feed" "revert" constr(H) :=
 
feed (fun p => let H':=fresh in pose proof p as H'; revert H') H.
 
Tactic Notation "efeed" "revert" constr(H) :=
 
efeed H using (fun p => let H':=fresh in pose proof p as H'; revert H').
 
Tactic Notation "feed" "inversion" constr(H) :=
Tactic Notation "feed" "inversion" constr(H) :=
feed (fun p => let H':=fresh in pose proof p as H'; inversion H') H.
feed (fun p => let H':=fresh in pose proof p as H'; inversion H') H.
 
Tactic Notation "efeed" "inversion" constr(H) :=
 
efeed H using (fun p => let H':=fresh in pose proof p as H'; inversion H').
 
Tactic Notation "feed" "inversion" constr(H) "as" simple_intropattern(IP) :=
Tactic Notation "feed" "inversion" constr(H) "as" simple_intropattern(IP) :=
feed (fun p => let H':=fresh in pose proof p as H'; inversion H' as IP) H.
feed (fun p => let H':=fresh in pose proof p as H'; inversion H' as IP) H.
 
Tactic Notation "efeed" "inversion" constr(H) "as" simple_intropattern(IP) :=
 
efeed H using (fun p => let H':=fresh in pose proof p as H'; inversion H' as IP).
Tactic Notation "feed" "destruct" constr(H) :=
Tactic Notation "feed" "destruct" constr(H) :=
feed (fun p => let H':=fresh in pose proof p as H'; destruct H') H.
feed (fun p => let H':=fresh in pose proof p as H'; destruct H') H.
 
Tactic Notation "efeed" "destruct" constr(H) :=
 
efeed H using (fun p => let H':=fresh in pose proof p as H'; destruct H').
 
Tactic Notation "feed" "destruct" constr(H) "as" simple_intropattern(IP) :=
Tactic Notation "feed" "destruct" constr(H) "as" simple_intropattern(IP) :=
feed (fun p => let H':=fresh in pose proof p as H'; destruct H' as IP) H.
feed (fun p => let H':=fresh in pose proof p as H'; destruct H' as IP) H.
 
Tactic Notation "efeed" "destruct" constr(H) "as" simple_intropattern(IP) :=
 
efeed H using (fun p => let H':=fresh in pose proof p as H'; destruct H' as IP).
(** The block definitions are taken from [Coq.Program.Equality] and can be used
(** The block definitions are taken from [Coq.Program.Equality] and can be used
by tactics to separate their goal from hypotheses they generalize over. *)
by tactics to separate their goal from hypotheses they generalize over. *)
Loading