20#if !defined(__PORTABLE_PLATFORM__)
23#include "absl/log/check.h"
24#include "absl/types/span.h"
35 : variable_index_(0), drat_checker_(new
DratChecker()) {}
40 drat_writer_(new
DratWriter(in_binary_format, output)) {
42 drat_checker_ = std::make_unique<DratChecker>();
50 for (BooleanVariable v(0); v < mapping.size(); ++v) {
51 const BooleanVariable image = mapping[v];
53 if (image >= new_mapping.size())
57 v < reverse_mapping_.size() ? reverse_mapping_[v] : v;
61 std::swap(new_mapping, reverse_mapping_);
65 CHECK_GE(num_variables, reverse_mapping_.size());
66 while (reverse_mapping_.size() < num_variables) {
67 reverse_mapping_.
push_back(BooleanVariable(variable_index_++));
72 reverse_mapping_.
push_back(BooleanVariable(variable_index_++));
76 if (drat_checker_ !=
nullptr) {
77 drat_checker_->AddProblemClause(clause);
83 if (drat_checker_ !=
nullptr) {
84 drat_checker_->AddInferedClause(values_);
86 if (drat_writer_ !=
nullptr) {
87 drat_writer_->AddClause(values_);
93 if (drat_checker_ !=
nullptr) {
94 drat_checker_->DeleteClause(values_);
96 if (drat_writer_ !=
nullptr) {
97 drat_writer_->DeleteClause(values_);
102 if (drat_checker_ !=
nullptr) {
104 drat_checker_->AddInferedClause({});
105 return drat_checker_->Check(max_time_in_seconds);
110void DratProofHandler::MapClause(absl::Span<const Literal> clause) {
112 for (
const Literal l : clause) {
113 CHECK_LT(l.Variable(), reverse_mapping_.size());
114 const Literal original_literal =
115 Literal(reverse_mapping_[l.Variable()], l.IsPositive());
116 values_.push_back(original_literal);
122 std::sort(values_.begin(), values_.end(), [](Literal
a, Literal
b) {
123 return std::abs(a.SignedValue()) > std::abs(b.SignedValue());
DratChecker::Status Check(double max_time_in_seconds)
void AddProblemClause(absl::Span< const Literal > clause)
void ApplyMapping(const util_intops::StrongVector< BooleanVariable, BooleanVariable > &mapping)
void AddClause(absl::Span< const Literal > clause)
void DeleteClause(absl::Span< const Literal > clause)
void SetNumVariables(int num_variables)
This need to be called when new variables are created.
void push_back(const value_type &val)
void resize(size_type new_size)
const BooleanVariable kNoBooleanVariable(-1)
In SWIG mode, we don't want anything besides these top-level includes.