Skip to content

Commit ba6c2bc

Browse files
author
BaierD
committed
Add a model test that checks error when requesting a model for UNSAT (do we have this already elsewhere?)
1 parent e73b889 commit ba6c2bc

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/org/sosy_lab/java_smt/test/ModelTest.java

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,32 @@ public void testDeeplyNestedFormulaBV() throws SolverException, InterruptedExcep
24312431
var -> bvmgr.equal(var, bvmgr.makeBitvector(4, 1)));
24322432
}
24332433

2434+
@Test
2435+
public void testModelAfterUnsatInt() throws SolverException, InterruptedException {
2436+
requireIntegers();
2437+
try (ProverEnvironment prover = context.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
2438+
HardIntegerFormulaGenerator gen = new HardIntegerFormulaGenerator(imgr, bmgr);
2439+
prover.push(gen.generate(8));
2440+
2441+
assertThat(prover).isUnsatisfiable();
2442+
2443+
assertThrows(IllegalStateException.class, prover::getModel);
2444+
}
2445+
}
2446+
2447+
@Test
2448+
public void testModelAfterUnsatBv() throws SolverException, InterruptedException {
2449+
requireBitvectors();
2450+
try (ProverEnvironment prover = context.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
2451+
HardBitvectorFormulaGenerator gen = new HardBitvectorFormulaGenerator(bvmgr, bmgr);
2452+
prover.push(gen.generate(8));
2453+
2454+
assertThat(prover).isUnsatisfiable();
2455+
2456+
assertThrows(IllegalStateException.class, prover::getModel);
2457+
}
2458+
}
2459+
24342460
/**
24352461
* Build a deep nesting that is easy to solve and can not be simplified by the solver. If any part
24362462
* of JavaSMT or the solver tries to analyse all branches of this formula, the runtime is
@@ -2459,7 +2485,9 @@ private <T> void testDeeplyNestedFormula(
24592485
private void evaluateInModel(BooleanFormula constraint, Formula variable, Object expectedValue)
24602486
throws SolverException, InterruptedException {
24612487

2462-
try (ProverEnvironment prover = context.newProverEnvironment(ProverOptions.GENERATE_MODELS)) {
2488+
try (ProverEnvironment prover =
2489+
context.newProverEnvironment(
2490+
ProverOptions.GENERATE_MODELS, ProverOptions.GENERATE_UNSAT_CORE)) {
24632491
prover.push(constraint);
24642492
assertThat(prover).isSatisfiable();
24652493

0 commit comments

Comments
 (0)