Debian Codegraph @

plugins/ltac2/tac2expr.mli

raw symbols SCIP
1 (************************************************************************)
2 (* * The Rocq Prover / The Rocq Development Team *)
3 (* v * Copyright INRIA, CNRS and contributors *)
4 (* <O___,, * (see version control and CREDITS file for authors & dates) *)
5 (* \VV/ **************************************************************)
6 (* // * This file is distributed under the terms of the *)
7 (* * GNU Lesser General Public License Version 2.1 *)
8 (* * (see LICENSE file for the text of the license) *)
9 (************************************************************************)
10
11 open Names
12 open Libnames
13
14 type mutable_flag = bool
15 type rec_flag = bool
16 type redef_flag = bool
17 type lid = Id.t
18 type uid = Id.t
19
20 type ltac_constant = KerName.t
21 type ltac_alias = KerName.t
22 type ltac_notation = KerName.t
23 type ltac_constructor = KerName.t
24 type ltac_projection = KerName.t
25 type type_constant = KerName.t
26
27 type tacref =
28 | TacConstant of ltac_constant
29 | TacAlias of ltac_alias
30
31 type 'a or_relid =
32 | RelId of qualid
33 | AbsKn of 'a
34
35 (** {5 Misc} *)
36
37 type ml_tactic_name = {
38 mltac_plugin : string;
39 mltac_tactic : string;
40 }
41
42 type 'a or_tuple =
43 | Tuple of int
44 | Other of 'a
45
46 (** {5 Type syntax} *)
47
48 type raw_typexpr_r =
49 | CTypVar of Name.t
50 | CTypArrow of raw_typexpr * raw_typexpr
51 | CTypRef of type_constant or_tuple or_relid * raw_typexpr list
52
53 and raw_typexpr = raw_typexpr_r CAst.t
54
55 type raw_typedef =
56 | CTydDef of raw_typexpr option
57 | CTydAlg of (Attributes.vernac_flags * lident * raw_typexpr list) list
58 | CTydRec of (lid * mutable_flag * raw_typexpr) list
59 | CTydOpn
60
61 type 'a glb_typexpr =
62 | GTypVar of 'a
63 | GTypArrow of 'a glb_typexpr * 'a glb_typexpr
64 | GTypRef of type_constant or_tuple * 'a glb_typexpr list
65
66 type glb_alg_type = {
67 galg_constructors : (UserWarn.t option * uid * int glb_typexpr list) list;
68 (** Constructors of the algebraic type *)
69 galg_nconst : int;
70 (** Number of constant constructors *)
71 galg_nnonconst : int;
72 (** Number of non-constant constructors *)
73 }
74
75 type glb_typedef =
76 | GTydDef of int glb_typexpr option
77 | GTydAlg of glb_alg_type
78 | GTydRec of (lid * mutable_flag * int glb_typexpr) list
79 | GTydOpn
80
81 type type_scheme = int * int glb_typexpr
82
83 type raw_quant_typedef = Names.lident list * raw_typedef
84 type glb_quant_typedef = int * glb_typedef
85
86 (** {5 Term syntax} *)
87
88 type atom =
89 | AtmInt of int
90 | AtmStr of string
91
92 (* We want to generate these easily in the Closed case, otherwise we
93 could have the kn in the ctor_data_for_patterns type. Maybe still worth doing?? *)
94 type ctor_indx =
95 | Closed of int
96 | Open of ltac_constructor
97
98 type ctor_data_for_patterns = {
99 ctyp : type_constant option; (* [None] means [Tuple cnargs] and [cindx = Closed 0] *)
100 cnargs : int;
101 cindx : ctor_indx;
102 }
103
104 type glb_pat =
105 | GPatVar of Name.t
106 | GPatAtm of atom
107 | GPatRef of ctor_data_for_patterns * glb_pat list
108 | GPatOr of glb_pat list
109 | GPatAs of glb_pat * Id.t
110
111 module PartialPat : sig
112 type r =
113 | Var of Name.t
114 | Atom of atom
115 | Ref of ctor_data_for_patterns * t list
116 | Or of t list
117 | As of t * Id.t
118 | Extension of { example : atom option }
119 and t = r CAst.t
120 end
121
122 type case_info = type_constant or_tuple
123
124 type 'a open_match = {
125 opn_match : 'a;
126 opn_branch : (Name.t * Name.t array * 'a) KerName.Map.t;
127 (** Invariant: should not be empty *)
128 opn_default : Name.t * 'a;
129 }
130
131 type glb_tacexpr =
132 | GTacAtm of atom
133 | GTacVar of Id.t
134 | GTacRef of ltac_constant
135 | GTacFun of Name.t list * glb_tacexpr
136 | GTacApp of glb_tacexpr * glb_tacexpr list
137 | GTacLet of rec_flag * (Name.t * glb_tacexpr) list * glb_tacexpr
138 | GTacCst of case_info * int * glb_tacexpr list
139 | GTacCse of glb_tacexpr * case_info * glb_tacexpr array * (Name.t array * glb_tacexpr) array
140 | GTacPrj of type_constant * glb_tacexpr * int
141 | GTacSet of type_constant * glb_tacexpr * int * glb_tacexpr
142 | GTacOpn of ltac_constructor * glb_tacexpr list
143 | GTacWth of glb_tacexpr open_match
144 | GTacFullMatch of glb_tacexpr * (glb_pat * glb_tacexpr) list
145 | GTacExt : (_, 'a) Tac2dyn.Arg.tag * 'a -> glb_tacexpr
146 | GTacPrm of ml_tactic_name
147
148 (** Tactic expressions *)
149 type raw_patexpr_r =
150 | CPatVar of Name.t
151 | CPatAtm of atom
152 | CPatRef of ltac_constructor or_tuple or_relid * raw_patexpr list
153 | CPatRecord of (ltac_projection or_relid * raw_patexpr) list
154 | CPatCnv of raw_patexpr * raw_typexpr
155 | CPatOr of raw_patexpr list
156 | CPatAs of raw_patexpr * lident
157
158 and raw_patexpr = raw_patexpr_r CAst.t
159
160 type raw_tacexpr_r =
161 | CTacAtm of atom
162 | CTacRef of tacref or_relid
163 | CTacCst of ltac_constructor or_tuple or_relid
164 | CTacFun of raw_patexpr list * raw_tacexpr
165 | CTacApp of raw_tacexpr * raw_tacexpr list
166 | CTacSyn of (lname * raw_tacexpr) list * KerName.t
167 | CTacLet of rec_flag * (raw_patexpr * raw_tacexpr) list * raw_tacexpr
168 | CTacCnv of raw_tacexpr * raw_typexpr
169 | CTacSeq of raw_tacexpr * raw_tacexpr
170 | CTacIft of raw_tacexpr * raw_tacexpr * raw_tacexpr
171 | CTacCse of raw_tacexpr * raw_taccase list
172 | CTacRec of raw_tacexpr option * raw_recexpr
173 | CTacPrj of raw_tacexpr * ltac_projection or_relid
174 | CTacSet of raw_tacexpr * ltac_projection or_relid * raw_tacexpr
175 | CTacExt : ('a, _) Tac2dyn.Arg.tag * 'a -> raw_tacexpr_r
176 | CTacGlb of int * (lname * raw_tacexpr * int glb_typexpr option) list * glb_tacexpr * int glb_typexpr
177 (** CTacGlb is essentially an expanded typed notation.
178 Arguments bound with Anonymous have no type constraint. *)
179
180 and raw_tacexpr = raw_tacexpr_r CAst.t
181
182 and raw_taccase = raw_patexpr * raw_tacexpr
183
184 and raw_recexpr = (ltac_projection or_relid * raw_tacexpr) list
185
186 (** {5 Parsing & Printing} *)
187
188 type exp_level =
189 | E5
190 | E4
191 | E3
192 | E2
193 | E1
194 | E0
195
196 type sexpr =
197 | SexprStr of string CAst.t
198 | SexprInt of int CAst.t
199 | SexprRec of Loc.t * qualid option CAst.t * sexpr list
200
201 (** {5 Toplevel statements} *)
202
203 type strexpr =
204 | StrVal of mutable_flag * rec_flag * (Names.lname * raw_tacexpr) list
205 (** Term definition *)
206 | StrTyp of rec_flag * (qualid * redef_flag * raw_quant_typedef) list
207 (** Type definition *)
208 | StrPrm of Names.lident * raw_typexpr * ml_tactic_name
209 (** External definition *)
210 | StrMut of qualid * Names.lident option * raw_tacexpr
211 (** Redefinition of mutable globals *)
212
213 type frame =
214 | FrLtac of ltac_constant
215 | FrAnon of glb_tacexpr
216 | FrPrim of ml_tactic_name
217 | FrExtn : ('a, 'b) Tac2dyn.Arg.tag * 'b -> frame
218
219 type backtrace = frame list