In Z3, the following is clearly evaluated to a maximum of 2, with the model x=true and y=true.
(declare-const x Bool)
(declare-const y Bool)
(declare-const z Bool)
(assert(= z false))
(maximize(
+
(ite (= x true) 1 0)
(ite (= y true) 1 0)
(ite (= z true) 1 0)
)
)
(check-sat)
(get-model)
How could I implement this using the C/C++ APIs? I've tried simply parsing using this:
Z3_ast parsed = Z3_parse_smtlib2_string(c,<The above Z3>,0,0,0,0,0,0);
z3::expr simpleExample(c, parsed);
s.add(simpleExample);
But it prints "unsupported \n ;maximize
".
I wouldn't mind constructing the expression manually - rather than using a constructed file. I simply didn't know which expr functions or operators to use for "maximize
".
ADDENDUM: In light of some recent answers and discussions, it seems clear that what I am requesting is not normal functionality at the moment. So, I alter the question to ask for the specific details of a way to make this work as things stand at the moment.
maximize
and check why it chokes on "unsupported ..." . You will see the fail condition for that and you might gain some insight. Alternatively you could browse the source and check what internal representationmaximize
requires and how you should reformat your code. – Quillet