Package net.sf.tweety.lp.asp.syntax
Class ComparativeAtom
- java.lang.Object
-
- net.sf.tweety.lp.asp.syntax.ASPElement
-
- net.sf.tweety.lp.asp.syntax.ASPBodyElement
-
- net.sf.tweety.lp.asp.syntax.ComparativeAtom
-
- All Implemented Interfaces:
Formula,ComplexLogicalFormula,LogicStructure,SimpleLogicalFormula
public class ComparativeAtom extends ASPBodyElement
This class represents a comparative atom, meaning an expression of the form t x u where t,u are terms and x is in {<, <=, ==, !=, >, >=}. Comparatives are called "Built-in atoms" in the ASP-Core-2 standard.- Author:
- Tim Janus, Thomas Vengels, Anna Gessler
-
-
Constructor Summary
Constructors Constructor Description ComparativeAtom(ASPOperator.BinaryOperator op, Term<?> left, Term<?> right)ComparativeAtom(ComparativeAtom other)Copy-Constructor
-
Method Summary
Modifier and Type Method Description ASPBodyElementclone()Creates a deep copy of this formulabooleanequals(java.lang.Object obj)java.util.Set<ASPAtom>getAtoms()Processes the set of all atoms which appear in this formulaTerm<?>getLeft()Returns the left (first) term of the comparative atom.java.util.SortedSet<ASPLiteral>getLiterals()Returns all literals in this element in form of a SortedSet.ASPOperator.BinaryOperatorgetOperator()Returns the comparative operator of the atom.java.lang.Class<? extends Predicate>getPredicateCls()java.util.Set<Predicate>getPredicates()Processes the set of all predicates which appear in this formulaTerm<?>getRight()Returns the right (second) term of the comparative atom.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.inthashCode()booleanisLiteral()ComparativeAtomsubstitute(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, exchange, isGround, isWellFormed, substitute
-
-
-
-
Constructor Detail
-
ComparativeAtom
public ComparativeAtom(ASPOperator.BinaryOperator op, Term<?> left, Term<?> right)
-
ComparativeAtom
public ComparativeAtom(ComparativeAtom other)
Copy-Constructor- Parameters:
other- another ComparativeAtom
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getLiterals
public java.util.SortedSet<ASPLiteral> getLiterals()
Description copied from class:ASPBodyElementReturns all literals in this element in form of a SortedSet. Literals are atoms or strict negations of atoms.- Specified by:
getLiteralsin classASPBodyElement- Returns:
- all the literals used in the rule element
-
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 ComparativeAtom 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 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
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 ASPBodyElement 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
-
getPredicateCls
public java.lang.Class<? extends Predicate> getPredicateCls()
- Specified by:
getPredicateClsin interfaceSimpleLogicalFormula- Overrides:
getPredicateClsin 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
public java.util.Set<Term<?>> getTerms()
- Returns:
- a set containing all terms of this logical structure
-
getOperator
public ASPOperator.BinaryOperator getOperator()
Returns the comparative operator of the atom.- Returns:
- the comparative operator of the atom.
-
getLeft
public Term<?> getLeft()
Returns the left (first) term of the comparative atom.- Returns:
- the left (first) term of the comparative atom.
-
getRight
public Term<?> getRight()
Returns the right (second) term of the comparative atom.- Returns:
- the right (second) term of the comparative atom.
-
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
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceSimpleLogicalFormula- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin interfaceSimpleLogicalFormula- Overrides:
equalsin classjava.lang.Object
-
-