-
Notifications
You must be signed in to change notification settings - Fork 3
Use generated exprs to test expression evaluation against smt solver #499
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
base: main
Are you sure you want to change the base?
Conversation
| val t = timeoutSec match { | ||
| case Some(n) => Seq(s"-T:$n") | ||
| case _ => Seq() | ||
| } | ||
| val softT = softTimeoutMillis match { | ||
| case Some(n) => Seq(s"-t:$n") | ||
| case None => Seq() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use .map. Options can be ++-ed onto a sequence and they act like a sequence of zero or one items.
| def genExpr(size: Option[Int] = None, depthLimit: Int = 10): Gen[Expr] = | ||
| if (size.exists(_ <= 1) || depthLimit <= 0) then genValue(size) | ||
| else Gen.oneOf(genBinExp(size, depthLimit - 1), genUnExp(size), genValue(size)) | ||
|
|
||
| def genNonLiteralExpr(size: Option[Int] = None, depthLimit: Int = 3): Gen[Expr] = | ||
| if (size.exists(_ <= 1)) then genValue(size) else Gen.oneOf(genBinExp(size, depthLimit), genUnExp(size)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ik it's not new in this pr, but what is this condition on size.exists(_ <= 1)? so, if size is negative or 0, it'll get passed to genValue? this seems wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its ugly but its because you can reliably generate width 1 bitvectors but the other options need more careful consideration as they sometimes try and partition it down further, e.g. bvconcat. I just didnt bother dealing with each possible leaf needed for the other cases. note size is option
|
I don't think theres a way to reliably generate expressions that its possible for Z3 to always verify within a timeframe, maybe I just let timeouts silently pass the test (maybe there's a way to ask scalacheck to generate more checks in that case to make sure there's a certain number of positive examples?). I don't think we should merge as is since it will lead to unreliable failures from timeouts. |
|
@katrinafyi I guess we can just mark this as disabled and merge so we can run manually? Its a somewhat useful test to have but probably too flaky. |
|
That makes sense. Should the scalacheck cases be in a different test suite so that the existing genSMT can still run? |
|
Yeah |
Reuses the scalacheck-based expr generator to test the interpreter against z3 with more complex expressions:
@b-paul
This test tends to time out when it generates difficult expressions, maybe z3's simplify tactic would be more appropriate than just an assertion.