Skip to content

Cvc5: Fix parsing bug#607

Open
daniel-raffler wants to merge 5 commits intomasterfrom
cvc5-fix-parsing
Open

Cvc5: Fix parsing bug#607
daniel-raffler wants to merge 5 commits intomasterfrom
cvc5-fix-parsing

Conversation

@daniel-raffler
Copy link
Contributor

Hello,

our CVC5 parsing code has an issue that allows duplicate versions of the same variable to be created. The problem is that quotes are not removed from symbols when looking them up in the variable cache. Because of a new variable may be created when looking up a quoted symbol, even though the variable already exists without the quotes

We need to always remove quotes before accessing the variable cache. Otherwise, duplicate variables will be created for "|var|" and "var"
Copy link
Contributor

@baierd baierd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!
I have some small requests, nothing mayor.


/** Variable names (symbols) can be wrapped with "|". This function removes those chars. */
protected static String dequote(String s) {
public String dequote(String s) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually don't want anything from the creator publicly accessible, as the creator itself is hidden. Maybe the better move would be to make this available in the FormulaManager as a common method in a protected way for now? (Possibly a parsing/dumping util class would be helpful in the future)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved dequote to Tokenizer as it is the closest thing we have to a parsing/dumping util class

}

@Test
public void testParseall_quotedSymbol() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to stick to the Java naming scheme ;D
testParseall_quotedSymbol -> parseAllQuotedSymbolTest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the names in the class should be updated now

var str = mgr.dumpFormula(f).toString();
var g = mgr.parse(str);

assertThat(g).isEqualTo(f);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also assert that it was really quoted in str.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name contains a space character. So it needs to be quoted or parsing would fail. However, it's difficult to assert that as different solvers will generate different output in mgr.dumpFormula

I've now changed the test to use a fixed String as input

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

Development

Successfully merging this pull request may close these issues.

2 participants