Google OR-Tools v9.14
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
drat_writer.h
Go to the documentation of this file.
1// Copyright 2010-2025 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_SAT_DRAT_WRITER_H_
15#define OR_TOOLS_SAT_DRAT_WRITER_H_
16
17#include <string>
18
19#include "absl/types/span.h"
20#include "ortools/base/file.h"
22
23namespace operations_research {
24namespace sat {
25
26// DRAT is a SAT proof format that allows a simple program to check that the
27// problem is really UNSAT. The description of the format and a checker are
28// available at: // http://www.cs.utexas.edu/~marijn/drat-trim/
29//
30// Note that DRAT proofs are often huge (can be GB), and take about as much time
31// to check as it takes for the solver to find the proof in the first place!
33 public:
34 DratWriter(bool in_binary_format, File* output)
35 : in_binary_format_(in_binary_format), output_(output) {}
37
38 // Writes a new clause to the DRAT output. Note that the RAT property is only
39 // checked on the first literal.
40 void AddClause(absl::Span<const Literal> clause);
41
42 // Writes a "deletion" information about a clause that has been added before
43 // to the DRAT output. Note that it is also possible to delete a clause from
44 // the problem.
45 void DeleteClause(absl::Span<const Literal> clause);
46
47 private:
48 void WriteClause(absl::Span<const Literal> clause);
49
50 // TODO(user): Support binary format as proof in text format can be large.
51 bool in_binary_format_;
52 File* output_;
53
54 std::string buffer_;
55};
56
57} // namespace sat
58} // namespace operations_research
59
60#endif // OR_TOOLS_SAT_DRAT_WRITER_H_
Definition file.h:29
void DeleteClause(absl::Span< const Literal > clause)
DratWriter(bool in_binary_format, File *output)
Definition drat_writer.h:34
void AddClause(absl::Span< const Literal > clause)
In SWIG mode, we don't want anything besides these top-level includes.