📘 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 optionally an iterable of items or attributes to initialise the concept. When neither items nor attributes are provided, the concept is initialised as the top concept (with full extent and smallest intent).

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

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 0x7a83d0106b80>
[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 0x7a83d123fd40>
['M(int(@),4)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7a83bbf8c980>
[]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7a83d0214e80>
['⊥']

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 0x7a83bbfa3940>
[Item(key=1, value=48), Item(key=2, value=16), Item(key=3, value=32)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7a83bbf9ff00>
['M(int(@),16)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7a83bbf8c800>
[Item(key=0, value=36)]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7a83bbf9e880>
['M(int(@),4)', 'M(int(@),9)']
<galactic.algebras.convex.descriptions.core.Intent object at 0x7a83bbf9e880>
['M(int(@),4)', 'M(int(@),9)']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7a83bbfb08c0>
[]
<galactic.algebras.convex.descriptions.core.Intent object at 0x7a83bbfb0940>
['⊥']
<galactic.algebras.convex.descriptions.core.Extent object at 0x7a83bbfa3900>
[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 0x7a83bbfae2c0>
['M(int(@),4)']
True
True
True