Package net.sf.tweety.logics.fol.syntax
Class Implication
- java.lang.Object
-
- net.sf.tweety.logics.commons.syntax.RelationalFormula
-
- net.sf.tweety.logics.fol.syntax.FolFormula
-
- net.sf.tweety.logics.fol.syntax.Implication
-
- All Implemented Interfaces:
Formula,ClassicalFormula,ComplexLogicalFormula,Conjunctable,Disjunctable,Invertable,LogicStructure,ProbabilityAware,QuantifiedFormula,SimpleLogicalFormula
public class Implication extends FolFormula
The implication of first-order logic.- Author:
- Anna Gessler
-
-
Constructor Summary
Constructors Constructor Description Implication(Pair<RelationalFormula,RelationalFormula> formulas)Creates a new implication with the given pair of formulasImplication(RelationalFormula a, RelationalFormula b)Creates a new implication a=>b with the two given formulas
-
Method Summary
Modifier and Type Method Description Implicationclone()Creates a deep copy of this formulaRelationalFormulacollapseAssociativeFormulas()This method collapses all associative operations appearing in this term, e.g.booleancontainsQuantifier()Checks whether this formula contains any quantification.booleanequals(java.lang.Object obj)java.util.Set<? extends Atom>getAtoms()Processes the set of all atoms which appear in this formulaPair<RelationalFormula,RelationalFormula>getFormulas()Returns the formulas of the implication.java.util.Set<Functor>getFunctors()java.util.Set<? extends Predicate>getPredicates()Processes the set of all predicates which appear in this formulajava.util.Set<Term<?>>getTerms()<C extends Term<?>>
java.util.Set<C>getTerms(java.lang.Class<C> cls)Processes the set containing all terms of type C.java.util.Set<Variable>getUnboundVariables()inthashCode()booleanisClosed()Checks whether this formula is closed, i.e.booleanisClosed(java.util.Set<Variable> boundVariables)Checks whether this formula is closed, i.e.booleanisDnf()Checks whether this formula is in disjunctive normal form.booleanisLiteral()booleanisWellBound()Checks whether this formula is well-bound, i.e.booleanisWellBound(java.util.Set<Variable> boundVariables)Checks whether this formula is well-bound, i.e.voidsetFormulas(Pair<RelationalFormula,RelationalFormula> formulas)Sets the formulas of the implication.voidsetFormulas(RelationalFormula left, RelationalFormula right)Sets the formulas of the implication.FolFormulasubstitute(Term<?> v, Term<?> t)Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.FolFormulatoNnf()Makes the negation normal form of this formula.java.lang.StringtoString()-
Methods inherited from class net.sf.tweety.logics.fol.syntax.FolFormula
combineWithAnd, combineWithOr, complement, getQuantifierVariables, getSignature, getUniformProbability, toDnf
-
Methods inherited from class net.sf.tweety.logics.commons.syntax.RelationalFormula
allGroundInstances, allSubstitutions, containsTermsOfType, exchange, getFormula, getPredicateCls, getSatisfactionRatio, isGround, isWellFormed, substitute
-
-
-
-
Constructor Detail
-
Implication
public Implication(RelationalFormula a, RelationalFormula b)
Creates a new implication a=>b with the two given formulas- Parameters:
a- a relational formula.b- a relational formula.
-
Implication
public Implication(Pair<RelationalFormula,RelationalFormula> formulas)
Creates a new implication with the given pair of formulas- Parameters:
formulas- a pair of formulas
-
-
Method Detail
-
getFormulas
public Pair<RelationalFormula,RelationalFormula> getFormulas()
Returns the formulas of the implication.- Returns:
- the formulas that are part of the implication
-
setFormulas
public void setFormulas(Pair<RelationalFormula,RelationalFormula> formulas)
Sets the formulas of the implication.- Parameters:
formulas- the formulas
-
setFormulas
public void setFormulas(RelationalFormula left, RelationalFormula right)
Sets the formulas of the implication.- Parameters:
left-right-
-
getPredicates
public java.util.Set<? extends Predicate> getPredicates()
Description copied from interface:SimpleLogicalFormulaProcesses 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 java.util.Set<Variable> getUnboundVariables()
- Returns:
- a set of of unbound variables
-
containsQuantifier
public boolean containsQuantifier()
Description copied from interface:QuantifiedFormulaChecks whether this formula contains any quantification.- Returns:
- "true" if this formula contains a quantification.
-
isWellBound
public boolean isWellBound()
Description copied from interface:QuantifiedFormulaChecks 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(java.util.Set<Variable> boundVariables)
Description copied from interface:QuantifiedFormulaChecks 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:QuantifiedFormulaChecks 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(java.util.Set<Variable> boundVariables)
Description copied from interface:QuantifiedFormulaChecks 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 java.util.Set<Term<?>> getTerms()
- Returns:
- a set containing all terms of this logical structure
-
getTerms
public <C extends Term<?>> java.util.Set<C> getTerms(java.lang.Class<C> cls)
Description copied from interface:LogicStructureProcesses 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:FolFormulaMakes the negation normal form of this formula.- Specified by:
toNnfin classFolFormula- Returns:
- the NNF of this formula
-
collapseAssociativeFormulas
public RelationalFormula collapseAssociativeFormulas()
Description copied from class:FolFormulaThis method collapses all associative operations appearing in this term, e.g. every a||(b||c) becomes a||b||c.- Specified by:
collapseAssociativeFormulasin classFolFormula- Returns:
- the collapsed formula.
-
isDnf
public boolean isDnf()
Description copied from class:FolFormulaChecks whether this formula is in disjunctive normal form.- Specified by:
isDnfin classFolFormula- Returns:
- "true" iff this formula is in disjunctive normal form.
-
substitute
public FolFormula substitute(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
Description copied from class:RelationalFormulaSubstitutes 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:
substitutein interfaceComplexLogicalFormula- Specified by:
substitutein classFolFormula- 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:
java.lang.IllegalArgumentException- if "v" and "t" are of different sorts (NOTE: this exception is only thrown when "v" actually appears in this formula).
-
clone
public Implication clone()
Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
clonein interfaceComplexLogicalFormula- Specified by:
clonein interfaceSimpleLogicalFormula- Specified by:
clonein classFolFormula- Returns:
- the cloned formula
-
getAtoms
public java.util.Set<? extends Atom> getAtoms()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Specified by:
getAtomsin classRelationalFormula- Returns:
- all atoms that appear in this formula.
-
getFunctors
public java.util.Set<Functor> getFunctors()
- Specified by:
getFunctorsin classRelationalFormula- Returns:
- all functors that appear in this formula.
-
toString
public java.lang.String toString()
- Specified by:
toStringin classRelationalFormula
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classjava.lang.Object
-
-