2

Notice in the new versions of Z3, the model only prints the arguments to the function that have a value other than the default. Is there a way to return to the old method of receiving all instances, including those that map to the default value?

Code:

import z3

config_init = z3.Function('config_init', z3.IntSort(), z3.IntSort(), z3.IntSort(), z3.IntSort())


def fooY(W, X, Y, Z):
    return config_init(W, X, Y) == Z


s = z3.Solver()
s.add(fooY(1, 2, 3, 4))
s.add(fooY(2, 3, 4, 5))
s.add(fooY(1, 2, 8, 4))
s.add(fooY(2, 3, 9, 5))

print("Z3 Version", z3.get_version())
if s.check() == z3.sat:
    mod = s.model()
    print(mod)
else:
    print('failed')
    print(s.unsat_core())

Old Z3 Output

('Z3 Version', (4L, 5L, 1L, 0L))
[config_init = [(1, 2, 3) -> 4,
                (2, 3, 4) -> 5,
                (1, 2, 8) -> 4,
                (2, 3, 9) -> 5,
                else -> 4]]

New Z3 Output

Z3 Version (4, 8, 7, 0)
[config_init = [(2, 3, 4) -> 5, (2, 3, 9) -> 5, else -> 4]]
Dana Chee
  • 21
  • 3
  • After a quick search of the code, adding: ``` z3.set_param('model.compact', False) ``` Causes the desired behavior. Hopefully this will help someone else in the future. – Dana Chee Sep 18 '21 at 21:50
  • You should add this comment as an answer and accept it so it has better visibility. It's perfectly OK to answer your own questions on stack-overflow: https://stackoverflow.com/help/self-answer – alias Sep 19 '21 at 01:01

0 Answers0