feat: add transfer-to-pbv CLI tool for PBV soundness queries - #91
Draft
bollu wants to merge 1 commit into
Draft
Conversation
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>
Author
|
@math-fehr I'm not sure how to test this, to be honest. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
transfer-to-pbvthat reads a transfer function in thetransfer.MLIR dialect (KnownBits abstract domain) and emits a PBV-format (Parametric BitVec) SMT-LIB soundness queryktransfer-to-pbventry point topyproject.tomlDetails
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) ∋ xiff(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, andarith.andi/ori/xorioni1.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 bvandTest plan
transfer-to-pbv kb_Xor.mlir --concrete-op bvxorproduces correct PBV formulatransfer-to-pbv kb_And.mlir --concrete-op bvandproduces correct PBV formulatransfer-to-pbv kb_Add.mlir --concrete-op bvaddhandles complex ops (constants, shifts)transfer-to-pbv kb_Shl.mlir --concrete-op bvshlhandles arith boolean opsNotImplementedError🤖 Generated with Claude Code