Class Flat

All Implemented Interfaces:
Lattice

public class Flat
extends AbstractLattice
A flat lattice: all elements are incomparable except for zero and one. Flat lattices are not distributive, unless they have less than five elements.

Nontrivial elements of a flat lattice with n elements are numbered from 0 to n − 3, causing an unfortunate clash between zero() (one()), which can be obtained as valueOf("0") (valueOf("1")), and the nontrivial element valueOf(0) (valueOf(1)).

  • Constructor Details

    • Flat

      public Flat​(int n, String... name)
      Create a flat lattice with named elements.
      Parameters:
      n - the number of elements in the lattice.
      name - names for the lattice elements.
    • Flat

      public Flat​(int n)
      Create a flat lattice.
      Parameters:
      n - the number of elements in the lattice.
  • Method Details

    • isDistributive

      public boolean isDistributive()
      Description copied from interface: Lattice
      Return true if this lattice is distributive.
      Specified by:
      isDistributive in interface Lattice
      Overrides:
      isDistributive in class AbstractLattice
      Returns:
      true if this lattice is distributive.
    • 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)
    • 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.