Concept lattice

A population can be created using a collection of python objects:

[1]:
from galactic.population import Population
individuals = {48: 48, 36: 36, 64: 64, 56:56, 84: 84}
population = Population(individuals)
population
[1]:
<galactic.population.Population at 0x7f7b387c0440>
[2]:
list(population)
[2]:
['48', '36', '64', '56', '84']

A lattice can be created from a population using a set of strategies:

[3]:
from galactic.algebras.poset import HasseDiagram, IterativeDiagram
from galactic.concepts import (
    ConceptRenderer,
    ConceptLattice,
    ConceptClosure,
    Concept
)
from galactic.examples.arithmetic import (
    MultipleDescription,
    DivisorDescription
)
descriptions = [MultipleDescription(), DivisorDescription()]
closure = ConceptClosure(population, descriptions)
concept = Concept(closure)
concept
[3]:

Predicates:

  • M(4)

  • D(4032)

Individuals:

  • 48

  • 36

  • 64

  • 56

  • 84

[4]:
from galactic.examples.arithmetic import (
    MultipleStrategy,
    DivisorStrategy
)
lattice = ConceptLattice.create(
    population,
    descriptions,
    [DivisorStrategy()]
)
[5]:
lattice.global_entropy
[5]:
4.077819531114783
[6]:
lattice.global_stability
[6]:
0.28125
[7]:
lattice.global_logarithmic_stability
[7]:
0.05928469016817753
[8]:
lattice.global_information
[8]:
20.389097655573917
[9]:
list(str(concept) for concept in lattice.domain)
[9]:
['M(4) and D(4032)',
 'M(4) and D(1008)',
 'M(4) and D(1344)',
 'M(4) and D(576)',
 'M(4) and D(504)',
 'M(4) and D(336)',
 'M(12) and D(144)',
 'M(8) and D(448)',
 'M(16) and D(192)',
 'M(12) and D(252)',
 'M(28) and D(168)',
 'M(48) and D(48)',
 'M(36) and D(36)',
 'M(64) and D(64)',
 'M(56) and D(56)',
 'M(84) and D(84)',
 'M(0) and D(1)']
[10]:
for diagram in IterativeDiagram(lattice, domain_renderer=ConceptRenderer()):
    display(diagram)
../../_images/notebooks_concepts_notebook_12_0.png
../../_images/notebooks_concepts_notebook_12_1.png
../../_images/notebooks_concepts_notebook_12_2.png
../../_images/notebooks_concepts_notebook_12_3.png
../../_images/notebooks_concepts_notebook_12_4.png
../../_images/notebooks_concepts_notebook_12_5.png
../../_images/notebooks_concepts_notebook_12_6.png
../../_images/notebooks_concepts_notebook_12_7.png
../../_images/notebooks_concepts_notebook_12_8.png
../../_images/notebooks_concepts_notebook_12_9.png
../../_images/notebooks_concepts_notebook_12_10.png
../../_images/notebooks_concepts_notebook_12_11.png
../../_images/notebooks_concepts_notebook_12_12.png
../../_images/notebooks_concepts_notebook_12_13.png
../../_images/notebooks_concepts_notebook_12_14.png
../../_images/notebooks_concepts_notebook_12_15.png
../../_images/notebooks_concepts_notebook_12_16.png
../../_images/notebooks_concepts_notebook_12_17.png
../../_images/notebooks_concepts_notebook_12_18.png
[11]:
lattice.apply([MultipleStrategy()])
HasseDiagram(lattice, domain_renderer=ConceptRenderer())
[11]:
../../_images/notebooks_concepts_notebook_13_0.png
[12]:
from galactic.concepts import ConceptTable
ConceptTable(lattice)
[12]:

Concept

Individuals

Predicates

0

M(4)D(4032)

1

D(1008)

2

D(1344)

3

D(576)

4

M(12)

5

D(504)

6

D(336)

7

M(8)

8

D(144)

9

M(16)D(192)

10

D(252)

12

M(28)D(168)

14

D(448)

15

48

M(48)D(48)

16

36

M(36)D(36)

17

64

M(64)D(64)

18

84

M(84)D(84)

19

56

M(56)D(56)

20

M(0)D(1)

[13]:
ConceptTable(lattice,all_individuals=True, all_predicates=True)
[13]:

Concept

Individuals

Predicates

0

['48', '36', '64', '56', '84']

M(4)D(4032)

1

['48', '36', '56', '84']

M(4)D(1008)

2

['48', '64', '56', '84']

M(4)D(1344)

3

['48', '36', '64']

M(4)D(576)

4

['48', '36', '84']

M(12)D(1008)

5

['36', '56', '84']

M(4)D(504)

6

['48', '56', '84']

M(4)D(336)

7

['48', '64', '56']

M(8)D(1344)

8

['48', '36']

M(12)D(144)

9

['48', '64']

M(16)D(192)

10

['36', '84']

M(12)D(252)

11

['48', '84']

M(12)D(336)

12

['56', '84']

M(28)D(168)

13

['48', '56']

M(8)D(336)

14

['64', '56']

M(8)D(448)

15

48

M(48)D(48)

16

36

M(36)D(36)

17

64

M(64)D(64)

18

84

M(84)D(84)

19

56

M(56)D(56)

20

M(0)D(1)

[14]:
display(*lattice.domain)

Predicates:

  • M(4)

  • D(4032)

Individuals:

  • 48

  • 36

  • 64

  • 56

  • 84

Predicates:

  • M(4)

  • D(1008)

Individuals:

  • 48

  • 36

  • 56

  • 84

Predicates:

  • M(4)

  • D(1344)

Individuals:

  • 48

  • 64

  • 56

  • 84

Predicates:

  • M(4)

  • D(576)

Individuals:

  • 48

  • 36

  • 64

Predicates:

  • M(12)

  • D(1008)

Individuals:

  • 48

  • 36

  • 84

Predicates:

  • M(4)

  • D(504)

Individuals:

  • 36

  • 56

  • 84

Predicates:

  • M(4)

  • D(336)

Individuals:

  • 48

  • 56

  • 84

Predicates:

  • M(8)

  • D(1344)

Individuals:

  • 48

  • 64

  • 56

Predicates:

  • M(12)

  • D(144)

Individuals:

  • 48

  • 36

Predicates:

  • M(16)

  • D(192)

Individuals:

  • 48

  • 64

Predicates:

  • M(12)

  • D(252)

Individuals:

  • 36

  • 84

Predicates:

  • M(12)

  • D(336)

Individuals:

  • 48

  • 84

Predicates:

  • M(28)

  • D(168)

Individuals:

  • 56

  • 84

Predicates:

  • M(8)

  • D(336)

Individuals:

  • 48

  • 56

Predicates:

  • M(8)

  • D(448)

Individuals:

  • 64

  • 56

Predicates:

  • M(48)

  • D(48)

Individuals:

  • 48

Predicates:

  • M(36)

  • D(36)

Individuals:

  • 36

Predicates:

  • M(64)

  • D(64)

Individuals:

  • 64

Predicates:

  • M(84)

  • D(84)

Individuals:

  • 84

Predicates:

  • M(56)

  • D(56)

Individuals:

  • 56

Predicates:

  • M(0)

  • D(1)

Individuals:

Reduced context

[15]:
from galactic.algebras.lattice import ReducedContextDiagram
ReducedContextDiagram(
    lattice,
    domain_renderer=ConceptRenderer(join_irreducible=True),
    co_domain_renderer=ConceptRenderer(meet_irreducible=True)
)
[15]:
../../_images/notebooks_concepts_notebook_18_0.png
[16]:
from galactic.algebras.relational import BinaryTable
BinaryTable(
    lattice.reduced_context,
    domain_renderer=ConceptRenderer(join_irreducible=True),
    co_domain_renderer=ConceptRenderer(meet_irreducible=True),
)
[16]:

@0

@1

@2

@3

@4

@5

@6

48

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

36

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

56

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

64

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

84

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)

\(\checkmark\)