|
13 | 13 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_check_sat;
|
14 | 14 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_create_config;
|
15 | 15 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_create_env;
|
| 16 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_create_shared_env; |
16 | 17 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_decl_get_arity;
|
17 | 18 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_decl_get_name;
|
18 | 19 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_destroy_config;
|
|
26 | 27 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_rational_type;
|
27 | 28 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_is_enum_type;
|
28 | 29 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_is_integer_type;
|
| 30 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_and; |
29 | 31 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_asin;
|
30 | 32 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_eq;
|
31 | 33 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_equal;
|
32 | 34 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_exp;
|
| 35 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_leq; |
33 | 36 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_log;
|
34 | 37 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_not;
|
35 | 38 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_make_number;
|
|
45 | 48 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_pop_backtrack_point;
|
46 | 49 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_push_backtrack_point;
|
47 | 50 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_set_option_checked;
|
| 51 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_set_termination_callback; |
48 | 52 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_term_get_type;
|
49 | 53 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_term_is_pi;
|
50 | 54 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_term_repr;
|
51 | 55 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_type_equals;
|
52 | 56 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_type_repr;
|
53 | 57 |
|
| 58 | +import java.util.concurrent.ExecutionException; |
| 59 | +import java.util.concurrent.ExecutorService; |
| 60 | +import java.util.concurrent.Executors; |
| 61 | +import java.util.concurrent.Future; |
54 | 62 | import org.junit.AssumptionViolatedException;
|
55 | 63 | import org.junit.Before;
|
56 | 64 | import org.junit.BeforeClass;
|
@@ -526,4 +534,49 @@ public void enumTypeTest() throws SolverException, InterruptedException {
|
526 | 534 | assertThat(msat_check_sat(env)).isFalse();
|
527 | 535 | msat_pop_backtrack_point(env);
|
528 | 536 | }
|
| 537 | + |
| 538 | + private final ExecutorService executor = Executors.newSingleThreadExecutor(); |
| 539 | + |
| 540 | + |
| 541 | + @SuppressWarnings("unused") |
| 542 | + private long createSharedEnv(long sibling) { |
| 543 | + long cfg = msat_create_config(); |
| 544 | + msat_set_option_checked(cfg, "dpll.ghost_filtering", "true"); |
| 545 | + msat_set_option_checked(cfg, "theory.la.split_rat_eq", "false"); |
| 546 | + |
| 547 | + long prover = msat_create_shared_env(cfg, sibling); |
| 548 | + msat_destroy_config(cfg); |
| 549 | + |
| 550 | + // FIXME: Bug #339 is caused by this line. Removing it will fix the test. |
| 551 | + long hook = msat_set_termination_callback(prover, () -> false); |
| 552 | + |
| 553 | + return prover; |
| 554 | + } |
| 555 | + |
| 556 | + private long makeLt(long e, long t1, long t2) { |
| 557 | + return msat_make_not(e, msat_make_leq(e, t2, t1)); |
| 558 | + } |
| 559 | + |
| 560 | + @Test |
| 561 | + public void bug339Test() throws ExecutionException, InterruptedException { |
| 562 | + long integerType = msat_get_integer_type(env); |
| 563 | + |
| 564 | + long varA = msat_make_variable(env, "A", integerType); |
| 565 | + long varB = msat_make_variable(env, "B", integerType); |
| 566 | + |
| 567 | + long formula = msat_make_and(env, makeLt(env, varA, varB), makeLt(env, varB, varA)); |
| 568 | + |
| 569 | + long prover = createSharedEnv(this.env); |
| 570 | + msat_assert_formula(prover, formula); |
| 571 | + |
| 572 | + Future<?> task1 = executor.submit(() -> { |
| 573 | + try { |
| 574 | + assertThat(msat_check_sat(prover)).isFalse(); |
| 575 | + } catch (InterruptedException | SolverException pE) { |
| 576 | + throw new RuntimeException(pE); |
| 577 | + } |
| 578 | + }); |
| 579 | + |
| 580 | + assert task1.get() == null; |
| 581 | + } |
529 | 582 | }
|
0 commit comments