Package net.sf.tweety.logics.pl.syntax
Class AssociativePlFormula
- java.lang.Object
-
- net.sf.tweety.logics.pl.syntax.PlFormula
-
- net.sf.tweety.logics.pl.syntax.AssociativePlFormula
-
- All Implemented Interfaces:
java.lang.Iterable<PlFormula>,java.util.Collection<PlFormula>,java.util.List<PlFormula>,Formula,AssociativeFormulaSupport.AssociativeSupportBridge,AssociativeFormula<PlFormula>,ClassicalFormula,Conjunctable,Disjunctable,Invertable,ProbabilityAware,SimpleLogicalFormula
- Direct Known Subclasses:
Conjunction,Disjunction,ExclusiveDisjunction
public abstract class AssociativePlFormula extends PlFormula implements AssociativeFormula<PlFormula>, AssociativeFormulaSupport.AssociativeSupportBridge, java.util.Collection<PlFormula>
This class captures the common functionalities of formulas with an associative operation like conjunction, disjunction, etc.- Author:
- Matthias Thimm, Tim Janus
-
-
Constructor Summary
Constructors Constructor Description AssociativePlFormula()Creates a new (empty) associative formula.AssociativePlFormula(java.util.Collection<? extends PlFormula> formulas)Creates a new associative formula with the given inner formulas.AssociativePlFormula(PlFormula first, PlFormula second)Creates a new associative formula with the two given formulae
-
Method Summary
Modifier and Type Method Description voidadd(int index, PlFormula element)booleanadd(PlFormula f)booleanadd(PlFormula... formulas)Adds the specified elements to the end of this collection (optional operation).booleanaddAll(int index, java.util.Collection<? extends PlFormula> c)booleanaddAll(java.util.Collection<? extends PlFormula> c)voidclear()booleancontains(java.lang.Object o)booleancontainsAll(java.util.Collection<?> c)SignaturecreateEmptySignature()booleanequals(java.lang.Object obj)PlFormulaget(int index)java.util.Set<Proposition>getAtoms()Processes the set of all atoms which appear in this formulajava.util.List<PlFormula>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<PlFormula>getLiterals()Returns all literals, i.e.java.util.Set<PlPredicate>getPredicates()Processes the set of all predicates which appear in this formulaPlSignaturegetSignature()Returns the signature of the language of this formula.inthashCode()intindexOf(java.lang.Object o)booleanisEmpty()java.util.Iterator<PlFormula>iterator()intlastIndexOf(java.lang.Object o)java.util.ListIterator<PlFormula>listIterator()java.util.ListIterator<PlFormula>listIterator(int index)intnumberOfOccurrences(Proposition p)Returns the number of occurrences of the given proposition within this formulaPlFormularemove(int index)booleanremove(java.lang.Object o)booleanremoveAll(java.util.Collection<?> c)booleanretainAll(java.util.Collection<?> c)PlFormulaset(int index, PlFormula element)intsize()java.util.List<PlFormula>subList(int fromIndex, int toIndex)java.lang.Object[]toArray()java.lang.Object[]toArray(java.lang.Object[] a)java.lang.StringtoString()-
Methods inherited from class net.sf.tweety.logics.pl.syntax.PlFormula
clone, collapseAssociativeFormulas, combineWithAnd, combineWithOr, complement, getModels, getModels, getPredicateCls, getPrimeImplicants, getUniformProbability, isClause, isConjunctiveClause, isLiteral, replace, resolvableWith, resolveWith, toBlakeCanonicalForm, toCnf, toDnf, toNnf, trim
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.AssociativeFormulaSupport.AssociativeSupportBridge
createEmptyFormula, getEmptySymbol, getOperatorSymbol
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
clone, getPredicateCls, isLiteral
-
-
-
-
Constructor Detail
-
AssociativePlFormula
public AssociativePlFormula()
Creates a new (empty) associative formula.
-
AssociativePlFormula
public AssociativePlFormula(java.util.Collection<? extends PlFormula> formulas)
Creates a new associative formula with the given inner formulas.- Parameters:
formulas- a collection of formulas.
-
-
Method Detail
-
getPredicates
public java.util.Set<PlPredicate> getPredicates()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Specified by:
getPredicatesin interfaceSimpleLogicalFormula- Specified by:
getPredicatesin classPlFormula- Returns:
- all predicates that appear in this formula
-
getFormulas
public java.util.List<PlFormula> getFormulas()
- Specified by:
getFormulasin interfaceAssociativeFormula<PlFormula>- 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<PlFormula>- 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<Proposition> getAtoms()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Specified by:
getAtomsin classPlFormula- Returns:
- The set of all atoms
-
getLiterals
public java.util.Set<PlFormula> getLiterals()
Description copied from class:PlFormulaReturns all literals, i.e. all formulas of the form "a" or "!a" where "a" is a proposition, that appear in this formula.- Specified by:
getLiteralsin classPlFormula- Returns:
- all literals appearing in this formula.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getSignature
public PlSignature getSignature()
Description copied from interface:FormulaReturns the signature of the language of this formula.- Specified by:
getSignaturein interfaceFormula- Overrides:
getSignaturein classPlFormula- Returns:
- the signature of the language of this formula.
-
createEmptySignature
public Signature createEmptySignature()
- Specified by:
createEmptySignaturein interfaceAssociativeFormulaSupport.AssociativeSupportBridge- Returns:
- An empty signature of the language of the AssociativeFormula implementation
-
numberOfOccurrences
public int numberOfOccurrences(Proposition p)
Description copied from class:PlFormulaReturns the number of occurrences of the given proposition within this formula- Specified by:
numberOfOccurrencesin classPlFormula- Parameters:
p- some proposition- Returns:
- the number of occurrences of the given proposition within this formula
-
hashCode
public int hashCode()
-
equals
public boolean equals(java.lang.Object obj)
-
add
public boolean add(PlFormula f)
-
add
public boolean add(PlFormula... 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 PlFormula> c)
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<PlFormula> iterator()
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
size
public int size()
-
toArray
public java.lang.Object[] toArray()
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] a)
-
add
public void add(int index, PlFormula element)- Specified by:
addin interfacejava.util.List<PlFormula>
-
addAll
public boolean addAll(int index, java.util.Collection<? extends PlFormula> c)- Specified by:
addAllin interfacejava.util.List<PlFormula>
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOfin interfacejava.util.List<PlFormula>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOfin interfacejava.util.List<PlFormula>
-
listIterator
public java.util.ListIterator<PlFormula> listIterator()
- Specified by:
listIteratorin interfacejava.util.List<PlFormula>
-
listIterator
public java.util.ListIterator<PlFormula> listIterator(int index)
- Specified by:
listIteratorin interfacejava.util.List<PlFormula>
-
remove
public PlFormula remove(int index)
- Specified by:
removein interfacejava.util.List<PlFormula>
-
set
public PlFormula set(int index, PlFormula element)
- Specified by:
setin interfacejava.util.List<PlFormula>
-
-