9// Arithmetic operations and sorts
11// MkIntSort creates the integer sort.
12func (c *Context) MkIntSort() *Sort {
13 return newSort(c, C.Z3_mk_int_sort(c.ptr))
16// MkRealSort creates the real number sort.
17func (c *Context) MkRealSort() *Sort {
18 return newSort(c, C.Z3_mk_real_sort(c.ptr))
21// MkInt creates an integer constant from an int.
22func (c *Context) MkInt(value int, sort *Sort) *Expr {
23 return newExpr(c, C.Z3_mk_int(c.ptr, C.int(value), sort.ptr))
26// MkInt64 creates an integer constant from an int64.
27func (c *Context) MkInt64(value int64, sort *Sort) *Expr {
28 return newExpr(c, C.Z3_mk_int64(c.ptr, C.int64_t(value), sort.ptr))
31// MkReal creates a real constant from numerator and denominator.
32func (c *Context) MkReal(num, den int) *Expr {
33 return newExpr(c, C.Z3_mk_real(c.ptr, C.int(num), C.int(den)))
36// MkIntConst creates an integer constant (variable) with the given name.
37func (c *Context) MkIntConst(name string) *Expr {
38 sym := c.MkStringSymbol(name)
39 return c.MkConst(sym, c.MkIntSort())
42// MkRealConst creates a real constant (variable) with the given name.
43func (c *Context) MkRealConst(name string) *Expr {
44 sym := c.MkStringSymbol(name)
45 return c.MkConst(sym, c.MkRealSort())
48// MkAdd creates an addition.
49func (c *Context) MkAdd(exprs ...*Expr) *Expr {
51 return c.MkInt(0, c.MkIntSort())
56 cExprs := make([]C.Z3_ast, len(exprs))
57 for i, e := range exprs {
60 return newExpr(c, C.Z3_mk_add(c.ptr, C.uint(len(exprs)), &cExprs[0]))
63// MkSub creates a subtraction.
64func (c *Context) MkSub(exprs ...*Expr) *Expr {
66 return c.MkInt(0, c.MkIntSort())
69 return newExpr(c, C.Z3_mk_unary_minus(c.ptr, exprs[0].ptr))
71 cExprs := make([]C.Z3_ast, len(exprs))
72 for i, e := range exprs {
75 return newExpr(c, C.Z3_mk_sub(c.ptr, C.uint(len(exprs)), &cExprs[0]))
78// MkMul creates a multiplication.
79func (c *Context) MkMul(exprs ...*Expr) *Expr {
81 return c.MkInt(1, c.MkIntSort())
86 cExprs := make([]C.Z3_ast, len(exprs))
87 for i, e := range exprs {
90 return newExpr(c, C.Z3_mk_mul(c.ptr, C.uint(len(exprs)), &cExprs[0]))
93// MkDiv creates a division.
94func (c *Context) MkDiv(lhs, rhs *Expr) *Expr {
95 return newExpr(c, C.Z3_mk_div(c.ptr, lhs.ptr, rhs.ptr))
98// MkMod creates a modulo operation.
99func (c *Context) MkMod(lhs, rhs *Expr) *Expr {
100 return newExpr(c, C.Z3_mk_mod(c.ptr, lhs.ptr, rhs.ptr))
103// MkRem creates a remainder operation.
104func (c *Context) MkRem(lhs, rhs *Expr) *Expr {
105 return newExpr(c, C.Z3_mk_rem(c.ptr, lhs.ptr, rhs.ptr))
108// MkLt creates a less-than constraint.
109func (c *Context) MkLt(lhs, rhs *Expr) *Expr {
110 return newExpr(c, C.Z3_mk_lt(c.ptr, lhs.ptr, rhs.ptr))
113// MkLe creates a less-than-or-equal constraint.
114func (c *Context) MkLe(lhs, rhs *Expr) *Expr {
115 return newExpr(c, C.Z3_mk_le(c.ptr, lhs.ptr, rhs.ptr))
118// MkGt creates a greater-than constraint.
119func (c *Context) MkGt(lhs, rhs *Expr) *Expr {
120 return newExpr(c, C.Z3_mk_gt(c.ptr, lhs.ptr, rhs.ptr))
123// MkGe creates a greater-than-or-equal constraint.
124func (c *Context) MkGe(lhs, rhs *Expr) *Expr {
125 return newExpr(c, C.Z3_mk_ge(c.ptr, lhs.ptr, rhs.ptr))