📘 Predicates#
The galactic.algebras.convex.predicates.core module provides the foundation
for creating and evaluating predicates on item data. It defines the
Predicate protocol,
which combines characteristics with truth evaluation logic through an abstract
_truth() method.
Predicates handle imprecision by returning None when truth values cannot
be determined, such as when characteristics return empty lists or exceptions occur
during evaluation.
The module includes basic comparison predicates and a membership predicate for set
containment checks. Each predicate uses a template-based string representation with
the format() mechanism, allowing flexible display of predicates with
their parameters and characteristics.
Special predicates are also provided:
Degenerated(combines multiple predicates using conjunction, requiring all sub-predicates to share the same characteristic space)
Predicates are hashable and comparable based on their characteristics and parameters, enabling efficient storage in sets and use as dictionary keys. They serve as extended attributes in classical Formal Concept Analysis, created on demand to precisely describe groups of items.
from galactic.algebras.concept.core import Item
from galactic.algebras.convex.characteristics.core import Integer
from galactic.algebras.convex.predicates.core import GreaterEqual
characteristic = Integer()
predicate = GreaterEqual((characteristic,), value=10)
display(str(characteristic), str(predicate))
display(
predicate(Item(value=15)),
predicate(Item(value=10)),
predicate(Item(value=0)),
predicate(Item(value=None))
)
'int(@)'
'int(@) ≥ 10'
True
True
False
None