Skip to content

Add CoBRA simplifier backend and simplify chain composition - #7

Open
mrexodia wants to merge 5 commits into
masterfrom
claude/cobra-backend-integration-47w1tm
Open

Add CoBRA simplifier backend and simplify chain composition#7
mrexodia wants to merge 5 commits into
masterfrom
claude/cobra-backend-integration-47w1tm

Conversation

@mrexodia

Copy link
Copy Markdown
Contributor

Summary

This PR adds a new CoBRA-based simplifier backend to the SMT server and introduces a simplify chain mechanism for composing multiple simplifier backends in sequence.

Key Changes

  • New CoBRA Backend (cobra_backend.rs): Implements a simplifier backend built on CoBRA, a worklist-driven mixed Boolean-arithmetic (MBA) simplifier. The backend:

    • Identifies maximal MBA islands in expressions and simplifies them in place
    • Preserves non-MBA structural skeleton verbatim
    • Supports two modes: certified (requires Lean certificate) and spot-checked (also accepts probe-verified rewrites)
    • Handles boundary variables for non-MBA subtrees and width mismatches
    • Limits processing to bit-vectors up to 64 bits wide
  • Simplify Chain Backend (simplify_chain.rs): Enables sequential composition of simplifier backends where:

    • Each stage processes the output of the previous stage
    • Stages that decline (return UNKNOWN, error, or produce invalid artifacts) are skipped
    • Allows complementary simplifiers to work together (e.g., Rumba for linear MBA, then CoBRA for deeper optimization)
  • Integration: Updated library exports and main server configuration to include the new backends

  • Tests (cobra_simplify.rs): Comprehensive test suite covering:

    • Certified MBA identity simplification
    • Narrow-width simplification
    • Nested MBA islands under structural operators
    • Preservation of non-MBA boundary subtrees
    • Boundary name collision handling
    • Unimproved island skeleton preservation
    • Chain composition with Rumba backend

Implementation Details

  • Island conversion abstracts non-MBA/wrong-width subtrees as opaque boundary variables that map back to recursively-simplified subtrees during lowering
  • Synthetic boundary variable names use __cobra_boundary prefix with underscore disambiguation to avoid collisions with real variables
  • Shift operations by constant amounts stay within islands; shifts by expressions become boundaries
  • Subtraction is converted to addition with negation for CoBRA's binary tree representation
  • All structural failures gracefully fall back to identity simplification (returning input unchanged)

https://claude.ai/code/session_015FYCZ18U7J69pBs3QxKoGG

claude added 2 commits August 24, 2026 22:06
Add a CobraBackend built on the cobra-mba crate (binsnake/cobra), using
the same maximal-island extraction as the Rumba backend: the structural
skeleton of the target expression is copied verbatim while each maximal
same-width MBA island is handed to CoBRA's worklist pipeline, with
non-MBA subtrees abstracted as opaque boundary variables. Logical
right-shifts by a constant amount convert into islands as well.

By default the backend only adopts rewrites CoBRA backs with a
replayable Lean certificate, declining everything weaker (including the
probe-verified side paths), so unsupported islands fall back to a
structural copy. A spot-checked constructor trades that guarantee for a
higher simplification rate on non-adversarial inputs.

A new SimplifyChainBackend composes simplifiers by feeding each stage
the previous stage's output and skipping stages that decline; the
shipped server now routes SIMPLIFY through Rumba then CoBRA.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015FYCZ18U7J69pBs3QxKoGG
CI runs clippy from the latest stable toolchain (1.98), whose new
chunks_exact_to_as_chunks lint rejects the constant-size chunks_exact
call in parse_annotation and fails the workspace-wide -D warnings gate
on every run. Use as_chunks::<2>() as the lint suggests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015FYCZ18U7J69pBs3QxKoGG

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be9d03ed20

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/smt-server/src/simplify_chain.rs Outdated
A cancelled request previously broke out of the stage loop and returned
the last good block as a conclusive SIMPLIFIED result. Follow the
backend cancellation convention instead: any observed cancellation
yields an inconclusive UNKNOWN, so a racing layer never adopts a
vacuous identity simplification from a cancelled chain.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015FYCZ18U7J69pBs3QxKoGG

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3673f7b4b1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/smt-server/src/simplify_chain.rs
The pre-stage cancellation check has no next iteration to run after the
last stage, so cancellation arriving mid-flight in that stage was
swallowed and the chain still answered with the last good block as a
conclusive SIMPLIFIED result. Re-check the context after the stage loop
and return the inconclusive cancellation result there too.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015FYCZ18U7J69pBs3QxKoGG

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9141605097

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/smt-server/src/cobra_backend.rs
A declined maximal island was retried on every nested subtree, and the
tree conversion re-expands shared wire DAG nodes on each visit, so an
adversarial unsimplifiable expression could turn one bounded request
into quadratic (or, through sharing, exponential) conversion work with
unbounded repeat runs of CoBRA's search pipeline. Give each request a
node-visit budget shared across all island attempts, sized from the
input's node count; once spent, remaining islands are copied
structurally.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015FYCZ18U7J69pBs3QxKoGG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants