Class IntervalAntichains
- All Implemented Interfaces:
Lattice
public class IntervalAntichains extends AbstractDistributiveLattice
Given an integer n, this class represents the lattice of interval antichains of the linear order { 0, 1, …, n − 1 }.
This lattice plays a prominent rôle in “An algebra for structured text search and a framework for its implementation”, by Charles L.A. Clarke, Gordon V. Cormack, and Forbes J. Burkowski, Comput. J., 38(1):43−56, 1995, where it is used to denote regions of text satisfying a query (albeit the authors do not remark that their lattice is actually an order-ideal completion). The algorithms used in this implementation are described in “Efficient lazy algorithms for minimal-interval semantics”, by Paolo Boldi and Sebastiano Vigna, Proc. SPIRE 2006, number 4209 in Lecture Notes in Computer Science, pages 134−149. Springer–Verlag, 2006, where a more mathematically oriented description of the lattice can be found.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IntervalAntichains.Antichain
A class representing elements of this lattice (antichains of intervals). -
Field Summary
Fields Modifier and Type Field Description int
n
Number of elements used to generate intervals. -
Constructor Summary
Constructors Constructor Description IntervalAntichains(int n)
-
Method Summary
Modifier and Type Method Description boolean
comp(Element x, Element y)
Return whether the two provided elements are comparable.Collection<Element>
elements()
Generate iteratively all elements of this lattice.Collection<Element>
generators()
Return a collection of generators for the lattice.IntervalAntichains.Antichain
join(Element... element)
Return the join of the provided elements.boolean
leq(Element x, Element y)
Return whether an element is less than or equal to another element in the natural order of this lattice.IntervalAntichains.Antichain
meet(Element... element)
Return the meet of the provided elements.IntervalAntichains.Antichain
one()
Return a singleton representing the zero of this lattice (the antichain formed by the empty interval).IntervalAntichains.Antichain
pscomp(Element x, Element y)
Enumerate all elements of this lattice to compute explicitly the pseudocomplement using the definition given inLattice.pscomp(Element, Element)
.IntervalAntichains.Antichain
psdiff(Element x, Element y)
Return an antichain equal to the first element from which all intervals containing some interval of the second element have been eliminated.IntervalAntichains.Antichain
symdiff(Element x, Element y)
Return the symmetric difference of the arguments, that is,psdiff(x,y).join(psdiff(y,x))
.IntervalAntichains.Antichain
valueOf(String name)
Parse an antichain, returning the corresponding element.IntervalAntichains.Antichain
zero()
Return a singleton representing the zero of this lattice (the empty antichain).Methods inherited from class it.unimi.dsi.lama4j.AbstractLattice
coveringRelation, ensureElementsInLattice, ensureElementsInLattice, ensureElementsInLattice, valueOfZeroOrOne
-
Field Details
-
n
public final int nNumber of elements used to generate intervals.
-
-
Constructor Details
-
IntervalAntichains
public IntervalAntichains(int n)
-
-
Method Details
-
meet
Description copied from interface:Lattice
Return the meet of the provided elements. In particular, upon the empty list of arguments returnsone
, 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.
-
join
Description copied from interface:Lattice
Return the join of the provided elements. In particular, upon the empty list of arguments returnszero
, 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.
-
generators
Description copied from interface:Lattice
Return a collection of generators for the lattice. The set will not includezero
orone
. There is no guarantee of freeness or minimality.- Returns:
- a collection of generators.
-
valueOf
Parse an antichain, returning the corresponding element.An interval is described (using Hoare's notation) by a pair of integers, separated by two dots and surrounded by square brackets. Thus,
[1..3]
denotes the interval containing the integers 1, 2, and 3. The shortcut[x]
can be used to denote the singleton interval containing x.An interval antichain is described by a list of intervals separated by commas. Of course, no interval in the list must contain another interval. Intervals can be in any order. For instance,
[1..3], [2..4], [0]
is a legal antichain.Spaces are not significative, but the two dots in an interval must be consecutive.
- Parameters:
name
- the description of an antichain.- Returns:
- the corresponding element of this lattice.
-
zero
Return a singleton representing the zero of this lattice (the empty antichain).The element returned by this method is a singleton: it has a single instance. All lattice scomputation methods will return this object when they have to return zero. As a consequence, it is possible to test for zero using
==
instead ofequals()
.- Returns:
- a singleton representing the zero of this lattice (the empty antichain).
-
one
Return a singleton representing the zero of this lattice (the antichain formed by the empty interval).The element returned by this method is a singleton: it has a single instance. All lattice computation methods will return this object when they have to return one. As a consequence, it is possible to test for one using
==
instead ofequals()
.- Returns:
- a singleton representing the zero of this lattice (the antichain formed by the empty interval).
-
comp
Return whether the two provided elements are comparable.- Specified by:
comp
in interfaceLattice
- Overrides:
comp
in classAbstractLattice
- Parameters:
x
- an element.y
- another element.- Returns:
- true if x ≤ y or y ≤ x, false otherwise.
-
leq
Return whether an element is less than or equal to another element in the natural order of this lattice.This implementation is based on a simple linear greedy algorithm that uses an explicit definition (an antichain A is smaller than or equal to an antichain B iff for every interval in A there is a corresponding smaller interval in B).
- Specified by:
leq
in interfaceLattice
- Overrides:
leq
in classAbstractLattice
- Parameters:
x
- an element.y
- another element.- Returns:
- true iff
x
≤y
.
-
psdiff
Return an antichain equal to the first element from which all intervals containing some interval of the second element have been eliminated.In the case of this lattice, the difference assumes the simple form above, and it can be easily computed with a linear greedy algorithm.
- Specified by:
psdiff
in interfaceLattice
- Overrides:
psdiff
in classAbstractLattice
- Parameters:
x
- an element.y
- another element.- Returns:
- an antichain equal to
x
with intervals containing some interval ofy
removed. - See Also:
Lattice.psdiff(Element, Element)
-
pscomp
Description copied from class:AbstractLattice
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
- Overrides:
pscomp
in classAbstractLattice
- Parameters:
x
- an element.y
- another element.- Returns:
x
⇒y
.- See Also:
Lattice.pscomp(Element, Element)
-
symdiff
Description copied from class:AbstractLattice
Return the symmetric difference of the arguments, that is,psdiff(x,y).join(psdiff(y,x))
.- Specified by:
symdiff
in interfaceLattice
- Overrides:
symdiff
in classAbstractLattice
- Parameters:
x
- an element.y
- another element.- Returns:
x
Δy
.- See Also:
Element.join(Element)
,Lattice.psdiff(Element, Element)
-
elements
Generate iteratively all elements of this lattice.This methods uses the CAT enumeration algorithm for interval antichains by Boldi and Vigna.
- Specified by:
elements
in interfaceLattice
- Overrides:
elements
in classAbstractLattice
- Returns:
- the set of elements of this lattice.
-