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

Yices2 produces invalid SMTLIB output when dumping formulas #402

Open
daniel-raffler opened this issue Oct 9, 2024 · 4 comments
Open

Yices2 produces invalid SMTLIB output when dumping formulas #402

daniel-raffler opened this issue Oct 9, 2024 · 4 comments
Labels
Blocked by Solver Support solver does not yet support this feature OR there was not yet any public release of the solver solver Yices2

Comments

@daniel-raffler
Copy link
Contributor

Hello everyone,
yices2 does not apply correct quotes while dumping SMTLIB formulas. An example for this can be seen in VariableNamesTest.testBoolVariableDump() where the formula for a (boolean) variable named "(" produces the following output:

(declare-fun |(| () Bool)
(assert ()

The correct output should use quotes for the "(" in the assertion:

(declare-fun |(| () Bool)
(assert |(|)

Without the quotes the SMTLIB string is invalid and will cause an exception during post-processing. (Which is why the test was temporarily disabled for yices2)

The problem is with the yices2 function yices_term_to_string(), which fails to apply the quotes while printing the formula. We should report this to the yices2 developers and wait for a fix. If this is not an option we may want to handle quoting on our end by overloading `Yices2FormulaManager.makeVariable.

@kfriedberger kfriedberger added Blocked by Solver Support solver does not yet support this feature OR there was not yet any public release of the solver solver Yices2 labels Oct 9, 2024
@kfriedberger
Copy link
Member

Does this issue only affect simple formulas like |(| or also complex ones like and |(| x |)|?

@daniel-raffler
Copy link
Contributor Author

Does this issue only affect simple formulas like |(| or also complex ones like and |(| x |)|?

It seems to be for all formulas. Take for instance:

BooleanFormula var1 = bmgr.makeVariable(")");
BooleanFormula var2 = bmgr.makeVariable("var2");
BooleanFormula formula = bmgr.and(var1, var2);
String dump = mgr.dumpFormula(formula).toString()

Here Yices2FormulaManager.dumpFormulaImpl will give us:

(declare-fun var2 () Bool)
(declare-fun |)| () Bool)
(assert (and ) var2))"

Which does not quote the ")" in the assert.

(Note that the ")" in declare-fun is in fact quoted. This is because we added the declaration ourselves before the term is printed. For this job there already is a function quote in Yices2FormulaManager. Applying it to an entire term, however, would require us to use a visitor that rewrites the variable names.)

@kfriedberger
Copy link
Member

kfriedberger commented Oct 9, 2024

Please report this issue to Yices. If they provide a fix, we can update the library in JavaSMT quite easily.

Also, using a formula visitor to print a formula (and escape symbols) could be a good exercise for new developers and could be added as example. A plain String representation can be exponentially large, so one would introduce let-terms for some parts. 🐞 Maybe someone wants toplay around here.

@daniel-raffler
Copy link
Contributor Author

I've now opened an issue for Yices:
SRI-CSL/yices2#534

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked by Solver Support solver does not yet support this feature OR there was not yet any public release of the solver solver Yices2
Development

No branches or pull requests

2 participants