Package net.sf.tweety.logics.fol.syntax
Class FolAtom
- java.lang.Object
-
- net.sf.tweety.logics.commons.syntax.RelationalFormula
-
- net.sf.tweety.logics.fol.syntax.FolFormula
-
- net.sf.tweety.logics.fol.syntax.FolAtom
-
- All Implemented Interfaces:
Formula
,Atom
,ClassicalFormula
,ComplexLogicalFormula
,Conjunctable
,Disjunctable
,Invertable
,LogicStructure
,ProbabilityAware
,QuantifiedFormula
,SimpleLogicalFormula
public class FolAtom extends FolFormula implements Atom
An atom in first-order logic, i.e. a predicate and a list of argument terms.- Author:
- Matthias Thimm
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.Atom
Atom.AtomImpl, Atom.RETURN_SET_PREDICATE
-
-
Constructor Summary
Constructors Constructor Description FolAtom()
Default-Ctor: Creates new empty FOL-AtomFolAtom(Predicate predicate)
Creates a new atom with the given predicate and initializes an empty argument list.FolAtom(Predicate predicate, java.util.List<? extends Term<?>> arguments)
Creates a new atom with the given predicate and list of termsFolAtom(Predicate predicate, Term<?>... terms)
FolAtom(FolAtom other)
-
Method Summary
Modifier and Type Method Description void
addArgument(Term<?> term)
Appends the given argument to this atom's arguments and returns itself.FolAtom
clone()
Creates a deep copy of this formulaFolFormula
collapseAssociativeFormulas()
This method collapses all associative operations appearing in this term, e.g.boolean
containsQuantifier()
Checks whether this formula contains any quantification.boolean
equals(java.lang.Object obj)
java.util.List<Term<?>>
getArguments()
java.util.Set<FolAtom>
getAtoms()
Processes the set of all atoms which appear in this formulajava.util.Set<Functor>
getFunctors()
java.lang.String
getName()
Predicate
getPredicate()
Returns the predicate of this atomjava.util.Set<Predicate>
getPredicates()
Processes the set of all predicates which appear in this formulajava.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.java.util.Set<Variable>
getUnboundVariables()
int
hashCode()
boolean
isClosed()
Checks whether this formula is closed, i.e.boolean
isClosed(java.util.Set<Variable> boundVariables)
Checks whether this formula is closed, i.e.boolean
isComplete()
Checks whether this atom is complete, i.e.boolean
isDnf()
Checks whether this formula is in disjunctive normal form.boolean
isLiteral()
boolean
isWellBound()
Checks whether this formula is well-bound, i.e.boolean
isWellBound(java.util.Set<Variable> boundVariables)
Checks whether this formula is well-bound, i.e.Atom.RETURN_SET_PREDICATE
setPredicate(Predicate newer)
Changes the predicate of the atom.FolAtom
substitute(Term<?> v, Term<?> t)
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula.FolFormula
toNnf()
Makes the negation normal form of this formula.java.lang.String
toString()
-
Methods inherited from class net.sf.tweety.logics.fol.syntax.FolFormula
combineWithAnd, combineWithOr, complement, getQuantifierVariables, getSignature, getUniformProbability, toDnf
-
Methods inherited from class net.sf.tweety.logics.commons.syntax.RelationalFormula
allGroundInstances, allSubstitutions, containsTermsOfType, exchange, getFormula, getPredicateCls, getSatisfactionRatio, isGround, isWellFormed, substitute
-
Methods inherited from interface net.sf.tweety.commons.Formula
getSignature
-
Methods inherited from interface net.sf.tweety.logics.commons.syntax.interfaces.SimpleLogicalFormula
getPredicateCls
-
-
-
-
Constructor Detail
-
FolAtom
public FolAtom()
Default-Ctor: Creates new empty FOL-Atom
-
FolAtom
public FolAtom(Predicate predicate)
Creates a new atom with the given predicate and initializes an empty argument list.- Parameters:
predicate
- the predicate of the atom.
-
FolAtom
public FolAtom(Predicate predicate, java.util.List<? extends Term<?>> arguments)
Creates a new atom with the given predicate and list of terms- Parameters:
predicate
- the predicate of the atomarguments
- the arguments (terms) of the atom
-
FolAtom
public FolAtom(FolAtom other)
-
-
Method Detail
-
addArgument
public void addArgument(Term<?> term) throws java.lang.IllegalArgumentException
Appends the given argument to this atom's arguments and returns itself.- Specified by:
addArgument
in interfaceAtom
- Parameters:
term
- an argument to be added- Throws:
java.lang.IllegalArgumentException
- if the given term does not correspond to the expected sort or the argument list is complete.
-
substitute
public FolAtom substitute(Term<?> v, Term<?> t) throws java.lang.IllegalArgumentException
Description copied from class:RelationalFormula
Substitutes all occurrences of term "v" in this formula by term "t" and returns the new formula. NOTE: if "v" is a variable and bound to a quantifier then "v" is not substituted in that quantifiers inner formula.- Specified by:
substitute
in interfaceComplexLogicalFormula
- Specified by:
substitute
in classFolFormula
- 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 (NOTE: this exception is only thrown when "v" actually appears in this formula).
-
getAtoms
public java.util.Set<FolAtom> 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 classRelationalFormula
- Returns:
- all atoms that appear in this formula.
-
isComplete
public boolean isComplete()
Checks whether this atom is complete, i.e. whether every argument is set.- Specified by:
isComplete
in interfaceAtom
- Returns:
- "true" if the atom is complete.
-
getUnboundVariables
public java.util.Set<Variable> getUnboundVariables()
- Specified by:
getUnboundVariables
in interfaceQuantifiedFormula
- Returns:
- a set of of unbound variables
-
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
- Returns:
- all predicates that appear in this formula
-
getFunctors
public java.util.Set<Functor> getFunctors()
- Specified by:
getFunctors
in classRelationalFormula
- Returns:
- all functors that appear in this formula.
-
isClosed
public boolean isClosed()
Description copied from interface:QuantifiedFormula
Checks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier.- Specified by:
isClosed
in interfaceQuantifiedFormula
- Returns:
- "true" if this formula is closed, "false" otherwise.
-
isClosed
public boolean isClosed(java.util.Set<Variable> boundVariables)
Description copied from interface:QuantifiedFormula
Checks whether this formula is closed, i.e. whether every variables occurring in the formula is bound by a quantifier. Every variable in "boundVariables" is already assumed to be bound.- Specified by:
isClosed
in interfaceQuantifiedFormula
- Parameters:
boundVariables
- the variables assumed to be bound.- Returns:
- "true" if this formula is closed wrt. "boundVariables", "false" otherwise.
-
isWellBound
public boolean isWellBound()
Description copied from interface:QuantifiedFormula
Checks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier's range.- Specified by:
isWellBound
in interfaceQuantifiedFormula
- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
isWellBound
public boolean isWellBound(java.util.Set<Variable> boundVariables)
Description copied from interface:QuantifiedFormula
Checks whether this formula is well-bound, i.e. whether no variable bound by a quantifier is again bound by another quantifier within the first quantifier range. Every variable in "boundVariables" is assumed to be bound already.- Specified by:
isWellBound
in interfaceQuantifiedFormula
- Parameters:
boundVariables
- the variables assumed to be bound.- Returns:
- "true" if this formula is well-bound, "false" otherwise.
-
containsQuantifier
public boolean containsQuantifier()
Description copied from interface:QuantifiedFormula
Checks whether this formula contains any quantification.- Specified by:
containsQuantifier
in interfaceQuantifiedFormula
- Returns:
- "true" if this formula contains a quantification.
-
getPredicate
public Predicate getPredicate()
Returns the predicate of this atom- Specified by:
getPredicate
in interfaceAtom
- Returns:
- the predicate of this atom
-
getArguments
public java.util.List<Term<?>> getArguments()
- Specified by:
getArguments
in interfaceAtom
- Returns:
- the arguments of this atom.
-
isDnf
public boolean isDnf()
Description copied from class:FolFormula
Checks whether this formula is in disjunctive normal form.- Specified by:
isDnf
in classFolFormula
- Returns:
- "true" iff this formula is in disjunctive normal form.
-
isLiteral
public boolean isLiteral()
- Specified by:
isLiteral
in interfaceSimpleLogicalFormula
- Returns:
- true if the formula represents a literal in the language or false otherwise
-
toString
public java.lang.String toString()
- Specified by:
toString
in classRelationalFormula
-
toNnf
public FolFormula toNnf()
Description copied from class:FolFormula
Makes the negation normal form of this formula.- Specified by:
toNnf
in classFolFormula
- Returns:
- the NNF of this formula
-
collapseAssociativeFormulas
public FolFormula collapseAssociativeFormulas()
Description copied from class:FolFormula
This method collapses all associative operations appearing in this term, e.g. every a||(b||c) becomes a||b||c.- Specified by:
collapseAssociativeFormulas
in classFolFormula
- Returns:
- the collapsed formula.
-
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
-
getTerms
public java.util.Set<Term<?>> getTerms()
- Specified by:
getTerms
in interfaceLogicStructure
- 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.- Specified by:
getTerms
in interfaceLogicStructure
- 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 FolAtom 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 classFolFormula
- Returns:
- the cloned formula
-
setPredicate
public Atom.RETURN_SET_PREDICATE setPredicate(Predicate newer)
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.- Specified by:
setPredicate
in interfaceAtom
- Parameters:
newer
- some predicate- Returns:
- Depends on the cases described above: 1. RSP_SUCCESS 2. RSP_INCOMPLETE 3. RSP_TRUNCATED 4. RSP_CLEARED
-
-