package dolmen

  1. Overview
  2. Docs

Source file builtin.ml

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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

(* This file is free software, part of dolmen. See file "LICENSE" for more information *)

(* Main Typedef *)
(* ************************************************************************* *)

type 'a t = 'a Dolmen_intf.Builtin.t = .. constraint 'a = < .. >
(* Extensible variant type for builtin operations.
   Parameterized over the type of variables, constants, and terms. *)

(* Base builtins *)
(* ************************************************************************* *)

type _ t += Base

type _ t +=
  | Wildcard : { ty : 'ty option ref; } -> < ty : 'ty ; .. > t

type _ t += Kind | Type

type _ t += Unit | Univ

type _ t += Equal | Distinct

type _ t += Coercion

type _ t +=
  | Maps_to
  | Multi_trigger
  | Semantic_trigger

type _ t += Pi | Sigma


(* Boolean builtins *)
(* ************************************************************************* *)

module Prop = struct
  type _ t =
    | T (* Alias Prop *)
    | True | False
    | Neg | And | Or
    | Nand | Nor | Xor
    | Imply | Implied | Equiv
    | Ite
end

type 'a t += Prop of 'a Prop.t


(* Algebraic datatype builtins *)
(* ************************************************************************* *)

module Adt = struct
  type _ t =
    | Tester :
        { adt: 'ty_cst; case: int; cstr : 'term_cst; } ->
        < ty_cst : 'ty_cst ; term_cst : 'term_cst; .. > t
    | Constructor :
        { adt : 'ty_cst; case : int; } ->
        < ty_cst : 'ty_cst ; .. > t
    | Destructor :
        { adt : 'ty_cst; case : int; cstr : 'term_cst; field: int; } ->
        < ty_cst : 'ty_cst ; term_cst : 'term_cst; .. > t
end

type 'a t += Adt of 'a Adt.t


(* HO encoding into FO using Maps *)
(* ************************************************************************* *)

module Map = struct
  type _ t =
    | T
    | App
end

type 'a t += Map of 'a Map.t


(* Arithmetic builtins *)
(* ************************************************************************* *)

module Arith = struct
  type int_real = [ `Int | `Real ]
  type rat_real = [ `Rat | `Real ]
  type int_rat_real = [ `Int | `Rat | `Real ]
  type _ t =
    | Int | Integer of string
    | Rat | Rational of string
    | Real | Decimal of string
    | Lt of int_rat_real | Leq of int_rat_real
    | Gt of int_rat_real | Geq of int_rat_real
    | Minus of int_rat_real
    | Add of int_rat_real | Sub of int_rat_real
    | Mul of int_rat_real | Pow of int_real
    | Div of rat_real
    | Div_e of int_rat_real | Modulo_e of int_rat_real
    | Div_t of int_rat_real | Modulo_t of int_rat_real
    | Div_f of int_rat_real | Modulo_f of int_rat_real
    | Abs | Divisible
    | Is_int of int_rat_real | Is_rat of int_rat_real
    | Floor of int_rat_real | Floor_to_int of rat_real
    | Ceiling of int_rat_real | Truncate of int_rat_real | Round of int_rat_real
end

type 'a t += Arith of 'a Arith.t


(* Array builtins *)
(* ************************************************************************* *)

module Array = struct
  type _ t =
    | T | Const | Store | Select
end

type 'a t += Array of 'a Array.t

(* Bitvectors *)
(* ************************************************************************* *)

module Bitv = struct
  type _ t =
    | T of { n : int; }
    | Binary_lit of string
    | To_int of { n : int; signed : bool; }
    | Of_int of { n : int; }
    | Concat of { n : int; m : int }
    | Extract of { n : int; i : int; j : int }
    | Repeat of { n : int; k : int }
    | Zero_extend of { n : int; k : int }
    | Sign_extend of { n : int; k : int }
    | Rotate_right of { n : int; i : int }
    | Rotate_left of { n : int; i : int }
    | Not of { n : int; }
    | And of { n : int; }
    | Or of { n : int; }
    | Nand of { n : int; }
    | Nor of { n : int; }
    | Xor of { n : int; }
    | Xnor of { n : int; }
    | Comp of { n : int; }
    | Neg of { n : int; }
    | Add of { n : int; }
    | Sub of { n : int; }
    | Mul of { n : int; }
    | Udiv of { n : int; }
    | Urem of { n : int; }
    | Sdiv of { n : int; }
    | Srem of { n : int; }
    | Smod of { n : int; }
    | Shl of { n : int; }
    | Lshr of { n : int; }
    | Ashr of { n : int; }
    | Ult of { n : int; }
    | Ule of { n : int; }
    | Ugt of { n : int; }
    | Uge of { n : int; }
    | Slt of { n : int; }
    | Sle of { n : int; }
    | Sgt of { n : int; }
    | Sge of { n : int; }
    | Overflow_neg of { n : int; }
    | Overflow_add of { n : int; signed : bool; }
    | Overflow_sub of { n : int; signed : bool; }
    | Overflow_mul of { n : int; signed : bool; }
    | Overflow_div of { n : int; }
end

type 'a t += Bitv of 'a Bitv.t

(* Floats *)
(* ************************************************************************* *)

module Float = struct

  type rounding_mode =
    | RoundNearestTiesToEven
    | RoundNearestTiesToAway
    | RoundTowardPositive
    | RoundTowardNegative
    | RoundTowardZero

  type _ t =
    | T of { e : int; s : int; }
    | RoundingMode
    | RM of rounding_mode
    | Fp of { e : int; s : int; }
    | Plus_infinity of { e : int; s : int; }
    | Minus_infinity of { e : int; s : int; }
    | Plus_zero of { e : int; s : int; }
    | Minus_zero of { e : int; s : int; }
    | NaN of { e : int; s : int; }
    | Abs of { e : int; s : int; }
    | Neg of { e : int; s : int; }
    | Add of { e : int; s : int; }
    | Sub of { e : int; s : int; }
    | Mul of { e : int; s : int; }
    | Div of { e : int; s : int; }
    | Fma of { e : int; s : int; }
    | Sqrt of { e : int; s : int; }
    | Rem of { e : int; s : int; }
    | RoundToIntegral  of { e : int; s : int; }
    | Min of { e : int; s : int; }
    | Max of { e : int; s : int; }
    | Leq of { e : int; s : int; }
    | Lt of { e : int; s : int; }
    | Geq of { e : int; s : int; }
    | Gt of { e : int; s : int; }
    | Eq of { e : int; s : int; }
    | IsNormal of { e : int; s : int; }
    | IsSubnormal of { e : int; s : int; }
    | IsZero of { e : int; s : int; }
    | IsInfinite of { e : int; s : int; }
    | IsNaN of { e : int; s : int; }
    | IsNegative of { e : int; s : int; }
    | IsPositive of { e : int; s : int; }
    | Ieee_format_to_fp of { e : int; s : int; }
    | To_fp of { e1 : int; s1 : int; e2 : int; s2 : int; }
    | Of_real of { e : int; s : int; }
    | Of_sbv of { m : int; e : int; s : int; }
    | Of_ubv of { m : int; e : int; s : int; }
    | To_ubv of { m : int; e : int; s : int; }
    | To_sbv of { m : int; e : int; s : int; }
    | To_real of { e : int; s : int; }
end

type 'a t += Float of 'a Float.t


(* Strings *)
(* ************************************************************************* *)

module Str = struct

  type _ t =
    | T
    | Raw of string
    | Length
    | At
    | To_code
    | Of_code
    | Is_digit
    | To_int
    | Of_int
    | Concat
    | Sub
    | Index_of
    | Replace
    | Replace_all
    | Replace_re
    | Replace_re_all
    | Is_prefix
    | Is_suffix
    | Contains
    | Lexicographic_strict
    | Lexicographic_large
    | In_re

  (* String Regular languages *)
  module RegLan = struct
    type _ t =
      | T
      | Empty
      | All
      | Allchar
      | Of_string
      | Range
      | Concat
      | Union
      | Inter
      | Star
      | Cross
      | Complement
      | Diff
      | Option
      | Power of int
      | Loop of int * int
  end

end

type 'a t +=
  | Str of 'a Str.t
  | Regexp of 'a Str.RegLan.t