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

Some regression tests print different counterexamples depending on solver version #1280

Closed
brianhuffman opened this issue Sep 10, 2021 · 3 comments
Labels
test-framework For issues related to Cryptol's test framework.

Comments

@brianhuffman
Copy link
Contributor

The expected output for regression tests issue066.icry and issue093.icry includes witnesses for :sat and/or counterexample values. With z3-4.8.12, the values printed do not match the expected ones in the .stdout files.

We should modify the regression tests so that we never rely on arbitrary choices about counterexamples made by external solvers: Any :sat query should be designed to have only one possible satisfying assignment, so that the test will be deterministic.

@robdockins robdockins added the test-framework For issues related to Cryptol's test framework. label Oct 22, 2021
@LeventErkok
Copy link
Contributor

This is a common problem with SBV, and I wish there was a good way to deal with it. Constraining too much to get a "deterministic" result can render the problem rather artificial.

For the SBV backend, one idea is to use the model-validator:

Prelude Data.SBV> isSatisfiableWith z3{validateModel=True} $ \x -> x .> (10 :: SInteger)
True

So, instead of getting a counter-model, we just make sure that the result is sat, and the validateModel=True parameter makes sure the model returned by the solver really does satisfy the result.

I suspect What4 backend can implement something similar as well.

One place where this doesn't work all that well is doctests, which is common in SBV. I'm not sure if Cryptol has many of those; but something to keep in mind.

@RyanGlScott
Copy link
Contributor

I just hit this recently with Z3 4.8.14, so I'll record the diffs here for posterity's sake. For issue066, the diff is:

26c26
< g {x = 0xffffffff, y = 0x00000000} = False
---
> g {x = 0xfffff7ff, y = 0x00000800} = False
28c28
< {result = False, arg1 = {x = 0xffffffff, y = 0x00000000}}
---
> {result = False, arg1 = {x = 0xfffff7ff, y = 0x00000800}}
34c34
< h 0x00 0x00 = False
---
> h 0xfe 0x00 = False
36,37c36,37
< {result = False, arg1 = 0x00, arg2 = 0x00}
< 0x00
---
> {result = False, arg1 = 0xfe, arg2 = 0x00}
> 0xfe
40c40
< h 0x00 0x01 = True
---
> h 0x3e 0x40 = True
42c42
< {result = True, arg1 = 0x00, arg2 = 0x01}
---
> {result = True, arg1 = 0x3e, arg2 = 0x40}

And for issue093, the diff is:

33c33
< t2 0xfffffffe 0xffffffff = True
---
> t2 0x00000000 0x00000000 = True

@RyanGlScott
Copy link
Contributor

RyanGlScott commented Jan 14, 2022

Another approach, already employed in 3ea5e9e, is to simply use :set show-examples=false at the top of the .icry file and avoid printing it. This would avoid needing to overly constrain the queries, at the expense of making the test cases show less output. Then again:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test-framework For issues related to Cryptol's test framework.
Projects
None yet
Development

No branches or pull requests

4 participants