Lattices

The galactic.algebras.lattice module defines types for representing lattices.

Elements of semi-lattices and lattices:

Function on elements of semi-lattices and lattices:

Abstract classes of semi-lattices and lattices:

and their implementations:

class Joinable(*args, **kwargs)

Bases: PartiallyComparable, Protocol

It represents joinable elements.

This class sets for each pair of elements a, b a unique supremum \(c = a \vee b\) (also called a least upper bound or join).

Example

Let the integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?

>>> from galactic.algebras.examples.arithmetic import PrimeFactors
>>> PrimeFactors(24) | PrimeFactors(36)
PrimeFactors(72)
>>> PrimeFactors(24).join(PrimeFactors(36), PrimeFactors(10))
PrimeFactors(360)
abstract __or__(other)

Return the join of this element and the other.

Parameters:

other (Self) – the other element

Returns:

The join of this element and the other

Return type:

Self

Raises:

NotImplementedError

join(*others)

Return the supremum of this element and the others.

Parameters:

*others (Self) – The others elements

Returns:

The join of this element and the others

Return type:

Self

join_level(generators)

Compute the level of an element considering an iterable of generators.

Parameters:

generators (Iterable[Self]) – An iterable of generators.

Returns:

The level of the element.

Return type:

int

abstract __ge__(other)

Test if this element is greater than or equal to the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is greater than or equal to the other.

Return type:

bool

abstract __gt__(other)

Test if this element is greater than the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is greater than the other.

Return type:

bool

abstract __le__(other)

Test if this element is lesser than or equal to the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is lesser than or equal to the other.

Return type:

bool

abstract __lt__(other)

Test if this element is lesser than the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is lesser than the other.

Return type:

bool

class Meetable(*args, **kwargs)

Bases: PartiallyComparable, Protocol

It represents meetable elements.

This type sets for each pair of elements a, b a unique infimum \(c = a \wedge b\) (also called one of the greatest lower bound or meet).

Example

Let the integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?

>>> from galactic.algebras.examples.arithmetic import PrimeFactors
>>> PrimeFactors(24) & PrimeFactors(36)
PrimeFactors(12)
>>> PrimeFactors(24).meet(PrimeFactors(36), PrimeFactors(10))
PrimeFactors(2)
abstract __and__(other)

Return the meet of this element and the other.

Parameters:

other (Self) – the other element

Returns:

The meet of this element and the other

Return type:

Self

Raises:

NotImplementedError

meet(*others)

Return the infimum of this element and the others.

Parameters:

*others (Self) – The others elements

Returns:

The meet of this element and the others

Return type:

Self

meet_level(generators)

Compute the level of an element considering an iterable of generators.

Parameters:

generators (Iterable[Self]) – An iterable of generators.

Returns:

The level of the element.

Return type:

int

abstract __ge__(other)

Test if this element is greater than or equal to the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is greater than or equal to the other.

Return type:

bool

abstract __gt__(other)

Test if this element is greater than the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is greater than the other.

Return type:

bool

abstract __le__(other)

Test if this element is lesser than or equal to the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is lesser than or equal to the other.

Return type:

bool

abstract __lt__(other)

Test if this element is lesser than the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is lesser than the other.

Return type:

bool

class Element(*args, **kwargs)

Bases: Meetable, Joinable, Protocol

It represents elements that can be member of a lattice.

abstract __and__(other)

Return the meet of this element and the other.

Parameters:

other (Self) – the other element

Returns:

The meet of this element and the other

Return type:

Self

Raises:

NotImplementedError

abstract __ge__(other)

Test if this element is greater than or equal to the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is greater than or equal to the other.

Return type:

bool

abstract __gt__(other)

Test if this element is greater than the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is greater than the other.

Return type:

bool

abstract __le__(other)

Test if this element is lesser than or equal to the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is lesser than or equal to the other.

Return type:

bool

abstract __lt__(other)

Test if this element is lesser than the other.

Parameters:

other (Self) – the other element

Returns:

True if this element is lesser than the other.

Return type:

bool

abstract __or__(other)

Return the join of this element and the other.

Parameters:

other (Self) – the other element

Returns:

The join of this element and the other

Return type:

Self

Raises:

NotImplementedError

join(*others)

Return the supremum of this element and the others.

Parameters:

*others (Self) – The others elements

Returns:

The join of this element and the others

Return type:

Self

join_level(generators)

Compute the level of an element considering an iterable of generators.

Parameters:

generators (Iterable[Self]) – An iterable of generators.

Returns:

The level of the element.

Return type:

int

meet(*others)

Return the infimum of this element and the others.

Parameters:

*others (Self) – The others elements

Returns:

The meet of this element and the others

Return type:

Self

meet_level(generators)

Compute the level of an element considering an iterable of generators.

Parameters:

generators (Iterable[Self]) – An iterable of generators.

Returns:

The level of the element.

Return type:

int

infimum(iterable)

Compute the infimum of meetable elements.

Parameters:

iterable (Iterable[TypeVar(_M, bound= Meetable)]) – An iterable collection of meetable elements.

Returns:

The meet of all elements from the iterable collection.

Return type:

_M

Raises:

ValueError – If the iterable is empty.

infimum_generators(iterable)

Produce the infimum generators from the iterable of meetable elements.

Parameters:

iterable (Iterable[TypeVar(_M, bound= Meetable)]) – The iterable collection of elements.

Yields:

_M – An infimum generator.

Return type:

Iterator[TypeVar(_M, bound= Meetable)]

supremum(iterable)

Compute the supremum of joinable elements.

Parameters:

iterable (Iterable[TypeVar(_J, bound= Joinable)]) – An iterable collection of joinable elements.

Returns:

The supremum of all elements from the iterable collection.

Return type:

_J

Raises:

ValueError – If the iterable is empty.

supremum_generators(iterable)

Produce the supremum generators from the iterable of joinable elements.

Parameters:

iterable (Iterable[TypeVar(_J, bound= Joinable)]) – The iterable collection of elements.

Yields:

_J – A supremum generator.

Return type:

Iterator[TypeVar(_J, bound= Joinable)]

class AbstractFiniteJoinSemiLattice(*args, **kwargs)

Bases: AbstractFinitePartiallyOrderedSet[_J], Protocol

It describes finite join semi-lattices.

abstract property co_atoms: Collection[_J]

Get the co-atoms of this join semi-lattice.

Return type:

The co-atoms.

abstract property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

Get the join irreducible elements.

Return type:

The join irreducible elements.

abstract greatest_join_irreducible(limit)

Get the greatest join irreducible smaller than a limit.

Parameters:

limit (TypeVar(_J, bound= Joinable)) – The limit whose greatest join irreducible are requested.

Returns:

The greatest join irreducible smaller than the limit.

Return type:

Collection[_J]

Raises:

NotImplementedError

abstract property bottom: Collection[_P]

Get the bottom elements.

Return type:

The bottom elements.

abstract property cover: AbstractFiniteCoveringRelation[_P]

Get the covering relation of this poset.

Return type:

The covering relation.

abstract filter(element)

Get a filter of a poset.

Parameters:

element (TypeVar(_P, bound= PartiallyComparable)) – The lower limit

Returns:

A view on the lower bounded poset.

Return type:

AbstractFinitePartiallyOrderedSet[_P]

Raises:

ValueError – If the element does not belong to the poset.

Notes

Unpredictable behavior can occur if the lower bound is no longer part of the original poset.

abstract ideal(element)

Get an ideal of the poset.

Parameters:

element (TypeVar(_P, bound= PartiallyComparable)) – The upper limit

Returns:

A view on the upper bounded set.

Return type:

AbstractFinitePartiallyOrderedSet[_P]

Raises:

ValueError – If the element does not belong to the poset.

Notes

Unpredictable behavior can occur if the upper bound is no longer part of the original poset.

abstract isdisjoint(other)

Test if the poset is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is disjoint from the other.

Return type:

bool

abstract issubset(other)

Test whether every element in the poset is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is a subset of the other.

Return type:

bool

abstract issuperset(other)

Test whether every element in the other is in the poset.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is a superset of the other.

Return type:

bool

abstract lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

abstract property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

abstract property order: AbstractFinitePartialOrder[_P]

Get the partial order of this poset.

Return type:

The partial order.

abstract property top: Collection[_P]

Get the top elements.

Return type:

The top elements.

abstract upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property version: int

Get the poset version.

Return type:

The poset version.

Notes

This can be used to detect a change in the poset.

class AbstractFiniteMeetSemiLattice(*args, **kwargs)

Bases: AbstractFinitePartiallyOrderedSet[_M], Protocol

It describes finite meet semi-lattices.

abstract property atoms: Collection[_M]

Get the atoms of this meet semi-lattice.

Return type:

The atoms.

abstract property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]

Get the meet irreducible elements.

Return type:

The meet irreducible elements.

abstract smallest_meet_irreducible(limit)

Get the smallest meet irreducible greater than a limit.

Parameters:

limit (TypeVar(_M, bound= Meetable)) – The limit whose smallest meet irreducible are requested.

Returns:

The smallest meet irreducible greater than the limit.

Return type:

Collection[_M]

Raises:

NotImplementedError

abstract property bottom: Collection[_P]

Get the bottom elements.

Return type:

The bottom elements.

abstract property cover: AbstractFiniteCoveringRelation[_P]

Get the covering relation of this poset.

Return type:

The covering relation.

abstract filter(element)

Get a filter of a poset.

Parameters:

element (TypeVar(_P, bound= PartiallyComparable)) – The lower limit

Returns:

A view on the lower bounded poset.

Return type:

AbstractFinitePartiallyOrderedSet[_P]

Raises:

ValueError – If the element does not belong to the poset.

Notes

Unpredictable behavior can occur if the lower bound is no longer part of the original poset.

abstract ideal(element)

Get an ideal of the poset.

Parameters:

element (TypeVar(_P, bound= PartiallyComparable)) – The upper limit

Returns:

A view on the upper bounded set.

Return type:

AbstractFinitePartiallyOrderedSet[_P]

Raises:

ValueError – If the element does not belong to the poset.

Notes

Unpredictable behavior can occur if the upper bound is no longer part of the original poset.

abstract isdisjoint(other)

Test if the poset is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is disjoint from the other.

Return type:

bool

abstract issubset(other)

Test whether every element in the poset is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is a subset of the other.

Return type:

bool

abstract issuperset(other)

Test whether every element in the other is in the poset.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is a superset of the other.

Return type:

bool

abstract lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

abstract property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

abstract property order: AbstractFinitePartialOrder[_P]

Get the partial order of this poset.

Return type:

The partial order.

abstract property top: Collection[_P]

Get the top elements.

Return type:

The top elements.

abstract upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property version: int

Get the poset version.

Return type:

The poset version.

Notes

This can be used to detect a change in the poset.

class AbstractFiniteLattice(*args, **kwargs)

Bases: AbstractFiniteJoinSemiLattice[_E], AbstractFiniteMeetSemiLattice[_E], Protocol

It represents finite lattices.

abstract property reduced_context: AbstractFiniteBinaryRelation[_E, _E]

Get the reduced context from this lattice.

Returns:

The reduced context.

Return type:

AbstractFiniteBinaryRelation[_E, _E]

Raises:

NotImplementedError

abstract property atoms: Collection[_M]

Get the atoms of this meet semi-lattice.

Return type:

The atoms.

abstract property bottom: Collection[_P]

Get the bottom elements.

Return type:

The bottom elements.

abstract property co_atoms: Collection[_J]

Get the co-atoms of this join semi-lattice.

Return type:

The co-atoms.

abstract property cover: AbstractFiniteCoveringRelation[_P]

Get the covering relation of this poset.

Return type:

The covering relation.

abstract filter(element)

Get a filter of a poset.

Parameters:

element (TypeVar(_P, bound= PartiallyComparable)) – The lower limit

Returns:

A view on the lower bounded poset.

Return type:

AbstractFinitePartiallyOrderedSet[_P]

Raises:

ValueError – If the element does not belong to the poset.

Notes

Unpredictable behavior can occur if the lower bound is no longer part of the original poset.

abstract greatest_join_irreducible(limit)

Get the greatest join irreducible smaller than a limit.

Parameters:

limit (TypeVar(_J, bound= Joinable)) – The limit whose greatest join irreducible are requested.

Returns:

The greatest join irreducible smaller than the limit.

Return type:

Collection[_J]

Raises:

NotImplementedError

abstract ideal(element)

Get an ideal of the poset.

Parameters:

element (TypeVar(_P, bound= PartiallyComparable)) – The upper limit

Returns:

A view on the upper bounded set.

Return type:

AbstractFinitePartiallyOrderedSet[_P]

Raises:

ValueError – If the element does not belong to the poset.

Notes

Unpredictable behavior can occur if the upper bound is no longer part of the original poset.

abstract isdisjoint(other)

Test if the poset is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is disjoint from the other.

Return type:

bool

abstract issubset(other)

Test whether every element in the poset is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is a subset of the other.

Return type:

bool

abstract issuperset(other)

Test whether every element in the other is in the poset.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of values.

Returns:

True if the poset is a superset of the other.

Return type:

bool

abstract property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

Get the join irreducible elements.

Return type:

The join irreducible elements.

abstract lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

abstract property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]

Get the meet irreducible elements.

Return type:

The meet irreducible elements.

abstract property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

abstract property order: AbstractFinitePartialOrder[_P]

Get the partial order of this poset.

Return type:

The partial order.

abstract smallest_meet_irreducible(limit)

Get the smallest meet irreducible greater than a limit.

Parameters:

limit (TypeVar(_M, bound= Meetable)) – The limit whose smallest meet irreducible are requested.

Returns:

The smallest meet irreducible greater than the limit.

Return type:

Collection[_M]

Raises:

NotImplementedError

abstract property top: Collection[_P]

Get the top elements.

Return type:

The top elements.

abstract upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property version: int

Get the poset version.

Return type:

The poset version.

Notes

This can be used to detect a change in the poset.

class FrozenFiniteJoinSemiLattice(*others, elements=None)

Bases: FiniteJoinSemiLatticeMixin[_J]

It represents concrete finite join semi-lattice.

An instance stores its irreducible in a poset.

Its memory complexity is in \(O(j)\)

Parameters:

Example

>>> from galactic.algebras.lattice import ExtensibleFiniteJoinSemiLattice
>>> from galactic.algebras.examples.arithmetic import PrimeFactors
>>> semi_lattice = ExtensibleFiniteJoinSemiLattice[PrimeFactors](
...     elements = [
...         PrimeFactors(2*3*5),
...         PrimeFactors(3*5*7),
...         PrimeFactors(5*7*11)
...     ]
... )
>>>

It’s possible to get the maximum element.

Example

>>> int(semi_lattice.maximum)
2310

It’s possible to iterate over the elements.

Example

>>> sorted(list(map(int, semi_lattice)))
[30, 105, 210, 385, 1155, 2310]

It’s possible to iterate over the co-atoms.

Example

>>> sorted(list(map(int, semi_lattice.co_atoms)))
[210, 1155]

It’s possible to iterate over the join irreducible.

Example

>>> sorted(list(map(int, semi_lattice.join_irreducible)))
[30, 105, 385]

It’s possible to iterate over the greatest join irreducible smaller than a limit.

Example

>>> sorted(
...     list(
...         map(
...             int,
...             semi_lattice.greatest_join_irreducible(PrimeFactors(2*3*5*7))
...         )
...     )
... )
[30, 105]

It’s possible to enlarge a join semi-lattice.

Example

>>> semi_lattice.extend([PrimeFactors(13)])
>>> sorted(list(map(int, semi_lattice)))
[13, 30, 105, 210, 385, 390, 1155, 1365, 2310, 2730, 5005, 15015, 30030]
property version: int

Get the version number.

Return type:

The version number.

Notes

This can be used to detect a change in the semi-lattice.

copy()

Get a copy of the join semi-lattice.

Return type:

Self

Returns:

The copy of this join semi-lattice.

property order: AbstractFinitePartialOrder[_J]

Get the partial order of this join semi-lattice.

Return type:

The partial order.

property cover: AbstractFiniteCoveringRelation[_J]

Get the covering relation of this join semi-lattice.

Return type:

The covering relation.

greatest_join_irreducible(limit, strict=False)

Get the greatest join irreducible smaller than a limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit whose greatest join irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The greatest join irreducible smaller than the limit.

Return type:

Collection[_J]

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_J]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

property top: Collection[_J]

Get the top elements.

The collection contains only one element, the maximum element.

Return type:

The top elements.

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_J]

property bottom: Collection[_J]

Get the bottom elements.

Return type:

The bottom elements.

filter(element)

Get a filter of a join semi-lattice.

Parameters:

element (TypeVar(_J, bound= Joinable)) – The lower limit.

Returns:

A view on the lower bounded join semi-lattice.

Return type:

AbstractFiniteJoinSemiLattice[_J]

Raises:

ValueError – If the element does not belong to the join semi-lattice.

ideal(element)

Get an ideal of a join semi-lattice.

Parameters:

element (TypeVar(_J, bound= Joinable)) – The upper limit.

Returns:

A view on the upper bounded join semi-lattice.

Return type:

AbstractFiniteJoinSemiLattice[_J]

Raises:

ValueError – If the element does not belong to the join semi-lattice.

property co_atoms: Collection[_J]

Get the co-atoms of this join semi-lattice.

Return type:

The co-atoms.

property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

Get the join-irreducible elements of this join semi-lattice.

Return type:

The join-irreducible elements.

class FrozenFiniteMeetSemiLattice(*others, elements=None)

Bases: FiniteMeetSemiLatticeMixin[_M]

It represents concrete finite meet semi-lattice.

An instance stores its irreducible in a poset.

Its memory complexity is in \(O(j)\)

Parameters:

Example

>>> from galactic.algebras.lattice import ExtensibleFiniteMeetSemiLattice
>>> from galactic.algebras.examples.arithmetic import PrimeFactors
>>> semi_lattice = ExtensibleFiniteMeetSemiLattice[PrimeFactors](
...     elements = [
...         PrimeFactors(2*3*5),
...         PrimeFactors(3*5*7),
...         PrimeFactors(5*7*11)
...     ]
... )
>>>

It’s possible to get the maximum element.

Example

>>> int(semi_lattice.minimum)
5

It’s possible to iterate over the elements.

Example

>>> sorted(list(map(int, semi_lattice)))
[5, 15, 30, 35, 105, 385]

It’s possible to iterate over the atoms.

Example

>>> sorted(list(map(int, semi_lattice.atoms)))
[15, 35]

It’s possible to iterate over the meet irreducible.

Example

>>> sorted(list(map(int, semi_lattice.meet_irreducible)))
[30, 105, 385]

It’s possible to iterate over the smallest meet irreducible greater than a limit.

Example

>>> sorted(
...     list(
...         map(
...             int,
...             semi_lattice.smallest_meet_irreducible(PrimeFactors(7))
...         )
...     )
... )
[105, 385]

It’s possible to enlarge a meet semi-lattice.

Example

>>> semi_lattice.extend([PrimeFactors(13)])
>>> sorted(list(map(int, semi_lattice)))
[1, 5, 13, 15, 30, 35, 105, 385]
property version: int

Get the version number.

Return type:

The version number.

Notes

This can be used to detect a change in the semi-lattice.

copy()

Get a copy of the meet semi-lattice.

Return type:

Self

Returns:

The copy of this meet semi-lattice.

property order: AbstractFinitePartialOrder[_M]

Get the partial order of this meet semi-lattice.

Return type:

The partial order.

property cover: AbstractFiniteCoveringRelation[_M]

Get the covering relation of this meet semi-lattice.

Return type:

The covering relation.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_M]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

smallest_meet_irreducible(limit, strict=False)

Get the smallest meet irreducible greater than a limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit whose smallest meet irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The smallest meet irreducible greater than the limit.

Return type:

Collection[_M]

property top: Collection[_M]

Get the top elements.

The collection contains only one element, the maximum element.

Return type:

The top elements.

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_M]

property bottom: Collection[_M]

Get the bottom elements.

Return type:

The bottom elements.

filter(element)

Get a filter of a meet semi-lattice.

Parameters:

element (TypeVar(_M, bound= Meetable)) – The lower limit.

Returns:

A view on the lower bounded meet semi-lattice.

Return type:

AbstractFiniteMeetSemiLattice[_M]

Raises:

ValueError – If the element does not belong to the meet semi-lattice.

ideal(element)

Get an ideal of a meet semi-lattice.

Parameters:

element (TypeVar(_M, bound= Meetable)) – The upper limit.

Returns:

A view on the upper bounded meet semi-lattice.

Return type:

AbstractFiniteMeetSemiLattice[_M]

Raises:

ValueError – If the element does not belong to the meet semi-lattice.

property atoms: Collection[_M]

Get the atoms of this meet semi-lattice.

Returns:

The atoms.

Return type:

Collection[_M]

property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]

Get the meet-irreducible elements of this meet semi-lattice.

Returns:

The meet-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_M]

class FrozenFiniteLattice(*others, elements=None)

Bases: FiniteLatticeMixin[_E]

It represents frozen finite lattices.

Parameters:
property version: int

Get the version number.

Returns:

The version number

Return type:

int

copy()

Get a copy of the lattice.

Return type:

Self

Returns:

The copy of this lattice.

property order: AbstractFinitePartialOrder[_E]

Get the partial order of this lattice.

Return type:

The partial order.

property cover: AbstractFiniteCoveringRelation[_E]

Get the covering relation of this lattice.

Return type:

The covering relation.

property top: Collection[_E]

Get the top elements.

Return type:

The top elements.

property bottom: Collection[_E]

Get the bottom elements.

Return type:

The bottom elements.

filter(element)

Get a filter of a lattice.

Parameters:

element (TypeVar(_E, bound= Element)) – The lower limit.

Returns:

A view on the bounded lattice.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

Raises:

ValueError – If the element does not belong to the lattice.

property atoms: Collection[_E]

Get the atoms of this lattice.

Return type:

The atoms.

property co_atoms: Collection[_E]

Get the co-atoms of this lattice.

Return type:

The co-atoms.

greatest_join_irreducible(limit, strict=False)

Get the greatest join irreducible smaller than a limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit whose greatest join irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The greatest join irreducible smaller than the limit.

Return type:

Collection[_J]

ideal(element)

Get an ideal of a lattice.

Parameters:

element (TypeVar(_E, bound= Element)) – The upper limit.

Returns:

A view on the bounded lattice.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

Raises:

ValueError – If the element does not belong to the lattice.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_E, bound= Element)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_E]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

smallest_meet_irreducible(limit, strict=False)

Get the smallest meet irreducible greater than a limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit whose smallest meet irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The smallest meet irreducible greater than the limit.

Return type:

Collection[_M]

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_E, bound= Element)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_E]

property meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the meet-irreducible elements of this lattice.

Return type:

The meet-irreducible elements.

property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the join-irreducible elements of this lattice.

Return type:

The join-irreducible elements.

property reduced_context: AbstractFiniteBinaryRelation[_E, _E]

Get the reduced context from this lattice.

Returns:

The reduced context.

Return type:

AbstractFiniteBinaryRelation[_E, _E]

class ExtensibleFiniteJoinSemiLattice(*others, elements=None)

Bases: FrozenFiniteJoinSemiLattice[_J]

It represents extensible join finite semi-lattices.

property bottom: Collection[_J]

Get the bottom elements.

Return type:

The bottom elements.

property co_atoms: Collection[_J]

Get the co-atoms of this join semi-lattice.

Return type:

The co-atoms.

copy()

Get a copy of the join semi-lattice.

Return type:

Self

Returns:

The copy of this join semi-lattice.

property cover: AbstractFiniteCoveringRelation[_J]

Get the covering relation of this join semi-lattice.

Return type:

The covering relation.

filter(element)

Get a filter of a join semi-lattice.

Parameters:

element (TypeVar(_J, bound= Joinable)) – The lower limit.

Returns:

A view on the lower bounded join semi-lattice.

Return type:

AbstractFiniteJoinSemiLattice[_J]

Raises:

ValueError – If the element does not belong to the join semi-lattice.

greatest_join_irreducible(limit, strict=False)

Get the greatest join irreducible smaller than a limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit whose greatest join irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The greatest join irreducible smaller than the limit.

Return type:

Collection[_J]

ideal(element)

Get an ideal of a join semi-lattice.

Parameters:

element (TypeVar(_J, bound= Joinable)) – The upper limit.

Returns:

A view on the upper bounded join semi-lattice.

Return type:

AbstractFiniteJoinSemiLattice[_J]

Raises:

ValueError – If the element does not belong to the join semi-lattice.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

Get the join-irreducible elements of this join semi-lattice.

Return type:

The join-irreducible elements.

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_J]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

property order: AbstractFinitePartialOrder[_J]

Get the partial order of this join semi-lattice.

Return type:

The partial order.

property top: Collection[_J]

Get the top elements.

The collection contains only one element, the maximum element.

Return type:

The top elements.

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_J]

property version: int

Get the version number.

Return type:

The version number.

Notes

This can be used to detect a change in the semi-lattice.

extend(iterable)

Extend this join semi-lattice.

Parameters:

iterable (Iterable[TypeVar(_J, bound= Joinable)]) – An iterable of values.

Return type:

None

class ExtensibleFiniteMeetSemiLattice(*others, elements=None)

Bases: FrozenFiniteMeetSemiLattice[_M]

It represents extensible meet finite semi-lattices.

property atoms: Collection[_M]

Get the atoms of this meet semi-lattice.

Returns:

The atoms.

Return type:

Collection[_M]

property bottom: Collection[_M]

Get the bottom elements.

Return type:

The bottom elements.

copy()

Get a copy of the meet semi-lattice.

Return type:

Self

Returns:

The copy of this meet semi-lattice.

property cover: AbstractFiniteCoveringRelation[_M]

Get the covering relation of this meet semi-lattice.

Return type:

The covering relation.

filter(element)

Get a filter of a meet semi-lattice.

Parameters:

element (TypeVar(_M, bound= Meetable)) – The lower limit.

Returns:

A view on the lower bounded meet semi-lattice.

Return type:

AbstractFiniteMeetSemiLattice[_M]

Raises:

ValueError – If the element does not belong to the meet semi-lattice.

ideal(element)

Get an ideal of a meet semi-lattice.

Parameters:

element (TypeVar(_M, bound= Meetable)) – The upper limit.

Returns:

A view on the upper bounded meet semi-lattice.

Return type:

AbstractFiniteMeetSemiLattice[_M]

Raises:

ValueError – If the element does not belong to the meet semi-lattice.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_M]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]

Get the meet-irreducible elements of this meet semi-lattice.

Returns:

The meet-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_M]

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

property order: AbstractFinitePartialOrder[_M]

Get the partial order of this meet semi-lattice.

Return type:

The partial order.

smallest_meet_irreducible(limit, strict=False)

Get the smallest meet irreducible greater than a limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit whose smallest meet irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The smallest meet irreducible greater than the limit.

Return type:

Collection[_M]

property top: Collection[_M]

Get the top elements.

The collection contains only one element, the maximum element.

Return type:

The top elements.

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_M]

property version: int

Get the version number.

Return type:

The version number.

Notes

This can be used to detect a change in the semi-lattice.

extend(iterable)

Extend this meet semi-lattice.

Parameters:

iterable (Iterable[TypeVar(_M, bound= Meetable)]) – An iterable of values.

Return type:

None

class ExtensibleFiniteLattice(*others, elements=None)

Bases: FrozenFiniteLattice[_E]

It represents extensible finite lattices.

It uses its join irreducible and meet irreducible elements.

The elements of this can be iterated from the maximum element to the minimum element or from the minimum element to the maximum element using the reversed() built-in function. It is not guaranteed that the order will be exactly the reverse order, but it is guaranteed that an element will always be iterated before its successors.

Example

Let the integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?

implemented by the PrimeFactors class:

>>> from galactic.algebras.examples.arithmetic import PrimeFactors
>>> from galactic.algebras.lattice import ExtensibleFiniteLattice
>>> lattice = ExtensibleFiniteLattice[PrimeFactors](
...     elements=[PrimeFactors(2), PrimeFactors(3)]
... )
>>> list(map(int, lattice))
[6, 2, 3, 1]
property atoms: Collection[_E]

Get the atoms of this lattice.

Return type:

The atoms.

property bottom: Collection[_E]

Get the bottom elements.

Return type:

The bottom elements.

property co_atoms: Collection[_E]

Get the co-atoms of this lattice.

Return type:

The co-atoms.

copy()

Get a copy of the lattice.

Return type:

Self

Returns:

The copy of this lattice.

property cover: AbstractFiniteCoveringRelation[_E]

Get the covering relation of this lattice.

Return type:

The covering relation.

filter(element)

Get a filter of a lattice.

Parameters:

element (TypeVar(_E, bound= Element)) – The lower limit.

Returns:

A view on the bounded lattice.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

Raises:

ValueError – If the element does not belong to the lattice.

greatest_join_irreducible(limit, strict=False)

Get the greatest join irreducible smaller than a limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit whose greatest join irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The greatest join irreducible smaller than the limit.

Return type:

Collection[_J]

ideal(element)

Get an ideal of a lattice.

Parameters:

element (TypeVar(_E, bound= Element)) – The upper limit.

Returns:

A view on the bounded lattice.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

Raises:

ValueError – If the element does not belong to the lattice.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the join-irreducible elements of this lattice.

Return type:

The join-irreducible elements.

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_E, bound= Element)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_E]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the meet-irreducible elements of this lattice.

Return type:

The meet-irreducible elements.

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

property order: AbstractFinitePartialOrder[_E]

Get the partial order of this lattice.

Return type:

The partial order.

property reduced_context: AbstractFiniteBinaryRelation[_E, _E]

Get the reduced context from this lattice.

Returns:

The reduced context.

Return type:

AbstractFiniteBinaryRelation[_E, _E]

smallest_meet_irreducible(limit, strict=False)

Get the smallest meet irreducible greater than a limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit whose smallest meet irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The smallest meet irreducible greater than the limit.

Return type:

Collection[_M]

property top: Collection[_E]

Get the top elements.

Return type:

The top elements.

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_E, bound= Element)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_E]

property version: int

Get the version number.

Returns:

The version number

Return type:

int

extend(iterable)

Extend this lattice.

Parameters:

iterable (Iterable[TypeVar(_E, bound= Element)]) – An iterable of values.

Return type:

None

class FiniteJoinSemiLatticeView(semi_lattice, lower=None, upper=None)

Bases: FiniteJoinSemiLatticeMixin[_J]

It represents bounded finite join semi-lattice.

Parameters:
greatest_join_irreducible(limit, strict=False)

Get the greatest join irreducible smaller than a limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit whose greatest join irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The greatest join irreducible smaller than the limit.

Return type:

Collection[_J]

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_J]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_J]

property version: int

Get the version number.

Return type:

The version number.

Notes

This can be used to detect a change in the semi-lattice.

property order: AbstractFinitePartialOrder[_J]

Get the partial order of this join semi-lattice.

Return type:

The partial order.

property cover: AbstractFiniteCoveringRelation[_J]

Get the covering relation of this join semi-lattice.

Return type:

The covering relation.

property top: Collection[_J]

Get the top elements.

The collection contains only one element, the maximum element.

Return type:

The top elements.

property bottom: Collection[_J]

Get the bottom elements.

Return type:

The bottom elements.

filter(element)

Get a filter of a join semi-lattice.

Parameters:

element (TypeVar(_J, bound= Joinable)) – The lower limit.

Returns:

A view on the bounded semi-lattice.

Return type:

AbstractFiniteJoinSemiLattice[_J]

Raises:

ValueError – If the element does not belong to the join semi-lattice.

ideal(element)

Get an ideal of a join semi-lattice.

Parameters:

element (TypeVar(_J, bound= Joinable)) – The upper limit.

Returns:

A view on the bounded semi-lattice.

Return type:

AbstractFiniteJoinSemiLattice[_J]

Raises:

ValueError – If the element does not belong to the join semi-lattice.

property co_atoms: Collection[_J]

Get the co-atoms of this join semi-lattice.

Return type:

The co-atoms.

property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

Get the join-irreducible elements of this join semi-lattice.

Return type:

The join-irreducible elements.

class FiniteMeetSemiLatticeView(semi_lattice, lower=None, upper=None)

Bases: FiniteMeetSemiLatticeMixin[_M]

It represents bounded finite meet semi-lattice.

Parameters:
isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_M]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

smallest_meet_irreducible(limit, strict=False)

Get the smallest meet irreducible greater than a limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit whose smallest meet irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The smallest meet irreducible greater than the limit.

Return type:

Collection[_M]

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_M]

property version: int

Get the version number.

Return type:

The version number.

Notes

This can be used to detect a change in the semi-lattice.

property order: AbstractFinitePartialOrder[_M]

Get the partial order of this meet semi-lattice.

Return type:

The partial order.

property cover: AbstractFiniteCoveringRelation[_M]

Get the covering relation of this meet semi-lattice.

Return type:

The covering relation.

property top: Collection[_M]

Get the top elements.

Return type:

The top elements.

property bottom: Collection[_M]

Get the bottom elements.

Return type:

The bottom elements.

filter(element)

Get a filter of a meet semi-lattice.

Parameters:

element (TypeVar(_M, bound= Meetable)) – The lower limit.

Returns:

A view on the bounded semi-lattice.

Return type:

AbstractFiniteMeetSemiLattice[_M]

Raises:

ValueError – If the element does not belong to the meet semi-lattice.

ideal(element)

Get an ideal of a meet semi-lattice.

Parameters:

element (TypeVar(_M, bound= Meetable)) – The upper limit.

Returns:

A view on the bounded semi-lattice.

Return type:

AbstractFiniteMeetSemiLattice[_M]

Raises:

ValueError – If the element does not belong to the meet semi-lattice.

property atoms: Collection[_M]

Get the atoms of this meet semi-lattice.

Return type:

The atoms.

property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]

Get the meet-irreducible elements of this meet semi-lattice.

Return type:

The meet-irreducible elements.

class FiniteLatticeView(lattice, lower=None, upper=None)

Bases: FiniteLatticeMixin[_E]

It represents a view of a lattice using ideal or filter construction.

Parameters:
greatest_join_irreducible(limit, strict=False)

Get the greatest join irreducible smaller than a limit.

Parameters:
  • limit (TypeVar(_J, bound= Joinable)) – The limit whose greatest join irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The greatest join irreducible smaller than the limit.

Return type:

Collection[_J]

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is disjoint from the other.

Return type:

bool

issubset(other)

Test whether every element in the relation is in other.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a subset of the other.

Return type:

bool

issuperset(other)

Test whether every element in the other relation is in the relation.

Parameters:

other (Iterable[TypeVar(_P, bound= PartiallyComparable)]) – An iterable of couples.

Returns:

True if the relation is a superset of the other.

Return type:

bool

lower_limit(limit, strict=False)

Get the values greater than the limit.

Parameters:
  • limit (TypeVar(_E, bound= Element)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

A collection of values.

Return type:

Collection[_E]

property maximum: _P | None

Get the maximum element if any.

Return type:

The maximum element.

property minimum: _P | None

Get the minimum element if any.

Return type:

The minimum element.

smallest_meet_irreducible(limit, strict=False)

Get the smallest meet irreducible greater than a limit.

Parameters:
  • limit (TypeVar(_M, bound= Meetable)) – The limit whose smallest meet irreducible are requested.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

The smallest meet irreducible greater than the limit.

Return type:

Collection[_M]

upper_limit(limit, strict=False)

Get the values less than the limit.

Parameters:
  • limit (TypeVar(_E, bound= Element)) – The limit.

  • strict (bool, default: False) – Is the comparison strict?

Returns:

Values which are less than the limit.

Return type:

Collection[_E]

property version: int

Get the version number.

Return type:

The version number.

Notes

This can be used to detect a change in the lattice.

property order: AbstractFinitePartialOrder[_E]

Get the partial order of this lattice.

Return type:

The partial order.

property cover: AbstractFiniteCoveringRelation[_E]

Get the covering relation of this lattice.

Return type:

The covering relation.

property top: Collection[_E]

Get the top elements.

Return type:

The top elements.

property bottom: Collection[_E]

Get the bottom elements.

Return type:

The bottom elements.

filter(element)

Get a filter of a lattice.

Parameters:

element (TypeVar(_E, bound= Element)) – The lower limit.

Returns:

A view on the bounded lattice.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

Raises:

ValueError – If the element does not belong to the lattice.

ideal(element)

Get an ideal of a lattice.

Parameters:

element (TypeVar(_E, bound= Element)) – The upper limit.

Returns:

A view on the bounded lattice.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

Raises:

ValueError – If the element does not belong to the lattice.

property atoms: Collection[_E]

Get the atoms of this lattice.

Return type:

The atoms.

property meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the meet-irreducible elements of this lattice.

Return type:

The meet-irreducible elements.

property co_atoms: Collection[_E]

Get the co-atoms of this lattice.

Return type:

The co-atoms.

property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the join-irreducible elements of this lattice.

Return type:

The join-irreducible elements.

property reduced_context: AbstractFiniteBinaryRelation[_E, _E]

Get the reduced context from this lattice.

Returns:

The reduced context.

Return type:

AbstractFiniteBinaryRelation[_E, _E]