Package it.unive.lisa.analysis.lattices
Class InverseSetLattice<S extends InverseSetLattice<S,E>,E>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<S>
-
- it.unive.lisa.analysis.lattices.InverseSetLattice<S,E>
-
- Type Parameters:
S- the concrete instance ofInverseSetLatticeE- the type of elements of the domain of this lattice
- All Implemented Interfaces:
Lattice<S>,java.lang.Iterable<E>
public abstract class InverseSetLattice<S extends InverseSetLattice<S,E>,E> extends BaseLattice<S> implements java.lang.Iterable<E>
A generic inverse set lattice containing a set of elements. Lattice operations are the opposite of theSetLatticeones, namely:- the lub is the set intersection
- the ≤ is the inverse set inclusion
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<E>elementsThe set of elements contained in the lattice.-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedInverseSetLattice(java.util.Set<E> elements)Builds the lattice.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontains(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.booleanequals(java.lang.Object obj)Sglb(S other)Performs the greatest lower bound between this inverse set lattice element and the given one.inthashCode()booleanisEmpty()Returnstrueif this set contains no elements.java.util.Iterator<E>iterator()protected booleanlessOrEqualAux(S other)Yieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.protected SlubAux(S other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.protected abstract Smk(java.util.Set<E> set)Utility for creating a concrete instance ofInverseSetLatticegiven a set.intsize()Returns the number of elements in this lattice (its cardinality).java.lang.StringtoString()protected SwideningAux(S other)Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lub, widening
-
-
-
-
Field Detail
-
elements
protected java.util.Set<E> elements
The set of elements contained in the lattice.
-
-
Constructor Detail
-
InverseSetLattice
protected InverseSetLattice(java.util.Set<E> elements)
Builds the lattice.- Parameters:
elements- the elements that are contained in the lattice
-
-
Method Detail
-
mk
protected abstract S mk(java.util.Set<E> set)
Utility for creating a concrete instance ofInverseSetLatticegiven 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
InverseSetLatticecontaining the elements of the given set
-
lubAux
protected final S lubAux(S other) throws SemanticException
Description copied from class:BaseLatticePerforms 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:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lubAuxin classBaseLattice<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
-
glb
public final S glb(S other) throws SemanticException
Performs the greatest lower bound between this inverse set lattice element and the given one.- Parameters:
other- the other inverse set lattice element- Returns:
- the greatest lower bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
wideningAux
protected S wideningAux(S other) throws SemanticException
Description copied from class:BaseLatticePerforms the widening operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
wideningAuxin classBaseLattice<S extends InverseSetLattice<S,E>>- Parameters:
other- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
iterator
public java.util.Iterator<E> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<S extends InverseSetLattice<S,E>>
-
lessOrEqualAux
protected final boolean lessOrEqualAux(S other) throws SemanticException
Description copied from class:BaseLatticeYieldstrueif 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:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lessOrEqualAuxin classBaseLattice<S extends InverseSetLattice<S,E>>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<S extends InverseSetLattice<S,E>>
-
contains
public boolean contains(E elem)
Checks whether an element is contained in this set.- Parameters:
elem- the element- Returns:
trueif the element is contained in this set,falseotherwise.
-
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.
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<S extends InverseSetLattice<S,E>>
-
toString
public final java.lang.String toString()
- Specified by:
toStringin classBaseLattice<S extends InverseSetLattice<S,E>>
-
size
public int size()
Returns the number of elements in this lattice (its cardinality). If this lattice contains more thanInteger.MAX_VALUEelements, returnsInteger.MAX_VALUE.- Returns:
- the number of elements in this lattice (its cardinality)
-
isEmpty
public boolean isEmpty()
Returnstrueif this set contains no elements.- Returns:
trueif this set contains no elements
-
-