Package net.sf.tweety.logics.fol.syntax
Class FolSignature
- java.lang.Object
-
- net.sf.tweety.commons.QuadrupleSetSignature<Constant,Predicate,Functor,Sort>
-
- net.sf.tweety.logics.fol.syntax.FolSignature
-
- All Implemented Interfaces:
java.lang.Cloneable
,Signature
- Direct Known Subclasses:
ActionSignature
public class FolSignature extends QuadrupleSetSignature<Constant,Predicate,Functor,Sort>
This class captures the signature of a specific first-order language.- Author:
- Matthias Thimm
-
-
Constructor Summary
Constructors Constructor Description FolSignature()
Creates an empty signatureFolSignature(boolean containsEquality)
Creates an empty signature or an otherwise empty signature with equality.FolSignature(java.util.Collection<?> c)
Creates a signature with the given objects (should be sorts, constants, predicates, functors, or formulas).FolSignature(java.util.Collection<?> c, boolean containsEquality)
Creates a signature with the given objects (should be sorts, constants, predicates, functors, or formulas) and, if desired, equality.
-
Method Summary
Modifier and Type Method Description void
add(java.lang.Object obj)
Adds the given object, either a constant, a sort, a predicate, or a functor, to this signature.void
addAll(java.util.Collection<?> c)
Adds items of the given collection to this signature.FolSignature
clone()
boolean
contains(java.lang.Object o)
Returns true if this signature contains the specified constant, predicate, functor, sort or all constants, predicates, functors and sorts in the specified FolFormula.boolean
containsConstant(java.lang.String s)
Returns true if this signature contains the constant of the given name.boolean
containsFunctor(java.lang.String s)
Returns true if this signature contains the functor of the given name.boolean
containsPredicate(java.lang.String s)
Returns true if this signature contains the predicate of the given name.boolean
containsSort(java.lang.String s)
Returns true if this signature contains the sort of the given name.Constant
getConstant(java.lang.String s)
Get the constant with the given name.java.util.Set<Constant>
getConstants()
Returns the constants of this first-order logic signature.Functor
getFunctor(java.lang.String s)
Get the functor with the given name.java.util.Set<Functor>
getFunctors()
Returns the functors of this first-order logic signature.Predicate
getPredicate(java.lang.String s)
Get the predicate with the given name.java.util.Set<Predicate>
getPredicates()
Returns the predicates of this first-order logic signature.Sort
getSort(java.lang.String s)
Get the sort with the given name.java.util.Set<Sort>
getSorts()
Returns the sorts of this first-order logic signature.boolean
isRepresentable(FolFormula folFormula)
Checks whether the given formula can be represented by this signature.void
remove(java.lang.Object obj)
Removes the given formula from this signature, if it is present (optional operation).java.lang.String
toString()
Returns a string representation of this first-order logic signature.-
Methods inherited from class net.sf.tweety.commons.QuadrupleSetSignature
add, addSignature, clear, equals, hashCode, isEmpty, isOverlappingSignature, isSubSignature, removeAll
-
-
-
-
Constructor Detail
-
FolSignature
public FolSignature()
Creates an empty signature
-
FolSignature
public FolSignature(boolean containsEquality)
Creates an empty signature or an otherwise empty signature with equality.- Parameters:
containsEquality
- if true, the equality predicate is added to the signature
-
FolSignature
public FolSignature(java.util.Collection<?> c) throws java.lang.IllegalArgumentException
Creates a signature with the given objects (should be sorts, constants, predicates, functors, or formulas).- Parameters:
c
- a collection of items to be added.- Throws:
java.lang.IllegalArgumentException
- if at least one of the given objects is neither a constant, a sort, a predicate, a functor, or a formula.
-
FolSignature
public FolSignature(java.util.Collection<?> c, boolean containsEquality) throws java.lang.IllegalArgumentException
Creates a signature with the given objects (should be sorts, constants, predicates, functors, or formulas) and, if desired, equality.- Parameters:
c
- a collection of items to be added.containsEquality
- if true, the equality predicate is added to the signature- Throws:
java.lang.IllegalArgumentException
- if at least one of the given objects is neither a constant, a sort, a predicate, a functor, or a formula.
-
-
Method Detail
-
getConstants
public java.util.Set<Constant> getConstants()
Returns the constants of this first-order logic signature.- Returns:
- set of constants
-
getPredicates
public java.util.Set<Predicate> getPredicates()
Returns the predicates of this first-order logic signature.- Returns:
- set of predicates
-
getFunctors
public java.util.Set<Functor> getFunctors()
Returns the functors of this first-order logic signature.- Returns:
- set of functors
-
getSorts
public java.util.Set<Sort> getSorts()
Returns the sorts of this first-order logic signature.- Returns:
- set of sorts
-
add
public void add(java.lang.Object obj) throws java.lang.IllegalArgumentException
Adds the given object, either a constant, a sort, a predicate, or a functor, to this signature. If a constant is added its sort is added as well, the same is for any sort mentioned in predicates and functors. Alternatively, you can pass over a formula, then all predicates, sorts, constants, and functors of this formula are added to the signature.- Parameters:
obj
- the object to be added, either a constant, a sort, a predicate, a functor, or a formula.- Throws:
java.lang.IllegalArgumentException
- if the given object is neither a constant, a sort, a predicate, a functor, or a formula.
-
addAll
public void addAll(java.util.Collection<?> c) throws java.lang.IllegalArgumentException
Adds items of the given collection to this signature. These should be either constants, sorts, predicates, or functors. Alternatively, you can pass over formulas, then all predicates, sorts, constants, and functors of this formula are added t the signature.- Specified by:
addAll
in interfaceSignature
- Overrides:
addAll
in classQuadrupleSetSignature<Constant,Predicate,Functor,Sort>
- Parameters:
c
- the collection of items to be added- Throws:
java.lang.IllegalArgumentException
- if at least one of the given objects is neither a constant, a sort, a predicate, a functor, or a formula.
-
isRepresentable
public boolean isRepresentable(FolFormula folFormula)
Checks whether the given formula can be represented by this signature.- Parameters:
folFormula
- A formula to be checked.- Returns:
- "true" if the given formula is representable, "false" otherwise.
-
getConstant
public Constant getConstant(java.lang.String s)
Get the constant with the given name.- Parameters:
s
- name of constant- Returns:
- the constant with the given name if it is part of the signature, null otherwise
-
getPredicate
public Predicate getPredicate(java.lang.String s)
Get the predicate with the given name.- Parameters:
s
- name of predicate- Returns:
- the predicate with the given name if it is part of the signature, null otherwise
-
getFunctor
public Functor getFunctor(java.lang.String s)
Get the functor with the given name.- Parameters:
s
- name of functor- Returns:
- the functor with the given name if it is part of the signature, null otherwise
-
getSort
public Sort getSort(java.lang.String s)
Get the sort with the given name.- Parameters:
s
- name of sort- Returns:
- the sort with the given name if it is part of the signature, null otherwise
-
contains
public boolean contains(java.lang.Object o)
Returns true if this signature contains the specified constant, predicate, functor, sort or all constants, predicates, functors and sorts in the specified FolFormula.- Parameters:
o
- either a constant, predicate, functor, sort or FolFormula- Returns:
- true if the signature contains the specified formula
-
containsConstant
public boolean containsConstant(java.lang.String s)
Returns true if this signature contains the constant of the given name.- Parameters:
s
- name of constant- Returns:
- true if the signature contains the constant
-
containsPredicate
public boolean containsPredicate(java.lang.String s)
Returns true if this signature contains the predicate of the given name.- Parameters:
s
- name of predicate- Returns:
- true if the signature contains the predicate
-
containsFunctor
public boolean containsFunctor(java.lang.String s)
Returns true if this signature contains the functor of the given name.- Parameters:
s
- name of functor- Returns:
- true if the signature contains the functor
-
containsSort
public boolean containsSort(java.lang.String s)
Returns true if this signature contains the sort of the given name.- Parameters:
s
- name of sort- Returns:
- true if the signature contains the sort
-
toString
public java.lang.String toString()
Returns a string representation of this first-order logic signature.
-
remove
public void remove(java.lang.Object obj)
Description copied from interface:Signature
Removes the given formula from this signature, if it is present (optional operation).- Parameters:
obj
- some object
-
clone
public FolSignature clone()
-
-