engine.rete_factory

Factory for constructing per-context RETE engine instances.

Classes

RETEEngineFactoryConfig

Explicit per-context RETE engine assembly configuration.

RETEEngineFactory

Factory for per-context RETE engine instances.

Module Contents

class engine.rete_factory.RETEEngineFactoryConfig

Explicit per-context RETE engine assembly configuration.

This configuration is supplied to RETEEngineFactory and specifies the template for new engines. It is used to create a new engine for each context.

Parameters:
  • rules – The common ruleset applied to all engines.

  • contradiction_recorder_factory – The factory to use to create a new contradiction recorder for each context. Recorders are shared iff the same instance is always returned by this factory.

  • derivation_logger_factory – The factory to use to create a new derivation logger for each context. Loggers are shared iff the same instance is always returned by this factory.

  • builtins – The builtins (predicates / callbacks) to use for new engines. These are shared across all engines and are generally assumed to be stateless.

  • literal_subject_policy – The literal subject policy to use for the engine.

  • predicate_term_policy – The predicate term policy to use for the engine.

rules: collections.abc.Sequence[engine.rules.Rule]
contradiction_recorder_factory: collections.abc.Callable[[axiom.common.ContextIdentifier], engine.derivation.ContradictionRecorder]
derivation_logger_factory: collections.abc.Callable[[axiom.common.ContextIdentifier], engine.derivation.DerivationLogger]
builtins: engine.builtins.Builtins
literal_subject_policy: engine.rete_engine.LiteralSubjectPolicy
predicate_term_policy: engine.rete_engine.PredicateTermPolicy
class engine.rete_factory.RETEEngineFactory(*, config: RETEEngineFactoryConfig)

Factory for per-context RETE engine instances.

This factory is used by RETEStore to lazily create new RETE engines for each context (read: graph) whenever they are needed.

Parameters:

config – The configuration for the factory. This configuration will be reused for each new engine.

config: RETEEngineFactoryConfig
property rules_template: collections.abc.Sequence[engine.rules.Rule]

Return the shared rules applied to every engine created by this factory.

new_engine(context: axiom.common.ContextIdentifier) → engine.rete_engine.RETEEngine

Create a fresh RETE engine bound to context.