Package net.sf.tweety.lp.asp.syntax
Class ASPAtom
- java.lang.Object
- 
- net.sf.tweety.lp.asp.syntax.ASPElement
- 
- net.sf.tweety.lp.asp.syntax.ASPBodyElement
- 
- net.sf.tweety.lp.asp.syntax.ASPLiteral
- 
- net.sf.tweety.lp.asp.syntax.ASPAtom
 
 
 
 
- 
- All Implemented Interfaces:
- java.lang.Comparable<ASPLiteral>,- Formula,- Atom,- ComplexLogicalFormula,- Invertable,- LogicStructure,- SimpleLogicalFormula
 
 public class ASPAtom extends ASPLiteral 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 net.sf.tweety.logics.commons.syntax.interfaces.AtomAtom.AtomImpl, Atom.RETURN_SET_PREDICATE
 
- 
 - 
Constructor SummaryConstructors Constructor Description ASPAtom()Empty constructor.ASPAtom(java.lang.String name)Creates a new atom with the given predicate name and no terms.ASPAtom(java.lang.String symbol, Term<?>... terms)Creates an atom with the given predicate as name and the given terms as argumentASPAtom(Predicate p)Creates a new ASPAtom with the given predicate.ASPAtom(Predicate p, java.util.List<Term<?>> terms)Creates a new atom with the given predicate and terms.ASPAtom(FolAtom other)Copy-Constructor: Generates a deep copy of the given FOL atom.ASPAtom(ASPAtom other)Copy-Constructor: Generates a deep copy of the given ASP atom.
 - 
Method SummaryModifier and Type Method Description voidaddArgument(Term<?> arg)Adds an argument to the atom's argument listASPAtomclone()Creates a deep copy of this formulaASPAtomcloneWithAddedTerm(Term<?> term)Creates a copy of the literal and adds the given term as argument to the end of the argument list.intcompareTo(ASPLiteral o)ASPLiteralcomplement()booleanequals(java.lang.Object o)java.util.List<? extends Term<?>>getArguments()ASPAtomgetAtom()java.util.Set<ASPAtom>getAtoms()Processes the set of all atoms which appear in this formulajava.util.SortedSet<ASPLiteral>getLiterals()Returns all literals in this element in form of a SortedSet.java.lang.StringgetName()PredicategetPredicate()java.util.Set<Predicate>getPredicates()Processes the set of all predicates which appear in this formulaFolSignaturegetSignature()Returns the signature of the language of this formula.Term<?>getTerm(int i)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()booleanisComplete()Atom.RETURN_SET_PREDICATEsetPredicate(Predicate newer)Changes the predicate of the atom.ASPAtomsubstitute(Term<?> v, Term<?> t)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.ASPLiteralisLiteral
 - 
Methods inherited from class net.sf.tweety.lp.asp.syntax.ASPElementcontainsTermsOfType, exchange, getPredicateCls, isGround, isWellFormed, substitute
 - 
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormulagetPredicateCls
 
- 
 
- 
- 
- 
Constructor Detail- 
ASPAtompublic ASPAtom() Empty constructor.
 - 
ASPAtompublic ASPAtom(Predicate p, java.util.List<Term<?>> terms) Creates a new atom with the given predicate and terms.- Parameters:
- p- a predicate
- terms- arguments of the atom
 
 - 
ASPAtompublic ASPAtom(java.lang.String name) Creates a new atom with the given predicate name and no terms.- Parameters:
- name- a name
 
 - 
ASPAtompublic ASPAtom(FolAtom other) Copy-Constructor: Generates a deep copy of the given FOL atom.- Parameters:
- other- The FOL atom acting as source for the deep copy
 
 - 
ASPAtompublic ASPAtom(ASPAtom other) Copy-Constructor: Generates a deep copy of the given ASP atom.- Parameters:
- other- The atom acting as source for the deep copy
 
 - 
ASPAtompublic ASPAtom(java.lang.String symbol, Term<?>... terms)Creates an atom with the given predicate as name and the given terms as argument- Parameters:
- symbol- The name of the atom
- terms- A list of Term<?> defining the arguments of the term
 
 - 
ASPAtompublic ASPAtom(Predicate p) Creates a new ASPAtom with the given predicate.- Parameters:
- p- a predicate
 
 
- 
 - 
Method Detail- 
getNamepublic java.lang.String getName() - Returns:
- the name of the predicate
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getLiteralspublic 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 class- ASPBodyElement
- Returns:
- all the literals used in the rule element
 
 - 
getPredicatespublic java.util.Set<Predicate> getPredicates() Description copied from interface:SimpleLogicalFormulaProcesses the set of all predicates which appear in this formula- Specified by:
- getPredicatesin interface- SimpleLogicalFormula
- Specified by:
- getPredicatesin class- ASPElement
- Returns:
- all predicates that appear in this formula
 
 - 
getAtomspublic java.util.Set<ASPAtom> getAtoms() Description copied from interface:SimpleLogicalFormulaProcesses the set of all atoms which appear in this formula- Specified by:
- getAtomsin interface- SimpleLogicalFormula
- Specified by:
- getAtomsin class- ASPElement
- Returns:
- The set of all atoms
 
 - 
getSignaturepublic FolSignature getSignature() Description copied from interface:FormulaReturns the signature of the language of this formula.- Specified by:
- getSignaturein interface- Formula
- Specified by:
- getSignaturein class- ASPElement
- Returns:
- the signature of the language of this formula.
 
 - 
clonepublic ASPAtom clone() Description copied from interface:SimpleLogicalFormulaCreates a deep copy of this formula- Specified by:
- clonein interface- ComplexLogicalFormula
- Specified by:
- clonein interface- SimpleLogicalFormula
- Specified by:
- clonein class- ASPElement
- Returns:
- the cloned formula
 
 - 
getTermspublic java.util.Set<Term<?>> getTerms() - Returns:
- a set containing all terms of this logical structure
 
 - 
getTermspublic <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
 
 - 
getPredicatepublic Predicate getPredicate() - Returns:
- the predicate of the atom
 
 - 
setPredicatepublic Atom.RETURN_SET_PREDICATE setPredicate(Predicate newer) Description copied from interface:AtomChanges 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
 
 - 
addArgumentpublic void addArgument(Term<?> arg) throws LanguageException Description copied from interface:AtomAdds 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.
 
 - 
getArgumentspublic java.util.List<? extends Term<?>> getArguments() - Returns:
- A list containing all the arguments of this specific atom
 
 - 
isCompletepublic boolean isComplete() - Returns:
- true if the size of the argument list is equal to the arity of the predicate
 
 - 
compareTopublic int compareTo(ASPLiteral o) 
 - 
cloneWithAddedTermpublic ASPAtom cloneWithAddedTerm(Term<?> term) Description copied from class:ASPLiteralCreates a copy of the literal and adds the given term as argument to the end of the argument list.- Specified by:
- cloneWithAddedTermin class- ASPLiteral
- Parameters:
- term- the new argument.
- Returns:
- A copy of the literal containing the given term as new argument.
 
 - 
getAtompublic ASPAtom getAtom() - Specified by:
- getAtomin class- ASPLiteral
- Returns:
- The atom representing the literal.
 
 - 
complementpublic ASPLiteral complement() - Specified by:
- complementin interface- Invertable
- Specified by:
- complementin class- ASPLiteral
- Returns:
- the complement of this formula.
 
 - 
substitutepublic ASPAtom substitute(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 returns the new formula.- Specified by:
- substitutein interface- ComplexLogicalFormula
- Specified by:
- substitutein class- ASPBodyElement
- 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:
- java.lang.IllegalArgumentException- if "v" and "t" are of different sorts
 
 - 
getTermpublic Term<?> getTerm(int i) 
 - 
equalspublic boolean equals(java.lang.Object o) - Specified by:
- equalsin interface- SimpleLogicalFormula
- Overrides:
- equalsin class- java.lang.Object
 
 - 
hashCodepublic int hashCode() - Specified by:
- hashCodein interface- SimpleLogicalFormula
- Overrides:
- hashCodein class- java.lang.Object
 
 
- 
 
-