Z3
 
Loading...
Searching...
No Matches
fp.go
Go to the documentation of this file.
1package z3
2
3/*
4#include "z3.h"
5#include <stdlib.h>
6*/
7import "C"
8import (
9 "unsafe"
10)
11
12// Floating-point operations
13
14// MkFPSort creates a floating-point sort.
15func (c *Context) MkFPSort(ebits, sbits uint) *Sort {
16 return newSort(c, C.Z3_mk_fpa_sort(c.ptr, C.uint(ebits), C.uint(sbits)))
17}
18
19// MkFPSort16 creates a 16-bit floating-point sort.
20func (c *Context) MkFPSort16() *Sort {
21 return newSort(c, C.Z3_mk_fpa_sort_16(c.ptr))
22}
23
24// MkFPSort32 creates a 32-bit floating-point sort (single precision).
25func (c *Context) MkFPSort32() *Sort {
26 return newSort(c, C.Z3_mk_fpa_sort_32(c.ptr))
27}
28
29// MkFPSort64 creates a 64-bit floating-point sort (double precision).
30func (c *Context) MkFPSort64() *Sort {
31 return newSort(c, C.Z3_mk_fpa_sort_64(c.ptr))
32}
33
34// MkFPSort128 creates a 128-bit floating-point sort (quadruple precision).
35func (c *Context) MkFPSort128() *Sort {
36 return newSort(c, C.Z3_mk_fpa_sort_128(c.ptr))
37}
38
39// MkFPRoundingModeSort creates the rounding mode sort.
40func (c *Context) MkFPRoundingModeSort() *Sort {
41 return newSort(c, C.Z3_mk_fpa_rounding_mode_sort(c.ptr))
42}
43
44// MkFPNumeral creates a floating-point numeral from a string.
45func (c *Context) MkFPNumeral(value string, sort *Sort) *Expr {
46 cStr := C.CString(value)
47 defer C.free(unsafe.Pointer(cStr))
48 return newExpr(c, C.Z3_mk_numeral(c.ptr, cStr, sort.ptr))
49}
50
51// MkFPInf creates a floating-point infinity.
52func (c *Context) MkFPInf(sort *Sort, negative bool) *Expr {
53 return newExpr(c, C.Z3_mk_fpa_inf(c.ptr, sort.ptr, C.bool(negative)))
54}
55
56// MkFPNaN creates a floating-point NaN.
57func (c *Context) MkFPNaN(sort *Sort) *Expr {
58 return newExpr(c, C.Z3_mk_fpa_nan(c.ptr, sort.ptr))
59}
60
61// MkFPZero creates a floating-point zero.
62func (c *Context) MkFPZero(sort *Sort, negative bool) *Expr {
63 return newExpr(c, C.Z3_mk_fpa_zero(c.ptr, sort.ptr, C.bool(negative)))
64}
65
66// MkFPAdd creates a floating-point addition.
67func (c *Context) MkFPAdd(rm, lhs, rhs *Expr) *Expr {
68 return newExpr(c, C.Z3_mk_fpa_add(c.ptr, rm.ptr, lhs.ptr, rhs.ptr))
69}
70
71// MkFPSub creates a floating-point subtraction.
72func (c *Context) MkFPSub(rm, lhs, rhs *Expr) *Expr {
73 return newExpr(c, C.Z3_mk_fpa_sub(c.ptr, rm.ptr, lhs.ptr, rhs.ptr))
74}
75
76// MkFPMul creates a floating-point multiplication.
77func (c *Context) MkFPMul(rm, lhs, rhs *Expr) *Expr {
78 return newExpr(c, C.Z3_mk_fpa_mul(c.ptr, rm.ptr, lhs.ptr, rhs.ptr))
79}
80
81// MkFPDiv creates a floating-point division.
82func (c *Context) MkFPDiv(rm, lhs, rhs *Expr) *Expr {
83 return newExpr(c, C.Z3_mk_fpa_div(c.ptr, rm.ptr, lhs.ptr, rhs.ptr))
84}
85
86// MkFPNeg creates a floating-point negation.
87func (c *Context) MkFPNeg(expr *Expr) *Expr {
88 return newExpr(c, C.Z3_mk_fpa_neg(c.ptr, expr.ptr))
89}
90
91// MkFPAbs creates a floating-point absolute value.
92func (c *Context) MkFPAbs(expr *Expr) *Expr {
93 return newExpr(c, C.Z3_mk_fpa_abs(c.ptr, expr.ptr))
94}
95
96// MkFPSqrt creates a floating-point square root.
97func (c *Context) MkFPSqrt(rm, expr *Expr) *Expr {
98 return newExpr(c, C.Z3_mk_fpa_sqrt(c.ptr, rm.ptr, expr.ptr))
99}
100
101// MkFPLT creates a floating-point less-than.
102func (c *Context) MkFPLT(lhs, rhs *Expr) *Expr {
103 return newExpr(c, C.Z3_mk_fpa_lt(c.ptr, lhs.ptr, rhs.ptr))
104}
105
106// MkFPGT creates a floating-point greater-than.
107func (c *Context) MkFPGT(lhs, rhs *Expr) *Expr {
108 return newExpr(c, C.Z3_mk_fpa_gt(c.ptr, lhs.ptr, rhs.ptr))
109}
110
111// MkFPLE creates a floating-point less-than-or-equal.
112func (c *Context) MkFPLE(lhs, rhs *Expr) *Expr {
113 return newExpr(c, C.Z3_mk_fpa_leq(c.ptr, lhs.ptr, rhs.ptr))
114}
115
116// MkFPGE creates a floating-point greater-than-or-equal.
117func (c *Context) MkFPGE(lhs, rhs *Expr) *Expr {
118 return newExpr(c, C.Z3_mk_fpa_geq(c.ptr, lhs.ptr, rhs.ptr))
119}
120
121// MkFPEq creates a floating-point equality.
122func (c *Context) MkFPEq(lhs, rhs *Expr) *Expr {
123 return newExpr(c, C.Z3_mk_fpa_eq(c.ptr, lhs.ptr, rhs.ptr))
124}
125
126// MkFPIsNaN creates a predicate checking if a floating-point number is NaN.
127func (c *Context) MkFPIsNaN(expr *Expr) *Expr {
128 return newExpr(c, C.Z3_mk_fpa_is_nan(c.ptr, expr.ptr))
129}
130
131// MkFPIsInf creates a predicate checking if a floating-point number is infinite.
132func (c *Context) MkFPIsInf(expr *Expr) *Expr {
133 return newExpr(c, C.Z3_mk_fpa_is_infinite(c.ptr, expr.ptr))
134}
135
136// MkFPIsZero creates a predicate checking if a floating-point number is zero.
137func (c *Context) MkFPIsZero(expr *Expr) *Expr {
138 return newExpr(c, C.Z3_mk_fpa_is_zero(c.ptr, expr.ptr))
139}