Class InverseSetLattice<S extends InverseSetLattice<S,​E>,​E>

  • Type Parameters:
    S - the concrete instance of InverseSetLattice
    E - the type of elements of the domain of this lattice
    All Implemented Interfaces:
    BaseLattice<S>, Lattice<S>, StructuredObject, java.lang.Iterable<E>
    Direct Known Subclasses:
    ExpressionInverseSet, GenericInverseSetLattice

    public abstract class InverseSetLattice<S extends InverseSetLattice<S,​E>,​E>
    extends java.lang.Object
    implements BaseLattice<S>, java.lang.Iterable<E>
    A generic inverse set lattice containing a set of elements. Lattice operations are the opposite of the SetLattice ones, namely:
    • the lub is the set intersection
    • the ≤ is the inverse set inclusion
    Widening on instances of this lattice depends on the cardinality of the domain of the underlying elements. The provided implementation behave as the domain is finite, thus invoking the lub. Inverse set lattices defined on infinite domains must implement a coherent widening logic.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.util.Set<E> elements
      The set of elements contained in the lattice.
      boolean isTop
      Whether or not this is the top or bottom element of the lattice, valid only if the set of elements is empty.
    • Constructor Summary

      Constructors 
      Constructor Description
      InverseSetLattice​(java.util.Set<E> elements, boolean isTop)
      Builds the lattice.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(E elem)
      Checks whether an element is contained in this set.
      java.util.Set<E> elements()
      Yields the set of elements contained in this lattice element.
      boolean equals​(java.lang.Object obj)  
      S glbAux​(S other)
      Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled.
      int hashCode()  
      boolean isBottom()
      Yields true if and only if this object represents the bottom of the lattice.
      boolean isEmpty()
      Returns true if this set contains no elements.
      boolean isTop()
      Yields true if and only if this object represents the top of the lattice.
      java.util.Iterator<E> iterator()  
      boolean lessOrEqualAux​(S other)
      Yields true if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.
      S lubAux​(S other)
      Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.
      abstract S mk​(java.util.Set<E> set)
      Utility for creating a concrete instance of InverseSetLattice given a set.
      StructuredRepresentation representation()
      Yields a StructuredRepresentation of the information contained in this object's instance.
      int size()
      Returns the number of elements in this lattice (its cardinality).
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • elements

        public java.util.Set<E> elements
        The set of elements contained in the lattice.
      • isTop

        public final boolean isTop
        Whether or not this is the top or bottom element of the lattice, valid only if the set of elements is empty.
    • Constructor Detail

      • InverseSetLattice

        public InverseSetLattice​(java.util.Set<E> elements,
                                 boolean isTop)
        Builds the lattice.
        Parameters:
        elements - the elements that are contained in the lattice
        isTop - whether or not this is the top or bottom element of the lattice, valid only if the set of elements is empty
    • Method Detail

      • mk

        public abstract S mk​(java.util.Set<E> set)
        Utility for creating a concrete instance of InverseSetLattice given a set. This decouples the instance of set used during computation of the elements to put in the lattice from the actual type of set underlying the lattice.
        Parameters:
        set - the set containing the elements that must be included in the lattice instance
        Returns:
        a new concrete instance of InverseSetLattice containing the elements of the given set
      • lubAux

        public S lubAux​(S other)
                 throws SemanticException
        Description copied from interface: BaseLattice
        Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        lubAux in interface BaseLattice<S extends InverseSetLattice<S,​E>>
        Parameters:
        other - the other lattice element
        Returns:
        the least upper bound between this and other
        Throws:
        SemanticException - if an error occurs during the computation
      • glbAux

        public S glbAux​(S other)
                 throws SemanticException
        Description copied from interface: BaseLattice
        Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        glbAux in interface BaseLattice<S extends InverseSetLattice<S,​E>>
        Parameters:
        other - the other lattice element
        Returns:
        the greatest lower bound between this and other
        Throws:
        SemanticException - if an error occurs during the computation
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<S extends InverseSetLattice<S,​E>>
      • lessOrEqualAux

        public boolean lessOrEqualAux​(S other)
                               throws SemanticException
        Description copied from interface: BaseLattice
        Yields true if and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        lessOrEqualAux in interface BaseLattice<S extends InverseSetLattice<S,​E>>
        Parameters:
        other - the other lattice element
        Returns:
        true if and only if that condition holds
        Throws:
        SemanticException - if an error occurs during the computation
      • contains

        public boolean contains​(E elem)
        Checks whether an element is contained in this set.
        Parameters:
        elem - the element
        Returns:
        true if the element is contained in this set, false otherwise.
      • elements

        public java.util.Set<E> elements()
        Yields the set of elements contained in this lattice element.
        Returns:
        the set of elements contained in this lattice element.
      • isTop

        public boolean isTop()
        Description copied from interface: Lattice
        Yields true if and only if this object represents the top of the lattice. The default implementation of this method uses reference equality between this and the value returned by Lattice.top(), thus assuming that the top element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.
        Specified by:
        isTop in interface Lattice<S extends InverseSetLattice<S,​E>>
        Returns:
        true if this is the top of the lattice
      • isBottom

        public boolean isBottom()
        Description copied from interface: Lattice
        Yields true if and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality between this and the value returned by Lattice.bottom(), thus assuming that the bottom element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.
        Specified by:
        isBottom in interface Lattice<S extends InverseSetLattice<S,​E>>
        Returns:
        true if this is the bottom of the lattice
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface BaseLattice<S extends InverseSetLattice<S,​E>>
        Overrides:
        equals in class java.lang.Object
      • size

        public int size()
        Returns the number of elements in this lattice (its cardinality). If this lattice contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Returns:
        the number of elements in this lattice (its cardinality)
      • isEmpty

        public boolean isEmpty()
        Returns true if this set contains no elements.
        Returns:
        true if this set contains no elements