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 void
add(int index, PlFormula element)
boolean
add(PlFormula f)
boolean
add(PlFormula... formulas)
Adds the specified elements to the end of this collection (optional operation).boolean
addAll(int index, java.util.Collection<? extends PlFormula> c)
boolean
addAll(java.util.Collection<? extends PlFormula> c)
void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
Signature
createEmptySignature()
boolean
equals(java.lang.Object obj)
PlFormula
get(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 formulaPlSignature
getSignature()
Returns the signature of the language of this formula.int
hashCode()
int
indexOf(java.lang.Object o)
boolean
isEmpty()
java.util.Iterator<PlFormula>
iterator()
int
lastIndexOf(java.lang.Object o)
java.util.ListIterator<PlFormula>
listIterator()
java.util.ListIterator<PlFormula>
listIterator(int index)
int
numberOfOccurrences(Proposition p)
Returns the number of occurrences of the given proposition within this formulaPlFormula
remove(int index)
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
PlFormula
set(int index, PlFormula element)
int
size()
java.util.List<PlFormula>
subList(int fromIndex, int toIndex)
java.lang.Object[]
toArray()
java.lang.Object[]
toArray(java.lang.Object[] a)
java.lang.String
toString()
-
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:SimpleLogicalFormula
Processes the set of all predicates which appear in this formula- Specified by:
getPredicates
in interfaceSimpleLogicalFormula
- Specified by:
getPredicates
in classPlFormula
- Returns:
- all predicates that appear in this formula
-
getFormulas
public java.util.List<PlFormula> getFormulas()
- Specified by:
getFormulas
in 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:AssociativeFormula
Process the formulas of type C that are children of this associative formula- Specified by:
getFormulas
in 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:SimpleLogicalFormula
Processes the set of all atoms which appear in this formula- Specified by:
getAtoms
in interfaceSimpleLogicalFormula
- Specified by:
getAtoms
in classPlFormula
- Returns:
- The set of all atoms
-
getLiterals
public java.util.Set<PlFormula> getLiterals()
Description copied from class:PlFormula
Returns all literals, i.e. all formulas of the form "a" or "!a" where "a" is a proposition, that appear in this formula.- Specified by:
getLiterals
in classPlFormula
- Returns:
- all literals appearing in this formula.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getSignature
public PlSignature getSignature()
Description copied from interface:Formula
Returns the signature of the language of this formula.- Specified by:
getSignature
in interfaceFormula
- Overrides:
getSignature
in classPlFormula
- Returns:
- the signature of the language of this formula.
-
createEmptySignature
public Signature createEmptySignature()
- Specified by:
createEmptySignature
in interfaceAssociativeFormulaSupport.AssociativeSupportBridge
- Returns:
- An empty signature of the language of the AssociativeFormula implementation
-
numberOfOccurrences
public int numberOfOccurrences(Proposition p)
Description copied from class:PlFormula
Returns the number of occurrences of the given proposition within this formula- Specified by:
numberOfOccurrences
in 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:
add
in interfacejava.util.List<PlFormula>
-
addAll
public boolean addAll(int index, java.util.Collection<? extends PlFormula> c)
- Specified by:
addAll
in interfacejava.util.List<PlFormula>
-
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOf
in interfacejava.util.List<PlFormula>
-
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf
in interfacejava.util.List<PlFormula>
-
listIterator
public java.util.ListIterator<PlFormula> listIterator()
- Specified by:
listIterator
in interfacejava.util.List<PlFormula>
-
listIterator
public java.util.ListIterator<PlFormula> listIterator(int index)
- Specified by:
listIterator
in interfacejava.util.List<PlFormula>
-
remove
public PlFormula remove(int index)
- Specified by:
remove
in interfacejava.util.List<PlFormula>
-
set
public PlFormula set(int index, PlFormula element)
- Specified by:
set
in interfacejava.util.List<PlFormula>
-
-