Fix incorrect Boogie generation for equality in pure functions#480
Fix incorrect Boogie generation for equality in pure functions#480andreistefanescu merged 11 commits intomainfrom
Conversation
Pure functions were using direct == and != operators in Boogie, which fails for vectors and other non-extensional types. This fix changes the translation to use $IsEqual functions with proper type suffixes, matching the behavior of non-pure functions. Fixes #462 Co-authored-by: Cosmin Radoi <cos@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect Boogie generation for equality operations in pure functions by using the $IsEqual function instead of direct ==/!= operators, which is necessary for non-extensional types like vectors and tables.
Changes:
- Removed
EqandNeqfrom the simple operator symbol mapping inop_symbol - Added dedicated handling for equality/inequality operations using
boogie_equality_for_typeto generate appropriate$IsEqualfunction calls - Added explanatory comments for the new equality handling logic
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
crates/move-prover-boogie-backend/src/boogie_backend/bytecode_translator.rs
Show resolved
Hide resolved
|
@claude fix build issue |
|
@claude let's try again, let's fix the build issue |
|
Claude finished @andreistefanescu's task in 1m 40s —— View job Build issue fixed ✓
SummaryFixed the type mismatch compilation error at line 2853 in Problem: The Solution: Added The fix has been committed and pushed to the PR branch. --- | |
Add .unwrap() to num_oper to fix type mismatch error where Option<&NumOperation> was passed to bv_flag() which expects &NumOperation. Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>
|
@claude add the tests from the issue as insta tests |
|
Claude finished @andreistefanescu's task in 2m 24s —— View job Tests from issue #462 added ✓
SummaryAdded comprehensive test file
The test demonstrates the fix for issue #462, where pure functions now properly use Note on snapshots: The insta snapshot will be automatically generated when the test runs in CI. The test file is committed and will be executed by the existing test infrastructure at --- | Latest commit |
Tests vector equality and inequality operations in pure functions. These operations should use $IsEqual functions instead of direct == and != operators to properly handle non-extensional types like vectors. Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>
|
@claude add the exact tests from the issue, nothing different. |
|
Claude finished @andreistefanescu's task in 1m 46s —— View job Need exact test code from issue #462I'm unable to access issue #462 to retrieve the exact test code due to permission restrictions. The following commands require approval:
Current situation:
To proceed, please paste the exact Move code from issue #462 that should be in the test file, and I'll replace the current content and commit the changes. |
|
|
Claude finished @andreistefanescu's task in 41s —— View job Test file updated with exact code from issue ✓
SummaryReplaced the test file
The test file is now much simpler (25 lines vs the previous 60 lines) and matches exactly what was requested. |
Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>
|
@claude look at the nearby tests to see the |
|
Claude finished @andreistefanescu's task in 1m 9s —— View job Module structure added ✓
SummaryAdded the required No --- | Latest commit |
Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>
|
you can add |
|
@claude you can add module 0x42::pure_eq; to avoid {}. you also need use statements for requires and ensures, look in other tests |
|
Claude finished @andreistefanescu's task in 1m 18s —— View job Test file format updated ✓
SummaryUpdated Changes made:
The test file now follows the same pattern as other tests in the codebase (e.g., |
- Changed from `module 0x42::pure_functions { ... }` to `module 0x42::pure_eq;`
- Added `use prover::prover::{requires, ensures};` statement
Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>
|
@claude looks ok, please auto-format the code |
|
Claude finished @andreistefanescu's task in 1m 6s —— View job Auto-formatting code
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
This is the final PR Bugbot will review for you during this billing cycle
Your free Bugbot reviews will reset on March 1
Details
Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.
To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.
crates/move-prover-boogie-backend/src/boogie_backend/bytecode_translator.rs
Show resolved
Hide resolved
|
@claude formatting change |
|
Claude finished @andreistefanescu's task in 1m 5s —— View job Formatting change applied ✓
SummaryApplied the requested formatting change to Change: Reformatted the |
Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>
Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>
|
@claude fix build error |
|
Claude finished @andreistefanescu's task in 2m 13s —— View job Build error fixed ✓
SummaryFixed the Rust compilation error at Problem: The code was calling Solution: Split the operation into two steps:
This ensures the value lives long enough for the borrow and the function call. The fix has been committed and pushed to the PR branch. |
The skip_reference() call was creating a temporary value that was being borrowed. Split into two steps: first get the local type, then call skip_reference() on it, to ensure the value lives long enough for the borrow. Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>
|
@claude this is the snap for the test you added |
|
Claude finished @andreistefanescu's task in 43s —— View job Snapshot for issue-462 test added ✓
SummaryCreated and committed the snapshot file for the The snapshot contains the expected output: "Verification successful" This snapshot will be used by the insta test framework to verify that the prover correctly handles equality operations in pure functions for both |
Co-authored-by: Andrei Stefanescu <andreistefanescu@users.noreply.github.com>

Fixes incorrect Boogie generation for equality in pure functions.
Pure functions were using direct
==and!=operators in Boogie, which fails for vectors and other non-extensional types. This fix changes the translation to use$IsEqualfunctions with proper type suffixes, matching the behavior of non-pure functions.Fixes #462
Generated with Claude Code
Note
Medium Risk
Changes pure-function Boogie generation for
==/!=, affecting correctness for non-extensional types (e.g., vectors/tables) and potentially altering proof behavior across specs that rely on pure equality.Overview
Fixes Boogie translation for
#[ext(pure)]functions so==/!=no longer emit Boogie operators, but instead call the type-specialized$IsEqualfunctions (matching non-pure translation) to correctly compare non-extensional types likevector/tables.Adds a regression Move test (
issue-462.move) covering equality onOption<u8>andvector<u8>, with a snapshot asserting successful verification.Written by Cursor Bugbot for commit 37c6b08. This will update automatically on new commits. Configure here.