cprover: only equate bit-compatible reads in axiom field-condition eval#9067
Open
tautschnig wants to merge 1 commit into
Open
cprover: only equate bit-compatible reads in axiom field-condition eval#9067tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR tightens alias checking in axiomst::evaluate_fc by only equating pairs of evaluated addresses when their address expression types match, avoiding conditional casting between incompatible pointer types.
Changes:
- Add an early-continue to skip address pairs whose
type()differs. - Remove
conditional_castofb_it->address()toa_it->address().type()and compare original address expressions directly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5122437 to
e3cecd1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9067 +/- ##
========================================
Coverage 80.68% 80.69%
========================================
Files 1714 1714
Lines 189522 189536 +14
Branches 73 73
========================================
+ Hits 152925 152938 +13
- Misses 36597 36598 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
evaluate_fc() emitted addresses_equal => *a == (a_type)*b for every pair of same-state reads. conditional_cast produces a typecast_exprt, which the solver models as a value conversion, not a bitwise reinterpretation, so this implication is not a true fact about memory whenever the cast is not bit-preserving -- e.g. for reads of differing width (a 4-byte int and a 1-byte char), or for a 32-bit float vs a 32-bit int (where (float)int_val converts numerically), or for aggregates. Emitting it over-constrains the formula and can rule out genuine counterexamples (false proofs). Restrict the equality to pairs where the cast is a bit-preserving reinterpretation: identical read types, or two bit-vector-encoded scalar types (or pointers) of the same statically-known width. Skipping the other pairs only ever removes a constraint, so it is sound. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
e3cecd1 to
459dcca
Compare
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.
What
axiomst::evaluate_fc()emitted, for every pair of same-state reads,where the value is produced by
typecast_exprt::conditional_cast. The solvermodels that
typecast_exprtas a value conversion, not a bitwisereinterpretation, so the implication is not a true fact about memory whenever
the cast is not bit-preserving:
intand a 1-bytecharat thesame address);
floatvs a 32-bitint((float)int_valconverts numerically,e.g.
(float)3 == 3.0f, rather than reinterpreting the bits);For those pairs the emitted equality over-constrains the formula and can rule
out genuine counterexamples, i.e. produce false proofs.
Change
Restrict the equality to pairs where
(a_type)*bis a genuine bit-preservingreinterpretation:
differing only in signedness/qualifiers once they share a type), or
signedbv/unsignedbv/bv/c_bool/c_enum/c_enum_tag) or pointers, and have equal,statically-known width (a two's-complement reinterpretation).
All other pairs (differing width,
float/fixed-point, aggregates, or unknownwidth for differing types) are skipped. Skipping a pair only ever removes a
constraint, so the change is sound.
Testing
This is a solver-internal soundness fix: the field-condition axioms are
emitted in the induction / counterexample-validation layer, and their effect
does not surface in the verification outcome of small standalone programs (I
confirmed that even equating the float/int and int/char pairs does not flip
the result of minimal reproducers). The skip/equate decisions were verified
directly by instrumenting
evaluate_fc.regression/cproverpassesunchanged.