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 import Integer
[2]:
Integer(24) & Integer(18)
[2]:
[3]:
Integer(24) | Integer(18)
[3]:
Color example
[4]:
from galactic.examples.color import Color
[5]:
color1 = Color(red=0.8, green=0.5, blue=0.7)
color1
[5]:
[6]:
color2 = Color(red=0.5, green=1.0, blue=0.9)
color2
[6]:
[7]:
color1 & color2
[7]:
[8]:
color1 | color2
[8]:
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
[9]:
from galactic.algebras.lattice import (
Lattice,
ReducedContextDiagram
)
from galactic.algebras.poset import HasseDiagram
from galactic.examples.arithmetic import IntegerRenderer
[10]:
integers = [
Integer(2),
Integer(3),
Integer(5),
Integer(7),
Integer(9)
]
lattice = Lattice[Integer](domain=integers)
HasseDiagram[Integer](
lattice,
domain_renderer=IntegerRenderer(
meet_semi_lattice=True,
join_semi_lattice=True,
)
)
[10]:
[11]:
lattice.minimum
[11]:
[12]:
lattice.maximum
[12]:
[13]:
display(*lattice.atoms)
[14]:
display(*lattice.co_atoms)
[15]:
display(*lattice.meet_irreducible)
[16]:
display(*lattice.join_irreducible)
[17]:
display(*lattice.smallest_meet_irreducible(Integer(30)))
[18]:
display(*lattice.greatest_join_irreducible(Integer(30)))
Color example
[19]:
from galactic.examples.color import Color, ColorRenderer
from galactic.algebras.lattice import Lattice
[20]:
color3 = Color(red=1.0, green=0.7, blue=0.5)
color3
[20]:
[21]:
color4 = Color(red=0.6, green=1.0, blue=0.1)
color4
[21]:
[22]:
color5 = Color(red=0.4, green=0.6, blue=0.7)
color5
[22]:
[23]:
lattice = Lattice[Color](
domain = [
color3,
color4,
color5,
]
)
[24]:
HasseDiagram[Color](lattice, domain_renderer=ColorRenderer())
[24]:
[25]:
lattice.extend([
color1
])
[26]:
HasseDiagram[Color](lattice, domain_renderer=ColorRenderer())
[26]:
[27]:
ReducedContextDiagram(
lattice,
domain_renderer=ColorRenderer(),
co_domain_renderer=ColorRenderer(),
)
[27]:
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
[28]:
integers = [
Integer(2),
Integer(3),
Integer(5),
Integer(7),
Integer(9)
]
lattice = Lattice[Integer](domain=integers)
ReducedContextDiagram(
lattice,
domain_renderer=IntegerRenderer(join_irreducible=True),
co_domain_renderer=IntegerRenderer(meet_irreducible=True),
)
[28]:
[29]:
from galactic.algebras.relational import BinaryTable
BinaryTable(
lattice.reduced_context,
domain_renderer=IntegerRenderer(join_irreducible=True),
co_domain_renderer=IntegerRenderer(meet_irreducible=True)
)
[29]:
210 |
126 |
315 |
90 |
70 |
|
---|---|---|---|---|---|
\(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\) |