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

Missformed SMT source, Unknown SMT term of class: class smtlib.trees.Terms$FunctionApplication #1549

Open
vkuncak opened this issue Jul 31, 2024 · 8 comments
Assignees

Comments

@vkuncak
Copy link
Collaborator

vkuncak commented Jul 31, 2024

The snack dispenser example, https://github.com/epfl-lara/bolts/blob/main/tutorials/dispenser/Dispenser.scala
fails with smt-cvc5 with error messages apparently during Inox's preparation of the SMT-LIB file.

(Note: the benchmark only works with a substantial timeout with 43 seconds on my laptop to check exampleTrace postcondition; something that was likely not happening before.)

@sankalpgambhir
Copy link
Member

sankalpgambhir commented Aug 2, 2024

The error is apparently not in the generation of the SMT2 file, but rather in reading the SMTLIB model into Inox terms (In Inox: SMTLIBParser.scala:226). It starts here while reading function definitions from the model.

This seems to be caused by the fact that cvc5 is outputting a model where the model for one function uses the generated model for another function (but is returning them in the opposite order). Illustrated here:

Definitions:

(declare-fun lt () State)
(declare-fun r (State Action) Option)

And the model:

(define-fun lt () State (valueOf (r [...]) ; trimmed
(define-fun r ((arg1 State) (arg2 Action)) Option None)

(cleaned up a bit for readability)

There is also a valueOf None expression, which as far as I can tell, is assigned some unique value while testing for satisfiability (and is not returned).

Inox doesn't seem to expect this usage of functions and thus returns it as an unknown symbol. I'm checking if this is unexpected behaviour from the solver, or a failure to read it from Inox's end because of the order they are returned in.

z3 does not have this behaviour on this example, at least. Its model does not use other functions at all, only lets and ADT constructors.

@vkuncak
Copy link
Collaborator Author

vkuncak commented Aug 2, 2024 via email

@sankalpgambhir
Copy link
Member

sankalpgambhir commented Aug 2, 2024

That's correct, the "check model" option is only checked after retrieval and construction of the model in the unrolling solver.

The requirement of a model is encoded in the types and API as well (ResponseWithModel[Model { val program: self.program.type }]). We can widen this in the SimpleSolver API to just CheckResponse but I have to see if the removal of the refinement on program changes anything. (Likely safe)

After that it's a matter of changing the one-line check call itself to not ask for a model if the option is not requested. If the check call does not ask for a model, the corresponding call for model reconstruction does not happen, from what I can see; (get-model) is not even emitted to the solver.

@sankalpgambhir
Copy link
Member

Would you prefer to make this part of the --check-models option or a new option? (In any case, I will investigate the original issue as well; it should not fail on the default settings this way)

@sankalpgambhir
Copy link
Member

sankalpgambhir commented Aug 2, 2024

Regarding the original issue: the order of definitions returned is not an issue, that is accounted for. Inox does also allow seeing some (marked) constants reused, but it never expects actual functions with parameters. The function r here is neither marked nor a constant (per its type).

@samuelchassot
Copy link
Collaborator

I also wanted to remove model reconstruction when using --simple-models option, as Inox does not expect a model that does not assign all variables (if I remember correctly).
I think that adds to the pool of justifications to do it.

@sankalpgambhir
Copy link
Member

sankalpgambhir commented Aug 9, 2024

With ignore-models, this can be successfully verified now on the PR linked above. However, the issue of supporting models from cvc5 still stands.

Can I move this issue to Inox instead?

@vkuncak
Copy link
Collaborator Author

vkuncak commented Aug 11, 2024

You can move the issue as desired.

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

No branches or pull requests

3 participants