Connect++ 0.1
A fast, readable connection prover for first-order logic.
|
Representation of first order formulas. More...
#include <FOF.hpp>
Public Member Functions | |
FOF ()=delete | |
You don't want this constructor. | |
FOF (FOFType t) | |
You probably don't want this constructor. | |
FOF (const Literal &) | |
Construct FOF from Literal. | |
FOF (FOFType, const vector< FOF > &, Variable *) | |
Construct FOF for a non-literal. | |
void | show_indexes () const |
Show the indices. | |
FOFType | fof_type () |
Basic get method. | |
void | add_formula (const FOF &f) |
Add a subformula. | |
void | clear () |
Make an FOFType::Empty. | |
bool | is_literal () const |
Check if an FOF is a literal. | |
bool | is_clause () const |
Check if something is a clause. | |
void | remove_negation () |
Remove the leading negation from an arbitrary FOF, if it has one. | |
void | negate () |
Negate an FOF, applying obvious simplifications if it's already negated or an implication. | |
void | remove_iff () |
Replace <-> throughout using ->. | |
void | remove_imp () |
Replace A->B throughout with neg A v B. | |
void | make_unique_bound_variables () |
Replace all bound variables with unique new ones. | |
void | push_negs () |
Push all negations in. | |
void | convert_to_nnf () |
Convert to Negation Normal Form. | |
void | miniscope () |
Apply the rules for miniscoping. | |
void | convert_to_cnf_clauses (vector< Clause > &) |
Convert to Conjunctive Normal Form. | |
void | skolemize () |
Skolemize the given formula. | |
void | remove_universal_quantifiers () |
Self-explanatory. | |
void | to_Literal (Literal &) const |
Assuming the FOF is a literal, convert it to something of type Literal. | |
void | convert_to_clauses (vector< Clause > &) const |
Assuming you have a CNF, convert it to a collection of Clauses. | |
size_t | find_and () const |
Does the collection of subformulas contain an AND? If so, find it. | |
bool | distribute_or_once () |
Find an OR that can be distributed and deal with it. Indicate if there isn't one. | |
void | distribute_or () |
string | to_string () const |
Convert a FOF into a nice-looking string. | |
Static Public Member Functions | |
static void | set_indexes (std::tuple< VariableIndex *, FunctionIndex *, PredicateIndex *, TermIndex * > is) |
Set up pointer to the variable index etc. | |
static FOF | make_literal (const Literal &lit) |
Directly make a Literal. | |
static FOF | make_neg (const FOF &f) |
Directly negate a FOF. | |
static FOF | make_and (const vector< FOF > &fs) |
Directly make a conjunction. | |
static FOF | make_or (const vector< FOF > &fs) |
Directly make a disjunction. | |
static FOF | make_imp (const FOF &lhs, const FOF &rhs) |
Directly make an implication. | |
static FOF | make_iff (const FOF &lhs, const FOF &rhs) |
Directly make an iff. | |
static FOF | make_forall (const FOF &f, Variable *v) |
Directly make a universally quantified FOF. | |
static FOF | make_exists (const FOF &f, Variable *v) |
Directly make an existentially quantified FOF. | |
static SimplificationResult | simplify_cnf (vector< Clause > &) |
Simplify the clauses in a CNF using the method in Clause. | |
Friends | |
ostream & | operator<< (ostream &, const FOF &) |
Representation of first order formulas.
First and foremost: I intensely dislike the use of inheritance. I vastly prefer to make the methods static and do everything the obvioous way. If you want the alternative sort of OO, then feel free to implement this yourself.
This has to play nicely with the parser and with the indexing of terms, variables and so on, so it needs pointers to the relevant indices.
FOF::FOF | ( | const Literal & | lit | ) |
void FOF::convert_to_cnf_clauses | ( | vector< Clause > & | cs | ) |
Convert to Conjunctive Normal Form.
Follow the usual recipe (Larry's lecture notes.) BUT there are lots of ways to do this—at present there is nothing sophisticated happening, and the approach is entirely obvious/straightforward.
void FOF::convert_to_nnf | ( | ) |
Convert to Negation Normal Form.
Follows the usual recipe (Larry's lecture notes.)
void FOF::distribute_or | ( | ) |
Distribute ORs to the maximum extent possible.
Assumes you have nothing but a quantifier-free NNF. The result will have a tree structure with ANDs at the top, then ORs, then literals.
size_t FOF::find_and | ( | ) | const |
Does the collection of subformulas contain an AND? If so, find it.
Note: does not do any recursion – only looks at the top level.
bool FOF::is_clause | ( | ) | const |
Check if something is a clause.
This check in the strict sense: either it must be a literal or a disjunction of literals, including an empty disjunction.
Returns false if FOFType::Empty.
bool FOF::is_literal | ( | ) | const |
Check if an FOF is a literal.
Works in general, not just for NNF.
Directly negate a FOF.
Careful: no attempt here to make any obvious simplifications.
void FOF::make_unique_bound_variables | ( | ) |
Replace all bound variables with unique new ones.
Has to be done with care to maintain the indexes correctly.
void FOF::miniscope | ( | ) |
Apply the rules for miniscoping.
Push the quantifiers in as much as you can. Don't use this unless your formula is in NNF.
void FOF::push_negs | ( | ) |
Push all negations in.
DON'T call it on anything with a -> or <->.
void FOF::skolemize | ( | ) |
Skolemize the given formula.
All the hard work is done by skolemize_main.
void FOF::to_Literal | ( | Literal & | new_lit | ) | const |