From 7e60a6ab524a987ee685b4ef76fff1d9bb15c138 Mon Sep 17 00:00:00 2001 From: coq Date: Wed, 20 Apr 2005 16:18:41 +0000 Subject: Implementation of a new backtracking system, that allow to go back anywhere in a script (provided no suspend/resume is used): * the command "Backtrack n m p" (vernac_bactrack) performs the following operation: ** do abort p times, ** do undo on the current proof (after the aborts) in order to reach a stack depth of m (see vernac_undo_todepth) ** resets the global state to state labelled with n. * The coq prompt in emacs mode has more informations, it contains: ** the usual coq prompt plus: ** the state number (global state label) ** the depth of the current proof stack ** the names of all pending proofs, in *unspecified* order, separated by '|' Example: state proof stack num depth __ _ aux < 12 |aux|SmallStepAntiReflexive| 4 < รน ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ usual pending proofs usual special char git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@6947 85f007b7-540e-0410-9357-904b9bb8a0f7 --- lib/edit.ml | 22 ++++++++++++++++++++++ lib/edit.mli | 7 +++++++ 2 files changed, 29 insertions(+) (limited to 'lib') diff --git a/lib/edit.ml b/lib/edit.ml index 096fa5dc13..06a55d171d 100644 --- a/lib/edit.ml +++ b/lib/edit.ml @@ -84,6 +84,28 @@ let undo e n = errorlabstrm "Edit.undo" (str"Undo stack exhausted"); repeat n Bstack.pop bs +(* Return the depth of the focused proof of [e] stack, this is used to + put informations in coq prompt (in emacs mode). *) +let depth e = + match e.focus with + | None -> invalid_arg "Edit.depth" + | Some d -> + let (bs,_) = Hashtbl.find e.buf d in + Bstack.depth bs + +(* Undo focused proof of [e] to reach depth [n] *) +let undo_todepth e n = + match e.focus with + | None -> + if n <> 0 + then errorlabstrm "Edit.undo_todepth" (str"No proof in progress") + else () (* if there is no proof in progress, then n must be zero *) + | Some d -> + let (bs,_) = Hashtbl.find e.buf d in + if Bstack.depth bs < n then + errorlabstrm "Edit.undo_todepth" (str"Undo stack would be exhausted"); + repeat (Bstack.depth bs - n) Bstack.pop bs + let create e (d,b,c,udepth) = if Hashtbl.mem e.buf d then errorlabstrm "Edit.create" diff --git a/lib/edit.mli b/lib/edit.mli index 0bd802fcc3..d13d9c6f69 100644 --- a/lib/edit.mli +++ b/lib/edit.mli @@ -54,3 +54,10 @@ val delete : ('a,'b,'c) t -> 'a -> unit val dom : ('a,'b,'c) t -> 'a list val clear : ('a,'b,'c) t -> unit + +(* [depth e] Returns the depth of the focused proof stack of [e], this + is used to put informations in coq prompt (in emacs mode). *) +val depth : ('a,'b,'c) t -> int + +(* [undo_todepth e n] Undoes focused proof of [e] to reach depth [n] *) +val undo_todepth : ('a,'b,'c) t -> int -> unit -- cgit v1.2.3