Package jason.asSyntax
Class Literal
java.lang.Object
jason.asSyntax.DefaultTerm
jason.asSyntax.Literal
- All Implemented Interfaces:
LogicalFormula,Term,ToDOM,ToJson,Serializable,Cloneable,Comparable<Term>
- Direct Known Subclasses:
Atom
This class represents an abstract literal (an Atom, Structure, Predicate, etc), it is mainly
the interface of a literal.
To create a new Literal, one of the following concrete classes may be used:
- Atom -- the most simple literal, is composed by only a functor (no term, no annots);
- Structure -- has functor and terms;
- Pred -- has functor, terms, and annotations;
- LiteralImpl -- Pred + negation.
There are useful static methods in class ASSyntax to create Literals.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Atomstatic final Literalstatic final booleanstatic final booleanstatic final Literalprotected PredicateIndicatorFields inherited from class jason.asSyntax.DefaultTerm
hashCodeCache, srcInfo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadds some annots and return thisadds some annots and return thisadds the annotation source(agName)voidadds some terms and return thisadds some terms and return thisbooleanreturns this if this literal can be added in the belief base (Atoms, for instance, can not be)removes all annotations and returns itselfcopy()booleanbooleanbooleanremoves all annots in this pred that are in the list l.booleandeletes one source(agName) annotation, return true if deletedvoiddeletes all source annotationsvoiddelTerm(int index) booleanTransforms this into a full literal (which implements all methods of Literal), if it is an Atom; otherwise returns 'this'returns the first annotation (literal) that has the functorreturns all annotations of the literalreturns all annots with the specified functor e.g.: from annots [t(a), t(b), source(tom)] and functor "t", it returns [t(a),t(b)] in case that there is no such an annot, it returns an empty list.intgetArity()returns the number of terms of this literaljavax.json.JsonValuereturns this literal as a list with three elements: [namespace, functor, list of terms, list of annots]abstract Stringreturns the functor of this literalabstract AtomgetNS()returns the space name of this literalreturns name space :: functor symbol / arityreturns all singleton vars (that appears once) in this literalreturns the sources of this literal as a new list.getTerm(int i) returns the i-th term (first term is 0)getTerms()returns all terms of this literalTerm[]returns all terms of this literal as an arraybooleanhasAnnot()returns true if the pred has at least one annotbooleanreturns true if there is some annotation t in the literalbooleanreturns true if this literal has some source annotationbooleanreturns true if this literal has a "source(agName)"booleanreturns true if all this predicate annots are in p's annotsbooleanhasSubsetAnnot(Literal p, Unifier u) Returns true if all this predicate's annots are in p's annots using the unifier u.booleanhasTerm()returns true if this literal has some termboolean"import" annots from another predicate p.booleanlogicalConsequence(Agent ag, Unifier un) logicalConsequence checks whether one particular predicate is a logical consequence of the belief base.voidreplaces all terms by unnamed variables (_).replaces all variables by unnamed variables (_).makeVarsAnnon(Unifier un) replaces all variables of the term for unnamed variables (_).booleannegated()returns whether this literal is negated or not, use Literal.LNeg and Literal.LPos to compare the returned valuestatic Literalcreates a literal from a list with four elements: [namespace, functor, list of terms, list of annots] (namespace is optional)newFunctor(String f) noSource()static LiteralparseLiteral(String sLiteral) Deprecated.ASSyntax.parseLiteral or createLiteral are preferred.setNegated(boolean b) changes the negation of the literal and return thisvoidset all terms of the literal and return thisbooleanreturns this if this literal should be removed from BB while doing BUFMethods inherited from class jason.asSyntax.DefaultTerm
calcHashCode, capply, clone, cloneNS, compareTo, countVars, getCyclicVar, getErrorMsg, getSrcInfo, hashCode, hasVar, isArithExpr, isAtom, isCyclicTerm, isGround, isInternalAction, isList, isMap, isNumeric, isPlanBody, isPred, isRule, isSet, isString, isStructure, isUnnamedVar, isVar, parse, resetHashCodeCache, setSrcInfo, subsumesMethods inherited from class java.lang.Object
equals, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface jason.asSyntax.Term
capply, clone, cloneNS, countVars, equals, getCyclicVar, getSrcInfo, hasVar, isArithExpr, isAtom, isCyclicTerm, isGround, isInternalAction, isList, isMap, isNumeric, isPlanBody, isPred, isRule, isSet, isString, isStructure, isUnnamedVar, isVar, setSrcInfo, subsumesMethods inherited from interface jason.util.ToJson
getAsJsonStr
-
Field Details
-
LPos
public static final boolean LPos- See Also:
-
LNeg
public static final boolean LNeg- See Also:
-
DefaultNS
-
LTrue
-
LFalse
-
predicateIndicatorCache
-
-
Constructor Details
-
Literal
public Literal()
-
-
Method Details
-
parseLiteral
Deprecated.ASSyntax.parseLiteral or createLiteral are preferred. -
copy
-
getFunctor
returns the functor of this literal -
newFunctor
-
getNS
returns the space name of this literal -
isLiteral
public boolean isLiteral()- Specified by:
isLiteralin interfaceTerm- Overrides:
isLiteralin classDefaultTerm
-
getPredicateIndicator
returns name space :: functor symbol / arity -
getArity
public int getArity()returns the number of terms of this literal -
hasTerm
public boolean hasTerm()returns true if this literal has some term -
getTerms
returns all terms of this literal -
getTermsArray
returns all terms of this literal as an array -
getSingletonVars
returns all singleton vars (that appears once) in this literal -
makeTermsAnnon
public void makeTermsAnnon()replaces all terms by unnamed variables (_). -
makeVarsAnnon
replaces all variables by unnamed variables (_). -
makeVarsAnnon
replaces all variables of the term for unnamed variables (_).- Parameters:
un- is the unifier that contains the map of replacements
-
getAnnots
returns all annotations of the literal -
hasAnnot
returns true if there is some annotation t in the literal -
hasAnnot
public boolean hasAnnot()returns true if the pred has at least one annot -
hasSubsetAnnot
returns true if all this predicate annots are in p's annots -
hasSubsetAnnot
Returns true if all this predicate's annots are in p's annots using the unifier u. if p annots has a Tail, p annots's Tail will receive this predicate's annots, e.g.: this[a,b,c] = p[x,y,b|T] unifies and T is [a,c] (this will be a subset if p has a and c in its annots). if this annots has a tail, the Tail will receive all necessary term to be a subset, e.g.: this[b|T] = p[x,y,b] unifies and T is [x,y] (this will be a subset if T is [x,y]. -
clearAnnots
removes all annotations and returns itself -
getAnnots
returns all annots with the specified functor e.g.: from annots [t(a), t(b), source(tom)] and functor "t", it returns [t(a),t(b)] in case that there is no such an annot, it returns an empty list. -
getAnnot
returns the first annotation (literal) that has the functor -
getSources
returns the sources of this literal as a new list. e.g.: from annots [source(a), source(b)], it returns [a,b] -
hasSource
public boolean hasSource()returns true if this literal has some source annotation -
hasSource
returns true if this literal has a "source(agName)" -
canBeAddedInBB
public boolean canBeAddedInBB()returns this if this literal can be added in the belief base (Atoms, for instance, can not be) -
subjectToBUF
public boolean subjectToBUF()returns this if this literal should be removed from BB while doing BUF -
negated
public boolean negated()returns whether this literal is negated or not, use Literal.LNeg and Literal.LPos to compare the returned value -
equalsAsStructure
-
addTerm
-
delTerm
public void delTerm(int index) -
addTerms
adds some terms and return this -
addTerms
adds some terms and return this -
getTerm
returns the i-th term (first term is 0) -
setTerms
set all terms of the literal and return this -
setTerm
-
setAnnots
-
addAnnot
-
addAnnots
adds some annots and return this -
addAnnots
adds some annots and return this -
delAnnot
-
delAnnots
removes all annots in this pred that are in the list l.- Returns:
- true if some annot was removed.
-
delAnnots
public boolean delAnnots() -
importAnnots
"import" annots from another predicate p. p will be changed to contain only the annots actually imported (for Event), for example: p = b[a,b] this = b[b,c] after import, p = b[a] It is used to generate event invalid input: '<'+b[a]>.- Returns:
- true if some annot was imported.
-
addSource
adds the annotation source(agName) -
delSource
deletes one source(agName) annotation, return true if deleted -
delSources
public void delSources()deletes all source annotations -
noSource
-
setNegated
changes the negation of the literal and return this -
logicalConsequence
logicalConsequence checks whether one particular predicate is a logical consequence of the belief base. Returns an iterator for all unifiers that are logCons.- Specified by:
logicalConsequencein interfaceLogicalFormula
-
getAsListOfTerms
returns this literal as a list with three elements: [namespace, functor, list of terms, list of annots] -
newFromListOfTerms
creates a literal from a list with four elements: [namespace, functor, list of terms, list of annots] (namespace is optional)- Throws:
JasonException
-
forceFullLiteralImpl
Transforms this into a full literal (which implements all methods of Literal), if it is an Atom; otherwise returns 'this' -
addSourceInfoAsAnnots
-
getAsJson
public javax.json.JsonValue getAsJson()
-