Skip to content

Add solver independent quantifier elimination with ultimate eliminator #462

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

Draft
wants to merge 97 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
1cc2659
Add UltimateEliminator dependencies to ivy and the classpath and inte…
Nov 13, 2024
e4aa914
add dependencies for Ultimate Eliminator
Anastasia-Gu Nov 27, 2024
6271bf9
add dependencies for Ultimate Eliminator
Anastasia-Gu Nov 27, 2024
349ac26
add dependencies for Ultimate Eliminator
Anastasia-Gu Nov 27, 2024
ed9c398
Add more UltimateEliminator dependencies to ivy and the classpath and…
Dec 4, 2024
bbd1848
Extend UltimateEliminator test example with hints
Dec 4, 2024
6d12d67
added Ultimate Eliminator integration to CVC5 and Z3
Anastasia-Gu Feb 7, 2025
231935a
add Mathsat5QuantifiedFormulaManager;
Anastasia-Gu Feb 11, 2025
2efbf7e
fix ant
Anastasia-Gu Feb 15, 2025
d5eacf6
fix ant
Anastasia-Gu Feb 15, 2025
481ebaa
implement bound variables for Mathsat5QuantifiedFormulaManager
Anastasia-Gu Feb 18, 2025
ec1a17c
implement quantified formula generation for Mathsat5QuantifiedFormula…
Anastasia-Gu Feb 20, 2025
2dae218
remove quantifiedFormula initialization and fix for loop
Anastasia-Gu Feb 23, 2025
5e58542
initial commit for UltimateEliminator support for Yices2 and Bitwuzla
Anastasia-Gu Feb 26, 2025
0d163bc
add UltimateEliminatorWrapper to AbstractQuantifiedFormulaManager
Anastasia-Gu Feb 27, 2025
def1a38
add UltimateEliminatorWrapper
Anastasia-Gu Feb 27, 2025
188bc9e
Improve Mathsat5 quantifier support
Feb 27, 2025
e3d2614
put FormulaManager and mkWithoutQuantifier in AbstractQuantifiedFormu…
Anastasia-Gu Mar 5, 2025
100cb72
format code with ant
Anastasia-Gu Mar 5, 2025
29c1b30
fix mkWithoutQuantifier
Anastasia-Gu Mar 6, 2025
02a7e6c
revert
Anastasia-Gu Mar 6, 2025
d13c401
fix CI errors
Anastasia-Gu Mar 6, 2025
729e37d
fix CI errors
Anastasia-Gu Mar 6, 2025
acaf7da
Rework setup of QuantifierManagerTest so that the setup does not bloc…
Mar 6, 2025
3e318c0
Implement a method for Yices2 that allows the creation of bound varia…
Mar 6, 2025
3d4b036
Rework Yices2 quantifier creation with bound variables
Mar 6, 2025
25be000
Add Yices2 quantifier support in the manager
Mar 6, 2025
5ba98cd
Remove Boolector quantifier support (as it can never be supported)
Mar 6, 2025
f9e4c5a
Remove Boolector from QuantifierManagerTest
Mar 6, 2025
64a70f7
Add bound variables to Yices2 visitor
Mar 6, 2025
9a256e9
Disable quantifier tests that Yices2 can't handle
Mar 6, 2025
a787c54
Add visitor case for Yices2 quantifiers
Mar 6, 2025
d84820f
Use full import list instead of * in Yices2FormulaCreator
Mar 6, 2025
efc25cf
Move Yices2 free variable creation method to native test class and di…
Mar 6, 2025
96aeb4d
Move Yices2 free and bound variable creation method to creator and ca…
Mar 6, 2025
1c96551
Merge branch 'fix_yices2_quantifier' into remove_boolector_quantifiers
Mar 6, 2025
75085ff
Format
Mar 6, 2025
bf75c61
Merge release 5.0.1 with fix for Yices2 quantifiers and Boolector qua…
Mar 6, 2025
6bcc200
add UltimateEliminator support to Princess
Anastasia-Gu Mar 7, 2025
4dd3133
adjust Yices2 to previous changes to AbstractQuantifiedFormulaManager
Anastasia-Gu Mar 7, 2025
0b3175e
fix mkWithoutQuantifier in AbstractQuantifiedFormulaManager
Anastasia-Gu Mar 7, 2025
741b6ca
add some tests and exclude unsupported Solvers
Anastasia-Gu Mar 7, 2025
dbd8f66
implement eliminateQuantifiersUltimateEliminator in AbstractQuantifie…
Anastasia-Gu Mar 8, 2025
347d7ad
improve error handling of eliminateQuantifiers
Anastasia-Gu Mar 9, 2025
9d834c9
add tests for solver-independent quantifier elimination
Anastasia-Gu Mar 9, 2025
7200f60
fix some CI issues
Anastasia-Gu Mar 9, 2025
a4ad348
refactor eliminateQuantifiers to increase readability
Anastasia-Gu Mar 9, 2025
d92ca24
fix warnings
Anastasia-Gu Mar 9, 2025
75bdfc0
revert restriction for dumpFormulaImpl in Mathsat5FormulaManager
Anastasia-Gu Mar 9, 2025
6eae73d
fix CI
Anastasia-Gu Mar 13, 2025
9558318
fix more CI
Anastasia-Gu Mar 13, 2025
0baa28a
fix more more CI
Anastasia-Gu Mar 14, 2025
c5af782
shorten method names for checkstyle
Anastasia-Gu Mar 14, 2025
7374a04
remove Mathsat from tests that require native quantification
Anastasia-Gu Mar 14, 2025
71f443d
remove Mathsat from tests that require native quantification
Anastasia-Gu Mar 14, 2025
4032091
remove Mathsat from more tests that require native quantification
Anastasia-Gu Mar 14, 2025
9bead2b
refactor assume messages for tests where Mathsat5 got removed
Anastasia-Gu Mar 15, 2025
822f945
pulled SolverConcurrencyTest from master
Anastasia-Gu Mar 15, 2025
3207380
format code
Anastasia-Gu Mar 15, 2025
7fcae4b
refactor dependencies
Anastasia-Gu Mar 16, 2025
dd0c425
remove unused method from UltimateEliminatorWrapper
Anastasia-Gu Mar 16, 2025
cdff920
add quantifier elimination tests and refactor method names
Anastasia-Gu Mar 17, 2025
19c675f
remove unused option
Anastasia-Gu Mar 17, 2025
fa7ed3e
remove not thrown Exceptions from method signatures
Anastasia-Gu Mar 17, 2025
3c95681
rename logger componentName for UltimateEliminator
Anastasia-Gu Mar 17, 2025
0e3c875
Merge branch 'master' into add_solver_independent_quantifier_eliminat…
Anastasia-Gu Mar 19, 2025
ec6d411
Merge branch 'refs/heads/master' into add_solver_independent_quantifi…
Anastasia-Gu Mar 20, 2025
c456aea
merge master into branch
Anastasia-Gu Mar 20, 2025
f5a14a6
remove unused IOException
Anastasia-Gu Mar 20, 2025
cf60709
remove MathSAT5 and Yices2 from quantifier tests
Anastasia-Gu Mar 20, 2025
b7bf341
rename ProverOption SOLVER_INDEPENDENT_QUANTIFIER_ELIMINATION_BEFORE …
Anastasia-Gu Mar 20, 2025
e973e5f
updated options and option handling
Anastasia-Gu Mar 24, 2025
763f8e1
fix tests
Anastasia-Gu Mar 24, 2025
613eb07
resolve some comments
Anastasia-Gu Mar 24, 2025
7a1e814
fix CI
Anastasia-Gu Mar 24, 2025
fb403ff
fix CI
Anastasia-Gu Mar 24, 2025
64d7782
fix CI
Anastasia-Gu Mar 24, 2025
9d86ef4
slf4j-nop.jar to classpath to disable failed job from spotbugs
Anastasia-Gu Mar 24, 2025
8f2b80c
Revert "slf4j-nop.jar to classpath to disable failed job from spotbugs"
Anastasia-Gu Mar 24, 2025
db28834
Remove Boolector quantifier support (as it can never be supported)
Mar 6, 2025
0baae82
Remove Boolector from quantified tests
Mar 7, 2025
7e5766d
Use the delegate to set the options for quantified formula manger in …
Apr 3, 2025
2b4b834
extend AbstractQuantifiedFormulaManager with dumpFormula method and o…
Anastasia-Gu Apr 8, 2025
90cf638
add documentation
Anastasia-Gu Apr 8, 2025
b081df7
replace usage of ProverOption with QuantifierEliminationMethod and Qu…
Anastasia-Gu Apr 8, 2025
da132cc
Merge remote-tracking branch 'origin/add_solver_independent_quantifie…
Anastasia-Gu Apr 8, 2025
1af6a9f
remove unused code
Anastasia-Gu Apr 8, 2025
e7d00d8
fix pipeline issues
Anastasia-Gu Apr 8, 2025
389a2a1
fix more pipeline issues
Anastasia-Gu Apr 8, 2025
dba7e59
fix even more pipeline issues
Anastasia-Gu Apr 8, 2025
61107bb
move dumpFormulaImplExt to Mathsat5QuantifiedFormulaManager
Anastasia-Gu Apr 10, 2025
2dd9c77
set qfmgr's fmgr in AbstractFormulaManagers constructor
Anastasia-Gu Apr 10, 2025
b7f9cde
extract repeated try-catch blocks to methods
Anastasia-Gu Apr 10, 2025
4e72016
add documentation
Anastasia-Gu Apr 10, 2025
c9cd36a
extract repeated try-catch blocks for formula creation to a method
Anastasia-Gu Apr 13, 2025
de43b95
add null and empty checks to eliminateQuantifierBeforeMakingFormula a…
Anastasia-Gu May 7, 2025
e97a9ef
remove logic from msat_to_smtlib2_ext
Anastasia-Gu May 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ SPDX-License-Identifier: Apache-2.0
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="bin/"/>
<classpathentry kind="lib" path="lib/java/core/guava.jar" sourcepath="lib/java-contrib/guava-sources.jar"/>

<classpathentry kind="lib" path="lib/java/core/ultimate-model-checker-utils.jar" sourcepath="lib/java-contrib/ultimate-model-checker-utils-sources.jar"/>
<classpathentry kind="lib" path="lib/java/core/ultimate-core-rcp.jar" sourcepath="lib/java-contrib/ultimate-core-rcp-sources.jar"/>
<classpathentry kind="lib" path="lib/java/core/ultimate-core.jar" sourcepath="lib/java-contrib/ultimate-core-sources.jar"/>
<classpathentry kind="lib" path="lib/java/core/ultimate-model.jar" sourcepath="lib/java-contrib/ultimate-model-sources.jar"/>
<classpathentry kind="lib" path="lib/java/core/ultimate-library-smtlib.jar" sourcepath="lib/java-contrib/ultimate-library-smtlib-sources.jar"/>
<classpathentry kind="lib" path="lib/java/core/ultimate-library-smtlib-utils.jar" sourcepath="lib/java-contrib/ultimate-library-smtlib-utils-sources.jar"/>
<classpathentry kind="lib" path="lib/java/core/ultimate-util.jar" sourcepath="lib/java-contrib/ultimate-util-sources.jar"/>

<classpathentry kind="lib" path="lib/java/test/guava-testlib.jar" sourcepath="lib/java-contrib/guava-testlib-sources.jar"/>
<classpathentry kind="lib" path="lib/java/test/truth.jar" sourcepath="lib/java-contrib/truth-sources.jar"/>
<classpathentry kind="lib" path="lib/java/test/junit.jar"/>
Expand Down
77 changes: 76 additions & 1 deletion .idea/JavaSMT.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions .idea/ant.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 3 additions & 9 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions lib/ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,28 @@ SPDX-License-Identifier: Apache-2.0
<!-- SmtInterpol -->
<dependency org="de.uni-freiburg.informatik.ultimate" name="smtinterpol" rev="2.5-1242-g5c50fb6d" conf="runtime-smtinterpol->master; contrib->sources"/>

<!-- UltimateEliminator -->
<dependency org="de.uni-freiburg.informatik.ultimate" name="ultimate-model-checker-utils"
rev="2022-10-13-r05bfb7ad3d" conf="core->runtime; contrib->sources"/>
<dependency org="de.uni-freiburg.informatik.ultimate" name="ultimate-core-rcp"
rev="2022-10-13-r05bfb7ad3d" conf="core->runtime; contrib->sources"/>
<dependency org="de.uni-freiburg.informatik.ultimate" name="ultimate-core"
rev="2022-10-13-r05bfb7ad3d" conf="core->runtime; contrib->sources"/>
<dependency org="de.uni-freiburg.informatik.ultimate" name="ultimate-model"
rev="2022-10-13-r05bfb7ad3d" conf="core->runtime; contrib->sources"/>
<dependency org="de.uni-freiburg.informatik.ultimate" name="ultimate-library-smtlib"
rev="2022-10-13-r05bfb7ad3d" conf="core->runtime; contrib->sources"/>
<dependency org="de.uni-freiburg.informatik.ultimate" name="ultimate-library-smtlib-utils"
rev="2022-10-13-r05bfb7ad3d" conf="core->runtime; contrib->sources"/>
<dependency org="de.uni-freiburg.informatik.ultimate" name="ultimate-util"
rev="2022-10-13-r05bfb7ad3d" conf="core->runtime; contrib->sources"/>

<!-- Princess for our Maven release -->
<dependency org="io.github.uuverifiers" name="princess_2.13" rev="2024-01-12" conf="runtime-princess-with-javacup->default; contrib->sources"/>
<!-- Princess for our Ivy release-->
<dependency org="io.github.uuverifiers" name="princess_2.13" rev="2024-01-12"
conf="runtime-princess->default; contrib->sources"/>
<!-- Exclude dependency on java-cup and replace it with java-cup-runtime, which is enough.-->
<!-- Princess and Ostrich for our Maven release -->
<dependency org="io.github.uuverifiers" name="princess_2.13" rev="2024-11-08" conf="runtime-princess-with-javacup->default; contrib->sources"/>
<dependency org="io.github.uuverifiers" name="ostrich_2.13" rev="1.4.1" conf="runtime-princess-with-javacup->default; contrib->sources"/>
Expand Down
12 changes: 9 additions & 3 deletions src/org/sosy_lab/java_smt/SolverContextFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,23 @@ private SolverContext generateContext0(Solvers solverToCreate)

case PRINCESS:
return PrincessSolverContext.create(
config, shutdownNotifier, logfile, (int) randomSeed, nonLinearArithmetic);
config, shutdownNotifier, logfile, (int) randomSeed, nonLinearArithmetic, logger);

case YICES2:
return Yices2SolverContext.create(nonLinearArithmetic, shutdownNotifier, loader);
return Yices2SolverContext.create(nonLinearArithmetic, shutdownNotifier, loader, logger);

case BOOLECTOR:
return BoolectorSolverContext.create(config, shutdownNotifier, logfile, randomSeed, loader);

case BITWUZLA:
return BitwuzlaSolverContext.create(
config, shutdownNotifier, logfile, randomSeed, floatingPointRoundingMode, loader);
config,
shutdownNotifier,
logfile,
randomSeed,
floatingPointRoundingMode,
loader,
logger);

default:
throw new AssertionError("no solver selected");
Expand Down
121 changes: 118 additions & 3 deletions src/org/sosy_lab/java_smt/api/QuantifiedFormulaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,70 @@ enum Quantifier {
EXISTS
}

enum QuantifierEliminationMethod {
/** Use the solver's built-in quantifier elimination method. */
NATIVE,

/** Use the solver's built-in quantifier elimination method. */
NATIVE_FALLBACK_ON_FAILURE,

/** Use the solver's built-in quantifier elimination method. */
NATIVE_FALLBACK_WITH_WARNING_ON_FAILURE,

/** Whether the solver should enable quantifier eliminiation via UltimateEliminator. */
ULTIMATE_ELIMINATOR,

/**
* Whether the solver should enable quantifier eliminiation via UltimateEliminator and fall back
* to the native quantifier elimination if UltimateEliminator's elimination method fails. The
* solver will not log a warning in this case.
*/
ULTIMATE_ELIMINATOR_FALLBACK_ON_FAILURE,

/**
* Whether the solver should enable quantifier eliminiation via UltimateEliminator and back to
* the native quantifier elimination if UltimateEliminator's elimination method fails. The
* solver will log a warning in this case.
*/
ULTIMATE_ELIMINATOR_FALLBACK_WITH_WARNING_ON_FAILURE,
}

enum QuantifierCreationMethod {
/**
* Whether the solver should eliminate the quantifier via UltimateEliminator before inserting it
* to the native quantified formula.
*/
ULTIMATE_ELIMINATOR_BEFORE_FORMULA_CREATION,

/**
* Whether the solver should eliminate the quantifier via UltimateEliminator before inserting it
* to the native quantified formula and fall back to the native quantifier creation if
* UltimateEliminator fails. The solver will not log a warning in this case.
*/
ULTIMATE_ELIMINATOR_BEFORE_FORMULA_CREATION_FALLBACK,

/**
* Whether the solver should eliminate the quantifier via UltimateEliminator before inserting it
* to the native quantified formula and fall back to the native quantifier creation if
* UltimateEliminator fails. The solver will log a warning in this case.
*/
ULTIMATE_ELIMINATOR_BEFORE_FORMULA_CREATION_FALLBACK_WARN_ON_FAILURE
}

/**
* @return An existentially quantified formula.
* @param pVariables The variables that will get bound (variables) by the quantification.
* @param pBody The {@link BooleanFormula}} within that the binding will be performed.
* @return An existentially quantified formula.
* @throws IllegalArgumentException If the list {@code pVariables} is empty.
*/
default BooleanFormula exists(List<? extends Formula> pVariables, BooleanFormula pBody) {
return mkQuantifier(Quantifier.EXISTS, pVariables, pBody);
}

/**
* @return A universally quantified formula.
* @param pVariables The variables that will get bound (variables) by the quantification.
* @param pBody The {@link BooleanFormula}} within that the binding will be performed.
* @return A universally quantified formula.
* @throws IllegalArgumentException If the list {@code pVariables} is empty.
*/
default BooleanFormula forall(List<? extends Formula> pVariables, BooleanFormula pBody) {
Expand All @@ -54,15 +104,67 @@ default BooleanFormula exists(Formula quantifiedArg, BooleanFormula pBody) {
}

/**
* @return A quantified formula
* @param pVariables The variables that will get bound (variables) by the quantification.
* @param pBody The {@link BooleanFormula}} within that the binding will be performed.
* @param pMethod The {@link QuantifierCreationMethod}} to decide on the creation method.
* @return An existentially quantified formula.
* @throws IllegalArgumentException If the list {@code pVariables} is empty.
*/
default BooleanFormula exists(
List<? extends Formula> pVariables, BooleanFormula pBody, QuantifierCreationMethod pMethod) {
return mkQuantifier(Quantifier.EXISTS, pVariables, pBody, pMethod);
}

/**
* @param pVariables The variables that will get bound (variables) by the quantification.
* @param pBody The {@link BooleanFormula}} within that the binding will be performed.
* @param pMethod The {@link QuantifierCreationMethod}} to decide on the creation method.
* @return A universally quantified formula.
* @throws IllegalArgumentException If the list {@code pVariables} is empty.
*/
default BooleanFormula forall(
List<? extends Formula> pVariables, BooleanFormula pBody, QuantifierCreationMethod pMethod) {
return mkQuantifier(Quantifier.FORALL, pVariables, pBody, pMethod);
}

/** Syntax sugar, see {@link #forall(List, BooleanFormula)}. */
default BooleanFormula forall(
Formula quantifiedArg, BooleanFormula pBody, QuantifierCreationMethod pMethod) {
return forall(ImmutableList.of(quantifiedArg), pBody, pMethod);
}

/** Syntax sugar, see {@link #exists(List, BooleanFormula)}. */
default BooleanFormula exists(
Formula quantifiedArg, BooleanFormula pBody, QuantifierCreationMethod pMethod) {
return exists(ImmutableList.of(quantifiedArg), pBody, pMethod);
}

/**
* @param q Quantifier type
* @param pVariables The variables that will get bound (variables) by the quantification.
* @param pBody The {@link BooleanFormula}} within that the binding will be performed.
* @return A quantified formula
* @throws IllegalArgumentException If the list {@code pVariables} is empty.
*/
BooleanFormula mkQuantifier(
Quantifier q, List<? extends Formula> pVariables, BooleanFormula pBody);

/**
* Create a formula with a specific quantifier elimination method.
*
* @param q Quantifier type
* @param pVariables The variables that will get bound (variables) by the quantification.
* @param pBody The {@link BooleanFormula}} within that the binding will be performed.
* @param pMethod The {@link QuantifierCreationMethod}} to decide on the creation method.
* @return A boolean formula where the quantifier may already have been eliminated.
* @throws IllegalArgumentException If the list {@code pVariables} is empty.
*/
BooleanFormula mkQuantifier(
Quantifier q,
List<? extends Formula> pVariables,
BooleanFormula pBody,
QuantifierCreationMethod pMethod);

/**
* Eliminate the quantifiers for a given formula. If this is not possible, it will return the
* input formula. Note that CVC4 only supports this for LIA and LRA.
Expand All @@ -72,4 +174,17 @@ BooleanFormula mkQuantifier(
*/
BooleanFormula eliminateQuantifiers(BooleanFormula pF)
throws InterruptedException, SolverException;

/**
* Eliminate the quantifiers for a given formula using either UltimateEliminator or the native
* method. If this is not possible, depending on the given method it will fallback to the
* alternative method or throw an Exception. Note that CVC4 only supports this for LIA and LRA in
* the native elimination.
*
* @param pF Formula with quantifiers.
* @param pMethod enum value for method to be used for eliminating quantifiers.
* @return New formula without quantifiers.
*/
BooleanFormula eliminateQuantifiers(BooleanFormula pF, QuantifierEliminationMethod pMethod)
throws InterruptedException, SolverException;
}
Loading