Package net.sf.tweety.lp.asp.syntax
Class DefaultNegation
- java.lang.Object
-
- net.sf.tweety.lp.asp.syntax.ASPElement
-
- net.sf.tweety.lp.asp.syntax.ASPBodyElement
-
- net.sf.tweety.lp.asp.syntax.DefaultNegation
-
- All Implemented Interfaces:
Formula
,ComplexLogicalFormula
,LogicStructure
,SimpleLogicalFormula
public class DefaultNegation extends ASPBodyElement
This class represents a default negated literal, i.e. "not a", where a is a classical atom or an aggregate atom.In answer set programming, the body of a rule is usually composed of a set of positive and negative literals, where this valuation refers to default negation or negation as failure. When implementing a rule, there are two opportunities:
- implement the rule with two distinct lists, representing the sets of positive and negative literals
- implement the rule with one set containing super literals, where a super literal can be positive or strictly negated, with or without default negation.
This library takes the second approach, which allows more flexibility, but comes at the cost that malformed constructs like "not not a" are not intercepted by the library.
- Author:
- Tim Janus, Thomas Vengels, Anna Gessler
-
-
Constructor Summary
Constructors Constructor Description DefaultNegation(ASPBodyElement at)
Creates new default negation with the given literal.
-
Method Summary
Modifier and Type Method Description DefaultNegation
clone()
Creates a deep copy of this formulaboolean
equals(java.lang.Object obj)
java.util.Set<ASPAtom>
getAtoms()
Processes the set of all atoms which appear in this formulaASPBodyElement
getLiteral()
java.util.SortedSet<ASPLiteral>
getLiterals()
Returns all literals in this element in form of a SortedSet.java.util.Set<Predicate>
getPredicates()
Processes the set of all predicates which appear in this formulaFolSignature
getSignature()
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.int
hashCode()
boolean
isLiteral()
boolean
isWellFormed()
Checks if this formula is well formed in the logical langauge.void
setLiteral(ASPBodyElement literal)
ASPBodyElement
substitute(Term<?> t, Term<?> v)
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.java.lang.String
toString()
-
Methods inherited from class net.sf.tweety.lp.asp.syntax.ASPElement
containsTermsOfType, exchange, getPredicateCls, isGround, substitute
-
-
-
-
Constructor Detail
-
DefaultNegation
public DefaultNegation(ASPBodyElement at)
Creates new default negation with the given literal.- Parameters:
at
- a classical atom or an aggregate atom
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLiterals
public java.util.SortedSet<ASPLiteral> 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
public java.util.Set<Predicate> 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
public java.util.Set<ASPAtom> 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
-
substitute
public ASPBodyElement substitute(Term<?> t, Term<?> v)
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:
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: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.
-
isWellFormed
public boolean isWellFormed()
Description copied from interface:ComplexLogicalFormula
Checks if this formula is well formed in the logical langauge. What well- formed means is highly language dependent and the documentation of implementing sub classes shall describe the well formed term for the language they model.- Specified by:
isWellFormed
in interfaceComplexLogicalFormula
- Overrides:
isWellFormed
in classASPElement
- Returns:
- true if the formula is well-formed, false otherwise
-
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
-
getTerms
public <C extends Term<?>> java.util.Set<C> getTerms(java.lang.Class<C> cls)
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
-
clone
public DefaultNegation 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
-
getLiteral
public ASPBodyElement getLiteral()
-
setLiteral
public void setLiteral(ASPBodyElement literal)
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceSimpleLogicalFormula
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceSimpleLogicalFormula
- Overrides:
equals
in classjava.lang.Object
-
-