Lattices

Classes and functions

The galactic.algebras.lattice module.

It 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

Mixin classes of semi-lattices and lattices

Concrete classes of semi-lattices and lattices

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

join_priority(generators)

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

Parameters:

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

Returns:

The priority.

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

meet_priority(generators)

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

Parameters:

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

Returns:

The priority.

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

join_priority(generators)

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

Parameters:

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

Returns:

The priority.

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

meet_priority(generators)

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

Parameters:

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

Returns:

The priority.

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], Collection[_J], Protocol

It describes finite join semi-lattices.

abstract property co_atoms: Collection[_J]

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

Returns:

The co-atoms.

Return type:

Collection[_J]

abstract property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

Get the join irreducible elements.

Returns:

The join irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_J]

abstract floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

Raises:

NotImplementedError

abstract greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than the limits.

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

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

Returns:

The greatest join irreducible smaller than the limits.

Return type:

Collection[_J]

Raises:

NotImplementedError

abstract property bottom: Collection[_P]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_P]

abstract property cover: AbstractFiniteCoveringRelation[_P]

Get the covering relation of this poset.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_P]

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(*limits, strict=False)

Get the values greater than the limits.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property maximum: _P | None

Get the maximum element if any.

Returns:

The maximum element.

Return type:

_P | None

abstract property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

abstract property order: AbstractFinitePartialOrder[_P]

Get the partial order of this poset.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_P]

abstract property top: Collection[_P]

Get the top elements.

Returns:

The top elements.

Return type:

Collection[_P]

abstract upper_limit(*limits, strict=False)

Get the values less than the limits.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property version: int

Get the poset version.

Returns:

The poset version.

Return type:

int

Notes

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

class AbstractFiniteMeetSemiLattice(*args, **kwargs)

Bases: AbstractFinitePartiallyOrderedSet[_M], Collection[_M], Protocol

It describes finite meet semi-lattices.

abstract property atoms: Collection[_M]

Get the atoms of this meet semi-lattice.

Returns:

The atoms.

Return type:

Collection[_M]

abstract property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]

Get the meet irreducible elements.

Returns:

The meet irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_M]

abstract ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

Raises:

NotImplementedError

abstract smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than the limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

Raises:

NotImplementedError

abstract property bottom: Collection[_P]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_P]

abstract property cover: AbstractFiniteCoveringRelation[_P]

Get the covering relation of this poset.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_P]

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(*limits, strict=False)

Get the values greater than the limits.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property maximum: _P | None

Get the maximum element if any.

Returns:

The maximum element.

Return type:

_P | None

abstract property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

abstract property order: AbstractFinitePartialOrder[_P]

Get the partial order of this poset.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_P]

abstract property top: Collection[_P]

Get the top elements.

Returns:

The top elements.

Return type:

Collection[_P]

abstract upper_limit(*limits, strict=False)

Get the values less than the limits.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property version: int

Get the poset version.

Returns:

The poset version.

Return type:

int

Notes

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

class AbstractFiniteLattice(*args, **kwargs)

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

It represents finite lattices.

abstract interval(*limits)

Get the interval of limits.

Parameters:

*limits (TypeVar(_E, bound= Element)) – The limits whose interval is requested

Returns:

The interval of the limits.

Return type:

tuple[_E | None, _E | None]

Raises:

NotImplementedError

abstract property atoms: Collection[_M]

Get the atoms of this meet semi-lattice.

Returns:

The atoms.

Return type:

Collection[_M]

abstract property bottom: Collection[_P]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_P]

abstract ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

Raises:

NotImplementedError

abstract property co_atoms: Collection[_J]

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

Returns:

The co-atoms.

Return type:

Collection[_J]

abstract property cover: AbstractFiniteCoveringRelation[_P]

Get the covering relation of this poset.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_P]

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 floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

Raises:

NotImplementedError

abstract greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than the limits.

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

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

Returns:

The greatest join irreducible smaller than the limits.

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.

Returns:

The join irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_J]

abstract lower_limit(*limits, strict=False)

Get the values greater than the limits.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property maximum: _P | None

Get the maximum element if any.

Returns:

The maximum element.

Return type:

_P | None

abstract property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]

Get the meet irreducible elements.

Returns:

The meet irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_M]

abstract property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

abstract property order: AbstractFinitePartialOrder[_P]

Get the partial order of this poset.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_P]

abstract smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than the limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

Raises:

NotImplementedError

abstract property top: Collection[_P]

Get the top elements.

Returns:

The top elements.

Return type:

Collection[_P]

abstract upper_limit(*limits, strict=False)

Get the values less than the limits.

Parameters:
Returns:

A collection of values.

Return type:

Collection[_P]

abstract property version: int

Get the poset version.

Returns:

The poset version.

Return type:

int

Notes

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

class FiniteJoinSemiLatticeMixin

Bases: FinitePartiallyOrderedSetMixin[_J]

It represents finite join semi-lattice mixin.

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 maximum: _P | None

Get the maximum element if any.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_J]

lower_limit(*limits, strict=False)

Get the values greater than the limits.

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

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

Returns:

A collection of values.

Return type:

Collection[_J]

floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than a limit.

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

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

Returns:

The greatest join irreducible smaller than the limits.

Return type:

Collection[_J]

class FiniteMeetSemiLatticeMixin

Bases: FinitePartiallyOrderedSetMixin[_M]

It represents finite meet semi-lattice mixin.

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 maximum: _P | None

Get the maximum element if any.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_M]

lower_limit(*limits, strict=False)

Get the values greater than the limits.

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

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

Returns:

A collection of values.

Return type:

Collection[_M]

ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than a limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

class FiniteLatticeMixin

Bases: FinitePartiallyOrderedSetMixin[_E]

It represents finite lattice mixin.

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_E]

lower_limit(*limits, strict=False)

Get the values greater than the limits.

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

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

Returns:

A collection of values.

Return type:

Collection[_E]

property co_atoms: Collection[_E]

Get the co-atoms of this lattice.

Returns:

The co-atoms.

Return type:

Collection[_E]

greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than a limit.

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

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

Returns:

The greatest join irreducible smaller than the limits.

Return type:

Collection[_J]

floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

property atoms: Collection[_E]

Get the atoms of this lattice.

Returns:

The atoms.

Return type:

Collection[_E]

smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than a limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

interval(*limits)

Get the interval of limits.

Parameters:

*limits (TypeVar(_E, bound= Element)) – The limits whose interval is requested

Returns:

The interval of the limits.

Return type:

tuple[_E | None, _E | None]

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 maximum: _P | None

Get the maximum element if any.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

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)
...     ]
... )
>>> semi_lattice
<galactic.algebras.lattice.ExtensibleFiniteJoinSemiLattice object at 0x...>

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.

Returns:

The version number.

Return type:

int

Notes

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

copy()

Get a copy of the join semi-lattice.

Returns:

The copy of this join semi-lattice.

Return type:

Self

join(*others)

Compute the join of this join-semilattice and others.

Parameters:

*others (Self) – A sequence of join-semilattice.

Returns:

The join of this join-semilattice and others

Return type:

Self

meet(*others)

Compute the meet of this join-semilattice and others.

Parameters:

*others (Self) – A sequence of join-semilattice.

Returns:

The meet of this join-semilattice and others

Return type:

Self

property order: AbstractFinitePartialOrder[_J]

Get the partial order of this join semi-lattice.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_J]

property cover: AbstractFiniteCoveringRelation[_J]

Get the covering relation of this join semi-lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_J]

floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than a limit.

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

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

Returns:

The greatest join irreducible smaller than the limits.

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(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

property top: Collection[_J]

Get the top elements.

The collection contains only one element, the maximum element.

Returns:

The top elements.

Return type:

Collection[_J]

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_J]

property bottom: Collection[_J]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_J]

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.

Returns:

The co-atoms.

Return type:

Collection[_J]

property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

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

Returns:

The join-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_J]

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)
...     ]
... )
>>> semi_lattice
<galactic.algebras.lattice.ExtensibleFiniteMeetSemiLattice object at 0x...>

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.

Returns:

The version number.

Return type:

int

Notes

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

copy()

Get a copy of the meet semi-lattice.

Returns:

The copy of this meet semi-lattice.

Return type:

Self

join(*others)

Compute the join of this meet-semilattice and others.

Parameters:

*others (Self) – A sequence of meet-semilattice.

Returns:

The join of this meet-semilattice and others

Return type:

Self

meet(*others)

Compute the meet of this meet-semilattice and others.

Parameters:

*others (Self) – A sequence of meet-semilattice.

Returns:

The meet of this meet-semilattice and others

Return type:

Self

property order: AbstractFinitePartialOrder[_M]

Get the partial order of this meet semi-lattice.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_M]

property cover: AbstractFiniteCoveringRelation[_M]

Get the covering relation of this meet semi-lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_M]

ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

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(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than a limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

property top: Collection[_M]

Get the top elements.

The collection contains only one element, the maximum element.

Returns:

The top elements.

Return type:

Collection[_M]

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_M]

property bottom: Collection[_M]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_M]

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.

Returns:

The copy of this lattice.

Return type:

Self

join(*others)

Compute the join of this object and others.

Parameters:

*others (Self) – A sequence of lattice.

Returns:

The join of this object and others

Return type:

Self

meet(*others)

Compute the meet of this object and others.

Parameters:

*others (Self) – A sequence of lattice.

Returns:

The meet of this object and others

Return type:

Self

property order: AbstractFinitePartialOrder[_E]

Get the partial order of this lattice.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_E]

property cover: AbstractFiniteCoveringRelation[_E]

Get the covering relation of this lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_E]

property top: Collection[_E]

Get the top elements.

Returns:

The top elements.

Return type:

Collection[_E]

property bottom: Collection[_E]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_E]

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 meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the meet-irreducible elements of this lattice.

Returns:

The meet-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the join-irreducible elements of this lattice.

Returns:

The join-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

property atoms: Collection[_E]

Get the atoms of this lattice.

Returns:

The atoms.

Return type:

Collection[_E]

ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

property co_atoms: Collection[_E]

Get the co-atoms of this lattice.

Returns:

The co-atoms.

Return type:

Collection[_E]

floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than a limit.

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

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

Returns:

The greatest join irreducible smaller than the limits.

Return type:

Collection[_J]

interval(*limits)

Get the interval of limits.

Parameters:

*limits (TypeVar(_E, bound= Element)) – The limits whose interval is requested

Returns:

The interval of the limits.

Return type:

tuple[_E | None, _E | None]

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(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than a limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_E]

class ExtensibleFiniteJoinSemiLattice(*others, elements=None)

Bases: FrozenFiniteJoinSemiLattice[_J]

It represents extensible join finite semi-lattices.

property bottom: Collection[_J]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_J]

property co_atoms: Collection[_J]

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

Returns:

The co-atoms.

Return type:

Collection[_J]

copy()

Get a copy of the join semi-lattice.

Returns:

The copy of this join semi-lattice.

Return type:

Self

property cover: AbstractFiniteCoveringRelation[_J]

Get the covering relation of this join semi-lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_J]

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.

floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than a limit.

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

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

Returns:

The greatest join irreducible smaller than the limits.

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

join(*others)

Compute the join of this join-semilattice and others.

Parameters:

*others (Self) – A sequence of join-semilattice.

Returns:

The join of this join-semilattice and others

Return type:

Self

property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

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

Returns:

The join-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_J]

lower_limit(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

meet(*others)

Compute the meet of this join-semilattice and others.

Parameters:

*others (Self) – A sequence of join-semilattice.

Returns:

The meet of this join-semilattice and others

Return type:

Self

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

property order: AbstractFinitePartialOrder[_J]

Get the partial order of this join semi-lattice.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_J]

property top: Collection[_J]

Get the top elements.

The collection contains only one element, the maximum element.

Returns:

The top elements.

Return type:

Collection[_J]

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_J]

property version: int

Get the version number.

Returns:

The version number.

Return type:

int

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.

Returns:

The bottom elements.

Return type:

Collection[_M]

ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

copy()

Get a copy of the meet semi-lattice.

Returns:

The copy of this meet semi-lattice.

Return type:

Self

property cover: AbstractFiniteCoveringRelation[_M]

Get the covering relation of this meet semi-lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_M]

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

join(*others)

Compute the join of this meet-semilattice and others.

Parameters:

*others (Self) – A sequence of meet-semilattice.

Returns:

The join of this meet-semilattice and others

Return type:

Self

lower_limit(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

meet(*others)

Compute the meet of this meet-semilattice and others.

Parameters:

*others (Self) – A sequence of meet-semilattice.

Returns:

The meet of this meet-semilattice and others

Return type:

Self

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.

Returns:

The minimum element.

Return type:

_P | None

property order: AbstractFinitePartialOrder[_M]

Get the partial order of this meet semi-lattice.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_M]

smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than a limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

property top: Collection[_M]

Get the top elements.

The collection contains only one element, the maximum element.

Returns:

The top elements.

Return type:

Collection[_M]

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_M]

property version: int

Get the version number.

Returns:

The version number.

Return type:

int

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)]
... )
>>> lattice
<galactic.algebras.lattice.ExtensibleFiniteLattice object at 0x...>
>>> list(map(int, lattice))
[6, 2, 3, 1]
property atoms: Collection[_E]

Get the atoms of this lattice.

Returns:

The atoms.

Return type:

Collection[_E]

property bottom: Collection[_E]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_E]

ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

property co_atoms: Collection[_E]

Get the co-atoms of this lattice.

Returns:

The co-atoms.

Return type:

Collection[_E]

copy()

Get a copy of the lattice.

Returns:

The copy of this lattice.

Return type:

Self

property cover: AbstractFiniteCoveringRelation[_E]

Get the covering relation of this lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_E]

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.

floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than a limit.

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

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

Returns:

The greatest join irreducible smaller than the limits.

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.

interval(*limits)

Get the interval of limits.

Parameters:

*limits (TypeVar(_E, bound= Element)) – The limits whose interval is requested

Returns:

The interval of the limits.

Return type:

tuple[_E | None, _E | None]

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

join(*others)

Compute the join of this object and others.

Parameters:

*others (Self) – A sequence of lattice.

Returns:

The join of this object and others

Return type:

Self

property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the join-irreducible elements of this lattice.

Returns:

The join-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

lower_limit(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

meet(*others)

Compute the meet of this object and others.

Parameters:

*others (Self) – A sequence of lattice.

Returns:

The meet of this object and others

Return type:

Self

property meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the meet-irreducible elements of this lattice.

Returns:

The meet-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

property order: AbstractFinitePartialOrder[_E]

Get the partial order of this lattice.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_E]

smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than a limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

property top: Collection[_E]

Get the top elements.

Returns:

The top elements.

Return type:

Collection[_E]

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

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:
floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than a limit.

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

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

Returns:

The greatest join irreducible smaller than the limits.

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(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_J]

property version: int

Get the version number.

Returns:

The version number.

Return type:

int

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.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_J]

property cover: AbstractFiniteCoveringRelation[_J]

Get the covering relation of this join semi-lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_J]

property top: Collection[_J]

Get the top elements.

The collection contains only one element, the maximum element.

Returns:

The top elements.

Return type:

Collection[_J]

property bottom: Collection[_J]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_J]

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.

Returns:

The co-atoms.

Return type:

Collection[_J]

property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]

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

Returns:

The join-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_J]

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

Bases: FiniteMeetSemiLatticeMixin[_M]

It represents bounded finite meet semi-lattice.

Parameters:
ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

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(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than a limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_M]

property version: int

Get the version number.

Returns:

The version number.

Return type:

int

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.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_M]

property cover: AbstractFiniteCoveringRelation[_M]

Get the covering relation of this meet semi-lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_M]

property top: Collection[_M]

Get the top elements.

Returns:

The top elements.

Return type:

Collection[_M]

property bottom: Collection[_M]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_M]

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.

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 FiniteLatticeView(lattice, lower=None, upper=None)

Bases: FiniteLatticeMixin[_E]

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

Parameters:
ceil(*limits)

Get the ceil of item.

Parameters:

*limits (TypeVar(_M, bound= Meetable)) – Elements whose ceil is requested.

Returns:

The ceil of others

Return type:

_M | None

floor(*limits)

Get the floor of item.

Parameters:

*limits (TypeVar(_J, bound= Joinable)) – Elements whose floor is requested.

Returns:

The floor of limits

Return type:

_J | None

greatest_join_irreducible(*limits, strict=False)

Get the greatest join irreducible smaller than a limit.

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

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

Returns:

The greatest join irreducible smaller than the limits.

Return type:

Collection[_J]

interval(*limits)

Get the interval of limits.

Parameters:

*limits (TypeVar(_E, bound= Element)) – The limits whose interval is requested

Returns:

The interval of the limits.

Return type:

tuple[_E | None, _E | None]

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(*limits, strict=False)

Get the values greater than the limits.

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

  • 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.

Returns:

The maximum element.

Return type:

_P | None

property minimum: _P | None

Get the minimum element if any.

Returns:

The minimum element.

Return type:

_P | None

smallest_meet_irreducible(*limits, strict=False)

Get the smallest meet irreducible greater than a limits.

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

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

Returns:

The smallest meet irreducible greater than the limits.

Return type:

Collection[_M]

upper_limit(*limits, strict=False)

Get the values less than the limits.

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

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

Returns:

Values which are less than the limits.

Return type:

Collection[_E]

property version: int

Get the version number.

Returns:

The version number.

Return type:

int

Notes

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

property order: AbstractFinitePartialOrder[_E]

Get the partial order of this lattice.

Returns:

The partial order.

Return type:

AbstractFinitePartialOrder[_E]

property cover: AbstractFiniteCoveringRelation[_E]

Get the covering relation of this lattice.

Returns:

The covering relation.

Return type:

AbstractFiniteCoveringRelation[_E]

property top: Collection[_E]

Get the top elements.

Returns:

The top elements.

Return type:

Collection[_E]

property bottom: Collection[_E]

Get the bottom elements.

Returns:

The bottom elements.

Return type:

Collection[_E]

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.

Returns:

The atoms.

Return type:

Collection[_E]

property meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the meet-irreducible elements of this lattice.

Returns:

The meet-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

property co_atoms: Collection[_E]

Get the co-atoms of this lattice.

Returns:

The co-atoms.

Return type:

Collection[_E]

property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]

Get the join-irreducible elements of this lattice.

Returns:

The join-irreducible elements.

Return type:

AbstractFinitePartiallyOrderedSet[_E]

class ReducedContext(lattice)

Bases: FiniteRelationMixin, Generic[_E]

It represents the reduced context of a lattice.

It is a binary relation between the join irreducible and the meet irreducible elements.

Parameters:

lattice (AbstractFiniteLattice[TypeVar(_E, bound= Element)]) – The lattice.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[tuple[Any, ...]]) – An iterable of ntuple.

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[tuple[Any, ...]]) – An iterable of ntuple.

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[tuple[Any, ...]]) – An iterable of ntuple.

Returns:

True if the relation is a superset of the other.

Return type:

bool

property universes: tuple[Collection[_E], Collection[_E]]

Get the universes of this reduced context.

Returns:

The universes of this reduced context.

Return type:

tuple[Collection[_E], Collection[_E]]

property domain: Collection[_E]

Get the domain of this reduced context.

The domain is composed of the join irreducible of the underlying lattice.

Returns:

The join irreducible of the underlying lattice.

Return type:

Collection[_E]

property co_domain: Collection[_E]

Get the co-domain of this reduced context.

The co-domain is composed of the meet irreducible of the underlying lattice.

Returns:

The meet irreducible of the underlying lattice.

Return type:

Collection[_E]

successors(element)

Get the successors of a join-irreducible, i.e. its attributes.

Parameters:

element (TypeVar(_E, bound= Element)) – A join-irreducible of the underlying lattice.

Returns:

The successors of the element.

Return type:

Collection[_E]

Raises:

ValueError – If the element does not belong to the domain of this reduced context.

predecessors(element)

Get the predecessors of a meet-irreducible, i.e. its objects.

Parameters:

element (TypeVar(_E, bound= Element)) – A meet-irreducible of the underlying lattice.

Returns:

The predecessors of the element.

Return type:

Collection[_E]

Raises:

ValueError – If the element does not belong to the domain of this reduced context.

class LatticeCoveringRelation(lattice)

Bases: FiniteCoveringRelationMixin[_E]

It represents the covering relation.

Parameters:

lattice (AbstractFiniteLattice[TypeVar(_E, bound= Element)]) – The lattice.

successors(element)

Get the successors of an element.

Parameters:

element (TypeVar(_E, bound= Element)) – The element whose successors are requested.

Returns:

The successors.

Return type:

Collection[_E]

Raises:

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

predecessors(element)

Get the predecessors of an element.

Parameters:

element (TypeVar(_E, bound= Element)) – The element whose predecessors are requested.

Returns:

The predecessors.

Return type:

Collection[_E]

Raises:

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

property co_domain: Collection[_P]

Get the co-domain of this covering relation.

Returns:

The co-domain of this covering relation.

Return type:

Collection[_P]

Notes

The domain and the co-domain of a covering relation are identical.

property domain: Collection[_P]

Get the domain of this covering relation.

Returns:

The domain of this covering relation.

Return type:

Collection[_P]

Notes

The domain and the co-domain of a covering relation are identical.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[tuple[Any, ...]]) – An iterable of ntuple.

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[tuple[Any, ...]]) – An iterable of ntuple.

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[tuple[Any, ...]]) – An iterable of ntuple.

Returns:

True if the relation is a superset of the other.

Return type:

bool

neighbourhoods(reverse=False)

Get an iterator over the neighbourhoods of an element.

Parameters:

reverse (bool, default: False) – Is this a bottom-up generation ?

Returns:

An iterator giving a triple (element, successors, predecessors) for each element in the covering relation.

Return type:

Iterator[Neighbourhood[_E]]

property sinks: Collection[_P]

Get the elements with no successors.

Returns:

The elements with no successors.

Return type:

Collection[_P]

property sources: Collection[_P]

Get the elements with no predecessors.

Returns:

The elements with no predecessors.

Return type:

Collection[_P]

property universes: tuple[Collection[_P], Collection[_P]]

Get the universes of this covering relation.

Returns:

The universes of this covering relation.

Return type:

tuple[Collection[_P], Collection[_P]]

class JoinSemiLatticeCoveringRelation(semi_lattice)

Bases: FiniteCoveringRelationMixin[_J]

It represents the covering relation.

Parameters:

semi_lattice (AbstractFiniteJoinSemiLattice[TypeVar(_J, bound= Joinable)]) – The semi-lattice.

successors(element)

Get the successors of an element.

Parameters:

element (TypeVar(_J, bound= Joinable)) – The element whose successors are requested.

Returns:

The successors.

Return type:

Collection[_J]

Raises:

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

predecessors(element)

Get the predecessors of an element.

Parameters:

element (TypeVar(_J, bound= Joinable)) – The element whose predecessors are requested.

Returns:

The predecessors.

Return type:

Collection[_J]

Raises:

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

neighbourhoods(reverse=False)

Get an iterator over the neighbourhoods of an element.

Parameters:

reverse (bool, default: False) – Is this a bottom-up generation ?

Returns:

An iterator giving a triple (element, successors, predecessors) for each element in the covering relation.

Return type:

Iterator[Neighbourhood[_J]]

Raises:

NotImplementedError – if reverse is set.

property co_domain: Collection[_P]

Get the co-domain of this covering relation.

Returns:

The co-domain of this covering relation.

Return type:

Collection[_P]

Notes

The domain and the co-domain of a covering relation are identical.

property domain: Collection[_P]

Get the domain of this covering relation.

Returns:

The domain of this covering relation.

Return type:

Collection[_P]

Notes

The domain and the co-domain of a covering relation are identical.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[tuple[Any, ...]]) – An iterable of ntuple.

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[tuple[Any, ...]]) – An iterable of ntuple.

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[tuple[Any, ...]]) – An iterable of ntuple.

Returns:

True if the relation is a superset of the other.

Return type:

bool

property sinks: Collection[_P]

Get the elements with no successors.

Returns:

The elements with no successors.

Return type:

Collection[_P]

property sources: Collection[_P]

Get the elements with no predecessors.

Returns:

The elements with no predecessors.

Return type:

Collection[_P]

property universes: tuple[Collection[_P], Collection[_P]]

Get the universes of this covering relation.

Returns:

The universes of this covering relation.

Return type:

tuple[Collection[_P], Collection[_P]]

class MeetSemiLatticeCoveringRelation(semi_lattice)

Bases: FiniteCoveringRelationMixin[_M]

It represents the covering relation.

Parameters:

semi_lattice (AbstractFiniteMeetSemiLattice[TypeVar(_M, bound= Meetable)]) – The semi-lattice.

successors(element)

Get the successors of an element.

Parameters:

element (TypeVar(_M, bound= Meetable)) – The element whose successors are requested.

Returns:

The successors.

Return type:

Collection[_M]

Raises:

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

predecessors(element)

Get the predecessors of an element.

Parameters:

element (TypeVar(_M, bound= Meetable)) – The element whose predecessors are requested.

Returns:

The predecessors.

Return type:

Collection[_M]

Raises:

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

neighbourhoods(reverse=False)

Get an iterator over the neighbourhoods of an element.

Parameters:

reverse (bool, default: False) – Is this a bottom-up generation ?

Returns:

An iterator giving a triple (element, successors, predecessors) for each element in the covering relation.

Return type:

Iterator[Neighbourhood[_M]]

Raises:

NotImplementedError – if reverse is set.

property co_domain: Collection[_P]

Get the co-domain of this covering relation.

Returns:

The co-domain of this covering relation.

Return type:

Collection[_P]

Notes

The domain and the co-domain of a covering relation are identical.

property domain: Collection[_P]

Get the domain of this covering relation.

Returns:

The domain of this covering relation.

Return type:

Collection[_P]

Notes

The domain and the co-domain of a covering relation are identical.

isdisjoint(other)

Test if the relation is disjoint from the other.

Parameters:

other (Iterable[tuple[Any, ...]]) – An iterable of ntuple.

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[tuple[Any, ...]]) – An iterable of ntuple.

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[tuple[Any, ...]]) – An iterable of ntuple.

Returns:

True if the relation is a superset of the other.

Return type:

bool

property sinks: Collection[_P]

Get the elements with no successors.

Returns:

The elements with no successors.

Return type:

Collection[_P]

property sources: Collection[_P]

Get the elements with no predecessors.

Returns:

The elements with no predecessors.

Return type:

Collection[_P]

property universes: tuple[Collection[_P], Collection[_P]]

Get the universes of this covering relation.

Returns:

The universes of this covering relation.

Return type:

tuple[Collection[_P], Collection[_P]]

Renderers

The galactic.algebras.lattice.renderer module.

It defines classes for rendering diagrams:

class ReducedContextDiagram(context, graph_renderer=None, domain_renderer=None, co_domain_renderer=None, edge_renderer=None)

Bases: SagittalDiagram[_E, _E]

It is used for drawing sagittal diagrams.

It is useful for drawing sagittal diagrams of lattice reduced context in jupyter notebooks.

Parameters:
property co_domain_renderer: NodeRenderer[_F, _E]

Get the co-domain renderer.

Return type:

The co-domain renderer.

property domain_renderer: NodeRenderer[_E, _F]

Get the domain renderer.

Return type:

The domain renderer.

property edge_renderer: EdgeRenderer[_E, _F]

Get the edge renderer.

Return type:

The edge renderer.

property graph_renderer: GraphRenderer[_E, _F]

Get the graph renderer.

Return type:

The graph renderer.

property relation: AbstractFiniteBinaryRelation[_E, _F]

Get the relation.

Return type:

The underlying relation.

property source: str

Get the graphviz source for this partially ordered set.

Return type:

The graphviz output for this partially ordered set.

class ReducedContextDiagramRenderer

Bases: SagittalDiagramRenderer[_E, _E]

It renders graphviz attributes.

it is used for a reduced context diagram.

attributes()

Get the graphviz attributes for the graph.

Return type:

dict[str, str]

Returns:

A dictionary of graphviz attributes

add_destination(element, index=None, current=False, successors=None, predecessors=None)

Add a destination to the graph.

Parameters:
  • element (TypeVar(_F)) – The destination to add.

  • index (int | None, default: None) – The destination index.

  • current (bool, default: False) – Is it the current element?

  • successors (Collection[TypeVar(_E)] | None, default: None) – The successors of the destination.

  • predecessors (Collection[TypeVar(_E)] | None, default: None) – The predecessors of the destination.

Return type:

None

add_edge(source, destination, successors=None, predecessors=None)

Add an edge to the graph.

Parameters:
  • source (TypeVar(_E)) – The edge source

  • destination (TypeVar(_F)) – The edge destination

  • successors (Collection[TypeVar(_F)] | None, default: None) – The successors of source (including current destination).

  • predecessors (Collection[TypeVar(_E)] | None, default: None) – The predecessors of destination (including current source).

Return type:

None

add_source(element, index=None, current=False, successors=None, predecessors=None)

Add a source to the graph.

Parameters:
  • element (TypeVar(_E)) – The source to add.

  • index (int | None, default: None) – The source index.

  • current (bool, default: False) – Is it the current element?

  • successors (Collection[TypeVar(_F)] | None, default: None) – The successors of the source.

  • predecessors (Collection[TypeVar(_F)] | None, default: None) – The predecessors of the source.

Return type:

None