galactic.algebras.connection.core#

galactic.algebras.connection.core module

Defines classes for working with antitone Galois connections on power sets:

class AbstractPolarity(*args, **kwargs)#

Bases: Protocol[_C, _S, _D]

Represents polarities for antitone Galois connections.

  • the type _C represents the type of the closed of the left part of the antitone Galois connection

  • the type _S represents the type of the elements of the left part of the antitone Galois connection

  • the type _D represents the type of the closed of the right part of the antitone Galois connection

abstractmethod __call__(*others, elements=None)#

Compute the correspondence for the given closed sets or elements.

Parameters:
Returns:

The corresponding closed set

Return type:

_D

Raises:

NotImplementedError – If the method is not implemented

class AbstractGaloisConnection(*args, **kwargs)#

Bases: Protocol[_C, _S, _D, _T]

Represents antitone Galois connections.

  • the type _C represents the type of the closed of the left part of the antitone Galois connection

  • the type _S represents the type of the elements of the left part of the antitone Galois connection

  • the type _D represents the type of the closed of the right part of the antitone Galois connection

  • the type _T represents the type of the elements of the right part of the antitone Galois connection

Examples

>>> from galactic.algebras.connection.examples.numerical import IntegerConnection
>>> connection = IntegerConnection(
...     [2, 3, 4, 5, 6],
...     [10, 12, 18, 24, 36, 48, 30, 60],
... )
>>> polarities = connection.polarities
>>> list(polarities[0](elements=[2, 3, 4]))
[12, 24, 36, 48, 60]
>>> list(polarities[1](polarities[0](elements=[2, 3, 4])))
[2, 3, 4, 6]
>>> list(polarities[1]([30]))
[2, 3, 5, 6]
>>> list(polarities[0](polarities[1](elements=[30])))
[30, 60]
>>> list(polarities[1]([10]))
[2, 5]
>>> list(polarities[0](polarities[1](elements=[10])))
[10, 30, 60]
>>> closures = connection.closures
>>> list(closures[0](elements=[2, 3]))
[2, 3, 6]
>>> list(closures[1](elements=[30]))
[30, 60]
abstract property closures: tuple[AbstractClosure[_C, _S], AbstractClosure[_D, _T]]#

Get the closures of the Galois connection.

Returns:

The pair of closure operators

Return type:

tuple[AbstractClosure[_C, _S], AbstractClosure[_D, _T]]

Raises:

NotImplementedError – If the method is not implemented

abstract property polarities: tuple[AbstractPolarity[_C, _S, _D], AbstractPolarity[_D, _T, _C]]#

Get the polarities of the Galois connection.

Returns:

The pair of polarities

Return type:

tuple[AbstractPolarity[_C, _S, _D], AbstractPolarity[_D, _T, _C]]

Raises:

NotImplementedError – If the method is not implemented

class GaloisConnectionMixin#

Bases: Generic[_C, _S, _D, _T]

Represents antitone Galois connections.

  • the type _C represents the type of the closed of the left part of the antitone Galois connection

  • the type _S represents the type of the elements of the left part of the antitone Galois connection

  • the type _D represents the type of the closed of the right part of the antitone Galois connection

  • the type _T represents the type of the elements of the right part of the antitone Galois connection

Examples

>>> from galactic.algebras.connection.examples.numerical import IntegerConnection
>>> connection = IntegerConnection(
...     [2, 3, 4, 5, 6],
...     [10, 12, 18, 24, 36, 48, 30, 60],
... )
>>> polarities = connection.polarities
>>> list(polarities[0](elements=[2, 3, 4]))
[12, 24, 36, 48, 60]
>>> list(polarities[1](polarities[0](elements=[2, 3, 4])))
[2, 3, 4, 6]
>>> list(polarities[1]([30]))
[2, 3, 5, 6]
>>> list(polarities[0](polarities[1](elements=[30])))
[30, 60]
>>> list(polarities[1]([10]))
[2, 5]
>>> list(polarities[0](polarities[1](elements=[10])))
[10, 30, 60]
>>> closures = connection.closures
>>> list(closures[0](elements=[2, 3]))
[2, 3, 6]
>>> list(closures[1](elements=[30]))
[30, 60]
property closures: tuple[AbstractClosure[_C, _S], AbstractClosure[_D, _T]]#

Get the closures of the Galois connection.

Returns:

The pair of closure operators

Return type:

tuple[AbstractClosure[_C, _S], AbstractClosure[_D, _T]]