Package org.tweetyproject.lp.asp.syntax
Class ComparativeAtom
java.lang.Object
org.tweetyproject.lp.asp.syntax.ASPElement
org.tweetyproject.lp.asp.syntax.ASPBodyElement
org.tweetyproject.lp.asp.syntax.ComparativeAtom
- All Implemented Interfaces:
Formula
,ComplexLogicalFormula
,LogicStructure
,SimpleLogicalFormula
This class represents a comparative atom, meaning an expression of the form 't x u'
where t,u are terms and x is in {<, <=, ==, !=, >, >=}. Comparative atoms are
called "Built-in atoms" in the ASP-Core-2 standard.
- Author:
- Tim Janus, Thomas Vengels, Anna Gessler
-
Constructor Summary
ConstructorDescriptionComparativeAtom
(ASPOperator.BinaryOperator op, Term<?> left, Term<?> right) Create a new comparative atom with the given operator and left and right term.ComparativeAtom
(ComparativeAtom other) Copy-Constructor -
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates a deep copy of this formulaboolean
getAtoms()
Processes the set of all atoms which appear in this formulaTerm
<?> getLeft()
Returns all literals in this element in form of a SortedSet.Processes the set of all predicates which appear in this formulaTerm
<?> getRight()
Returns the signature of the language of this formula.getTerms()
Processes the set containing all terms of type C.int
hashCode()
boolean
Returns a representation of this ASP element in DLV syntax.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, exchange, isGround, isWellFormed, printToClingo, substitute
-
Constructor Details
-
ComparativeAtom
Create a new comparative atom with the given operator and left and right term.- Parameters:
op
- a binary operatorleft
- termright
- term
-
ComparativeAtom
Copy-Constructor- Parameters:
other
- another ComparativeAtom
-
-
Method Details
-
getLiterals
Description copied from class:ASPBodyElement
Returns all literals in this element in form of a SortedSet. Literals are atoms or strict negations of atoms.- Specified by:
getLiterals
in classASPBodyElement
- Returns:
- all the literals used in the rule element
-
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 classASPElement
- Returns:
- all predicates that appear in this formula
-
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 classASPElement
- Returns:
- The set of all atoms
-
substitute
Description copied from interface:ComplexLogicalFormula
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.- Specified by:
substitute
in interfaceComplexLogicalFormula
- Specified by:
substitute
in classASPBodyElement
- 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:Formula
Returns the signature of the language of this formula.- Specified by:
getSignature
in interfaceFormula
- Specified by:
getSignature
in classASPElement
- Returns:
- the signature of the language of this formula.
-
clone
Description copied from interface:SimpleLogicalFormula
Creates a deep copy of this formula- Specified by:
clone
in interfaceComplexLogicalFormula
- Specified by:
clone
in interfaceSimpleLogicalFormula
- Specified by:
clone
in classASPElement
- Returns:
- the cloned formula
-
getPredicateCls
- Specified by:
getPredicateCls
in interfaceSimpleLogicalFormula
- Overrides:
getPredicateCls
in classASPElement
- Returns:
- The class description of the predicate used by this formula.
-
isLiteral
public boolean isLiteral()- Returns:
- true if the formula represents a literal in the language or false otherwise
-
getTerms
-
getOperator
- Returns:
- the comparative operator of the atom.
-
getLeft
- Returns:
- the left (first) term of the comparative atom.
-
getRight
- Returns:
- the right (second) term of the comparative atom.
-
getTerms
Description copied from interface:LogicStructure
Processes 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
-
toString
-
printToDLV
Description copied from class:ASPElement
Returns a representation of this ASP element in DLV syntax. See http://www.dlvsystem.com/html/DLV_User_Manual.html for more information.- Overrides:
printToDLV
in classASPElement
- Returns:
- String representation in DLV syntax
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceSimpleLogicalFormula
- Overrides:
hashCode
in classObject
-
equals
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Overrides:
equals
in classObject
-