Package net.sf.tweety.logics.fol.syntax
Class ForallQuantifiedFormula
- java.lang.Object
-
- net.sf.tweety.logics.commons.syntax.RelationalFormula
-
- net.sf.tweety.logics.fol.syntax.FolFormula
-
- net.sf.tweety.logics.fol.syntax.ForallQuantifiedFormula
-
- All Implemented Interfaces:
Formula
,ClassicalFormula
,ComplexLogicalFormula
,Conjunctable
,Disjunctable
,Invertable
,LogicStructure
,ProbabilityAware
,QuantifiedFormula
,SimpleLogicalFormula
public class ForallQuantifiedFormula extends FolFormula
For-All-quantified first-order logic formula. Delegates to QuantifiedFormulaSupport for shared functionalities with other quantified formulas.- Author:
- Matthias Thimm, Anna Gessler
-
-
Constructor Summary
Constructors Constructor Description ForallQuantifiedFormula(RelationalFormula folFormula, java.util.Set<Variable> variables)
Creates a new quantified folFormula with the given folFormula and variables.ForallQuantifiedFormula(RelationalFormula folFormula, Variable variable)
Creates a new quantified folFormula with the given folFormula and variable.ForallQuantifiedFormula(ForallQuantifiedFormula other)
-
Method Summary
Modifier and Type Method Description ForallQuantifiedFormula
clone()
Creates a deep copy of this formulaFolFormula
collapseAssociativeFormulas()
This method collapses all associative operations appearing in this term, e.g.boolean
containsQuantifier()
Checks whether this formula contains any quantification.boolean
equals(java.lang.Object obj)
java.util.Set<FolAtom>
getAtoms()
Processes the set of all atoms which appear in this formulaFolFormula
getFormula()
java.util.Set<Functor>
getFunctors()
java.util.Set<? extends Predicate>
getPredicates()
Processes the set of all predicates which appear in this formulajava.util.Set<FolFormula>
getQuantifiedFormulas()
java.util.Set<Variable>
getQuantifierVariables()
java.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()
boolean
isClosed()
Checks whether this formula is closed, i.e.boolean
isClosed(java.util.Set<Variable> boundVariables)
Checks whether this formula is closed, i.e.boolean
isDnf()
Checks whether this formula is in disjunctive normal form.boolean
isLiteral()
boolean
isWellBound()
Checks whether this formula is well-bound, i.e.boolean
isWellBound(java.util.Set<Variable> boundVariables)
Checks whether this formula is well-bound, i.e.void
setFormula(FolFormula formula)
void
setQuantifierVariables(java.util.Set<Variable> variables)
ForallQuantifiedFormula
substitute(Term<?> v, Term<?> t)
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.FolFormula
toNnf()
Makes the negation normal form of this formula.java.lang.String
toString()
-
Methods inherited from class net.sf.tweety.logics.fol.syntax.FolFormula
combineWithAnd, combineWithOr, complement, getSignature, getUniformProbability, toDnf
-
Methods inherited from class net.sf.tweety.logics.commons.syntax.RelationalFormula
allGroundInstances, allSubstitutions, containsTermsOfType, exchange, getPredicateCls, getSatisfactionRatio, isGround, isWellFormed, substitute
-
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
hashCode
-
-
-
-
Constructor Detail
-
ForallQuantifiedFormula
public ForallQuantifiedFormula(RelationalFormula folFormula, java.util.Set<Variable> variables)
Creates a new quantified folFormula with the given folFormula and variables.- Parameters:
folFormula
- the folFormula this quantified folFormula ranges over.variables
- the variables of this quantified folFormula.
-
ForallQuantifiedFormula
public ForallQuantifiedFormula(RelationalFormula folFormula, Variable variable)
Creates a new quantified folFormula with the given folFormula and variable.- Parameters:
folFormula
- the folFormula this quantified folFormula ranges over.variable
- the variable of this quantified folFormula.
-
ForallQuantifiedFormula
public ForallQuantifiedFormula(ForallQuantifiedFormula other)
-
-
Method Detail
-
getQuantifiedFormulas
public java.util.Set<FolFormula> getQuantifiedFormulas()
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Overrides:
equals
in classjava.lang.Object
-
toNnf
public FolFormula toNnf()
Description copied from class:FolFormula
Makes the negation normal form of this formula.- Specified by:
toNnf
in classFolFormula
- Returns:
- the NNF of this formula
-
collapseAssociativeFormulas
public FolFormula 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 classFolFormula
- Returns:
- the collapsed formula.
-
substitute
public ForallQuantifiedFormula substitute(Term<?> v, Term<?> t) throws java.lang.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 interfaceComplexLogicalFormula
- Specified by:
substitute
in 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).
-
toString
public java.lang.String toString()
- Specified by:
toString
in classRelationalFormula
-
clone
public ForallQuantifiedFormula clone()
Description copied from interface:SimpleLogicalFormula
Creates a deep copy of this formula- Specified by:
clone
in interfaceComplexLogicalFormula
- Specified by:
clone
in interfaceSimpleLogicalFormula
- Specified by:
clone
in classFolFormula
- Returns:
- the cloned formula
-
getFormula
public FolFormula getFormula()
- Specified by:
getFormula
in interfaceQuantifiedFormula
- Overrides:
getFormula
in classRelationalFormula
- Returns:
- the relational formula
-
getQuantifierVariables
public java.util.Set<Variable> getQuantifierVariables()
- Specified by:
getQuantifierVariables
in interfaceQuantifiedFormula
- Overrides:
getQuantifierVariables
in classFolFormula
- Returns:
- a set containing all quantified variables
-
setFormula
public void setFormula(FolFormula formula)
-
setQuantifierVariables
public void setQuantifierVariables(java.util.Set<Variable> variables)
-
getAtoms
public java.util.Set<FolAtom> getAtoms()
Description copied from interface:SimpleLogicalFormula
Processes the set of all atoms which appear in this formula- Specified by:
getAtoms
in interfaceSimpleLogicalFormula
- Specified by:
getAtoms
in classRelationalFormula
- Returns:
- all atoms that appear in this formula.
-
getFunctors
public java.util.Set<Functor> getFunctors()
- Specified by:
getFunctors
in classRelationalFormula
- Returns:
- all functors that appear in this formula.
-
isDnf
public boolean isDnf()
Description copied from class:FolFormula
Checks whether this formula is in disjunctive normal form.- Specified by:
isDnf
in classFolFormula
- Returns:
- "true" iff this formula is in disjunctive normal form.
-
getPredicates
public java.util.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 java.util.Set<Variable> 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(java.util.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(java.util.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 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: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
-
-