-
Notifications
You must be signed in to change notification settings - Fork 3
/
term.ml
145 lines (104 loc) · 4.95 KB
/
term.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
(**************************************************************************)
(* Bitwuzla: Satisfiability Modulo Theories (SMT) solver. *)
(* *)
(* Copyright (C) 2023 by the authors listed in the AUTHORS file at *)
(* https://github.com/bitwuzla/bitwuzla/blob/main/AUTHORS *)
(* *)
(* This file is part of Bitwuzla under the MIT license. *)
(* See COPYING for more information at *)
(* https://github.com/bitwuzla/bitwuzla/blob/main/COPYING *)
(**************************************************************************)
type t
external id : t -> (int64[@unboxed])
= "ocaml_bitwuzla_cxx_term_id" "native_bitwuzla_cxx_term_id"
external compare : t -> t -> (int[@untagged])
= "ocaml_bitwuzla_cxx_term_compare" "native_bitwuzla_cxx_term_compare"
external equal : t -> t -> bool = "ocaml_bitwuzla_cxx_term_equal"
external hash : t -> (int[@untagged])
= "ocaml_bitwuzla_cxx_term_hash" "native_bitwuzla_cxx_term_hash"
external kind : t -> (int[@untagged])
= "ocaml_bitwuzla_cxx_term_kind" "native_bitwuzla_cxx_term_kind"
let kind t = Kind.of_cxx @@ kind t
external sort : t -> Sort.t = "ocaml_bitwuzla_cxx_term_sort"
external num_children : t -> (int[@untagged])
= "ocaml_bitwuzla_cxx_term_num_children"
"native_bitwuzla_cxx_term_num_children"
external children : t -> t array = "ocaml_bitwuzla_cxx_term_children"
external get : t -> (int[@untagged]) -> t
= "ocaml_bitwuzla_cxx_term_get" "native_bitwuzla_cxx_term_get"
external num_indices : t -> (int[@untagged])
= "ocaml_bitwuzla_cxx_term_num_indices" "native_bitwuzla_cxx_term_num_indices"
external indices : t -> int array = "ocaml_bitwuzla_cxx_term_indices"
external symbol : t -> string = "ocaml_bitwuzla_cxx_term_symbol"
external is_const : t -> bool = "ocaml_bitwuzla_cxx_term_is_const" [@@noalloc]
external is_variable : t -> bool = "ocaml_bitwuzla_cxx_term_is_variable"
[@@noalloc]
external is_value : t -> bool = "ocaml_bitwuzla_cxx_term_is_value" [@@noalloc]
external is_bv_value_zero : t -> bool
= "ocaml_bitwuzla_cxx_term_is_bv_value_zero"
[@@noalloc]
external is_bv_value_one : t -> bool = "ocaml_bitwuzla_cxx_term_is_bv_value_one"
[@@noalloc]
external is_bv_value_ones : t -> bool
= "ocaml_bitwuzla_cxx_term_is_bv_value_ones"
[@@noalloc]
external is_bv_value_min_signed : t -> bool
= "ocaml_bitwuzla_cxx_term_is_bv_value_min_signed"
[@@noalloc]
external is_bv_value_max_signed : t -> bool
= "ocaml_bitwuzla_cxx_term_is_bv_value_max_signed"
[@@noalloc]
external is_fp_value_pos_zero : t -> bool
= "ocaml_bitwuzla_cxx_term_is_fp_value_pos_zero"
[@@noalloc]
external is_fp_value_neg_zero : t -> bool
= "ocaml_bitwuzla_cxx_term_is_fp_value_neg_zero"
[@@noalloc]
external is_fp_value_pos_inf : t -> bool
= "ocaml_bitwuzla_cxx_term_is_fp_value_pos_inf"
[@@noalloc]
external is_fp_value_neg_inf : t -> bool
= "ocaml_bitwuzla_cxx_term_is_fp_value_neg_inf"
[@@noalloc]
external is_fp_value_nan : t -> bool = "ocaml_bitwuzla_cxx_term_is_fp_value_nan"
[@@noalloc]
external is_rm_value_rna : t -> bool = "ocaml_bitwuzla_cxx_term_is_rm_value_rna"
[@@noalloc]
external is_rm_value_rne : t -> bool = "ocaml_bitwuzla_cxx_term_is_rm_value_rne"
[@@noalloc]
external is_rm_value_rtn : t -> bool = "ocaml_bitwuzla_cxx_term_is_rm_value_rtn"
[@@noalloc]
external is_rm_value_rtp : t -> bool = "ocaml_bitwuzla_cxx_term_is_rm_value_rtp"
[@@noalloc]
external is_rm_value_rtz : t -> bool = "ocaml_bitwuzla_cxx_term_is_rm_value_rtz"
[@@noalloc]
external to_string : (int[@untagged]) -> t -> string
= "ocaml_bitwuzla_cxx_term_to_string" "native_bitwuzla_cxx_term_to_string"
let to_string ?(bv_format = 2) t = to_string bv_format t
external pp : Format.formatter -> t -> unit = "ocaml_bitwuzla_cxx_term_pp"
external pp_smt2 : bv_format:(int[@untagged]) -> Format.formatter -> t -> unit
= "ocaml_bitwuzla_cxx_term_pp_smt2" "native_bitwuzla_cxx_term_pp_smt2"
external to_bool : t -> bool = "ocaml_bitwuzla_cxx_term_boolean_value"
external to_rounding_mode : t -> (int[@untagged])
= "ocaml_bitwuzla_cxx_term_rounding_mode_value"
"native_bitwuzla_cxx_term_rounding_mode_value"
external to_base : t -> (int[@untagged]) -> string
= "ocaml_bitwuzla_cxx_term_string_value"
"native_bitwuzla_cxx_term_string_value"
external to_ieee_754 : t -> string * string * string
= "ocaml_bitwuzla_cxx_term_ieee_754_value"
external to_zarith : t -> Z.t = "ocaml_bitwuzla_cxx_term_zarith_value"
type _ cast =
| Bool : bool cast
| RoundingMode : RoundingMode.t cast
| String : { base : int } -> string cast
| IEEE_754 : (string * string * string) cast
| Z : Z.t cast
let value : type a. a cast -> t -> a =
fun kind t ->
match kind with
| Bool -> to_bool t
| RoundingMode -> RoundingMode.of_cxx (to_rounding_mode t)
| String { base } -> to_base t base
| IEEE_754 -> to_ieee_754 t
| Z -> to_zarith t