31#include "PredicateIndex.hpp"
32#include "FunctionIndex.hpp"
35#include "TPTPRecords.hpp"
44enum class FOFType {Empty, Atom, Neg, And, Or, Imp, Iff, A, E};
277 type = FOFType::Empty;
300 FOF result(FOFType::Neg, fs,
nullptr);
307 FOF result(FOFType::And, fs,
nullptr);
314 FOF result(FOFType::Or, fs,
nullptr);
324 FOF result(FOFType::Imp, fs,
nullptr);
334 FOF result(FOFType::Iff, fs,
nullptr);
343 FOF result(FOFType::A, fs, v);
352 FOF result(FOFType::E, fs, v);
577 static SimplificationResult
simplify_cnf(vector<Clause>&);
582 static SimplificationResult
simplify_cnf(vector<Clause>&,
594 friend ostream& operator<<(ostream&,
const FOF&);
Representation of first order formulas.
void skolemize()
Skolemize the given formula.
void remove_iff()
Replace <-> throughout using ->.
static FOF make_or(const vector< FOF > &fs)
Directly make a disjunction.
void miniscope_all()
Apply miniscoping to all subformulas.
size_t find_or() const
Does the collection of subformulas contain an OR? If so, find it.
static VariableIndex * var_index
Access to the index: static because all FOFs should share it.
void convert_to_nnf()
Convert to Negation Normal Form.
void clear()
Make an FOFType::Empty.
string to_tptp_string(bool=false) const
Convert a FOF into a nice-looking string in the TPTP format.
void add_formula(const FOF &f)
Add a subformula.
void dnf_invert_and_convert_to_clauses(vector< Clause > &) const
Assuming you have a DNF, invert it and convert it to a collection of CNF clauses.
set< Term * > find_free_variables() const
Find the free variables in the formula.
FOFType fof_type()
Basic get method.
void show_indexes() const
Show the indices.
void remove_redundant_quantifiers()
Remove quantifiers if they don't bind anything in their scope.
void miniscope_split(Variable *, vector< FOF > &, vector< FOF > &)
Helper for miniscope.
void split_sub_formulas(vector< FOF > &, vector< FOF > &)
Split subformulas in half.
void make_unique_bound_variables()
Replace all bound variables with unique new ones.
static SimplificationResult simplify_cnf(vector< Clause > &)
Simplify the clauses in a CNF using the method in Clause.
void remove_universal_quantifiers()
Self-explanatory.
void skolemize_main(vector< Term * >, FOF *, bool=false)
Main helper function called by FOF::skolemize().
Variable * var
Associate a Variable with a quantifier.
bool distribute_or_once()
Find an OR that can be distributed and deal with it. Indicate if there isn't one.
FOFType type
Used for all FOFs to denote what kind it it.
static FOF make_and(const vector< FOF > &fs)
Directly make a conjunction.
void miniscope()
Apply the rules for miniscoping.
static FOF make_iff(const FOF &lhs, const FOF &rhs)
Directly make an iff.
void push_negs()
Push all negations in.
static FOF make_literal(const Literal &lit)
Directly make a Literal.
static void set_indexes(std::tuple< VariableIndex *, FunctionIndex *, PredicateIndex *, TermIndex * > is)
Set up pointer to the variable index etc.
bool distribute_and_once()
Find an AND that can be distributed and deal with it. Indicate if there isn't one.
bool has_free_variable(Variable *)
Does this formula contain the specified variable unbound?
static FOF make_neg(const FOF &f)
Directly negate a FOF.
void skolemize_universals()
Skolemize the universal quantifiers in the given formula.
void replace_variable(Variable *, Variable *)
Self-explanatory.
vector< FOF > sub_formulas
Most FOFs will have subformulas.
void to_Literal(Literal &) const
Assuming the FOF is a literal, convert it to something of type Literal.
FOF make_definitional_predicate() const
When doing definitional clause conversion you need to be able to make unique new predicates....
static FOF make_exists(const FOF &f, Variable *v)
Directly make an existentially quantified FOF.
void definitional_convert_to_cnf_clauses(vector< Clause > &, vector< string > &, const string &)
Convert to Conjunctive Normal Form using a form of definitional conversion.
static TermIndex * term_index
Access to the index: static because all FOFs should share it.
void remove_negation()
Remove the leading negation from an arbitrary FOF, if it has one.
static PredicateIndex * pred_index
Access to the index: static because all FOFs should share it.
static FOF make_forall(const FOF &f, Variable *v)
Directly make a universally quantified FOF.
void convert_to_clauses(vector< Clause > &) const
Assuming you have a CNF, convert it to a collection of Clauses.
static void set_recs_p(TPTPRecords *_p)
Set up the pointer allowing TPTP outputs to be added.
void remove_imp()
Replace A->B throughout with neg A v B.
size_t find_and() const
Does the collection of subformulas contain an AND? If so, find it.
static FunctionIndex * fun_index
Access to the index: static because all FOFs should share it.
FOF(FOFType t)
You probably don't want this constructor.
FOF()=delete
You don't want this constructor.
void distribute_and()
Distribute ANDs to the maximum extent possible.
Term * make_skolem_function(const vector< Term * > &)
Make a new Skolem function.
static FOF make_imp(const FOF &lhs, const FOF &rhs)
Directly make an implication.
void distribute_or()
Distribute ORs to the maximum extent possible.
static TPTPRecords * recs_p
Allow FOF to add TPTP outputs.
void convert_to_cnf_clauses(vector< Clause > &, vector< string > &, const string &)
Convert to Conjunctive Normal Form.
void find_definitional_tuple(FOF &, vector< FOF > &, vector< FOF > &, bool)
Heavy-lifting for conversion to definitional clause form.
void simple_negate()
Negate an FOF without applying any simplifications.
bool is_literal() const
Check if an FOF is a literal.
void skolemize_universals_main(vector< Term * >, FOF *, bool=false)
The dual of skolemize_main.
string to_string() const
Convert a FOF into a nice-looking string.
void negate()
Negate an FOF, applying obvious simplifications if it's already negated or an implication.
string predicate_to_tptp_string() const
Assuming this is an Atom, return the predicate name as a string.
void remove_existential_quantifiers()
Self-explanatory.
void invert_literal()
Self-explanatory!
bool is_clause() const
Check if something is a clause.
Literal pred
FOFType::Atom can store one of these to represent a Literal.
void replace_variable_with_term(Term *, Variable *)
Replace a Variable with a Term.
Mechanism for looking after functions.
Basic representation of literals, bundling together (pointers to) a Predicate, a collection of argume...
void clear()
Basic manipulation - entirely self-explanatory.
Management of Predicate objects.
Class collecting a bunch of TPTPRecord items for later formatting.
General representation of terms.
Look after terms, using hash consing to avoid storing copies of terms.
Basic representation of variables.
Storage of named variables, and management of new, anonymous and unique variables.