Finite Lattices

Elements

Finite lattices are a particular case of posets. Their elements have the following properties:

For all \(x, y\) of a poset, there exists a unique infimum and a unique supremum:

PrimeFactors example

[2]:
[2]:
$6=2·3$
[3]:
[3]:
$72=2^3·3^2$

Color example

[5]:
color1 = Color(red=0.8, green=0.5, blue=0.7)
color1
[5]:
../../../_images/notebooks_algebras_lattice_notebook_6_0.svg
[6]:
color2 = Color(red=0.5, green=1.0, blue=0.9)
color2
[6]:
../../../_images/notebooks_algebras_lattice_notebook_7_0.svg
[7]:
[7]:
../../../_images/notebooks_algebras_lattice_notebook_8_0.svg
[8]:
[8]:
../../../_images/notebooks_algebras_lattice_notebook_9_0.svg

Collections

All operations on poset are available and some extras features:

  • get the minimum and maximum elements from a lattice;

  • get the atoms and the co-atoms elements from a lattice;

  • get the meet-irreducible and the join-irreducible elements from a lattice;

  • get the meet-irreducible generators and the join-irreducible generators of an element of the lattice.

PrimeFactors example

[9]:
from galactic.algebras.examples.arithmetic.renderer import PrimeFactorsRenderer
from galactic.algebras.lattice import ExtensibleFiniteLattice
from galactic.algebras.lattice.renderer import ReducedContextDiagram
from galactic.algebras.poset.renderer import HasseDiagram
[10]:
integers = [
    PrimeFactors(2),
    PrimeFactors(3),
    PrimeFactors(5),
    PrimeFactors(7),
    PrimeFactors(9),
]
lattice = ExtensibleFiniteLattice[PrimeFactors](elements=integers)
HasseDiagram[PrimeFactors](
    lattice,
    domain_renderer=PrimeFactorsRenderer(
        meet_semi_lattice=True,
        join_semi_lattice=True,
    ),
)
[10]:
../../../_images/notebooks_algebras_lattice_notebook_13_0.png
[11]:
lattice.minimum
[11]:
$1$
[12]:
lattice.maximum
[12]:
$630=2·3^2·5·7$
[13]:
display(*lattice.atoms)
$3=3$
$7=7$
$2=2$
$5=5$
[14]:
display(*lattice.co_atoms)
$315=3^2·5·7$
$126=2·3^2·7$
$90=2·3^2·5$
$210=2·3·5·7$
[15]:
display(*lattice.meet_irreducible)
$70=2·5·7$
$210=2·3·5·7$
$90=2·3^2·5$
$126=2·3^2·7$
$315=3^2·5·7$
[16]:
display(*lattice.join_irreducible)
$3=3$
$9=3^2$
$7=7$
$2=2$
$5=5$
[17]:
display(*lattice.smallest_meet_irreducible(PrimeFactors(30)))
$210=2·3·5·7$
$90=2·3^2·5$
[18]:
display(*lattice.greatest_join_irreducible(PrimeFactors(30)))
$3=3$
$2=2$
$5=5$

Color example

[20]:
color3 = Color(red=1.0, green=0.7, blue=0.5)
color3
[20]:
../../../_images/notebooks_algebras_lattice_notebook_24_0.svg
[21]:
color4 = Color(red=0.6, green=1.0, blue=0.1)
color4
[21]:
../../../_images/notebooks_algebras_lattice_notebook_25_0.svg
[22]:
color5 = Color(red=0.4, green=0.6, blue=0.7)
color5
[22]:
../../../_images/notebooks_algebras_lattice_notebook_26_0.svg
[23]:
lattice = ExtensibleFiniteLattice[Color](
    elements=[
        color3,
        color4,
        color5,
    ],
)
[24]:
HasseDiagram[Color](lattice, domain_renderer=ColorRenderer())
[24]:
../../../_images/notebooks_algebras_lattice_notebook_28_0.png
[25]:
lattice.extend([color1])
[26]:
HasseDiagram[Color](lattice, domain_renderer=ColorRenderer())
[26]:
../../../_images/notebooks_algebras_lattice_notebook_30_0.png
[27]:
ReducedContextDiagram(
    lattice,
    domain_renderer=ColorRenderer(),
    co_domain_renderer=ColorRenderer(),
)
[27]:
../../../_images/notebooks_algebras_lattice_notebook_31_0.png

Context

There exists a bijection between a lattice and its minimal binary table called its equivalent context:

  • the rows are composed by the meet-irreducible

  • the columns are composed by the join-irreducible

  • the boolean value for row \(i\) and column \(j\) is True if \(i\geq j\)

PrimeFactors example

[28]:
integers = [
    PrimeFactors(2),
    PrimeFactors(3),
    PrimeFactors(5),
    PrimeFactors(7),
    PrimeFactors(9),
]
lattice = ExtensibleFiniteLattice[PrimeFactors](elements=integers)
ReducedContextDiagram(
    lattice,
    domain_renderer=PrimeFactorsRenderer(join_irreducible=True),
    co_domain_renderer=PrimeFactorsRenderer(meet_irreducible=True),
)
[28]:
../../../_images/notebooks_algebras_lattice_notebook_33_0.png
[29]:
from galactic.algebras.relational.renderer import BinaryTable

BinaryTable(
    lattice.reduced_context,
    domain_renderer=PrimeFactorsRenderer(join_irreducible=True),
    co_domain_renderer=PrimeFactorsRenderer(meet_irreducible=True),
)
[29]:
70 210 90 126 315
$3=3$ $\checkmark$ $\checkmark$ $\checkmark$ $\checkmark$
$9=3^2$ $\checkmark$ $\checkmark$ $\checkmark$
$7=7$ $\checkmark$ $\checkmark$ $\checkmark$ $\checkmark$
$2=2$ $\checkmark$ $\checkmark$ $\checkmark$ $\checkmark$
$5=5$ $\checkmark$ $\checkmark$ $\checkmark$ $\checkmark$