Search code examples
pythondllz3smtz3py

How do I use the Z3Py dll?


I tried to use the Z3Py dll, but it didn't work. Here are my test programs and errors. I am very new to Python, I think I missed some important part everybody already knows.

init("z3.dll")

Traceback (most recent call last):
File "test5.py", line 1, in <module>
    init("z3.dll")

NameError: name 'init' is not defined

enter image description here

enter image description here

I also tried another way to load the dll:

import ctypes
so = ctypes.WinDLL('./z3.dll')     #for windows
print(so)
s = Solver()

<WinDLL './z3.dll', handle 10000000 at 0x10b15f0>
Traceback (most recent call last):
  File "test5.py", line 5, in <module>
    s = Solver()
NameError: name 'Solver' is not defined

enter image description here

enter image description here


Solution

  • Typically, all you have to do is import z3:

    from z3 import *
    
    s = Solver()
    x = Int("x")
    s.add(x > 5)
    s.check()
    print s.model()
    

    What happens when you run this simple script?