Knowledge Structures and Relations

Surmise relations

A surmise relation (or prerequisite relation) is a partial order on items. If \((a, b)\) is in the relation, then mastering \(a\) is a prerequisite for mastering \(b\).

from knowledgespaces import SurmiseRelation

rel = SurmiseRelation(
    items=["a", "b", "c", "d"],
    relations=[("a", "b"), ("a", "c"), ("b", "d"), ("c", "d")],
)

Transitive closure and Hasse diagram

closure = rel.transitive_closure()   # all implied relations
hasse = closure.transitive_reduction()  # minimal representation

print(closure.levels())  # {'a': 0, 'b': 1, 'c': 1, 'd': 2}
print(hasse.minimal_items())  # {'a'}

The transitive closure adds all transitively implied edges. The transitive reduction (Hasse diagram) keeps only the direct edges.

Knowledge structures

A knowledge structure \(\mathcal{K}\) on a domain \(Q\) is a family of subsets of \(Q\) (called knowledge states) that contains \(\emptyset\) and \(Q\).

from knowledgespaces import KnowledgeStructure

ks = KnowledgeStructure.from_surmise_relation(closure)
print(ks.n_states)  # number of valid states

Structural properties

Property

Meaning

Check

Knowledge space

Closed under \(\cup\)

ks.is_knowledge_space

Closure space

Closed under \(\cap\)

ks.is_closure_space

Well-graded

Every state has a predecessor

ks.is_well_graded

Learning space

Knowledge space + well-graded

ks.is_learning_space

Fringes

For a state \(K\):

  • Inner fringe: items \(q \in K\) such that \(K \setminus \{q\} \in \mathcal{K}\) — the most recently consolidated items.

  • Outer fringe: items \(q \notin K\) such that \(K \cup \{q\} \in \mathcal{K}\) — what the student is ready to learn.

state = frozenset({"a", "b"})
print(ks.outer_fringe(state))  # next learnable items
print(ks.inner_fringe(state))  # most recently consolidated

Base of the space

The base is the minimal generating family under union. Every state in the space can be expressed as a union of base elements.

print(ks.base())

Learning paths

A learning path is a sequence of states from \(\emptyset\) to \(Q\) where each step adds exactly one item:

for path in ks.learning_paths():
    print([set(s) for s in path])