Class AssociativeFolFormula
- java.lang.Object
-
- org.tweetyproject.logics.commons.syntax.RelationalFormula
-
- org.tweetyproject.logics.fol.syntax.FolFormula
-
- org.tweetyproject.logics.fol.syntax.AssociativeFolFormula
-
- All Implemented Interfaces:
java.lang.Iterable<RelationalFormula>,java.util.Collection<RelationalFormula>,java.util.List<RelationalFormula>,Formula,AssociativeFormulaSupport.AssociativeSupportBridge,AssociativeFormula<RelationalFormula>,ClassicalFormula,ComplexLogicalFormula,Conjunctable,Disjunctable,Invertable,LogicStructure,ProbabilityAware,QuantifiedFormula,SimpleLogicalFormula
- Direct Known Subclasses:
Conjunction,Disjunction,ExclusiveDisjunction
public abstract class AssociativeFolFormula extends FolFormula implements AssociativeFormula<RelationalFormula>, AssociativeFormulaSupport.AssociativeSupportBridge
This class captures the common functionalities first order associative formulas like conjunction, disjunction, etc.- Author:
- Matthias Thimm, Tim Janus
-
-
Constructor Summary
Constructors Constructor Description AssociativeFolFormula()Creates a new (empty) associative formula.AssociativeFolFormula(java.util.Collection<? extends RelationalFormula> formulas)Creates a new associative formula with the given inner formulas.AssociativeFolFormula(RelationalFormula first, RelationalFormula second)Creates a new associative formula with the two given formulae
-
Method Summary
Modifier and Type Method Description voidadd(int index, RelationalFormula element)booleanadd(RelationalFormula e)booleanadd(FolFormula... formulas)Adds the specified elements to the end of this collection (optional operation).booleanaddAll(int index, java.util.Collection<? extends RelationalFormula> c)booleanaddAll(java.util.Collection<? extends RelationalFormula> c)voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)booleancontainsQuantifier()Checks whether this formula contains any quantification.SignaturecreateEmptySignature()booleanequals(java.lang.Object obj)RelationalFormulaget(int index)java.util.Set<FolAtom>getAtoms()Processes the set of all atoms which appear in this formulajava.util.List<RelationalFormula>getFormulas()<C extends SimpleLogicalFormula>
java.util.Set<C>getFormulas(java.lang.Class<C> cls)Process the formulas of type C that are children of this associative formulajava.util.Set<Functor>getFunctors()java.util.Set<? extends Predicate>getPredicates()Processes the set of all predicates which appear in this formulajava.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()inthashCode()intindexOf(java.lang.Object o)booleanisClosed()Checks whether this formula is closed, i.e.booleanisClosed(java.util.Set<Variable> boundVariables)Checks whether this formula is closed, i.e.booleanisEmpty()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.java.util.Iterator<RelationalFormula>iterator()intlastIndexOf(java.lang.Object o)java.util.ListIterator<RelationalFormula>listIterator()java.util.ListIterator<RelationalFormula>listIterator(int index)RelationalFormularemove(int index)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)RelationalFormulaset(int index, RelationalFormula element)intsize()java.util.List<RelationalFormula>subList(int fromIndex, int toIndex)AssociativeFolFormulasubstitute(java.util.Map<? extends Term<?>,? extends Term<?>> termMap)Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.
NOTE: variables bound to quantifiers are not substituted in their inner formulas even if they appear in the map.AssociativeFolFormulasubstitute(Term<?> v, Term<?> t)Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.java.lang.Object[]toArray()<T> T[]toArray(T[] a)java.lang.StringtoString()-
Methods inherited from class org.tweetyproject.logics.fol.syntax.FolFormula
clone, collapseAssociativeFormulas, combineWithAnd, combineWithOr, complement, getSignature, getUniformProbability, isDnf, toDnf, toNnf
-
Methods inherited from class org.tweetyproject.logics.commons.syntax.RelationalFormula
allGroundInstances, allSubstitutions, containsTermsOfType, exchange, getFormula, getPredicateCls, getSatisfactionRatio, isGround, isWellFormed
-
Methods inherited from interface org.tweetyproject.logics.commons.syntax.AssociativeFormulaSupport.AssociativeSupportBridge
createEmptyFormula, getEmptySymbol, getOperatorSymbol
-
Methods inherited from interface org.tweetyproject.commons.Formula
getSignature
-
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.SimpleLogicalFormula
getPredicateCls
-
-
-
-
Constructor Detail
-
AssociativeFolFormula
public AssociativeFolFormula()
Creates a new (empty) associative formula.
-
AssociativeFolFormula
public AssociativeFolFormula(RelationalFormula first, RelationalFormula second)
Creates a new associative formula with the two given formulae- Parameters:
first- a relational formula.second- a relational formula.
-
AssociativeFolFormula
public AssociativeFolFormula(java.util.Collection<? extends RelationalFormula> formulas)
Creates a new associative formula with the given inner formulas.- Parameters:
formulas- a collection of formulas.
-
-
Method Detail
-
createEmptySignature
public Signature createEmptySignature()
- Specified by:
createEmptySignaturein interfaceAssociativeFormulaSupport.AssociativeSupportBridge- Returns:
- An empty signature of the language of the AssociativeFormula implementation
-
getFunctors
public java.util.Set<Functor> getFunctors()
- Specified by:
getFunctorsin classRelationalFormula- Returns:
- all functors that appear in this formula.
-
containsQuantifier
public boolean containsQuantifier()
Description copied from interface:QuantifiedFormulaChecks whether this formula contains any quantification.- Specified by:
containsQuantifierin interfaceQuantifiedFormula- Returns:
- "true" if this formula contains a quantification.
-
getUnboundVariables
public java.util.Set<Variable> getUnboundVariables()
- Specified by:
getUnboundVariablesin interfaceQuantifiedFormula- Returns:
- a set of of unbound variables
-
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.- Specified by:
isClosedin interfaceQuantifiedFormula- 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.- Specified by:
isClosedin interfaceQuantifiedFormula- Parameters:
boundVariables- the variables assumed to be bound.- Returns:
- "true" if this formula is closed wrt. "boundVariables", "false" otherwise.
-
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.- Specified by:
isWellBoundin interfaceQuantifiedFormula- 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.- Specified by:
isWellBoundin interfaceQuantifiedFormula- Parameters:
boundVariables- the variables assumed to be bound.- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
isLiteral
public boolean isLiteral()
- Specified by:
isLiteralin interfaceSimpleLogicalFormula- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getQuantifierVariables
public java.util.Set<Variable> getQuantifierVariables()
- Specified by:
getQuantifierVariablesin interfaceQuantifiedFormula- Overrides:
getQuantifierVariablesin classFolFormula- Returns:
- a set containing all quantified variables
-
getFormulas
public java.util.List<RelationalFormula> getFormulas()
- Specified by:
getFormulasin interfaceAssociativeFormula<RelationalFormula>- Returns:
- all the formulas saved as childs in the associative formula
-
getFormulas
public <C extends SimpleLogicalFormula> java.util.Set<C> getFormulas(java.lang.Class<C> cls)
Description copied from interface:AssociativeFormulaProcess the formulas of type C that are children of this associative formula- Specified by:
getFormulasin interfaceAssociativeFormula<RelationalFormula>- Type Parameters:
C- the type of formulas- Parameters:
cls- the class structure defining the type of formulas which are searched.- Returns:
- A set of formulas of type C which are members of the associative formula
-
getAtoms
public java.util.Set<FolAtom> 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.
-
getTerms
public java.util.Set<Term<?>> getTerms()
- Specified by:
getTermsin interfaceLogicStructure- 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.- Specified by:
getTermsin interfaceLogicStructure- 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
-
getPredicates
public java.util.Set<? extends Predicate> getPredicates()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Specified by:
getPredicatesin interfaceSimpleLogicalFormula- Returns:
- all predicates that appear in this formula
-
substitute
public AssociativeFolFormula substitute(Term<?> v, Term<?> t)
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".
-
substitute
public AssociativeFolFormula substitute(java.util.Map<? extends Term<?>,? extends Term<?>> termMap)
Description copied from class:RelationalFormulaSubstitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.
NOTE: variables bound to quantifiers are not substituted in their inner formulas even if they appear in the map.- Specified by:
substitutein interfaceComplexLogicalFormula- Overrides:
substitutein classRelationalFormula- Parameters:
termMap- a mapping defining which terms to be substituted.- Returns:
- a formula where every term in map.keyset() has been replaced by map.get(v).
-
toString
public java.lang.String toString()
- Specified by:
toStringin classRelationalFormula
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Collection<RelationalFormula>- Specified by:
hashCodein interfacejava.util.List<RelationalFormula>- Specified by:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfacejava.util.Collection<RelationalFormula>- Specified by:
equalsin interfacejava.util.List<RelationalFormula>- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classjava.lang.Object
-
add
public boolean add(RelationalFormula e)
- Specified by:
addin interfacejava.util.Collection<RelationalFormula>- Specified by:
addin interfacejava.util.List<RelationalFormula>
-
add
public boolean add(FolFormula... formulas)
Adds the specified elements to the end of this collection (optional operation).- Parameters:
formulas- to be appended to collection- Returns:
- true if all elements were added, false otherwise
-
addAll
public boolean addAll(java.util.Collection<? extends RelationalFormula> c)
- Specified by:
addAllin interfacejava.util.Collection<RelationalFormula>- Specified by:
addAllin interfacejava.util.List<RelationalFormula>
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<RelationalFormula>- Specified by:
clearin interfacejava.util.List<RelationalFormula>
-
contains
public boolean contains(java.lang.Object o)
- Specified by:
containsin interfacejava.util.Collection<RelationalFormula>- Specified by:
containsin interfacejava.util.List<RelationalFormula>
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
- Specified by:
containsAllin interfacejava.util.Collection<RelationalFormula>- Specified by:
containsAllin interfacejava.util.List<RelationalFormula>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection<RelationalFormula>- Specified by:
isEmptyin interfacejava.util.List<RelationalFormula>
-
iterator
public java.util.Iterator<RelationalFormula> iterator()
- Specified by:
iteratorin interfacejava.util.Collection<RelationalFormula>- Specified by:
iteratorin interfacejava.lang.Iterable<RelationalFormula>- Specified by:
iteratorin interfacejava.util.List<RelationalFormula>
-
remove
public boolean remove(java.lang.Object o)
- Specified by:
removein interfacejava.util.Collection<RelationalFormula>- Specified by:
removein interfacejava.util.List<RelationalFormula>
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
- Specified by:
removeAllin interfacejava.util.Collection<RelationalFormula>- Specified by:
removeAllin interfacejava.util.List<RelationalFormula>
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
- Specified by:
retainAllin interfacejava.util.Collection<RelationalFormula>- Specified by:
retainAllin interfacejava.util.List<RelationalFormula>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Collection<RelationalFormula>- Specified by:
sizein interfacejava.util.List<RelationalFormula>
-
toArray
public java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection<RelationalFormula>- Specified by:
toArrayin interfacejava.util.List<RelationalFormula>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArrayin interfacejava.util.Collection<RelationalFormula>- Specified by:
toArrayin interfacejava.util.List<RelationalFormula>
-
add
public void add(int index, RelationalFormula element)- Specified by:
addin interfacejava.util.List<RelationalFormula>
-
addAll
public boolean addAll(int index, java.util.Collection<? extends RelationalFormula> c)- Specified by:
addAllin interfacejava.util.List<RelationalFormula>
-
get
public RelationalFormula get(int index)
- Specified by:
getin interfacejava.util.List<RelationalFormula>
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOfin interfacejava.util.List<RelationalFormula>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOfin interfacejava.util.List<RelationalFormula>
-
listIterator
public java.util.ListIterator<RelationalFormula> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<RelationalFormula>
-
listIterator
public java.util.ListIterator<RelationalFormula> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<RelationalFormula>
-
remove
public RelationalFormula remove(int index)
- Specified by:
removein interfacejava.util.List<RelationalFormula>
-
set
public RelationalFormula set(int index, RelationalFormula element)
- Specified by:
setin interfacejava.util.List<RelationalFormula>
-
subList
public java.util.List<RelationalFormula> subList(int fromIndex, int toIndex)
- Specified by:
subListin interfacejava.util.List<RelationalFormula>
-
-