Skip to main content

Crate cobra

Crate cobra 

Source
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-erased Evaluator. 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 CoBRA pipeline.
orchestrator
CoBRA worklist scheduler.
parser
CoBRA MBA expression parser.
passes
CoBRA simplification passes. Each pass is a free function matching crate::orchestrator::PassFn plus an applicability predicate matching crate::orchestrator::ApplicabilityFn. Registration is done via PASS_REGISTRY — a 'static slice of PassDescriptor entries ordered by PassId value.
simd
Gate kernels operating on 16-lane u64 probe 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.