I'm wondering if it's possible to use named expressions to implement soft-constraints, without explicitly using manual "tracking" variables.
- In the message Soft/Hard constraints in Z3, Leonardo explains how to use auxiliary booleans to implement soft-constraints in a manual way.
- In the following message: z3 behaviour changing on request for unsat core, Leonardo says named expressions are essentially treated as implications for model finding purposes.
It's rather cumbersome to use manual tracking as described in the first message above, as it requires multiple calls to the solver (in fact 2^n
calls might be needed in the worst case to get the largest possible set of soft-constraints satisfied when we have n
soft constraints).
Would it be possible to combine these two ideas to have Z3 implement soft constraints in a much simpler way? Based on the ideas from those two messages, I naively tried the following:
(set-option :produce-models true)
(set-option :produce-unsat-cores true)
(assert (! false :named absurd))
(check-sat)
I was hoping z3 would tell me sat
since taking absurd
to be false
in a model would satisfy this contrived example; but it produced unsat
instead; which is reasonable, but not as useful..
I'd appreciate any insights you might offer; or point me to some documentation on how z3 uses named expressions in more detail. (I skimmed through the manuals but didn't see them explained in detail anywhere.)