🔌 Antitone Galois connection#
Classes and functions#
galactic.algebras.connection.core
module
Defines classes for working with antitone Galois connections on powersets:
- 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 connectionthe type
_S
represents the type of the elements of the left part of the antitone Galois connectionthe 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 connectionthe type
_S
represents the type of the elements of the left part of the antitone Galois connectionthe type
_D
represents the type of the closed of the right part of the antitone Galois connectionthe 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 connectionthe type
_S
represents the type of the elements of the left part of the antitone Galois connectionthe type
_D
represents the type of the closed of the right part of the antitone Galois connectionthe 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]]
Examples#
galactic.algebras.connection.examples.numerical
module
Defines example classes for working with antitone finite Galois connections:
- class IntegerConnection(domain, co_domain)#
Bases:
GaloisConnectionMixin
[Divisors
,int
,Multiples
,int
]Represents an antitone Galois connection between divisors and multiples.
- Parameters:
- 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]]
- property co_domain: FrozenFIFOSet[int]#
Get the co-domain.
- Returns:
The co-domain
- Return type:
FrozenFIFOSet[int]
- property domain: FrozenFIFOSet[int]#
Get the domain.
- Returns:
The domain
- Return type:
FrozenFIFOSet[int]
- property polarities: tuple[MultiplePolarity, DivisorPolarity]#
Get the polarities.
- Returns:
The couple of polarities
- Return type:
- class MultiplePolarity(connection)#
Bases:
object
Represents the polarity for multiples.
- Parameters:
connection (
IntegerConnection
) – The antitone Galois connection
- class Divisors(connection, elements=None)#
Bases:
ClosedEnumerableMixin
[int
],Element
Represents the set of divisors of given integers.
- Parameters:
connection (
IntegerConnection
) – An antitone Galois connectionelements (
Iterable
[int
] |None
, default:None
) – An iterable of integers
- Raises:
ValueError – If an element is not in the co-domain
- property closure: AbstractClosure[Divisors, int]#
Get the closure operator.
- Returns:
The closure operator
- Return type:
- equivalence(element)#
Compute the equivalence elements of the given element.
- Parameters:
element (
TypeVar
(_T
)) – The element for which equivalence elements are requested- Returns:
An iterator over the equivalence elements of the element
- Return type:
Iterator[_T]
- join(*others)#
Return the supremum of this element and the given elements.
- Parameters:
*others (
Self
) – The other elements- Returns:
The join of this element and the others
- Return type:
Self
- join_level(generators)#
Compute the level of this element with respect to an iterable of generators.
- join_priority(generators)#
Compute the priority of this element with respect to an iterable of generators.
- meet(*others)#
Return the infimum of this element and the others.
- Parameters:
*others (
Self
) – The other elements- Returns:
The meet of this element and the others
- Return type:
Self
- meet_level(generators)#
Compute the level of this element with respect to an iterable of generators.
- meet_priority(generators)#
Compute the priority of this element with respect to an iterable of generators.
- subsumption(element)#
Compute the elements subsumed by the given element.
- Parameters:
element (
TypeVar
(_T
)) – The element for which subsumed elements are requested- Returns:
An iterator over the subsumed elements of the element
- Return type:
Iterator[_T]
- property support: float#
Compute the support of the closed set.
- Returns:
The support of the closed set
- Return type:
- supsumption(element)#
Compute the elements supsumed by the given element.
Notes
Supsumption is a neologism designating the inverse relation of subsumption.
- Parameters:
element (
TypeVar
(_T
)) – The element for which supsumed elements are requested- Returns:
An iterator over the supsumed elements of the element
- Return type:
Iterator[_T]
- class Multiples(connection, elements=None)#
Bases:
ClosedEnumerableMixin
[int
],Element
Represents the set of multiples of given integers.
- Parameters:
connection (
IntegerConnection
) – The Galois connectionelements (
Iterable
[int
] |None
, default:None
) – An optional iterable of integers
- Raises:
ValueError – If an element is not in the domain
- property closure: AbstractClosure[Multiples, int]#
Get the closure operator.
- Returns:
The closure operator
- Return type:
- equivalence(element)#
Compute the equivalence elements of the given element.
- Parameters:
element (
TypeVar
(_T
)) – The element for which equivalence elements are requested- Returns:
An iterator over the equivalence elements of the element
- Return type:
Iterator[_T]
- join(*others)#
Return the supremum of this element and the given elements.
- Parameters:
*others (
Self
) – The other elements- Returns:
The join of this element and the others
- Return type:
Self
- join_level(generators)#
Compute the level of this element with respect to an iterable of generators.
- join_priority(generators)#
Compute the priority of this element with respect to an iterable of generators.
- meet(*others)#
Return the infimum of this element and the others.
- Parameters:
*others (
Self
) – The other elements- Returns:
The meet of this element and the others
- Return type:
Self
- meet_level(generators)#
Compute the level of this element with respect to an iterable of generators.
- meet_priority(generators)#
Compute the priority of this element with respect to an iterable of generators.
- subsumption(element)#
Compute the elements subsumed by the given element.
- Parameters:
element (
TypeVar
(_T
)) – The element for which subsumed elements are requested- Returns:
An iterator over the subsumed elements of the element
- Return type:
Iterator[_T]
- property support: float#
Compute the support of the closed set.
- Returns:
The support of the closed set
- Return type:
- supsumption(element)#
Compute the elements supsumed by the given element.
Notes
Supsumption is a neologism designating the inverse relation of subsumption.
- Parameters:
element (
TypeVar
(_T
)) – The element for which supsumed elements are requested- Returns:
An iterator over the supsumed elements of the element
- Return type:
Iterator[_T]