27std::mt19937
Clause::d(params::random_seed);
33 cerr <<
"Don't check an empty clause for positivity" << endl;
35 for (
size_t i = 0; i <
c.size(); i++) {
45 cerr <<
"Don't check an empty clause for negativity" << endl;
47 for (
size_t i = 0; i <
c.size(); i++) {
58 vector<Literal> new_c;
59 for (
size_t i = 0; i < s - 1; i++) {
61 for (
size_t j = i+1; j < s; j++ ) {
68 new_c.push_back(
c[i]);
70 new_c.push_back(
c[s - 1]);
78 for (
size_t i = 0; i < s - 1; i++) {
79 for (
size_t j = i+1; j < s; j++) {
80 if (
c[i].is_complement_of(
c[j]))
88 for (
size_t i = 0; i <
c.size(); i++)
91 cerr <<
"Don't duplicate Literals in a clause!" << endl;
101 cerr <<
"You are making a copy of an empty clause" << endl;
103 vector<Literal> new_lits;
104 unordered_map<Variable*,Term*> new_vars;
105 for (
size_t i = 0; i <
c.size(); i++)
106 new_lits.push_back(
c[i].make_copy_with_new_vars_helper(vi, ti, new_vars));
113 vector<Literal> new_clause;
114 bool clause_is_true =
false;
119 clause_is_true =
true;
122 new_clause.push_back(lit);
126 return SimplificationResult::Tautology;
129 return SimplificationResult::Contradiction;
131 return SimplificationResult::Tautology;
132 return SimplificationResult::OK;
138 cerr <<
"Can't drop_literal from empty clause" << endl;
142 if (l >
c.size() - 1) {
144 cerr <<
"drop_literal argument is out of range" << endl;
160 cerr <<
"Can't extract_literal from empty clause" << endl;
164 if (l >
c.size() - 1) {
166 cerr <<
"extract_literal argument is out of range" << endl;
182 if (i >
c.size() - 1)
183 cerr <<
"You're out of range accessing a clause" << endl;
190 vector<size_t> new_order;
192 for (
size_t i = 0; i < s; i++)
193 new_order.push_back(i);
194 std::shuffle(new_order.begin(), new_order.end(),
d);
196 vector<Literal> new_c =
c;
197 for (
size_t i = 0; i < s; i++) {
198 c[i] = new_c[new_order[i]];
203 return vector_to_string(
c, subbed,
"{ ",
" }",
", ");
210 result += l.to_prolog_string();
221 result += l.to_tptp_string();
223 if (s ==
string(
", "))
233 string s (
"\\textcolor{blue}{\\{} ");
235 s += l.make_LaTeX(subbed);
238 s +=
"\\textcolor{blue}{\\}}";
242ostream& operator<<(ostream& out,
const Clause& cl) {
244 size_t s = cl.
c.size();
246 for (
const Literal& l : cl.c) {
247 out << l.to_string();
249 out <<
" " << unicode_symbols::LogSym::or_sym <<
" ";
Representation of clauses.
Literal & operator[](size_t)
Direct read of the specified Literal.
Literal extract_literal(LitNum)
Get rid of and return the specified Literal.
bool has_complementary_literals() const
Check whether the clause contains complementary literals.
string to_tptp_string() const
Convert to a string that is compatible with the TPTP.
void random_reorder()
Randomly re-order the literals.
void remove_duplicates()
Get rid of identical literals.
static std::mt19937 d
Randomness for random reordering.
string to_prolog_string() const
Convert to a string that can be read by Prolog.
Clause make_copy_with_new_vars(VariableIndex &, TermIndex &) const
Make a copy of an entire clause, introducing new variables.
vector< Literal > c
A Clause is just a vector of Literals.
SimplificationResult simplify()
Simplify a clause by dealing with $true, $false, complementary literals, and duplicates.
bool is_positive() const
A clause is positive if it has no negated literals.
void add_lit(const Literal &)
Add a literal, making sure you don't duplicate.
bool is_negative() const
A clause is negative if it has only negated literals.
string to_string(bool=false) const
Convert to a string.
string make_LaTeX(bool=false) const
Convert the clause to a LaTeX representation.
void drop_literal(LitNum)
Get rid of the specified Literal.
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of argume...
Look after terms, (ideally) using hash consing to avoid storing copies of terms.
Storage of named variables, and management of new, anonymous and unique variables.
Simple function object for putting commas in lists.