Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in Z3 timeout? #2354

Closed
aytey opened this issue Jun 21, 2019 · 14 comments
Closed

Regression in Z3 timeout? #2354

aytey opened this issue Jun 21, 2019 · 14 comments

Comments

@aytey
Copy link
Contributor

aytey commented Jun 21, 2019

Hello,

I have two builds of Z3:

Given a particular Z3 Python script, and when using 606754c09, I get a timeout (i.e., Z3 returns unknown). However, when using the same script under b1893f2a5, Z3 never terminates (i.e., it appears that the timeout parameter is being ignored). This timeout is set to 10000 ms.

I have captured the Z3 logs from these two runs:

The log for b1893f2a5 ends when I kill the process; the log for 606754c09 has been "artificially truncated" to match that of b1893f2a5 (i.e., after the check gives unknown, we do further work with Z3, which is irrelevant for this issue I believe).

Please let me know if there are any more details I can provide on this issue.

Cheers,

Andrew

@aytey
Copy link
Contributor Author

aytey commented Jun 21, 2019

I added the following:

z3.set_param("verbose", 10)

and it seems to "get stuck" with output like this:

(smt.delete-inactive-clauses  :num-deleted-clauses 188)
(smt.working :conflicts 245727 :agility 0.314074)
(smt.working :conflicts 247128 :agility 0.311207)
(smt.working :conflicts 248669 :agility 0.311665)
(smt.delete-inactive-clauses  :num-deleted-clauses 8888)
(smt.working :conflicts 250364 :agility 0.269951)
(smt.working :conflicts 252228 :agility 0.334213)
(smt.working :conflicts 253229 :agility 0.295869)
(smt.working :conflicts 254278 :agility 0.325157)
(smt.delete-inactive-clauses  :num-deleted-clauses 4100)
(smt.working :conflicts 255279 :agility 0.339337)
(smt.working :conflicts 256532 :agility 0.250027)
(smt.working :conflicts 257533 :agility 0.326521)

@aytey
Copy link
Contributor Author

aytey commented Jun 21, 2019

In case it is useful, I captured the verbose output from running under these two different builds:

For 606754c09, the execution ends with:

(tactic-exception "smt tactic failed to show goal to be sat/unsat timeout")

while b1893f2a5 is "stuck".

@aytey
Copy link
Contributor Author

aytey commented Jun 21, 2019

Attempted fix in #2356.

I think this is where things got broken: 48fc3d7#diff-5f65287f221a60407bf05209d67c8d9bL3734

@NikolajBjorner
Copy link
Contributor

smt.timeout should really be deprecated.
The "timeout" parameter should be settable directly. The script times out if I replace "smt.timeout" by "timeout". I don't recall why I left smt.timeout

@aytey
Copy link
Contributor Author

aytey commented Jun 21, 2019

Yep! I can confirm that -- I changed our code to use z3.set_param("timeout", ...) rather than z3.set_param("smt.timeout", ...) and it now seems to work!

NikolajBjorner added a commit that referenced this issue Jun 21, 2019
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
@yxliang01
Copy link
Contributor

yxliang01 commented Oct 12, 2019

@NikolajBjorner Hmm, from release note for 4.8.6, I saw this issue. But, the timeout option is not available in z3 4.8.6 when calling solver.set in z3py API ... If I set globally using set_param, the timeout is not so functioning. What's the replacement?

@lexbailey
Copy link

I've hit this issue too, @yxliang01 where are the release notes you mentioned? I can't see details of this bug in the main release notes file in the repo

@yxliang01
Copy link
Contributor

@yxliang01
Copy link
Contributor

No, I didn't see any issue mentioning this. That's why I commented here.

@lexbailey
Copy link

ah okay, I see now a link to this issue and a commit that removes the timeout, I see something about "datalog.timeout", not sure what that is but doesn't do what I want.
:(

@yxliang01
Copy link
Contributor

CC: @NikolajBjorner

@lexbailey
Copy link

Ah, I think I found my issue, and I'm not sure if it's a bug or intended, I was calling set on the result of Then.solver()...

t = Then(*tactics)
self.solver = t.solver()
if timeout:
    set_param("timeout", timeout*1000) # New way???
    #self.solver.set("timeout", timeout*1000) # Deprecated???

@NikolajBjorner
Copy link
Contributor

There is a gobal timeout:
timeout (unsigned int) (default: 4294967295)

The solver object also admits setting a timeout, though it isn't called solver.timeout. It is called timeout. This works for me:

from z3 import *

s = Solver()
s.set("timeout", 1)
x, y, z = Ints('x y z')
s.add(x * x > 0)
print(s.check())

Arguably, it should have been called "solver.timeout", or for usability, both options are available.
If there is no timeout on the solver object, the global timeout is used.
The timeout on the solver object overwrites the global timeout if it is set.

NikolajBjorner added a commit that referenced this issue Oct 16, 2019
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
@asymmetric
Copy link

I was doing (or-else (using-params smt :random-seed 3 :timeout 1000) (using-params smt :random-seed 2 :timeout 2000) (using-params smt :random-seed 1))) on 4.8.5 to set timeouts on the individual tactics.

Which timeout am I supposed to configure to achieve the same result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants