# Class Equivalence

All Implemented Interfaces:
Formula, ClassicalFormula, ComplexLogicalFormula, Conjunctable, Disjunctable, Invertable, LogicStructure, ProbabilityAware, QuantifiedFormula, SimpleLogicalFormula

public class Equivalence extends FolFormula
The equivalence of first-order logic.
Author:
Anna Gessler
• ## Constructor Details

• ### Equivalence

public Equivalence
Creates a new equivalence with the given two formulas
Parameters:
a - a formula
b - a formula
• ### Equivalence

public Equivalence(Pair<RelationalFormula,RelationalFormula> formulas)
Creates a new equivalence with the given pair of formulas
Parameters:
formulas - a pair of formulas
• ## Method Details

• ### getFormulas

public  getFormulas()
Returns the formulas of the equivalence.
Returns:
the formulas that are part of the equivalence
• ### setFormulas

public void setFormulas(Pair<RelationalFormula,RelationalFormula> formulas)
Sets the formulas of the equivalence.
Parameters:
formulas - the formulas
• ### setFormulas

public void setFormulas(RelationalFormula formula1, RelationalFormula formula2)
Sets the formulas of the equivalence.
Parameters:
formula1 - 1st formula
formula2 - 2nd formula
• ### getPredicates

public Set<? extends Predicate> getPredicates()
Description copied from interface: SimpleLogicalFormula
Processes the set of all predicates which appear in this formula
Returns:
all predicates that appear in this formula
• ### isLiteral

public boolean isLiteral()
Returns:
true if the formula represents a literal in the language or false otherwise
• ### getUnboundVariables

public  getUnboundVariables()
Returns:
a set of of unbound variables
• ### containsQuantifier

public boolean containsQuantifier()
Description copied from interface: QuantifiedFormula
Checks whether this formula contains any quantification.
Returns:
"true" if this formula contains a quantification.
• ### isWellBound

public boolean isWellBound()
Description copied from interface: QuantifiedFormula
Checks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier's range.
Returns:
"true" if this formula is well-bound, "false" otherwise.
• ### isWellBound

public boolean isWellBound(Set<Variable> boundVariables)
Description copied from interface: QuantifiedFormula
Checks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier range. Every variable in "boundVariables" is assumed to be bound already.
Parameters:
boundVariables - the variables assumed to be bound.
Returns:
"true" if this formula is well-bound, "false" otherwise.
• ### isClosed

public boolean isClosed()
Description copied from interface: QuantifiedFormula
Checks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier.
Returns:
"true" if this formula is closed, "false" otherwise.
• ### isClosed

public boolean isClosed(Set<Variable> boundVariables)
Description copied from interface: QuantifiedFormula
Checks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier. Every variable in "boundVariables" is already assumed to be bound.
Parameters:
boundVariables - the variables assumed to be bound.
Returns:
"true" if this formula is closed wrt. "boundVariables", "false" otherwise.
• ### getTerms

public Set<Term<?>> getTerms()
Returns:
a set containing all terms of this logical structure
• ### getTerms

public <C extends Term<?>> Set<C> getTerms(Class<C> cls)
Description copied from interface: LogicStructure
Processes the set containing all terms of type C. This method uses the equals method of the given Class and therefore does not add terms which are sub classes of type C to the set.
Type Parameters:
C - the type of terms
Parameters:
cls - The Class structure containing type information about the searched term
Returns:
A set containing all terms of type C of this logical structure
• ### toNnf

public FolFormula toNnf()
Description copied from class: FolFormula
Makes the negation normal form of this formula.
Specified by:
toNnf in class FolFormula
Returns:
the NNF of this formula
• ### collapseAssociativeFormulas

public RelationalFormula collapseAssociativeFormulas()
Description copied from class: FolFormula
This method collapses all associative operations appearing in this term, e.g. every a||(b||c) becomes a||b||c.
Specified by:
collapseAssociativeFormulas in class FolFormula
Returns:
the collapsed formula.
• ### isDnf

public boolean isDnf()
Description copied from class: FolFormula
Checks whether this formula is in disjunctive normal form.
Specified by:
isDnf in class FolFormula
Returns:
"true" iff this formula is in disjunctive normal form.
• ### substitute

public FolFormula substitute(Term<?> v, Term<?> t) throws IllegalArgumentException
Description copied from class: RelationalFormula
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula. NOTE: if "v" is a variable and bound to a quantifier then "v" is not substituted in that quantifiers inner formula.
Specified by:
substitute in interface ComplexLogicalFormula
Specified by:
substitute in class FolFormula
Parameters:
v - the term to be substituted.
t - the term to substitute.
Returns:
a formula where every occurrence of "v" is replaced by "t".
Throws:
IllegalArgumentException - if "v" and "t" are of different sorts (NOTE: this exception is only thrown when "v" actually appears in this formula).
• ### clone

public Equivalence clone()
Description copied from interface: SimpleLogicalFormula
Creates a deep copy of this formula
Specified by:
clone in interface ComplexLogicalFormula
Specified by:
clone in interface SimpleLogicalFormula
Specified by:
clone in class FolFormula
Returns:
the cloned formula
• ### getAtoms

public Set<? extends Atom> getAtoms()
Description copied from interface: SimpleLogicalFormula
Processes the set of all atoms which appear in this formula
Specified by:
getAtoms in interface SimpleLogicalFormula
Specified by:
getAtoms in class RelationalFormula
Returns:
all atoms that appear in this formula.
• ### getFunctors

public  getFunctors()
Specified by:
getFunctors in class RelationalFormula
Returns:
all functors that appear in this formula.
• ### toString

public String toString()
Specified by:
toString in class RelationalFormula
• ### hashCode

public int hashCode()
Specified by:
hashCode in interface SimpleLogicalFormula
Overrides:
hashCode in class Object
• ### equals

public boolean equals(Object obj)
Specified by:
equals in interface SimpleLogicalFormula
Overrides:
equals in class Object