]> matita.cs.unibo.it Git - helm.git/blob - matita/components/grafite/grafiteAst.ml
c4ec503c797a2418b66ea0dcfc8c39359f747b80
[helm.git] / matita / components / grafite / grafiteAst.ml
1 (* Copyright (C) 2004, 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 (* $Id$ *)
27
28 type direction = [ `LeftToRight | `RightToLeft ]
29
30 type loc = Stdpp.location
31
32 type nterm = NotationPt.term
33
34 type npattern = 
35  nterm option * (string * nterm) list * nterm option
36
37 type auto_params = nterm list option * (string*string) list
38
39 type just = [`Term of nterm | `Auto of auto_params]
40
41 type ntactic =
42    | NApply of loc * nterm
43    | NSmartApply of loc * nterm
44    | NAssert of loc * ((string * [`Decl of nterm | `Def of nterm * nterm]) list * nterm) list
45    | NCases of loc * nterm * npattern  
46    | NCase1 of loc * string
47    | NChange of loc * npattern * nterm
48    | NClear of loc * string list
49    | NConstructor of loc * int option * nterm list
50    | NCut of loc * nterm
51 (* | NDiscriminate of loc * nterm
52    | NSubst of loc * nterm *)
53    | NDestruct of loc * string list option * string list
54    | NElim of loc * nterm * npattern  
55    | NGeneralize of loc * npattern
56    | NId of loc
57    | NIntro of loc * string
58    | NIntros of loc * string list
59    | NInversion of loc * nterm * npattern  
60    | NLApply of loc * nterm
61    | NLetIn of loc * npattern * nterm * string
62    | NReduce of loc * [ `Normalize of bool | `Whd of bool ] * npattern
63    | NRewrite of loc * direction * nterm * npattern
64    | NAuto of loc * auto_params
65    | NDot of loc
66    | NSemicolon of loc
67    | NBranch of loc
68    | NShift of loc
69    | NPos of loc * int list
70    | NPosbyname of loc * string
71    | NWildcard of loc
72    | NMerge of loc
73    | NSkip of loc
74    | NFocus of loc * int list
75    | NUnfocus of loc
76    | NTry of loc * ntactic
77    | NAssumption of loc
78    | NRepeat of loc * ntactic
79    | NBlock of loc * ntactic list
80    (* Declarative langauge *)
81    (* Not the best idea to use a string directly, an abstract type for identifiers would be better *)
82    | Assume of loc * string * nterm * nterm option (* loc, identifier, type, eqty *)
83    | Suppose of loc * nterm *string * nterm option (* loc, assumption, identifier, eqass *)
84    | By_just_we_proved of loc * just * nterm * string option * nterm option (* loc,
85    justification, conclusion, identifier, eqconcl *)
86    | We_need_to_prove of loc * nterm * string option * nterm option (* loc, newconclusion,
87    identifier, equivnewcon *)
88    | Bydone of loc * just
89    | ExistsElim of loc * just * string * nterm * nterm * string
90    | AndElim of loc * just * nterm * string * nterm * string
91                 (*
92    | RewritingStep of
93       loc * (string option * nterm) option * nterm *
94        [ `Term of nterm | `Auto of auto_params
95        | `Proof | `SolveWith of nterm ] *
96        bool (* last step*)
97                    *)
98    | RewritingStep of
99       loc * nterm * [ `Term of nterm | `Auto of auto_params | `Proof | `SolveWith of nterm ] * bool (* last step*)
100    | Obtain of
101       loc * string * nterm
102    | Conclude of
103       loc * nterm
104    | Thesisbecomes of loc * nterm * nterm option
105    | We_proceed_by_induction_on of loc * nterm * nterm
106    | We_proceed_by_cases_on of loc * nterm * nterm
107    | Byinduction of loc * nterm * string
108    | Case of loc * string * (string * nterm) list 
109     (* This is a debug tactic to print the stack to stdout, can be safely removed *)
110    | PrintStack of loc 
111
112 type nmacro =
113   | NCheck of loc * nterm
114   | Screenshot of loc * string
115   | NAutoInteractive of loc * auto_params
116   | NIntroGuess of loc
117
118 (** To be increased each time the command type below changes, used for "safe"
119  * marshalling *)
120 let magic = 37
121
122 (* composed magic: term + command magics. No need to change this value *)
123 let magic = magic + 10000 * NotationPt.magic
124
125 type alias_spec =
126   | Ident_alias of string * string        (* identifier, uri *)
127   | Symbol_alias of string * int * string (* name, instance no, description *)
128   | Number_alias of int * string          (* instance no, description *)
129
130 type inclusion_mode = WithPreferences | WithoutPreferences | OnlyPreferences (* aka aliases *)
131
132 type command =
133   | Include of loc * inclusion_mode * string (* _,buri,_,path *)
134   | UnificationHint of loc * nterm * int (* term, precedence *)
135   | NObj of loc * nterm NotationPt.obj * bool
136   | NDiscriminator of loc * nterm
137   | NInverter of loc * string * nterm * bool list option * nterm option
138   | NUnivConstraint of loc * bool * NUri.uri * NUri.uri
139   | NCopy of loc * string * NUri.uri * (NUri.uri * NUri.uri) list
140   | NCoercion of loc * string * bool * 
141       (nterm * nterm * (string * nterm) * nterm) option
142   | NQed of loc * bool
143   (* ex lexicon commands *)
144   | Alias of loc * alias_spec
145       (** parameters, name, type, fields *) 
146   | Notation of loc * direction option * nterm * Gramext.g_assoc *
147       int * nterm
148       (* direction, l1 pattern, associativity, precedence, l2 pattern *)
149   | Interpretation of loc *
150       string * (string * NotationPt.argument_pattern list) *
151         NotationPt.cic_appl_pattern
152       (* description (i.e. id), symbol, arg pattern, appl pattern *)
153
154 type code =
155   | NCommand of loc * command
156   | NMacro of loc * nmacro 
157   | NTactic of loc * ntactic list
158              
159 type comment =
160   | Note of loc * string
161   | Code of loc * code
162              
163 type statement =
164   | Executable of loc * code
165   | Comment of loc * comment
166
167 let description_of_alias =
168  function
169     Ident_alias (_,desc)
170   | Symbol_alias (_,_,desc)
171   | Number_alias (_,desc) -> desc