Repository navigation
Parse rational and negative real values in SMT-LIB models - #1837
Open
agusaldasoro wants to merge 2 commits into
Open
agusaldasoro wants to merge 2 commits into
agusaldasoro wants to merge 2 commits into
Conversation
Z3 prints a non-integer Real as a division, e.g. (/ 1999.0 100.0), and a negative Real as (- 20.0) or (- (/ 7.0 2.0)). These came back as StringValue, so the solver built a StringGene for a decimal column. parseValue now evaluates these numeric terms into RealValue.
agusaldasoro
changed the base branch from
master
to
fix/smtlib-parser-quoted-values
October 7, 2026 09:56
agusaldasoro
marked this pull request as ready for review
October 8, 2026 09:46
jgaleotti
approved these changes
Oct 8, 2026
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.
Stacked on #1836.
Problem
Z3 prints a
Realthat is not an integer as a division, and a negativeRealas a negation:SMTResultParser.parseValueonly understood plain literals and the integer negation(- 6). Onmasterthese values break the struct split and throwArrayIndexOutOfBoundsException, so the query gets an ERROR. With #1836 the split works, but the value comes back as theStringValue"/ 1999.0 100.0".SMTLibZ3DbConstraintSolverthen builds aStringGenefor a DECIMAL/REAL column, which gives an invalid INSERT. The problem hits any query that constrains a decimal column to a non-integer value (e.g.WHERE price > 10.5) or to a negative value.Fix
parseValuefirst tries the newparseNumericTerm. It evaluates the numeric terms Z3 uses in models:(- x), plus(-x)as the existing line sanitizer rewrites it;(/ a b).These can be nested, as in
(- (/ 7.0 2.0)).LongValue. An integer too large for aLongbecomes aRealValue, as before.RealValue.nulland falls through to the existing string handling, so nothing else changes.Tests
The new cases in
SMTResultParserTestuse the exact output of the Z3 image the solver runs:testParseComposedTypeWithRationalValue:(/ 1999.0 100.0)→ 19.99testParseComposedTypeWithNegativeRealValues:(- (/ 7.0 2.0))→ -3.5 and(- 20.0)→ -20.0Both fail on #1836 (
StringValueinstead ofRealValue) and pass with this change. All tests incore-extra/solverpass, including the Z3 Docker ones.