|
17 | 17 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_decl_get_name;
|
18 | 18 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_destroy_config;
|
19 | 19 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_destroy_model_iterator;
|
| 20 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_destroy_proof_manager; |
20 | 21 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_from_smtlib2;
|
21 | 22 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_enum_constants;
|
22 | 23 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_enum_type;
|
23 | 24 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_integer_type;
|
24 | 25 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_model;
|
25 | 26 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_model_value;
|
| 27 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_proof; |
| 28 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_proof_manager; |
26 | 29 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_get_rational_type;
|
27 | 30 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_is_enum_type;
|
28 | 31 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_is_integer_type;
|
|
43 | 46 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_model_iterator_has_next;
|
44 | 47 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_model_iterator_next;
|
45 | 48 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_pop_backtrack_point;
|
| 49 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_proof_get_arity; |
| 50 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_proof_get_child; |
| 51 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_proof_get_name; |
| 52 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_proof_id; |
| 53 | +import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_proof_is_term; |
46 | 54 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_push_backtrack_point;
|
47 | 55 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_set_option_checked;
|
48 | 56 | import static org.sosy_lab.java_smt.solvers.mathsat5.Mathsat5NativeApi.msat_term_get_type;
|
@@ -90,6 +98,56 @@ public void createEnvironment() {
|
90 | 98 | var = msat_make_variable(env, "rat", rationalType);
|
91 | 99 | }
|
92 | 100 |
|
| 101 | + @Test |
| 102 | + public void proofTest() throws IllegalStateException, InterruptedException, SolverException { |
| 103 | + long cfg = msat_create_config(); |
| 104 | + |
| 105 | + msat_set_option_checked(cfg, "proof_generation", "true"); |
| 106 | + |
| 107 | + env = msat_create_env(cfg); |
| 108 | + msat_destroy_config(cfg); |
| 109 | + |
| 110 | + const0 = msat_make_number(env, "0"); |
| 111 | + const1 = msat_make_number(env, "1"); |
| 112 | + long rationalType = msat_get_rational_type(env); |
| 113 | + var = msat_make_variable(env, "rat", rationalType); |
| 114 | + |
| 115 | + msat_push_backtrack_point(env); |
| 116 | + |
| 117 | + msat_assert_formula(env, msat_make_equal(env, var, const0)); |
| 118 | + msat_assert_formula(env, msat_make_equal(env, var, const1)); |
| 119 | + |
| 120 | + // UNSAT |
| 121 | + assertThat(msat_check_sat(env)).isFalse(); |
| 122 | + |
| 123 | + long proofMgr = msat_get_proof_manager(env); |
| 124 | + long proof = msat_get_proof(proofMgr); |
| 125 | + |
| 126 | + assertThat(msat_proof_is_term(proof)).isFalse(); |
| 127 | + |
| 128 | + assertThat(msat_proof_get_arity(proof)).isEqualTo(1); |
| 129 | + |
| 130 | + String proofName = msat_proof_get_name(proof); |
| 131 | + assertThat(proofName).isEqualTo("res-chain"); |
| 132 | + |
| 133 | + // Child is also a proof |
| 134 | + long proofChild = msat_proof_get_child(proof, 0); |
| 135 | + assertThat(msat_proof_get_name(proofChild)).isEqualTo("clause-hyp"); |
| 136 | + assertThat(msat_proof_is_term(proofChild)).isFalse(); |
| 137 | + assertThat(msat_proof_get_arity(proofChild)).isEqualTo(0); |
| 138 | + |
| 139 | + // Can be used to check for the equality of proofs |
| 140 | + int proofID = msat_proof_id(proof); |
| 141 | + int proofChildID = msat_proof_id(proofChild); |
| 142 | + assertThat(proofChildID).isNotEqualTo(proofID); |
| 143 | + |
| 144 | + // TODO: test term representation of a proof |
| 145 | + // long term = msat_proof_get_term(proofChild2); |
| 146 | + |
| 147 | + // Cleans up the proof manager and the associated proof |
| 148 | + msat_destroy_proof_manager(proofMgr); |
| 149 | + } |
| 150 | + |
93 | 151 | /** x == 0 and sin(x) == 0 SAT; x == 1 and sin(x) == 0 UNSAT. */
|
94 | 152 | @Test
|
95 | 153 | public void sinTest() throws IllegalStateException, InterruptedException, SolverException {
|
|
0 commit comments