Class Chain

All Implemented Interfaces:
Lattice

public class Chain
extends AbstractDistributiveLattice
A chain (a.k.a. linearly ordered) distributive lattice.

Elements of a chain with n elements are numbered from 0 to n − 1, causing an unfortunate clash between one(), which can be obtained as valueOf("1"), and the second element (starting from zero()) of the chain, which can be obtained as valueOf(1).

  • Constructor Details

    • Chain

      public Chain​(int n, String... name)
      Create a chain with the given number of elements, naming elements with the given strings.
      Parameters:
      n - the number of elements in this chain.
      name - n-2 names for the elements of this chain, except for zero() and one().
    • Chain

      public Chain​(int n)
      Create a chain with the given number of elements.
      Parameters:
      n - the number of elements in this chain.
  • Method Details

    • valueOf

      public Element valueOf​(String name)
      Description copied from interface: Lattice
      Return an element of this lattice, given its name.

      Certain lattices make it possible to define names for elements. This method returns the element corresponding to the provided name.

      Parameters:
      name - the name of an element of this lattice.
      Returns:
      the element of this lattice named name.
    • valueOf

      public Element valueOf​(int i)
      Return the element of this chain of given ordinal position.

      Note that while valueOf(0) return zero(), valueOf(1) will not return one() unless this chain has less than three elements.

      Parameters:
      i - the ordinal position in this chain (starting at zero() with position 0).
      Returns:
      the element of this chain of ordinal position i.
    • generators

      public Collection<Element> generators()
      Description copied from interface: Lattice
      Return a collection of generators for the lattice. The set will not include zero or one. There is no guarantee of freeness or minimality.
      Returns:
      a collection of generators.
    • elements

      public Collection<Element> elements()
      Description copied from class: AbstractLattice
      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.

      Specified by:
      elements in interface Lattice
      Overrides:
      elements in class AbstractLattice
      Returns:
      the set of elements of this lattice.
    • one

      public Element one()
      Description copied from interface: Lattice
      Return the one of this lattice.

      Note that there is no guarantee that the returned element is the only element representing one in this lattice. Other ones may arise from computations, but they will always be equal to the element returned by this method.

      Returns:
      the one of this lattice.
    • zero

      public Element zero()
      Description copied from interface: Lattice
      Return the zero of this lattice.

      Note that there is no guarantee that the returned element is the only element representing zero in this lattice. Other zeroes may arise from computations, but they will always be equal to the element returned by this method.

      Returns:
      the zero of this lattice.
    • join

      public Element join​(Element... element)
      Description copied from interface: Lattice
      Return the join of the provided elements. In particular, upon the empty list of arguments returns zero, and upon a singleton list the only specified element.
      Parameters:
      element - the elements whose join has to be computed.
      Returns:
      the join of the provided elements.
    • meet

      public Element meet​(Element... element)
      Description copied from interface: Lattice
      Return the meet of the provided elements. In particular, upon the empty list of arguments returns one, and upon a singleton list the only specified element.
      Parameters:
      element - the elements whose meet has to be computed.
      Returns:
      the meet of the provided elements.
    • comp

      public boolean comp​(Element x, Element y)
      Description copied from class: AbstractLattice
      Check whether two elements are comparable using Lattice.meet(Element[]).
      Specified by:
      comp in interface Lattice
      Overrides:
      comp in class AbstractLattice
      Parameters:
      x - an element.
      y - another element.
      Returns:
      true iff x.meet(y) equals x or y.
    • leq

      public boolean leq​(Element x, Element y)
      Description copied from class: AbstractLattice
      Check whether an element is smaller than or equal to another element using Lattice.meet(Element[]).
      Specified by:
      leq in interface Lattice
      Overrides:
      leq in class AbstractLattice
      Parameters:
      x - an element.
      y - another element.
      Returns:
      true iff x.meet(y) equals x.
    • toString

      public String toString()
      Overrides:
      toString in class Object