Package org.tweetyproject.lp.asp.syntax
Class ASPAtom
java.lang.Object
org.tweetyproject.lp.asp.syntax.ASPElement
org.tweetyproject.lp.asp.syntax.ASPBodyElement
org.tweetyproject.lp.asp.syntax.ASPLiteral
org.tweetyproject.lp.asp.syntax.ASPAtom
- All Implemented Interfaces:
Comparable<ASPLiteral>
,Formula
,Atom
,ComplexLogicalFormula
,Invertable
,LogicStructure
,SimpleLogicalFormula
This class models an atom, which is a basic structure for building literals
and rules for logic programs.
- Author:
- Tim Janus, Thomas Vengels, Matthias Thimm, Anna Gessler
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.Atom
Atom.AtomImpl, Atom.RETURN_SET_PREDICATE
-
Constructor Summary
ConstructorDescriptionASPAtom()
Empty constructor.Creates a new atom with the given predicate name and no terms.Creates an atom with the given predicate as name and the given terms as argumentCreates a new ASPAtom with the given predicate.Creates a new atom with the given predicate and terms.Creates a new atom with the given predicate and terms.Copy-Constructor: Generates a deep copy of the given FOL atom.Copy-Constructor: Generates a deep copy of the given ASP atom. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addArgument
(Term<?> arg) Adds an argument to the atom's argument listclone()
Creates a deep copy of this formulacloneWithAddedTerm
(Term<?> term) Creates a copy of the literal and adds the given term as argument to the end of the argument list.int
boolean
getAtom()
Return The atom representing the literal.getAtoms()
Processes the set of all atoms which appear in this formulaReturns all literals in this element in form of a SortedSet.getName()
Processes the set of all predicates which appear in this formulaReturns the signature of the language of this formula.Term
<?> getTerm
(int i) Retrieves the term at the specified index from the list of arguments.getTerms()
Processes the set containing all terms of type C.int
hashCode()
boolean
Returns a representation of this ASP element in clingo (potassco) syntax.Returns a representation of this ASP element in DLV syntax.setPredicate
(Predicate newer) Changes the predicate of the atom.substitute
(Term<?> v, Term<?> t) 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.ASPLiteral
isLiteral
Methods inherited from class org.tweetyproject.lp.asp.syntax.ASPElement
containsTermsOfType, exchange, getPredicateCls, isGround, isWellFormed, substitute
Methods inherited from interface org.tweetyproject.logics.commons.syntax.interfaces.SimpleLogicalFormula
getPredicateCls
-
Constructor Details
-
ASPAtom
public ASPAtom()Empty constructor. -
ASPAtom
-
ASPAtom
-
ASPAtom
Creates a new atom with the given predicate name and no terms.- Parameters:
name
- a name
-
ASPAtom
Copy-Constructor: Generates a deep copy of the given FOL atom.- Parameters:
other
- The FOL atom acting as source for the deep copy
-
ASPAtom
Copy-Constructor: Generates a deep copy of the given ASP atom.- Parameters:
other
- The atom acting as source for the deep copy
-
ASPAtom
-
ASPAtom
Creates a new ASPAtom with the given predicate.- Parameters:
p
- a predicate
-
-
Method Details
-
getName
- Returns:
- the name of the predicate
-
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
-
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
-
getTerms
-
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
-
getPredicate
- Returns:
- the predicate of the atom
-
setPredicate
Description copied from interface:Atom
Changes the predicate of the atom. Given an old Predicate po and a new predicate pn with their list of arguments types at(po) and at(pn) and the arguments of this Atom: arg(this) this method distinguishes between three cases: 1. The predicate only differ in the names, returning RSP_SUCCESS 2. The old predicates argument types is a sub-list of the new argument types then the method returns RSP_INCOMPLETE and the atoms isComplete() method returns false 3. The new predicates argument types is a sub-list of the old argument types then the method returns RSP_TRUNCATED and the arguments of this atom are truncated too and isComplete() returns true. 4. The old and new predicates' argument types differ then the list of arguments of the atom get cleared and isComplete() returns false.- Parameters:
newer
- some predicate- Returns:
- Depends on the cases described above: 1. RSP_SUCCESS 2. RSP_INCOMPLETE 3. RSP_TRUNCATED 4. RSP_CLEARED
-
addArgument
Description copied from interface:Atom
Adds an argument to the atom's argument list- Parameters:
arg
- The next argument- Throws:
LanguageException
- If the language does not support arguments for their constructs.
-
getArguments
-
isComplete
public boolean isComplete()- Returns:
- true if the size of the argument list is equal to the arity of the predicate
-
compareTo
-
cloneWithAddedTerm
Description copied from class:ASPLiteral
Creates a copy of the literal and adds the given term as argument to the end of the argument list.- Specified by:
cloneWithAddedTerm
in classASPLiteral
- Parameters:
term
- the new argument.- Returns:
- A copy of the literal containing the given term as new argument.
-
getAtom
Description copied from class:ASPLiteral
Return The atom representing the literal.- Specified by:
getAtom
in classASPLiteral
- Returns:
- The atom representing the literal.
-
complement
- Specified by:
complement
in interfaceInvertable
- Specified by:
complement
in classASPLiteral
- Returns:
- the complement of this formula.
-
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:
v
- the term to be substituted.t
- the term to substitute.- Returns:
- a formula where every occurrence of "v" is replaced by "t".
- Throws:
IllegalArgumentException
- if "v" and "t" are of different sorts
-
getTerm
Retrieves the term at the specified index from the list of arguments.This method allows access to the term stored at the given index in the list of arguments. The returned term is of a generic type
Term<?>
, meaning it can represent any type of term.- Parameters:
i
- the index of the term to retrieve, starting from 0.- Returns:
- the
Term<?>
at the specified index. - Throws:
IndexOutOfBoundsException
- if the index is out of range (i.e.,i < 0
ori >= arguments.size()
).
-
toString
-
printToClingo
Description copied from class:ASPElement
Returns a representation of this ASP element in clingo (potassco) syntax. See https://potassco.org/ for more information.- Overrides:
printToClingo
in classASPElement
- Returns:
- String representation in clingo syntax
-
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
-