Skip to content

Commit ef366e5

Browse files
Split out is_in_conflict solver capability
This is only provided by the prop_conv_solvert-based hierarchy at the moment and is quite specific to MiniSAT-based solvers. The functionality itself is used out-of-tree only (2LS).
1 parent b77b5b0 commit ef366e5

File tree

5 files changed

+41
-20
lines changed

5 files changed

+41
-20
lines changed

src/solvers/conflict_provider.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*******************************************************************\
2+
3+
Module: Capability to check whether an expression is a reason for
4+
the solver returning UNSAT
5+
6+
Author: Peter Schrammel
7+
8+
\*******************************************************************/
9+
10+
/// \file
11+
/// Capability to check whether an expression is a reason for
12+
/// the solver returning UNSAT
13+
14+
#ifndef CPROVER_SOLVERS_CONFLICT_PROVIDER_H
15+
#define CPROVER_SOLVERS_CONFLICT_PROVIDER_H
16+
17+
class exprt;
18+
19+
class conflict_providert
20+
{
21+
public:
22+
/// Returns true if an expression is in the final conflict leading to UNSAT.
23+
/// The argument can be a Boolean expression or something more
24+
/// solver-specific, e.g. a `literal_exprt`.
25+
virtual bool is_in_conflict(const exprt &) const = 0;
26+
27+
virtual ~conflict_providert() = default;
28+
};
29+
30+
#endif // CPROVER_SOLVERS_CONFLICT_PROVIDER_H

src/solvers/prop/prop_conv.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ exprt prop_convt::handle(const exprt &expr)
3636
return literal_exprt(l);
3737
}
3838

39-
/// determine whether a variable is in the final conflict
40-
bool prop_convt::is_in_conflict(literalt) const
41-
{
42-
UNREACHABLE;
43-
return false;
44-
}
45-
4639
void prop_convt::set_assumptions(const bvt &)
4740
{
4841
UNREACHABLE;

src/solvers/prop/prop_conv.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ class prop_convt:public decision_proceduret
4646
virtual void set_assumptions(const bvt &_assumptions);
4747
virtual bool has_set_assumptions() const { return false; }
4848
virtual void set_all_frozen() {}
49-
50-
// returns true if an assumption is in the final conflict
51-
virtual bool is_in_conflict(literalt l) const;
52-
virtual bool has_is_in_conflict() const { return false; }
5349
};
5450

5551
#endif // CPROVER_SOLVERS_PROP_PROP_CONV_H

src/solvers/prop/prop_conv_solver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ Author: Daniel Kroening, [email protected]
1010

1111
#include <algorithm>
1212

13+
bool prop_conv_solvert::is_in_conflict(const exprt &expr) const
14+
{
15+
return prop.is_in_conflict(to_literal_expr(expr).get_literal());
16+
}
17+
1318
bool prop_conv_solvert::literal(const symbol_exprt &expr, literalt &dest) const
1419
{
1520
PRECONDITION(expr.type().id() == ID_bool);

src/solvers/prop/prop_conv_solver.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ Author: Daniel Kroening, [email protected]
1616
#include <util/message.h>
1717
#include <util/std_expr.h>
1818

19+
#include <solvers/conflict_provider.h>
20+
1921
#include "literal.h"
2022
#include "literal_expr.h"
2123
#include "prop.h"
2224
#include "prop_conv.h"
2325
#include "solver_resource_limits.h"
2426

25-
class prop_conv_solvert : public prop_convt, public solver_resource_limitst
27+
class prop_conv_solvert : public conflict_providert,
28+
public prop_convt,
29+
public solver_resource_limitst
2630
{
2731
public:
2832
prop_conv_solvert(propt &_prop, message_handlert &message_handler)
@@ -65,14 +69,7 @@ class prop_conv_solvert : public prop_convt, public solver_resource_limitst
6569
freeze_all = true;
6670
}
6771
literalt convert(const exprt &expr) override;
68-
bool is_in_conflict(literalt l) const override
69-
{
70-
return prop.is_in_conflict(l);
71-
}
72-
bool has_is_in_conflict() const override
73-
{
74-
return prop.has_is_in_conflict();
75-
}
72+
bool is_in_conflict(const exprt &expr) const override;
7673

7774
// get literal for expression, if available
7875
bool literal(const symbol_exprt &expr, literalt &literal) const;

0 commit comments

Comments
 (0)