]> matita.cs.unibo.it Git - helm.git/blob - components/tactics/continuationals.mli
matita 0.5.1 tagged
[helm.git] / components / 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   val mk_tactic : (input_status -> output_status) -> tactic
83   val apply_tactic : tactic -> input_status -> output_status
84
85   val goals : output_status -> goal list * goal list (** opened, closed goals *)
86   val get_stack : input_status -> Stack.t
87   val set_stack : Stack.t -> output_status -> output_status
88
89   val inject : input_status -> output_status
90   val focus : goal -> output_status -> input_status
91 end
92
93 module type C =
94 sig
95   type input_status
96   type output_status
97   type tactic
98
99   type tactical =
100     | Tactic of tactic
101     | Skip
102
103   type t =
104     | Dot
105     | Semicolon
106
107     | Branch
108     | Shift
109     | Pos of int list
110     | Wildcard
111     | Merge
112
113     | Focus of goal list
114     | Unfocus
115
116     | Tactical of tactical
117
118   val eval: t -> input_status -> output_status
119 end
120
121 module Make (S: Status) : C
122   with type tactic = S.tactic
123    and type input_status = S.input_status
124    and type output_status = S.output_status
125