Repository navigation
Decide precision loss by symbol kind instead of by variable name - #71
Closed
nils-loose wants to merge 2 commits into
Closed
nils-loose wants to merge 2 commits into
nils-loose wants to merge 2 commits into
Conversation
DTOBuilder flagged a branch constraint as imprecise when one of its symbols did not match the name pattern [A-Z].*_[0-9].*. Array base symbols ([I_0) and the exact UFs of the String models (trimStart, trimEnd, commonPrefixLength, lastIndexOf) failed it, so SAFE was downgraded for constraints that are encoded exactly. Symbols are now declared with their kind where they are created (SymbolRegistry): inputs, other symbolic values, array base symbols, exact model functions and approximate model functions. A constraint is imprecise if it mentions an approximate model function or a symbol nobody declared. Array base symbols get their own namespace (<prefix>_alloc<n>), so an input array of the same prefix and index cannot share them. lastIndexOf(int) with a symbolic char records precision loss: chars outside the BMP, and negative ones, are not modelled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sin/cos, toLowerCase and equalsIgnoreCase are approximate model functions. sin/cos restrict their argument to the sample points, and the guarded toLowerCase restricts chars to printable ASCII. Both constraints reach every query, so they record precision loss where they are added, not only when a branch mentions the function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nils-loose
added a commit
that referenced
this pull request
Oct 19, 2026
SinCosUF.java: deleted as in #80 (its trace-global sample constraint gave a false SAFE); #71's eager precision loss there goes with it. StrategyService.py: solve_branch takes both #74's extra_exprs and #80's approximate_rlimit, on #80's sliced query. SVCompDriver.py: retries (#74) and first queries both get the approximate-query cap (#80); a solution keeps #74's record and #80's query-based guess flag. SymbolicExplorer.py: both sets of options. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nils-loose
added a commit
that referenced
this pull request
Oct 19, 2026
Combining #71 and #80: each per-call math_<f>_<n> function is declared APPROXIMATE_MODEL_FUNCTION in the SymbolRegistry, so a branch over one is a precision loss by kind, not only as an undeclared symbol. The registry test builds its function through SampledMath, as SinCosUF is gone, and the divergence tests pass #80's approximate_rlimit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nils-loose
added a commit
that referenced
this pull request
Oct 19, 2026
_extract_variables: one copy (#82 cherry-picks #72's patch). StrategyService.py, Database.py: #82 walks the Database's tree under the lock; visit_tree passes the solved and #74's retired branches, in #72's 'with lock' style. SVCompDriver.py: #82's shallow snapshot of the target node for check_divergence, with #74's solution record and #80's guess flag; the ingest-failure (#72) and stack-overflow (#78) checks read the Database without copying the tree. DTOBuilder.java: #82's FormulaDumper with #71's SymbolRegistry check. DFS.py: #82 logs the per-node line only with an SA graph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes
DTOBuilderused to flag precision loss when any symbol in a branch constraint failed the name regex[A-Z].*_[0-9].*. It now decides from the kind each symbol was declared with.SymbolRegistry. Each symbol is declared, where it is created, as one of:INPUT,VALUE(another symbolic value),ARRAY_BASE,MODEL_FUNCTION(the definition holds for every argument) orAPPROXIMATE_MODEL_FUNCTION. A branch constraint is imprecise if it mentions an approximate function or a symbol nobody declared. An undeclared symbol is logged once.Declarations:
Value.initSymbolic*declaresVALUE.SymbolicTraceHandler.addInputdeclaresINPUT.ARRAY_BASE.trimStart,trimEnd,commonPrefixLength,lastIndexOf) areMODEL_FUNCTION.sin,cos,toLowerCaseandequalsIgnoreCaseareAPPROXIMATE_MODEL_FUNCTION.Approximate models record precision loss where they add constraints. This now happens explicitly (
recordSymbolicPrecisionLoss()), not only when a branch mentions the function:SinCosUFrestricts its argument to the sample points.toLowerCaserestricts chars to printable ASCII.lastIndexOf(int)with a symbolic char is approximate (non-BMP and negative chars are not modelled).These constraints are trace-global, so they reach every query.
Array base symbols get their own namespace (
[I_alloc<n>,A_alloc<n>). An input array[I_<idx>can no longer share, and so constrain, an allocated array's base symbol.Why this is sound: a precise symbol may still be under-constrained, for example a fresh value, an array base outside the stored range, or a partially defined function. That only over-approximates: UNSAT stays a proof. A model that does not reach its branch is a divergence, and an unexpected divergence already downgrades SAFE. Anything that may exclude real behaviour stays a precision loss.
Measured
--sv-comp,--mem15g, 300 s, no SA. 1189 runs, compared withbaseline-results.jsonl.precision-loss-false-positive-var-name,precision-loss-uforarray-base-symbol-collides-with-input;Result: +8 / -0, net +8, no new wrong verdicts. The one wrong verdict, AlbersProjection_true (SAFE -> VIOLATION), is the same as in the baseline.
Soundness check:
lastIndexOf(int)autostubs, which are now flagged by the explicit record.Tests
SymbolRegistrySpeccovering:trimUFs are precise;sinis a precision loss and records it;Limits
toLowerCase,StringBuffer) or by timeouts.🤖 Generated with Claude Code