Class AbstractLattice
- All Implemented Interfaces:
Lattice
- Direct Known Subclasses:
AbstractDistributiveLattice
,Flat
,Product
public abstract class AbstractLattice extends Object implements Lattice
Lattice
providing obvious
implementations of order-related operators and an
implementation of elements()
based on exhaustive generation.
The additional methods ensureElementsInLattice(Element[])
and valueOfZeroOrOne(String)
can be used to simplify concrete
implementing subclasses.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractLattice()
-
Method Summary
Modifier and Type Method Description boolean
comp(Element x, Element y)
Check whether two elements are comparable usingLattice.meet(Element[])
.Map<Element,Set<Element>>
coveringRelation()
Return the covering relation of this lattice.Collection<Element>
elements()
Generate iteratively all elements of this lattice.protected void
ensureElementsInLattice(Element x)
Ensure that the provided element belong to this lattice, throwing anElementLatticeMismatchException
otherwise.protected void
ensureElementsInLattice(Element... element)
Ensure that the provided elements belong to this lattice, throwing anElementLatticeMismatchException
otherwise.protected void
ensureElementsInLattice(Element x, Element y)
Ensure that the provided elements belong to this lattice, throwing anElementLatticeMismatchException
otherwise.boolean
isDistributive()
Return true if this lattice is distributive.boolean
leq(Element x, Element y)
Check whether an element is smaller than or equal to another element usingLattice.meet(Element[])
.Element
pscomp(Element x, Element y)
Enumerate all elements of this lattice to compute explicitly the pseudocomplement using the definition given inLattice.pscomp(Element, Element)
.Element
psdiff(Element x, Element y)
Enumerate all elements of this lattice to compute explicitly the difference using the definition given inLattice.psdiff(Element, Element)
.Element
symdiff(Element x, Element y)
Return the symmetric difference of the arguments, that is,psdiff(x,y).join(psdiff(y,x))
.protected Element
valueOfZeroOrOne(String s)
A simple support method to make it easy to parse zero and one.
-
Constructor Details
-
AbstractLattice
public AbstractLattice()
-
-
Method Details
-
isDistributive
public boolean isDistributive()Description copied from interface:Lattice
Return true if this lattice is distributive.- Specified by:
isDistributive
in interfaceLattice
- Returns:
- true if this lattice is distributive.
-
ensureElementsInLattice
Ensure that the provided element belong to this lattice, throwing anElementLatticeMismatchException
otherwise.- Parameters:
x
- an element.
-
ensureElementsInLattice
Ensure that the provided elements belong to this lattice, throwing anElementLatticeMismatchException
otherwise.- Parameters:
x
- an element.y
- another element.
-
ensureElementsInLattice
Ensure that the provided elements belong to this lattice, throwing anElementLatticeMismatchException
otherwise.- Parameters:
element
- some elements.
-
valueOfZeroOrOne
A simple support method to make it easy to parse zero and one.- Parameters:
s
- a string.- Returns:
Lattice.zero()
orLattice.one()
iss
is0
or1
, respectively;null
otherwise.
-
elements
Generate iteratively all elements of this lattice.This methods uses
Lattice.generators()
to obtain an initial set of elements, and then computes joins and meets of all available elements until no new elements are generated. It is expected that concrete subclasses will override this method with an ad hoc, more efficient implementation.It is strongly suggested that concrete subclasses that do not override this method cache its result internally.
-
comp
Check whether two elements are comparable usingLattice.meet(Element[])
. -
leq
Check whether an element is smaller than or equal to another element usingLattice.meet(Element[])
. -
psdiff
Enumerate all elements of this lattice to compute explicitly the difference using the definition given inLattice.psdiff(Element, Element)
. It is expected that concrete subclasses will override this method with an ad hoc, more efficient implementation.- Specified by:
psdiff
in interfaceLattice
- Parameters:
x
- an element.y
- another element.- Returns:
x
−y
.- See Also:
Lattice.psdiff(Element, Element)
-
pscomp
Enumerate all elements of this lattice to compute explicitly the pseudocomplement using the definition given inLattice.pscomp(Element, Element)
. It is expected that concrete subclasses will override this method with an ad hoc, more efficient implementation.- Specified by:
pscomp
in interfaceLattice
- Parameters:
x
- an element.y
- another element.- Returns:
x
⇒y
.- See Also:
Lattice.pscomp(Element, Element)
-
symdiff
Return the symmetric difference of the arguments, that is,psdiff(x,y).join(psdiff(y,x))
.- Specified by:
symdiff
in interfaceLattice
- Parameters:
x
- an element.y
- another element.- Returns:
x
Δy
.- See Also:
Element.join(Element)
,Lattice.psdiff(Element, Element)
-
coveringRelation
Return the covering relation of this lattice.This method examines exhaustively all pairs of elements x, y such that there is no element strictly between x and y. In the worst case, this requires cubic time. It is expected that concrete subclasses will override this method with an ad hoc, more efficient implementation.
- Specified by:
coveringRelation
in interfaceLattice
- Returns:
- a map from elements to set of elements representing the covering relation.
-