Skip to content

Commit 3be67b0

Browse files
committed
Remove Internals.has_to_ieee_bv in favour of option type
1 parent e299f0c commit 3be67b0

10 files changed

+19
-35
lines changed

src/smtml/altergo_mappings.default.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ module M = struct
4949
let caches_consts = false
5050

5151
let is_available = true
52-
53-
let has_to_ieee_bv = false
5452
end
5553

5654
type 'a sat_module = (module Sat_solver_sig.S with type t = 'a)

src/smtml/bitwuzla_mappings.default.ml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ module Fresh_bitwuzla (B : Bitwuzla_cxx.S) : M = struct
1111
let caches_consts = false
1212

1313
let is_available = true
14-
15-
let has_to_ieee_bv = false
1614
end
1715

1816
type ty = Sort.t
@@ -414,8 +412,7 @@ module Fresh_bitwuzla (B : Bitwuzla_cxx.S) : M = struct
414412

415413
let of_ieee_bv eb sb bv = mk_term1_indexed2 Kind.Fp_to_fp_from_bv bv eb sb
416414

417-
let to_ieee_bv _f =
418-
Fmt.failwith "Bitwuzla_mappings: to_ieee_bv is not implemented"
415+
let to_ieee_bv = None
419416
end
420417

421418
module Func = struct

src/smtml/colibri2_mappings.default.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ module M = struct
2424
let caches_consts = false
2525

2626
let is_available = true
27-
28-
let has_to_ieee_bv = false
2927
end
3028

3129
type model =

src/smtml/cvc5_mappings.default.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ module Fresh_cvc5 () = struct
1010
let caches_consts = false
1111

1212
let is_available = true
13-
14-
let has_to_ieee_bv = false
1513
end
1614

1715
type ty = Sort.sort
@@ -411,7 +409,7 @@ module Fresh_cvc5 () = struct
411409
let op = Op.mk_op tm Kind.Floatingpoint_to_fp_from_ieee_bv [| i1; i2 |] in
412410
Term.mk_term_op tm op [| t |]
413411

414-
let to_ieee_bv _ = assert false
412+
let to_ieee_bv = None
415413
end
416414

417415
module Func = struct

src/smtml/dolmenexpr_to_expr.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ module DolmenIntf = struct
341341

342342
let of_ieee_bv eb sb bv = DTerm.Float.ieee_format_to_fp eb sb bv
343343

344-
let to_ieee_bv _fp = assert false
344+
let to_ieee_bv = None
345345
end
346346

347347
module Func = struct

src/smtml/dolmenexpr_to_expr.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ module DolmenIntf : sig
324324

325325
val of_ieee_bv : int -> int -> term -> term
326326

327-
val to_ieee_bv : term -> term
327+
val to_ieee_bv : (term -> term) option
328328
end
329329

330330
module Func : sig

src/smtml/mappings.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,10 @@ module Make (M_with_make : M_with_make) : S_with_fresh = struct
429429
end
430430
end)
431431

432-
let to_ieee_bv f e =
433-
if M.Internals.has_to_ieee_bv then M.Float.to_ieee_bv e
434-
else M.Func.apply f [ e ]
432+
let to_ieee_bv =
433+
match M.Float.to_ieee_bv with
434+
| Some to_ieee_bv -> fun _ e -> to_ieee_bv e
435+
| None -> fun f e -> M.Func.apply f [ e ]
435436

436437
module I32 = Bitv_impl (struct
437438
type elt = int32

src/smtml/mappings.nop.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ module Nop = struct
88
let caches_consts = false
99

1010
let is_available = false
11-
12-
let has_to_ieee_bv = false
1311
end
1412

1513
type ty = unit
@@ -323,7 +321,7 @@ module Nop = struct
323321

324322
let of_ieee_bv _ = assert false
325323

326-
let to_ieee_bv _ = assert false
324+
let to_ieee_bv = None
327325
end
328326

329327
module Func = struct

src/smtml/mappings_intf.ml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
1313
solvers, including term construction, type handling, and solver interaction.
1414
*)
1515
module type M = sig
16-
module Internals : sig
17-
(** [is_available] indicates whether the module is available for use. *)
18-
val is_available : bool
19-
20-
(** [caches_consts] indicates whether the solver caches constants. *)
21-
val caches_consts : bool
22-
23-
(** [has_to_ieee_bv] indicates whether the solver native support for the
24-
[to_ieee_bv]. *)
25-
val has_to_ieee_bv : bool
26-
end
27-
2816
(** The type of SMT sorts (types). *)
2917
type ty
3018

@@ -102,6 +90,14 @@ module type M = sig
10290
(** [exists vars body] constructs an existential quantification term. *)
10391
val exists : term list -> term -> term
10492

93+
module Internals : sig
94+
(** [is_available] indicates whether the module is available for use. *)
95+
val is_available : bool
96+
97+
(** [caches_consts] indicates whether the solver caches constants. *)
98+
val caches_consts : bool
99+
end
100+
105101
(** {2 Type Handling} *)
106102

107103
module Types : sig
@@ -584,7 +580,7 @@ module type M = sig
584580

585581
(** [to_ieee_bv t] converts the floating-point term [t] to an IEEE bitvector
586582
term. *)
587-
val to_ieee_bv : term -> term
583+
val to_ieee_bv : (term -> term) option
588584
end
589585

590586
(** {2 Function Handling} *)

src/smtml/z3_mappings.default.ml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ module M = struct
1010
let caches_consts = true
1111

1212
let is_available = true
13-
14-
let has_to_ieee_bv = true
1513
end
1614

1715
type ty = Z3.Sort.sort
@@ -393,7 +391,7 @@ module M = struct
393391
let of_ieee_bv eb sb bv =
394392
Z3.FloatingPoint.mk_to_fp_bv ctx bv (Types.float eb sb)
395393

396-
let to_ieee_bv fp = Z3.FloatingPoint.mk_to_ieee_bv ctx fp
394+
let to_ieee_bv = Some (fun fp -> Z3.FloatingPoint.mk_to_ieee_bv ctx fp)
397395
end
398396

399397
module Func = struct

0 commit comments

Comments
 (0)