/*++ Copyright (c) 2021 Microsoft Corporation Module Name: Conflict explanation Author: Nikolaj Bjorner (nbjorner) 2021-03-19 Jakob Rath 2021-04-6 --*/ #pragma once #include "math/polysat/conflict.h" #include "math/polysat/constraint.h" #include "math/polysat/clause_builder.h" #include "math/polysat/interval.h" namespace polysat { class solver; class explainer { friend class conflict; protected: solver& s; public: explainer(solver& s) :s(s) {} virtual ~explainer() {} virtual bool try_explain(pvar v, /* vector const& cjust_v, */ conflict& core) = 0; }; class ex_polynomial_superposition : public explainer { private: signed_constraint resolve1(pvar v, signed_constraint c1, signed_constraint c2); lbool find_replacement(signed_constraint c2, pvar v, conflict& core); void reduce_by(pvar v, conflict& core); bool reduce_by(pvar, signed_constraint c, conflict& core); lbool try_explain1(pvar v, conflict& core); public: ex_polynomial_superposition(solver& s) : explainer(s) {} bool try_explain(pvar v, conflict& core) override; }; #if 0 class conflict_explainer { solver& m_solver; // conflict m_conflict; vector m_new_assertions; // to be inserted into Gamma (conclusions from saturation) scoped_ptr_vector inference_engines; bool push_omega_mul(clause_builder& clause, unsigned level, unsigned p, pdd const& x, pdd const& y); // Gamma // search_state& search() { return m_solver.m_search; } // Core // conflict& conflict() { return m_solver.m_conflict; } public: /** Create empty conflict */ conflict_explainer(solver& s); /** Perform one step of core saturation, if possible. * Core saturation derives new constraints according applicable inference rules. */ bool saturate(); /** resolve conflict state against assignment to v */ void resolve(pvar v, ptr_vector const& cjust_v); void resolve(sat::literal lit); // TODO: move conflict resolution from solver into this class. // we have a single public method as entry point to conflict resolution. // what do we need to return? /** conflict resolution until first (relevant) decision */ void resolve(); }; #endif }