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:
Comparable<ASPLiteral>,net.sf.tweety.commons.Formula,net.sf.tweety.logics.commons.syntax.interfaces.Atom,net.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula,net.sf.tweety.logics.commons.syntax.interfaces.Invertable,net.sf.tweety.logics.commons.syntax.interfaces.LogicStructure,net.sf.tweety.logics.commons.syntax.interfaces.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
-
-
Constructor Summary
Constructors Constructor Description ASPAtom()Empty constructor.ASPAtom(String name)Creates a new atom with the given predicate name and no terms.ASPAtom(String symbol, net.sf.tweety.logics.commons.syntax.interfaces.Term<?>... terms)Creates an atom with the given predicate as name and the given terms as argumentASPAtom(net.sf.tweety.logics.commons.syntax.Predicate p)Creates a new ASPAtom with the given predicate.ASPAtom(net.sf.tweety.logics.commons.syntax.Predicate p, List<net.sf.tweety.logics.commons.syntax.interfaces.Term<?>> terms)Creates a new atom with the given predicate and terms.ASPAtom(net.sf.tweety.logics.fol.syntax.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 Summary
Modifier and Type Method Description voidaddArgument(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> arg)ASPAtomclone()ASPAtomcloneWithAddedTerm(net.sf.tweety.logics.commons.syntax.interfaces.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(Object o)List<? extends net.sf.tweety.logics.commons.syntax.interfaces.Term<?>>getArguments()ASPAtomgetAtom()Set<ASPAtom>getAtoms()SortedSet<ASPLiteral>getLiterals()Returns all literals in this element in form of a SortedSet.StringgetName()net.sf.tweety.logics.commons.syntax.PredicategetPredicate()Set<net.sf.tweety.logics.commons.syntax.Predicate>getPredicates()net.sf.tweety.logics.fol.syntax.FolSignaturegetSignature()net.sf.tweety.logics.commons.syntax.interfaces.Term<?>getTerm(int i)Set<net.sf.tweety.logics.commons.syntax.interfaces.Term<?>>getTerms()<C extends net.sf.tweety.logics.commons.syntax.interfaces.Term<?>>
Set<C>getTerms(Class<C> cls)inthashCode()booleanisComplete()net.sf.tweety.logics.commons.syntax.interfaces.Atom.RETURN_SET_PREDICATEsetPredicate(net.sf.tweety.logics.commons.syntax.Predicate newer)ASPAtomsubstitute(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> v, net.sf.tweety.logics.commons.syntax.interfaces.Term<?> t)StringtoString()-
Methods inherited from class net.sf.tweety.lp.asp.syntax.ASPLiteral
isLiteral
-
Methods inherited from class net.sf.tweety.lp.asp.syntax.ASPElement
containsTermsOfType, exchange, getPredicateCls, isGround, isWellFormed, substitute
-
-
-
-
Field Detail
-
predicate
protected net.sf.tweety.logics.commons.syntax.Predicate predicate
The predicate identifying the atom
-
arguments
protected List<net.sf.tweety.logics.commons.syntax.interfaces.Term<?>> arguments
A list of arguments of the atom
-
-
Constructor Detail
-
ASPAtom
public ASPAtom()
Empty constructor.
-
ASPAtom
public ASPAtom(net.sf.tweety.logics.commons.syntax.Predicate p, List<net.sf.tweety.logics.commons.syntax.interfaces.Term<?>> terms)Creates a new atom with the given predicate and terms.- Parameters:
p- a predicateterms- arguments of the atom
-
ASPAtom
public ASPAtom(String name)
Creates a new atom with the given predicate name and no terms.- Parameters:
name- a name
-
ASPAtom
public ASPAtom(net.sf.tweety.logics.fol.syntax.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
-
ASPAtom
public 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
-
ASPAtom
public ASPAtom(String symbol, net.sf.tweety.logics.commons.syntax.interfaces.Term<?>... terms)
Creates an atom with the given predicate as name and the given terms as argument- Parameters:
symbol- The name of the atomterms- A list of Term<?> defining the arguments of the term
-
ASPAtom
public ASPAtom(net.sf.tweety.logics.commons.syntax.Predicate p)
Creates a new ASPAtom with the given predicate.- Parameters:
p- a predicate
-
-
Method Detail
-
getName
public String getName()
-
getLiterals
public 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 Set<net.sf.tweety.logics.commons.syntax.Predicate> getPredicates()
- Specified by:
getPredicatesin interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula- Specified by:
getPredicatesin classASPElement
-
getAtoms
public Set<ASPAtom> getAtoms()
- Specified by:
getAtomsin interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula- Specified by:
getAtomsin classASPElement
-
getSignature
public net.sf.tweety.logics.fol.syntax.FolSignature getSignature()
- Specified by:
getSignaturein interfacenet.sf.tweety.commons.Formula- Specified by:
getSignaturein classASPElement
-
clone
public ASPAtom clone()
- Specified by:
clonein interfacenet.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula- Specified by:
clonein interfacenet.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula- Specified by:
clonein classASPElement
-
getTerms
public Set<net.sf.tweety.logics.commons.syntax.interfaces.Term<?>> getTerms()
-
getTerms
public <C extends net.sf.tweety.logics.commons.syntax.interfaces.Term<?>> Set<C> getTerms(Class<C> cls)
-
getPredicate
public net.sf.tweety.logics.commons.syntax.Predicate getPredicate()
-
setPredicate
public net.sf.tweety.logics.commons.syntax.interfaces.Atom.RETURN_SET_PREDICATE setPredicate(net.sf.tweety.logics.commons.syntax.Predicate newer)
-
addArgument
public void addArgument(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> arg) throws net.sf.tweety.logics.commons.error.LanguageException- Throws:
net.sf.tweety.logics.commons.error.LanguageException
-
getArguments
public List<? extends net.sf.tweety.logics.commons.syntax.interfaces.Term<?>> getArguments()
-
isComplete
public boolean isComplete()
-
compareTo
public int compareTo(ASPLiteral o)
-
cloneWithAddedTerm
public ASPAtom cloneWithAddedTerm(net.sf.tweety.logics.commons.syntax.interfaces.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 classASPLiteral- Parameters:
term- the new argument.- Returns:
- A copy of the literal containing the given term as new argument.
-
getAtom
public ASPAtom getAtom()
- Specified by:
getAtomin classASPLiteral- Returns:
- The atom representing the literal.
-
complement
public ASPLiteral complement()
- Specified by:
complementin interfacenet.sf.tweety.logics.commons.syntax.interfaces.Invertable- Specified by:
complementin classASPLiteral
-
substitute
public ASPAtom substitute(net.sf.tweety.logics.commons.syntax.interfaces.Term<?> v, net.sf.tweety.logics.commons.syntax.interfaces.Term<?> t) throws IllegalArgumentException
- Specified by:
substitutein interfacenet.sf.tweety.logics.commons.syntax.interfaces.ComplexLogicalFormula- Specified by:
substitutein classASPBodyElement- Throws:
IllegalArgumentException
-
getTerm
public net.sf.tweety.logics.commons.syntax.interfaces.Term<?> getTerm(int i)
-
equals
public boolean equals(Object o)
-
-