Lattices
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:
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.
- 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
],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 greatest_join_irreducible(limit)
Get the greatest join irreducible smaller than a limit.
- 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(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.
- 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(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.
- 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 smallest_meet_irreducible(limit)
Get the smallest meet irreducible greater than a limit.
- 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(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.
- 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(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.
- 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 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 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.
- Returns:
The join irreducible elements.
- 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.
- 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(limit)
Get the smallest meet irreducible greater than a limit.
- abstract property top: Collection[_P]
Get the top elements.
- Returns:
The top elements.
- Return type:
Collection[_P]
- 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) ... ] ... ) >>> 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
- 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:
- 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.
- Returns:
The top elements.
- Return type:
Collection[_J]
- upper_limit(limit, strict=False)
Get the values less than the limit.
- 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
- 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:
- 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.
- Returns:
The top elements.
- Return type:
Collection[_M]
- upper_limit(limit, strict=False)
Get the values less than the limit.
- 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
- 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.
- property atoms: Collection[_E]
Get the atoms of this lattice.
- Returns:
The atoms.
- Return type:
Collection[_E]
- property co_atoms: Collection[_E]
Get the co-atoms of this lattice.
- Returns:
The co-atoms.
- Return type:
Collection[_E]
- greatest_join_irreducible(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.
- 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 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.
- 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.
- 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.
- Returns:
The join-irreducible elements.
- Return type:
- 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.
- 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(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.
- Returns:
The bottom elements.
- Return type:
Collection[_M]
- 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:
- 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.
- Returns:
The partial order.
- Return type:
- 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.
- Returns:
The top elements.
- Return type:
Collection[_M]
- 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)] ... ) >>> 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]
- 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.
- 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.
- Returns:
The join-irreducible elements.
- Return type:
- 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.
- Returns:
The meet-irreducible elements.
- Return type:
- property order: AbstractFinitePartialOrder[_E]
Get the partial order of this lattice.
- Returns:
The partial order.
- Return type:
- 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.
- Returns:
The top elements.
- Return type:
Collection[_E]
- 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.
- 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:
- 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.
- 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:
- 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.
- 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:
- property reduced_context: AbstractFiniteBinaryRelation[_E, _E]
Get the reduced context from this lattice.
- Returns:
The reduced context.
- Return type:
AbstractFiniteBinaryRelation[_E, _E]