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

SAT-check for String theory with codepoint crashes in MatchError #18

Open
kfriedberger opened this issue Dec 30, 2024 · 2 comments
Open

Comments

@kfriedberger
Copy link

The JavaSMT developers are currently trying to improve their support for String theory with the SMT solver Princess (see sosy-lab/java-smt#422). There are some smaller issues in Princess (version 2024-11-08) that block us from a good integration.

The following issue appeared in a simple SAT check:

Description:
We want to assert a formula string::codepoint(x) == string::codepoint(x) with a simple integer symbol x. Princess crashes. 😢

Java code (partial):

    SimpleAPI api = SimpleAPI.apply(...default args...);
    StringTheory stringTheory = new OstrichStringTheory(toSeq(new ArrayList<>()), new OFlags(...default args...));

    ITerm var = api.createConstant("x", Integer$.MODULE$);
    IFunApp cp = new IFunApp(stringTheory.str_from_code(), toITermSeq(var));
    IFormula eq = cp.$eq$eq$eq(cp);
    api.addAssertion(eq);
    Value result = api.checkSat(true); // --> CRASH

Stacktrace:

scala.MatchError: str_cons(cp, 0) (of class ap.parser.IFunApp)
	at ostrich.StrDatabase.iTerm2Id(StrDatabase.scala:172)
	at ostrich.OstrichStringEncoder.postVisit(OstrichPreprocessor.scala:457)
	at ostrich.OstrichStringEncoder.postVisit(OstrichPreprocessor.scala:440)
	at ap.parser.CollectingVisitor.visit(InputAbsyVisitor.scala:126)
	at ostrich.OstrichStringEncoder.apply(OstrichPreprocessor.scala:446)
	at ostrich.OstrichStringTheory.iPreprocess(OstrichStringTheory.scala:488)
	at ap.theories.Theory$.$anonfun$iPreprocess$1(Theory.scala:135)
	at scala.collection.immutable.List.foldRight(List.scala:353)
	at scala.collection.IterableOnceOps.$colon$bslash(IterableOnce.scala:761)
	at scala.collection.IterableOnceOps.$colon$bslash$(IterableOnce.scala:761)
	at scala.collection.AbstractIterable.$colon$bslash(Iterable.scala:935)
	at ap.theories.Theory$.iPreprocess(Theory.scala:135)
	at ap.parser.Preprocessing$.$anonfun$apply$3(Preprocessing.scala:99)
	at scala.collection.immutable.List.map(List.scala:247)
	at ap.parser.Preprocessing$.apply(Preprocessing.scala:98)
	at ap.api.SimpleAPI.toInternal(SimpleAPI.scala:4272)
	at ap.api.SimpleAPI.flushTodo(SimpleAPI.scala:4034)
	at ap.api.SimpleAPI.checkSatHelp(SimpleAPI.scala:1960)
	at ap.api.SimpleAPI.checkSat(SimpleAPI.scala:1946)
@pruemmer
Copy link
Collaborator

pruemmer commented Dec 31, 2024 via email

@kfriedberger
Copy link
Author

JavaSMT does not want to introduce additional utility symbols and equations. Integrating this functionality directly within Princess/Ostrich would be beneficial. This enhancement is not a high priority for us, so its implementation can be deferred.

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

No branches or pull requests

2 participants