📘 Formal convex concepts

📘 Formal convex concepts#

Formal convex concepts are the building blocks of formal concept analysis (FCA), representing the relationships between a set of items and their patterns. In the GALACTIC framework, formal convex concepts are implemented using the Concept class of the galactic.algebras.convex.descriptions.core module, which allows for the creation, manipulation, and analysis of these concepts within a given antitone Galois connection.

Creating convex concepts#

The constructor of the Concept class takes an instance of the GaloisConnection class as input, which defines the context in which the concepts are formed and optionnally an iterable of items or attributes to initialize the concept. When neither items nor attributes are provided, the concept is initialized as the top concept (with full extent and smallest intent).

<galactic.algebras.convex.descriptions.core.Concept object at 0x7ef0183438e0>

The extent and intent of the concept can be accessed using the extent and intent attributes, respectively. They are closed sets of items and attributes within the context of the antitone Galois connection.

display(top.extent, list(top.extent))
display(top.intent, [str(attr) for attr in top.intent])
display(bottom.extent, list(bottom.extent))
display(bottom.intent, [str(attr) for attr in bottom.intent])
<galactic.algebras.convex.descriptions.core.Extent object at 0x7ef0201298c0>
[Item(key=0, value=36),
 Item(key=1, value=48),
 Item(key=2, value=16),
 Item(key=3, value=32)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7ef02010ad00>
['M(int(@),4)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7ef01834ed00>
[]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7ef01834e900>
['⊥']

Operating on concepts#

The Concept class implements the Element protocol of the galactic.algebras.lattice.core module, which also provides methods to create concepts using the join (\(\vee\)) or meet (\(\wedge\)) operators.

concept_1 = Concept(
    connection,
    items=[context.domain[1], context.domain[2]],
)
concept_2 = Concept(
    connection,
    items=[context.domain[0]],
)
join = concept_1 | concept_2
meet = concept_1 & concept_2
display(concept_1.extent, list(concept_1.extent))
display(concept_1.intent, [str(attr) for attr in concept_1.intent])
display(concept_2.extent, list(concept_2.extent))
display(concept_2.intent, [str(attr) for attr in concept_2.intent])
display(concept_2.intent, [str(attr) for attr in concept_2.intent.convexes[0]])
display(meet.extent, list(meet.extent))
display(meet.intent, [str(attr) for attr in meet.intent])
display(join.extent, list(join.extent))
display(join.intent, [str(attr) for attr in join.intent])
display(meet <= join, meet.extent <= join.extent, meet.intent >= join.intent)
<galactic.algebras.convex.descriptions.core.Extent object at 0x7ef01837bb40>
[Item(key=1, value=48), Item(key=2, value=16), Item(key=3, value=32)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7ef01846d740>
['M(int(@),16)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7ef01834eac0>
[Item(key=0, value=36)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7ef018373140>
['M(int(@),4)', 'M(int(@),9)']
<galactic.algebras.convex.descriptions.core.Intent object at 0x7ef018373140>
['M(int(@),4)', 'M(int(@),9)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7ef018380740>
[]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7ef0183807c0>
['⊥']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7ef01837ba80>
[Item(key=0, value=36),
 Item(key=1, value=48),
 Item(key=2, value=16),
 Item(key=3, value=32)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7ef01837c780>
['M(int(@),4)']
True
True
True