📘 Closures and closed sets

📘 Closures and closed sets#

In mathematics, a subset \(C\) of a set \(S\) is said to be closed under a closure operator \(\phi\) on \(S\) if applying the closure operator to \(C\) returns \(C\) itself: \(\phi(C) = C\).

In the GALACTIC framework closed sets are represented as instances of the Closed protocol that provide methods to check for membership and to retrieve the underlying elements of the closed set.

The galactic.algebras.closure.examples.color.core module defines the Colors closure operator (implementing the Closure protocol) that operates on colors represented by the Color elements.

from IPython.display import HTML
from galactic.algebras.closure.examples.color.core import Colors
from galactic.algebras.lattice.examples.color.core import Color
colors = Colors([Color(red=1.0), Color(green=1.0)]) # From black to yellow
display(colors == Colors(colors))  # Closed set
display(colors, *colors, HTML("<br>"))
display(Color(red=1.0), Color(red=1.0) in colors)
display(Color(green=1.0), Color(green=1.0) in colors)
# Elements different from Color(red=1.0) and Color(green=1.0) are in the closed set
display(Color(red=1.0, green=1.0), Color(red=1.0, green=1.0) in colors)
display(Color(red=0.5, green=0.2), Color(red=0.5, green=0.2) in colors)
display(Color(), Color() in colors)
# blue is not in the closed set since it cannot be obtained by mixing red and green
display(Color(blue=1.0), Color(blue=1.0) in colors) # Not in the closed set
True
../_images/e659cd0bc202c6936fd5c879d4001186c7b5383d1d11cde4d12fd05a5d74ddf7.svg ../_images/6887fb67fb49fdc62c78e735bb655666a88a95b019ae8f19f01a4e47da9bab49.svg ../_images/3b72c035f37e08a15cea70cd6d1a1d5ff74423e9551da7c9c5ff9e93933d7e6c.svg

../_images/6491be69d7d159ae476a39a7d7ef090cfbba9453c324b8cfcd245da166de967f.svg
True
../_images/098cf94924edbb5f4a4d7b06b3a10900f87ecb93ac5561402cf29d9755a5a92a.svg
True
../_images/3b72c035f37e08a15cea70cd6d1a1d5ff74423e9551da7c9c5ff9e93933d7e6c.svg
True
../_images/f35d8cb9d6dc600f9b65bf87ff5d4400c5ec4a4e0bbeac63267d26ac7d001490.svg
True
../_images/6887fb67fb49fdc62c78e735bb655666a88a95b019ae8f19f01a4e47da9bab49.svg
True
../_images/9566eda342a924fc672b3f1fbf873b5a9421aa8f8eed6387b566814f17904fff.svg
False