Class AggregateElement
java.lang.Object
org.tweetyproject.lp.asp.syntax.ASPElement
org.tweetyproject.lp.asp.syntax.AggregateElement
- All Implemented Interfaces:
Formula,ComplexLogicalFormula,LogicStructure,SimpleLogicalFormula
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 atom.
- Author:
- Anna Gessler
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAggregateElement(List<Term<?>> terms, List<ASPBodyElement> literals) Creates a new Aggregate Element with the given list of terms and the given list of naf literals.AggregateElement(Term<?> term, List<ASPBodyElement> literals) Creates a new Aggregate Element with the given single term and the given list of naf literals.AggregateElement(Term<?> term, ASPBodyElement literal) Creates a new Aggregate Element with the given single term and the given single literal.AggregateElement(Term<?> term, ASPBodyElement... literals) Creates a new Aggregate Element with the given single term and the given naf literals.AggregateElement(AggregateElement other) Copy-Constructor -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a deep copy of this formulabooleanSubstitutes 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.getAtoms()Processes the set of all atoms which appear in this formulagetLeft()Return the left part (the term tuple) of the Aggregate element.Retrieves a sorted set of all the ASP literals present in the body elements of this rule.Processes the set of all predicates which appear in this formulagetRight()Returns the right part (the literals tuple) of the Aggregate element.Returns the signature of the language of this formula.getTerms()Processes the set containing all terms of type C.inthashCode()booleanReturns a representation of this ASP element in clingo (potassco) syntax.Returns a representation of this ASP element in DLV syntax.voidSets the term tuple of the aggregate element.voidsetRight(List<ASPBodyElement> literals) Sets the literal tuple of this aggregate element.substitute(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.substitute(Term<?> t, Term<?> v) Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.toString()Methods inherited from class org.tweetyproject.lp.asp.syntax.ASPElement
containsTermsOfType, getPredicateCls, isGround, isWellFormed
-
Constructor Details
-
AggregateElement
Creates a new Aggregate Element with the given list of terms and the given list of naf literals.- Parameters:
terms- a list of termsliterals- a list of body elements
-
AggregateElement
Creates a new Aggregate Element with the given single term and the given single literal.- Parameters:
term- the termliteral- the literal
-
AggregateElement
Creates a new Aggregate Element with the given single term and the given list of naf literals.- Parameters:
term- the termliterals- a list of body elements
-
AggregateElement
Creates a new Aggregate Element with the given single term and the given naf literals.- Parameters:
term- the termliterals- the literals
-
AggregateElement
Copy-Constructor- Parameters:
other- another AggregateElement
-
-
Method Details
-
isLiteral
public boolean isLiteral()- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getTerms
-
getTerms
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
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
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
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
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
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
-
getRight
Returns the right part (the literals tuple) of the Aggregate element.- Returns:
- list of naf literals (= literals or default negated literals)
-
setLeft
-
setRight
Sets the literal tuple of this aggregate element.- Parameters:
literals- the literal tuple to set
-
substitute
public AggregateElement substitute(Map<? extends Term<?>, ? extends Term<?>> map) throws 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:
IllegalArgumentException- if any term and its mapping are of different sorts
-
exchange
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:
IllegalArgumentException- if "v" and "t" are of different sorts
-
getLiterals
Retrieves a sorted set of all the ASP literals present in the body elements of this rule.This method iterates through each
ASPBodyElementin the right-hand side of the rule, collects the literals from each body element, and returns them in aSortedSet. The literals are sorted according to their natural ordering.- Returns:
- A sorted set of
ASPLiteralobjects found in the body elements of the rule.
-
toString
-
printToClingo
Description copied from class:ASPElementReturns a representation of this ASP element in clingo (potassco) syntax. See https://potassco.org/ for more information.- Overrides:
printToClingoin classASPElement- Returns:
- String representation in clingo syntax
-
printToDLV
Description copied from class:ASPElementReturns a representation of this ASP element in DLV syntax. See http://www.dlvsystem.com/html/DLV_User_Manual.html for more information.- Overrides:
printToDLVin classASPElement- Returns:
- String representation in DLV syntax
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classObject
-