]> matita.cs.unibo.it Git - helm.git/blob - matita/components/ng_tactics/continuationals.mli
acic_procedural and tactics removed
[helm.git] / matita / components / ng_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 = int
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 of_nmetasenv: (goal * 'a) list -> t
46   val head_switches: t -> switch list (** top level switches *)
47   val head_goals: t -> goal list      (** top level goals *)
48   val head_tag: t -> tag              (** top level tag *)
49   val shift_goals: t -> goal list     (** second level goals *)
50   val open_goals: t -> goal list      (** all (Open) goals *)
51   val goal_of_switch: switch -> goal
52   val filter_open : (goal * switch) list -> (goal * switch) list
53   val is_open: goal * switch -> bool
54   val is_fresh: goal * switch -> bool
55   val init_pos: (goal * switch) list -> (goal * switch) list 
56   val goal_of_loc: goal * switch -> goal
57   val switch_of_loc: goal * switch -> switch
58   val zero_pos : goal list -> (goal * switch) list
59   val deep_close: goal list -> t -> t
60
61
62   val ( @+ ) : 'a list -> 'a list -> 'a list
63   val ( @- ) : 'a list -> 'a list -> 'a list
64   val ( @~- ) : ('a * switch) list -> goal list -> ('a * switch) list
65
66
67
68   (** @param int depth, depth 0 is the top of the stack *)
69   val fold:
70     env: ('a -> int -> tag -> locator -> 'a) ->
71     cont:('a -> int -> tag -> locator -> 'a) ->
72     todo:('a -> int -> tag -> locator -> 'a) ->
73       'a  -> t -> 'a
74
75   val iter: (** @param depth as above *)
76     env: (int -> tag -> locator -> unit) ->
77     cont:(int -> tag -> locator -> unit) ->
78     todo:(int -> tag -> locator -> unit) ->
79       t -> unit
80
81   val map:  (** @param depth as above *)
82     env: (int -> tag -> locator list -> locator list) ->
83     cont:(int -> tag -> locator list -> locator list) ->
84     todo:(int -> tag -> locator list -> locator list) ->
85       t -> t
86
87   val pp: t -> string
88 end
89
90 (** {2 Functorial interface} *)
91
92 module type Status =
93 sig
94   type input_status
95   type output_status
96
97   type tactic
98   val mk_tactic : (input_status -> output_status) -> tactic
99   val apply_tactic : tactic -> input_status -> output_status
100
101   val goals : output_status -> goal list * goal list (** opened, closed goals *)
102   val get_stack : input_status -> Stack.t
103   val set_stack : Stack.t -> output_status -> output_status
104
105   val inject : input_status -> output_status
106   val focus : goal -> output_status -> input_status
107 end
108
109 module type C =
110 sig
111   type input_status
112   type output_status
113   type tactic
114
115   type tactical =
116     | Tactic of tactic
117     | Skip
118
119   type t =
120     | Dot
121     | Semicolon
122
123     | Branch
124     | Shift
125     | Pos of int list
126     | Wildcard
127     | Merge
128
129     | Focus of goal list
130     | Unfocus
131
132     | Tactical of tactical
133
134   val eval: t -> input_status -> output_status
135 end
136
137 module Make (S: Status) : C
138   with type tactic = S.tactic
139    and type input_status = S.input_status
140    and type output_status = S.output_status
141