Lattices
Classes and functions
The galactic.algebras.lattice
module.
It defines types for representing lattices.
Elements of semi-lattices and lattices
Joinable
for joinable elements;Meetable
for meetable elements;Element
for joinable and meetable elements.
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:
- 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.
- join_priority(generators)
Compute the priority of an element considering an iterable of generators.
- 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:
- 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:
- 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:
- 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:
- 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.
- meet_priority(generators)
Compute the priority of an element considering an iterable of generators.
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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.
- join_priority(generators)
Compute the priority of an element considering an iterable of generators.
- 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.
- 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.
- 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.
- 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:
- abstract floor(*limits)
Get the floor of item.
- abstract greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than the limits.
- Parameters:
- Returns:
The greatest join irreducible smaller than the limits.
- Return type:
Collection[_J]
- Raises:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- abstract lower_limit(*limits, strict=False)
Get the values greater than the limits.
- Parameters:
*limits (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limits.strict (
bool
, default:False
) – Is the comparison strict?
- 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:
- 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:
*limits (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limits.strict (
bool
, default:False
) – Is the comparison strict?
- Returns:
A collection of values.
- Return type:
Collection[_P]
- 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:
- abstract ceil(*limits)
Get the ceil of item.
- abstract smallest_meet_irreducible(*limits, strict=False)
Get the smallest meet irreducible greater than the limits.
- Parameters:
- Returns:
The smallest meet irreducible greater than the limits.
- Return type:
Collection[_M]
- Raises:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- abstract lower_limit(*limits, strict=False)
Get the values greater than the limits.
- Parameters:
*limits (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limits.strict (
bool
, default:False
) – Is the comparison strict?
- 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:
- 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:
*limits (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limits.strict (
bool
, default:False
) – Is the comparison strict?
- Returns:
A collection of values.
- Return type:
Collection[_P]
- class AbstractFiniteLattice(*args, **kwargs)
Bases:
AbstractFiniteJoinSemiLattice
[_E
],AbstractFiniteMeetSemiLattice
[_E
],Collection
[_E
],Protocol
It represents finite lattices.
- abstract interval(*limits)
Get the interval of limits.
- 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.
- 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:
- 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:
- 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.
- abstract greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than the limits.
- Parameters:
- Returns:
The greatest join irreducible smaller than the limits.
- Return type:
Collection[_J]
- Raises:
- 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:
- 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:
- 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:
- 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:
- abstract property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]
Get the join irreducible elements.
- Returns:
The join irreducible elements.
- Return type:
- abstract lower_limit(*limits, strict=False)
Get the values greater than the limits.
- Parameters:
*limits (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limits.strict (
bool
, default:False
) – Is the comparison strict?
- 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:
- 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:
- abstract smallest_meet_irreducible(*limits, strict=False)
Get the smallest meet irreducible greater than the limits.
- Parameters:
- Returns:
The smallest meet irreducible greater than the limits.
- Return type:
Collection[_M]
- Raises:
- 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:
*limits (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limits.strict (
bool
, default:False
) – Is the comparison strict?
- Returns:
A collection of values.
- Return type:
Collection[_P]
- 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:
- 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:
- 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:
- 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.
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- floor(*limits)
Get the floor of item.
- greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than a limit.
- 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:
- 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:
- 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:
- 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.
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- ceil(*limits)
Get the ceil of item.
- smallest_meet_irreducible(*limits, strict=False)
Get the smallest meet irreducible greater than a limits.
- class FiniteLatticeMixin
Bases:
FinitePartiallyOrderedSetMixin
[_E
]It represents finite lattice mixin.
- upper_limit(*limits, strict=False)
Get the values less than the limits.
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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.
- floor(*limits)
Get the floor of item.
- 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.
- ceil(*limits)
Get the ceil of item.
- interval(*limits)
Get the interval of limits.
- 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:
- 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:
- 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:
- 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
It’s possible to iterate over the co-atoms.
Example
It’s possible to iterate over the join irreducible.
Example
It’s possible to iterate over the greatest join irreducible smaller than a limit.
Example
It’s possible to enlarge a join semi-lattice.
Example
- property version: int
Get the version number.
- Returns:
The version number.
- Return type:
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:
- property cover: AbstractFiniteCoveringRelation[_J]
Get the covering relation of this join semi-lattice.
- Returns:
The covering relation.
- Return type:
- floor(*limits)
Get the floor of item.
- greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than a limit.
- 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:
- 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:
- 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:
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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.
- 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:
- Returns:
A view on the lower bounded join semi-lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the join semi-lattice.
- ideal(element)
Get an ideal of a join semi-lattice.
- Parameters:
- Returns:
A view on the upper bounded join semi-lattice.
- Return type:
- 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:
- 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
It’s possible to iterate over the atoms.
Example
It’s possible to iterate over the meet irreducible.
Example
It’s possible to iterate over the smallest meet irreducible greater than a limit.
Example
It’s possible to enlarge a meet semi-lattice.
Example
- property version: int
Get the version number.
- Returns:
The version number.
- Return type:
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:
- property cover: AbstractFiniteCoveringRelation[_M]
Get the covering relation of this meet semi-lattice.
- Returns:
The covering relation.
- Return type:
- ceil(*limits)
Get the ceil of item.
- 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:
- 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:
- 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:
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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.
- 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.
- 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:
- Returns:
A view on the lower bounded meet semi-lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the meet semi-lattice.
- ideal(element)
Get an ideal of a meet semi-lattice.
- Parameters:
- Returns:
A view on the upper bounded meet semi-lattice.
- Return type:
- 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:
- class FrozenFiniteLattice(*others, elements=None)
Bases:
FiniteLatticeMixin
[_E
]It represents frozen finite lattices.
- Parameters:
- 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:
- property cover: AbstractFiniteCoveringRelation[_E]
Get the covering relation of this lattice.
- Returns:
The covering relation.
- Return type:
- 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:
- Returns:
A view on the bounded lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the lattice.
- ideal(element)
Get an ideal of a lattice.
- Parameters:
- Returns:
A view on the bounded lattice.
- Return type:
- 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:
- property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]
Get the join-irreducible elements of this lattice.
- Returns:
The join-irreducible elements.
- Return type:
- property atoms: Collection[_E]
Get the atoms of this lattice.
- Returns:
The atoms.
- Return type:
Collection[_E]
- ceil(*limits)
Get the ceil of item.
- 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.
- greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than a limit.
- interval(*limits)
Get the interval of limits.
- 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:
- 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:
- 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:
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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.
- 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:
- filter(element)
Get a filter of a join semi-lattice.
- Parameters:
- Returns:
A view on the lower bounded join semi-lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the join semi-lattice.
- floor(*limits)
Get the floor of item.
- greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than a limit.
- ideal(element)
Get an ideal of a join semi-lattice.
- Parameters:
- Returns:
A view on the upper bounded join semi-lattice.
- Return type:
- 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:
- 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:
- 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:
- 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:
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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:
- 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.
- 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.
- 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:
- filter(element)
Get a filter of a meet semi-lattice.
- Parameters:
- Returns:
A view on the lower bounded meet semi-lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the meet semi-lattice.
- ideal(element)
Get an ideal of a meet semi-lattice.
- Parameters:
- Returns:
A view on the upper bounded meet semi-lattice.
- Return type:
- 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:
- 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:
- 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:
- 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.
- 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:
- 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:
- smallest_meet_irreducible(*limits, strict=False)
Get the smallest meet irreducible greater than a limits.
- 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.
- 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.
- 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:
- filter(element)
Get a filter of a lattice.
- Parameters:
- Returns:
A view on the bounded lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the lattice.
- floor(*limits)
Get the floor of item.
- greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than a limit.
- ideal(element)
Get an ideal of a lattice.
- Parameters:
- Returns:
A view on the bounded lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the lattice.
- interval(*limits)
Get the interval of limits.
- 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:
- 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:
- 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:
- 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:
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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:
- 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:
- smallest_meet_irreducible(*limits, strict=False)
Get the smallest meet irreducible greater than a limits.
- 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.
- 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.
- greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than a limit.
- 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:
- 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:
- 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:
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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.
- property version: int
Get the version number.
- Returns:
The version number.
- Return type:
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:
- property cover: AbstractFiniteCoveringRelation[_J]
Get the covering relation of this join semi-lattice.
- Returns:
The covering relation.
- Return type:
- 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:
- Returns:
A view on the bounded semi-lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the join semi-lattice.
- ideal(element)
Get an ideal of a join semi-lattice.
- Parameters:
- Returns:
A view on the bounded semi-lattice.
- Return type:
- 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:
- 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.
- 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:
- 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:
- 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:
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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.
- upper_limit(*limits, strict=False)
Get the values less than the limits.
- property version: int
Get the version number.
- Returns:
The version number.
- Return type:
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:
- property cover: AbstractFiniteCoveringRelation[_M]
Get the covering relation of this meet semi-lattice.
- Returns:
The covering relation.
- Return type:
- 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:
- Returns:
A view on the bounded semi-lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the meet semi-lattice.
- ideal(element)
Get an ideal of a meet semi-lattice.
- Parameters:
- Returns:
A view on the bounded semi-lattice.
- Return type:
- 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:
- 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.
- floor(*limits)
Get the floor of item.
- greatest_join_irreducible(*limits, strict=False)
Get the greatest join irreducible smaller than a limit.
- interval(*limits)
Get the interval of limits.
- 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:
- 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:
- 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:
- lower_limit(*limits, strict=False)
Get the values greater than the limits.
- 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.
- upper_limit(*limits, strict=False)
Get the values less than the limits.
- property version: int
Get the version number.
- Returns:
The version number.
- Return type:
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:
- property cover: AbstractFiniteCoveringRelation[_E]
Get the covering relation of this lattice.
- Returns:
The covering relation.
- Return type:
- 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:
- Returns:
A view on the bounded lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the lattice.
- ideal(element)
Get an ideal of a lattice.
- Parameters:
- Returns:
A view on the bounded lattice.
- Return type:
- 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:
- 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:
- 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.
- issubset(other)
Test whether every element in the relation is in other.
- issuperset(other)
Test whether every element in the other relation is in the relation.
- 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.
- issubset(other)
Test whether every element in the relation is in other.
- issuperset(other)
Test whether every element in the other relation is in the relation.
- 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.
- issubset(other)
Test whether every element in the relation is in other.
- issuperset(other)
Test whether every element in the other relation is in the relation.
- 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.
- issubset(other)
Test whether every element in the relation is in other.
- issuperset(other)
Test whether every element in the other relation is in the relation.
- 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:
context (
ReducedContext
[TypeVar
(_E
, bound=Element
)]) – The reduced context.graph_renderer (
Optional
[ReducedContextDiagramRenderer
[TypeVar
(_E
, bound=Element
)]], default:None
) – The graph renderer.domain_renderer (
Optional
[NodeRenderer
[TypeVar
(_E
, bound=Element
),TypeVar
(_E
, bound=Element
)]], default:None
) – The domain renderer.co_domain_renderer (
Optional
[NodeRenderer
[TypeVar
(_E
, bound=Element
),TypeVar
(_E
, bound=Element
)]], default:None
) – The domain renderer.edge_renderer (
Optional
[EdgeRenderer
[TypeVar
(_E
, bound=Element
),TypeVar
(_E
, bound=Element
)]], default:None
) – The edge renderer.
- 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.
- class ReducedContextDiagramRenderer
Bases:
SagittalDiagramRenderer
[_E
,_E
]It renders graphviz attributes.
it is used for a reduced context diagram.
Notes
- attributes()
Get the graphviz attributes for the graph.
- 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.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:
- add_edge(source, destination, successors=None, predecessors=None)
Add an edge to the graph.
- Parameters:
source (
TypeVar
(_E
)) – The edge sourcedestination (
TypeVar
(_F
)) – The edge destinationsuccessors (
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:
- 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.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: