Class FolSignature

  • All Implemented Interfaces:
    Cloneable, net.sf.tweety.commons.Signature

    public class FolSignature
    extends net.sf.tweety.commons.QuadrupleSetSignature<net.sf.tweety.logics.commons.syntax.Constant,​net.sf.tweety.logics.commons.syntax.Predicate,​net.sf.tweety.logics.commons.syntax.Functor,​net.sf.tweety.logics.commons.syntax.Sort>
    This class captures the signature of a specific first-order language.
    Author:
    Matthias Thimm
    • Field Summary

      • Fields inherited from class net.sf.tweety.commons.QuadrupleSetSignature

        firstSet, fourthSet, secondSet, thirdSet
    • Constructor Summary

      Constructors 
      Constructor Description
      FolSignature()
      Creates an empty signature
      FolSignature​(boolean containsEquality)
      Creates an empty signature or an otherwise empty signature with equality.
      FolSignature​(Collection<?> c)
      Creates a signature with the given objects (should be sorts, constants, predicates, functors, or formulas).
      FolSignature​(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​(Object obj)
      Adds the given object, either a constant, a sort, a predicate, or a functor, to this signature.
      void addAll​(Collection<?> c)
      Adds items of the given collection to this signature.
      FolSignature clone()  
      boolean contains​(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​(String s)
      Returns true if this signature contains the constant of the given name.
      boolean containsFunctor​(String s)
      Returns true if this signature contains the functor of the given name.
      boolean containsPredicate​(String s)
      Returns true if this signature contains the predicate of the given name.
      boolean containsSort​(String s)
      Returns true if this signature contains the sort of the given name.
      net.sf.tweety.logics.commons.syntax.Constant getConstant​(String s)
      Get the constant with the given name.
      Set<net.sf.tweety.logics.commons.syntax.Constant> getConstants()
      Returns the constants of this first-order logic signature.
      net.sf.tweety.logics.commons.syntax.Functor getFunctor​(String s)
      Get the functor with the given name.
      Set<net.sf.tweety.logics.commons.syntax.Functor> getFunctors()
      Returns the functors of this first-order logic signature.
      net.sf.tweety.logics.commons.syntax.Predicate getPredicate​(String s)
      Get the predicate with the given name.
      Set<net.sf.tweety.logics.commons.syntax.Predicate> getPredicates()
      Returns the predicates of this first-order logic signature.
      net.sf.tweety.logics.commons.syntax.Sort getSort​(String s)
      Get the sort with the given name.
      Set<net.sf.tweety.logics.commons.syntax.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​(Object obj)  
      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​(Collection<?> c)
                     throws 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:
        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​(Collection<?> c,
                            boolean containsEquality)
                     throws 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:
        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 Set<net.sf.tweety.logics.commons.syntax.Constant> getConstants()
        Returns the constants of this first-order logic signature.
        Returns:
        set of constants
      • getPredicates

        public Set<net.sf.tweety.logics.commons.syntax.Predicate> getPredicates()
        Returns the predicates of this first-order logic signature.
        Returns:
        set of predicates
      • getFunctors

        public Set<net.sf.tweety.logics.commons.syntax.Functor> getFunctors()
        Returns the functors of this first-order logic signature.
        Returns:
        set of functors
      • getSorts

        public Set<net.sf.tweety.logics.commons.syntax.Sort> getSorts()
        Returns the sorts of this first-order logic signature.
        Returns:
        set of sorts
      • add

        public void add​(Object obj)
                 throws 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:
        IllegalArgumentException - if the given object is neither a constant, a sort, a predicate, a functor, or a formula.
      • addAll

        public void addAll​(Collection<?> c)
                    throws 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 interface net.sf.tweety.commons.Signature
        Overrides:
        addAll in class net.sf.tweety.commons.QuadrupleSetSignature<net.sf.tweety.logics.commons.syntax.Constant,​net.sf.tweety.logics.commons.syntax.Predicate,​net.sf.tweety.logics.commons.syntax.Functor,​net.sf.tweety.logics.commons.syntax.Sort>
        Parameters:
        c - the collection of items to be added
        Throws:
        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 net.sf.tweety.logics.commons.syntax.Constant getConstant​(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 net.sf.tweety.logics.commons.syntax.Predicate getPredicate​(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 net.sf.tweety.logics.commons.syntax.Functor getFunctor​(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 net.sf.tweety.logics.commons.syntax.Sort getSort​(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​(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​(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​(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​(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​(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 String toString()
        Returns a string representation of this first-order logic signature.
        Specified by:
        toString in interface net.sf.tweety.commons.Signature
        Overrides:
        toString in class net.sf.tweety.commons.QuadrupleSetSignature<net.sf.tweety.logics.commons.syntax.Constant,​net.sf.tweety.logics.commons.syntax.Predicate,​net.sf.tweety.logics.commons.syntax.Functor,​net.sf.tweety.logics.commons.syntax.Sort>
        Returns:
        a string consisting of the sorts with their constants followed by the predicates and functors of the signature.
      • remove

        public void remove​(Object obj)
      • clone

        public FolSignature clone()
        Specified by:
        clone in interface net.sf.tweety.commons.Signature
        Specified by:
        clone in class net.sf.tweety.commons.QuadrupleSetSignature<net.sf.tweety.logics.commons.syntax.Constant,​net.sf.tweety.logics.commons.syntax.Predicate,​net.sf.tweety.logics.commons.syntax.Functor,​net.sf.tweety.logics.commons.syntax.Sort>