@@ -90,8 +90,22 @@ void satcheck_ipasirt::lcnf(const bvt &bv)
90
90
}
91
91
ipasir_add (solver, 0 ); // terminate clause
92
92
93
- with_solver_hardness (
94
- [&bv](solver_hardnesst &hardness) { hardness.register_clause (bv); });
93
+ with_solver_hardness ([this , &bv](solver_hardnesst &hardness) {
94
+ // To map clauses to lines of program code, track clause indices in the
95
+ // dimacs cnf output. Dimacs output is generated after processing
96
+ // clauses to remove duplicates and clauses that are trivially true.
97
+ // Here, a clause is checked to see if it can be thus eliminated. If
98
+ // not, add the clause index to list of clauses in
99
+ // solver_hardnesst::register_clause().
100
+ static size_t cnf_clause_index = 0 ;
101
+ bvt cnf;
102
+ bool clause_removed = process_clause (bv, cnf);
103
+
104
+ if (!clause_removed)
105
+ cnf_clause_index++;
106
+
107
+ hardness.register_clause (bv, cnf, cnf_clause_index, !clause_removed);
108
+ });
95
109
96
110
clause_counter++;
97
111
}
@@ -103,51 +117,40 @@ propt::resultt satcheck_ipasirt::do_prop_solve()
103
117
log .statistics () << (no_variables () - 1 ) << " variables, " << clause_counter
104
118
<< " clauses" << messaget::eom;
105
119
106
- // use the internal representation, as ipasir does not support reporting the
107
- // status
108
- if (status==statust::UNSAT)
120
+ // if assumptions contains false, we need this to be UNSAT
121
+ bvt::const_iterator it =
122
+ std::find_if (assumptions.begin (), assumptions.end (), is_false);
123
+ const bool has_false = it != assumptions.end ();
124
+
125
+ if (has_false)
109
126
{
110
- log .status () << " SAT checker inconsistent : instance is UNSATISFIABLE"
127
+ log .status () << " got FALSE as assumption : instance is UNSATISFIABLE"
111
128
<< messaget::eom;
112
129
}
113
130
else
114
131
{
115
- // if assumptions contains false, we need this to be UNSAT
116
- bvt::const_iterator it = std::find_if (assumptions.begin (),
117
- assumptions.end (), is_false);
118
- const bool has_false = it != assumptions.end ();
132
+ forall_literals (it, assumptions)
133
+ if (!it->is_false ())
134
+ ipasir_assume (solver, it->dimacs ());
119
135
120
- if (has_false)
136
+ // solve the formula, and handle the return code (10=SAT, 20=UNSAT)
137
+ int solver_state = ipasir_solve (solver);
138
+ if (10 == solver_state)
121
139
{
122
- log .status () << " got FALSE as assumption: instance is UNSATISFIABLE"
123
- << messaget::eom;
140
+ log .status () << " SAT checker: instance is SATISFIABLE" << messaget::eom;
141
+ status = statust::SAT;
142
+ return resultt::P_SATISFIABLE;
143
+ }
144
+ else if (20 == solver_state)
145
+ {
146
+ log .status () << " SAT checker: instance is UNSATISFIABLE" << messaget::eom;
124
147
}
125
148
else
126
149
{
127
- forall_literals (it, assumptions)
128
- if (!it->is_false ())
129
- ipasir_assume (solver, it->dimacs ());
130
-
131
- // solve the formula, and handle the return code (10=SAT, 20=UNSAT)
132
- int solver_state=ipasir_solve (solver);
133
- if (10 ==solver_state)
134
- {
135
- log .status () << " SAT checker: instance is SATISFIABLE" << messaget::eom;
136
- status=statust::SAT;
137
- return resultt::P_SATISFIABLE;
138
- }
139
- else if (20 ==solver_state)
140
- {
141
- log .status () << " SAT checker: instance is UNSATISFIABLE"
142
- << messaget::eom;
143
- }
144
- else
145
- {
146
- log .status () << " SAT checker: solving returned without solution"
147
- << messaget::eom;
148
- throw analysis_exceptiont (
149
- " solving inside IPASIR SAT solver has been interrupted" );
150
- }
150
+ log .status () << " SAT checker: solving returned without solution"
151
+ << messaget::eom;
152
+ throw analysis_exceptiont (
153
+ " solving inside IPASIR SAT solver has been interrupted" );
151
154
}
152
155
}
153
156
0 commit comments