How get a a value from a Lambda expression?
up vote
3
down vote
favorite
I'm experimenting with z3 in python. I have the following model:
(set-option :produce-models true)
(set-logic QF_AUFBV )
(declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) )
(declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) )
(assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32) ) (concat (select another (_ bv1 32) ) (select another (_ bv0 32) ) ) ) ) ) ) ) )
I can load it and check that is sat. At this point how can I get an example value for a
and another
?
import z3
s = z3.Solver()
s.from_file("first.smt")
"""
s
[And(False ==
(77 == Concat(a[3], Concat(a[2], Concat(a[1], a[0])))),
False ==
(12 ==
Concat(another[3],
Concat(another[2],
Concat(another[1], another[0])))))]
"""
s.check()
"""
sat
"""
m = s.model()
m
[a = Lambda(k!0, 1), another = Lambda(k!0, 1)]
Thanks
python z3 z3py
add a comment |
up vote
3
down vote
favorite
I'm experimenting with z3 in python. I have the following model:
(set-option :produce-models true)
(set-logic QF_AUFBV )
(declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) )
(declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) )
(assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32) ) (concat (select another (_ bv1 32) ) (select another (_ bv0 32) ) ) ) ) ) ) ) )
I can load it and check that is sat. At this point how can I get an example value for a
and another
?
import z3
s = z3.Solver()
s.from_file("first.smt")
"""
s
[And(False ==
(77 == Concat(a[3], Concat(a[2], Concat(a[1], a[0])))),
False ==
(12 ==
Concat(another[3],
Concat(another[2],
Concat(another[1], another[0])))))]
"""
s.check()
"""
sat
"""
m = s.model()
m
[a = Lambda(k!0, 1), another = Lambda(k!0, 1)]
Thanks
python z3 z3py
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I'm experimenting with z3 in python. I have the following model:
(set-option :produce-models true)
(set-logic QF_AUFBV )
(declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) )
(declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) )
(assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32) ) (concat (select another (_ bv1 32) ) (select another (_ bv0 32) ) ) ) ) ) ) ) )
I can load it and check that is sat. At this point how can I get an example value for a
and another
?
import z3
s = z3.Solver()
s.from_file("first.smt")
"""
s
[And(False ==
(77 == Concat(a[3], Concat(a[2], Concat(a[1], a[0])))),
False ==
(12 ==
Concat(another[3],
Concat(another[2],
Concat(another[1], another[0])))))]
"""
s.check()
"""
sat
"""
m = s.model()
m
[a = Lambda(k!0, 1), another = Lambda(k!0, 1)]
Thanks
python z3 z3py
I'm experimenting with z3 in python. I have the following model:
(set-option :produce-models true)
(set-logic QF_AUFBV )
(declare-fun a () (Array (_ BitVec 32) (_ BitVec 8) ) )
(declare-fun another () (Array (_ BitVec 32) (_ BitVec 8) ) )
(assert (and (= false (= (_ bv77 32) (concat (select a (_ bv3 32) ) (concat (select a (_ bv2 32) ) (concat (select a (_ bv1 32) ) (select a (_ bv0 32) ) ) ) ) ) ) (= false (= (_ bv12 32) (concat (select another (_ bv3 32) ) (concat (select another (_ bv2 32) ) (concat (select another (_ bv1 32) ) (select another (_ bv0 32) ) ) ) ) ) ) ) )
I can load it and check that is sat. At this point how can I get an example value for a
and another
?
import z3
s = z3.Solver()
s.from_file("first.smt")
"""
s
[And(False ==
(77 == Concat(a[3], Concat(a[2], Concat(a[1], a[0])))),
False ==
(12 ==
Concat(another[3],
Concat(another[2],
Concat(another[1], another[0])))))]
"""
s.check()
"""
sat
"""
m = s.model()
m
[a = Lambda(k!0, 1), another = Lambda(k!0, 1)]
Thanks
python z3 z3py
python z3 z3py
edited 2 days ago
asked Nov 10 at 13:53
Alberto
1078
1078
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Z3 produces Lambda
abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:
z3.set_param('model_compress', False)
You should do this right after you import z3
.
With this, if you print the model in your program, you get:
>>> m
[a = [3 -> 1, else -> 1],
another = [1 -> 1, else -> 1],
k!0 = [3 -> 1, else -> 1],
k!1 = [1 -> 1, else -> 1]]
which should be more readable. (It's essentially saying both a
and another
are arrays that map everything to 1; though a bit convoluted.)
Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
– Alberto
2 days ago
1
On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
– Levent Erkok
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Z3 produces Lambda
abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:
z3.set_param('model_compress', False)
You should do this right after you import z3
.
With this, if you print the model in your program, you get:
>>> m
[a = [3 -> 1, else -> 1],
another = [1 -> 1, else -> 1],
k!0 = [3 -> 1, else -> 1],
k!1 = [1 -> 1, else -> 1]]
which should be more readable. (It's essentially saying both a
and another
are arrays that map everything to 1; though a bit convoluted.)
Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
– Alberto
2 days ago
1
On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
– Levent Erkok
2 days ago
add a comment |
up vote
1
down vote
accepted
Z3 produces Lambda
abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:
z3.set_param('model_compress', False)
You should do this right after you import z3
.
With this, if you print the model in your program, you get:
>>> m
[a = [3 -> 1, else -> 1],
another = [1 -> 1, else -> 1],
k!0 = [3 -> 1, else -> 1],
k!1 = [1 -> 1, else -> 1]]
which should be more readable. (It's essentially saying both a
and another
are arrays that map everything to 1; though a bit convoluted.)
Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
– Alberto
2 days ago
1
On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
– Levent Erkok
2 days ago
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Z3 produces Lambda
abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:
z3.set_param('model_compress', False)
You should do this right after you import z3
.
With this, if you print the model in your program, you get:
>>> m
[a = [3 -> 1, else -> 1],
another = [1 -> 1, else -> 1],
k!0 = [3 -> 1, else -> 1],
k!1 = [1 -> 1, else -> 1]]
which should be more readable. (It's essentially saying both a
and another
are arrays that map everything to 1; though a bit convoluted.)
Z3 produces Lambda
abstractions for arrays by default; which are useful but hard to see what's going on in a model. I'd recommend turning that off, by putting the following line in your python program:
z3.set_param('model_compress', False)
You should do this right after you import z3
.
With this, if you print the model in your program, you get:
>>> m
[a = [3 -> 1, else -> 1],
another = [1 -> 1, else -> 1],
k!0 = [3 -> 1, else -> 1],
k!1 = [1 -> 1, else -> 1]]
which should be more readable. (It's essentially saying both a
and another
are arrays that map everything to 1; though a bit convoluted.)
answered Nov 10 at 17:40
Levent Erkok
6,42611025
6,42611025
Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
– Alberto
2 days ago
1
On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
– Levent Erkok
2 days ago
add a comment |
Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
– Alberto
2 days ago
1
On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
– Levent Erkok
2 days ago
Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
– Alberto
2 days ago
Thanks for your answer, I was able to have the model in that format now. I'd ask you another clarification if possible. I edited my original question for that. Could you explain more in details the model. Thanks
– Alberto
2 days ago
1
1
On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
– Levent Erkok
2 days ago
On stack-overflow, it's always best to start a different question instead of editing the original. Also, "accepting" the answer tells others the issue is resolved; both for people having similar issues and the people trying to help others out. Comments should be reserved only for the original discussion. So, please start a new question and I'm sure someone will answer!
– Levent Erkok
2 days ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239653%2fhow-get-a-a-value-from-a-lambda-expression%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password