Expand description
Public API for the CoBRA mixed Boolean-arithmetic simplifier.
The package emits both a normal Rust rlib and a Rust dylib. Static
linking remains the default; development builds can select the DLL with
RUSTFLAGS="-C prefer-dynamic" to reduce relinking in consumers.
[dependencies]
cobra = { package = "cobra-mba", version = "0.4" }use cobra::{parse_to_ast, render, simplify_expr, Options};
let parsed = parse_to_ast("(x ^ y) + 2 * (x & y)", 64)?;
let outcome = simplify_expr(&parsed.expr, &parsed.vars, Options::default())?;
let simplified = outcome.expr.as_deref().unwrap_or(&parsed.expr);
assert_eq!(render(simplified, &parsed.vars, 64), "x + y");Re-exports§
pub use crate::core::is_valid_bitwidth;pub use crate::core::CobraError;pub use crate::core::ErrorInfo;pub use crate::core::Result;pub use crate::expression::build_var_support;pub use crate::expression::remap_var_indices;pub use crate::expression::render;pub use crate::expression::Expr;pub use crate::expression::Kind;pub use crate::parser::parse_to_ast;pub use crate::parser::AstResult;pub use crate::parser::MAX_VARIABLES;pub use crate::simplify::simplify;pub use crate::simplify::simplify_expr;pub use crate::simplify::Diagnostic;pub use crate::simplify::Options;pub use crate::simplify::ProofLevel;pub use crate::simplify::SimplifyOutcome;pub use crate::simplify::SimplifyOutcomeKind;pub use crate::simplify::SimplifyTelemetry;pub use crate::simplify::MAX_INPUT_VARS;
Modules§
- core
- Provides the expression IR (
expr), modular arithmetic helpers (arith), compiled stack-machine bytecode (compiled), and a type-erasedEvaluator. Downstream crates (cobra-ir,cobra-passes,cobra-orchestrator, etc.) build on top of these types. - expression
- Expression types and rendering helpers.
- ir
- Intermediate representations for the
CoBRApipeline. - orchestrator
CoBRAworklist scheduler.- parser
CoBRAMBA expression parser.- passes
CoBRAsimplification passes. Each pass is a free function matchingcrate::orchestrator::PassFnplus an applicability predicate matchingcrate::orchestrator::ApplicabilityFn. Registration is done viaPASS_REGISTRY— a'staticslice ofPassDescriptorentries ordered byPassIdvalue.- simd
- Gate kernels operating on 16-lane
u64probe arrays. - simplify
- Simplifier entry points, options, outcomes, and diagnostics.
- verify
- Verifier trait and optional Z3 backend.
Macros§
- cobra_
frame - cobra_
msg - cobra_
plot - cobra_
trace - cobra_
trace_ expr - cobra_
trace_ sig - cobra_
zone - cobra_
zone_ n - cobra_
zone_ text - cobra_
zone_ value
Functions§
- outcome_
expr_ in_ original_ space - Map a finished outcome’s expression back into the caller’s variable namespace.