Lattice

Elements

Lattice are a particular case of poset. Their elements have the following properties:

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

Integer example

[1]:
from galactic.examples.arithmetic.algebras import Integer
[2]:
Integer(24) & Integer(18)
[2]:
$6=2^13^1$
[3]:
Integer(24) | Integer(18)
[3]:
$72=2^33^2$

Color example

[4]:
from galactic.examples.color.algebras import Color
[5]:
Color(red=0.8, green=0.5, blue=0.7) \
    & Color(red=0.5, green=1.0, blue=0.9)
[5]:
../../../_images/notebooks_algebras_lattice_notebook_6_0.png
[6]:
Color(red=0.8, green=0.5, blue=0.7) \
    | Color(red=0.5, green=1.0, blue=0.9)
[6]:
../../../_images/notebooks_algebras_lattice_notebook_7_0.png

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.

Integer example

[7]:
from galactic.algebras.lattice.collections import BasicLattice
from galactic.algebras.poset.collections import HasseDiagram
[8]:
integers = [
    Integer(2),
    Integer(3),
    Integer(5),
    Integer(7),
    Integer(9)
]
lattice = BasicLattice(integers)
HasseDiagram(lattice)
[8]:
../../../_images/notebooks_algebras_lattice_notebook_11_0.png
[9]:
display(*lattice)
$2=2^1$
$3=3^1$
$5=5^1$
$6=2^13^1$
$7=7^1$
$9=3^2$
$10=2^15^1$
$42=2^13^17^1$
$45=3^25^1$
$14=2^17^1$
$15=3^15^1$
$18=2^13^2$
$21=3^17^1$
$30=2^13^15^1$
$35=5^17^1$
$315=3^25^17^1$
$63=3^27^1$
$70=2^15^17^1$
$210=2^13^15^17^1$
$90=2^13^25^1$
$105=3^15^17^1$
$630=2^13^25^17^1$
$126=2^13^27^1$
$1$
[10]:
lattice.minimum()
[10]:
$1$
[11]:
lattice.maximum()
[11]:
$630=2^13^25^17^1$
[12]:
display(*lattice.atoms())
$2=2^1$
$3=3^1$
$5=5^1$
$7=7^1$
[13]:
display(*lattice.co_atoms())
$315=3^25^17^1$
$210=2^13^15^17^1$
$90=2^13^25^1$
$126=2^13^27^1$
[14]:
display(*lattice.meet_irreducible())
$315=3^25^17^1$
$70=2^15^17^1$
$210=2^13^15^17^1$
$90=2^13^25^1$
$126=2^13^27^1$
[15]:
display(*lattice.join_irreducible())
$2=2^1$
$3=3^1$
$5=5^1$
$7=7^1$
$9=3^2$
[16]:
display(*lattice.smallest_meet_irreducible(Integer(30)))
$210=2^13^15^17^1$
$90=2^13^25^1$
[17]:
display(*lattice.greatest_join_irreducible(Integer(30)))
$2=2^1$
$3=3^1$
$5=5^1$

Color example

[18]:
from galactic.examples.color.algebras import Color
from galactic.algebras.lattice.collections import CompactLattice
[19]:
lattice = CompactLattice([
    Color(red=1.0, green=0.7, blue=0.5),
    Color(red=0.6, green=1.0, blue=0.1),
    Color(red=0.4, green=0.6, blue=0.7),
    Color(red=1.0, green=0.4, blue=0.3),
])
[20]:
HasseDiagram(lattice)
[20]:
../../../_images/notebooks_algebras_lattice_notebook_24_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\)

Integer example

[21]:
from galactic.algebras.lattice.contexts import ReducedContext
integers = [
    Integer(2),
    Integer(3),
    Integer(5),
    Integer(7),
    Integer(9)
]
lattice = CompactLattice(integers)
context = ReducedContext(lattice)
list(context)
[21]:
[(Integer(2), Integer(70)),
 (Integer(2), Integer(90)),
 (Integer(2), Integer(126)),
 (Integer(2), Integer(210)),
 (Integer(3), Integer(90)),
 (Integer(3), Integer(126)),
 (Integer(3), Integer(210)),
 (Integer(3), Integer(315)),
 (Integer(5), Integer(70)),
 (Integer(5), Integer(90)),
 (Integer(5), Integer(210)),
 (Integer(5), Integer(315)),
 (Integer(7), Integer(70)),
 (Integer(7), Integer(126)),
 (Integer(7), Integer(210)),
 (Integer(7), Integer(315)),
 (Integer(9), Integer(90)),
 (Integer(9), Integer(126)),
 (Integer(9), Integer(315))]
[22]:
context
[22]:

\(70=2^15^17^1\)

\(90=2^13^25^1\)

\(126=2^13^27^1\)

\(210=2^13^15^17^1\)

\(315=3^25^17^1\)

\(2=2^1\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(3=3^1\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(5=5^1\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(7=7^1\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(9=3^2\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)