![]() |
Connect++ 0.6.1
A fast, readable connection prover for first-order logic.
|
Representation of clauses. More...
#include <Clause.hpp>
Public Member Functions | |
Clause (const vector< Literal > &new_lits) | |
Construction is just taking a new vector of Literals. | |
size_t | size () const |
Straightforward get method. | |
bool | empty () const |
Straightforward get method. | |
void | clear () |
Straightforward reset method. | |
bool | is_positive () const |
A clause is positive if it has no negated literals. | |
bool | is_negative () const |
A clause is negative if it has only negated literals. | |
void | remove_duplicates () |
Get rid of identical literals. | |
bool | has_complementary_literals () const |
Check whether the clause contains complementary literals. | |
bool | is_ground () const |
Is this a ground clause? | |
void | add_lit (const Literal &) |
Add a literal, making sure you don't duplicate. | |
void | drop_literal (LitNum) |
Get rid of the specified Literal. | |
Literal | extract_literal (LitNum) |
Get rid of and return the specified Literal. | |
Literal | get_literal (LitNum) const |
Get and return the specified Literal. | |
Literal & | operator[] (size_t) |
Direct read of the specified Literal. | |
Clause | make_copy_with_new_vars (VariableIndex &, TermIndex &) const |
Make a copy of an entire clause, introducing new variables. | |
Clause | make_copy_with_new_unique_vars (VariableIndex &, TermIndex &) const |
Make a copy of an entire clause, introducing new variables. | |
void | make_copy_with_new_vars (Literal &, Clause &, VariableIndex &, TermIndex &) |
Make a copy of an entire clause and literal, introducing new variables. | |
SimplificationResult | simplify () |
Simplify a clause by dealing with $true, $false, complementary literals, and duplicates. | |
void | random_reorder () |
Randomly re-order the literals. | |
void | reverse () |
Reverse the order of the literals in the clause. | |
string | to_string (bool=false) const |
Convert to a string. | |
string | to_prolog_string () const |
Convert to a string that can be read by Prolog. | |
string | to_tptp_string () const |
Convert to a string that is compatible with the TPTP. | |
string | make_LaTeX (bool=false) const |
Convert the clause to a LaTeX representation. | |
vector< Literal >::const_iterator | cbegin () const |
vector< Literal >::const_iterator | cend () const |
vector< Literal >::iterator | begin () |
vector< Literal >::iterator | end () |
Private Attributes | |
vector< Literal > | c |
A Clause is just a vector of Literals. | |
Static Private Attributes | |
static std::mt19937 | d |
Randomness for random reordering. | |
Friends | |
ostream & | operator<< (ostream &out, const Clause &cl) |
Representation of clauses.
Essentially straightforward as they are just vectors of Literals. Other classes do all the heavy lifting.
Definition at line 52 of file Clause.hpp.
|
inline |
Definition at line 63 of file Clause.hpp.
|
inline |
Construction is just taking a new vector of Literals.
new_lits | Reference to new vector of Literals. |
Definition at line 69 of file Clause.hpp.
void Clause::add_lit | ( | const Literal & | l | ) |
Add a literal, making sure you don't duplicate.
Yes, yes a set<> would be a good idea, but vectors are easy, nicer if you want indexes amd nicer for the cache.
l | Reference to Literal to add |
Definition at line 96 of file Clause.cpp.
|
inline |
Definition at line 236 of file Clause.hpp.
|
inline |
Definition at line 234 of file Clause.hpp.
|
inline |
Definition at line 235 of file Clause.hpp.
|
inline |
void Clause::drop_literal | ( | LitNum | l | ) |
Get rid of the specified Literal.
l | Index of literal to remove. |
Definition at line 168 of file Clause.cpp.
|
inline |
|
inline |
Definition at line 237 of file Clause.hpp.
Literal Clause::extract_literal | ( | LitNum | l | ) |
Get rid of and return the specified Literal.
l | Index of literal to remove. |
Definition at line 189 of file Clause.cpp.
Literal Clause::get_literal | ( | LitNum | l | ) | const |
Get and return the specified Literal.
l | Index of literal to return. |
Definition at line 213 of file Clause.cpp.
bool Clause::has_complementary_literals | ( | ) | const |
Check whether the clause contains complementary literals.
This does not take account of substitutions as it is mainly used for simplification before any substitutions happen.
Definition at line 74 of file Clause.cpp.
bool Clause::is_ground | ( | ) | const |
Is this a ground clause?
Do not attempt to follow substitutions.
Definition at line 87 of file Clause.cpp.
bool Clause::is_negative | ( | ) | const |
A clause is negative if it has only negated literals.
Definition at line 42 of file Clause.cpp.
bool Clause::is_positive | ( | ) | const |
A clause is positive if it has no negated literals.
Definition at line 30 of file Clause.cpp.
Clause Clause::make_copy_with_new_unique_vars | ( | VariableIndex & | vi, |
TermIndex & | ti ) const |
Make a copy of an entire clause, introducing new variables.
Straightforward because the heavy lifting is done elsewhere.
This version uses unique variables, that do not get recycled when backtracking, and are thus suitable for caching copies of clauses.
vi | Reference to the VariableIndex |
ti | Reference to the TermIndex |
Definition at line 120 of file Clause.cpp.
void Clause::make_copy_with_new_vars | ( | Literal & | _l, |
Clause & | _c, | ||
VariableIndex & | vi, | ||
TermIndex & | ti ) |
Make a copy of an entire clause and literal, introducing new variables.
Straightforward because the heavy lifting is done elsewhere.
_l | New literal. |
_c | New clause, |
vi | Reference to the VariableIndex |
ti | Reference to the TermIndex |
Definition at line 133 of file Clause.cpp.
Clause Clause::make_copy_with_new_vars | ( | VariableIndex & | vi, |
TermIndex & | ti ) const |
Make a copy of an entire clause, introducing new variables.
Straightforward because the heavy lifting is done elsewhere.
vi | Reference to the VariableIndex |
ti | Reference to the TermIndex |
Definition at line 107 of file Clause.cpp.
string Clause::make_LaTeX | ( | bool | subbed = false | ) | const |
Convert the clause to a LaTeX representation.
Assumes you are in Math Mode.
subbed | implement substitution if true. |
Definition at line 286 of file Clause.cpp.
Literal & Clause::operator[] | ( | size_t | i | ) |
Direct read of the specified Literal.
There is no check on whether you've given a sensible index, so behave yourself!
i | Index of required Literal |
Definition at line 231 of file Clause.cpp.
void Clause::random_reorder | ( | ) |
Randomly re-order the literals.
Definition at line 239 of file Clause.cpp.
void Clause::remove_duplicates | ( | ) |
Get rid of identical literals.
This does not take account of substitutions as it is mainly used for simplification before any substitutions happen.
Definition at line 54 of file Clause.cpp.
void Clause::reverse | ( | ) |
Reverse the order of the literals in the clause.
Definition at line 253 of file Clause.cpp.
SimplificationResult Clause::simplify | ( | ) |
Simplify a clause by dealing with $true, $false, complementary literals, and duplicates.
Definition at line 143 of file Clause.cpp.
|
inline |
string Clause::to_prolog_string | ( | ) | const |
Convert to a string that can be read by Prolog.
Does not apply substitutions.
Definition at line 261 of file Clause.cpp.
string Clause::to_string | ( | bool | subbed = false | ) | const |
Convert to a string.
subbed | Implement substitutions if true. |
Definition at line 257 of file Clause.cpp.
string Clause::to_tptp_string | ( | ) | const |
Convert to a string that is compatible with the TPTP.
Does not apply substitutions.
Definition at line 272 of file Clause.cpp.
|
friend |
Definition at line 297 of file Clause.cpp.
|
private |
A Clause is just a vector of Literals.
Definition at line 57 of file Clause.hpp.
|
staticprivate |
Randomness for random reordering.
Definition at line 61 of file Clause.hpp.