z3 0.0.20160427 → 0.0.20161008

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -0
  3. data/Rakefile +56 -0
  4. data/examples/bit_tricks +21 -38
  5. data/examples/circuit_problems +170 -0
  6. data/lib/z3/ast.rb +21 -3
  7. data/lib/z3/context.rb +9 -7
  8. data/lib/z3/exception.rb +1 -2
  9. data/lib/z3/expr/arith_expr.rb +29 -11
  10. data/lib/z3/expr/array_expr.rb +5 -0
  11. data/lib/z3/expr/bitvec_expr.rb +293 -13
  12. data/lib/z3/expr/bool_expr.rb +30 -6
  13. data/lib/z3/expr/expr.rb +155 -2
  14. data/lib/z3/expr/float_expr.rb +185 -0
  15. data/lib/z3/expr/int_expr.rb +20 -5
  16. data/lib/z3/expr/real_expr.rb +1 -3
  17. data/lib/z3/expr/rounding_mode_expr.rb +5 -0
  18. data/lib/z3/expr/set_expr.rb +66 -0
  19. data/lib/z3/func_decl.rb +5 -5
  20. data/lib/z3/goal.rb +64 -0
  21. data/lib/z3/interface.rb +21 -222
  22. data/lib/z3/low_level.rb +84 -58
  23. data/lib/z3/low_level_auto.rb +1509 -1563
  24. data/lib/z3/model.rb +39 -37
  25. data/lib/z3/printer.rb +54 -12
  26. data/lib/z3/probe.rb +69 -0
  27. data/lib/z3/solver.rb +20 -20
  28. data/lib/z3/sort/array_sort.rb +24 -0
  29. data/lib/z3/sort/bitvec_sort.rb +1 -1
  30. data/lib/z3/sort/float_sort.rb +92 -0
  31. data/lib/z3/sort/rounding_mode_sort.rb +41 -0
  32. data/lib/z3/sort/set_sort.rb +31 -0
  33. data/lib/z3/sort/sort.rb +39 -5
  34. data/lib/z3/tactic.rb +69 -0
  35. data/lib/z3/very_low_level.rb +33 -29
  36. data/lib/z3/very_low_level_auto.rb +505 -517
  37. data/lib/z3.rb +13 -0
  38. data/spec/array_expr_spec.rb +18 -0
  39. data/spec/array_sort_spec.rb +11 -0
  40. data/spec/bitvec_expr_spec.rb +196 -44
  41. data/spec/bitvec_sort_spec.rb +29 -27
  42. data/spec/bool_expr_spec.rb +57 -55
  43. data/spec/bool_sort_spec.rb +17 -15
  44. data/spec/coverage_helper.rb +11 -0
  45. data/spec/expr_spec.rb +151 -147
  46. data/spec/float_expr_spec.rb +167 -0
  47. data/spec/float_sort_spec.rb +44 -0
  48. data/spec/goal_spec.rb +17 -0
  49. data/spec/int_expr_spec.rb +76 -63
  50. data/spec/int_sort_spec.rb +16 -14
  51. data/spec/integration/algebra_problems_spec.rb +4 -4
  52. data/spec/integration/cicruit_problem_spec.rb +23 -0
  53. data/spec/integration/geometry_problem_spec.rb +4 -4
  54. data/spec/integration/kinematics_problems_spec.rb +3 -3
  55. data/spec/model_spec.rb +39 -37
  56. data/spec/printer_spec.rb +49 -18
  57. data/spec/probe_spec.rb +17 -0
  58. data/spec/real_expr_spec.rb +59 -51
  59. data/spec/real_sort_spec.rb +22 -20
  60. data/spec/rounding_mode_expr_spec.rb +16 -0
  61. data/spec/rounding_mode_sort_spec.rb +13 -0
  62. data/spec/set_expr_spec.rb +61 -0
  63. data/spec/set_sort_spec.rb +27 -0
  64. data/spec/solver_spec.rb +37 -27
  65. data/spec/sort_spec.rb +38 -36
  66. data/spec/spec_helper.rb +59 -2
  67. data/spec/tactic_spec.rb +9 -0
  68. metadata +44 -4
@@ -9,59 +9,339 @@ module Z3
9
9
  end
10
10
 
11
11
  def &(other)
12
- Z3.And(self, other)
12
+ Expr.And(self, other)
13
13
  end
14
14
 
15
15
  def |(other)
16
- Z3.Or(self, other)
16
+ Expr.Or(self, other)
17
17
  end
18
18
 
19
19
  def ^(other)
20
- Z3.Xor(self, other)
20
+ Expr.Xor(self, other)
21
+ end
22
+
23
+ def xnor(other)
24
+ BitvecExpr.Xnor(self, other)
25
+ end
26
+
27
+ def nand(other)
28
+ BitvecExpr.Nand(self, other)
29
+ end
30
+
31
+ def nor(other)
32
+ BitvecExpr.Nor(self, other)
21
33
  end
22
34
 
23
35
  def +(other)
24
- ::Z3.Add(self, other)
36
+ Expr.Add(self, other)
25
37
  end
26
38
 
27
39
  def -(other)
28
- ::Z3.Sub(self, other)
40
+ Expr.Sub(self, other)
29
41
  end
30
42
 
31
43
  def *(other)
32
- ::Z3.Mul(self, other)
44
+ Expr.Mul(self, other)
45
+ end
46
+
47
+ def /(other)
48
+ raise "Use signed_div or unsigned_div"
49
+ end
50
+
51
+ def %(other)
52
+ raise "Use signed_mod or signed_rem or unsigned_rem"
53
+ end
54
+
55
+ def rotate_left(num)
56
+ sort.new(LowLevel.mk_rotate_left(num, self))
57
+ end
58
+
59
+ def rotate_right(num)
60
+ sort.new(LowLevel.mk_rotate_right(num, self))
61
+ end
62
+
63
+ def zero_ext(size)
64
+ BitvecSort.new(sort.size + size).new(LowLevel.mk_zero_ext(size, self))
65
+ end
66
+
67
+ def sign_ext(size)
68
+ BitvecSort.new(sort.size + size).new(LowLevel.mk_sign_ext(size, self))
69
+ end
70
+
71
+ def add_no_overflow?(other)
72
+ raise Z3::Exception, "Use #signed_add_no_overflow? or #unsigned_add_no_overflow? for Bitvec, not #add_no_overflow?"
73
+ end
74
+
75
+ def add_no_overflow?(other)
76
+ raise "Use signed_add_no_overflow? or unsigned_add_no_overflow?"
77
+ end
78
+ def signed_add_no_overflow?(other)
79
+ BitvecExpr.SignedAddNoOverflow(self, other)
80
+ end
81
+ def unsigned_add_no_overflow?(other)
82
+ BitvecExpr.UnsignedAddNoOverflow(self, other)
83
+ end
84
+
85
+ def add_no_underflow?(other)
86
+ BitvecExpr.SignedAddNoUnderflow(self, other)
87
+ end
88
+ def signed_add_no_underflow?(other)
89
+ BitvecExpr.SignedAddNoUnderflow(self, other)
90
+ end
91
+ def unsigned_add_no_underflow?(other)
92
+ raise "Unsigned + cannot underflow"
93
+ end
94
+
95
+ def unsigned_neg_no_overflow?
96
+ raise "There is no unsigned negation"
97
+ end
98
+ def signed_neg_no_overflow?
99
+ BitvecExpr.SignedNegNoOverflow(self)
100
+ end
101
+ def neg_no_overflow?
102
+ BitvecExpr.SignedNegNoOverflow(self)
103
+ end
104
+
105
+ def mul_no_overflow?(other)
106
+ raise "Use signed_mul_no_overflow? or unsigned_mul_no_overflow?"
107
+ end
108
+ def signed_mul_no_overflow?(other)
109
+ BitvecExpr.SignedMulNoOverflow(self, other)
110
+ end
111
+ def unsigned_mul_no_overflow?(other)
112
+ BitvecExpr.UnsignedMulNoOverflow(self, other)
113
+ end
114
+
115
+ def mul_no_underflow?(other)
116
+ BitvecExpr.SignedMulNoUnderflow(self, other)
117
+ end
118
+ def signed_mul_no_underflow?(other)
119
+ BitvecExpr.SignedMulNoUnderflow(self, other)
120
+ end
121
+ def unsigned_mul_no_underflow?(other)
122
+ raise "Unsigned + cannot underflow"
123
+ end
124
+
125
+ def div_no_overflow?(other)
126
+ BitvecExpr.SignedDivNoOverflow(self, other)
127
+ end
128
+ def signed_div_no_overflow?(other)
129
+ BitvecExpr.SignedDivNoOverflow(self, other)
130
+ end
131
+ def unsigned_div_no_overflow?(other)
132
+ raise "Unsigned / cannot underflow"
33
133
  end
34
134
 
35
135
  def >>(other)
36
- Z3.RShift(self, other)
136
+ raise Z3::Exception, "Use #signed_rshift or #unsigned_rshift for Bitvec, not >>"
137
+ end
138
+
139
+ def signed_rshift(other)
140
+ BitvecExpr.SignedRShift(self, other)
141
+ end
142
+
143
+ def unsigned_rshift(other)
144
+ BitvecExpr.UnsignedRShift(self, other)
145
+ end
146
+
147
+ def rshift(other)
148
+ raise Z3::Exception, "Use #signed_rshift or #unsigned_rshift for Bitvec, not #rshift"
37
149
  end
38
150
 
39
151
  def <<(other)
40
- Z3.LShift(self, other)
152
+ BitvecExpr.LShift(self, other)
153
+ end
154
+
155
+ def signed_lshift(other)
156
+ BitvecExpr.LShift(self, other)
157
+ end
158
+
159
+ def unsigned_lshift(other)
160
+ BitvecExpr.LShift(self, other)
161
+ end
162
+
163
+ def lshift(other)
164
+ BitvecExpr.LShift(self, other)
41
165
  end
42
166
 
43
167
  def >(other)
44
- ::Z3.Gt(self, other)
168
+ Expr.Gt(self, other)
45
169
  end
46
170
 
47
171
  def >=(other)
48
- ::Z3.Ge(self, other)
172
+ Expr.Ge(self, other)
49
173
  end
50
174
 
51
175
  def <=(other)
52
- ::Z3.Le(self, other)
176
+ Expr.Le(self, other)
53
177
  end
54
178
 
55
179
  def <(other)
56
- ::Z3.Lt(self, other)
180
+ Expr.Lt(self, other)
181
+ end
182
+
183
+ def signed_gt(other)
184
+ BitvecExpr.SignedGt(self, other)
185
+ end
186
+
187
+ def signed_ge(other)
188
+ BitvecExpr.SignedGe(self, other)
189
+ end
190
+
191
+ def signed_lt(other)
192
+ BitvecExpr.SignedLt(self, other)
193
+ end
194
+
195
+ def signed_le(other)
196
+ BitvecExpr.SignedLe(self, other)
197
+ end
198
+
199
+ def unsigned_gt(other)
200
+ BitvecExpr.UnsignedGt(self, other)
201
+ end
202
+
203
+ def unsigned_ge(other)
204
+ BitvecExpr.UnsignedGe(self, other)
205
+ end
206
+
207
+ def unsigned_lt(other)
208
+ BitvecExpr.UnsignedLt(self, other)
209
+ end
210
+
211
+ def unsigned_le(other)
212
+ BitvecExpr.UnsignedLe(self, other)
57
213
  end
58
214
 
59
215
  def coerce(other)
60
- other_sort = Value.sort_for_const(other)
216
+ other_sort = Expr.sort_for_const(other)
61
217
  max_sort = [sort, other_sort].max
62
218
  [max_sort.from_const(other), max_sort.from_value(self)]
63
219
  end
64
220
 
65
221
  public_class_method :new
222
+
223
+ class << self
224
+ def coerce_to_same_bv_sort(*args)
225
+ args = coerce_to_same_sort(*args)
226
+ raise Z3::Exception, "Bitvec value with same size expected" unless args[0].is_a?(BitvecExpr)
227
+ args
228
+ end
229
+
230
+ def SignedRShift(a, b)
231
+ a, b = coerce_to_same_bv_sort(a, b)
232
+ a.sort.new(LowLevel.mk_bvashr(a, b))
233
+ end
234
+
235
+ def UnsignedRShift(a, b)
236
+ a, b = coerce_to_same_bv_sort(a, b)
237
+ a.sort.new(LowLevel.mk_bvlshr(a, b))
238
+ end
239
+
240
+ # Signed/Unsigned work the same
241
+ def LShift(a, b)
242
+ a, b = coerce_to_same_bv_sort(a, b)
243
+ a.sort.new(LowLevel.mk_bvshl(a, b))
244
+ end
245
+
246
+ def Xnor(*args)
247
+ args = coerce_to_same_bv_sort(*args)
248
+ args.inject do |a,b|
249
+ a.sort.new(LowLevel.mk_bvxnor(a, b))
250
+ end
251
+ end
252
+
253
+ def Nand(*args)
254
+ args = coerce_to_same_bv_sort(*args)
255
+ args.inject do |a,b|
256
+ a.sort.new(LowLevel.mk_bvnand(a, b))
257
+ end
258
+ end
259
+
260
+ def Nor(*args)
261
+ args = coerce_to_same_bv_sort(*args)
262
+ args.inject do |a,b|
263
+ a.sort.new(LowLevel.mk_bvnor(a, b))
264
+ end
265
+ end
266
+
267
+ def UnsignedGt(a, b)
268
+ a, b = coerce_to_same_bv_sort(a, b)
269
+ BoolSort.new.new(LowLevel.mk_bvugt(a, b))
270
+ end
271
+
272
+ def UnsignedGe(a, b)
273
+ a, b = coerce_to_same_bv_sort(a, b)
274
+ BoolSort.new.new(LowLevel.mk_bvuge(a, b))
275
+ end
276
+
277
+ def UnsignedLt(a, b)
278
+ a, b = coerce_to_same_bv_sort(a, b)
279
+ BoolSort.new.new(LowLevel.mk_bvult(a, b))
280
+ end
281
+
282
+ def UnsignedLe(a, b)
283
+ a, b = coerce_to_same_bv_sort(a, b)
284
+ BoolSort.new.new(LowLevel.mk_bvule(a, b))
285
+ end
286
+
287
+ def SignedGt(a, b)
288
+ a, b = coerce_to_same_bv_sort(a, b)
289
+ BoolSort.new.new(LowLevel.mk_bvsgt(a, b))
290
+ end
291
+
292
+ def SignedGe(a, b)
293
+ a, b = coerce_to_same_bv_sort(a, b)
294
+ BoolSort.new.new(LowLevel.mk_bvsge(a, b))
295
+ end
296
+
297
+ def SignedLt(a, b)
298
+ a, b = coerce_to_same_bv_sort(a, b)
299
+ BoolSort.new.new(LowLevel.mk_bvslt(a, b))
300
+ end
301
+
302
+ def SignedLe(a, b)
303
+ a, b = coerce_to_same_bv_sort(a, b)
304
+ BoolSort.new.new(LowLevel.mk_bvsle(a, b))
305
+ end
306
+
307
+ def SignedAddNoOverflow(a, b)
308
+ a, b = coerce_to_same_bv_sort(a, b)
309
+ BoolSort.new.new(LowLevel.mk_bvadd_no_overflow(a, b, true))
310
+ end
311
+
312
+ def UnsignedAddNoOverflow(a, b)
313
+ a, b = coerce_to_same_bv_sort(a, b)
314
+ BoolSort.new.new(LowLevel.mk_bvadd_no_overflow(a, b, false))
315
+ end
316
+
317
+ def SignedAddNoUnderflow(a, b)
318
+ a, b = coerce_to_same_bv_sort(a, b)
319
+ BoolSort.new.new(LowLevel.mk_bvadd_no_underflow(a, b))
320
+ end
321
+
322
+ def SignedNegNoOverflow(a)
323
+ BoolSort.new.new(LowLevel.mk_bvneg_no_overflow(a))
324
+ end
325
+
326
+ def SignedMulNoOverflow(a, b)
327
+ a, b = coerce_to_same_bv_sort(a, b)
328
+ BoolSort.new.new(LowLevel.mk_bvmul_no_overflow(a, b, true))
329
+ end
330
+
331
+ def UnsignedMulNoOverflow(a, b)
332
+ a, b = coerce_to_same_bv_sort(a, b)
333
+ BoolSort.new.new(LowLevel.mk_bvmul_no_overflow(a, b, false))
334
+ end
335
+
336
+ def SignedMulNoUnderflow(a, b)
337
+ a, b = coerce_to_same_bv_sort(a, b)
338
+ BoolSort.new.new(LowLevel.mk_bvmul_no_underflow(a, b))
339
+ end
340
+
341
+ def SignedDivNoOverflow(a, b)
342
+ a, b = coerce_to_same_bv_sort(a, b)
343
+ BoolSort.new.new(LowLevel.mk_bvsdiv_no_overflow(a, b))
344
+ end
345
+ end
66
346
  end
67
347
  end
@@ -5,29 +5,53 @@ module Z3
5
5
  end
6
6
 
7
7
  def &(other)
8
- Z3.And(self, other)
8
+ Expr.And(self, other)
9
9
  end
10
10
 
11
11
  def |(other)
12
- Z3.Or(self, other)
12
+ Expr.Or(self, other)
13
13
  end
14
14
 
15
15
  def ^(other)
16
- Z3.Xor(self, other)
16
+ Expr.Xor(self, other)
17
17
  end
18
18
 
19
19
  def iff(other)
20
- Z3.Iff(self, other)
20
+ BoolExpr.Iff(self, other)
21
21
  end
22
22
 
23
23
  def implies(other)
24
- Z3.Implies(self, other)
24
+ BoolExpr.Implies(self, other)
25
25
  end
26
26
 
27
27
  def ite(a, b)
28
- Z3.IfThenElse(self, a, b)
28
+ BoolExpr.IfThenElse(self, a, b)
29
29
  end
30
30
 
31
31
  public_class_method :new
32
+
33
+ class << self
34
+ def coerce_to_same_bool_sort(*args)
35
+ args = coerce_to_same_sort(*args)
36
+ raise Z3::Exception, "Bool value expected" unless args[0].is_a?(BoolExpr)
37
+ args
38
+ end
39
+
40
+ def Implies(a,b)
41
+ a, b = coerce_to_same_bool_sort(a, b)
42
+ BoolSort.new.new(LowLevel.mk_implies(a, b))
43
+ end
44
+
45
+ def Iff(a,b)
46
+ a, b = coerce_to_same_bool_sort(a, b)
47
+ BoolSort.new.new(LowLevel.mk_iff(a, b))
48
+ end
49
+
50
+ def IfThenElse(a, b, c)
51
+ a, = coerce_to_same_bool_sort(a)
52
+ b, c = coerce_to_same_sort(b, c)
53
+ b.sort.new(LowLevel.mk_ite(a, b, c))
54
+ end
55
+ end
32
56
  end
33
57
  end
data/lib/z3/expr/expr.rb CHANGED
@@ -12,14 +12,22 @@ module Z3
12
12
  end
13
13
 
14
14
  def ==(other)
15
- ::Z3.Eq(self, other)
15
+ Expr.Eq(self, other)
16
16
  end
17
17
 
18
18
  def !=(other)
19
- ::Z3.Distinct(self, other)
19
+ Expr.Distinct(self, other)
20
20
  end
21
21
 
22
22
  class << self
23
+ def coerce_to_same_sort(*args)
24
+ # This will raise exception unless one of the sorts is highest
25
+ max_sort = args.map{|a| a.is_a?(Expr) ? a.sort : Expr.sort_for_const(a)}.max
26
+ args.map do |a|
27
+ max_sort.cast(a)
28
+ end
29
+ end
30
+
23
31
  def sort_for_const(a)
24
32
  case a
25
33
  when TrueClass, FalseClass
@@ -37,6 +45,151 @@ module Z3
37
45
  _sort = Z3::VeryLowLevel.Z3_get_sort(Z3::LowLevel._ctx_pointer, _ast)
38
46
  Sort.from_pointer(_sort).new(_ast)
39
47
  end
48
+
49
+ def Gt(a, b)
50
+ a, b = coerce_to_same_sort(a, b)
51
+ case a
52
+ when ArithExpr
53
+ BoolSort.new.new(LowLevel.mk_gt(a, b))
54
+ when BitvecExpr
55
+ raise Z3::Exception, "Use #signed_gt or #unsigned_gt for Bitvec, not >"
56
+ else
57
+ raise Z3::Exception, "Can't compare #{a.sort} values"
58
+ end
59
+ end
60
+
61
+ def Ge(a, b)
62
+ a, b = coerce_to_same_sort(a, b)
63
+ case a
64
+ when ArithExpr
65
+ BoolSort.new.new(LowLevel.mk_ge(a, b))
66
+ when BitvecExpr
67
+ raise Z3::Exception, "Use #signed_ge or #unsigned_ge for Bitvec, not >="
68
+ else
69
+ raise Z3::Exception, "Can't compare #{a.sort} values"
70
+ end
71
+ end
72
+
73
+ def Lt(a, b)
74
+ a, b = coerce_to_same_sort(a, b)
75
+ case a
76
+ when ArithExpr
77
+ BoolSort.new.new(LowLevel.mk_lt(a, b))
78
+ when BitvecExpr
79
+ raise Z3::Exception, "Use #signed_lt or #unsigned_lt for Bitvec, not <"
80
+ else
81
+ raise Z3::Exception, "Can't compare #{a.sort} values"
82
+ end
83
+ end
84
+
85
+ def Le(a, b)
86
+ a, b = coerce_to_same_sort(a, b)
87
+ case a
88
+ when ArithExpr
89
+ BoolSort.new.new(LowLevel.mk_le(a, b))
90
+ when BitvecExpr
91
+ raise Z3::Exception, "Use #signed_le or #unsigned_le for Bitvec, not <="
92
+ else
93
+ raise Z3::Exception, "Can't compare #{a.sort} values"
94
+ end
95
+ end
96
+
97
+ def Eq(a, b)
98
+ a, b = coerce_to_same_sort(a, b)
99
+ BoolSort.new.new(LowLevel.mk_eq(a, b))
100
+ end
101
+
102
+ def Distinct(*args)
103
+ args = coerce_to_same_sort(*args)
104
+ BoolSort.new.new(LowLevel.mk_distinct(args))
105
+ end
106
+
107
+ def And(*args)
108
+ args = coerce_to_same_sort(*args)
109
+ case args[0]
110
+ when BoolExpr
111
+ BoolSort.new.new(Z3::LowLevel.mk_and(args))
112
+ when BitvecExpr
113
+ args.inject do |a,b|
114
+ a.sort.new(Z3::LowLevel.mk_bvand(a, b))
115
+ end
116
+ else
117
+ raise Z3::Exception, "Can't perform logic operations on #{a.sort} exprs, only Bool and Bitvec"
118
+ end
119
+ end
120
+
121
+ def Or(*args)
122
+ args = coerce_to_same_sort(*args)
123
+ case args[0]
124
+ when BoolExpr
125
+ BoolSort.new.new(Z3::LowLevel.mk_or(args))
126
+ when BitvecExpr
127
+ args.inject do |a,b|
128
+ a.sort.new(Z3::LowLevel.mk_bvor(a, b))
129
+ end
130
+ else
131
+ raise Z3::Exception, "Can't perform logic operations on #{a.sort} exprs, only Bool and Bitvec"
132
+ end
133
+ end
134
+
135
+ def Xor(*args)
136
+ args = coerce_to_same_sort(*args)
137
+ case args[0]
138
+ when BoolExpr
139
+ args.inject do |a,b|
140
+ BoolSort.new.new(Z3::LowLevel.mk_xor(a, b))
141
+ end
142
+ when BitvecExpr
143
+ args.inject do |a,b|
144
+ a.sort.new(Z3::LowLevel.mk_bvxor(a, b))
145
+ end
146
+ else
147
+ raise Z3::Exception, "Can't perform logic operations on #{a.sort} exprs, only Bool and Bitvec"
148
+ end
149
+ end
150
+
151
+ def Add(*args)
152
+ raise Z3::Exception if args.empty?
153
+ args = coerce_to_same_sort(*args)
154
+ case args[0]
155
+ when ArithExpr
156
+ args[0].sort.new(LowLevel.mk_add(args))
157
+ when BitvecExpr
158
+ args.inject do |a,b|
159
+ a.sort.new(LowLevel.mk_bvadd(a,b))
160
+ end
161
+ else
162
+ raise Z3::Exception, "Can't perform logic operations on #{args[0].sort} exprs, only Int/Real/Bitvec"
163
+ end
164
+ end
165
+
166
+ def Sub(*args)
167
+ args = coerce_to_same_sort(*args)
168
+ case args[0]
169
+ when ArithExpr
170
+ args[0].sort.new(LowLevel.mk_sub(args))
171
+ when BitvecExpr
172
+ args.inject do |a,b|
173
+ a.sort.new(LowLevel.mk_bvsub(a,b))
174
+ end
175
+ else
176
+ raise Z3::Exception, "Can't perform logic operations on #{args[0].sort} values, only Int/Real/Bitvec"
177
+ end
178
+ end
179
+
180
+ def Mul(*args)
181
+ args = coerce_to_same_sort(*args)
182
+ case args[0]
183
+ when ArithExpr
184
+ args[0].sort.new(LowLevel.mk_mul(args))
185
+ when BitvecExpr
186
+ args.inject do |a,b|
187
+ a.sort.new(LowLevel.mk_bvmul(a,b))
188
+ end
189
+ else
190
+ raise Z3::Exception, "Can't perform logic operations on #{args[0].sort} values, only Int/Real/Bitvec"
191
+ end
192
+ end
40
193
  end
41
194
  end
42
195
  end