-
Notifications
You must be signed in to change notification settings - Fork 20
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
Invariant Solver #214
Invariant Solver #214
Conversation
Models from z3 are now extracted and printed (:tada:). I'll add a commit soon to improve the printing for this. Following the discovery of unsoundness when processing some invalid queries, I realized that the computation of arguments of predicates is not always simple in a single pass. It is much safer to do it as two passes. This reduces the complexity of the encoding a bit, since there are quite a few less things to track once you give up doing things in one pass. This motivated a significant rewrite of the constraint generation. Alongside this, there is now clearer support for polymorphic recursion since I was rewriting those parts already, wherein each concretely typed version of each function gets its own definition, clauses, and thus invariants. This adds a fixpoint computation in the constraint generation to transitively accumulate concrete calls, but this should terminate quite quickly if the program terminates (i.e. if you at least don't have unbounded polymorphic recursion). Turns out that even in the two-pass generation, it is not always clear when certain guards should be injected into clauses (conditions under which certain variables' presence is justified), so that added a bit of complexity and thinking to the new implementation. I've tested some more integer programs, valid and invalid. I'll be adding some of these as tests soon. |
New Eldarica intepreter is in and working. There is no longer a hardcoded dependence on an external wrapper. Communication with Eldarica happens through some string streams. Not great, but much better than starting new JVMs. Interruption (as expected by Inox's solver interface) is provided by using Java Executors / Futures. There is (kinda) a provision to read models from Eldarica, but after a long session figuring out parsing errors, it was as simple as Eldarica not quite respecting the SMTLIB standard. For models, Eldarica simply returns S-expressions for each element of the model, rather than an S-list. As a result, the model: (
(define-fun F ((A Int)) Bool (true))
) becomes (define-fun F ((A Int)) Bool (true)) and the empty model The lines requesting and parsing the model from eldarica are thus commented out in the interpreter file for now. I'll make a PR on the eldarica repo to fix this. uuverifiers/eldarica#64 |
e52dc68
to
9bf9546
Compare
Rebased wrt main |
Integrating this with Stainless will require minor changes to the |
Adding a solver backend to encode problems as constrained Horn clauses and attempt to produce invariants.
Currently supports recursive first-order integer programs. Experimental support for higher-order functions is implemented using arrays to represent first-class functions.
There are currently two versions:
SimpleHornSolver
andInvariantSolver
. TheSimpleHornSolver
was created as a modification of theUnrollingSolver
but will be removed in favour of the from-scratchInvariantSolver
before merge.Working on getting it to print discovered invariants as additional info. Currently, z3 outputs some models for Horn clauses with syntax outside that accepted by scala-smtlib, which need to be dealt with.
Concrete changelist:
InvariantSolver
: main additionSMTLIBSolver
/SMTLIBTarget
: common SMTLIB solver backendFunctionType(Seq(...), Boolean)
)registerPredicate
functionparseSuccess
method that accessed interpreter internals. (checked because the eldarica interpreter is not well-behaved wrt these internal semantics as it does not use IPC like every other interpreter)EldaricaInterpreter
SolverFactory
: updated options and factory to makeinv-z3
andinv-eld
available as solversuuverifiers
dependenciesprincess
to resolve as a library instead of a git dependency (eldarica uses princess from maven, so there is a conflict too otherwise)eldarica
as a library dependencysbt dependencyTree
). These dependencies have their 2.13 suffixed alternatives explicitly excluded.scala-parser-combinators
to be the same version as that used by eldarica ( 1.1.2 -> 2.3.0)