Skip to main content

Module knowledge

Module knowledge 

Source
Expand description

Compiler knowledge-base rules.

This module contains the data model and runtime helpers used by the active compiler rule system. A knowledge rule describes an ordered match pattern, optional symbolic-parameter conditions, and a rewrite target.

The main layers are:

  • rule: runtime rule structures and structural validation.
  • rule_dsl: parser, loader, lowering, and dumper for .rule files.
  • library: validated rule storage, stable rule ids, metadata, and gate indexes for candidate selection.
  • matcher: adjacent-operation structural matching, binding, condition checks, and target instantiation.
  • rule_equivalence: symbolic and sampling-based equivalence validation.

Transform passes should use RuleLibrary to select candidate rules, then use matcher helpers to bind a specific operation window. Search policy, commutation-aware scans, cost decisions, and circuit patching live outside this module.

Re-exports§

pub use library::RuleId;
pub use library::RuleKind;
pub use library::RuleLibrary;
pub use library::RuleLibraryError;
pub use library::RuleMetadata;
pub use matcher::ConcreteOperationView;
pub use matcher::KnowledgeInstructionKey;
pub use matcher::MatchBindings;
pub use matcher::MatchError;
pub use matcher::MatchedReplacement;
pub use matcher::conditions_hold;
pub use matcher::instantiate_target;
pub use matcher::match_rule_item;
pub use matcher::rule_matches_operations;

Modules§

library
Rule library and indexes for compiler knowledge-base rules.
matcher
Shared structural matcher for compiler knowledge rules.
rule
Runtime model for knowledge-base rewrite rules.
rule_dsl
Rule DSL parser, loader, and dumper for the cqlib compiler.
rule_equivalence
Equivalence validation for knowledge-base rewrite rules.