Skip to main content

Module rules

Module rules 

Source
Expand description

Rule-based commutation oracle.

This module extracts exact two-operation commutation rules from the compiler knowledge library. A rule is accepted by this oracle only when its source and target are the same two operations in swapped order, i.e. an explicit A; B -> B; A proof. Matching is structural: instruction identity, a one-to-one qubit binding, symbolic parameter bindings, and rule conditions must all agree.

§Examples

use cqlib_core::circuit::{Instruction, Parameter, Qubit, StandardGate};
use cqlib_core::compile::commutation::{Commutation, CommutationChecker};

let checker = CommutationChecker::builtin();
let result = checker.check(
    &Instruction::Standard(StandardGate::CX),
    &[Qubit::new(0), Qubit::new(1)],
    &[],
    &Instruction::Standard(StandardGate::RZ),
    &[Qubit::new(0)],
    &[Parameter::symbol("theta")],
);

assert_eq!(result, Some(Commutation::Exact));

Structs§

RuleCommutationOracle
Compiled commutation rules loaded from the compiler knowledge library.