Antitone Galois connection

The galactic.algebras.connection module.

It defines several classes for dealing with antitone Galois connection defined on powersets:

class AbstractPolarity(*args, **kwargs)

Bases: Protocol[_C, _S, _D]

It 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;

abstract __call__(*others, elements=None)

Call this instance.

Parameters:
Returns:

The correspondence of the arguments.

Return type:

_D

Raises:

NotImplementedError

class AbstractGaloisConnection(*args, **kwargs)

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

It 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.examples.connection 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 polarities: tuple[AbstractPolarity[_C, _S, _D], AbstractPolarity[_D, _T, _C]]

Get the polarities.

Returns:

The polarities.

Return type:

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

Raises:

NotImplementedError

abstract property closures: tuple[AbstractClosure[_C, _S], AbstractClosure[_D, _T]]

Get the closures.

Returns:

The closures.

Return type:

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

Raises:

NotImplementedError

class GaloisConnectionMixin

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

It 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.examples.connection 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.

Returns:

The closures.

Return type:

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