aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/alt-ergo/smtlib2_ast.ml
blob: 65dc3e360d681a40d90ec8c5b566c68bcd554fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
(**************************************************************************)
(*                                                                        *)
(*     SMTCoq, originally belong to The Alt-ergo theorem prover           *)
(*     Copyright (C) 2006-2010                                            *)
(*                                                                        *)
(*     Sylvain Conchon                                                    *)
(*     Evelyne Contejean                                                  *)
(*     Stephane Lescuyer                                                  *)
(*     Mohamed Iguernelala                                                *)
(*     Alain Mebsout                                                      *)
(*                                                                        *)
(*     CNRS - INRIA - Universite Paris Sud                                *)
(*                                                                        *)
(*   This file is distributed under the terms of the CeCILL-C licence     *)
(*                                                                        *)
(**************************************************************************)


type loc = Lexing.position * Lexing.position

type specconstant =
  | SpecConstsDec of loc * string
  | SpecConstNum of loc * string
  | SpecConstString of loc * string
  | SpecConstsHex of loc * string
  | SpecConstsBinary of loc * string

type symbol =
  | Symbol of loc * string
  | SymbolWithOr of loc * string

type sexpr =
  | SexprSpecConst of loc * specconstant
  | SexprSymbol of loc * symbol
  | SexprKeyword of loc * string
  | SexprInParen of loc * (loc * sexpr list)

type attributevalue =
  | AttributeValSpecConst of loc * specconstant
  | AttributeValSymbol of loc * symbol
  | AttributeValSexpr of loc * (loc * sexpr list)

type attribute =
  | AttributeKeyword of loc * string
  | AttributeKeywordValue of loc * string * attributevalue

type an_option = AnOptionAttribute of loc * attribute

type infoflag = InfoFlagKeyword of loc * string

type identifier =
  | IdSymbol of loc * symbol
  | IdUnderscoreSymNum of loc * symbol * (loc * string list)

type sort =
  | SortIdentifier of loc * identifier
  | SortIdSortMulti of loc * identifier * (loc * sort list)

type qualidentifier =
  | QualIdentifierId of loc * identifier
  | QualIdentifierAs of loc * identifier * sort

type sortedvar =
  | SortedVarSymSort of loc * symbol * sort

type varbinding = VarBindingSymTerm of loc * symbol * term

and term =
  | TermSpecConst of loc * specconstant
  | TermQualIdentifier of loc * qualidentifier
  | TermQualIdTerm of loc * qualidentifier * (loc * term list)
  | TermLetTerm of loc * (loc * varbinding list) * term
  | TermForAllTerm of loc * (loc * sortedvar list) * term
  | TermExistsTerm of loc * (loc * sortedvar list) * term
  | TermExclimationPt of loc * term * (loc * attribute list)

type command =
  | CSetLogic of loc * symbol
  | CSetOption of loc * an_option
  | CSetInfo of loc * attribute
  | CDeclareSort of loc * symbol * string
  | CDefineSort of loc * symbol * (loc * symbol list) * sort
  | CDeclareFun of loc * symbol * (loc * sort list) * sort
  | CDefineFun of loc * symbol * (loc * sortedvar list) * sort * term
  | CPush of loc * string
  | CPop of loc * string
  | CAssert of loc * term
  | CCheckSat of loc
  | CGetAssert of loc
  | CGetProof of loc
  | CGetUnsatCore of loc
  | CGetValue of loc * (loc * term list)
  | CGetAssign of loc
  | CGetOption of loc * string
  | CGetInfo of loc * infoflag
  | CExit of loc

type commands = Commands of loc * (loc * command list)


(* loc stands for pos (position) and extradata *)

let loc_an_option = function
  | AnOptionAttribute(d,_) -> d

let loc_attribute = function
  | AttributeKeyword(d,_) -> d
  | AttributeKeywordValue(d,_,_) -> d

let loc_attributevalue = function
  | AttributeValSpecConst(d,_) -> d
  | AttributeValSymbol(d,_) -> d
  | AttributeValSexpr(d,_) -> d

let loc_command = function
  | CSetLogic(d,_) -> d
  | CSetOption(d,_) -> d
  | CSetInfo(d,_) -> d
  | CDeclareSort(d,_,_) -> d
  | CDefineSort(d,_,_,_) -> d
  | CDeclareFun(d,_,_,_) -> d
  | CDefineFun(d,_,_,_,_) -> d
  | CPush(d,_) -> d
  | CPop(d,_) -> d
  | CAssert(d,_) -> d
  | CCheckSat(d) -> d
  | CGetAssert(d) -> d
  | CGetProof(d) -> d
  | CGetUnsatCore(d) -> d
  | CGetValue(d,_) -> d
  | CGetAssign(d) -> d
  | CGetOption(d,_) -> d
  | CGetInfo(d,_) -> d
  | CExit(d) -> d

let loc_commands = function
  | Commands(d,_) -> d

let loc_identifier = function
  | IdSymbol(d,_) -> d
  | IdUnderscoreSymNum(d,_,_) -> d

let loc_infoflag = function
  | InfoFlagKeyword(d,_) -> d

let loc_qualidentifier = function
  | QualIdentifierId(d,_) -> d
  | QualIdentifierAs(d,_,_) -> d

let loc_sexpr = function
  | SexprSpecConst(d,_) -> d
  | SexprSymbol(d,_) -> d
  | SexprKeyword(d,_) -> d
  | SexprInParen(d,_) -> d

let loc_sort = function
  | SortIdentifier(d,_) -> d
  | SortIdSortMulti(d,_,_) -> d

let loc_sortedvar = function
  | SortedVarSymSort(d,_,_) -> d

let loc_specconstant = function
  | SpecConstsDec(d,_) -> d
  | SpecConstNum(d,_) -> d
  | SpecConstString(d,_) -> d
  | SpecConstsHex(d,_) -> d
  | SpecConstsBinary(d,_) -> d

let loc_symbol = function
  | Symbol(d,_) -> d
  | SymbolWithOr(d,_) -> d

let loc_term = function
  | TermSpecConst(d,_) -> d
  | TermQualIdentifier(d,_) -> d
  | TermQualIdTerm(d,_,_) -> d
  | TermLetTerm(d,_,_) -> d
  | TermForAllTerm(d,_,_) -> d
  | TermExistsTerm(d,_,_) -> d
  | TermExclimationPt(d,_,_) -> d

let loc_varbinding = function
  | VarBindingSymTerm(d,_,_) -> d

let loc_couple = fst

let loc_of e = loc_commands e;;



(* let print_specconstant fmt = function
 *   | SpecConstsDec (_, s)
 *   | SpecConstNum (_, s)
 *   | SpecConstString (_, s)
 *   | SpecConstsHex (_, s)
 *   | SpecConstsBinary (_, s) -> Format.pp_print_string fmt s *)


(* let print_symbol fmt = function
 *   | Symbol (_, s)
 *   | SymbolWithOr (_, s) -> Format.pp_print_string fmt s *)


(* let print_identifier fmt = function
 *   | IdSymbol (_, s) -> print_symbol fmt s
 *   | IdUnderscoreSymNum (_, s, (_, l)) ->
 *     Format.fprintf fmt "(_ %a" print_symbol s;
 *     List.iter (Format.fprintf fmt " %s") l;
 *     Format.fprintf fmt ")" *)

(* let rec print_sort fmt = function
 *   | SortIdentifier (_, i) -> print_identifier fmt i
 *   | SortIdSortMulti (_, i, (_, ls)) ->
 *     Format.fprintf fmt "(%a" print_identifier i;
 *     List.iter (Format.fprintf fmt " %a" print_sort) ls;
 *     Format.fprintf fmt ")" *)

(* let print_qualidentifier fmt = function
 *   | QualIdentifierId (_, i) -> print_identifier fmt i
 *   | QualIdentifierAs (_, i, s) ->
 *     Format.fprintf fmt "(%a as %a)"
 *       print_identifier i print_sort s *)

(* let print_sortedvar fmt = function
 *   | SortedVarSymSort (_, v, s) ->
 *     Format.fprintf fmt "(%a %a)" print_symbol v print_sort s *)

(* let rec print_varbinding fmt = function
 *   | VarBindingSymTerm (_, s, t) ->
 *     Format.fprintf fmt "(%a %a)" print_symbol s print_term t *)

(* and print_term fmt = function
 *   | TermSpecConst (_, c) -> print_specconstant fmt c
 *   | TermQualIdentifier (_, i) -> print_qualidentifier fmt i
 *   | TermQualIdTerm (_, i, (_, tl)) ->
 *     Format.fprintf fmt "(%a" print_qualidentifier i;
 *     List.iter (Format.fprintf fmt " %a" print_term) tl;
 *     Format.fprintf fmt ")"
 *   | TermLetTerm (_, (_, vb), t) ->
 *     Format.fprintf fmt "(let (";
 *     List.iter (Format.fprintf fmt " %a" print_varbinding) vb;
 *     Format.fprintf fmt ") %a)" print_term t
 *   | TermForAllTerm (_, (_, sv), t) ->
 *     Format.fprintf fmt "(forall (";
 *     List.iter (Format.fprintf fmt " %a" print_sortedvar) sv;
 *     Format.fprintf fmt ") %a)" print_term t
 *   | TermExistsTerm (_, (_, sv), t) ->
 *     Format.fprintf fmt "(exists (";
 *     List.iter (Format.fprintf fmt " %a" print_sortedvar) sv;
 *     Format.fprintf fmt ") %a)" print_term t
 *   | TermExclimationPt (_, t, _) -> print_term fmt t *)