Skip to content

Restrict BV sharing to bit-vector applications - #11851

Draft
Nikolaj Bjorner (NikolajBjorner) wants to merge 2 commits into
masterfrom
copilot/fix-instability-maximizing-bv-sharing
Draft

Nikolaj Bjorner (NikolajBjorner) wants to merge 2 commits into
masterfrom
copilot/fix-instability-maximizing-bv-sharing

Conversation

@NikolajBjorner

@NikolajBjorner Nikolaj Bjorner (NikolajBjorner) commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

The BV-sharing pass matched operator kinds without checking their family. Kind collisions caused it to rebalance Boolean or and arithmetic + applications, affecting solver stability.

  • Family guard: Restrict the BV rewriter to bit-vector-family applications.
  • Regression coverage: Check that Boolean and arithmetic applications remain unchanged while registered BV operators are still rewritten.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@NikolajBjorner Nikolaj Bjorner (NikolajBjorner) changed the title [WIP] Fix instability due to maximizing-bv-sharing pass Restrict BV sharing to bit-vector applications Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

F* NFV audit: proved

Audited head: f342d2b1871b9b6816e4154c332bd6191fafc10c

Partial scope: one changed function (BV family guard in maximize_bv_sharing::reduce_app), 3 obligations proved on a guard-level model; C++ execution not verified. Pre-PR witness (bool or / arith + collide on kind 6) confirmed and removed by the guard.

Download the audit sources, report, and log from the run artifacts; no branch writes were attempted.
Workflow run and downloadable evidence (30-day retention)

F* model

module BvSharingFamilyGuard
(* Model of maximize_ac_sharing::reduce_app guards (maximize_ac_sharing.cpp:30-38)
   and the PR's maximize_bv_sharing::reduce_app family guard (header :110-114).
   Family ids: only distinctness matters. Kind values computed from the enums at base. *)
type family = | Basic | Arith | BV
type decl = { fam: family; kind: nat; assoc: bool }

let registered (k:nat) : bool = k = 4 || k = 6 || k = 31 || k = 30  // OP_BADD,OP_BMUL,OP_BOR,OP_BAND

(* base: reduce_app proceeds past guards iff associative, n>2, kind registered *)
let base_rewrites (d:decl) (n:nat) : bool = d.assoc && n > 2 && registered d.kind
(* head: additionally requires BV family *)
let head_rewrites (d:decl) (n:nat) : bool = d.fam = BV && base_rewrites d n

let bool_or  : decl = { fam = Basic; kind = 6; assoc = true }   // OP_OR = 6
let arith_add: decl = { fam = Arith; kind = 6; assoc = true }   // arith OP_ADD = 6

(* O1: witnesses at base: Boolean or / arithmetic + with 3 args are rewritten *)
let o1a () : Lemma (base_rewrites bool_or 3 = true) = ()
let o1b () : Lemma (base_rewrites arith_add 3 = true) = ()
(* O2: at head they are not *)
let o2 () : Lemma (head_rewrites bool_or 3 = false /\ head_rewrites arith_add 3 = false) = ()
(* O3: head never rewrites non-BV; and for BV decls head agrees with base *)
let o3 (d:decl) (n:nat) : Lemma
  (ensures (d.fam <> BV ==> head_rewrites d n = false) /\ (d.fam = BV ==> head_rewrites d n = base_rewrites d n)) = ()

This is a scoped semantic source audit, not mechanized verification of the C++ implementation or the entire PR.
An inconclusive result or an unproved obligation is not evidence of correctness.

Generated by Fstar NFV PR audit.

@github-actions

Copy link
Copy Markdown
Contributor

Determinism warnings

Warnings in affected files (base 102/1101, PR 102/1101 translation units).

Base: 27 → PR: 27; change: +0.

Base a2cc0c789289; head f342d2b1871b.
Tested the PR merged into its base (fca4ded1bbcc).

Warning type Base PR Change
z3-ast-argument-order 27 27 +0
z3-char-signedness 0 0 +0
z3-random-order 0 0 +0
Warning diff

No warning changes.

CI run and diagnostics

This branch has not been deployed

No deployments
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.

Instability due to maximizing-bv-sharing pass

2 participants