31#include "PredicateIndex.hpp"
32#include "FunctionIndex.hpp"
43enum class FOFType {Empty, Atom, Neg, And, Or, Imp, Iff, A, E};
266 type = FOFType::Empty;
289 FOF result(FOFType::Neg, fs,
nullptr);
296 FOF result(FOFType::And, fs,
nullptr);
303 FOF result(FOFType::Or, fs,
nullptr);
313 FOF result(FOFType::Imp, fs,
nullptr);
323 FOF result(FOFType::Iff, fs,
nullptr);
332 FOF result(FOFType::A, fs, v);
341 FOF result(FOFType::E, fs, v);
552 static SimplificationResult
simplify_cnf(vector<Clause>&);
557 static SimplificationResult
simplify_cnf(vector<Clause>&, vector<string>&);
567 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.
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.
void convert_to_cnf_clauses(vector< Clause > &)
Convert to Conjunctive Normal Form.
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 skolemize_main(vector< Term * >)
Main helper function called by FOF::skolemize().
void remove_universal_quantifiers()
Self-explanatory.
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 definitional_convert_to_cnf_clauses(vector< Clause > &)
Convert to Conjunctive Normal Form using a form of definitional conversion.
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.
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.
void skolemize_universals_main(vector< Term * >)
The dual of skolemize_main.
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.
void find_definitional_tuple(FOF &, vector< FOF > &, bool)
Heavy-lifting for conversion to definitional clause form.
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.
void simple_negate()
Negate an FOF without applying any simplifications.
bool is_literal() const
Check if an FOF is a literal.
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.
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.
General representation of terms.
Look after terms, (ideally) using hash consing to avoid storing copies of terms.
Basic representation of variables.
Storage of named variables, and management of new, anonymous variables.