Skip to content

Encode NaN return values as \result != \result (JLiSA-Wit compatibility) - #4

Merged
nils-loose merged 2 commits into
mainfrom
fix/nan-result-constraint
Nov 17, 2026
Merged

nils-loose merged 2 commits into
mainfrom
fix/nan-result-constraint

Conversation

@nils-loose

Copy link
Copy Markdown
Contributor

What

function_return constraints for a NaN float/double return were rendered as Float.isNaN(\result) / Double.isNaN(\result). They are now \result != \result. All other encodings are unchanged; the input contract is untouched. Version bumped to 1.1.1.

Why

JLiSA-Wit (SV-COMP 2027 Java violation witness validator, Zenodo 24103125, commit 98fc3130) reads one value from the constraint in ReturnConstraint.value. It accepts only \result == <literal> (including Float/Double.NaN and the infinities), \result != \result (as NaN) and \result.equals("..."). Any isNaN(...) form gives "Could not validate". Of the forms it accepts, \result != \result is the only one that is right in Java: \result == Double.NaN is always false. Its ForceReturnSteerer turns the NaN into the method's float or double return type.

Verification

  • Unit/e2e tests updated (test_literals, test_e2e::test_float_special_values, which also runs WitnessLint on the NaN witness).
  • I patched the 9 SWAT witnesses from the SV-COMP 2027 preliminary run that used isNaN(\result) and ran them through the archived JLiSA-Wit binary with the official command lines:
    • before: 9/9 Could not validate | UNKNOWN, the same as the official run
    • after: 9/9 Witness Correct | FALSE
    • negative control (MathSin with \result == 0.5): Witness Spurious | TRUE
  • WitnessLint 2.4.1-dev (sv-witnesses master): exit code 0 on all 9, before and after.

Not changed

Long.MIN_VALUE stays \result == -9223372036854775808L, which is valid Java. The archived validator overflows on it because it negates after Long.decode of the magnitude. Upstream fixed this in 17de2811. No other literal spelling (hex, octal) gets past that old parser, so there is no safe workaround. Integer.MIN_VALUE (\result == -2147483648) parses fine.

Note

5 tests in test_e2e (test_default_violation_lints[*], test_no_target_warns_but_writes) fail with the current sv-witnesses master linter, which reports a schema mismatch for witnesses without a target waypoint. They fail the same way on main, so this PR does not cause them.

🤖 Generated with Claude Code

nils-loose and others added 2 commits November 17, 2026 09:32
The function_return constraint for a NaN float/double return was
Float.isNaN(\result) / Double.isNaN(\result). JLiSA-Wit, the SV-COMP 2027
Java violation witness validator, reads a single value from the constraint
and accepts only \result == <literal> (incl. Float/Double.NaN and the
infinities), \result != \result and \result.equals("..."), so it could
not validate witnesses with a NaN return. \result != \result is exactly
NaN in Java semantics (unlike \result == Double.NaN, which is always
false) and passes WitnessLint. Other encodings are unchanged.

Bump the version to 1.1.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sv-witnesses master (2.4.1-dev) rejects violation witnesses without a target
waypoint, which the default-violation tests write on purpose.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nils-loose
nils-loose merged commit 6393918 into main Nov 17, 2026
5 checks passed
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.

1 participant