z3 0.0.20170204 → 0.0.20171020

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6f02c4166af3fe459893d1ee5d19e181f5bce45
4
- data.tar.gz: 62497676a02f20c92a53afe81abee249632d026e
3
+ metadata.gz: f60c524dca681eab09bf92ff91d055060c806c80
4
+ data.tar.gz: e93747a1a7d10f62d1f8384f625c005651eeaf2e
5
5
  SHA512:
6
- metadata.gz: 9e48a27d5cf718468b6dc7030e212b7eaf8c141c40cc3456d89ee4f1cb8b37f3075e2505323a830cc9af40999f62b2a91389acf2a24aa6ac3516009310e523f9
7
- data.tar.gz: b83dfe9c5600a816de119a7440f0e5bb1df3e048421504d9c4c61dc26c8b19a2f73ea32cc9ebff17b9f89fa6e9b063f24dc91f6ed9d695cd27651e1945974764
6
+ metadata.gz: c7282273ba2bc89bd26e7096104fde50487956994300765957495a0c123ca0f06897103512c01ab9121e3349715fe9bf02e71832a3a73a7d9664ae33d8a2c5a5
7
+ data.tar.gz: a44bdce9868882fee77cfc502d9c1e977dce11df27648025d06172512396c2c35ddd4b7b56ecefcd60a04d9012cd9db74e1f0eb06e2fdffc1cd2a416c89ddce5
data/lib/z3/model.rb CHANGED
@@ -49,5 +49,11 @@ module Z3
49
49
  )
50
50
  end
51
51
  end
52
+
53
+ def !
54
+ Z3.Or(
55
+ *map{|v| v != self[v]}
56
+ )
57
+ end
52
58
  end
53
59
  end
data/lib/z3/solver.rb CHANGED
@@ -35,11 +35,25 @@ module Z3
35
35
  end
36
36
 
37
37
  def satisfiable?
38
- check == :sat
38
+ case check
39
+ when :sat
40
+ true
41
+ when :unsat
42
+ false
43
+ else
44
+ raise Z3::Exception, "Satisfiability unknown"
45
+ end
39
46
  end
40
47
 
41
48
  def unsatisfiable?
42
- check == :unsat
49
+ case check
50
+ when :unsat
51
+ true
52
+ when :sat
53
+ false
54
+ else
55
+ raise Z3::Exception, "Satisfiability unknown"
56
+ end
43
57
  end
44
58
 
45
59
  def model
data/spec/model_spec.rb CHANGED
@@ -42,5 +42,12 @@ module Z3
42
42
  expect(model.to_s).to eq("Z3::Model<a=2, b=4>")
43
43
  expect(model.inspect).to eq("Z3::Model<a=2, b=4>")
44
44
  end
45
+
46
+ it "#!" do
47
+ solver.assert(a == 2)
48
+ solver.assert(b == a+2)
49
+ expect(solver).to be_satisfiable
50
+ expect(!model).to be_same_as((a != 2) | (b != 4))
51
+ end
45
52
  end
46
53
  end
data/spec/solver_spec.rb CHANGED
@@ -39,5 +39,14 @@ module Z3
39
39
  stats = solver.statistics
40
40
  expect(stats.keys).to match_array(["rlimit count", "max memory", "memory", "num allocs"])
41
41
  end
42
+
43
+ # This is a very simple example of unknown satisfiablity
44
+ # so we might need more complex one in the future
45
+ it "third way" do
46
+ solver.assert a**3 == a
47
+ expect(solver.check).to eq(:unknown)
48
+ expect{solver.satisfiable?}.to raise_error("Satisfiability unknown")
49
+ expect{solver.unsatisfiable?}.to raise_error("Satisfiability unknown")
50
+ end
42
51
  end
43
52
  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.20170204
4
+ version: 0.0.20171020
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Wegrzanowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-04 00:00:00.000000000 Z
11
+ date: 2017-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry