Z3
 
Loading...
Searching...
No Matches
bitvec.go
Go to the documentation of this file.
1package z3
2
3/*
4#include "z3.h"
5#include <stdlib.h>
6*/
7import "C"
8
9// Bit-vector operations
10
11// MkBVConst creates a bit-vector constant with the given name and size.
12func (c *Context) MkBVConst(name string, size uint) *Expr {
13 sym := c.MkStringSymbol(name)
14 return c.MkConst(sym, c.MkBvSort(size))
15}
16
17// MkBV creates a bit-vector numeral from an integer.
18func (c *Context) MkBV(value int, size uint) *Expr {
19 return newExpr(c, C.Z3_mk_int(c.ptr, C.int(value), c.MkBvSort(size).ptr))
20}
21
22// MkBVFromInt64 creates a bit-vector from an int64.
23func (c *Context) MkBVFromInt64(value int64, size uint) *Expr {
24 return newExpr(c, C.Z3_mk_int64(c.ptr, C.int64_t(value), c.MkBvSort(size).ptr))
25}
26
27// MkBVAdd creates a bit-vector addition.
28func (c *Context) MkBVAdd(lhs, rhs *Expr) *Expr {
29 return newExpr(c, C.Z3_mk_bvadd(c.ptr, lhs.ptr, rhs.ptr))
30}
31
32// MkBVSub creates a bit-vector subtraction.
33func (c *Context) MkBVSub(lhs, rhs *Expr) *Expr {
34 return newExpr(c, C.Z3_mk_bvsub(c.ptr, lhs.ptr, rhs.ptr))
35}
36
37// MkBVMul creates a bit-vector multiplication.
38func (c *Context) MkBVMul(lhs, rhs *Expr) *Expr {
39 return newExpr(c, C.Z3_mk_bvmul(c.ptr, lhs.ptr, rhs.ptr))
40}
41
42// MkBVUDiv creates an unsigned bit-vector division.
43func (c *Context) MkBVUDiv(lhs, rhs *Expr) *Expr {
44 return newExpr(c, C.Z3_mk_bvudiv(c.ptr, lhs.ptr, rhs.ptr))
45}
46
47// MkBVSDiv creates a signed bit-vector division.
48func (c *Context) MkBVSDiv(lhs, rhs *Expr) *Expr {
49 return newExpr(c, C.Z3_mk_bvsdiv(c.ptr, lhs.ptr, rhs.ptr))
50}
51
52// MkBVURem creates an unsigned bit-vector remainder.
53func (c *Context) MkBVURem(lhs, rhs *Expr) *Expr {
54 return newExpr(c, C.Z3_mk_bvurem(c.ptr, lhs.ptr, rhs.ptr))
55}
56
57// MkBVSRem creates a signed bit-vector remainder.
58func (c *Context) MkBVSRem(lhs, rhs *Expr) *Expr {
59 return newExpr(c, C.Z3_mk_bvsrem(c.ptr, lhs.ptr, rhs.ptr))
60}
61
62// MkBVNeg creates a bit-vector negation.
63func (c *Context) MkBVNeg(expr *Expr) *Expr {
64 return newExpr(c, C.Z3_mk_bvneg(c.ptr, expr.ptr))
65}
66
67// MkBVAnd creates a bit-vector bitwise AND.
68func (c *Context) MkBVAnd(lhs, rhs *Expr) *Expr {
69 return newExpr(c, C.Z3_mk_bvand(c.ptr, lhs.ptr, rhs.ptr))
70}
71
72// MkBVOr creates a bit-vector bitwise OR.
73func (c *Context) MkBVOr(lhs, rhs *Expr) *Expr {
74 return newExpr(c, C.Z3_mk_bvor(c.ptr, lhs.ptr, rhs.ptr))
75}
76
77// MkBVXor creates a bit-vector bitwise XOR.
78func (c *Context) MkBVXor(lhs, rhs *Expr) *Expr {
79 return newExpr(c, C.Z3_mk_bvxor(c.ptr, lhs.ptr, rhs.ptr))
80}
81
82// MkBVNot creates a bit-vector bitwise NOT.
83func (c *Context) MkBVNot(expr *Expr) *Expr {
84 return newExpr(c, C.Z3_mk_bvnot(c.ptr, expr.ptr))
85}
86
87// MkBVShl creates a bit-vector shift left.
88func (c *Context) MkBVShl(lhs, rhs *Expr) *Expr {
89 return newExpr(c, C.Z3_mk_bvshl(c.ptr, lhs.ptr, rhs.ptr))
90}
91
92// MkBVLShr creates a bit-vector logical shift right.
93func (c *Context) MkBVLShr(lhs, rhs *Expr) *Expr {
94 return newExpr(c, C.Z3_mk_bvlshr(c.ptr, lhs.ptr, rhs.ptr))
95}
96
97// MkBVAShr creates a bit-vector arithmetic shift right.
98func (c *Context) MkBVAShr(lhs, rhs *Expr) *Expr {
99 return newExpr(c, C.Z3_mk_bvashr(c.ptr, lhs.ptr, rhs.ptr))
100}
101
102// MkBVULT creates an unsigned bit-vector less-than.
103func (c *Context) MkBVULT(lhs, rhs *Expr) *Expr {
104 return newExpr(c, C.Z3_mk_bvult(c.ptr, lhs.ptr, rhs.ptr))
105}
106
107// MkBVSLT creates a signed bit-vector less-than.
108func (c *Context) MkBVSLT(lhs, rhs *Expr) *Expr {
109 return newExpr(c, C.Z3_mk_bvslt(c.ptr, lhs.ptr, rhs.ptr))
110}
111
112// MkBVULE creates an unsigned bit-vector less-than-or-equal.
113func (c *Context) MkBVULE(lhs, rhs *Expr) *Expr {
114 return newExpr(c, C.Z3_mk_bvule(c.ptr, lhs.ptr, rhs.ptr))
115}
116
117// MkBVSLE creates a signed bit-vector less-than-or-equal.
118func (c *Context) MkBVSLE(lhs, rhs *Expr) *Expr {
119 return newExpr(c, C.Z3_mk_bvsle(c.ptr, lhs.ptr, rhs.ptr))
120}
121
122// MkBVUGE creates an unsigned bit-vector greater-than-or-equal.
123func (c *Context) MkBVUGE(lhs, rhs *Expr) *Expr {
124 return newExpr(c, C.Z3_mk_bvuge(c.ptr, lhs.ptr, rhs.ptr))
125}
126
127// MkBVSGE creates a signed bit-vector greater-than-or-equal.
128func (c *Context) MkBVSGE(lhs, rhs *Expr) *Expr {
129 return newExpr(c, C.Z3_mk_bvsge(c.ptr, lhs.ptr, rhs.ptr))
130}
131
132// MkBVUGT creates an unsigned bit-vector greater-than.
133func (c *Context) MkBVUGT(lhs, rhs *Expr) *Expr {
134 return newExpr(c, C.Z3_mk_bvugt(c.ptr, lhs.ptr, rhs.ptr))
135}
136
137// MkBVSGT creates a signed bit-vector greater-than.
138func (c *Context) MkBVSGT(lhs, rhs *Expr) *Expr {
139 return newExpr(c, C.Z3_mk_bvsgt(c.ptr, lhs.ptr, rhs.ptr))
140}
141
142// MkConcat creates a bit-vector concatenation.
143func (c *Context) MkConcat(lhs, rhs *Expr) *Expr {
144 return newExpr(c, C.Z3_mk_concat(c.ptr, lhs.ptr, rhs.ptr))
145}
146
147// MkExtract creates a bit-vector extraction.
148func (c *Context) MkExtract(high, low uint, expr *Expr) *Expr {
149 return newExpr(c, C.Z3_mk_extract(c.ptr, C.uint(high), C.uint(low), expr.ptr))
150}
151
152// MkSignExt creates a bit-vector sign extension.
153func (c *Context) MkSignExt(i uint, expr *Expr) *Expr {
154 return newExpr(c, C.Z3_mk_sign_ext(c.ptr, C.uint(i), expr.ptr))
155}
156
157// MkZeroExt creates a bit-vector zero extension.
158func (c *Context) MkZeroExt(i uint, expr *Expr) *Expr {
159 return newExpr(c, C.Z3_mk_zero_ext(c.ptr, C.uint(i), expr.ptr))
160}