z3 0.0.20211213 → 0.0.20220630

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c73d508e9644e0c32681754a8f33959bc54d838c21d13f896223225e8b275a76
4
- data.tar.gz: 12e017b721b97aaec2d8e1a75145f0c5d3f0769eee2badc89e08e2b0ff11fef1
3
+ metadata.gz: a9289c94f0a177c8e59d2c18c65775344414bb3558151ac58fc02e932b3a7eb1
4
+ data.tar.gz: 3171e750dc3a36d1534ffc0c069274ff8bc7bc4d59d15e6792add5c4ab5f90b6
5
5
  SHA512:
6
- metadata.gz: d4993e91a238ad4e1c70e78bfe12301e1bd83759d9ad610fca64f89267868b9c8959c6e51ba98f175836235702c66f9cde8b19d73ddcd2cb760da75aed1f564d
7
- data.tar.gz: cca1389567fb61df3d4dc2fa6281b833edcc3c3a2c5872fec2b71089c9f9c927ba0d3e2d164127d5be167c2bb1cc4fd86f2360718631e0a8fbc473bda68ec90b
6
+ metadata.gz: d19511280987279176db440a5c5f3764d9029b49c74185c32cbf3dd01e6f02bcefa92b5800b24d4e872f052cb40a8daddf756783c81f3fdb63055d1be950b119
7
+ data.tar.gz: '09eedf827d3dfae3c56fd6d1c165160cdb5e3aeab0e2faae429dd81da91b7eaafd6640a6f28ed2a1b45e8a3a3c3e12a03d38327e86ac497b69e974e5f431cee6'
@@ -49,11 +49,31 @@ module Z3
49
49
  end
50
50
 
51
51
  def /(other)
52
- raise "Use signed_div or unsigned_div"
52
+ raise Z3::Exception, "Use signed_div or unsigned_div"
53
+ end
54
+
55
+ def signed_div(other)
56
+ BitvecExpr.SignedDiv(self, other)
57
+ end
58
+
59
+ def unsigned_div(other)
60
+ BitvecExpr.UnsignedDiv(self, other)
53
61
  end
54
62
 
55
63
  def %(other)
56
- raise "Use signed_mod or signed_rem or unsigned_rem"
64
+ raise Z3::Exception, "Use signed_mod or signed_rem or unsigned_rem"
65
+ end
66
+
67
+ def signed_mod(other)
68
+ BitvecExpr.SignedMod(self, other)
69
+ end
70
+
71
+ def signed_rem(other)
72
+ BitvecExpr.SignedRem(self, other)
73
+ end
74
+
75
+ def unsigned_rem(other)
76
+ BitvecExpr.UnsignedRem(self, other)
57
77
  end
58
78
 
59
79
  def rotate_left(num)
@@ -257,6 +277,31 @@ module Z3
257
277
  a.sort.new(LowLevel.mk_bvshl(a, b))
258
278
  end
259
279
 
280
+ def SignedDiv(a, b)
281
+ a, b = coerce_to_same_bv_sort(a, b)
282
+ a.sort.new(LowLevel.mk_bvsdiv(a, b))
283
+ end
284
+
285
+ def UnsignedDiv(a, b)
286
+ a, b = coerce_to_same_bv_sort(a, b)
287
+ a.sort.new(LowLevel.mk_bvudiv(a, b))
288
+ end
289
+
290
+ def SignedMod(a, b)
291
+ a, b = coerce_to_same_bv_sort(a, b)
292
+ a.sort.new(LowLevel.mk_bvsmod(a, b))
293
+ end
294
+
295
+ def SignedRem(a, b)
296
+ a, b = coerce_to_same_bv_sort(a, b)
297
+ a.sort.new(LowLevel.mk_bvsrem(a, b))
298
+ end
299
+
300
+ def UnsignedRem(a, b)
301
+ a, b = coerce_to_same_bv_sort(a, b)
302
+ a.sort.new(LowLevel.mk_bvurem(a, b))
303
+ end
304
+
260
305
  def Xnor(*args)
261
306
  args = coerce_to_same_bv_sort(*args)
262
307
  args.inject do |a,b|
data/lib/z3/optimize.rb CHANGED
@@ -3,7 +3,6 @@ module Z3
3
3
  attr_reader :_optimize
4
4
 
5
5
  def initialize
6
- raise Z3::Exception, "This is known to crash in Z3 4.8.13"
7
6
  @_optimize = LowLevel.mk_optimize
8
7
  LowLevel.optimize_inc_ref(self)
9
8
  reset_model!
@@ -4,7 +4,7 @@ require "ffi"
4
4
  module Z3
5
5
  module VeryLowLevel
6
6
  extend FFI::Library
7
- ffi_lib ["libz3.so.4.8", "libz3.so", "z3"]
7
+ ffi_lib ["libz3.so.4.8", "libz3.so", "z3", "libz3"]
8
8
 
9
9
  class << self
10
10
  # Aliases defined just to make APIs below look nicer
@@ -36,6 +36,19 @@ module Z3
36
36
  expect([a == 30, b == 42, c == (a * b)]).to have_solution(c => 236)
37
37
  end
38
38
 
39
+ it "/" do
40
+ expect{ a / b }.to raise_error(Z3::Exception)
41
+ expect([a == 200, b == 20, c == a.unsigned_div(b)]).to have_solution(c => 10)
42
+ expect([a == 200, b == 20, c == a.signed_div(b)]).to have_solution(c => 254)
43
+ end
44
+
45
+ it "%" do
46
+ expect{ a % b }.to raise_error(Z3::Exception)
47
+ expect([a == 200, b == 20, c == a.signed_mod(b)]).to have_solution(c => 4)
48
+ expect([a == 200, b == 20, c == a.signed_rem(b)]).to have_solution(c => 240)
49
+ expect([a == 200, b == 20, c == a.unsigned_rem(b)]).to have_solution(c => 0)
50
+ end
51
+
39
52
  it "&" do
40
53
  expect([a == 50, b == 27, c == (a & b)]).to have_solution(c => 18)
41
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: z3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.20211213
4
+ version: 0.0.20220630
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Wegrzanowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2022-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -331,7 +331,8 @@ files:
331
331
  homepage: https://github.com/taw/z3
332
332
  licenses:
333
333
  - MIT
334
- metadata: {}
334
+ metadata:
335
+ msys2_mingw_dependencies: z3
335
336
  post_install_message:
336
337
  rdoc_options: []
337
338
  require_paths:
@@ -348,7 +349,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
348
349
  version: '0'
349
350
  requirements:
350
351
  - z3 library (4.8+)
351
- rubygems_version: 3.1.2
352
+ rubygems_version: 3.3.7
352
353
  signing_key:
353
354
  specification_version: 4
354
355
  summary: Z3 Constraint Solver