Repository navigation
Show a counterexample for state errors, restricted to the shown Found - #527
CatarinaGamboa wants to merge 2 commits into
Conversation
A state refinement error now shows the values a model of what is known where the call fails gives the variables of the found the message shows. Values found already states, generated names and ghost or state values are left out, so A1_09 shows previousMode == BORDERLESS and an error about states alone shows none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex review, round 1
Soundness prompt: a program whose model assignment is real but irrelevant. Both arms violate Fixed in "Show no state counterexample when every value fails the call". Before asking for a model, one solver check asks whether Found ⇒ ¬Expected. If it holds, no value lets the call through, and there is no counterexample.
Tests: 729 run, 0 failures. |
Clean-code reviewI audited the diff with the clean-code-principles checklist. Fixed:
Declined:
|
Codex review, round 2
Soundness prompt: no case printed a state or ghost value, named a variable missing from Found, or gave a value outside a model of Found ∧ ¬Expected. It reported one redundant value: Found entails Declined. The value is real and part of a model, so the line is sound. The filter drops only values Found states as This ends the Codex loop for this PR: nothing relevant is left. |
Closes #522, part 4 of 5: counterexample for state errors. Design: #522 (comment)
State refinement errors had no counterexample. Now, when a state error is reported, one more solver call asks for a model of Found ∧ ¬Expected. It is the same VC, with the same context gathering, as the failed check. The model is shown restricted as S2 asks.
What is shown
Only the assignments to variables of the Found the headline shows. Left out:
display(host) = 1: a state is an unconstrained number (S3);#…);T!val!n);x == calready states (RefinementError.isKnown, reused).If the headline shows no Found (
expected … but could not prove it), there is no counterexample. What is shown is a sub-assignment of a model of Found ∧ ¬Expected. If the solver fails, the error is reported without one.Study tasks, before and after
A1_09:
State Refinement Error: found newMode == BORDERLESS && (previousMode == BORDERLESS && newMode != BORDERLESS ? … : …) but expected display(host) == notDisplayable 51 | case BORDERLESS: 52 | host.setResizable(false); 53 | host.setUndecorated(true); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 54 | host.setExtendedState(Frame.MAXIMIZED_BOTH); 55 | host.setVisible(true); + --> Counterexample: previousMode == BORDERLESSnewModeis left out because Found states it.Each task still gives exactly one error, on its
reportedLine.Changes
TypeChecker.throwStateRefinementErrorasks for the model (best effort) and passes it throughVCChecker.StateRefinementError.showCounterexamplefilters the model.RefinementError.isKnownbecomes package-private so the filter can reuse it.TestCounterexamples, on the existingErrorStateHintPathDependent.java, givesready == false. It fails without the change.Conflicts
throwStateRefinementError, so whichever merges second needs a one-line rebase.RefinementError) only atisKnown's modifier.Tests:
mvn test, 729 run, 0 failures.🤖 Generated with Claude Code