You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cd49fea
Browse filesBrowse the repository at this point in the historyBrowse files
Name generated values after what they are instead of #fresh (#477)
Closes#373.
## What changed
Every value the verifier introduces used to be called `#freshN`, so path
conditions, call results and new receivers all looked the same in
Expected/Found and in counterexamples. Each one is now named after where
it comes from:
| Origin | Name shown |
|---|---|
| `if` condition | `#if_condition¹¹` |
| `while`/`for` condition (body and exit) | `#loop_condition¹⁴` |
| `c ? a : b` condition | `#ternary_condition¹⁶` |
| try/catch path (try ran / this catch ran) | `#try_branch¹⁸`,
`#catch_branch²¹` |
| result of a call inside an expression or used as a receiver |
`#read_result²⁸` (method name + `_result`) |
| value read from a field not tracked here (e.g. `a.length`, another
object's field) | `#length_value⁷` (field name + `_value`) |
| receiver of `new T(..).m()` | `#new_Door³⁵` |
| value of an operation that is not encoded (`x == null`, `instanceof`,
bitwise ops) | `#operation_result³⁰` |
| size of `new int[n]` | `#array_length⁴` |
The subclass-contract checks in `AuxHierarchyRefinementsPassage` also
used `#fresh` for the return value and the receiver. They now use the
existing `#ret_N` and `#this_N` names.
How it works: the new `liquidjava.utils.GeneratedNames` builds every
such name as `##<description>_<counter>`. The context counter keeps
names unique. The second `#` keeps them apart from instances of program
variables (`#<variable>_<counter>`), since a Java name can't start with
`#`. Characters that the refinement language's `ID` token doesn't accept
(e.g. `$` in `Map$Entry`, non-ASCII letters in method names) are
replaced by `_`, so the names still parse and work with the SMT
encoding. `GeneratedNames.isGenerated` replaces the old `#fresh_` prefix
checks in three places: the counterexample ordering (`RefinementError`),
unused path-binder removal (`VCBinderSimplification`) and keeping
condition values in context (`RefinementTypeChecker`).
`VariableFormatter` removes one `#` as it does for instances, so
generated names are shown with a single `#` (`#if_condition¹¹`), as
`#fresh` was, and stay distinct from program variables.
## Before / after
From the new fixture `testSuite/classes/generated_names_error`:
```
before: #fresh¹¹ == ready¹⁰ && #fresh¹¹ is not a subtype of a > 0
after: #if_condition¹¹ == ready¹⁰ && #if_condition¹¹ is not a subtype of a > 0
before: #fresh¹⁴ == ready¹² && #fresh¹⁴ == true is not a subtype of a > 0
after: #loop_condition¹⁴ == ready¹² && #loop_condition¹⁴ == true is not a subtype of a > 0
before: #fresh¹⁶ == ready¹⁵ && #fresh¹⁶ == true is not a subtype of a < 0
after: #ternary_condition¹⁶ == ready¹⁵ && #ternary_condition¹⁶ == true is not a subtype of a < 0
before: !#fresh¹⁸ && !#fresh²¹ is not a subtype of a²⁵ > 0
after: !#try_branch¹⁸ && !#catch_branch²¹ is not a subtype of a²⁵ > 0
before: x²⁹ == #fresh²⁸ - 1 is not a subtype of x²⁹ > 0
after: x²⁹ == #read_result²⁸ - 1 is not a subtype of x²⁹ > 0
Counterexample: x²⁹ == 0 && #read_result²⁸ == 1
before: #fresh³² == #fresh³⁰ && #fresh³² && x³³ == 0 is not a subtype of x³³ > 0
after: #if_condition³² == #operation_result³⁰ && #if_condition³² && x³³ == 0 is not a subtype of x³³ > 0
before: found closed(#fresh³⁵) but expected opened(#fresh³⁵)
after: found closed(#new_Door³⁵) but expected opened(#new_Door³⁵)
```
The Found row in the issue's screenshot, `∀#fresh²²⁰ baseline²¹⁶ ||
extended²¹⁷`, becomes `∀#if_condition²²⁰ baseline²¹⁶ || extended²¹⁷`.
## Tests
- New fixture
`liquidjava-example/src/main/java/testSuite/classes/generated_names_error/`
(`GeneratedNames.java`, `Door.java`), one error for each origin that
shows up in a message.
- New `TestGeneratedNames`: one test checking the exact message for each
of those errors (counters stripped); it fails on any missing or extra
error.
- Updated the expected names in `VariableFormatterTest`,
`VCBinderSimplificationTest`, `VCConstraintSimplificationTest`,
`RefinementErrorCounterexampleTest` and `TestCounterexamples`.
- Full suite run locally: 683 tests, 0 failures.
Separately: a call to a method with a refinement contract still gets its
result named `#<method>_N` in `MethodsFunctionsChecker` (shown as
`ready¹⁰` above). That name wasn't a `#fresh` and is left unchanged
here.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/general_checkers/OperationsChecker.java
Copy file name to clipboardExpand all lines: liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/object_checkers/AuxHierarchyRefinementsPassage.java
Copy file name to clipboardExpand all lines: liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/object_checkers/AuxStateHandler.java
0 commit comments