📘 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 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)])
display(colors == Colors(colors)) # Closed set
display(list(colors))
display(Color(red=1.0) in colors)
display(Color(green=1.0) in colors)
display(Color(blue=1.0) in colors) # Not in the closed set
# 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) in colors)
display(Color(red=0.5, green=0.2) in colors)
display(Color() in colors)
True
[Color(), Color(red=1, green=1)]
True
True
False
True
True
True