Skip to content

Refactor asserting/Asserting to use in syntax and remove function definitions#47

Closed
jcp19 wants to merge 2 commits into
mainfrom
claude/amazing-mccarthy-y1ro1r
Closed

Refactor asserting/Asserting to use in syntax and remove function definitions#47
jcp19 wants to merge 2 commits into
mainfrom
claude/amazing-mccarthy-y1ro1r

Conversation

@jcp19

@jcp19 jcp19 commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR refactors the asserting/Asserting helper functions across the codebase to use Gobra's in expression syntax instead of let bindings, and removes the now-redundant function definitions from utility modules.

Key Changes

  • Syntax modernization: Converted all asserting(condition) calls from let _ := asserting(...) patterns to asserting (...) in expressions, which is more idiomatic in Gobra

  • Return type consistency: Added explicit in Unit{} returns where needed to ensure proper type alignment with the new syntax

  • Function removal: Deleted deprecated asserting/Asserting function definitions from:

    • util/util.gobra
    • evaluation/experiments/standard_library/util/util.gobra
    • refinementguard/util.gobra
    • Multiple program proof example files (full.gobra, last_half.gobra, first_half.gobra, minimal.gobra)
  • Whitespace normalization: Added consistent spacing around asserting calls (e.g., asserting (...) instead of asserting(...))

Files Modified

  • resalgebra/product.gobra - Multiple asserting calls refactored
  • resalgebra/ra.gobra - Asserting calls in query functions updated
  • resalgebra/loc.gobra - Frame lemma asserting calls refactored
  • refinementguard/lii.gobra - Asserting calls converted to in syntax
  • dicts/dicts.gobra - Dictionary operation asserting calls updated
  • seqs/seqs.gobra - Sequence operation asserting calls updated
  • sets/sets.gobra - Set operation asserting calls updated
  • Multiple evaluation/experiments files with similar refactoring
  • Utility modules with function definition removals

Implementation Details

The refactoring maintains semantic equivalence while improving code clarity. The in syntax is more explicit about the scope and sequencing of assertions within proof expressions, making the code easier to read and maintain.

https://claude.ai/code/session_01PwdWmKZjxyysaGtdgYU5La

claude added 2 commits June 14, 2026 12:27
Delete all pure helper functions named asserting/Asserting and rewrite
every usage with Gobra's built-in asserting expression
(asserting <assertion> in <expression>), introduced in
viperproject/gobra#1036.
Remove the parentheses around the assertion of an asserting expression
when the assertion is simple enough that removal is unambiguous (keeping
them only for quantified or let-bearing assertions). Also place the
synthesized Unit/util.Unit return value on its own line.
jcp19 pushed a commit that referenced this pull request Jul 4, 2026
Gobra now supports `asserting <cond> in <expr>` natively
(viperproject/gobra#1036), so replace calls to the Asserting helper
functions with asserting expressions and drop the definitions that are
no longer used (refinementguard, resalgebra, and the
program_proofs_example_10_2 experiments). This adopts the rewrites from
PR #47.

The one exception (which made PR #47's CI fail with termination errors
at dicts.gobra:117) is the fact established inside dicts' `Remove`:
`Union`'s termination proof needs `ys intersection domain(d) == ys` to
be available when Remove's body is inlined at the recursive call sites,
which works with the `util.Asserting` call but not with an `asserting`
expression. Keep `util.Asserting` there (and in the two evaluation
copies of dicts), and hence keep its definition in both util packages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KscwsNqoA4o7nkNjcLbGCB
@jcp19 jcp19 closed this Jul 4, 2026
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.

2 participants