aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre-Marie Pédrot2016-06-16 16:17:47 +0200
committerPierre-Marie Pédrot2016-06-16 16:17:47 +0200
commita33999800dc7e0a12935034350c31b47b6e5d494 (patch)
treedcb545400147aa7dbd2a00db42f40da637473de1
parent6aac2c78ad5dec79c6ed16a50accde57c37398a9 (diff)
parenteab9b0125238decef60a1710649671dc26959667 (diff)
Merge PR #195: Complete is_* family of term-examining tactics.
-rw-r--r--CHANGES1
-rw-r--r--ltac/extratactics.ml428
2 files changed, 29 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 15110e701d..fa0e70ba0a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -21,6 +21,7 @@ Tactics
- When in strict mode (i.e. in a Ltac definition) the "intro" tactic cannot use
a locally free identifier anymore. It must use e.g. the "fresh" primitive
instead (potential source of incompatibilities).
+- New tactics is_ind, is_const, is_proj, is_constructor for use in Ltac (DOC TODO).
Program
diff --git a/ltac/extratactics.ml4 b/ltac/extratactics.ml4
index 57fad85113..845ac67139 100644
--- a/ltac/extratactics.ml4
+++ b/ltac/extratactics.ml4
@@ -866,6 +866,34 @@ TACTIC EXTEND is_cofix
| _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a cofix definition") ]
END;;
+TACTIC EXTEND is_ind
+| [ "is_ind" constr(x) ] ->
+ [ match kind_of_term x with
+ | Ind _ -> Proofview.tclUNIT ()
+ | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not an (co)inductive datatype") ]
+END;;
+
+TACTIC EXTEND is_constructor
+| [ "is_constructor" constr(x) ] ->
+ [ match kind_of_term x with
+ | Construct _ -> Proofview.tclUNIT ()
+ | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a constructor") ]
+END;;
+
+TACTIC EXTEND is_proj
+| [ "is_proj" constr(x) ] ->
+ [ match kind_of_term x with
+ | Proj _ -> Proofview.tclUNIT ()
+ | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a primitive projection") ]
+END;;
+
+TACTIC EXTEND is_const
+| [ "is_const" constr(x) ] ->
+ [ match kind_of_term x with
+ | Const _ -> Proofview.tclUNIT ()
+ | _ -> Tacticals.New.tclFAIL 0 (Pp.str "not a constant") ]
+END;;
+
(* Command to grab the evars left unresolved at the end of a proof. *)
(* spiwack: I put it in extratactics because it is somewhat tied with
the semantics of the LCF-style tactics, hence with the classic tactic