3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-26 21:16:02 +00:00

Connect conflict2

This commit is contained in:
Jakob Rath 2022-09-21 12:12:57 +02:00
parent a978604a7e
commit b43971bb4a
9 changed files with 420 additions and 293 deletions

View file

@ -26,13 +26,26 @@ namespace polysat {
class search_item;
class solver;
class inference {
class displayable {
public:
virtual ~inference() {}
virtual ~displayable() {}
virtual std::ostream& display(std::ostream& out) const = 0;
};
inline std::ostream& operator<<(std::ostream& out, inference const& i) { return i.display(out); }
inline std::ostream& operator<<(std::ostream& out, displayable const& d) { return d.display(out); }
class display_c_str : public displayable {
char const* m_str;
public:
display_c_str(char const* str) : m_str(str) { }
std::ostream& display(std::ostream& out) const override {
if (m_str)
out << m_str;
return out;
}
};
class inference : public displayable { };
class inference_named : public inference {
char const* m_name;
@ -46,12 +59,14 @@ namespace polysat {
virtual ~inference_logger() {}
/// Begin next conflict
virtual void begin_conflict(char const* text = nullptr) = 0;
void begin_conflict(char const* text = nullptr) { begin_conflict(display_c_str(text)); }
virtual void begin_conflict(displayable const& header) = 0;
/// Log inference and the current state.
virtual void log(inference const& inf) = 0;
virtual void log(char const* name) { log(inference_named(name)); }
virtual void log_var(pvar v) = 0;
/// Log relevant part of search state and viable.
/// Call end_conflict before backjumping in the solver.
virtual void end_conflict() = 0;
/// Log current conflict state (implicitly done by log_inference)
@ -62,7 +77,7 @@ namespace polysat {
class dummy_inference_logger : public inference_logger {
public:
virtual void begin_conflict(char const* text) override {}
virtual void begin_conflict(displayable const& header) override {}
virtual void log(inference const& inf) override {}
virtual void log_var(pvar v) override {}
virtual void end_conflict() override {}
@ -85,18 +100,11 @@ namespace polysat {
public:
file_inference_logger(solver& s);
/// Begin next conflict
void begin_conflict(char const* text) override;
/// Log inference and the current state.
void begin_conflict(displayable const& header) override;
void log(inference const& inf) override;
void log_var(pvar v) override;
/// Log relevant part of search state and viable.
void end_conflict() override;
/// Log current conflict state (implicitly done by log_inference)
void log_conflict_state() override;
void log_lemma(clause_builder const& cb) override;
};