1

is there a built in method in Z3 python to convert a formula to DNF ? I would imagine applying some strategies or tactics to do so.

Also, how do I "create" an expression, for example, if I have the variables

op=Or, arg1=True, arg2=False

I want to create the expression Or(True,False) using op,arg1,arg2. I could do something like

if op.name == 'or':   Or(arg1,arg2)   
elif op.name == 'and':  And(arg1,arg2)
...

but is there a better way ?

Also, I recall there's a file in Z3 that lists the sort code, e.g. 2L is Z3_INT_SORT, what's its name ?

Vu Nguyen
  • 987
  • 1
  • 9
  • 20
  • I figured out the create an expression part, I can just simply call op(arg1,arg2) .. – Vu Nguyen Oct 23 '12 at 15:03
  • You may want a full-blown parser, depending upon what you want to accomplish, instead of switching on operation names. I didn't understand the last part: "I recall there's a file in Z3 that lists the sort code, e.g. 2L is Z3_INT_SORT, what's its name ?" What is 2L? – Taylor T. Johnson Oct 23 '12 at 16:12
  • 2L is the identifier for int sort in Z3. There's a file in Z3 that tells you what these identifiers are (e.g. 2L correspond to Z3_INT_SORT) and I want to know where that file is. – Vu Nguyen Oct 23 '12 at 21:27
  • Okay, look at the bottom of the python documentation (under the "Data" section): http://research.microsoft.com/en-us/um/redmond/projects/z3/z3.html You can see Z3_INT_SORT declared as 2 there. You might also check this source file (z3consts.py): http://z3.codeplex.com/SourceControl/changeset/view/1cfe6e477a3d#python%2fz3consts.py – Taylor T. Johnson Oct 24 '12 at 01:04

1 Answers1

0

See this answer for how to convert to DNF: How to convert a formula to Disjunctive Normal Form?

As a related note, see this answer on how to convert to CNF: Convert formula to CNF

These examples are in the SMT format, here they are in z3py: http://rise4fun.com/Z3Py/ik4

Community
  • 1
  • 1
Taylor T. Johnson
  • 2,834
  • 16
  • 17
  • the CNF method given introduces auxilary variables so not exactly what I want. I want the new formula to consist of just variables from the input formula. – Vu Nguyen Jan 24 '13 at 14:56