diff options
author | Jason Gross <jgross@mit.edu> | 2017-01-26 18:19:54 -0500 |
---|---|---|
committer | Jason Gross <jgross@mit.edu> | 2017-01-26 18:20:08 -0500 |
commit | 39c70ae2abd720ec76e01c85d2aa0e56aeae3414 (patch) | |
tree | b8ca8c8c4e935a078813d1f753f29db7e95f91d4 /src/Util | |
parent | 0cf72bdda642db646e25cba8af97f3c63d88764d (diff) |
Split off some bits of Reflection.Syntax
Also split off some bits of Util.Tactics
Diffstat (limited to 'src/Util')
-rw-r--r-- | src/Util/Tactics.v | 49 | ||||
-rw-r--r-- | src/Util/Tactics/DoWithHyp.v | 7 | ||||
-rw-r--r-- | src/Util/Tactics/RewriteHyp.v | 44 |
3 files changed, 53 insertions, 47 deletions
diff --git a/src/Util/Tactics.v b/src/Util/Tactics.v index e6f5a1cac..dffd6e581 100644 --- a/src/Util/Tactics.v +++ b/src/Util/Tactics.v @@ -4,6 +4,8 @@ Require Export Crypto.Util.Tactics.BreakMatch. Require Export Crypto.Util.Tactics.Head. Require Export Crypto.Util.Tactics.DestructHyps. Require Export Crypto.Util.Tactics.DestructHead. +Require Export Crypto.Util.Tactics.DoWithHyp. +Require Export Crypto.Util.Tactics.RewriteHyp. Require Export Crypto.Util.Tactics.SpecializeBy. Require Export Crypto.Util.Tactics.SplitInContext. @@ -178,53 +180,6 @@ Ltac side_conditions_before_to_side_conditions_after tac_in H := move H after H'; clear H' | .. ]. -(** Do something with every hypothesis. *) -Ltac do_with_hyp' tac := - match goal with - | [ H : _ |- _ ] => tac H - end. - -(** Rewrite with any applicable hypothesis. *) -Tactic Notation "rewrite_hyp" "*" := do_with_hyp' ltac:(fun H => rewrite H). -Tactic Notation "rewrite_hyp" "->" "*" := do_with_hyp' ltac:(fun H => rewrite -> H). -Tactic Notation "rewrite_hyp" "<-" "*" := do_with_hyp' ltac:(fun H => rewrite <- H). -Tactic Notation "rewrite_hyp" "?*" := repeat do_with_hyp' ltac:(fun H => rewrite !H). -Tactic Notation "rewrite_hyp" "->" "?*" := repeat do_with_hyp' ltac:(fun H => rewrite -> !H). -Tactic Notation "rewrite_hyp" "<-" "?*" := repeat do_with_hyp' ltac:(fun H => rewrite <- !H). -Tactic Notation "rewrite_hyp" "!*" := progress rewrite_hyp ?*. -Tactic Notation "rewrite_hyp" "->" "!*" := progress rewrite_hyp -> ?*. -Tactic Notation "rewrite_hyp" "<-" "!*" := progress rewrite_hyp <- ?*. - -Tactic Notation "rewrite_hyp" "*" "in" "*" := do_with_hyp' ltac:(fun H => rewrite H in * ). -Tactic Notation "rewrite_hyp" "->" "*" "in" "*" := do_with_hyp' ltac:(fun H => rewrite -> H in * ). -Tactic Notation "rewrite_hyp" "<-" "*" "in" "*" := do_with_hyp' ltac:(fun H => rewrite <- H in * ). -Tactic Notation "rewrite_hyp" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => rewrite !H in * ). -Tactic Notation "rewrite_hyp" "->" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => rewrite -> !H in * ). -Tactic Notation "rewrite_hyp" "<-" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => rewrite <- !H in * ). -Tactic Notation "rewrite_hyp" "!*" "in" "*" := progress rewrite_hyp ?* in *. -Tactic Notation "rewrite_hyp" "->" "!*" "in" "*" := progress rewrite_hyp -> ?* in *. -Tactic Notation "rewrite_hyp" "<-" "!*" "in" "*" := progress rewrite_hyp <- ?* in *. - -Tactic Notation "erewrite_hyp" "*" := do_with_hyp' ltac:(fun H => erewrite H). -Tactic Notation "erewrite_hyp" "->" "*" := do_with_hyp' ltac:(fun H => erewrite -> H). -Tactic Notation "erewrite_hyp" "<-" "*" := do_with_hyp' ltac:(fun H => erewrite <- H). -Tactic Notation "erewrite_hyp" "?*" := repeat do_with_hyp' ltac:(fun H => erewrite !H). -Tactic Notation "erewrite_hyp" "->" "?*" := repeat do_with_hyp' ltac:(fun H => erewrite -> !H). -Tactic Notation "erewrite_hyp" "<-" "?*" := repeat do_with_hyp' ltac:(fun H => erewrite <- !H). -Tactic Notation "erewrite_hyp" "!*" := progress erewrite_hyp ?*. -Tactic Notation "erewrite_hyp" "->" "!*" := progress erewrite_hyp -> ?*. -Tactic Notation "erewrite_hyp" "<-" "!*" := progress erewrite_hyp <- ?*. - -Tactic Notation "erewrite_hyp" "*" "in" "*" := do_with_hyp' ltac:(fun H => erewrite H in * ). -Tactic Notation "erewrite_hyp" "->" "*" "in" "*" := do_with_hyp' ltac:(fun H => erewrite -> H in * ). -Tactic Notation "erewrite_hyp" "<-" "*" "in" "*" := do_with_hyp' ltac:(fun H => erewrite <- H in * ). -Tactic Notation "erewrite_hyp" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => erewrite !H in * ). -Tactic Notation "erewrite_hyp" "->" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => erewrite -> !H in * ). -Tactic Notation "erewrite_hyp" "<-" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => erewrite <- !H in * ). -Tactic Notation "erewrite_hyp" "!*" "in" "*" := progress erewrite_hyp ?* in *. -Tactic Notation "erewrite_hyp" "->" "!*" "in" "*" := progress erewrite_hyp -> ?* in *. -Tactic Notation "erewrite_hyp" "<-" "!*" "in" "*" := progress erewrite_hyp <- ?* in *. - (** Execute [progress tac] on all subterms of the goal. Useful for things like [ring_simplify]. *) Ltac tac_on_subterms tac := repeat match goal with diff --git a/src/Util/Tactics/DoWithHyp.v b/src/Util/Tactics/DoWithHyp.v new file mode 100644 index 000000000..b31072a63 --- /dev/null +++ b/src/Util/Tactics/DoWithHyp.v @@ -0,0 +1,7 @@ +Require Export Crypto.Util.FixCoqMistakes. + +(** Do something with every hypothesis. *) +Ltac do_with_hyp' tac := + match goal with + | [ H : _ |- _ ] => tac H + end. diff --git a/src/Util/Tactics/RewriteHyp.v b/src/Util/Tactics/RewriteHyp.v new file mode 100644 index 000000000..240931e05 --- /dev/null +++ b/src/Util/Tactics/RewriteHyp.v @@ -0,0 +1,44 @@ +Require Export Crypto.Util.FixCoqMistakes. +Require Import Crypto.Util.Tactics.DoWithHyp. + + +(** Rewrite with any applicable hypothesis. *) +Tactic Notation "rewrite_hyp" "*" := do_with_hyp' ltac:(fun H => rewrite H). +Tactic Notation "rewrite_hyp" "->" "*" := do_with_hyp' ltac:(fun H => rewrite -> H). +Tactic Notation "rewrite_hyp" "<-" "*" := do_with_hyp' ltac:(fun H => rewrite <- H). +Tactic Notation "rewrite_hyp" "?*" := repeat do_with_hyp' ltac:(fun H => rewrite !H). +Tactic Notation "rewrite_hyp" "->" "?*" := repeat do_with_hyp' ltac:(fun H => rewrite -> !H). +Tactic Notation "rewrite_hyp" "<-" "?*" := repeat do_with_hyp' ltac:(fun H => rewrite <- !H). +Tactic Notation "rewrite_hyp" "!*" := progress rewrite_hyp ?*. +Tactic Notation "rewrite_hyp" "->" "!*" := progress rewrite_hyp -> ?*. +Tactic Notation "rewrite_hyp" "<-" "!*" := progress rewrite_hyp <- ?*. + +Tactic Notation "rewrite_hyp" "*" "in" "*" := do_with_hyp' ltac:(fun H => rewrite H in * ). +Tactic Notation "rewrite_hyp" "->" "*" "in" "*" := do_with_hyp' ltac:(fun H => rewrite -> H in * ). +Tactic Notation "rewrite_hyp" "<-" "*" "in" "*" := do_with_hyp' ltac:(fun H => rewrite <- H in * ). +Tactic Notation "rewrite_hyp" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => rewrite !H in * ). +Tactic Notation "rewrite_hyp" "->" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => rewrite -> !H in * ). +Tactic Notation "rewrite_hyp" "<-" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => rewrite <- !H in * ). +Tactic Notation "rewrite_hyp" "!*" "in" "*" := progress rewrite_hyp ?* in *. +Tactic Notation "rewrite_hyp" "->" "!*" "in" "*" := progress rewrite_hyp -> ?* in *. +Tactic Notation "rewrite_hyp" "<-" "!*" "in" "*" := progress rewrite_hyp <- ?* in *. + +Tactic Notation "erewrite_hyp" "*" := do_with_hyp' ltac:(fun H => erewrite H). +Tactic Notation "erewrite_hyp" "->" "*" := do_with_hyp' ltac:(fun H => erewrite -> H). +Tactic Notation "erewrite_hyp" "<-" "*" := do_with_hyp' ltac:(fun H => erewrite <- H). +Tactic Notation "erewrite_hyp" "?*" := repeat do_with_hyp' ltac:(fun H => erewrite !H). +Tactic Notation "erewrite_hyp" "->" "?*" := repeat do_with_hyp' ltac:(fun H => erewrite -> !H). +Tactic Notation "erewrite_hyp" "<-" "?*" := repeat do_with_hyp' ltac:(fun H => erewrite <- !H). +Tactic Notation "erewrite_hyp" "!*" := progress erewrite_hyp ?*. +Tactic Notation "erewrite_hyp" "->" "!*" := progress erewrite_hyp -> ?*. +Tactic Notation "erewrite_hyp" "<-" "!*" := progress erewrite_hyp <- ?*. + +Tactic Notation "erewrite_hyp" "*" "in" "*" := do_with_hyp' ltac:(fun H => erewrite H in * ). +Tactic Notation "erewrite_hyp" "->" "*" "in" "*" := do_with_hyp' ltac:(fun H => erewrite -> H in * ). +Tactic Notation "erewrite_hyp" "<-" "*" "in" "*" := do_with_hyp' ltac:(fun H => erewrite <- H in * ). +Tactic Notation "erewrite_hyp" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => erewrite !H in * ). +Tactic Notation "erewrite_hyp" "->" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => erewrite -> !H in * ). +Tactic Notation "erewrite_hyp" "<-" "?*" "in" "*" := repeat do_with_hyp' ltac:(fun H => erewrite <- !H in * ). +Tactic Notation "erewrite_hyp" "!*" "in" "*" := progress erewrite_hyp ?* in *. +Tactic Notation "erewrite_hyp" "->" "!*" "in" "*" := progress erewrite_hyp -> ?* in *. +Tactic Notation "erewrite_hyp" "<-" "!*" "in" "*" := progress erewrite_hyp <- ?* in *. |