Implicational system

[1]:
from galactic.rules import HasseDiagramOrderedBasis, CanonicalDirectBasis
from galactic.rules import RuleTable
from galactic.population import Population
from galactic.characteristics import Key
from galactic.examples.arithmetic import (
    MultipleStrategy,
    DivisorStrategy,
    MultipleDescription,
    DivisorDescription,
    Integer,
)

individuals = [{"x": 48, "y": 15}, {"x": 36, "y": 3}, {"x": 64, "y": 10}]
population = Population(individuals)
strategies = [
    MultipleStrategy(Integer(Key(name="x"))),
    DivisorStrategy(Integer(Key(name="x"))),
    MultipleStrategy(Integer(Key(name="y"))),
    DivisorStrategy(Integer(Key(name="y"))),
]
descriptions = [
    MultipleDescription(Integer(Key(name="x"))),
    DivisorDescription(Integer(Key(name="x"))),
    MultipleDescription(Integer(Key(name="y"))),
    DivisorDescription(Integer(Key(name="y"))),
]
[2]:
from galactic.algebras.poset import HasseDiagram
from galactic.concepts import ConceptRenderer, ConceptLattice

lattice = ConceptLattice(population=population, descriptions=descriptions)
lattice.apply(strategies)
[3]:
HasseDiagram(lattice, domain_renderer=ConceptRenderer())
[3]:
../../_images/notebooks_rules_notebook_3_0.png
[4]:
display(*lattice.domain)

Predicates:

  • M(x,4)

  • D(x,576)

  • D(y,30)

Individuals:

  • 0

  • 1

  • 2

Predicates:

  • M(x,16)

  • D(x,192)

  • M(y,5)

  • D(y,30)

Individuals:

  • 0

  • 2

Predicates:

  • M(x,12)

  • D(x,144)

  • M(y,3)

  • D(y,15)

Individuals:

  • 0

  • 1

Predicates:

  • M(x,64)

  • D(x,64)

  • M(y,10)

  • D(y,10)

Individuals:

  • 2

Predicates:

  • M(x,48)

  • D(x,48)

  • M(y,15)

  • D(y,15)

Individuals:

  • 0

Predicates:

  • M(x,36)

  • D(x,36)

  • M(y,3)

  • D(y,3)

Individuals:

  • 1

Predicates:

  • M(x,0)

  • D(x,1)

  • M(y,0)

  • D(y,1)

Individuals:

[5]:
RuleTable(HasseDiagramOrderedBasis(lattice=lattice), support=0.0)
[5]:

Premises

Conclusions

Support

Confidence

$0

1

1

$0

M(x,4)D(x,576)D(y,30)

1

1

M(x,16)

$1

0.666667

1

D(x,192)

$1

0.666667

1

M(y,5)

$1

0.666667

1

$1

M(x,16)D(x,192)M(y,5)D(y,30)

0.666667

1

M(x,12)

$2

0.666667

1

D(x,144)

$2

0.666667

1

M(y,3)

$2

0.666667

1

D(y,15)

$2

0.666667

1

$2

M(x,12)D(x,144)M(y,3)D(y,15)

0.666667

1

M(x,64)

$3

0.333333

1

D(x,64)

$3

0.333333

1

M(y,10)

$3

0.333333

1

D(y,10)

$3

0.333333

1

$3

M(x,64)D(x,64)M(y,10)D(y,10)

0.333333

1

$1$2

$4

0.333333

1

$4

M(x,48)D(x,48)M(y,15)D(y,15)

0.333333

1

M(x,36)

$5

0.333333

1

D(x,36)

$5

0.333333

1

D(y,3)

$5

0.333333

1

$5

M(x,36)D(x,36)M(y,3)D(y,3)

0.333333

1

[6]:
RuleTable(CanonicalDirectBasis(lattice=lattice), support=0.0)
[6]:

Premises

Conclusions

Support

Confidence

M(x,4)D(x,576)D(y,30)

1

1

M(x,16)

D(x,192)M(y,5)D(y,30)

0.666667

1

D(x,192)

M(x,16)M(y,5)D(y,30)

0.666667

1

M(y,5)

M(x,16)D(x,192)D(y,30)

0.666667

1

M(x,12)

D(x,144)M(y,3)D(y,15)

0.666667

1

D(x,144)

M(x,12)M(y,3)D(y,15)

0.666667

1

M(y,3)

M(x,12)D(x,144)D(y,15)

0.666667

1

D(y,15)

M(x,12)D(x,144)M(y,3)

0.666667

1

M(x,64)

D(x,64)M(y,10)D(y,10)

0.333333

1

D(x,64)

M(x,64)M(y,10)D(y,10)

0.333333

1

M(y,10)

M(x,64)D(x,64)D(y,10)

0.333333

1

D(y,10)

M(x,64)D(x,64)M(y,10)

0.333333

1

M(x,36)

D(x,36)M(y,3)D(y,3)

0.333333

1

D(x,36)

M(x,36)M(y,3)D(y,3)

0.333333

1

D(y,3)

M(x,36)D(x,36)M(y,3)

0.333333

1