Skip to content

feat: add transfer-to-pbv CLI tool for PBV soundness queries - #91

Draft
bollu wants to merge 1 commit into
mainfrom
bollu/transfer-to-pbv
Draft

feat: add transfer-to-pbv CLI tool for PBV soundness queries#91
bollu wants to merge 1 commit into
mainfrom
bollu/transfer-to-pbv

Conversation

@bollu

@bollu bollu commented Feb 27, 2026

Copy link
Copy Markdown

Summary

  • Adds a new CLI tool transfer-to-pbv that reads a transfer function in the transfer. MLIR dialect (KnownBits abstract domain) and emits a PBV-format (Parametric BitVec) SMT-LIB soundness query
  • Symbolically interprets the transfer function, inlining each SSA value as a PBV expression, then assembles the KnownBits soundness formula with symbolic width k
  • Adds the transfer-to-pbv entry point to pyproject.toml

Details

The generated query checks: for all concrete inputs in the concretization of the abstract inputs, the concrete operation result is in the concretization of the abstract result.

KnownBits concretization: γ(k0, k1) ∋ x iff (x & k0 = 0) ∧ (x & k1 = k1), well-formedness: k0 & k1 = 0.

Supported ops: all transfer. binary/unary bitvec ops, transfer.cmp, transfer.select, transfer.constant, transfer.get_all_ones, transfer.get_bit_width, transfer.smin/smax/umin/umax, and arith.andi/ori/xori on i1.

Unsupported: count/popcount ops raise NotImplementedError (no parametric bitvector equivalent).

Usage:

transfer-to-pbv kb_Xor.mlir --concrete-op bvxor
cat kb_And.mlir | transfer-to-pbv --concrete-op bvand

Test plan

  • transfer-to-pbv kb_Xor.mlir --concrete-op bvxor produces correct PBV formula
  • transfer-to-pbv kb_And.mlir --concrete-op bvand produces correct PBV formula
  • transfer-to-pbv kb_Add.mlir --concrete-op bvadd handles complex ops (constants, shifts)
  • transfer-to-pbv kb_Shl.mlir --concrete-op bvshl handles arith boolean ops
  • Unsupported ops (countl_zero etc.) raise a clear NotImplementedError

🤖 Generated with Claude Code

Adds a new CLI tool `transfer-to-pbv` that reads a transfer function
written in the `transfer.` MLIR dialect (KnownBits abstract domain)
and emits a PBV-format (Parametric BitVec) SMT-LIB query checking its
soundness.

The tool symbolically interprets the transfer function, mapping each
SSA value to an inlined PBV expression string, then assembles the
standard KnownBits soundness formula:

  (assert (not (=>
    (and γ(LHS,IN0) γ(RHS,IN1) well-formedness...)
    (and γ(result, concrete_op(IN0,IN1))...)
  )))

Where γ(k0,k1) ∋ x means `(x & k0 = 0) ∧ (x & k1 = k1)`.

Supported ops: all transfer binary/unary bitvec ops, transfer.cmp,
transfer.select, transfer.constant, transfer.get_all_ones,
transfer.get_bit_width, transfer.smin/smax/umin/umax, and arith
boolean ops (andi/ori/xori) on i1. Count/popcount ops raise
NotImplementedError since they have no parametric bitvector equivalent.

Usage:
  transfer-to-pbv kb_Xor.mlir --concrete-op bvxor
  cat kb_And.mlir | transfer-to-pbv --concrete-op bvand

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bollu
bollu requested a review from math-fehr February 27, 2026 03:06
@bollu

bollu commented Feb 27, 2026

Copy link
Copy Markdown
Author

@math-fehr I'm not sure how to test this, to be honest.

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.

1 participant