engine.rete.compiler

Rule compilation into RETE intermediate representations.

Classes

AlphaConstraint

A constant-position filter used by the alpha side of the network.

CompiledTripleCondition

Normalized triple body condition with explicit alpha constraints and binders.

CompiledPredicateCondition

Normalized predicate condition with explicit binding dependencies.

CompiledRule

Compiler output consumed by RETE network construction.

JoinOptimizer

Construction-time utility for ordering joins in conjunctive rule bodies.

RuleCompiler

Entry point for translating public rule definitions into RETE IR.

Module Contents

class engine.rete.compiler.AlphaConstraint(/, **data: Any)

Bases: pydantic.BaseModel

A constant-position filter used by the alpha side of the network.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

position: Literal['subject', 'predicate', 'object']
value: rdflib.term.Node
class engine.rete.compiler.CompiledTripleCondition(/, **data: Any)

Bases: pydantic.BaseModel

Normalized triple body condition with explicit alpha constraints and binders.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source_index: int
pattern: engine.rules.TriplePattern
constraints: tuple[AlphaConstraint, Ellipsis] = None
bound_variables: tuple[str, Ellipsis] = None
class engine.rete.compiler.CompiledPredicateCondition(/, **data: Any)

Bases: pydantic.BaseModel

Normalized predicate condition with explicit binding dependencies.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source_index: int
predicate: str
arguments: tuple[rdflib.term.Node, Ellipsis] = None
required_variables: tuple[str, Ellipsis] = None
class engine.rete.compiler.CompiledRule(/, **data: Any)

Bases: pydantic.BaseModel

Compiler output consumed by RETE network construction.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

rule_id: engine.proof.RuleId
salience: int = 0
silent: bool = False
bootstrap: bool = False
triple_conditions: tuple[CompiledTripleCondition, Ellipsis] = None
predicate_conditions: tuple[CompiledPredicateCondition, Ellipsis] = None
productions: tuple[engine.rete.consequents.TripleProduction, Ellipsis] = None
callbacks: tuple[engine.rete.consequents.CallbackSchedule, Ellipsis] = None
contradictions: tuple[engine.rete.consequents.ContradictionSchedule, Ellipsis] = None
variables: tuple[str, Ellipsis] = None
class engine.rete.compiler.JoinOptimizer

Construction-time utility for ordering joins in conjunctive rule bodies.

static order_triple_conditions(conditions: tuple[CompiledTripleCondition, Ellipsis]) → tuple[CompiledTripleCondition, Ellipsis]

Order triple joins using simple selectivity heuristics.

More constants are better. Constant predicates are preferred, and constants other than rdf:type are treated as more selective.

class engine.rete.compiler.RuleCompiler

Entry point for translating public rule definitions into RETE IR.

This remains a programmatic rule-definition boundary; no text syntax is implied by this scaffold.

classmethod compile_rule(rule: engine.rules.Rule) → CompiledRule

Translate one public Rule into compiled RETE IR.