package codex

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file sva_sig.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
(**************************************************************************)
(*  This file is part of the Codex semantics library.                     *)
(*                                                                        *)
(*  Copyright (C) 2013-2025                                               *)
(*    CEA (Commissariat à l'énergie atomique et aux énergies              *)
(*         alternatives)                                                  *)
(*                                                                        *)
(*  you can redistribute it and/or modify it under the terms of the GNU   *)
(*  Lesser General Public License as published by the Free Software       *)
(*  Foundation, version 2.1.                                              *)
(*                                                                        *)
(*  It is distributed in the hope that it will be useful,                 *)
(*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *)
(*  GNU Lesser General Public License for more details.                   *)
(*                                                                        *)
(*  See the GNU Lesser General Public License version 2.1                 *)
(*  for more details (enclosed in the file LICENSE).                      *)
(*                                                                        *)
(**************************************************************************)

(****************************************************************)
(** Standard abstraction for booleans. *)
module Quadrivalent = Lattices.Quadrivalent
module Bitfield = Lattices.Bitfield

(****************************************************************)
(** {1 Forward transfer functions} *)

module type WITH_BOOLEAN_FORWARD = sig
  type boolean = Quadrivalent.t
  module Boolean_Forward:Operator.BOOLEAN_FORWARD
    with module Arity := Operator.Forward_Arity and type boolean := boolean
end

module type WITH_INTEGER_FORWARD = sig
  type boolean = Quadrivalent.t
  type integer
  module Integer_Forward:Operator.INTEGER_FORWARD
    with module Arity := Operator.Forward_Arity
     and type boolean := boolean
     and type integer := integer
end


module type WITH_BITVECTOR_FORWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  module Bitvector_Forward:Operator.BITVECTOR_FORWARD_WITH_BIMUL_ADD
    with module Arity := Operator.Forward_Arity
     and type boolean := boolean
     and type bitvector := bitvector
end

module type WITH_ENUM_FORWARD = sig
  type boolean = Quadrivalent.t
  type enum
  module Enum_Forward:Operator.ENUM_FORWARD
    with module Arity := Operator.Forward_Arity
     and type boolean := boolean
     and type enum := enum
end

module type WITH_BLOCK_FORWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  type block
  module Block_Forward:Operator.BLOCK_FORWARD
    with module Arity := Operator.Forward_Arity
     and type boolean := boolean
     and type value := bitvector
     and type block := block
     and type offset := bitvector
end

module type WITH_MEMORY_FORWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  type memory
  type block
  module Memory_Forward:Operator.MEMORY_FORWARD
    with module Arity := Operator.Forward_Arity
     and type boolean := boolean
     and type address := bitvector
     and type memory := memory
     and type block := block
     and type value := bitvector
end

module type WITH_MEMORY_BITVECTOR_BOOLEAN_FORWARD = sig
  include WITH_MEMORY_FORWARD
  include WITH_BLOCK_FORWARD with type boolean := boolean
                              and type bitvector := bitvector
                              and type block := block
  include WITH_BITVECTOR_FORWARD with type boolean := boolean
                                  and type bitvector := bitvector
  include WITH_BOOLEAN_FORWARD with type boolean := boolean
end

module type WITH_MEMORY_BITVECTOR_INTEGER_BOOLEAN_FORWARD = sig
  include WITH_MEMORY_FORWARD
  include WITH_BLOCK_FORWARD with type boolean := boolean
                              and type bitvector := bitvector
                              and type block := block
  include WITH_BITVECTOR_FORWARD with type boolean := boolean
                                  and type bitvector := bitvector
  include WITH_INTEGER_FORWARD with type boolean := boolean
  include WITH_BOOLEAN_FORWARD with type boolean := boolean
end

module type WITH_FORWARD = sig
  include WITH_MEMORY_BITVECTOR_INTEGER_BOOLEAN_FORWARD
end


(****************************************************************)
(** {1 Backward transfer functions} *)

module type WITH_BOOLEAN_BACKWARD = sig
  type boolean = Quadrivalent.t
  module Boolean_Backward:Operator.BOOLEAN_BACKWARD
    with module Arity := Operator.Backward_Arity and type boolean := boolean;;
end

module type WITH_INTEGER_BACKWARD = sig
  type boolean = Quadrivalent.t
  type integer
  module Integer_Backward:Operator.INTEGER_BACKWARD
    with module Arity := Operator.Backward_Arity
     and type boolean := boolean
     and type integer := integer
end

module type WITH_ENUM_BACKWARD = sig
  type boolean = Quadrivalent.t
  type enum
  module Enum_Backward:Operator.ENUM_BACKWARD
    with module Arity := Operator.Backward_Arity
     and type boolean := boolean
     and type enum := enum
end

module type WITH_BITVECTOR_BACKWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  module Bitvector_Backward:sig
    include Operator.BITVECTOR_BACKWARD
      with module Arity := Operator.Backward_Arity
       and type boolean := boolean
       and type bitvector := bitvector

    (** Combined operation for multiplication and addition [x -> prod*x + offset].
        This operation does not overflows if only the intermediate term [prod*x] overflows. *)
    val bimul_add: size:Units.In_bits.t -> prod:Z.t -> offset:Z.t -> (bitvector,bitvector) Operator.Backward_Arity.ar1
  end
end

module type WITH_BLOCK_BACKWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  type block
  module Block_Backward:Operator.BLOCK_BACKWARD
    with module Arity := Operator.Backward_Arity
     and type boolean := boolean
     and type value := bitvector
     and type block := block
     and type offset := bitvector
end

module type WITH_MEMORY_BACKWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  type memory
  type block
  module Memory_Backward:Operator.MEMORY_BACKWARD
    with module Arity := Operator.Backward_Arity
     and type boolean := boolean
     and type address := bitvector
     and type memory := memory
     and type block := block
     and type value := bitvector
end

module type WITH_MEMORY_BITVECTOR_BOOLEAN_BACKWARD = sig
  include WITH_MEMORY_BACKWARD
  include WITH_BLOCK_BACKWARD with type boolean := boolean
                               and type bitvector := bitvector
                               and type block := block
  include WITH_BITVECTOR_BACKWARD with type boolean := boolean
                                   and type bitvector := bitvector
  include WITH_BOOLEAN_BACKWARD with type boolean := boolean
end

(****************************************************************)
(** {1 Both backward and forward} *)

module type WITH_BOOLEAN_FORWARD_BACKWARD = sig
  type boolean = Quadrivalent.t
  include WITH_BOOLEAN_FORWARD with type boolean := boolean
  include WITH_BOOLEAN_BACKWARD with type boolean := boolean
end

module type WITH_INTEGER_FORWARD_BACKWARD = sig
  type boolean = Quadrivalent.t
  type integer
  include WITH_INTEGER_FORWARD
    with type boolean := boolean
     and type integer := integer
  include WITH_INTEGER_BACKWARD
    with type boolean := boolean
     and type integer := integer
end

module type WITH_ENUM_FORWARD_BACKWARD = sig
  type boolean = Quadrivalent.t
  type enum
  include WITH_ENUM_FORWARD
    with type boolean := boolean
     and type enum := enum
  include WITH_ENUM_BACKWARD
    with type boolean := boolean
     and type enum := enum
end

module type WITH_BITVECTOR_FORWARD_BACKWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  include WITH_BITVECTOR_FORWARD
    with type boolean := boolean
     and type bitvector := bitvector
  include WITH_BITVECTOR_BACKWARD
    with type boolean := boolean
     and type bitvector := bitvector
end

module type WITH_BLOCK_FORWARD_BACKWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  type block
  include WITH_BLOCK_FORWARD
    with type boolean := boolean
     and type bitvector := bitvector
     and type block := block
  include WITH_BLOCK_BACKWARD
    with type boolean := boolean
     and type bitvector := bitvector
     and type block := block
end

module type WITH_MEMORY_FORWARD_BACKWARD = sig
  type boolean = Quadrivalent.t
  type bitvector
  type memory
  type block
  include WITH_MEMORY_FORWARD
    with type boolean := boolean
     and type bitvector := bitvector
     and type memory := memory
     and type block := block
  include WITH_MEMORY_BACKWARD
    with type boolean := boolean
     and type bitvector := bitvector
     and type memory := memory
     and type block := block
end

module type WITH_BITVECTOR_BOOLEAN_FORWARD_BACKWARD = sig
  include WITH_BITVECTOR_FORWARD_BACKWARD
  include WITH_BOOLEAN_FORWARD_BACKWARD with type boolean := boolean
end


module type WITH_MEMORY_BITVECTOR_BOOLEAN_FORWARD_BACKWARD = sig
  include WITH_MEMORY_FORWARD_BACKWARD;;
  include WITH_BLOCK_FORWARD_BACKWARD with type boolean := boolean
                                       and type bitvector := bitvector
                                       and type block := block
  include WITH_BITVECTOR_BOOLEAN_FORWARD_BACKWARD with type boolean := boolean
                                                   and type bitvector := bitvector
end


module type WITH_FORWARD_BACKWARD = sig
  include WITH_MEMORY_BITVECTOR_BOOLEAN_FORWARD_BACKWARD
end

(****************************************************************)
(** {1 Base versions} *)

module type BOOLEAN_LATTICE = Lattices.Sig.BOOLEAN_LATTICE

module type INTEGER_LATTICE = Lattices.Sig.INTEGER_LATTICE

module type BITVECTOR_LATTICE = Lattices.Sig.BITVECTOR_LATTICE

module type ENUM_LATTICE = Lattices.Sig.ENUM_LATTICE

module type MEMORY_LATTICE = sig
  include Lattices.Sig.JOIN_SEMI_LATTICE_WITH_BOTTOM
end

module type BLOCK_LATTICE = sig
  include Lattices.Sig.JOIN_SEMI_LATTICE_WITH_BOTTOM
end

module type BOOLEAN = sig
  val name: string
  include WITH_BOOLEAN_FORWARD_BACKWARD
  module Boolean_Lattice:BOOLEAN_LATTICE with type t = boolean
end

module type INTEGER = sig
  val name: string
  include WITH_INTEGER_FORWARD_BACKWARD
  include WITH_BOOLEAN_FORWARD_BACKWARD with type boolean := boolean
  module Boolean_Lattice:BOOLEAN_LATTICE with type t = boolean
  module Integer_Lattice:INTEGER_LATTICE with type t = integer
end

module type ENUM = sig
  val name: string
  include WITH_ENUM_FORWARD_BACKWARD
  include WITH_BOOLEAN_FORWARD_BACKWARD with type boolean := boolean
  module Boolean_Lattice:BOOLEAN_LATTICE with type t = boolean
  module Enum_Lattice:ENUM_LATTICE with type t = enum
end

module type BITVECTOR = sig
  val name: string
  include WITH_BITVECTOR_FORWARD_BACKWARD
  include WITH_BOOLEAN_FORWARD_BACKWARD with type boolean := boolean
  module Boolean_Lattice:BOOLEAN_LATTICE with type t = boolean
  module Bitvector_Lattice:BITVECTOR_LATTICE with type t = bitvector
end

module type BITVECTOR_ENUM = sig
  include BITVECTOR
  include ENUM with type boolean := boolean
                and module Boolean_Lattice := Boolean_Lattice
                and module Boolean_Forward := Boolean_Forward
                and module Boolean_Backward := Boolean_Backward
end

module type NUMERIC = sig
  include BITVECTOR
  include INTEGER with type boolean := boolean
                   and module Boolean_Lattice := Boolean_Lattice
                   and module Boolean_Forward := Boolean_Forward
                   and module Boolean_Backward := Boolean_Backward
end

module type NUMERIC_ENUM = sig
  include BITVECTOR
  include INTEGER with type boolean := boolean
                   and module Boolean_Lattice := Boolean_Lattice
                   and module Boolean_Forward := Boolean_Forward
                   and module Boolean_Backward := Boolean_Backward

  include ENUM with type boolean := boolean
                and module Boolean_Lattice := Boolean_Lattice
                and module Boolean_Forward := Boolean_Forward
                and module Boolean_Backward := Boolean_Backward
end


(** Most complete version, with all datatypes. Used as a parameter for
    functors. *)
module type ALL = sig
  val name: string
  include WITH_BOOLEAN_FORWARD_BACKWARD
  include WITH_INTEGER_FORWARD_BACKWARD with type boolean := boolean
  include WITH_BITVECTOR_FORWARD_BACKWARD with type boolean := boolean
  include WITH_BLOCK_FORWARD_BACKWARD with type boolean := boolean
                                       and type bitvector := bitvector
  include WITH_MEMORY_FORWARD_BACKWARD with type bitvector := bitvector
                                        and type boolean := boolean
                                        and type block := block
  include WITH_ENUM_FORWARD_BACKWARD with type boolean := boolean
  module Boolean_Lattice:BOOLEAN_LATTICE with type t = boolean
  module Integer_Lattice:INTEGER_LATTICE with type t = integer
  module Bitvector_Lattice:BITVECTOR_LATTICE with type t = bitvector
  module Memory_Lattice:MEMORY_LATTICE with type t = memory
  module Enum_Lattice:ENUM_LATTICE with type t = enum
  module Block_Lattice:BLOCK_LATTICE with type t = block
end