aboutsummaryrefslogtreecommitdiff
path: root/proofs
diff options
context:
space:
mode:
authoraspiwack2013-11-02 15:38:41 +0000
committeraspiwack2013-11-02 15:38:41 +0000
commitaf63420fe7202f01b483812bc1f5ff50c5a640e2 (patch)
treeeb124c5a451cb55a3080093994b14a8960251a68 /proofs
parenta9cfc4691726ac248dc7bbc43bb5ae8a7db3233f (diff)
Adds a tactical once.
[once t] does just as [t] but has exactly one success it [t] has at least one success. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@17004 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'proofs')
-rw-r--r--proofs/proofview.ml9
-rw-r--r--proofs/proofview.mli4
2 files changed, 13 insertions, 0 deletions
diff --git a/proofs/proofview.ml b/proofs/proofview.ml
index 8a3511651f..167fedf7b7 100644
--- a/proofs/proofview.ml
+++ b/proofs/proofview.ml
@@ -244,6 +244,15 @@ let tclIFCATCH a s f =
| Util.Inr e -> f e
| Util.Inl (x,a') -> Proof.plus (s x) (fun e -> (a' e) >>= fun x' -> (s x'))
+(* [tclONCE t] fails if [t] fails, otherwise it has exactly one
+ success. *)
+let tclONCE t =
+ (* spiwack: convenience notations, waiting for ocaml 3.12 *)
+ let (>>=) = Proof.bind in
+ Proof.split t >>= function
+ | Util.Inr e -> tclZERO e
+ | Util.Inl (x,_) -> tclUNIT x
+
(* Focuses a tactic at a range of subgoals, found by their indices. *)
(* arnaud: bug if 0 goals ! *)
let tclFOCUS i j t =
diff --git a/proofs/proofview.mli b/proofs/proofview.mli
index 207df891e4..c9296e694f 100644
--- a/proofs/proofview.mli
+++ b/proofs/proofview.mli
@@ -156,6 +156,10 @@ val tclORELSE : 'a tactic -> (exn -> 'a tactic) -> 'a tactic
fails with [e], then it behaves as [f e]. *)
val tclIFCATCH : 'a tactic -> ('a -> 'b tactic) -> (exn -> 'b tactic) -> 'b tactic
+(* [tclONCE t] fails if [t] fails, otherwise it has exactly one
+ success. *)
+val tclONCE : 'a tactic -> 'a tactic
+
(* Focuses a tactic at a range of subgoals, found by their indices. *)
val tclFOCUS : int -> int -> 'a tactic -> 'a tactic