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.
| Constructor and Description |
|---|
AbstractLattice() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
comp(Element x,
Element y)
Check whether two elements are comparable using
Lattice.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... element)
Ensure that the provided elements belong to this lattice, throwing an
ElementLatticeMismatchException otherwise. |
protected void |
ensureElementsInLattice(Element x)
Ensure that the provided element belong to this lattice, throwing an
ElementLatticeMismatchException otherwise. |
protected void |
ensureElementsInLattice(Element x,
Element y)
Ensure that the provided elements belong to this lattice, throwing an
ElementLatticeMismatchException 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 using
Lattice.meet(Element[]). |
Element |
pscomp(Element x,
Element y)
Enumerate all elements of this lattice to compute explicitly the
pseudocomplement using the definition given in
Lattice.pscomp(Element, Element). |
Element |
psdiff(Element x,
Element y)
Enumerate all elements of this lattice to compute explicitly the
difference using the definition given in
Lattice.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.
|
public boolean isDistributive()
LatticeisDistributive in interface Latticeprotected void ensureElementsInLattice(Element x)
ElementLatticeMismatchException otherwise.x - an element.protected void ensureElementsInLattice(Element x, Element y)
ElementLatticeMismatchException otherwise.x - an element.y - another element.protected void ensureElementsInLattice(Element... element)
ElementLatticeMismatchException otherwise.element - some elements.protected Element valueOfZeroOrOne(String s)
s - a string.Lattice.zero() or Lattice.one() is s is 0
or 1, respectively; null otherwise.public Collection<Element> elements()
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.
public boolean comp(Element x, Element y)
Lattice.meet(Element[]).public boolean leq(Element x, Element y)
Lattice.meet(Element[]).public Element psdiff(Element x, Element y)
Lattice.psdiff(Element, Element).
It is expected that concrete subclasses will override this method
with an ad hoc, more efficient implementation.psdiff in interface Latticex - an element.y - another element.x − y.Lattice.psdiff(Element, Element)public Element pscomp(Element x, Element y)
Lattice.pscomp(Element, Element).
It is expected that concrete subclasses will override this method
with an ad hoc, more efficient implementation.pscomp in interface Latticex - an element.y - another element.x ⇒ y.Lattice.pscomp(Element, Element)public Element symdiff(Element x, Element y)
psdiff(x,y).join(psdiff(y,x)).symdiff in interface Latticex - an element.y - another element.x Δ y.Element.join(Element),
Lattice.psdiff(Element, Element)public Map<Element,Set<Element>> coveringRelation()
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.
coveringRelation in interface Lattice