package bitwuzla-cxx

  1. Overview
  2. Docs

Source file bitwuzla_cxx.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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
(**************************************************************************)
(*  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                *)
(**************************************************************************)

external copyright : unit -> string = "ocaml_bitwuzla_cxx_copyright"
external version : unit -> string = "ocaml_bitwuzla_cxx_version"
external init_format : unit -> unit = "ocaml_bitwuzla_cxx_init_format"

let () =
  Callback.register "Format.pp_open_vbox" Format.pp_open_vbox;
  Callback.register "Format.pp_print_string" Format.pp_print_string;
  Callback.register "Format.pp_print_char" Format.pp_print_char;
  Callback.register "Format.pp_print_space" Format.pp_print_space;
  Callback.register "Format.pp_close_box" Format.pp_close_box;
  init_format ()

external mk_array_sort : Manager.t -> Sort.t -> Sort.t -> Sort.t
  = "ocaml_bitwuzla_cxx_mk_array_sort"

external mk_bool_sort : Manager.t -> Sort.t = "ocaml_bitwuzla_cxx_mk_bool_sort"

external mk_bv_sort : Manager.t -> (int[@untagged]) -> Sort.t
  = "ocaml_bitwuzla_cxx_mk_bv_sort" "native_bitwuzla_cxx_mk_bv_sort"

external mk_fp_sort :
  Manager.t -> (int[@untagged]) -> (int[@untagged]) -> Sort.t
  = "ocaml_bitwuzla_cxx_mk_fp_sort" "native_bitwuzla_cxx_mk_fp_sort"

external mk_fun_sort : Manager.t -> Sort.t array -> Sort.t -> Sort.t
  = "ocaml_bitwuzla_cxx_mk_fun_sort"

external mk_rm_sort : Manager.t -> Sort.t = "ocaml_bitwuzla_cxx_mk_rm_sort"

external mk_uninterpreted_sort : Manager.t -> ?symbol:string -> unit -> Sort.t
  = "ocaml_bitwuzla_cxx_mk_uninterpreted_sort"

external mk_true : Manager.t -> Term.t = "ocaml_bitwuzla_cxx_mk_true"
external mk_false : Manager.t -> Term.t = "ocaml_bitwuzla_cxx_mk_false"

external mk_bv_zero : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_bv_zero"

external mk_bv_one : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_bv_one"

external mk_bv_ones : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_bv_ones"

external mk_bv_min_signed : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_bv_min_signed"

external mk_bv_max_signed : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_bv_max_signed"

external mk_bv_value :
  Manager.t -> Sort.t -> string -> (int[@untagged]) -> Term.t
  = "ocaml_bitwuzla_cxx_mk_bv_value" "native_bitwuzla_cxx_mk_bv_value"

external mk_bv_value_int : Manager.t -> Sort.t -> (int[@untagged]) -> Term.t
  = "ocaml_bitwuzla_cxx_mk_bv_value_int" "native_bitwuzla_cxx_mk_bv_value_int64"

external mk_bv_value_int64 : Manager.t -> Sort.t -> (int64[@unboxed]) -> Term.t
  = "ocaml_bitwuzla_cxx_mk_bv_value_int64"
    "native_bitwuzla_cxx_mk_bv_value_int64"

external mk_fp_pos_zero : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_fp_pos_zero"

external mk_fp_neg_zero : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_fp_neg_zero"

external mk_fp_pos_inf : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_fp_pos_inf"

external mk_fp_neg_inf : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_fp_neg_inf"

external mk_fp_nan : Manager.t -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_fp_nan"

external mk_fp_value : Manager.t -> Term.t -> Term.t -> Term.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_fp_value"

external mk_fp_value_from_real :
  Manager.t -> Sort.t -> Term.t -> string -> Term.t
  = "ocaml_bitwuzla_cxx_mk_fp_value_from_real"

external mk_fp_value_from_rational :
  Manager.t -> Sort.t -> Term.t -> string -> string -> Term.t
  = "ocaml_bitwuzla_cxx_mk_fp_value_from_rational"

external mk_rm_value : Manager.t -> (int[@untagged]) -> Term.t
  = "ocaml_bitwuzla_cxx_mk_rm_value" "native_bitwuzla_cxx_mk_rm_value"

external mk_term1 : Manager.t -> (int[@untagged]) -> Term.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_term1" "native_bitwuzla_cxx_mk_term1"

external mk_term2 : Manager.t -> (int[@untagged]) -> Term.t -> Term.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_term2" "native_bitwuzla_cxx_mk_term2"

external mk_term3 :
  Manager.t -> (int[@untagged]) -> Term.t -> Term.t -> Term.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_term3" "native_bitwuzla_cxx_mk_term3"

external mk_term1_indexed1 :
  Manager.t -> (int[@untagged]) -> Term.t -> (int[@untagged]) -> Term.t
  = "ocaml_bitwuzla_cxx_mk_term1_indexed1"
    "native_bitwuzla_cxx_mk_term1_indexed1"

external mk_term1_indexed2 :
  Manager.t ->
  (int[@untagged]) ->
  Term.t ->
  (int[@untagged]) ->
  (int[@untagged]) ->
  Term.t
  = "ocaml_bitwuzla_cxx_mk_term1_indexed2"
    "native_bitwuzla_cxx_mk_term1_indexed2"

external mk_term2_indexed1 :
  Manager.t ->
  (int[@untagged]) ->
  Term.t ->
  Term.t ->
  (int[@untagged]) ->
  Term.t
  = "ocaml_bitwuzla_cxx_mk_term2_indexed1"
    "native_bitwuzla_cxx_mk_term2_indexed1"

external mk_term2_indexed2 :
  Manager.t ->
  (int[@untagged]) ->
  Term.t ->
  Term.t ->
  (int[@untagged]) ->
  (int[@untagged]) ->
  Term.t
  = "ocaml_bitwuzla_cxx_mk_term2_indexed2"
    "native_bitwuzla_cxx_mk_term2_indexed2"

external mk_term :
  Manager.t -> (int[@untagged]) -> Term.t array -> int array -> Term.t
  = "ocaml_bitwuzla_cxx_mk_term" "native_bitwuzla_cxx_mk_term"

external mk_const : Manager.t -> ?symbol:string -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_const"

external mk_const_array : Manager.t -> Sort.t -> Term.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_const_array"

external mk_var : Manager.t -> ?symbol:string -> Sort.t -> Term.t
  = "ocaml_bitwuzla_cxx_mk_var"

external substitute_term :
  Manager.t -> Term.t -> (Term.t * Term.t) array -> Term.t
  = "ocaml_bitwuzla_cxx_substitute_term"

external substitute_terms :
  Manager.t -> Term.t array -> (Term.t * Term.t) array -> unit
  = "ocaml_bitwuzla_cxx_substitute_terms"

module Options = Options

module type S = sig
  module Sort : sig
    (** {1:sort Sort} *)

    type t
    (** A Bitwuzla sort. *)

    (** {2:sort_util Util} *)

    val hash : t -> int
    (**
     [hash t]
     compute the hash value for a sort.

     @param t The sort.

     @return The hash value of the sort.
  *)

    val equal : t -> t -> bool
    (**
     [equal a b]
     Syntactical equality operator.

     @param a The first sort.
     @param b The second sort.
     @return True if the given sorts are equal.
  *)

    val compare : t -> t -> int
    (**
     [compare a b]
     Syntactical comparison operator.

     @param a The first sort.
     @param b The second sort.
     @return Zero if the given sorts are equal,
             a positive number if [a] > [b],
             a negative number otherwise.
  *)

    val pp : Format.formatter -> t -> unit
    (**
     [pp formatter t]
     print sort.

     @param t The sort.
     @param formatter The outpout formatter.
  *)

    val to_string : t -> string
    (**
     [to_string t]
     get string representation of this sort.

     @return String representation of this sort.
  *)

    (** {2:sort_query Query} *)

    val id : t -> int64
    (**
     [id t]
     get the id of this sort.

     @param t The sort.
     @return The id value of the sort.
  *)

    val bv_size : t -> int
    (**
     [bv_size t]
     get the size of a bit-vector sort.

     Requires that given sort is a bit-vector sort.

     @param t The sort.

     @return The size of the bit-vector sort.
  *)

    val fp_exp_size : t -> int
    (**
     [fp_exp_size sort]
     get the exponent size of a floating-point sort.

     Requires that given sort is a floating-point sort.

     @param t The sort.

     @return The exponent size of the floating-point sort.
  *)

    val fp_sig_size : t -> int
    (**
     [fp_sig_size t]
     get the significand size of a floating-point sort.

     Requires that given sort is a floating-point sort.

     @param t The sort.

     @return The significand size of the floating-point sort.
  *)

    val array_index : t -> t
    (**
     [array_index t]
     get the index sort of an array sort.

     Requires that given sort is an array sort.

     @param t The sort.

     @return The index sort of the array sort.
  *)

    val array_element : t -> t
    (**
     [array_element t]
     get the element sort of an array sort.

     Requires that given sort is an array sort.

     @param t The sort.

     @return The element sort of the array sort.
  *)

    val fun_domain : t -> t array
    (**
     [fun_domain_sorts t]
     get the domain sorts of a function sort.

     Requires that given sort is a function sort.

     @param t The sort.

     @return The domain sorts of the function sort as an array of sort.
  *)

    val fun_codomain : t -> t
    (**
     [fun_codomain t]
     get the codomain sort of a function sort.

     Requires that given sort is a function sort.

     @param t The sort.

     @return The codomain sort of the function sort.
  *)

    val fun_arity : t -> int
    (**
     [fun_arity t]
     get the arity of a function sort.

     @param t The sort.

     @return The number of arguments of the function sort.
  *)

    val uninterpreted_symbol : t -> string
    (**
     [uninterpreted_symbol t]
     get the symbol of an uninterpreted sort.

     @param t The sort.

     @return The symbol.

     @raise Not_found if no symbol is defined.
  *)

    val is_array : t -> bool
    (**
     [is_array t]
     determine if a sort is an array sort.

     @param t The sort.

     @return [true] if [t] is an array sort.
  *)

    val is_bool : t -> bool
    (**
     [is_bool t]
     determine if a sort is a Boolean sort.

     @param t The sort.

     @return [true] if [t] is a Boolean sort.
  *)

    val is_bv : t -> bool
    (**
     [is_bv t]
     determine if a sort is a bit-vector sort.

     @param t The sort.

     @return [true] if [t] is a bit-vector sort.
  *)

    val is_fp : t -> bool
    (**
     [is_fp t]
     determine if a sort is a floating-point sort.

     @param t The sort.

     @return [true] if [t] is a floating-point sort.
  *)

    val is_fun : t -> bool
    (**
     [is_fun t]
     determine if a sort is a function sort.

     @param t The sort.

     @return [true] if [t] is a function sort.
  *)

    val is_rm : t -> bool
    (**
     [is_rm t]
     determine if a sort is a Roundingmode sort.

     @param t The sort.

     @return [true] if [t] is a Roundingmode sort.
  *)

    val is_uninterpreted : t -> bool
    (**
     [is_uninterpreted t]
     determine if a sort is an uninterpreted sort.

     @param t The sort.

     @return [true] if [t] is an uninterpreted sort.
  *)
  end

  module RoundingMode : sig
    (**
     Rounding mode for floating-point operations.

     For some floating-point operations, infinitely precise results may not be
     representable in a given format. Hence, they are rounded modulo one of five
     rounding modes to a representable floating-point number.

     The following rounding modes follow the SMT-LIB theory for floating-point
     arithmetic, which in turn is based on IEEE Standard 754.
     The rounding modes are specified in Sections 4.3.1 and 4.3.2 of the IEEE
     Standard 754.
  *)
    type t =
      | Rne
          (** Round to the nearest even number.
        If the two nearest floating-point numbers bracketing an unrepresentable
        infinitely precise result are equally near, the one with an even least
        significant digit will be delivered.

        SMT-LIB: [RNE] roundNearestTiesToEven
    *)
      | Rna
          (** Round to the nearest number away from zero.
        If the two nearest floating-point numbers bracketing an unrepresentable
        infinitely precise result are equally near, the one with larger
        magnitude will be selected.

        SMT-LIB: [RNA] roundNearestTiesToAway
    *)
      | Rtn
          (** Round towards negative infinity (-oo).
        The result shall be the format’s floating-point number (possibly -oo)
        closest to and no less than the infinitely precise result.

        SMT-LIB: [RTN] roundTowardNegative
    *)
      | Rtp
          (** Round towards positive infinity (+oo).
        The result shall be the format’s floating-point number (possibly +oo)
        closest to and no less than the infinitely precise result.

        SMT-LIB: [RTP] roundTowardPositive
    *)
      | Rtz
          (** Round towards zero.
        The result shall be the format’s floating-point number closest to and no
        greater in magnitude than the infinitely precise result.

        SMT-LIB: [RTZ] roundTowardZero
    *)

    val to_string : t -> string
    (**
     [to_string t]
     get string representation of this rounding mode.

     @return String representation of this rounding mode.
  *)
  end

  module Kind : sig
    (** The term kind. *)
    type t =
      | Constant  (** First order constant. *)
      | Const_array  (** Constant array. *)
      | Value  (** Value. *)
      | Variable  (** Bound variable. *)
      | And  (** Boolean and.

               SMT-LIB: [and] *)
      | Distinct  (** Disequality.

                    SMT-LIB: [distinct] *)
      | Equal  (** Equality.

                 SMT-LIB: [=] *)
      | Iff  (** Boolean if and only if.

               SMT-LIB: [=] *)
      | Implies  (** Boolean implies.

                   SMT-LIB: [=>] *)
      | Not  (** Boolean not.

               SMT-LIB: [not] *)
      | Or  (** Boolean or.

              SMT-LIB: [or] *)
      | Xor  (** Boolean xor.

               SMT-LIB: [xor] *)
      | Ite  (** If-then-else.

               SMT-LIB: [ite] *)
      | Exists  (** Existential quantification.

          SMT-LIB: [exists] *)
      | Forall
          (** Universal quantification.

                  SMT-LIB: [forall] *)
      | Apply  (** Function application. *)
      | Lambda  (** Lambda. *)
      | Select  (** Array select.

                        SMT-LIB: [select] *)
      | Store  (** Array store.

                       SMT-LIB: [store] *)
      | Bv_add  (** Bit-vector addition.

                  SMT-LIB: [bvadd] *)
      | Bv_and  (** Bit-vector and.

                  SMT-LIB: [bvand] *)
      | Bv_ashr
          (** Bit-vector arithmetic right shift.

        SMT-LIB: [bvashr] *)
      | Bv_comp
          (** Bit-vector comparison.

                   SMT-LIB: [bvcomp] *)
      | Bv_concat
          (** Bit-vector concat.

                     SMT-LIB: [concat] *)
      | Bv_dec
          (** Bit-vector decrement.

                  Decrement by one. *)
      | Bv_inc
          (** Bit-vector increment.

                  Increment by one. *)
      | Bv_mul
          (** Bit-vector multiplication.

                  SMT-LIB: [bvmul] *)
      | Bv_nand  (** Bit-vector nand.

                   SMT-LIB: [bvnand] *)
      | Bv_neg
          (** Bit-vector negation (two's complement).

        SMT-LIB: [bvneg] *)
      | Bv_nego
          (** Bit-vector negation overflow test.

            Predicate indicating if bit-vector negation produces an overflow.

            SMT-LIB: [bvnego] *)
      | Bv_nor  (** Bit-vector nor.

                  SMT-LIB: [bvnor] *)
      | Bv_not
          (** Bit-vector not (one's complement).

          SMT-LIB: [bvnot] *)
      | Bv_or  (** Bit-vector or.

                 SMT-LIB: [bvor] *)
      | Bv_redand
          (** Bit-vector and reduction.

        Bit-wise {b and} reduction, all bits are {b and}'ed together into a single
        bit.
        This corresponds to bit-wise {b and} reduction as known from Verilog. *)
      | Bv_redor
          (** Bit-vector reduce or.

        Bit-wise {b or} reduction, all bits are {b or}'ed together into a single
        bit.
        This corresponds to bit-wise {b or} reduction as known from Verilog. *)
      | Bv_redxor
          (** Bit-vector reduce xor.

        Bit-wise {b xor} reduction, all bits are {b xor}'ed together into a
        single bit.
        This corresponds to bit-wise {b xor} reduction as known from Verilog. *)
      | Bv_rol
          (** Bit-vector rotate left (not indexed).

        This is a non-indexed variant of SMT-LIB [rotate_left]. *)
      | Bv_ror
          (** Bit-vector rotate right.

        This is a non-indexed variant of SMT-LIB [rotate_right]. *)
      | Bv_saddo
          (** Bit-vector signed addition overflow test.

        Single bit to indicate if signed addition produces an overflow. *)
      | Bv_sdivo
          (** Bit-vector signed division overflow test.

        Single bit to indicate if signed division produces an overflow. *)
      | Bv_sdiv
          (** Bit-vector signed division.

           SMT-LIB: [bvsdiv] *)
      | Bv_sge
          (** Bit-vector signed greater than or equal.

        SMT-LIB: [bvsge] *)
      | Bv_sgt
          (** Bit-vector signed greater than.

          SMT-LIB: [bvsgt] *)
      | Bv_shl
          (** Bit-vector logical left shift.

          SMT-LIB: [bvshl] *)
      | Bv_shr
          (** Bit-vector logical right shift.

          SMT-LIB: [bvshr] *)
      | Bv_sle
          (** Bit-vector signed less than or equal.

        SMT-LIB: [bvsle] *)
      | Bv_slt  (** Bit-vector signed less than.

          SMT-LIB: [bvslt] *)
      | Bv_smod  (** Bit-vector signed modulo.

           SMT-LIB: [bvsmod] *)
      | Bv_smulo
          (** Bit-vector signed multiplication overflow test.

        SMT-LIB: [bvsmod] *)
      | Bv_srem
          (** Bit-vector signed remainder.

           SMT-LIB: [bvsrem] *)
      | Bv_ssubo
          (** Bit-vector signed subtraction overflow test.

        Single bit to indicate if signed subtraction produces an overflow. *)
      | Bv_sub
          (** Bit-vector subtraction.

                  SMT-LIB: [bvsub] *)
      | Bv_uaddo
          (** Bit-vector unsigned addition overflow test.

        Single bit to indicate if unsigned addition produces an overflow. *)
      | Bv_udiv
          (** Bit-vector unsigned division.

           SMT-LIB: [bvudiv] *)
      | Bv_uge
          (** Bit-vector unsigned greater than or equal.

        SMT-LIB: [bvuge] *)
      | Bv_ugt
          (** Bit-vector unsigned greater than.

          SMT-LIB: [bvugt] *)
      | Bv_ule
          (** Bit-vector unsigned less than or equal.

        SMT-LIB: [bvule] *)
      | Bv_ult
          (** Bit-vector unsigned less than.

          SMT-LIB: [bvult] *)
      | Bv_umulo
          (** Bit-vector unsigned multiplication overflow test.

        Single bit to indicate if unsigned multiplication produces
        an overflow. *)
      | Bv_urem
          (** Bit-vector unsigned remainder.

           SMT-LIB: [bvurem] *)
      | Bv_usubo
          (** Bit-vector unsigned subtraction overflow test.

        Single bit to indicate if unsigned subtraction produces an overflow. *)
      | Bv_xnor  (** Bit-vector xnor.

                   SMT-LIB: [bvxnor] *)
      | Bv_xor  (** Bit-vector xor.

                  SMT-LIB: [bvxor] *)
      | Bv_extract
          (** Bit-vector extract.

              SMT-LIB: [extract] (indexed) *)
      | Bv_repeat
          (** Bit-vector repeat.

             SMT-LIB: [repeat] (indexed) *)
      | Bv_roli
          (** Bit-vector rotate left by integer.

        SMT-LIB: [rotate_left] (indexed) *)
      | Bv_rori
          (** Bit-vector rotate right by integer.

        SMT-LIB: [rotate_right] (indexed) *)
      | Bv_sign_extend
          (** Bit-vector sign extend.

        SMT-LIB: [sign_extend] (indexed) *)
      | Bv_zero_extend
          (** Bit-vector zero extend.

        SMT-LIB: [zero_extend] (indexed) *)
      | Fp_abs
          (** Floating-point absolute value.

          SMT-LIB: [fp.abs] *)
      | Fp_add
          (** Floating-point addition.

                  SMT-LIB: [fp.add] *)
      | Fp_div
          (** Floating-point division.

                  SMT-LIB: [fp.div] *)
      | Fp_equal
          (** Floating-point equality.

                    SMT-LIB: [fp.eq] *)
      | Fp_fma
          (** Floating-point fused multiplcation and addition.

        SMT-LIB: [fp.fma] *)
      | Fp_fp
          (** Floating-point IEEE 754 value.

                 SMT-LIB: [fp] *)
      | Fp_geq
          (** Floating-point greater than or equal.

        SMT-LIB: [fp.geq] *)
      | Fp_gt
          (** Floating-point greater than.

                 SMT-LIB: [fp.gt] *)
      | Fp_is_inf
          (** Floating-point is infinity tester.

        SMT-LIB: [fp.isInfinite] *)
      | Fp_is_nan
          (** Floating-point is Nan tester.

             SMT-LIB: [fp.isNaN] *)
      | Fp_is_neg
          (** Floating-point is negative tester.

        SMT-LIB: [fp.isNegative] *)
      | Fp_is_normal
          (** Floating-point is normal tester.

        SMT-LIB: [fp.isNormal] *)
      | Fp_is_pos
          (** Floating-point is positive tester.

        SMT-LIB: [fp.isPositive] *)
      | Fp_is_subnormal
          (** Floating-point is subnormal tester.

        SMT-LIB: [fp.isSubnormal] *)
      | Fp_is_zero
          (** Floating-point is zero tester.

        SMT-LIB: [fp.isZero] *)
      | Fp_leq
          (** Floating-point less than or equal.

          SMT-LIB: [fp.leq] *)
      | Fp_lt
          (** Floating-point less than.

                 SMT-LIB: [fp.lt] *)
      | Fp_max  (** Floating-point max.

                  SMT-LIB: [fp.max] *)
      | Fp_min  (** Floating-point min.

                  SMT-LIB: [fp.min] *)
      | Fp_mul
          (** Floating-point multiplcation.

          SMT-LIB: [fp.mul] *)
      | Fp_neg
          (** Floating-point negation.

                  SMT-LIB: [fp.neg] *)
      | Fp_rem
          (** Floating-point remainder.

                  SMT-LIB: [fp.rem] *)
      | Fp_rti
          (** Floating-point round to integral.

        SMT-LIB: [fp.roundToIntegral] *)
      | Fp_sqrt
          (** Floating-point round to square root.

        SMT-LIB: [fp.sqrt] *)
      | Fp_sub
          (** Floating-point round to subtraction.

        SMT-LIB: [fp.sqrt] *)
      | Fp_to_fp_from_bv
          (** Floating-point to_fp from IEEE 754 bit-vector.

        SMT-LIB: [to_fp] (indexed) *)
      | Fp_to_fp_from_fp
          (** Floating-point to_fp from floating-point.

        SMT-LIB: [to_fp] (indexed) *)
      | Fp_to_fp_from_sbv
          (** Floating-point to_fp from signed bit-vector value.

        SMT-LIB: [to_fp] (indexed) *)
      | Fp_to_fp_from_ubv
          (** Floating-point to_fp from unsigned bit-vector value.

        SMT-LIB: [to_fp_unsigned] (indexed) *)
      | Fp_to_sbv
          (** Floating-point to_sbv.

        SMT-LIB: [fp.to_sbv] (indexed) *)
      | Fp_to_ubv
          (** Floating-point to_ubv.

        SMT-LIB: [fp.to_ubv] (indexed) *)

    val to_string : t -> string
    (**
     [to_string t]
     get string representation of this kind.

     @return String representation of this kind.
  *)
  end

  module Term : sig
    (** {1:term Term} *)

    type t
    (** A Bitwuzla term. *)

    (** {2:sort_util Util} *)

    val hash : t -> int
    (**
     [hash t]
     compute the hash value for a term.

     @param t The term.

     @return The hash value of the term.
  *)

    val equal : t -> t -> bool
    (**
     [equal a b]
     Syntactical equality operator.

     @param a The first term.
     @param b The second term.
     @return True if the given terms are equal.
  *)

    val compare : t -> t -> int
    (**
     [compare a b]
     Syntactical comparison operator.

     @param a The first term.
     @param b The second term.
     @return Zero if the given term are equal,
             a positive number if [a] > [b],
             a negative number otherwise.
  *)

    val pp : Format.formatter -> t -> unit
    (**
     [pp formatter t]
     print term.

     (alias for {!val:pp_smt2}[ 2])

     @param formatter The outpout formatter.
     @param t The term.
  *)

    val pp_smt2 : bv_format:int -> Format.formatter -> t -> unit
    (**
     [pp_smt2 base formatter t]
     print term in SMTlib format.

     @param bv_format The bit-vector number format:
                      [2] for binary, [10] for decimal and [16] for hexadecimal.
     @param formatter The output formatter.
     @param t The term.
  *)

    val to_string : ?bv_format:int -> t -> string
    (**
     [to_string t ~bv_format]
     get string representation of this term.

     @param t The term.
     @param bv_format The bit-vector number format:
                      [2] for binary \[{b default}\],
                      [10] for decimal and [16] for hexadecimal.

     @return String representation of this term.
  *)

    (** {2:term_query Query} *)

    val id : t -> int64
    (**
     [id t]
     get the id of this term.

     @param t The term.
     @return The id value of the term.
  *)

    val kind : t -> Kind.t
    (**
     [kind t]
     get the kind of a term.

     @param t The term.

     @return The kind of the given term.
  *)

    val sort : t -> Sort.t
    (**
     [sort t]
     get the sort of a term.

     @param t The term.

     @return The sort of the term.
  *)

    val num_children : t -> int
    (**
     [num_children t]
     get the number of child terms of a term.

     @param t The term.

     @return The  number children of [t].
  *)

    val children : t -> t array
    (**
     [children t]
     get the child terms of a term.

     @param t The term.

     @return The children of [t] as an array of terms.
  *)

    val get : t -> int -> t
    (**
     [get t i]
     return child at position [i].

     Only valid to call if [num_children t > 0].

     @param i The position of the child.
     @return The child node at position [i].
  *)

    val num_indices : t -> int
    (**
     [num_indices t]
     get the number of indices of an indexed term.

     Requires that given term is an indexed term.

     @param t The term.

     @return The number of indices of [t].
  *)

    val indices : t -> int array
    (**
     [indices t]
     get the indices of an indexed term.

     Requires that given term is an indexed term.

     @param t The term.

     @return The children of [t] as an array of terms.
  *)

    val symbol : t -> string
    (**
     [symbol t]
     get the symbol of a term.

     @param t The term.

     @return The symbol of [t].

     @raise Not_found if no symbol is defined.
  *)

    val is_const : t -> bool
    (**
     [is_const t]
     determine if a term is a constant.

     @param t The term.

     @return [true] if [t] is a constant.
  *)

    val is_variable : t -> bool
    (**
     [is_variable t]
     determine if a term is a variable.

     @param t The term.

     @return [true] if [t] is a variable.
  *)

    val is_value : t -> bool
    (**
     [is_value t]
     determine if a term is a value.

     @param t The term.

     @return [true] if [t] is a value.
  *)

    val is_bv_value_zero : t -> bool
    (**
     [is_bv_value_zero t]
     determine if a term is a bit-vector value representing zero.

     @param t The term.

     @return [true] if [t] is a bit-vector zero value.
  *)

    val is_bv_value_one : t -> bool
    (**
     [is_bv_value_one t]
     determine if a term is a bit-vector value representing one.

     @param t The term.

     @return [true] if [t] is a bit-vector one value.
  *)

    val is_bv_value_ones : t -> bool
    (**
     [is_bv_value_ones t]
     determine if a term is a bit-vector value with all bits set to one.

     @param t The term.

     @return [true] if [t] is a bit-vector value with all bits set to one.
  *)

    val is_bv_value_min_signed : t -> bool
    (**
     [is_bv_value_min_signed t]
     determine if a term is a bit-vector minimum signed value.

     @param t The term.

     @return [true] if [t] is a bit-vector value with the most significant bit
         set to 1 and all other bits set to 0.
  *)

    val is_bv_value_max_signed : t -> bool
    (**
     [is_bv_value_max_signed t]
     determine if a term is a bit-vector maximum signed value.

     @param t The term.

     @return [true] if [t] is a bit-vector value with the most significant bit
         set to 0 and all other bits set to 1.
  *)

    val is_fp_value_pos_zero : t -> bool
    (**
     [is_fp_value_pos_zero t]
     determine if a term is a floating-point positive zero (+zero) value.

     @param t The term.

     @return [true] if [t] is a floating-point +zero value.
  *)

    val is_fp_value_neg_zero : t -> bool
    (**
     [is_fp_value_neg_zero t]
     determine if a term is a floating-point value negative zero (-zero).

     @param t The term.

     @return [true] if [t] is a floating-point value negative zero.
  *)

    val is_fp_value_pos_inf : t -> bool
    (**
     [is_fp_value_pos_inf t]
     determine if a term is a floating-point positive infinity (+oo) value.

     @param t The term.

     @return [true] if [t] is a floating-point +oo value.
  *)

    val is_fp_value_neg_inf : t -> bool
    (**
     [is_fp_value_neg_inf t]
     determine if a term is a floating-point negative infinity (-oo) value.

     @param t The term.

     @return [true] if [t] is a floating-point -oo value.
  *)

    val is_fp_value_nan : t -> bool
    (**
     [is_fp_value_nan t]
     determine if a term is a floating-point NaN value.

     @param t The term.

     @return [true] if [t] is a floating-point NaN value.
  *)

    val is_rm_value_rna : t -> bool
    (**
     [is_rm_value_rna t]
     determine if a term is a rounding mode RNA value.

     @param t The term.

     @return [true] if [t] is a rounding mode RNA value.
  *)

    val is_rm_value_rne : t -> bool
    (**
     [is_rm_value_rna t]
     determine if a term is a rounding mode RNE value.

     @param t The term.

     @return [true] if [t] is a rounding mode RNE value.
  *)

    val is_rm_value_rtn : t -> bool
    (**
     [is_rm_value_rna t]
     determine if a term is a rounding mode RTN value.

     @param t The term.

     @return [true] if [t] is a rounding mode RTN value.
  *)

    val is_rm_value_rtp : t -> bool
    (**
     [is_rm_value_rna t]
     determine if a term is a rounding mode RTP value.

     @param t The term.

     @return [true] if [t] is a rounding mode RTP value.
  *)

    val is_rm_value_rtz : t -> bool
    (**
     [is_rm_value_rna t]
     determine if a term is a rounding mode RTZ value.

     @param t The term.

     @return [true] if [t] is a rounding mode RTZ value.
  *)

    type _ cast =
      | Bool : bool cast  (** for Boolean values *)
      | RoundingMode : RoundingMode.t cast  (** for rounding mode values *)
      | String : { base : int } -> string cast
          (** for any value
        (Boolean, RoundingMode, bit-vector and floating-point) *)
      | IEEE_754 : (string * string * string) cast
          (** for floating-point values as strings
        for sign bit, exponent and significand *)
      | Z : Z.t cast  (** for bit-vector *)

    val value : 'a cast -> t -> 'a
    (**
     [value kind t]
     get value from value term.

     @param kind The type of the value representation.
     @return The value of [t] in a given representation.
  *)
  end

  module Result : sig
    (** A satisfiability result. *)
    type t = Sat  (** sat *) | Unsat  (** unsat *) | Unknown  (** unknown *)

    val to_string : t -> string
    (**
       [to_string t]
       get string representation of this result.

       @return String representation of this result.
  *)
  end

  module Solver : sig
    (** {1 Solver} *)

    type t
    (** The Bitwuzla solver. *)

    val configure_terminator : t -> (unit -> bool) option -> unit
    (**
     [configure_terminator t f]
     configure a termination callback function.

     If terminator has been connected, Bitwuzla calls this function periodically
     to determine if the connected instance should be terminated.

     @param t The Bitwuzla instance.
     @param f The callback function, returns [true] if [t] should be terminated.
  *)

    val create : Options.t -> t
    (**
     [create options]
     create a new Bitwuzla instance.

     The returned instance can be deleted earlier via {!val:unsafe_delete}.

     @param options The associated options instance.
                  Options must be configured at this point.

     @return The created Bitwuzla instance.
  *)

    (** {2 Formula} *)

    val push : t -> int -> unit
    (**
     [push t nlevels]
     push context levels.

     @param t The Bitwuzla instance.
     @param nlevels The number of context levels to push.
  *)

    val pop : t -> int -> unit
    (**
     [pop t nlevels]
     pop context levels.

     @param t The Bitwuzla instance.
     @param nlevels The number of context levels to pop.
  *)

    val assert_formula : t -> Term.t -> unit
    (**
     [mk_assert t term]
     assert formula.

     @param t The Bitwuzla instance.
     @param term The formula to assert.
  *)

    val get_assertions : t -> Term.t array
    (**
     [get_assertions t]
     get the set of currently asserted formulas.

     @return The assertion formulas.
  *)

    val pp_formula : Format.formatter -> t -> unit
    (**
     [pp_formula formatter t]
     print the current input formula.

     @param formatter The output formatter.
     @param t The Bitwuzla instance.
  *)

    (** {2 Check} *)

    val simplify : t -> unit
    (**
     [simplify t]
     simplify the current input formula.

     @param t The Bitwuzla instance.
  *)

    val check_sat : ?assumptions:Term.t array -> t -> Result.t
    (**
     [check_sat ~assumptions t]
     check satisfiability of current input formula.

     An input formula consists of assertions added via {!val:assert_formula}.
     The search for a solution can by guided by making assumptions via
     [assumptions].

     Assertions and assumptions are combined via Boolean [and].

     @param t The Bitwuzla instance.

     @return {!constructor:Sat} if the input formula is satisfiable and
         {!constructor:Unsat} if it is unsatisfiable, and {!constructor:Unknown}
         when neither satisfiability nor unsatisfiability was determined.
         This can happen when [t] was terminated via a termination callback.
  *)

    (** {2 Sat} *)

    val get_value : t -> Term.t -> Term.t
    (**
     [get_value t term]
     get a term representing the model value of a given term.

     Requires that the last {!val:check_sat} query returned [Sat].

     @param t The Bitwuzla instance.
     @param term The term to query a model value for.

     @return A term representing the model value of term [term].
  *)

    (** {2 Unsat} *)

    val is_unsat_assumption : t -> Term.t -> bool
    (**
     [is_unsat_assumption t term]
     determine if an assumption is an unsat assumption.

     Unsat assumptions are assumptions that force an input formula to become
     unsatisfiable. Unsat assumptions handling in Bitwuzla is analogous to
     failed assumptions in MiniSAT.

     Requires that unsat assumption generation has been enabled via
     {!val:Options.set}.

     Requires that the last {!val:check_sat} query returned [Unsat].

     @param t The Bitwuzla instance.
     @param term The assumption to check for.

     @return [true] if given assumption is an unsat assumption.
  *)

    val get_unsat_assumptions : t -> Term.t array
    (**
     [get_unsat_assumptions t]
     get the set of unsat assumptions.

     Unsat assumptions are assumptions that force an input formula to become
     unsatisfiable. Unsat assumptions handling in Bitwuzla is analogous to
     failed assumptions in MiniSAT.

     Requires that unsat assumption generation has been enabled via
     {!val:Options.set}.

     Requires that the last {!val:check_sat} query returned [Unsat].

     @param t The Bitwuzla instance.

     @return An array with unsat assumptions.
  *)

    val get_unsat_core : t -> Term.t array
    (**
     [get_unsat_core t]
     get the set unsat core (unsat assertions).

     The unsat core consists of the set of assertions that force
     an input formula to become unsatisfiable.

     Requires that unsat core generation has been enabled via {!val:Options.set}.

     Requires that the last {!val:check_sat} query returned [Unsat].

     @param t The Bitwuzla instance.

     @return An array with unsat assertions.
  *)

    (** {2 Expert} *)
    val unsafe_delete : t -> unit
    (**
     [delete t]
     delete a Bitwuzla instance.

     UNSAFE: call this ONLY to release the resources earlier
     if the instance is about to be garbage collected.

     @param t The Bitwuzla instance to delete.
  *)

    val pp_statistics : Format.formatter -> t -> unit
  end

  (** {2:sort_constructor Sort constructor} *)

  val mk_array_sort : Sort.t -> Sort.t -> Sort.t
  (**
   [mk_array_sort index element]
   create an array sort.

   @param index The index sort of the array sort.
   @param element The element sort of the array sort.

   @return An array sort which maps sort [index] to sort [element].
*)

  val mk_bool_sort : unit -> Sort.t
  (**
   [mk_bool_sort ()]
   create a Boolean sort.

   A Boolean sort is a bit-vector sort of size 1.

   @return A Boolean sort.
*)

  val mk_bv_sort : int -> Sort.t
  (**
   [mk_bv_sort size]
   create a bit-vector sort of given size.

   @param size The size of the bit-vector sort.

   @return A bit-vector sort of given size.
*)

  val mk_fp_sort : int -> int -> Sort.t
  (**
   [mk_fp_sort exp_size sig_size]
   create a floating-point sort of given exponent and significand size.

   @param exp_size The size of the exponent.
   @param sig_size The size of the significand (including sign bit).

   @return A floating-point sort of given format.
*)

  val mk_fun_sort : Sort.t array -> Sort.t -> Sort.t
  (**
   [mk_fun_sort domain codomain]
   create a function sort.

   @param domain The domain sorts (the sorts of the arguments).
   @param codomain The codomain sort (the sort of the return value).

   @return A function sort of given domain and codomain sorts.
*)

  val mk_rm_sort : unit -> Sort.t
  (**
   [mk_rm_sort ()]
   create a Roundingmode sort.

   @return A Roundingmode sort.
*)

  val mk_uninterpreted_sort : ?symbol:string -> unit -> Sort.t
  (**
   [mk_uninterpreted_sort name]
   create an uninterpreted sort.

   Only 0-arity uninterpreted sorts are supported.

   @param symbol The symbol of the sort.
   @return An uninterpreted sort.
*)

  (** {2:term_constructor Term constructor} *)

  (** {3 Value} *)

  val mk_true : unit -> Term.t
  (**
   [mk_true ()]
   create a true value.

   This creates a bit-vector value 1 of size 1.

   @return A term representing the bit-vector value 1 of size 1.
*)

  val mk_false : unit -> Term.t
  (**
   [mk_false ()]
   create a false value.

   This creates a bit-vector value 0 of size 1.

   @return A term representing the bit-vector value 0 of size 1.
*)

  val mk_bv_zero : Sort.t -> Term.t
  (**
   [mk_bv_zero sort]
   create a bit-vector value zero.

   @param sort The sort of the value.

   @return A term representing the bit-vector value 0 of given sort.
*)

  val mk_bv_one : Sort.t -> Term.t
  (**
   [mk_bv_one sort]
   create a bit-vector value one.

   @param sort The sort of the value.

   @return A term representing the bit-vector value 1 of given sort.
*)

  val mk_bv_ones : Sort.t -> Term.t
  (**
   [mk_bv_ones sort]
   create a bit-vector value where all bits are set to 1.

   @param sort The sort of the value.

   @return A term representing the bit-vector value of given sort
         where all bits are set to 1.
*)

  val mk_bv_min_signed : Sort.t -> Term.t
  (**
   [mk_bv_min_signed sort]
   create a bit-vector minimum signed value.

   @param sort The sort of the value.

   @return A term representing the bit-vector value of given sort where the MSB
         is set to 1 and all remaining bits are set to 0.
*)

  val mk_bv_max_signed : Sort.t -> Term.t
  (**
   [mk_bv_max_signed sort]
   create a bit-vector maximum signed value.

   @param sort The sort of the value.

   @return A term representing the bit-vector value of given sort where the MSB
         is set to 0 and all remaining bits are set to 1.
*)

  val mk_bv_value : Sort.t -> string -> int -> Term.t
  (**
   [mk_bv_value sort value base]
   create a bit-vector value from its string representation.

   Parameter [base] determines the base of the string representation.

   Given value must fit into a bit-vector of given size (sort).

   @param sort The sort of the value.
   @param value A string representing the value.
   @param base The base in which the string is given.

   @return A term representing the bit-vector value of given sort.
*)

  val mk_bv_value_int : Sort.t -> int -> Term.t
  (**
   [mk_bv_value_int sort value]
   create a bit-vector value from its unsigned integer representation.

   If given value does not fit into a bit-vector of given size (sort),
       the value is truncated to fit.

   @param sort The sort of the value.
   @param value The unsigned integer representation of the bit-vector value.

   @return A term representing the bit-vector value of given sort.
*)

  val mk_bv_value_int64 : Sort.t -> int64 -> Term.t
  (**
   [mk_bv_value_int64 sort value]
   create a bit-vector value from its unsigned integer representation.

   If given value does not fit into a bit-vector of given size (sort),
       the value is truncated to fit.

   @param sort The sort of the value.
   @param value The unsigned integer representation of the bit-vector value.

   @return A term representing the bit-vector value of given sort.
*)

  val mk_fp_pos_zero : Sort.t -> Term.t
  (**
   [mk_fp_pos_zero sort]
   create a floating-point positive zero value (SMT-LIB: [+zero]).

   @param sort The sort of the value.

   @return A term representing the floating-point positive zero value of given
         floating-point sort.
*)

  val mk_fp_neg_zero : Sort.t -> Term.t
  (**
   [mk_fp_neg_zero sort]
   create a floating-point negative zero value (SMT-LIB: [-zero]).

   @param sort The sort of the value.

   @return A term representing the floating-point negative zero value of given
         floating-point sort.
*)

  val mk_fp_pos_inf : Sort.t -> Term.t
  (**
   [mk_fp_pos_inf sort]
   create a floating-point positive infinity value (SMT-LIB: [+oo]).

   @param sort The sort of the value.

   @return A term representing the floating-point positive infinity value of
         given floating-point sort.
*)

  val mk_fp_neg_inf : Sort.t -> Term.t
  (**
   [mk_fp_neg_inf sort]
   create a floating-point negative infinity value (SMT-LIB: [-oo]).

   @param sort The sort of the value.

   @return A term representing the floating-point negative infinity value of
         given floating-point sort.
*)

  val mk_fp_nan : Sort.t -> Term.t
  (**
   [mk_fp_nan sort]
   create a floating-point NaN value.

   @param sort The sort of the value.

   @return A term representing the floating-point NaN value of given
         floating-point sort.
*)

  val mk_fp_value : Term.t -> Term.t -> Term.t -> Term.t
  (**
   [mk_fp_value bv_sign bv_exponent bv_significand]
   create a floating-point value from its IEEE 754 standard representation
   given as three bitvectors representing the sign bit, the exponent and the
   significand.

   @param bv_sign The sign bit.
   @param bv_exponent The exponent bit-vector.
   @param bv_significand The significand bit-vector.

   @return A term representing the floating-point value.
*)

  val mk_fp_value_from_real : Sort.t -> Term.t -> string -> Term.t
  (**
   [mk_fp_value_from_real t sort rm real]
   create a floating-point value from its real representation, given as a
   decimal string, with respect to given rounding mode.

   @param sort The sort of the value.
   @param rm The rounding mode.
   @param real The decimal string representing a real value.

   @return A term representing the floating-point value of given sort.
*)

  val mk_fp_value_from_rational : Sort.t -> Term.t -> string -> string -> Term.t
  (**
   [mk_fp_value_from_rational sort rm num den]
   create a floating-point value from its rational representation, given as a
   two decimal strings representing the numerator and denominator, with respect
   to given rounding mode.

   @param sort The sort of the value.
   @param rm The rounding mode.
   @param num The decimal string representing the numerator.
   @param den The decimal string representing the denominator.

   @return A term representing the floating-point value of given sort.
*)

  val mk_rm_value : RoundingMode.t -> Term.t
  (**
   [mk_rm_value rm]
   create a rounding mode value.

   @param rm The rounding mode value.

   @return A term representing the rounding mode value.
*)

  (** {3 Expression} *)

  val mk_term1 : Kind.t -> Term.t -> Term.t
  (**
   [mk_term1 kind arg]
   create a term of given kind with one argument term.

   @param kind The operator kind.
   @param arg The argument to the operator.

   @return A term representing an operation of given kind.
*)

  val mk_term2 : Kind.t -> Term.t -> Term.t -> Term.t
  (**
   [mk_term2 kind arg0 arg1]
   create a term of given kind with two argument terms.

   @param kind The operator kind.
   @param arg0 The first argument to the operator.
   @param arg1 The second argument to the operator.

   @return A term representing an operation of given kind.
*)

  val mk_term3 : Kind.t -> Term.t -> Term.t -> Term.t -> Term.t
  (**
   [mk_term3 kind arg0 arg1 arg2]
   create a term of given kind with three argument terms.

   @param kind The operator kind.
   @param arg0 The first argument to the operator.
   @param arg1 The second argument to the operator.
   @param arg2 The third argument to the operator.

   @return A term representing an operation of given kind.
*)

  val mk_term1_indexed1 : Kind.t -> Term.t -> int -> Term.t
  (**
   [mk_term1_indexed1 kind arg idx]
   create an indexed term of given kind with one argument term and one index.

   @param kind The operator kind.
   @param arg The argument term.
   @param idx The index.

   @return A term representing an indexed operation of given kind.
*)

  val mk_term1_indexed2 : Kind.t -> Term.t -> int -> int -> Term.t
  (**
   [mk_term1_indexed2 kind arg idx0 idx1]
   create an indexed term of given kind with one argument term and two indices.

   @param kind The operator kind.
   @param arg The argument term.
   @param idx0 The first index.
   @param idx1 The second index.

   @return A term representing an indexed operation of given kind.
*)

  val mk_term2_indexed1 : Kind.t -> Term.t -> Term.t -> int -> Term.t
  (**
   [mk_term2_indexed1 t kind arg0 arg1 idx]
   create an indexed term of given kind with two argument terms and one index.

   @param kind The operator kind.
   @param arg0 The first argument term.
   @param arg1 The second argument term.
   @param idx The index.

   @return A term representing an indexed operation of given kind.
*)

  val mk_term2_indexed2 : Kind.t -> Term.t -> Term.t -> int -> int -> Term.t
  (**
   [mk_term2_indexed2 t kind arg0 arg1 idx0 idx1]
   create an indexed term of given kind with two argument terms and two indices.

   @param kind The operator kind.
   @param arg0 The first argument term.
   @param arg1 The second argument term.
   @param idx0 The first index.
   @param idx1 The second index.

   @return A term representing an indexed operation of given kind.
*)

  val mk_term : Kind.t -> ?indices:int array -> Term.t array -> Term.t
  (**
   [mk_term kind args ~indices]
   create an indexed term of given kind with the given argument terms and
   indices.

   @param kind The operator kind.
   @param args The argument terms.
   @param indices The indices.

   @return A term representing an indexed operation of given kind.
*)

  val mk_const : ?symbol:string -> Sort.t -> Term.t
  (**
   [mk_const sort ~symbol]
   create a (first-order) constant of given sort with given symbol.

   This creates a 0-arity function symbol.

   @param sort The sort of the constant.
   @param symbol The symbol of the constant.

   @return A term representing the constant.
*)

  val mk_const_array : Sort.t -> Term.t -> Term.t
  (**
   [mk_const_array sort value]
   create a one-dimensional constant array of given sort, initialized with
   given value.

   @param sort The sort of the array.
   @param value The value to initialize the elements of the array with.

   @return A term representing a constant array of given sort.
*)

  val mk_var : ?symbol:string -> Sort.t -> Term.t
  (**
   [mk_var sort ~symbol]
   create a variable of given sort with given symbol.

   This creates a variable to be bound by quantifiers or lambdas.

   @param sort The sort of the variable.
   @param symbol The symbol of the variable.

   @return A term representing the variable.
*)

  (** {2 Util} *)

  val substitute_term : Term.t -> (Term.t * Term.t) array -> Term.t
  (**
   [substitute t term map]
   substitute a set of keys with their corresponding values in the given term.

   @param term The term in which the keys are to be substituted.
   @param map The key/value associations.

   @return The resulting term from this substitution.
*)

  val substitute_terms : Term.t array -> (Term.t * Term.t) array -> unit
  (**
   [substitute_terms t terms map]
   substitute a set of keys with their corresponding values in the set of given
   terms.

   The terms in [terms] are replaced with the terms resulting from this
   substitutions.

   @param terms The terms in which the keys are to be substituted.
   @param map The key/value associations.
*)
end

module Make () : S = struct
  let t = Manager.create ()

  module Sort = Sort

  let mk_array_sort = mk_array_sort t
  let mk_bool_sort () = mk_bool_sort t
  let mk_bv_sort = mk_bv_sort t
  let mk_fp_sort = mk_fp_sort t
  let mk_fun_sort = mk_fun_sort t
  let mk_rm_sort () = mk_rm_sort t
  let mk_uninterpreted_sort = mk_uninterpreted_sort t

  module RoundingMode = RoundingMode
  module Kind = Kind
  module Term = Term

  let mk_true () = mk_true t
  let mk_false () = mk_false t
  let mk_bv_zero = mk_bv_zero t
  let mk_bv_one = mk_bv_one t
  let mk_bv_ones = mk_bv_ones t
  let mk_bv_min_signed = mk_bv_min_signed t
  let mk_bv_max_signed = mk_bv_max_signed t
  let mk_bv_value = mk_bv_value t
  let mk_bv_value_int = mk_bv_value_int t
  let mk_bv_value_int64 = mk_bv_value_int64 t
  let mk_fp_pos_zero = mk_fp_pos_zero t
  let mk_fp_neg_zero = mk_fp_neg_zero t
  let mk_fp_pos_inf = mk_fp_pos_inf t
  let mk_fp_neg_inf = mk_fp_neg_inf t
  let mk_fp_nan = mk_fp_nan t
  let mk_fp_value = mk_fp_value t
  let mk_fp_value_from_real = mk_fp_value_from_real t
  let mk_fp_value_from_rational = mk_fp_value_from_rational t
  let mk_rm_value m = mk_rm_value t (RoundingMode.to_cxx m)
  let mk_term1 k x = mk_term1 t (Kind.to_cxx k) x
  let mk_term2 k x1 x2 = mk_term2 t (Kind.to_cxx k) x1 x2
  let mk_term3 k x1 x2 x3 = mk_term3 t (Kind.to_cxx k) x1 x2 x3
  let mk_term1_indexed1 k x i = mk_term1_indexed1 t (Kind.to_cxx k) x i
  let mk_term1_indexed2 k x i j = mk_term1_indexed2 t (Kind.to_cxx k) x i j
  let mk_term2_indexed1 k x1 x2 i = mk_term2_indexed1 t (Kind.to_cxx k) x1 x2 i

  let mk_term2_indexed2 k x1 x2 i j =
    mk_term2_indexed2 t (Kind.to_cxx k) x1 x2 i j

  let mk_term k ?(indices = [||]) args = mk_term t (Kind.to_cxx k) args indices
  let mk_const = mk_const t
  let mk_const_array = mk_const_array t
  let mk_var = mk_var t
  let substitute_term = substitute_term t
  let substitute_terms = substitute_terms t

  module Result = Result

  module Solver = struct
    include Solver

    let create = create t
  end
end

include Make ()
OCaml

Innovation. Community. Security.