]> matita.cs.unibo.it Git - helm.git/blob - helm/ocaml/tactics/continuationals.mli
ocaml 3.09 transition
[helm.git] / helm / ocaml / tactics / continuationals.mli
1 (* Copyright (C) 2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 exception Error of string Lazy.t
27
28 type goal = ProofEngineTypes.goal
29
30 (** {2 Goal stack} *)
31
32 module Stack:
33 sig
34   type switch = Open of goal | Closed of goal
35   type locator = int * switch
36   type tag = [ `BranchTag | `FocusTag | `NoTag ]
37   type entry = locator list * locator list * locator list * tag
38   type t = entry list
39
40   val empty: t
41
42   val find_goal: t -> goal            (** find "next" goal *)
43   val is_empty: t -> bool             (** a singleton empty level *)
44   val of_metasenv: Cic.metasenv -> t
45   val head_switches: t -> switch list (** top level switches *)
46   val head_goals: t -> goal list      (** top level goals *)
47   val head_tag: t -> tag              (** top level tag *)
48   val shift_goals: t -> goal list     (** second level goals *)
49   val open_goals: t -> goal list      (** all (Open) goals *)
50   val goal_of_switch: switch -> goal
51
52   (** @param int depth, depth 0 is the top of the stack *)
53   val fold:
54     env: ('a -> int -> tag -> locator -> 'a) ->
55     cont:('a -> int -> tag -> locator -> 'a) ->
56     todo:('a -> int -> tag -> locator -> 'a) ->
57       'a  -> t -> 'a
58
59   val iter: (** @param depth as above *)
60     env: (int -> tag -> locator -> unit) ->
61     cont:(int -> tag -> locator -> unit) ->
62     todo:(int -> tag -> locator -> unit) ->
63       t -> unit
64
65   val map:  (** @param depth as above *)
66     env: (int -> tag -> locator list -> locator list) ->
67     cont:(int -> tag -> locator list -> locator list) ->
68     todo:(int -> tag -> locator list -> locator list) ->
69       t -> t
70
71   val pp: t -> string
72 end
73
74 (** {2 Functorial interface} *)
75
76 module type Status =
77 sig
78   type input_status
79   type output_status
80
81   type tactic
82
83   val id_tactic : tactic
84   val mk_tactic : (input_status -> output_status) -> tactic
85   val apply_tactic : tactic -> input_status -> output_status
86
87   val goals : output_status -> goal list * goal list (** opened, closed goals *)
88   val set_goals: goal list * goal list -> output_status -> output_status
89   val get_stack : input_status -> Stack.t
90   val set_stack : Stack.t -> output_status -> output_status
91
92   val inject : input_status -> output_status
93   val focus : goal -> output_status -> input_status
94 end
95
96 module type C =
97 sig
98   type input_status
99   type output_status
100   type tactic
101
102   type tactical =
103     | Tactic of tactic
104     | Skip
105
106   type t =
107     | Dot
108     | Semicolon
109
110     | Branch
111     | Shift
112     | Pos of int
113     | Merge
114     | Focus of goal list
115     | Unfocus
116
117     | Tactical of tactical
118
119   val eval: t -> input_status -> output_status
120 end
121
122 module Make (S: Status) : C
123   with type tactic = S.tactic
124    and type input_status = S.input_status
125    and type output_status = S.output_status
126