z3 0.0.20180629 → 0.0.20181126
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +9 -9
- data/examples/simple_regexp_parser.rb +58 -56
- data/lib/z3/expr/expr.rb +13 -12
- data/lib/z3/low_level.rb +6 -2
- data/lib/z3/low_level_auto.rb +44 -28
- data/lib/z3/optimize.rb +4 -4
- data/lib/z3/very_low_level.rb +3 -4
- data/lib/z3/very_low_level_auto.rb +11 -7
- data/spec/integration/oneofus_spec.rb +7 -15
- data/spec/optimize_spec.rb +3 -3
- data/spec/set_expr_spec.rb +9 -9
- data/spec/solver_spec.rb +3 -3
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c93f27f8597c24344b97bcb79677cb1c91d92d626e457600ab36e355db41586
|
4
|
+
data.tar.gz: a85deb034bee0faeb6a6c4283e85657cf394ae7ec2643b91f4d8d249ac337748
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34781021336dab28fe7969b707638461bd8da2bb1b331038ca10e0c7eb015582c478360f0264c2174b517807e99bbf7598431dd985b39b3d0472fea8b550d23f
|
7
|
+
data.tar.gz: e382c7d4caa935adda0172436e4d3f7e6499dd46c4dcb0f2a95ee641ac1487c2bb06035a7fe6c6d40f35a1d9d664a3948cd26fac856d890833f0ec8c85eb6b71
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -7,43 +7,43 @@ task "test:unit" => "spec:unit"
|
|
7
7
|
|
8
8
|
desc "Regenerate API"
|
9
9
|
task "api" do
|
10
|
-
|
10
|
+
sh "./api/gen_api api/definitions.h"
|
11
11
|
end
|
12
12
|
|
13
13
|
desc "Clean up"
|
14
14
|
task "clean" do
|
15
|
-
|
15
|
+
sh "trash z3-*.gem coverage"
|
16
16
|
end
|
17
17
|
|
18
18
|
desc "Run tests"
|
19
19
|
task "spec" do
|
20
|
-
|
20
|
+
sh "rspec"
|
21
21
|
end
|
22
22
|
|
23
23
|
desc "Run unit tests"
|
24
24
|
task "spec:unit" do
|
25
|
-
|
25
|
+
sh "rspec spec/*_spec.rb"
|
26
26
|
end
|
27
27
|
|
28
28
|
desc "Run integration tests"
|
29
29
|
task "spec:integration" do
|
30
|
-
|
30
|
+
sh "rspec spec/integration/*_spec.rb"
|
31
31
|
end
|
32
32
|
|
33
33
|
desc "Build gem"
|
34
34
|
task "gem:build" do
|
35
|
-
|
35
|
+
sh "gem build z3.gemspec"
|
36
36
|
end
|
37
37
|
|
38
38
|
desc "Upload gem"
|
39
39
|
task "gem:push" => "gem:build" do
|
40
40
|
gem_file = Dir["z3-*.gem"][-1] or raise "No gem found"
|
41
|
-
|
41
|
+
sh "gem", "push", gem_file
|
42
42
|
end
|
43
43
|
|
44
44
|
desc "Report missing APIs"
|
45
45
|
task "coverage:missing" do
|
46
|
-
|
46
|
+
sh "COVERAGE=1 rake test"
|
47
47
|
data = JSON.load(open("coverage/.resultset.json"))["RSpec"]["coverage"]
|
48
48
|
lla_path = data.keys.find{|k| k.end_with?("lib/z3/low_level_auto.rb")}
|
49
49
|
coverage = data[lla_path].zip(File.readlines(lla_path).map(&:strip))
|
@@ -53,4 +53,4 @@ task "coverage:missing" do
|
|
53
53
|
open("missing_apis.txt", "w") do |file|
|
54
54
|
file.puts missing
|
55
55
|
end
|
56
|
-
end
|
56
|
+
end
|
@@ -15,7 +15,7 @@ class SimpleRegexpParser
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def sequence(*parts)
|
18
|
-
parts = parts.select{|x| x[0] != :empty}
|
18
|
+
parts = parts.select { |x| x[0] != :empty }
|
19
19
|
case parts.size
|
20
20
|
when 0
|
21
21
|
[:empty]
|
@@ -46,9 +46,9 @@ class SimpleRegexpParser
|
|
46
46
|
# Saves us time to reuse ruby regexp engine for 1 character case
|
47
47
|
def character_type(char_rx)
|
48
48
|
char_rx = Regexp.new(char_rx)
|
49
|
-
codes = (0..127).select{|c| c.chr =~ char_rx}
|
49
|
+
codes = (0..127).select { |c| c.chr =~ char_rx }
|
50
50
|
# This is mostly here to make debugging easier
|
51
|
-
if codes.size > 127-codes.size
|
51
|
+
if codes.size > 127 - codes.size
|
52
52
|
[:neg_set, (0..127).to_a - codes]
|
53
53
|
else
|
54
54
|
[:set, codes]
|
@@ -64,7 +64,7 @@ class SimpleRegexpParser
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def literal(chars)
|
67
|
-
sequence(*chars.map{|c| character_type(c)})
|
67
|
+
sequence(*chars.map { |c| character_type(c) })
|
68
68
|
end
|
69
69
|
|
70
70
|
def star(part)
|
@@ -85,10 +85,10 @@ class SimpleRegexpParser
|
|
85
85
|
|
86
86
|
def repeat(part, min, max)
|
87
87
|
if max == -1
|
88
|
-
sequence(star(part), *([part]*min))
|
88
|
+
sequence(star(part), *([part] * min))
|
89
89
|
else
|
90
90
|
maybe_part = alternative([:empty], part)
|
91
|
-
sequence(*([part]*min), *([maybe_part] * (max-min)))
|
91
|
+
sequence(*([part] * min), *([maybe_part] * (max - min)))
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -105,7 +105,7 @@ class SimpleRegexpParser
|
|
105
105
|
sequence(repeat(base, min, max), part)
|
106
106
|
)
|
107
107
|
else # (a){2,} -> a{1,}(a)
|
108
|
-
sequence(repeat(base, min-1, max), part)
|
108
|
+
sequence(repeat(base, min - 1, max), part)
|
109
109
|
end
|
110
110
|
elsif max == 0 # a{0} -> empty, not really a thing
|
111
111
|
:empty
|
@@ -115,10 +115,10 @@ class SimpleRegexpParser
|
|
115
115
|
# with same group id for both ()s
|
116
116
|
alternative(
|
117
117
|
[:group, group, empty],
|
118
|
-
sequence(repeat(base, min, max-1), part)
|
118
|
+
sequence(repeat(base, min, max - 1), part)
|
119
119
|
)
|
120
120
|
else # (a){2,3} -> a{1,2}(a)
|
121
|
-
sequence(repeat(base, min-1, max-1), part)
|
121
|
+
sequence(repeat(base, min - 1, max - 1), part)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -131,58 +131,60 @@ class SimpleRegexpParser
|
|
131
131
|
# * empty
|
132
132
|
# * backref - \1
|
133
133
|
# * group - (a)
|
134
|
-
def parse(node
|
134
|
+
def parse(node = @tree)
|
135
135
|
result = case node
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
136
|
+
when Regexp::Expression::Group::Capture
|
137
|
+
# Assumes it's going to be parsed in right order
|
138
|
+
group(new_group, sequence(*node.expressions.map { |n| parse(n) }))
|
139
|
+
when Regexp::Expression::Alternation
|
140
|
+
alternative(*node.expressions.map { |n| parse(n) })
|
141
|
+
when Regexp::Expression::Assertion::Lookahead
|
142
|
+
[:anchor, :lookahead, sequence(*node.expressions.map { |n| parse(n) })]
|
143
|
+
when Regexp::Expression::Assertion::NegativeLookahead
|
144
|
+
[:anchor, :negative_lookahead, sequence(*node.expressions.map { |n| parse(n) })]
|
145
|
+
when Regexp::Expression::Assertion::Lookbehind
|
146
|
+
[:anchor, :lookbehind, sequence(*node.expressions.map { |n| parse(n) })]
|
147
|
+
when Regexp::Expression::Assertion::NegativeLookbehind
|
148
|
+
[:anchor, :negative_lookbehind, sequence(*node.expressions.map { |n| parse(n) })]
|
149
|
+
when Regexp::Expression::CharacterSet
|
150
|
+
character_set(node.negative?, node.expressions)
|
151
|
+
when Regexp::Expression::Subexpression
|
152
|
+
# It's annoyingly subtypes a lot
|
153
|
+
unless (node.class == Regexp::Expression::Subexpression or
|
154
|
+
node.class == Regexp::Expression::Group::Passive or
|
155
|
+
node.class == Regexp::Expression::Root or
|
156
|
+
node.class == Regexp::Expression::Alternative)
|
157
|
+
raise "Don't know how to deal with #{node.class}"
|
158
|
+
end
|
159
|
+
sequence(*node.expressions.map { |n| parse(n) })
|
160
|
+
when Regexp::Expression::Literal
|
161
|
+
literal(node.text.chars)
|
162
|
+
when Regexp::Expression::CharacterType::Base
|
163
|
+
character_type(node.text)
|
164
|
+
when Regexp::Expression::EscapeSequence::Base
|
165
|
+
character_type(node.text)
|
166
|
+
when Regexp::Expression::Backreference::Number
|
167
|
+
num = node.text[%r[\A\\(\d+)\z], 1] or raise "Parse error"
|
168
|
+
backref(num.to_i)
|
169
|
+
when Regexp::Expression::Anchor::BeginningOfString
|
170
|
+
[:anchor, :bos]
|
171
|
+
when Regexp::Expression::Anchor::EndOfString
|
172
|
+
[:anchor, :eos]
|
173
|
+
when Regexp::Expression::Anchor::BeginningOfLine
|
174
|
+
[:anchor, :bol]
|
175
|
+
when Regexp::Expression::Anchor::EndOfLine
|
176
|
+
[:anchor, :eol]
|
177
|
+
else
|
178
|
+
raise "Unknown expression"
|
179
|
+
end
|
178
180
|
if node.quantified?
|
179
181
|
min = node.quantifier.min
|
180
182
|
max = node.quantifier.max
|
181
183
|
result = if result[0] == :group
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
184
|
+
repeat_group(result, min, max)
|
185
|
+
else
|
186
|
+
repeat(result, min, max)
|
187
|
+
end
|
186
188
|
end
|
187
189
|
|
188
190
|
result
|
data/lib/z3/expr/expr.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Z3
|
2
2
|
class Expr < AST
|
3
3
|
attr_reader :sort
|
4
|
+
|
4
5
|
def initialize(_ast, sort)
|
5
6
|
super(_ast)
|
6
7
|
@sort = sort
|
7
|
-
raise Z3::Exception, "Values must have AST kind numeral or
|
8
|
+
raise Z3::Exception, "Values must have AST kind numeral, app, or quantifier" unless [:numeral, :app, :quantifier].include?(ast_kind)
|
8
9
|
end
|
9
10
|
|
10
11
|
def inspect
|
@@ -22,7 +23,7 @@ module Z3
|
|
22
23
|
class << self
|
23
24
|
def coerce_to_same_sort(*args)
|
24
25
|
# 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
|
+
max_sort = args.map { |a| a.is_a?(Expr) ? a.sort : Expr.sort_for_const(a) }.max
|
26
27
|
args.map do |a|
|
27
28
|
max_sort.cast(a)
|
28
29
|
end
|
@@ -110,7 +111,7 @@ module Z3
|
|
110
111
|
when BoolExpr
|
111
112
|
BoolSort.new.new(Z3::LowLevel.mk_and(args))
|
112
113
|
when BitvecExpr
|
113
|
-
args.inject do |a,b|
|
114
|
+
args.inject do |a, b|
|
114
115
|
a.sort.new(Z3::LowLevel.mk_bvand(a, b))
|
115
116
|
end
|
116
117
|
else
|
@@ -124,7 +125,7 @@ module Z3
|
|
124
125
|
when BoolExpr
|
125
126
|
BoolSort.new.new(Z3::LowLevel.mk_or(args))
|
126
127
|
when BitvecExpr
|
127
|
-
args.inject do |a,b|
|
128
|
+
args.inject do |a, b|
|
128
129
|
a.sort.new(Z3::LowLevel.mk_bvor(a, b))
|
129
130
|
end
|
130
131
|
else
|
@@ -136,11 +137,11 @@ module Z3
|
|
136
137
|
args = coerce_to_same_sort(*args)
|
137
138
|
case args[0]
|
138
139
|
when BoolExpr
|
139
|
-
args.inject do |a,b|
|
140
|
+
args.inject do |a, b|
|
140
141
|
BoolSort.new.new(Z3::LowLevel.mk_xor(a, b))
|
141
142
|
end
|
142
143
|
when BitvecExpr
|
143
|
-
args.inject do |a,b|
|
144
|
+
args.inject do |a, b|
|
144
145
|
a.sort.new(Z3::LowLevel.mk_bvxor(a, b))
|
145
146
|
end
|
146
147
|
else
|
@@ -155,8 +156,8 @@ module Z3
|
|
155
156
|
when ArithExpr
|
156
157
|
args[0].sort.new(LowLevel.mk_add(args))
|
157
158
|
when BitvecExpr
|
158
|
-
args.inject do |a,b|
|
159
|
-
a.sort.new(LowLevel.mk_bvadd(a,b))
|
159
|
+
args.inject do |a, b|
|
160
|
+
a.sort.new(LowLevel.mk_bvadd(a, b))
|
160
161
|
end
|
161
162
|
else
|
162
163
|
raise Z3::Exception, "Can't perform logic operations on #{args[0].sort} exprs, only Int/Real/Bitvec"
|
@@ -169,8 +170,8 @@ module Z3
|
|
169
170
|
when ArithExpr
|
170
171
|
args[0].sort.new(LowLevel.mk_sub(args))
|
171
172
|
when BitvecExpr
|
172
|
-
args.inject do |a,b|
|
173
|
-
a.sort.new(LowLevel.mk_bvsub(a,b))
|
173
|
+
args.inject do |a, b|
|
174
|
+
a.sort.new(LowLevel.mk_bvsub(a, b))
|
174
175
|
end
|
175
176
|
else
|
176
177
|
raise Z3::Exception, "Can't perform logic operations on #{args[0].sort} values, only Int/Real/Bitvec"
|
@@ -183,8 +184,8 @@ module Z3
|
|
183
184
|
when ArithExpr
|
184
185
|
args[0].sort.new(LowLevel.mk_mul(args))
|
185
186
|
when BitvecExpr
|
186
|
-
args.inject do |a,b|
|
187
|
-
a.sort.new(LowLevel.mk_bvmul(a,b))
|
187
|
+
args.inject do |a, b|
|
188
|
+
a.sort.new(LowLevel.mk_bvmul(a, b))
|
188
189
|
end
|
189
190
|
else
|
190
191
|
raise Z3::Exception, "Can't perform logic operations on #{args[0].sort} values, only Int/Real/Bitvec"
|
data/lib/z3/low_level.rb
CHANGED
@@ -9,7 +9,7 @@ module Z3
|
|
9
9
|
b = FFI::MemoryPointer.new(:int)
|
10
10
|
c = FFI::MemoryPointer.new(:int)
|
11
11
|
d = FFI::MemoryPointer.new(:int)
|
12
|
-
Z3::VeryLowLevel.Z3_get_version(a,b,c,d)
|
12
|
+
Z3::VeryLowLevel.Z3_get_version(a, b, c, d)
|
13
13
|
[a.get_uint(0), b.get_uint(0), c.get_uint(0), d.get_uint(0)]
|
14
14
|
end
|
15
15
|
|
@@ -63,6 +63,10 @@ module Z3
|
|
63
63
|
Z3::VeryLowLevel.Z3_mk_set_intersect(_ctx_pointer, asts.size, asts_vector(asts))
|
64
64
|
end
|
65
65
|
|
66
|
+
def optimize_check(optimize, asts)
|
67
|
+
Z3::VeryLowLevel.Z3_optimize_check(_ctx_pointer, optimize._optimize, asts.size, asts_vector(asts))
|
68
|
+
end
|
69
|
+
|
66
70
|
# Should be private
|
67
71
|
|
68
72
|
def unpack_ast_vector(_ast_vector)
|
@@ -96,7 +100,7 @@ module Z3
|
|
96
100
|
private
|
97
101
|
|
98
102
|
def asts_vector(args)
|
99
|
-
raise if args.empty?
|
103
|
+
# raise if args.empty?
|
100
104
|
c_args = FFI::MemoryPointer.new(:pointer, args.size)
|
101
105
|
c_args.write_array_of_pointer args.map(&:_ast)
|
102
106
|
c_args
|
data/lib/z3/low_level_auto.rb
CHANGED
@@ -77,10 +77,6 @@ module Z3
|
|
77
77
|
VeryLowLevel.Z3_algebraic_sub(_ctx_pointer, ast1._ast, ast2._ast)
|
78
78
|
end
|
79
79
|
|
80
|
-
def apply_result_convert_model(apply_result, num, model) #=> :model_pointer
|
81
|
-
VeryLowLevel.Z3_apply_result_convert_model(_ctx_pointer, apply_result._apply_result, num, model._model)
|
82
|
-
end
|
83
|
-
|
84
80
|
def apply_result_dec_ref(apply_result) #=> :void
|
85
81
|
VeryLowLevel.Z3_apply_result_dec_ref(_ctx_pointer, apply_result._apply_result)
|
86
82
|
end
|
@@ -213,6 +209,10 @@ module Z3
|
|
213
209
|
VeryLowLevel.Z3_enable_trace(str)
|
214
210
|
end
|
215
211
|
|
212
|
+
def eval_smtlib2_string(str) #=> :string
|
213
|
+
VeryLowLevel.Z3_eval_smtlib2_string(_ctx_pointer, str)
|
214
|
+
end
|
215
|
+
|
216
216
|
def finalize_memory #=> :void
|
217
217
|
VeryLowLevel.Z3_finalize_memory()
|
218
218
|
end
|
@@ -581,10 +581,6 @@ module Z3
|
|
581
581
|
VeryLowLevel.Z3_get_index_value(_ctx_pointer, ast._ast)
|
582
582
|
end
|
583
583
|
|
584
|
-
def get_interpolant(ast1, ast2, params) #=> :ast_vector_pointer
|
585
|
-
VeryLowLevel.Z3_get_interpolant(_ctx_pointer, ast1._ast, ast2._ast, params._params)
|
586
|
-
end
|
587
|
-
|
588
584
|
def get_num_probes #=> :uint
|
589
585
|
VeryLowLevel.Z3_get_num_probes(_ctx_pointer)
|
590
586
|
end
|
@@ -605,10 +601,6 @@ module Z3
|
|
605
601
|
VeryLowLevel.Z3_get_numerator(_ctx_pointer, ast._ast)
|
606
602
|
end
|
607
603
|
|
608
|
-
def get_parser_error #=> :string
|
609
|
-
VeryLowLevel.Z3_get_parser_error(_ctx_pointer)
|
610
|
-
end
|
611
|
-
|
612
604
|
def get_pattern(pattern, num) #=> :ast_pointer
|
613
605
|
VeryLowLevel.Z3_get_pattern(_ctx_pointer, pattern._ast, num)
|
614
606
|
end
|
@@ -725,6 +717,10 @@ module Z3
|
|
725
717
|
VeryLowLevel.Z3_goal_assert(_ctx_pointer, goal._goal, ast._ast)
|
726
718
|
end
|
727
719
|
|
720
|
+
def goal_convert_model(goal, model) #=> :model_pointer
|
721
|
+
VeryLowLevel.Z3_goal_convert_model(_ctx_pointer, goal._goal, model._model)
|
722
|
+
end
|
723
|
+
|
728
724
|
def goal_dec_ref(goal) #=> :void
|
729
725
|
VeryLowLevel.Z3_goal_dec_ref(_ctx_pointer, goal._goal)
|
730
726
|
end
|
@@ -769,6 +765,10 @@ module Z3
|
|
769
765
|
VeryLowLevel.Z3_goal_size(_ctx_pointer, goal._goal)
|
770
766
|
end
|
771
767
|
|
768
|
+
def goal_to_dimacs_string(goal) #=> :string
|
769
|
+
VeryLowLevel.Z3_goal_to_dimacs_string(_ctx_pointer, goal._goal)
|
770
|
+
end
|
771
|
+
|
772
772
|
def goal_to_string(goal) #=> :string
|
773
773
|
VeryLowLevel.Z3_goal_to_string(_ctx_pointer, goal._goal)
|
774
774
|
end
|
@@ -781,10 +781,6 @@ module Z3
|
|
781
781
|
VeryLowLevel.Z3_inc_ref(_ctx_pointer, ast._ast)
|
782
782
|
end
|
783
783
|
|
784
|
-
def interpolation_profile #=> :string
|
785
|
-
VeryLowLevel.Z3_interpolation_profile(_ctx_pointer)
|
786
|
-
end
|
787
|
-
|
788
784
|
def interrupt #=> :void
|
789
785
|
VeryLowLevel.Z3_interrupt(_ctx_pointer)
|
790
786
|
end
|
@@ -813,10 +809,18 @@ module Z3
|
|
813
809
|
VeryLowLevel.Z3_is_eq_sort(_ctx_pointer, sort1._ast, sort2._ast)
|
814
810
|
end
|
815
811
|
|
812
|
+
def is_lambda(ast) #=> :bool
|
813
|
+
VeryLowLevel.Z3_is_lambda(_ctx_pointer, ast._ast)
|
814
|
+
end
|
815
|
+
|
816
816
|
def is_numeral_ast(ast) #=> :bool
|
817
817
|
VeryLowLevel.Z3_is_numeral_ast(_ctx_pointer, ast._ast)
|
818
818
|
end
|
819
819
|
|
820
|
+
def is_quantifier_exists(ast) #=> :bool
|
821
|
+
VeryLowLevel.Z3_is_quantifier_exists(_ctx_pointer, ast._ast)
|
822
|
+
end
|
823
|
+
|
820
824
|
def is_quantifier_forall(ast) #=> :bool
|
821
825
|
VeryLowLevel.Z3_is_quantifier_forall(_ctx_pointer, ast._ast)
|
822
826
|
end
|
@@ -1349,14 +1353,6 @@ module Z3
|
|
1349
1353
|
VeryLowLevel.Z3_mk_int_to_str(_ctx_pointer, ast._ast)
|
1350
1354
|
end
|
1351
1355
|
|
1352
|
-
def mk_interpolant(ast) #=> :ast_pointer
|
1353
|
-
VeryLowLevel.Z3_mk_interpolant(_ctx_pointer, ast._ast)
|
1354
|
-
end
|
1355
|
-
|
1356
|
-
def mk_interpolation_context(config) #=> :ctx_pointer
|
1357
|
-
VeryLowLevel.Z3_mk_interpolation_context(config._config)
|
1358
|
-
end
|
1359
|
-
|
1360
1356
|
def mk_is_int(ast) #=> :ast_pointer
|
1361
1357
|
VeryLowLevel.Z3_mk_is_int(_ctx_pointer, ast._ast)
|
1362
1358
|
end
|
@@ -1605,6 +1601,10 @@ module Z3
|
|
1605
1601
|
VeryLowLevel.Z3_model_to_string(_ctx_pointer, model._model)
|
1606
1602
|
end
|
1607
1603
|
|
1604
|
+
def model_translate(model, context) #=> :model_pointer
|
1605
|
+
VeryLowLevel.Z3_model_translate(_ctx_pointer, model._model, context._context)
|
1606
|
+
end
|
1607
|
+
|
1608
1608
|
def optimize_assert(optimize, ast) #=> :void
|
1609
1609
|
VeryLowLevel.Z3_optimize_assert(_ctx_pointer, optimize._optimize, ast._ast)
|
1610
1610
|
end
|
@@ -1613,10 +1613,6 @@ module Z3
|
|
1613
1613
|
VeryLowLevel.Z3_optimize_assert_soft(_ctx_pointer, optimize._optimize, ast._ast, str, sym)
|
1614
1614
|
end
|
1615
1615
|
|
1616
|
-
def optimize_check(optimize) #=> :int
|
1617
|
-
VeryLowLevel.Z3_optimize_check(_ctx_pointer, optimize._optimize)
|
1618
|
-
end
|
1619
|
-
|
1620
1616
|
def optimize_dec_ref(optimize) #=> :void
|
1621
1617
|
VeryLowLevel.Z3_optimize_dec_ref(_ctx_pointer, optimize._optimize)
|
1622
1618
|
end
|
@@ -1665,6 +1661,10 @@ module Z3
|
|
1665
1661
|
VeryLowLevel.Z3_optimize_get_statistics(_ctx_pointer, optimize._optimize)
|
1666
1662
|
end
|
1667
1663
|
|
1664
|
+
def optimize_get_unsat_core(optimize) #=> :ast_vector_pointer
|
1665
|
+
VeryLowLevel.Z3_optimize_get_unsat_core(_ctx_pointer, optimize._optimize)
|
1666
|
+
end
|
1667
|
+
|
1668
1668
|
def optimize_get_upper(optimize, num) #=> :ast_pointer
|
1669
1669
|
VeryLowLevel.Z3_optimize_get_upper(_ctx_pointer, optimize._optimize, num)
|
1670
1670
|
end
|
@@ -1941,6 +1941,10 @@ module Z3
|
|
1941
1941
|
VeryLowLevel.Z3_solver_check(_ctx_pointer, solver._solver)
|
1942
1942
|
end
|
1943
1943
|
|
1944
|
+
def solver_cube(solver, ast_vector, num) #=> :ast_vector_pointer
|
1945
|
+
VeryLowLevel.Z3_solver_cube(_ctx_pointer, solver._solver, ast_vector, num)
|
1946
|
+
end
|
1947
|
+
|
1944
1948
|
def solver_dec_ref(solver) #=> :void
|
1945
1949
|
VeryLowLevel.Z3_solver_dec_ref(_ctx_pointer, solver._solver)
|
1946
1950
|
end
|
@@ -1969,6 +1973,10 @@ module Z3
|
|
1969
1973
|
VeryLowLevel.Z3_solver_get_model(_ctx_pointer, solver._solver)
|
1970
1974
|
end
|
1971
1975
|
|
1976
|
+
def solver_get_non_units(solver) #=> :ast_vector_pointer
|
1977
|
+
VeryLowLevel.Z3_solver_get_non_units(_ctx_pointer, solver._solver)
|
1978
|
+
end
|
1979
|
+
|
1972
1980
|
def solver_get_num_scopes(solver) #=> :uint
|
1973
1981
|
VeryLowLevel.Z3_solver_get_num_scopes(_ctx_pointer, solver._solver)
|
1974
1982
|
end
|
@@ -1989,10 +1997,18 @@ module Z3
|
|
1989
1997
|
VeryLowLevel.Z3_solver_get_statistics(_ctx_pointer, solver._solver)
|
1990
1998
|
end
|
1991
1999
|
|
2000
|
+
def solver_get_units(solver) #=> :ast_vector_pointer
|
2001
|
+
VeryLowLevel.Z3_solver_get_units(_ctx_pointer, solver._solver)
|
2002
|
+
end
|
2003
|
+
|
1992
2004
|
def solver_get_unsat_core(solver) #=> :ast_vector_pointer
|
1993
2005
|
VeryLowLevel.Z3_solver_get_unsat_core(_ctx_pointer, solver._solver)
|
1994
2006
|
end
|
1995
2007
|
|
2008
|
+
def solver_import_model_converter(solver1, solver2) #=> :void
|
2009
|
+
VeryLowLevel.Z3_solver_import_model_converter(_ctx_pointer, solver1._solver, solver2._solver)
|
2010
|
+
end
|
2011
|
+
|
1996
2012
|
def solver_inc_ref(solver) #=> :void
|
1997
2013
|
VeryLowLevel.Z3_solver_inc_ref(_ctx_pointer, solver._solver)
|
1998
2014
|
end
|
data/lib/z3/optimize.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Z3
|
2
2
|
class Optimize
|
3
3
|
attr_reader :_optimize
|
4
|
+
|
4
5
|
def initialize
|
5
6
|
@_optimize = LowLevel.mk_optimize
|
6
7
|
LowLevel.optimize_inc_ref(self)
|
@@ -27,9 +28,9 @@ module Z3
|
|
27
28
|
LowLevel.optimize_assert_soft(self, ast)
|
28
29
|
end
|
29
30
|
|
30
|
-
def check
|
31
|
+
def check(*args)
|
31
32
|
reset_model!
|
32
|
-
result = check_sat_results(LowLevel.optimize_check(self))
|
33
|
+
result = check_sat_results(LowLevel.optimize_check(self, args))
|
33
34
|
@has_model = true if result == :sat
|
34
35
|
result
|
35
36
|
end
|
@@ -81,7 +82,7 @@ module Z3
|
|
81
82
|
case check
|
82
83
|
when :sat
|
83
84
|
puts "Counterexample exists"
|
84
|
-
model.each do |n,v|
|
85
|
+
model.each do |n, v|
|
85
86
|
puts "* #{n} = #{v}"
|
86
87
|
end
|
87
88
|
when :unknown
|
@@ -95,7 +96,6 @@ module Z3
|
|
95
96
|
pop
|
96
97
|
end
|
97
98
|
|
98
|
-
|
99
99
|
def reason_unknown
|
100
100
|
LowLevel.optimize_get_reason_unknown(self)
|
101
101
|
end
|
data/lib/z3/very_low_level.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# Seriously do not use this directly in your code
|
2
|
-
|
3
|
-
require 'ffi'
|
2
|
+
require "ffi"
|
4
3
|
|
5
4
|
module Z3
|
6
5
|
module VeryLowLevel
|
@@ -10,8 +9,7 @@ module Z3
|
|
10
9
|
class << self
|
11
10
|
# Aliases defined just to make APIs below look nicer
|
12
11
|
def attach_function(name, arg_types, return_type)
|
13
|
-
|
14
|
-
arg_types = arg_types.map{|t| map_type(t)}
|
12
|
+
arg_types = arg_types.map { |t| map_type(t) }
|
15
13
|
return_type = map_type(return_type)
|
16
14
|
super(name, arg_types, return_type)
|
17
15
|
end
|
@@ -40,5 +38,6 @@ module Z3
|
|
40
38
|
attach_function :Z3_mk_set_union, [:ctx_pointer, :int, :pointer], :ast_pointer
|
41
39
|
attach_function :Z3_mk_set_intersect, [:ctx_pointer, :int, :pointer], :ast_pointer
|
42
40
|
attach_function :Z3_mk_distinct, [:ctx_pointer, :int, :pointer], :ast_pointer
|
41
|
+
attach_function :Z3_optimize_check, [:ctx_pointer, :optimize_pointer, :int, :pointer], :int
|
43
42
|
end
|
44
43
|
end
|
@@ -19,7 +19,6 @@ module Z3
|
|
19
19
|
attach_function :Z3_algebraic_root, [:ctx_pointer, :ast_pointer, :uint], :ast_pointer
|
20
20
|
attach_function :Z3_algebraic_sign, [:ctx_pointer, :ast_pointer], :int
|
21
21
|
attach_function :Z3_algebraic_sub, [:ctx_pointer, :ast_pointer, :ast_pointer], :ast_pointer
|
22
|
-
attach_function :Z3_apply_result_convert_model, [:ctx_pointer, :apply_result_pointer, :uint, :model_pointer], :model_pointer
|
23
22
|
attach_function :Z3_apply_result_dec_ref, [:ctx_pointer, :apply_result_pointer], :void
|
24
23
|
attach_function :Z3_apply_result_get_num_subgoals, [:ctx_pointer, :apply_result_pointer], :uint
|
25
24
|
attach_function :Z3_apply_result_get_subgoal, [:ctx_pointer, :apply_result_pointer, :uint], :goal_pointer
|
@@ -53,6 +52,7 @@ module Z3
|
|
53
52
|
attach_function :Z3_del_context, [:ctx_pointer], :void
|
54
53
|
attach_function :Z3_disable_trace, [:string], :void
|
55
54
|
attach_function :Z3_enable_trace, [:string], :void
|
55
|
+
attach_function :Z3_eval_smtlib2_string, [:ctx_pointer, :string], :string
|
56
56
|
attach_function :Z3_finalize_memory, [], :void
|
57
57
|
attach_function :Z3_fixedpoint_add_cover, [:ctx_pointer, :fixedpoint_pointer, :int, :func_decl_pointer, :ast_pointer], :void
|
58
58
|
attach_function :Z3_fixedpoint_add_invariant, [:ctx_pointer, :fixedpoint_pointer, :func_decl_pointer, :ast_pointer], :void
|
@@ -145,13 +145,11 @@ module Z3
|
|
145
145
|
attach_function :Z3_get_full_version, [], :string
|
146
146
|
attach_function :Z3_get_func_decl_id, [:ctx_pointer, :func_decl_pointer], :uint
|
147
147
|
attach_function :Z3_get_index_value, [:ctx_pointer, :ast_pointer], :uint
|
148
|
-
attach_function :Z3_get_interpolant, [:ctx_pointer, :ast_pointer, :ast_pointer, :params_pointer], :ast_vector_pointer
|
149
148
|
attach_function :Z3_get_num_probes, [:ctx_pointer], :uint
|
150
149
|
attach_function :Z3_get_num_tactics, [:ctx_pointer], :uint
|
151
150
|
attach_function :Z3_get_numeral_decimal_string, [:ctx_pointer, :ast_pointer, :uint], :string
|
152
151
|
attach_function :Z3_get_numeral_string, [:ctx_pointer, :ast_pointer], :string
|
153
152
|
attach_function :Z3_get_numerator, [:ctx_pointer, :ast_pointer], :ast_pointer
|
154
|
-
attach_function :Z3_get_parser_error, [:ctx_pointer], :string
|
155
153
|
attach_function :Z3_get_pattern, [:ctx_pointer, :pattern_pointer, :uint], :ast_pointer
|
156
154
|
attach_function :Z3_get_pattern_num_terms, [:ctx_pointer, :pattern_pointer], :uint
|
157
155
|
attach_function :Z3_get_probe_name, [:ctx_pointer, :uint], :string
|
@@ -181,6 +179,7 @@ module Z3
|
|
181
179
|
attach_function :Z3_global_param_reset_all, [], :void
|
182
180
|
attach_function :Z3_global_param_set, [:string, :string], :void
|
183
181
|
attach_function :Z3_goal_assert, [:ctx_pointer, :goal_pointer, :ast_pointer], :void
|
182
|
+
attach_function :Z3_goal_convert_model, [:ctx_pointer, :goal_pointer, :model_pointer], :model_pointer
|
184
183
|
attach_function :Z3_goal_dec_ref, [:ctx_pointer, :goal_pointer], :void
|
185
184
|
attach_function :Z3_goal_depth, [:ctx_pointer, :goal_pointer], :uint
|
186
185
|
attach_function :Z3_goal_formula, [:ctx_pointer, :goal_pointer, :uint], :ast_pointer
|
@@ -192,10 +191,10 @@ module Z3
|
|
192
191
|
attach_function :Z3_goal_precision, [:ctx_pointer, :goal_pointer], :uint
|
193
192
|
attach_function :Z3_goal_reset, [:ctx_pointer, :goal_pointer], :void
|
194
193
|
attach_function :Z3_goal_size, [:ctx_pointer, :goal_pointer], :uint
|
194
|
+
attach_function :Z3_goal_to_dimacs_string, [:ctx_pointer, :goal_pointer], :string
|
195
195
|
attach_function :Z3_goal_to_string, [:ctx_pointer, :goal_pointer], :string
|
196
196
|
attach_function :Z3_goal_translate, [:ctx_pointer, :goal_pointer, :ctx_pointer], :goal_pointer
|
197
197
|
attach_function :Z3_inc_ref, [:ctx_pointer, :ast_pointer], :void
|
198
|
-
attach_function :Z3_interpolation_profile, [:ctx_pointer], :string
|
199
198
|
attach_function :Z3_interrupt, [:ctx_pointer], :void
|
200
199
|
attach_function :Z3_is_algebraic_number, [:ctx_pointer, :ast_pointer], :bool
|
201
200
|
attach_function :Z3_is_app, [:ctx_pointer, :ast_pointer], :bool
|
@@ -203,7 +202,9 @@ module Z3
|
|
203
202
|
attach_function :Z3_is_eq_ast, [:ctx_pointer, :ast_pointer, :ast_pointer], :bool
|
204
203
|
attach_function :Z3_is_eq_func_decl, [:ctx_pointer, :func_decl_pointer, :func_decl_pointer], :bool
|
205
204
|
attach_function :Z3_is_eq_sort, [:ctx_pointer, :sort_pointer, :sort_pointer], :bool
|
205
|
+
attach_function :Z3_is_lambda, [:ctx_pointer, :ast_pointer], :bool
|
206
206
|
attach_function :Z3_is_numeral_ast, [:ctx_pointer, :ast_pointer], :bool
|
207
|
+
attach_function :Z3_is_quantifier_exists, [:ctx_pointer, :ast_pointer], :bool
|
207
208
|
attach_function :Z3_is_quantifier_forall, [:ctx_pointer, :ast_pointer], :bool
|
208
209
|
attach_function :Z3_is_well_sorted, [:ctx_pointer, :ast_pointer], :bool
|
209
210
|
attach_function :Z3_mk_array_default, [:ctx_pointer, :ast_pointer], :ast_pointer
|
@@ -337,8 +338,6 @@ module Z3
|
|
337
338
|
attach_function :Z3_mk_int_sort, [:ctx_pointer], :sort_pointer
|
338
339
|
attach_function :Z3_mk_int_symbol, [:ctx_pointer, :int], :symbol_pointer
|
339
340
|
attach_function :Z3_mk_int_to_str, [:ctx_pointer, :ast_pointer], :ast_pointer
|
340
|
-
attach_function :Z3_mk_interpolant, [:ctx_pointer, :ast_pointer], :ast_pointer
|
341
|
-
attach_function :Z3_mk_interpolation_context, [:config_pointer], :ctx_pointer
|
342
341
|
attach_function :Z3_mk_is_int, [:ctx_pointer, :ast_pointer], :ast_pointer
|
343
342
|
attach_function :Z3_mk_ite, [:ctx_pointer, :ast_pointer, :ast_pointer, :ast_pointer], :ast_pointer
|
344
343
|
attach_function :Z3_mk_le, [:ctx_pointer, :ast_pointer, :ast_pointer], :ast_pointer
|
@@ -401,9 +400,9 @@ module Z3
|
|
401
400
|
attach_function :Z3_model_has_interp, [:ctx_pointer, :model_pointer, :func_decl_pointer], :bool
|
402
401
|
attach_function :Z3_model_inc_ref, [:ctx_pointer, :model_pointer], :void
|
403
402
|
attach_function :Z3_model_to_string, [:ctx_pointer, :model_pointer], :string
|
403
|
+
attach_function :Z3_model_translate, [:ctx_pointer, :model_pointer, :ctx_pointer], :model_pointer
|
404
404
|
attach_function :Z3_optimize_assert, [:ctx_pointer, :optimize_pointer, :ast_pointer], :void
|
405
405
|
attach_function :Z3_optimize_assert_soft, [:ctx_pointer, :optimize_pointer, :ast_pointer, :string, :symbol_pointer], :uint
|
406
|
-
attach_function :Z3_optimize_check, [:ctx_pointer, :optimize_pointer], :int
|
407
406
|
attach_function :Z3_optimize_dec_ref, [:ctx_pointer, :optimize_pointer], :void
|
408
407
|
attach_function :Z3_optimize_from_file, [:ctx_pointer, :optimize_pointer, :string], :void
|
409
408
|
attach_function :Z3_optimize_from_string, [:ctx_pointer, :optimize_pointer, :string], :void
|
@@ -416,6 +415,7 @@ module Z3
|
|
416
415
|
attach_function :Z3_optimize_get_param_descrs, [:ctx_pointer, :optimize_pointer], :param_descrs_pointer
|
417
416
|
attach_function :Z3_optimize_get_reason_unknown, [:ctx_pointer, :optimize_pointer], :string
|
418
417
|
attach_function :Z3_optimize_get_statistics, [:ctx_pointer, :optimize_pointer], :stats_pointer
|
418
|
+
attach_function :Z3_optimize_get_unsat_core, [:ctx_pointer, :optimize_pointer], :ast_vector_pointer
|
419
419
|
attach_function :Z3_optimize_get_upper, [:ctx_pointer, :optimize_pointer, :uint], :ast_pointer
|
420
420
|
attach_function :Z3_optimize_get_upper_as_vector, [:ctx_pointer, :optimize_pointer, :uint], :ast_vector_pointer
|
421
421
|
attach_function :Z3_optimize_inc_ref, [:ctx_pointer, :optimize_pointer], :void
|
@@ -485,6 +485,7 @@ module Z3
|
|
485
485
|
attach_function :Z3_solver_assert, [:ctx_pointer, :solver_pointer, :ast_pointer], :void
|
486
486
|
attach_function :Z3_solver_assert_and_track, [:ctx_pointer, :solver_pointer, :ast_pointer, :ast_pointer], :void
|
487
487
|
attach_function :Z3_solver_check, [:ctx_pointer, :solver_pointer], :int
|
488
|
+
attach_function :Z3_solver_cube, [:ctx_pointer, :solver_pointer, :ast_vector_pointer, :uint], :ast_vector_pointer
|
488
489
|
attach_function :Z3_solver_dec_ref, [:ctx_pointer, :solver_pointer], :void
|
489
490
|
attach_function :Z3_solver_from_file, [:ctx_pointer, :solver_pointer, :string], :void
|
490
491
|
attach_function :Z3_solver_from_string, [:ctx_pointer, :solver_pointer, :string], :void
|
@@ -492,12 +493,15 @@ module Z3
|
|
492
493
|
attach_function :Z3_solver_get_consequences, [:ctx_pointer, :solver_pointer, :ast_vector_pointer, :ast_vector_pointer, :ast_vector_pointer], :int
|
493
494
|
attach_function :Z3_solver_get_help, [:ctx_pointer, :solver_pointer], :string
|
494
495
|
attach_function :Z3_solver_get_model, [:ctx_pointer, :solver_pointer], :model_pointer
|
496
|
+
attach_function :Z3_solver_get_non_units, [:ctx_pointer, :solver_pointer], :ast_vector_pointer
|
495
497
|
attach_function :Z3_solver_get_num_scopes, [:ctx_pointer, :solver_pointer], :uint
|
496
498
|
attach_function :Z3_solver_get_param_descrs, [:ctx_pointer, :solver_pointer], :param_descrs_pointer
|
497
499
|
attach_function :Z3_solver_get_proof, [:ctx_pointer, :solver_pointer], :ast_pointer
|
498
500
|
attach_function :Z3_solver_get_reason_unknown, [:ctx_pointer, :solver_pointer], :string
|
499
501
|
attach_function :Z3_solver_get_statistics, [:ctx_pointer, :solver_pointer], :stats_pointer
|
502
|
+
attach_function :Z3_solver_get_units, [:ctx_pointer, :solver_pointer], :ast_vector_pointer
|
500
503
|
attach_function :Z3_solver_get_unsat_core, [:ctx_pointer, :solver_pointer], :ast_vector_pointer
|
504
|
+
attach_function :Z3_solver_import_model_converter, [:ctx_pointer, :solver_pointer, :solver_pointer], :void
|
501
505
|
attach_function :Z3_solver_inc_ref, [:ctx_pointer, :solver_pointer], :void
|
502
506
|
attach_function :Z3_solver_pop, [:ctx_pointer, :solver_pointer, :uint], :void
|
503
507
|
attach_function :Z3_solver_push, [:ctx_pointer, :solver_pointer], :void
|
@@ -1,19 +1,11 @@
|
|
1
|
+
# This puzzle is ambiguous and different z3 versions return different result,
|
2
|
+
# so just checking that it doesn't crash
|
3
|
+
|
1
4
|
describe "OneOfUs" do
|
2
|
-
|
3
|
-
expect("oneofus").to have_output <<EOF
|
4
|
-
grey Triangle grey Circle grey Triangle
|
5
|
-
purple Square grey Triangle purple Triangle
|
6
|
-
grey Triangle grey Square grey Triangle
|
5
|
+
let(:binary) { Pathname(__dir__) + "../../examples/oneofus" }
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
Click 3: 1,2 - grey Square
|
12
|
-
Click 4: 1,1 - grey Triangle
|
13
|
-
Click 5: 1,0 - grey Circle
|
14
|
-
Click 6: 2,0 - grey Triangle
|
15
|
-
Click 7: 0,0 - grey Triangle
|
16
|
-
Click 8: 0,2 - grey Triangle
|
17
|
-
EOF
|
7
|
+
it do
|
8
|
+
output = `#{binary}`.chomp
|
9
|
+
expect(output.lines.size).to eq(13)
|
18
10
|
end
|
19
11
|
end
|
data/spec/optimize_spec.rb
CHANGED
@@ -43,14 +43,14 @@ module Z3
|
|
43
43
|
# This is a very simple example of unknown satisfiablity
|
44
44
|
# so we might need more complex one in the future
|
45
45
|
# Unlike Z3::Solver, this is unknown even 4.6.0
|
46
|
-
it "
|
46
|
+
it "unknown satisfiability" do
|
47
47
|
optimize.assert a**3 == a
|
48
48
|
expect(optimize.check).to eq(:unknown)
|
49
49
|
expect{optimize.satisfiable?}.to raise_error("Satisfiability unknown")
|
50
50
|
expect{optimize.unsatisfiable?}.to raise_error("Satisfiability unknown")
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "unknown satisfiability" do
|
54
54
|
optimize.assert a**a == a
|
55
55
|
expect(optimize.check).to eq(:unknown)
|
56
56
|
expect{optimize.satisfiable?}.to raise_error("Satisfiability unknown")
|
@@ -65,7 +65,7 @@ module Z3
|
|
65
65
|
expect(optimize.model[a].to_i).to eq 9
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
68
|
+
it "minimize" do
|
69
69
|
optimize.assert a > 0
|
70
70
|
optimize.assert a < 10
|
71
71
|
optimize.minimize a
|
data/spec/set_expr_spec.rb
CHANGED
@@ -25,9 +25,9 @@ module Z3
|
|
25
25
|
b.include?(3),
|
26
26
|
c == a.union(b),
|
27
27
|
]).to have_solution(
|
28
|
-
a => "
|
29
|
-
b => "
|
30
|
-
c => "
|
28
|
+
a => "(lambda ((x!1 Int)) (or (= x!1 1) (= x!1 2)))",
|
29
|
+
b => "(lambda ((x!1 Int)) (or (= x!1 3) (= x!1 2)))",
|
30
|
+
c => "(lambda ((x!1 Int)) (or (= x!1 1) (= x!1 3) (= x!1 2)))",
|
31
31
|
)
|
32
32
|
end
|
33
33
|
|
@@ -41,9 +41,9 @@ module Z3
|
|
41
41
|
b.include?(3),
|
42
42
|
c == a.difference(b),
|
43
43
|
]).to have_solution(
|
44
|
-
a => "
|
45
|
-
b => "
|
46
|
-
c => "
|
44
|
+
a => "(lambda ((x!1 Int)) (or (= x!1 1) (= x!1 2)))",
|
45
|
+
b => "(lambda ((x!1 Int)) (not (= x!1 1)))",
|
46
|
+
c => "(lambda ((x!1 Int)) (= x!1 1))",
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
@@ -55,9 +55,9 @@ module Z3
|
|
55
55
|
b.include?(3),
|
56
56
|
c == a.intersection(b),
|
57
57
|
]).to have_solution(
|
58
|
-
a => "
|
59
|
-
b => "
|
60
|
-
c => "
|
58
|
+
a => "(lambda ((x!1 Int)) (or (= x!1 1) (= x!1 2)))",
|
59
|
+
b => "(lambda ((x!1 Int)) (or (= x!1 3) (= x!1 2)))",
|
60
|
+
c => "(lambda ((x!1 Int)) (or (= x!1 1) (= x!1 3) (= x!1 2)))",
|
61
61
|
)
|
62
62
|
end
|
63
63
|
end
|
data/spec/solver_spec.rb
CHANGED
@@ -45,14 +45,14 @@ module Z3
|
|
45
45
|
# so we might need more complex one in the future
|
46
46
|
# This is now satisfiable in 4.6.0
|
47
47
|
if Z3.version >= "4.6"
|
48
|
-
it "
|
48
|
+
it "unknown satisfiability (until 4.6 fix)" do
|
49
49
|
solver.assert a**3 == a
|
50
50
|
expect(solver.check).to eq(:sat)
|
51
51
|
expect(solver).to be_satisfiable
|
52
52
|
expect(solver).to_not be_unsatisfiable
|
53
53
|
end
|
54
54
|
else
|
55
|
-
it "
|
55
|
+
it "unknown satisfiability (until 4.6 fix)" do
|
56
56
|
solver.assert a**3 == a
|
57
57
|
expect(solver.check).to eq(:unknown)
|
58
58
|
expect{solver.satisfiable?}.to raise_error("Satisfiability unknown")
|
@@ -60,7 +60,7 @@ module Z3
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
63
|
+
it "unknown satisfiability" do
|
64
64
|
solver.assert a**a == a
|
65
65
|
expect(solver.check).to eq(:unknown)
|
66
66
|
expect{solver.satisfiable?}.to raise_error("Satisfiability unknown")
|
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.
|
4
|
+
version: 0.0.20181126
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomasz Wegrzanowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -30,70 +30,70 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '12'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '12'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.8'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: simplecov
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '0.16'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '0.16'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: regexp_parser
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '1.3'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: ffi
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.9'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1.9'
|
97
97
|
description: Ruby bindings for Z3 Constraint Solver
|
98
98
|
email: Tomasz.Wegrzanowski@gmail.com
|
99
99
|
executables: []
|
@@ -267,9 +267,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
267
|
- !ruby/object:Gem::Version
|
268
268
|
version: '0'
|
269
269
|
requirements:
|
270
|
-
- z3 library
|
270
|
+
- z3 library (4.8+)
|
271
271
|
rubyforge_project:
|
272
|
-
rubygems_version: 2.7.
|
272
|
+
rubygems_version: 2.7.6
|
273
273
|
signing_key:
|
274
274
|
specification_version: 4
|
275
275
|
summary: Z3 Constraint Solver
|