galactic.algebras.lattice.core#
Defines types for representing lattices.
Protocols
Elements of semi-lattices and lattices:
Joinablefor joinable elementsMeetablefor meetable elementsElementfor joinable and meetable elements
Semi-lattices and lattices:
JoinSemiLatticefor join semi-latticesMeetSemiLatticefor meet semi-latticesLatticefor lattices
Functions on elements of semi-lattices and lattices
Concrete classes for semi-lattices and lattices
- class Joinable(*args, **kwargs)#
Bases:
PartiallyComparable,ProtocolRepresents joinable elements.
For each pair of elements \((a, b)\), this class defines a unique supremum \(c = a \vee b\) (also called the least upper bound or join).
Example
Consider integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?
>>> from galactic.algebras.lattice.examples.arithmetic.core import PrimeFactors >>> PrimeFactors(24) | PrimeFactors(36) PrimeFactors(72) >>> PrimeFactors(24).join(PrimeFactors(36), PrimeFactors(10)) PrimeFactors(360)
- class Meetable(*args, **kwargs)#
Bases:
PartiallyComparable,ProtocolRepresents meetable elements.
For each pair of elements \((a, b)\), this type defines a unique infimum \(c = a \wedge b\) (also called the greatest lower bound or meet).
Example
Consider integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?
>>> from galactic.algebras.lattice.examples.arithmetic.core import PrimeFactors >>> PrimeFactors(24) & PrimeFactors(36) PrimeFactors(12) >>> PrimeFactors(24).meet(PrimeFactors(36), PrimeFactors(10)) PrimeFactors(2)
- class Element(*args, **kwargs)#
Bases:
Joinable,Meetable,ProtocolRepresents elements that can be members of a lattice.
- class JoinSemiLattice[_J: Joinable](*args, **kwargs)#
Bases:
PartiallyOrderedSet[_J],ProtocolDescribes join semi-lattices.
- __bool__()#
Check whether this join semi-lattice is non-empty.
- Returns:
Whether this join semi-lattice is non-empty
- Return type:
- __eq__(other)#
Check whether this join semi-lattice is equal to another.
- __contains__(elem)#
Check whether an element belongs to this join semi-lattice.
- __iter__()#
Iterate over the elements of this join semi-lattice [1].
- Returns:
An iterator over the elements of this join semi-lattice
- Return type:
Iterator[_J]
- __len__()#
Return the number of elements in this join semi-lattice.
- Returns:
The number of elements in this join semi-lattice
- Return type:
- __lt__(other)#
Check whether this join semi-lattice is less than another.
- Parameters:
other (
object) β The other join semi-lattice- Returns:
Whether this join semi-lattice is less than the other
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __gt__(other)#
Check whether this join semi-lattice is greater than another.
- Parameters:
other (
object) β The other join semi-lattice- Returns:
Whether this join semi-lattice is greater than the other
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __le__(other)#
Check whether this join semi-lattice is less than or equal to another.
- Parameters:
other (
object) β The other join semi-lattice- Returns:
Whether this join semi-lattice is less than or equal to the other
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __ge__(other)#
Check whether this join semi-lattice is greater than or equal to another.
- Parameters:
other (
object) β The other join semi-lattice- Returns:
Whether this join semi-lattice is greater than or equal to the other
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- upper_limit(*limits, strict=False)#
Return the elements less than the given limits.
- Parameters:
*limits (
_J) β The limitsstrict (
bool, default:False) β Whether the comparison is strict
- Returns:
The elements less than the limits
- Return type:
Collection[_J]
- lower_limit(*limits, strict=False)#
Return the elements greater than the given limits.
- Parameters:
*limits (
_J) β The limitsstrict (
bool, default:False) β Whether the comparison is strict
- Returns:
The elements greater than the limits
- Return type:
Collection[_J]
- floor(*limits)#
Return the floor of the given elements.
- Parameters:
*limits (
_J) β The elements for which the floor is requested- Returns:
The floor of the given elements, or None if not found
- Return type:
_J|None
- greatest_join_irreducible(*limits, strict=False)#
Return the greatest join-irreducible elements smaller than the given limits.
- Parameters:
*limits (
_J) β The limitsstrict (
bool, default:False) β Whether the comparison is strict
- Returns:
The greatest join-irreducible elements smaller than the limits
- Return type:
Collection[_J]
- 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: Collection[_J]#
Get the join-irreducible elements.
- Returns:
The join-irreducible elements
- Return type:
Collection[_J]
- Raises:
- class MeetSemiLattice[_M: Meetable](*args, **kwargs)#
Bases:
PartiallyOrderedSet[_M],ProtocolDescribes meet semi-lattices.
- __bool__()#
Check whether this meet semi-lattice is non-empty.
- Returns:
Whether this meet semi-lattice is non-empty
- Return type:
- __eq__(other)#
Check whether this meet semi-lattice is equal to another.
- __contains__(elem)#
Check whether an element belongs to this meet semi-lattice.
- __iter__()#
Iterate over the elements of this meet semi-lattice [1].
- Returns:
An iterator over the elements of this meet semi-lattice
- Return type:
Iterator[_M]
- __len__()#
Return the number of elements in this meet semi-lattice.
- Returns:
The number of elements in this meet semi-lattice
- Return type:
- __lt__(other)#
Check whether this meet semi-lattice is less than another.
- Parameters:
other (
object) β The other meet semi-lattice- Returns:
Whether this meet semi-lattice is less than the other
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __gt__(other)#
Check whether this meet semi-lattice is greater than another.
- Parameters:
other (
object) β The other meet semi-lattice- Returns:
Whether this meet semi-lattice is greater than the other
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __le__(other)#
Check whether this meet semi-lattice is less than or equal to another.
- Parameters:
other (
object) β The other meet semi-lattice- Returns:
Whether this meet semi-lattice is less than or equal to the other
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __ge__(other)#
Check whether this meet semi-lattice is greater than or equal to another.
- Parameters:
other (
object) β The other meet semi-lattice- Returns:
Whether this meet semi-lattice is greater than or equal to the other
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- upper_limit(*limits, strict=False)#
Return the elements less than the given limits.
- Parameters:
*limits (
_M) β The limitsstrict (
bool, default:False) β Whether the comparison is strict
- Returns:
The elements less than the limits
- Return type:
Collection[_M]
- lower_limit(*limits, strict=False)#
Return the elements greater than the given limits.
- Parameters:
*limits (
_M) β The limitsstrict (
bool, default:False) β Whether the comparison is strict
- Returns:
The elements greater than the limits
- Return type:
Collection[_M]
- ceil(*limits)#
Return the ceil of the given elements.
- Parameters:
*limits (
_M) β The elements for which the ceil is requested- Returns:
The ceil of the given elements, or None if not found
- Return type:
_M|None
- smallest_meet_irreducible(*limits, strict=False)#
Return the smallest meet-irreducible elements smaller than the given limits.
- Parameters:
*limits (
_M) β The limitsstrict (
bool, default:False) β Whether the comparison is strict
- Returns:
The smallest meet-irreducible elements greater than the limits
- Return type:
Collection[_M]
- abstract property atoms: Collection[_M]#
Get the co-atoms of this meet semi-lattice.
- Returns:
The atoms
- Return type:
Collection[_M]
- abstract property meet_irreducible: Collection[_M]#
Get the meet-irreducible elements.
- Returns:
The meet-irreducible elements
- Return type:
Collection[_M]
- Raises:
- class Lattice[_E: Element](*args, **kwargs)#
Bases:
JoinSemiLattice[_E],MeetSemiLattice[_E],ProtocolRepresents lattices.
- __eq__(other)#
Check whether this lattice is equal to another collection.
- __contains__(elem)#
Check whether an element belongs to the lattice.
- __iter__()#
Compute the concept lattice using the Close By One algorithm [1].
- Returns:
An iterator over the elements in the lattice
- Return type:
Iterator[_E]
References
Notes
This implementation chooses between attribute and item mode depending on the size of the context for better performance.
- __len__()#
Get the number of elements in the lattice.
- Returns:
The number of elements in the lattice
- Return type:
- __lt__(other)#
Check whether this lattice is a strict subset of another collection.
- Parameters:
other (
object) β A collection of elements- Returns:
True if this lattice is a strict subset of the other collection
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __gt__(other)#
Check whether this lattice is a strict superset of another collection.
- Parameters:
other (
object) β A collection of elements- Returns:
True if this lattice is a strict superset of the other collection
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __le__(other)#
Check whether this lattice is a subset of another collection.
- Parameters:
other (
object) β A collection of elements- Returns:
True if this lattice is a subset of the other collection
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __ge__(other)#
Check whether this lattice is a superset of another collection.
- Parameters:
other (
object) β A collection of elements- Returns:
True if this lattice is a superset of the other collection
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- issubset(other)#
Check whether every element in the lattice is in the other iterable.
- issuperset(other)#
Check whether every element in the other iterable is in the lattice.
- upper_limit(*limits, strict=False)#
Return the elements less than the given limits.
- Parameters:
*limits (
_E) β The limitsstrict (
bool, default:False) β If True, uses strict comparison
- Returns:
The elements less than the limits
- Return type:
Collection[_E]
- lower_limit(*limits, strict=False)#
Return the elements greater than the given limits.
- Parameters:
*limits (
_E) β The limitsstrict (
bool, default:False) β If True, uses strict comparison
- Returns:
The elements greater than the limits
- Return type:
Collection[_E]
- infimum(iterable)#
Compute the infimum of meetable elements.
- Parameters:
iterable (
Iterable[_M]) β An iterable collection of meetable elements- Returns:
The meet of all elements in the iterable
- Return type:
_M- Raises:
ValueError β If the iterable is empty
- infimum_generators(iterable)#
Produce the infimum generators from an iterable of meetable elements.
- Parameters:
iterable (
Iterable[_M]) β The iterable collection of elements- Yields:
_M β An infimum generator
- supremum(iterable)#
Compute the supremum of joinable elements.
- Parameters:
iterable (
Iterable[_J]) β An iterable of joinable elements- Returns:
The supremum of all elements in the iterable
- Return type:
_J- Raises:
ValueError β If the iterable is empty
- supremum_generators(iterable)#
Produce the supremum generators from an iterable of joinable elements.
- Parameters:
iterable (
Iterable[_J]) β An iterable of elements- Yields:
_J β A supremum generator
- class FrozenJoinSemiLattice[_J: Joinable](*elements)#
Bases:
JoinSemiLattice[_J]Represents a concrete join semi-lattice.
An instance stores its irreducible elements in a poset.
Its memory complexity is \(O(j)\).
- Parameters:
*elements (
Iterable[_J]) β The initial elements
Examples
>>> from galactic.algebras.lattice.core import ExtensibleJoinSemiLattice >>> from galactic.algebras.lattice.examples.arithmetic.core import PrimeFactors >>> semi_lattice = ExtensibleJoinSemiLattice[PrimeFactors]( ... [ ... PrimeFactors(2*3*5), ... PrimeFactors(3*5*7), ... PrimeFactors(5*7*11) ... ], ... ) >>> semi_lattice <galactic.algebras.lattice.core.ExtensibleJoinSemiLattice object at 0x...>
You can get the maximum element.
>>> int(semi_lattice.maximum) 2310
You can iterate over the elements.
You can iterate over the co-atoms.
You can iterate over the join-irreducible elements.
You can iterate over the greatest join-irreducible elements smaller than a limit.
You can enlarge a join semi-lattice.
- 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.
- __hash__()#
Return the hash value of the join semi-lattice.
- Returns:
The hash value of the join semi-lattice
- Return type:
Notes
The hash value is computed based on the elements of the join semi-lattice. It is cached after the first computation for efficiency.
- __copy__()#
Create a shallow copy of the join semi-lattice.
- Returns:
The shallow copy of this join semi-lattice
- Return type:
- copy()#
Return a copy of the join semi-lattice.
- Returns:
The copy of this join semi-lattice
- Return type:
- __len__()#
Return the number of elements in this join semi-lattice.
- Returns:
The number of elements in this join semi-lattice
- Return type:
- __or__(other)#
Return the join of this join-semilattice and another.
- Parameters:
other (
object) β Another join-semilattice- Returns:
The join of this join-semilattice and another
- Return type:
Notes
If other is not an instance of Iterable, this method returns NotImplemented.
- __and__(other)#
Return the meet of this join-semilattice and another.
- Parameters:
other (
object) β Another join-semilattice- Returns:
The meet of this join-semilattice and another
- Return type:
Notes
If other is not an instance of Iterable, this method returns NotImplemented.
- join(*others)#
Compute the join of this join-semilattice and others.
- Parameters:
*others (
JoinSemiLattice[_J]) β A sequence of join-semilattice- Returns:
The join of this join-semilattice and others
- Return type:
- meet(*others)#
Compute the meet of this join-semilattice and others.
- Parameters:
*others (
JoinSemiLattice[_J]) β A sequence of join-semilattice- Returns:
The meet of this join-semilattice and others
- Return type:
- property order: Ordering[_J]#
Get the partial order of this join semi-lattice.
- Returns:
The partial order
- Return type:
Ordering[_J]
- property cover: Ordering[_J]#
Get the covering relation of this join semi-lattice.
- Returns:
The covering relation
- Return type:
Ordering[_J]
- property top: Collection[_J]#
Get the top elements.
The collection contains only one element, the maximum element.
- Returns:
The top elements
- Return type:
Collection[_J]
- property bottom: Collection[_J]#
Get the bottom elements.
- Returns:
The bottom elements
- Return type:
Collection[_J]
- filter(elem)#
Return a filter of a join semi-lattice.
- Parameters:
elem (
_J) β The lower limit- Returns:
A view on the lower bounded join semi-lattice
- Return type:
JoinSemiLattice[_J]- Raises:
ValueError β If the element does not belong to the join semi-lattice
- ideal(elem)#
Return an ideal of a join semi-lattice.
- Parameters:
elem (
_J) β The upper limit- Returns:
A view on the upper bounded join semi-lattice
- Return type:
JoinSemiLattice[_J]- Raises:
ValueError β If the element does not belong to the join semi-lattice
- property co_atoms: Collection[_J]#
Get the co-atoms of this join semi-lattice.
- Returns:
The co-atoms
- Return type:
Collection[_J]
- property join_irreducible: Collection[_J]#
Get the join-irreducible elements of this join semi-lattice.
- Returns:
The join-irreducible elements
- Return type:
Collection[_J]
- class FrozenMeetSemiLattice[_M: Meetable](*elements)#
Bases:
MeetSemiLattice[_M]Represents a concrete meet semi-lattice.
An instance stores its irreducible elements in a poset.
Its memory complexity is \(O(m)\).
- Parameters:
*elements (
Iterable[_M]) β The initial elements
Examples
>>> from galactic.algebras.lattice.core import ExtensibleMeetSemiLattice >>> from galactic.algebras.lattice.examples.arithmetic.core import PrimeFactors >>> semi_lattice = ExtensibleMeetSemiLattice[PrimeFactors]( ... [ ... PrimeFactors(2*3*5), ... PrimeFactors(3*5*7), ... PrimeFactors(5*7*11) ... ] ... ) >>> semi_lattice <galactic.algebras.lattice.core.ExtensibleMeetSemiLattice object at 0x...>
You can get the minimum element.
>>> int(semi_lattice.minimum) 5
You can iterate over the elements.
You can iterate over the atoms.
You can iterate over the meet-irreducible elements.
You can iterate over the smallest meet-irreducible elements greater than a limit.
You can enlarge a meet semi-lattice.
- property version: int#
Get the version number.
- Returns:
The version number
- Return type:
Notes
This can be used to detect changes in the semi-lattice.
- __hash__()#
Return the hash value of this meet semi-lattice.
- Returns:
The hash value of this meet semi-lattice
- Return type:
Notes
The hash value is computed based on the elements of the meet semi-lattice. It is cached after the first computation.
- __copy__()#
Return a shallow copy of this meet semi-lattice.
- Returns:
A shallow copy of this meet semi-lattice
- Return type:
- copy()#
Return a copy of this meet semi-lattice.
- Returns:
A copy of this meet semi-lattice
- Return type:
- __len__()#
Return the number of elements in this meet semi-lattice.
- Returns:
The number of elements in this meet semi-lattice
- Return type:
- __or__(other)#
Return the join of this meet-semilattice and another.
- Parameters:
other (
object) β Another meet-semilattice- Returns:
The join of this meet-semilattice and another
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- __and__(other)#
Return the meet of this meet-semilattice and another.
- Parameters:
other (
object) β Another meet-semilattice- Returns:
The meet of this meet-semilattice and another
- Return type:
Notes
If other is not an instance of Collection, this method returns NotImplemented.
- join(*others)#
Return the join of this meet semi-lattice and others.
- Parameters:
*others (
MeetSemiLattice[_M]) β A sequence of meet semi-lattices- Returns:
The join of this meet semi-lattice and the others
- Return type:
- meet(*others)#
Return the meet of this meet semi-lattice and others.
- Parameters:
*others (
MeetSemiLattice[_M]) β A sequence of meet semi-lattices- Returns:
The meet of this meet semi-lattice and the others
- Return type:
- property order: Ordering[_M]#
Get the partial order of this meet semi-lattice.
- Returns:
The partial order
- Return type:
Ordering[_M]
- property cover: Ordering[_M]#
Get the covering relation of this meet semi-lattice.
- Returns:
The covering relation
- Return type:
Ordering[_M]
- property top: Collection[_M]#
Get the top elements.
- Returns:
The top elements
- Return type:
Collection[_M]
- property bottom: Collection[_M]#
Get the bottom elements.
The collection contains only the minimum element.
- Returns:
The bottom elements
- Return type:
Collection[_M]
- filter(elem)#
Return a filter of the meet semi-lattice.
- Parameters:
elem (
_M) β The lower bound- Returns:
A view of the lower bounded meet semi-lattice
- Return type:
MeetSemiLattice[_M]- Raises:
ValueError β If the element does not belong to the meet semi-lattice
- ideal(elem)#
Return an ideal of the meet semi-lattice.
- Parameters:
elem (
_M) β The upper bound- Returns:
A view of the upper bounded meet semi-lattice
- Return type:
MeetSemiLattice[_M]- Raises:
ValueError β If the element does not belong to the meet semi-lattice
- property atoms: Collection[_M]#
Get the atoms of this meet semi-lattice.
- Returns:
The atoms
- Return type:
Collection[_M]
- property meet_irreducible: Collection[_M]#
Get the meet-irreducible elements of this meet semi-lattice.
- Returns:
The meet-irreducible elements
- Return type:
Collection[_M]
- class FrozenLattice[_E: Element](*elements)#
Bases:
Lattice[_E]Represents a frozen lattice.
- Parameters:
*elements (
Iterable[_E]) β The initial elements
- __hash__()#
Get the hash value of the lattice.
- Returns:
The hash value of the lattice
- Return type:
Notes
The hash value is computed based on the smaller of the join-irreducible or meet-irreducible elements for efficiency. It is cached after the first computation.
- __copy__()#
Create a shallow copy of this lattice.
- Returns:
A shallow copy of this lattice
- Return type:
- __len__()#
Get the number of elements in the lattice.
- Returns:
The number of elements in the lattice
- Return type:
- __or__(other)#
Return the union of this lattice and an iterable of elements.
- Parameters:
other (
object) β Another lattice- Returns:
The union of this lattice and the other iterable
- Return type:
Notes
If other is not an instance of Iterable, this method returns NotImplemented.
- __and__(other)#
Return the intersection of this lattice and another.
- Parameters:
other (
object) β Another lattice- Returns:
The intersection of this lattice and the other
- Return type:
Notes
If other is not an instance of Iterable, this method returns NotImplemented.
- join(*others)#
Compute the join of this lattice and others.
- meet(*others)#
Compute the meet of this lattice and others.
- property order: Ordering[_E]#
Get the partial order of this lattice.
- Returns:
The partial order
- Return type:
Ordering[_E]
- property cover: Ordering[_E]#
Get the covering relation of this lattice.
- Returns:
The covering relation
- Return type:
Ordering[_E]
- property top: Collection[_E]#
Get the top elements.
- Returns:
The top elements
- Return type:
Collection[_E]
- property bottom: Collection[_E]#
Get the bottom elements.
- Returns:
The bottom elements
- Return type:
Collection[_E]
- filter(elem)#
Return a filter of the lattice.
- Parameters:
elem (
_E) β The lower bound- Returns:
A view of the lower bounded lattice
- Return type:
Lattice[_E]- Raises:
ValueError β If the element does not belong to the lattice
- ideal(elem)#
Return an ideal of the lattice.
- Parameters:
elem (
_E) β The upper bound- Returns:
A view of the upper bounded lattice
- Return type:
Lattice[_E]- Raises:
ValueError β If the element does not belong to the lattice
- property meet_irreducible: Collection[_E]#
Get the meet-irreducible elements of this lattice.
- Returns:
The meet-irreducible elements
- Return type:
Collection[_E]
- property atoms: Collection[_E]#
Get the atoms of this lattice.
- Returns:
The atoms
- Return type:
Collection[_E]
- property join_irreducible: Collection[_E]#
Get the join-irreducible elements of this lattice.
- Returns:
The join-irreducible 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]
- class ExtensibleJoinSemiLattice[_J: Joinable](*elements)#
Bases:
FrozenJoinSemiLattice[_J]Represents an extensible join semi-lattice.
- class ExtensibleMeetSemiLattice[_M: Meetable](*elements)#
Bases:
FrozenMeetSemiLattice[_M]Represents an extensible meet semi-lattices.
- class ExtensibleLattice[_E: Element](*elements)#
Bases:
FrozenLattice[_E]Represents extensible lattices.
The elements can be iterated from the maximum to the minimum element.
Example
Let the integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?
implemented by the
PrimeFactorsclass:>>> from galactic.algebras.lattice.examples.arithmetic.core import PrimeFactors >>> from galactic.algebras.lattice.core import ExtensibleLattice >>> lattice = ExtensibleLattice[PrimeFactors]( ... [PrimeFactors(2), PrimeFactors(3)], ... ) >>> lattice <galactic.algebras.lattice.core.ExtensibleLattice object at 0x...> >>> list(map(int, lattice)) [1, 3, 2, 6]
- class JoinSemiLatticeView[_J: Joinable](semi_lattice, *, lower=None, upper=None)#
Bases:
JoinSemiLattice[_J]Represents a bounded join semi-lattice.
This class provides a view of a join semi-lattice with specified lower and upper bounds.
- Parameters:
semi_lattice (
JoinSemiLattice[_J]) β The underlying semi-latticelower (
_J|None, default:None) β The lower boundupper (
_J|None, default:None) β The upper bound
- property version: int#
Get the version number of the semi-lattice.
- Returns:
The version number
- Return type:
Notes
This can be used to detect changes in the semi-lattice.
- __len__()#
Return the number of elements in this join semi-lattice.
- Returns:
The number of elements in this join semi-lattice
- Return type:
- property order: Ordering[_J]#
Get the partial order of this join semi-lattice.
- Returns:
The partial order
- Return type:
Ordering[_J]
- property cover: Ordering[_J]#
Get the covering relation of this join semi-lattice.
- Returns:
The covering relation
- Return type:
Ordering[_J]
- property top: Collection[_J]#
Get the top elements.
The collection contains only 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(elem)#
Return a filter of the join semi-lattice.
- Parameters:
elem (
_J) β The lower bound- Returns:
A view of the bounded semi-lattice
- Return type:
JoinSemiLattice[_J]- Raises:
ValueError β If the element does not belong to the semi-lattice
- ideal(elem)#
Return an ideal of the join semi-lattice.
- Parameters:
elem (
_J) β The upper bound- Returns:
A view of the bounded semi-lattice
- Return type:
JoinSemiLattice[_J]- Raises:
ValueError β If the element does not belong to the 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: Collection[_J]#
Get the join-irreducible elements of this join semi-lattice.
- Returns:
The join-irreducible elements
- Return type:
Collection[_J]
- class MeetSemiLatticeView[_M: Meetable](semi_lattice, *, lower=None, upper=None)#
Bases:
MeetSemiLattice[_M]Represents a bounded meet semi-lattice.
This class provides a view of a meet semi-lattice with specified lower and upper bounds.
- Parameters:
semi_lattice (
MeetSemiLattice[_M]) β The underlying semi-latticelower (
_M|None, default:None) β The lower boundupper (
_M|None, default:None) β The upper bound
- property version: int#
Get the version number.
- Returns:
The version number
- Return type:
Notes
This can be used to detect changes in the semi-lattice.
- __len__()#
Return the number of elements in this join semi-lattice.
- Returns:
The number of elements in this join semi-lattice
- Return type:
- property order: Ordering[_M]#
Get the partial order of this meet semi-lattice.
- Returns:
The partial order
- Return type:
Ordering[_M]
- property cover: Ordering[_M]#
Get the covering relation of this meet semi-lattice.
- Returns:
The covering relation
- Return type:
Ordering[_M]
- property top: Collection[_M]#
Get the top elements.
- Returns:
The top elements
- Return type:
Collection[_M]
- property bottom: Collection[_M]#
Get the bottom elements.
The collection contains only the minimum element.
- Returns:
The bottom elements
- Return type:
Collection[_M]
- filter(elem)#
Return a filter of the meet semi-lattice.
- Parameters:
elem (
_M) β The lower bound- Returns:
A view of the lower bounded meet semi-lattice
- Return type:
MeetSemiLattice[_M]- Raises:
ValueError β If the element does not belong to the meet semi-lattice
- ideal(elem)#
Return an ideal of the meet semi-lattice.
- Parameters:
elem (
_M) β The upper bound- Returns:
A view of the upper bounded meet semi-lattice
- Return type:
MeetSemiLattice[_M]- Raises:
ValueError β If the element does not belong to the meet semi-lattice
- property atoms: Collection[_M]#
Get the atoms of this meet semi-lattice.
- Returns:
The atoms
- Return type:
Collection[_M]
- property meet_irreducible: Collection[_M]#
Get the meet-irreducible elements of this meet semi-lattice.
- Returns:
The meet-irreducible elements
- Return type:
Collection[_M]
- class LatticeView[_E: Element](lattice, *, lower=None, upper=None)#
Bases:
Lattice[_E]Represents a view of a lattice using ideal or filter construction.
- Parameters:
- property version: int#
Get the version number.
- Returns:
The version number
- Return type:
Notes
This can be used to detect changes in the lattice.
- __len__()#
Get the number of elements in the lattice view.
- Returns:
The number of elements in the lattice view
- Return type:
- property order: Ordering[_E]#
Get the partial order of this lattice.
- Returns:
The partial order
- Return type:
Ordering[_E]
- property cover: Ordering[_E]#
Get the covering relation of this lattice.
- Returns:
The covering relation
- Return type:
Ordering[_E]
- property top: Collection[_E]#
Get the top elements.
- Returns:
The top elements
- Return type:
Collection[_E]
- property bottom: Collection[_E]#
Get the bottom elements.
- Returns:
The bottom elements
- Return type:
Collection[_E]
- filter(elem)#
Return a filter of the lattice.
- Parameters:
elem (
_E) β The lower bound- Returns:
A view of the lower bounded lattice
- Return type:
Lattice[_E]- Raises:
ValueError β If the element does not belong to the lattice
- ideal(elem)#
Return an ideal of the lattice.
- Parameters:
elem (
_E) β The upper bound- Returns:
A view of the upper bounded lattice
- Return type:
Lattice[_E]- Raises:
ValueError β If the element does not belong to the lattice
- property atoms: Collection[_E]#
Get the atoms of this lattice.
- Returns:
The atoms
- Return type:
Collection[_E]
- property meet_irreducible: Collection[_E]#
Get the meet-irreducible elements of this lattice.
- Returns:
The meet-irreducible 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]
- property join_irreducible: Collection[_E]#
Get the join-irreducible elements of this lattice.
- Returns:
The join-irreducible elements
- Return type:
Collection[_E]
- class LatticeCoveringRelation[_E: Element](lattice)#
Bases:
CoveringRelationMixin[_E]Represents the covering relation of a lattice.
- Parameters:
lattice (
Lattice[_E]) β The lattice
- successors(elem)#
Return the successors of an element.
- Parameters:
elem (
_E) β 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(elem)#
Return the predecessors of an element.
- Parameters:
elem (
_E) β The element whose predecessors are requested- Returns:
The predecessors
- Return type:
Collection[_E]- Raises:
ValueError β If the element does not belong to the lattice
- class ReducedContext[_E: Element](lattice)#
Bases:
EndoRelation[_E]Represents the reduced context of a lattice.
It is a binary relation between the join-irreducible and meet-irreducible elements.
- Parameters:
lattice (
Lattice[_E]) β The lattice
- __contains__(pair)#
Check whether a pair belongs to the reduced context.
- __iter__()#
Iterate over the pairs in the reduced context.
- __len__()#
Get the number of pairs in the reduced context.
- Returns:
The number of pairs in the reduced context
- Return type:
- 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]]
- successors(elem)#
Return the successors of a join-irreducible, i.e. its attributes.
- Parameters:
elem (
_E) β 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(elem)#
Return the predecessors of a meet-irreducible, i.e. its objects.
- Parameters:
elem (
_E) β 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 co-domain of this reduced context