mirror of
https://github.com/Z3Prover/z3
synced 2025-07-23 12:48:53 +00:00
CNF conversion refactoring (#5547)
* split sat2goal out of goal2sat These two classes need different things out of the sat::solver class, and separating them makes it easier to fiddle with their dependencies independently. I also fiddled with some headers to make it possible to include sat_solver_core.h instead of sat_solver.h. * limit solver_core methods to those needed by goal2sat And switch sat2goal and sat_tactic over to relying on the derived sat::solver class instead. There were no other uses of solver_core. I'm hoping this makes it feasible to reuse goal2sat's CNF conversion from places like the tseitin-cnf tactic, so they can be unified into a single implementation.
This commit is contained in:
parent
91fb646f55
commit
426306376f
13 changed files with 506 additions and 439 deletions
|
@ -18,14 +18,13 @@ Revision History:
|
|||
--*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "sat/sat_model_converter.h"
|
||||
#include "sat/sat_types.h"
|
||||
|
||||
namespace sat {
|
||||
|
||||
class cut_simplifier;
|
||||
class extension;
|
||||
class drat;
|
||||
|
||||
class solver_core {
|
||||
protected:
|
||||
|
@ -34,27 +33,6 @@ namespace sat {
|
|||
solver_core(reslimit& l) : m_rlimit(l) {}
|
||||
virtual ~solver_core() {}
|
||||
|
||||
virtual void pop_to_base_level() {}
|
||||
virtual bool at_base_lvl() const { return true; }
|
||||
|
||||
// retrieve model if solver return sat
|
||||
virtual model const & get_model() const = 0;
|
||||
|
||||
// retrieve core from assumptions
|
||||
virtual literal_vector const& get_core() const = 0;
|
||||
|
||||
// is the state inconsistent?
|
||||
virtual bool inconsistent() const = 0;
|
||||
|
||||
// number of variables and clauses
|
||||
virtual unsigned num_vars() const = 0;
|
||||
virtual unsigned num_clauses() const = 0;
|
||||
|
||||
// check satisfiability
|
||||
virtual lbool check(unsigned num_lits = 0, literal const* lits = nullptr) = 0;
|
||||
|
||||
virtual char const* get_reason_unknown() const { return "reason unavailable"; }
|
||||
|
||||
// add clauses
|
||||
virtual void add_clause(unsigned n, literal* lits, status st) = 0;
|
||||
void add_clause(literal l1, literal l2, status st) {
|
||||
|
@ -68,18 +46,7 @@ namespace sat {
|
|||
// create boolean variable, tagged as external (= true) or internal (can be eliminated).
|
||||
virtual bool_var add_var(bool ext) = 0;
|
||||
|
||||
// update parameters
|
||||
virtual void updt_params(params_ref const& p) {}
|
||||
|
||||
|
||||
virtual bool check_invariant() const { return true; }
|
||||
virtual void display_status(std::ostream& out) const {}
|
||||
virtual void display_dimacs(std::ostream& out) const {}
|
||||
|
||||
virtual bool is_external(bool_var v) const { return true; }
|
||||
bool is_external(literal l) const { return is_external(l.var()); }
|
||||
virtual void set_external(bool_var v) {}
|
||||
virtual void set_non_external(bool_var v) {}
|
||||
virtual void set_eliminated(bool_var v, bool f) {}
|
||||
virtual void set_phase(literal l) { }
|
||||
|
||||
|
@ -96,32 +63,6 @@ namespace sat {
|
|||
virtual void set_extension(extension* e) { if (e) throw default_exception("optional API not supported"); }
|
||||
|
||||
virtual cut_simplifier* get_cut_simplifier() { return nullptr; }
|
||||
|
||||
virtual drat* get_drat_ptr() { return nullptr; }
|
||||
|
||||
|
||||
// The following methods are used when converting the state from the SAT solver back
|
||||
// to a set of assertions.
|
||||
|
||||
// retrieve model converter that handles variable elimination and other transformations
|
||||
virtual void flush(model_converter& mc) {}
|
||||
|
||||
// size of initial trail containing unit clauses
|
||||
virtual unsigned init_trail_size() const = 0;
|
||||
|
||||
// literal at trail index i
|
||||
virtual literal trail_literal(unsigned i) const = 0;
|
||||
|
||||
// collect n-ary clauses
|
||||
virtual clause_vector const& clauses() const = 0;
|
||||
|
||||
// collect binary clauses
|
||||
typedef std::pair<literal, literal> bin_clause;
|
||||
virtual void collect_bin_clauses(svector<bin_clause> & r, bool learned, bool learned_only) const = 0;
|
||||
|
||||
// collect statistics from sat solver
|
||||
virtual void collect_statistics(statistics & st) const {}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue