Elements¶
This module defines essential type for representing lattice elements.
-
class
galactic.algebras.lattice.elements.
Joinable
¶ Bases:
galactic.algebras.poset.elements.PartiallyOrdered
The
Joinable
type sets for each pair of elements a, b an unique supremum c = a | b (also called a least upper bound or join).A class implementing the
Joinable
abstract class must be declared by inheriting fromJoinable
with itself as a parameter and must implement the methods:__lt__()
__gt__()
__eq__()
Example
Let the integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?
implemented by the
Integer
class:>>> from galactic.examples.arithmetic.algebras import Integer >>> Integer(24) | Integer(36) Integer(72) >>> Integer(24).union(Integer(36), Integer(10)) Integer(360)
-
abstract
__or__
(other)¶ Return the join of this element and the other.
- Parameters
other – the other element
- Returns
the join of this element and the other
- Return type
-
union
(*args) → galactic.algebras.lattice.elements.Joinable¶ Returns the union of this element and the others.
-
class
galactic.algebras.lattice.elements.
Meetable
¶ Bases:
galactic.algebras.poset.elements.PartiallyOrdered
The
Meetable
type sets for each pair of elements a, b an unique infimum c = a & b (also called a greatest lower bound or meet).A class implementing the
Meetable
abstract class must be declared by inheriting fromMeetable
with itself as a parameter and must implement the methods:__lt__()
__gt__()
__eq__()
Example
Let the integers ordered by the relation \(a \leq b\): is \(a\) a divisor of \(b\)?
implemented by the
Integer
class:>>> from galactic.examples.arithmetic.algebras import Integer >>> Integer(24) & Integer(36) Integer(12) >>> Integer(24).intersection(Integer(36), Integer(10)) Integer(2)
-
abstract
__and__
(other)¶ Return the meet of this element and the other.
- Parameters
other – the other element
- Returns
the meet of this element and the other
- Return type
-
intersection
(*args) → galactic.algebras.lattice.elements.Meetable¶ Returns the intersection of this element and the others.
-
class
galactic.algebras.lattice.elements.
Element
¶ Bases:
galactic.algebras.lattice.elements.Meetable
,galactic.algebras.lattice.elements.Joinable
The
Element
class describes elements that can be member of a lattice.
-
galactic.algebras.lattice.elements.
infimum
(iterable: Iterable[galactic.algebras.lattice.elements.Meetable] = None, default=None) → galactic.algebras.lattice.elements.Meetable¶ Computes the infimum of meetable elements.
- Keyword Arguments
iterable (
Iterable[Meetable]
) – An iterable collection of meetable elements.default – The default value when the iterable is empty.
- Returns
- Return type
The intersection of all elements from the iterable collection.
-
galactic.algebras.lattice.elements.
supremum
(iterable: Iterable[galactic.algebras.lattice.elements.Joinable] = None, default=None) → galactic.algebras.lattice.elements.Joinable¶ Computes the supremum of joinable elements.
- Keyword Arguments
iterable (
Iterable[joinable]
) – An iterable collection of joinable elements.default – The default value when the iterable is empty.
- Returns
- Return type
The union of all elements from the iterable collection.
-
galactic.algebras.lattice.elements.
supremum_generators
(iterable: Iterable[galactic.algebras.lattice.elements.Joinable] = None) → Iterator[galactic.algebras.lattice.elements.Joinable]¶ The
supremum_generators()
function produces the supremum generators from an iterable of joinable elements.- Keyword Arguments
iterable (
Iterable[Joinable]
) – The iterable collection of elements.- Returns
An iterator over the supremum generators.
- Return type
-
galactic.algebras.lattice.elements.
infimum_generators
(iterable: Iterable[galactic.algebras.lattice.elements.Meetable] = None) → Iterator[galactic.algebras.lattice.elements.Meetable]¶ The
infimum_generators()
function produces the infimum generators from an iterable of meetable elements.- Keyword Arguments
iterable (
Iterable[Meetable]
) – The iterable collection of elements.- Returns
An iterator over the infimum generators.
- Return type