πŸ“˜ Antitone Galois connections

πŸ“˜ Antitone Galois connections#

Antitone Galois connections are a fundamental concept in order theory and lattice theory, establishing a relationship between two partially ordered sets (posets) through a pair of antitone functions that are adjoint to each other.

In the GALACTIC framework, antitone Galois connections are implemented using specific classes and methods.

Closure operators#

The GaloisConnection class from the galactic.algebras.concept.core module represents an antitone Galois connection between two posets (parts of two universes). It provides methods to create and manipulate antitone Galois connections, as well as to compute the associated closure operators.

from galactic.algebras.concept.core import (
    GaloisConnection,
    create_context_from_dataset
)
from galactic.algebras.concept.examples.animals.core import ANIMAL_ATTRS, ANIMAL_DATA
context = create_context_from_dataset(ANIMAL_DATA, ANIMAL_ATTRS)
connection = GaloisConnection(context)
display(connection, connection.polarities, connection.closures, connection.context)
<galactic.algebras.concept.core.GaloisConnection object at 0x7c9eecba6440>
(<galactic.algebras.concept.core.AttrPolarity object at 0x7c9ed7f53f10>,
 <galactic.algebras.concept.core.ItemPolarity object at 0x7c9ed7f53f40>)
(compose(<galactic.algebras.concept.core.ItemPolarity object at 0x7c9ed7f53f40>, <galactic.algebras.concept.core.AttrPolarity object at 0x7c9ed7f53f10>),
 compose(<galactic.algebras.concept.core.AttrPolarity object at 0x7c9ed7f53f10>, <galactic.algebras.concept.core.ItemPolarity object at 0x7c9ed7f53f40>))
<galactic.algebras.concept.core.Context object at 0x7c9eecb6d990>

The closures operators can be accessed using the closures attribute of the GaloisConnection instance. These operators allow for the computation of the closure of a collection of items or attributes within the context of the antitone Galois connection.

item_closure = connection.closures[0]
attr_closure = connection.closures[1]
display(item_closure, attr_closure)
closed_items = item_closure(
    [
        context.domain.item(key='Cat'),
        context.domain.item(key='Dog'),
    ],
)
display(closed_items, list(closed_items), len(closed_items))
closed_attrs = attr_closure(
    [
        context.co_domain.attr(name='feathers'),
    ],
)
display(closed_attrs, list(closed_attrs), len(closed_attrs))
compose(<galactic.algebras.concept.core.ItemPolarity object at 0x7c9ed7f53f40>, <galactic.algebras.concept.core.AttrPolarity object at 0x7c9ed7f53f10>)
compose(<galactic.algebras.concept.core.AttrPolarity object at 0x7c9ed7f53f10>, <galactic.algebras.concept.core.ItemPolarity object at 0x7c9ed7f53f40>)
<galactic.algebras.concept.core.Extent object at 0x7c9ed7f2b3c0>
[Item(key='Fox', value=<tuple object at 0x7c9ed7f6ccc0>),
 Item(key='Dog', value=<tuple object at 0x7c9eecb6e340>),
 Item(key='Wolf', value=<tuple object at 0x7c9eecb3cb80>),
 Item(key='Cat', value=<tuple object at 0x7c9ed7f6cd10>),
 Item(key='Tiger', value=<tuple object at 0x7c9ed7f6cd60>),
 Item(key='Lion', value=<tuple object at 0x7c9ed7f35a80>),
 Item(key='Horse', value=<tuple object at 0x7c9ed7f373a0>),
 Item(key='Zebra', value=<tuple object at 0x7c9ed7f373a0>)]
8
<galactic.algebras.concept.core.Intent object at 0x7c9eecb7db40>
[<function twolegs at 0x7c9ed7f5a840>, <function feathers at 0x7c9ed7f5a020>]
2

Closed sets of items and attributes#

The application of the closure operators demonstrates how the antitone Galois connection can be used to derive closed sets of items and attributes based on the relationships defined in the context. The first closure operation computes the closure of the items β€œCat” and β€œDog”, resulting in a closed set that includes all items sharing the same attributes using the Extent class. The second closure operation computes the closure of the attribute β€œfeathers”, resulting in a closed set of attributes that are common to all items possessing that attribute using the Intent class.

The Extent and Intent classes implement the Closed protocol from the galactic.algebras.closure.core module, providing a structured way to represent closed sets of items and attributes within the framework of antitone Galois connections.

from galactic.algebras.concept.core import Intent, Extent
extent_1 = Extent(
    connection,
    [context.co_domain.attr(name='feathers')],
)
extent_2 = Extent(
    connection,
    [context.co_domain.attr(name='medium')],
)
join = extent_1 | extent_2
meet = extent_1 & extent_2
display(extent_1, list(extent_1), len(extent_1))
display(extent_2, list(extent_2), len(extent_2))
display(join, list(join), len(join))
display(meet, list(meet), len(meet))
<galactic.algebras.concept.core.Extent object at 0x7c9ed7f91580>
[Item(key='Dove', value=<tuple object at 0x7c9eecb6e2a0>),
 Item(key='Hen', value=<tuple object at 0x7c9eecb8d380>),
 Item(key='Duck', value=<tuple object at 0x7c9ed7f6cbd0>),
 Item(key='Goose', value=<tuple object at 0x7c9ed7f6cbd0>),
 Item(key='Owl', value=<tuple object at 0x7c9ed7f6cc20>),
 Item(key='Hawk', value=<tuple object at 0x7c9ed7f6cc20>),
 Item(key='Eagle', value=<tuple object at 0x7c9ed7f6cc70>)]
7
<galactic.algebras.concept.core.Extent object at 0x7c9ed7f916c0>
[Item(key='Eagle', value=<tuple object at 0x7c9ed7f6cc70>),
 Item(key='Fox', value=<tuple object at 0x7c9ed7f6ccc0>),
 Item(key='Dog', value=<tuple object at 0x7c9eecb6e340>),
 Item(key='Wolf', value=<tuple object at 0x7c9eecb3cb80>)]
4
<galactic.algebras.concept.core.Extent object at 0x7c9eecbd7480>
[Item(key='Dove', value=<tuple object at 0x7c9eecb6e2a0>),
 Item(key='Hen', value=<tuple object at 0x7c9eecb8d380>),
 Item(key='Duck', value=<tuple object at 0x7c9ed7f6cbd0>),
 Item(key='Goose', value=<tuple object at 0x7c9ed7f6cbd0>),
 Item(key='Owl', value=<tuple object at 0x7c9ed7f6cc20>),
 Item(key='Hawk', value=<tuple object at 0x7c9ed7f6cc20>),
 Item(key='Eagle', value=<tuple object at 0x7c9ed7f6cc70>),
 Item(key='Fox', value=<tuple object at 0x7c9ed7f6ccc0>),
 Item(key='Dog', value=<tuple object at 0x7c9eecb6e340>),
 Item(key='Wolf', value=<tuple object at 0x7c9eecb3cb80>),
 Item(key='Cat', value=<tuple object at 0x7c9ed7f6cd10>),
 Item(key='Tiger', value=<tuple object at 0x7c9ed7f6cd60>),
 Item(key='Lion', value=<tuple object at 0x7c9ed7f35a80>),
 Item(key='Horse', value=<tuple object at 0x7c9ed7f373a0>),
 Item(key='Zebra', value=<tuple object at 0x7c9ed7f373a0>),
 Item(key='Cow', value=<tuple object at 0x7c9ed7f6c9a0>)]
16
<galactic.algebras.concept.core.Extent object at 0x7c9ed7f91a80>
[Item(key='Eagle', value=<tuple object at 0x7c9ed7f6cc70>)]
1
intent_1 = Intent(
    connection,
    [context.domain.item(key='Zebra')],
)
intent_2 = Intent(
    connection,
    [context.domain.item(key='Wolf')],
)
join = intent_1 | intent_2
meet = intent_1 & intent_2
display(intent_1, list(intent_1), len(intent_1))
display(intent_2, list(intent_2), len(intent_2))
display(join, list(join), len(join))
display(meet, list(meet), len(meet))
<galactic.algebras.concept.core.Intent object at 0x7c9ed7f933c0>
[<function big at 0x7c9ed7f5a480>,
 <function fourlegs at 0x7c9ed7f5ac00>,
 <function hair at 0x7c9ed7f5afc0>,
 <function run at 0x7c9ed7f5be20>,
 <function mane at 0x7c9ed7f785e0>,
 <function hooves at 0x7c9ed7f789a0>]
6
<galactic.algebras.concept.core.Intent object at 0x7c9ed7f91f40>
[<function medium at 0x7c9ed7f5a340>,
 <function fourlegs at 0x7c9ed7f5ac00>,
 <function hair at 0x7c9ed7f5afc0>,
 <function run at 0x7c9ed7f5be20>,
 <function hunt at 0x7c9ed7f78220>,
 <function mane at 0x7c9ed7f785e0>]
6
<galactic.algebras.concept.core.Intent object at 0x7c9efe2ceb40>
[<function small at 0x7c9ed7f58ae0>,
 <function medium at 0x7c9ed7f5a340>,
 <function big at 0x7c9ed7f5a480>,
 <function twolegs at 0x7c9ed7f5a840>,
 <function fourlegs at 0x7c9ed7f5ac00>,
 <function hair at 0x7c9ed7f5afc0>,
 <function feathers at 0x7c9ed7f5a020>,
 <function fly at 0x7c9ed7f5b6a0>,
 <function swim at 0x7c9ed7f5ba60>,
 <function run at 0x7c9ed7f5be20>,
 <function hunt at 0x7c9ed7f78220>,
 <function mane at 0x7c9ed7f785e0>,
 <function hooves at 0x7c9ed7f789a0>]
13
<galactic.algebras.concept.core.Intent object at 0x7c9ed7f92600>
[<function fourlegs at 0x7c9ed7f5ac00>,
 <function hair at 0x7c9ed7f5afc0>,
 <function run at 0x7c9ed7f5be20>,
 <function mane at 0x7c9ed7f785e0>]
4

Iterable given in arguments to constructors can be any iterable including instance of the other closed set class (in that case, the operation is optimized since intents and extents are represented by bitmaps).

extent_from_intent = Extent(
    connection,
    intent_1,
)
display(extent_from_intent, list(extent_from_intent), len(extent_from_intent))
intent_from_extent = Intent(
    connection,
    extent_1,
)
display(intent_from_extent, list(intent_from_extent), len(intent_from_extent))
<galactic.algebras.concept.core.Extent object at 0x7c9ed7f93f00>
[Item(key='Horse', value=<tuple object at 0x7c9ed7f373a0>),
 Item(key='Zebra', value=<tuple object at 0x7c9ed7f373a0>)]
2
<galactic.algebras.concept.core.Intent object at 0x7c9ed7f92e00>
[<function twolegs at 0x7c9ed7f5a840>, <function feathers at 0x7c9ed7f5a020>]
2