Skip to content

Commit 7cb1056

Browse files
Add protected do_prop_solve for overriding
This will allow us to count solver invocations without repeating the code in each propt implementation.
1 parent f614c70 commit 7cb1056

27 files changed

+59
-41
lines changed

src/solvers/prop/prop.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ bvt propt::new_variables(std::size_t width)
2525
result[i]=new_variable();
2626
return result;
2727
}
28+
29+
propt::resultt propt::prop_solve()
30+
{
31+
return do_prop_solve();
32+
}

src/solvers/prop/prop.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class propt
9797
// solving
9898
virtual const std::string solver_text()=0;
9999
enum class resultt { P_SATISFIABLE, P_UNSATISFIABLE, P_ERROR };
100-
virtual resultt prop_solve()=0;
100+
resultt prop_solve();
101101

102102
// satisfying assignment
103103
virtual tvt l_get(literalt a) const=0;
@@ -120,6 +120,8 @@ class propt
120120
}
121121

122122
protected:
123+
virtual resultt do_prop_solve() = 0;
124+
123125
// to avoid a temporary for lcnf(...)
124126
bvt lcnf_bv;
125127

src/solvers/sat/cnf_clause_list.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ class cnf_clause_listt:public cnft
3939
return tvt::unknown();
4040
}
4141

42-
resultt prop_solve() override
43-
{
44-
return resultt::P_ERROR;
45-
}
46-
4742
size_t no_clauses() const override
4843
{
4944
return clauses.size();
@@ -82,6 +77,11 @@ class cnf_clause_listt:public cnft
8277
}
8378

8479
protected:
80+
resultt do_prop_solve() override
81+
{
82+
return resultt::P_ERROR;
83+
}
84+
8585
clausest clauses;
8686
};
8787

src/solvers/sat/dimacs_cnf.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ class dimacs_cnf_dumpt:public cnft
5252

5353
void lcnf(const bvt &bv) override;
5454

55-
resultt prop_solve() override
56-
{
57-
return resultt::P_ERROR;
58-
}
59-
6055
tvt l_get(literalt) const override
6156
{
6257
return tvt::unknown();
@@ -68,6 +63,11 @@ class dimacs_cnf_dumpt:public cnft
6863
}
6964

7065
protected:
66+
resultt do_prop_solve() override
67+
{
68+
return resultt::P_ERROR;
69+
}
70+
7171
std::ostream &out;
7272
};
7373

src/solvers/sat/pbs_dimacs_cnf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ bool pbs_dimacs_cnft::pbs_solve()
205205
return satisfied;
206206
}
207207

208-
propt::resultt pbs_dimacs_cnft::prop_solve()
208+
propt::resultt pbs_dimacs_cnft::do_prop_solve()
209209
{
210210
std::ofstream file("temp.cnf");
211211

src/solvers/sat/pbs_dimacs_cnf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class pbs_dimacs_cnft:public dimacs_cnft
4848

4949
bool pbs_solve();
5050

51-
resultt prop_solve() override;
52-
5351
tvt l_get(literalt a) const override;
5452

5553
// dummy functions
@@ -60,6 +58,8 @@ class pbs_dimacs_cnft:public dimacs_cnft
6058
}
6159

6260
protected:
61+
resultt do_prop_solve() override;
62+
6363
std::set<int> assigned;
6464
};
6565

src/solvers/sat/satcheck_booleforce.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void satcheck_booleforce_baset::lcnf(const bvt &bv)
7979
clause_counter++;
8080
}
8181

82-
propt::resultt satcheck_booleforce_baset::prop_solve()
82+
propt::resultt satcheck_booleforce_baset::do_prop_solve()
8383
{
8484
PRECONDITION(status == SAT || status == INIT);
8585

src/solvers/sat/satcheck_booleforce.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ class satcheck_booleforce_baset:public cnf_solvert
2121
virtual ~satcheck_booleforce_baset();
2222

2323
const std::string solver_text() override;
24-
resultt prop_solve() override;
2524
tvt l_get(literalt a) const override;
2625

2726
void lcnf(const bvt &bv) override;
27+
28+
protected:
29+
resultt do_prop_solve() override;
2830
};
2931

3032
class satcheck_booleforcet:public satcheck_booleforce_baset

src/solvers/sat/satcheck_cadical.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void satcheck_cadicalt::lcnf(const bvt &bv)
6565
clause_counter++;
6666
}
6767

68-
propt::resultt satcheck_cadicalt::prop_solve()
68+
propt::resultt satcheck_cadicalt::do_prop_solve()
6969
{
7070
INVARIANT(status != statust::ERROR, "there cannot be an error");
7171

src/solvers/sat/satcheck_cadical.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class satcheck_cadicalt:public cnf_solvert
2424
virtual ~satcheck_cadicalt();
2525

2626
const std::string solver_text() override;
27-
resultt prop_solve() override;
2827
tvt l_get(literalt a) const override;
2928

3029
void lcnf(const bvt &bv) override;
@@ -42,6 +41,8 @@ class satcheck_cadicalt:public cnf_solvert
4241
bool is_in_conflict(literalt a) const override;
4342

4443
protected:
44+
resultt do_prop_solve() override;
45+
4546
// NOLINTNEXTLINE(readability/identifiers)
4647
CaDiCaL::Solver * solver;
4748
};

src/solvers/sat/satcheck_glucose.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ void satcheck_glucose_baset<T>::lcnf(const bvt &bv)
131131
}
132132
}
133133

134-
template<typename T>
135-
propt::resultt satcheck_glucose_baset<T>::prop_solve()
134+
template <typename T>
135+
propt::resultt satcheck_glucose_baset<T>::do_prop_solve()
136136
{
137137
PRECONDITION(status != statust::ERROR);
138138

src/solvers/sat/satcheck_glucose.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class satcheck_glucose_baset:public cnf_solvert
3030
satcheck_glucose_baset(T *, message_handlert &message_handler);
3131
virtual ~satcheck_glucose_baset();
3232

33-
resultt prop_solve() override;
3433
tvt l_get(literalt a) const override;
3534

3635
void lcnf(const bvt &bv) override;
@@ -53,6 +52,8 @@ class satcheck_glucose_baset:public cnf_solvert
5352
}
5453

5554
protected:
55+
resultt do_prop_solve() override;
56+
5657
T *solver;
5758

5859
void add_variables();

src/solvers/sat/satcheck_ipasir.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void satcheck_ipasirt::lcnf(const bvt &bv)
9393
clause_counter++;
9494
}
9595

96-
propt::resultt satcheck_ipasirt::prop_solve()
96+
propt::resultt satcheck_ipasirt::do_prop_solve()
9797
{
9898
INVARIANT(status!=statust::ERROR, "there cannot be an error");
9999

src/solvers/sat/satcheck_ipasir.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class satcheck_ipasirt:public cnf_solvert
2424
/// This method returns the description produced by the linked SAT solver
2525
const std::string solver_text() override;
2626

27-
resultt prop_solve() override;
28-
2927
/// This method returns the truth value for a literal of the current SAT model
3028
tvt l_get(literalt a) const override final;
3129

@@ -47,6 +45,8 @@ class satcheck_ipasirt:public cnf_solvert
4745
}
4846

4947
protected:
48+
resultt do_prop_solve() override;
49+
5050
void *solver;
5151

5252
bvt assumptions;

src/solvers/sat/satcheck_lingeling.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void satcheck_lingelingt::lcnf(const bvt &bv)
6363
clause_counter++;
6464
}
6565

66-
propt::resultt satcheck_lingelingt::prop_solve()
66+
propt::resultt satcheck_lingelingt::do_prop_solve()
6767
{
6868
PRECONDITION(status != ERROR);
6969

src/solvers/sat/satcheck_lingeling.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class satcheck_lingelingt:public cnf_solvert
2222
virtual ~satcheck_lingelingt();
2323

2424
const std::string solver_text() override;
25-
resultt prop_solve() override;
2625
tvt l_get(literalt a) const override;
2726

2827
void lcnf(const bvt &bv) override;
@@ -41,6 +40,8 @@ class satcheck_lingelingt:public cnf_solvert
4140
void set_frozen(literalt a) override;
4241

4342
protected:
43+
resultt do_prop_solve() override;
44+
4445
// NOLINTNEXTLINE(readability/identifiers)
4546
struct LGL * solver;
4647
bvt assumptions;

src/solvers/sat/satcheck_minisat.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void satcheck_minisat1_baset::lcnf(const bvt &bv)
150150
clause_counter++;
151151
}
152152

153-
propt::resultt satcheck_minisat1_baset::prop_solve()
153+
propt::resultt satcheck_minisat1_baset::do_prop_solve()
154154
{
155155
PRECONDITION(status != ERROR);
156156

@@ -262,11 +262,11 @@ const std::string satcheck_minisat1_prooft::solver_text()
262262
return "MiniSAT + Proof";
263263
}
264264

265-
propt::resultt satcheck_minisat1_coret::prop_solve()
265+
propt::resultt satcheck_minisat1_coret::do_prop_solve()
266266
{
267267
propt::resultt r;
268268

269-
r=satcheck_minisat1_prooft::prop_solve();
269+
r = satcheck_minisat1_prooft::do_prop_solve();
270270

271271
if(status==UNSAT)
272272
{

src/solvers/sat/satcheck_minisat.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class satcheck_minisat1_baset:public cnf_solvert
2525
virtual ~satcheck_minisat1_baset();
2626

2727
const std::string solver_text() override;
28-
resultt prop_solve() override;
2928
tvt l_get(literalt a) const override;
3029

3130
void lcnf(const bvt &bv) final;
@@ -48,6 +47,8 @@ class satcheck_minisat1_baset:public cnf_solvert
4847
bool is_in_conflict(literalt l) const override;
4948

5049
protected:
50+
resultt do_prop_solve() override;
51+
5152
// NOLINTNEXTLINE(readability/identifiers)
5253
class Solver *solver;
5354
void add_variables();
@@ -84,7 +85,6 @@ class satcheck_minisat1_coret:public satcheck_minisat1_prooft
8485
~satcheck_minisat1_coret();
8586

8687
const std::string solver_text() override;
87-
resultt prop_solve() override;
8888

8989
bool has_in_core() const
9090
{
@@ -99,5 +99,7 @@ class satcheck_minisat1_coret:public satcheck_minisat1_prooft
9999

100100
protected:
101101
std::vector<bool> in_core;
102+
103+
resultt do_prop_solve() override;
102104
};
103105
#endif // CPROVER_SOLVERS_SAT_SATCHECK_MINISAT_H

src/solvers/sat/satcheck_minisat2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ static void interrupt_solver(int signum)
162162

163163
#endif
164164

165-
template<typename T>
166-
propt::resultt satcheck_minisat2_baset<T>::prop_solve()
165+
template <typename T>
166+
propt::resultt satcheck_minisat2_baset<T>::do_prop_solve()
167167
{
168168
PRECONDITION(status != statust::ERROR);
169169

src/solvers/sat/satcheck_minisat2.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class satcheck_minisat2_baset:public cnf_solvert
3030
satcheck_minisat2_baset(T *, message_handlert &message_handler);
3131
virtual ~satcheck_minisat2_baset();
3232

33-
resultt prop_solve() override;
3433
tvt l_get(literalt a) const override final;
3534

3635
void lcnf(const bvt &bv) override final;
@@ -64,6 +63,8 @@ class satcheck_minisat2_baset:public cnf_solvert
6463
}
6564

6665
protected:
66+
resultt do_prop_solve() override;
67+
6768
T *solver;
6869
uint32_t time_limit_seconds;
6970

src/solvers/sat/satcheck_picosat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void satcheck_picosatt::lcnf(const bvt &bv)
6565
clause_counter++;
6666
}
6767

68-
propt::resultt satcheck_picosatt::prop_solve()
68+
propt::resultt satcheck_picosatt::do_prop_solve()
6969
{
7070
PRECONDITION(status != ERROR);
7171

src/solvers/sat/satcheck_picosat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class satcheck_picosatt:public cnf_solvert
2222
~satcheck_picosatt();
2323

2424
const std::string solver_text() override;
25-
resultt prop_solve() override;
2625
tvt l_get(literalt a) const override;
2726

2827
void lcnf(const bvt &bv) override;
@@ -40,6 +39,8 @@ class satcheck_picosatt:public cnf_solvert
4039
}
4140

4241
protected:
42+
resultt do_prop_solve() override;
43+
4344
bvt assumptions;
4445

4546
private:

src/solvers/sat/satcheck_zchaff.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void satcheck_zchaff_baset::copy_cnf()
7070
reinterpret_cast<int*>(&((*it)[0])), it->size());
7171
}
7272

73-
propt::resultt satcheck_zchaff_baset::prop_solve()
73+
propt::resultt satcheck_zchaff_baset::do_prop_solve()
7474
{
7575
// this is *not* incremental
7676
PRECONDITION(status == INIT);

src/solvers/sat/satcheck_zchaff.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class satcheck_zchaff_baset:public cnf_clause_listt
2525
virtual ~satcheck_zchaff_baset();
2626

2727
const std::string solver_text() override;
28-
resultt prop_solve() override;
2928
tvt l_get(literalt a) const override;
3029
void set_assignment(literalt a, bool value) override;
3130
virtual void copy_cnf();
@@ -36,6 +35,8 @@ class satcheck_zchaff_baset:public cnf_clause_listt
3635
}
3736

3837
protected:
38+
resultt do_prop_solve() override;
39+
3940
CSolver *solver;
4041

4142
enum statust { INIT, SAT, UNSAT, ERROR };

src/solvers/sat/satcheck_zcore.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const std::string satcheck_zcoret::solver_text()
3434
return "ZCore";
3535
}
3636

37-
propt::resultt satcheck_zcoret::prop_solve()
37+
propt::resultt satcheck_zcoret::do_prop_solve()
3838
{
3939
// We start counting at 1, thus there is one variable fewer.
4040
{

src/solvers/sat/satcheck_zcore.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class satcheck_zcoret:public dimacs_cnft
2121
virtual ~satcheck_zcoret();
2222

2323
const std::string solver_text() override;
24-
resultt prop_solve() override;
2524
tvt l_get(literalt a) const override;
2625

2726
bool is_in_core(literalt l) const
@@ -30,6 +29,8 @@ class satcheck_zcoret:public dimacs_cnft
3029
}
3130

3231
protected:
32+
resultt do_prop_solve() override;
33+
3334
std::set<unsigned> in_core;
3435
};
3536

0 commit comments

Comments
 (0)