Lattices
The galactic.algebras.lattice
module 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:
and their implementations:
- class Joinable(*args, **kwargs)
Bases:
PartiallyComparable
,Protocol
It represents joinable elements.
This class sets for each pair of elements a, b a unique supremum \(c = a \vee b\) (also called a least upper bound or join).
Example
Let the integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?
>>> from galactic.algebras.examples.arithmetic import PrimeFactors >>> PrimeFactors(24) | PrimeFactors(36) PrimeFactors(72) >>> PrimeFactors(24).join(PrimeFactors(36), PrimeFactors(10)) PrimeFactors(360)
- abstract __or__(other)
Return the join of this element and the other.
- Parameters:
other (
Self
) – the other element- Returns:
The join of this element and the other
- Return type:
Self
- Raises:
- 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.
- 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.
- 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.
- 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
- 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
],Protocol
It describes finite join semi-lattices.
- abstract property co_atoms: Collection[_J]
Get the co-atoms of this join semi-lattice.
- Return type:
The co-atoms.
- abstract property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]
Get the join irreducible elements.
- Return type:
The join irreducible elements.
- abstract greatest_join_irreducible(limit)
Get the greatest join irreducible smaller than a limit.
- abstract property bottom: Collection[_P]
Get the bottom elements.
- Return type:
The bottom elements.
- abstract property cover: AbstractFiniteCoveringRelation[_P]
Get the covering relation of this poset.
- Return type:
The covering relation.
- abstract filter(element)
Get a filter of a poset.
- Parameters:
element (
TypeVar
(_P
, bound=PartiallyComparable
)) – The lower limit- Returns:
A view on the lower bounded poset.
- Return type:
- 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(limit, strict=False)
Get the values greater than the limit.
- Parameters:
limit (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limit.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.
- Return type:
The maximum element.
- abstract property minimum: _P | None
Get the minimum element if any.
- Return type:
The minimum element.
- abstract property order: AbstractFinitePartialOrder[_P]
Get the partial order of this poset.
- Return type:
The partial order.
- abstract property top: Collection[_P]
Get the top elements.
- Return type:
The top elements.
- abstract upper_limit(limit, strict=False)
Get the values less than the limit.
- Parameters:
limit (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limit.strict (
bool
, default:False
) – Is the comparison strict?
- Returns:
A collection of values.
- Return type:
Collection[_P]
- class AbstractFiniteMeetSemiLattice(*args, **kwargs)
Bases:
AbstractFinitePartiallyOrderedSet
[_M
],Protocol
It describes finite meet semi-lattices.
- abstract property atoms: Collection[_M]
Get the atoms of this meet semi-lattice.
- Return type:
The atoms.
- abstract property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]
Get the meet irreducible elements.
- Return type:
The meet irreducible elements.
- abstract smallest_meet_irreducible(limit)
Get the smallest meet irreducible greater than a limit.
- abstract property bottom: Collection[_P]
Get the bottom elements.
- Return type:
The bottom elements.
- abstract property cover: AbstractFiniteCoveringRelation[_P]
Get the covering relation of this poset.
- Return type:
The covering relation.
- abstract filter(element)
Get a filter of a poset.
- Parameters:
element (
TypeVar
(_P
, bound=PartiallyComparable
)) – The lower limit- Returns:
A view on the lower bounded poset.
- Return type:
- 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(limit, strict=False)
Get the values greater than the limit.
- Parameters:
limit (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limit.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.
- Return type:
The maximum element.
- abstract property minimum: _P | None
Get the minimum element if any.
- Return type:
The minimum element.
- abstract property order: AbstractFinitePartialOrder[_P]
Get the partial order of this poset.
- Return type:
The partial order.
- abstract property top: Collection[_P]
Get the top elements.
- Return type:
The top elements.
- abstract upper_limit(limit, strict=False)
Get the values less than the limit.
- Parameters:
limit (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limit.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
],Protocol
It represents finite lattices.
- abstract property reduced_context: AbstractFiniteBinaryRelation[_E, _E]
Get the reduced context from this lattice.
- Returns:
The reduced context.
- Return type:
AbstractFiniteBinaryRelation[_E, _E]
- Raises:
- abstract property atoms: Collection[_M]
Get the atoms of this meet semi-lattice.
- Return type:
The atoms.
- abstract property bottom: Collection[_P]
Get the bottom elements.
- Return type:
The bottom elements.
- abstract property co_atoms: Collection[_J]
Get the co-atoms of this join semi-lattice.
- Return type:
The co-atoms.
- abstract property cover: AbstractFiniteCoveringRelation[_P]
Get the covering relation of this poset.
- Return type:
The covering relation.
- abstract filter(element)
Get a filter of a poset.
- Parameters:
element (
TypeVar
(_P
, bound=PartiallyComparable
)) – The lower limit- Returns:
A view on the lower bounded poset.
- Return type:
- Raises:
ValueError – If the element does not belong to the poset.
Notes
Unpredictable behavior can occur if the lower bound is no longer part of the original poset.
- abstract greatest_join_irreducible(limit)
Get the greatest join irreducible smaller than a limit.
- 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.
- Return type:
The join irreducible elements.
- abstract lower_limit(limit, strict=False)
Get the values greater than the limit.
- Parameters:
limit (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limit.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.
- Return type:
The maximum element.
- abstract property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]
Get the meet irreducible elements.
- Return type:
The meet irreducible elements.
- abstract property minimum: _P | None
Get the minimum element if any.
- Return type:
The minimum element.
- abstract property order: AbstractFinitePartialOrder[_P]
Get the partial order of this poset.
- Return type:
The partial order.
- abstract smallest_meet_irreducible(limit)
Get the smallest meet irreducible greater than a limit.
- abstract property top: Collection[_P]
Get the top elements.
- Return type:
The top elements.
- abstract upper_limit(limit, strict=False)
Get the values less than the limit.
- Parameters:
limit (
TypeVar
(_P
, bound=PartiallyComparable
)) – The limit.strict (
bool
, default:False
) – Is the comparison strict?
- Returns:
A collection of values.
- Return type:
Collection[_P]
- class FrozenFiniteJoinSemiLattice(*others, elements=None)
Bases:
FiniteJoinSemiLatticeMixin
[_J
]It represents concrete finite join semi-lattice.
An instance stores its irreducible in a poset.
Its memory complexity is in \(O(j)\)
- Parameters:
Example
>>> from galactic.algebras.lattice import ExtensibleFiniteJoinSemiLattice >>> from galactic.algebras.examples.arithmetic import PrimeFactors >>> semi_lattice = ExtensibleFiniteJoinSemiLattice[PrimeFactors]( ... elements = [ ... PrimeFactors(2*3*5), ... PrimeFactors(3*5*7), ... PrimeFactors(5*7*11) ... ] ... ) >>>
It’s possible to get the maximum element.
Example
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.
- Return type:
The version number.
Notes
This can be used to detect a change in the semi-lattice.
- copy()
Get a copy of the join semi-lattice.
- Return type:
Self
- Returns:
The copy of this join semi-lattice.
- property order: AbstractFinitePartialOrder[_J]
Get the partial order of this join semi-lattice.
- Return type:
The partial order.
- property cover: AbstractFiniteCoveringRelation[_J]
Get the covering relation of this join semi-lattice.
- Return type:
The covering relation.
- greatest_join_irreducible(limit, strict=False)
Get the greatest join irreducible smaller than a limit.
- 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(limit, strict=False)
Get the values greater than the limit.
- property top: Collection[_J]
Get the top elements.
The collection contains only one element, the maximum element.
- Return type:
The top elements.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- property bottom: Collection[_J]
Get the bottom elements.
- Return type:
The bottom elements.
- 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.
- Return type:
The co-atoms.
- property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]
Get the join-irreducible elements of this join semi-lattice.
- Return type:
The join-irreducible elements.
- class FrozenFiniteMeetSemiLattice(*others, elements=None)
Bases:
FiniteMeetSemiLatticeMixin
[_M
]It represents concrete finite meet semi-lattice.
An instance stores its irreducible in a poset.
Its memory complexity is in \(O(j)\)
- Parameters:
Example
>>> from galactic.algebras.lattice import ExtensibleFiniteMeetSemiLattice >>> from galactic.algebras.examples.arithmetic import PrimeFactors >>> semi_lattice = ExtensibleFiniteMeetSemiLattice[PrimeFactors]( ... elements = [ ... PrimeFactors(2*3*5), ... PrimeFactors(3*5*7), ... PrimeFactors(5*7*11) ... ] ... ) >>>
It’s possible to get the maximum element.
Example
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.
- Return type:
The version number.
Notes
This can be used to detect a change in the semi-lattice.
- copy()
Get a copy of the meet semi-lattice.
- Return type:
Self
- Returns:
The copy of this meet semi-lattice.
- property order: AbstractFinitePartialOrder[_M]
Get the partial order of this meet semi-lattice.
- Return type:
The partial order.
- property cover: AbstractFiniteCoveringRelation[_M]
Get the covering relation of this meet semi-lattice.
- Return type:
The covering relation.
- isdisjoint(other)
Test if the relation is disjoint from the other.
- Parameters:
other (
Iterable
[TypeVar
(_P
, bound=PartiallyComparable
)]) – An iterable of couples.- Returns:
True if the relation is disjoint from the other.
- Return type:
- 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(limit, strict=False)
Get the values greater than the limit.
- smallest_meet_irreducible(limit, strict=False)
Get the smallest meet irreducible greater than a limit.
- property top: Collection[_M]
Get the top elements.
The collection contains only one element, the maximum element.
- Return type:
The top elements.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- property bottom: Collection[_M]
Get the bottom elements.
- Return type:
The bottom elements.
- 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.
- Return type:
Self
- Returns:
The copy of this lattice.
- property order: AbstractFinitePartialOrder[_E]
Get the partial order of this lattice.
- Return type:
The partial order.
- property cover: AbstractFiniteCoveringRelation[_E]
Get the covering relation of this lattice.
- Return type:
The covering relation.
- property top: Collection[_E]
Get the top elements.
- Return type:
The top elements.
- property bottom: Collection[_E]
Get the bottom elements.
- Return type:
The bottom elements.
- filter(element)
Get a filter of a lattice.
- Parameters:
- 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.
- Return type:
The atoms.
- property co_atoms: Collection[_E]
Get the co-atoms of this lattice.
- Return type:
The co-atoms.
- greatest_join_irreducible(limit, strict=False)
Get the greatest join irreducible smaller than a limit.
- 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.
- 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(limit, strict=False)
Get the values greater than the limit.
- smallest_meet_irreducible(limit, strict=False)
Get the smallest meet irreducible greater than a limit.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- property meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]
Get the meet-irreducible elements of this lattice.
- Return type:
The meet-irreducible elements.
- property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]
Get the join-irreducible elements of this lattice.
- Return type:
The join-irreducible elements.
- property reduced_context: AbstractFiniteBinaryRelation[_E, _E]
Get the reduced context from this lattice.
- Returns:
The reduced context.
- Return type:
AbstractFiniteBinaryRelation[_E, _E]
- class ExtensibleFiniteJoinSemiLattice(*others, elements=None)
Bases:
FrozenFiniteJoinSemiLattice
[_J
]It represents extensible join finite semi-lattices.
- property bottom: Collection[_J]
Get the bottom elements.
- Return type:
The bottom elements.
- property co_atoms: Collection[_J]
Get the co-atoms of this join semi-lattice.
- Return type:
The co-atoms.
- copy()
Get a copy of the join semi-lattice.
- Return type:
Self
- Returns:
The copy of this join semi-lattice.
- property cover: AbstractFiniteCoveringRelation[_J]
Get the covering relation of this join semi-lattice.
- Return type:
The covering relation.
- filter(element)
Get a filter of a join semi-lattice.
- Parameters:
- 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.
- greatest_join_irreducible(limit, 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:
- property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]
Get the join-irreducible elements of this join semi-lattice.
- Return type:
The join-irreducible elements.
- lower_limit(limit, strict=False)
Get the values greater than the limit.
- property order: AbstractFinitePartialOrder[_J]
Get the partial order of this join semi-lattice.
- Return type:
The partial order.
- property top: Collection[_J]
Get the top elements.
The collection contains only one element, the maximum element.
- Return type:
The top elements.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- class ExtensibleFiniteMeetSemiLattice(*others, elements=None)
Bases:
FrozenFiniteMeetSemiLattice
[_M
]It represents extensible meet finite semi-lattices.
- property atoms: Collection[_M]
Get the atoms of this meet semi-lattice.
- Returns:
The atoms.
- Return type:
Collection[_M]
- property bottom: Collection[_M]
Get the bottom elements.
- Return type:
The bottom elements.
- copy()
Get a copy of the meet semi-lattice.
- Return type:
Self
- Returns:
The copy of this meet semi-lattice.
- property cover: AbstractFiniteCoveringRelation[_M]
Get the covering relation of this meet semi-lattice.
- Return type:
The covering relation.
- filter(element)
Get a filter of a meet semi-lattice.
- Parameters:
- 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:
- lower_limit(limit, strict=False)
Get the values greater than the limit.
- property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]
Get the meet-irreducible elements of this meet semi-lattice.
- Returns:
The meet-irreducible elements.
- Return type:
- property order: AbstractFinitePartialOrder[_M]
Get the partial order of this meet semi-lattice.
- Return type:
The partial order.
- smallest_meet_irreducible(limit, strict=False)
Get the smallest meet irreducible greater than a limit.
- property top: Collection[_M]
Get the top elements.
The collection contains only one element, the maximum element.
- Return type:
The top elements.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- class ExtensibleFiniteLattice(*others, elements=None)
Bases:
FrozenFiniteLattice
[_E
]It represents extensible finite lattices.
It uses its join irreducible and meet irreducible elements.
The elements of this can be iterated from the maximum element to the minimum element or from the minimum element to the maximum element using the
reversed()
built-in function. It is not guaranteed that the order will be exactly the reverse order, but it is guaranteed that an element will always be iterated before its successors.Example
Let the integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?
implemented by the
PrimeFactors
class:>>> from galactic.algebras.examples.arithmetic import PrimeFactors >>> from galactic.algebras.lattice import ExtensibleFiniteLattice >>> lattice = ExtensibleFiniteLattice[PrimeFactors]( ... elements=[PrimeFactors(2), PrimeFactors(3)] ... ) >>> list(map(int, lattice)) [6, 2, 3, 1]
- property atoms: Collection[_E]
Get the atoms of this lattice.
- Return type:
The atoms.
- property bottom: Collection[_E]
Get the bottom elements.
- Return type:
The bottom elements.
- property co_atoms: Collection[_E]
Get the co-atoms of this lattice.
- Return type:
The co-atoms.
- copy()
Get a copy of the lattice.
- Return type:
Self
- Returns:
The copy of this lattice.
- property cover: AbstractFiniteCoveringRelation[_E]
Get the covering relation of this lattice.
- Return type:
The covering relation.
- filter(element)
Get a filter of a lattice.
- Parameters:
- Returns:
A view on the bounded lattice.
- Return type:
- Raises:
ValueError – If the element does not belong to the lattice.
- greatest_join_irreducible(limit, strict=False)
Get the greatest join irreducible smaller than a limit.
- 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.
- 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 join_irreducible: AbstractFinitePartiallyOrderedSet[_E]
Get the join-irreducible elements of this lattice.
- Return type:
The join-irreducible elements.
- lower_limit(limit, strict=False)
Get the values greater than the limit.
- property meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]
Get the meet-irreducible elements of this lattice.
- Return type:
The meet-irreducible elements.
- property order: AbstractFinitePartialOrder[_E]
Get the partial order of this lattice.
- Return type:
The partial order.
- property reduced_context: AbstractFiniteBinaryRelation[_E, _E]
Get the reduced context from this lattice.
- Returns:
The reduced context.
- Return type:
AbstractFiniteBinaryRelation[_E, _E]
- smallest_meet_irreducible(limit, strict=False)
Get the smallest meet irreducible greater than a limit.
- property top: Collection[_E]
Get the top elements.
- Return type:
The top elements.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- class FiniteJoinSemiLatticeView(semi_lattice, lower=None, upper=None)
Bases:
FiniteJoinSemiLatticeMixin
[_J
]It represents bounded finite join semi-lattice.
- Parameters:
- greatest_join_irreducible(limit, strict=False)
Get the greatest join irreducible smaller than a limit.
- 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(limit, strict=False)
Get the values greater than the limit.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- property version: int
Get the version number.
- Return type:
The version number.
Notes
This can be used to detect a change in the semi-lattice.
- property order: AbstractFinitePartialOrder[_J]
Get the partial order of this join semi-lattice.
- Return type:
The partial order.
- property cover: AbstractFiniteCoveringRelation[_J]
Get the covering relation of this join semi-lattice.
- Return type:
The covering relation.
- property top: Collection[_J]
Get the top elements.
The collection contains only one element, the maximum element.
- Return type:
The top elements.
- property bottom: Collection[_J]
Get the bottom elements.
- Return type:
The bottom elements.
- filter(element)
Get a filter of a join semi-lattice.
- Parameters:
- 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.
- Return type:
The co-atoms.
- property join_irreducible: AbstractFinitePartiallyOrderedSet[_J]
Get the join-irreducible elements of this join semi-lattice.
- Return type:
The join-irreducible elements.
- class FiniteMeetSemiLatticeView(semi_lattice, lower=None, upper=None)
Bases:
FiniteMeetSemiLatticeMixin
[_M
]It represents bounded finite meet semi-lattice.
- Parameters:
- isdisjoint(other)
Test if the relation is disjoint from the other.
- Parameters:
other (
Iterable
[TypeVar
(_P
, bound=PartiallyComparable
)]) – An iterable of couples.- Returns:
True if the relation is disjoint from the other.
- Return type:
- 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(limit, strict=False)
Get the values greater than the limit.
- smallest_meet_irreducible(limit, strict=False)
Get the smallest meet irreducible greater than a limit.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- property version: int
Get the version number.
- Return type:
The version number.
Notes
This can be used to detect a change in the semi-lattice.
- property order: AbstractFinitePartialOrder[_M]
Get the partial order of this meet semi-lattice.
- Return type:
The partial order.
- property cover: AbstractFiniteCoveringRelation[_M]
Get the covering relation of this meet semi-lattice.
- Return type:
The covering relation.
- property top: Collection[_M]
Get the top elements.
- Return type:
The top elements.
- property bottom: Collection[_M]
Get the bottom elements.
- Return type:
The bottom elements.
- filter(element)
Get a filter of a meet semi-lattice.
- Parameters:
- 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.
- Return type:
The atoms.
- property meet_irreducible: AbstractFinitePartiallyOrderedSet[_M]
Get the meet-irreducible elements of this meet semi-lattice.
- Return type:
The meet-irreducible elements.
- class FiniteLatticeView(lattice, lower=None, upper=None)
Bases:
FiniteLatticeMixin
[_E
]It represents a view of a lattice using ideal or filter construction.
- Parameters:
- greatest_join_irreducible(limit, strict=False)
Get the greatest join irreducible smaller than a limit.
- 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(limit, strict=False)
Get the values greater than the limit.
- smallest_meet_irreducible(limit, strict=False)
Get the smallest meet irreducible greater than a limit.
- upper_limit(limit, strict=False)
Get the values less than the limit.
- property version: int
Get the version number.
- Return type:
The version number.
Notes
This can be used to detect a change in the lattice.
- property order: AbstractFinitePartialOrder[_E]
Get the partial order of this lattice.
- Return type:
The partial order.
- property cover: AbstractFiniteCoveringRelation[_E]
Get the covering relation of this lattice.
- Return type:
The covering relation.
- property top: Collection[_E]
Get the top elements.
- Return type:
The top elements.
- property bottom: Collection[_E]
Get the bottom elements.
- Return type:
The bottom elements.
- filter(element)
Get a filter of a lattice.
- Parameters:
- 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.
- Return type:
The atoms.
- property meet_irreducible: AbstractFinitePartiallyOrderedSet[_E]
Get the meet-irreducible elements of this lattice.
- Return type:
The meet-irreducible elements.
- property co_atoms: Collection[_E]
Get the co-atoms of this lattice.
- Return type:
The co-atoms.
- property join_irreducible: AbstractFinitePartiallyOrderedSet[_E]
Get the join-irreducible elements of this lattice.
- Return type:
The join-irreducible elements.
- property reduced_context: AbstractFiniteBinaryRelation[_E, _E]
Get the reduced context from this lattice.
- Returns:
The reduced context.
- Return type:
AbstractFiniteBinaryRelation[_E, _E]