Package net.sf.tweety.lp.asp.syntax
Class AggregateElement
- java.lang.Object
-
- net.sf.tweety.lp.asp.syntax.ASPElement
-
- net.sf.tweety.lp.asp.syntax.AggregateElement
-
- All Implemented Interfaces:
Formula,ComplexLogicalFormula,LogicStructure,SimpleLogicalFormula
public class AggregateElement extends ASPElement
This class models an aggregate element, meaning a set of terms and a set of naf literals (= literals or default negated literals). One or more aggregate elements form an aggregate or aggregate atom.- Author:
- Anna Gessler
- See Also:
AggregateAtom
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Term<?>>leftThe term tuple of the aggregate element.private java.util.List<ASPBodyElement>rightThe literal tuple of this aggregate element.
-
Constructor Summary
Constructors Constructor Description AggregateElement(java.util.List<Term<?>> l, java.util.List<ASPBodyElement> r)Creates a new Aggregate Element with the given list of terms and the given list of naf literals.AggregateElement(AggregateElement other)Copy-Constructor
-
Method Summary
Modifier and Type Method Description AggregateElementclone()Creates a deep copy of this formulaAggregateElementexchange(Term<?> v, Term<?> t)Substitutes all occurrences of term "v" in this formula by term "t" and at the same time replaces all occurrences of term "t" by term "v" and eventually returns the new formula.java.util.Set<ASPAtom>getAtoms()Processes the set of all atoms which appear in this formulajava.util.List<Term<?>>getLeft()Returns the left part of the Aggregate element.java.util.SortedSet<ASPLiteral>getLiterals()java.util.Set<Predicate>getPredicates()Processes the set of all predicates which appear in this formulajava.util.List<ASPBodyElement>getRight()Returns the right part of the Aggregate element.FolSignaturegetSignature()Returns the signature of the language of this formula.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.booleanisLiteral()AggregateElementsubstitute(java.util.Map<? extends Term<?>,? extends Term<?>> map)Substitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.AggregateElementsubstitute(Term<?> t, Term<?> v)Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.java.lang.StringtoString()-
Methods inherited from class net.sf.tweety.lp.asp.syntax.ASPElement
containsTermsOfType, getPredicateCls, isGround, isWellFormed
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
equals, hashCode
-
-
-
-
Field Detail
-
left
private java.util.List<Term<?>> left
The term tuple of the aggregate element.
-
right
private java.util.List<ASPBodyElement> right
The literal tuple of this aggregate element. TODO: Remove possibility of having AggregateAtoms in this list.
-
-
Constructor Detail
-
AggregateElement
public AggregateElement(java.util.List<Term<?>> l, java.util.List<ASPBodyElement> r)
Creates a new Aggregate Element with the given list of terms and the given list of naf literals.- Parameters:
l- a list of termsr- a list of body elements
-
AggregateElement
public AggregateElement(AggregateElement other)
Copy-Constructor- Parameters:
other- another AggregateElement
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isLiteral
public boolean isLiteral()
- Returns:
- true if the formula represents a literal in the language or 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
-
getPredicates
public java.util.Set<Predicate> getPredicates()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Specified by:
getPredicatesin interfaceSimpleLogicalFormula- Specified by:
getPredicatesin classASPElement- Returns:
- all predicates that appear in this formula
-
getAtoms
public java.util.Set<ASPAtom> getAtoms()
Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
getAtomsin interfaceSimpleLogicalFormula- Specified by:
getAtomsin classASPElement- Returns:
- The set of all atoms
-
substitute
public AggregateElement substitute(Term<?> t, Term<?> v)
Description copied from interface:ComplexLogicalFormulaSubstitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.- Specified by:
substitutein interfaceComplexLogicalFormula- Specified by:
substitutein classASPElement- Parameters:
t- the term to be substituted.v- the term to substitute.- Returns:
- a formula where every occurrence of "v" is replaced by "t".
-
getSignature
public FolSignature getSignature()
Description copied from interface:FormulaReturns the signature of the language of this formula.- Specified by:
getSignaturein interfaceFormula- Specified by:
getSignaturein classASPElement- Returns:
- the signature of the language of this formula.
-
clone
public AggregateElement clone()
Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
clonein interfaceComplexLogicalFormula- Specified by:
clonein interfaceSimpleLogicalFormula- Specified by:
clonein classASPElement- Returns:
- the cloned formula
-
getLeft
public java.util.List<Term<?>> getLeft()
Returns the left part of the Aggregate element.- Returns:
- list of terms
-
getRight
public java.util.List<ASPBodyElement> getRight()
Returns the right part of the Aggregate element.- Returns:
- list of naf literals (= literals or default negated literals)
-
substitute
public AggregateElement substitute(java.util.Map<? extends Term<?>,? extends Term<?>> map) throws java.lang.IllegalArgumentException
Description copied from interface:ComplexLogicalFormulaSubstitutes all occurrences of all terms "v" in map.keyset() in this formula by map.get(v) and returns the new formula.- Specified by:
substitutein interfaceComplexLogicalFormula- Overrides:
substitutein classASPElement- Parameters:
map- a mapping defining which terms to be substituted.- Returns:
- a formula where every term in map.keyset() has been replaced by map.get(v).
- Throws:
java.lang.IllegalArgumentException- if any term and its mapping are of different sorts
-
exchange
public AggregateElement exchange(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
Description copied from interface:ComplexLogicalFormulaSubstitutes all occurrences of term "v" in this formula by term "t" and at the same time replaces all occurrences of term "t" by term "v" and eventually returns the new formula.- Specified by:
exchangein interfaceComplexLogicalFormula- Overrides:
exchangein classASPElement- Parameters:
v- a term.t- a term.- Returns:
- a new logical formula with both "v" and "t" exchanged.
- Throws:
java.lang.IllegalArgumentException- if "v" and "t" are of different sorts
-
getLiterals
public java.util.SortedSet<ASPLiteral> getLiterals()
-
-