Implement \real literals (#3570); fix LogicPrinter.quickPrintSemisequent (#243)#3865
Merged
Conversation
unp1
marked this pull request as ready for review
June 27, 2026 10:57
wadoon
reviewed
Jun 28, 2026
unp1
force-pushed
the
fix/key-core-printer-low
branch
from
June 28, 2026 12:34
be621b2 to
b6407f4
Compare
unp1
enabled auto-merge
June 28, 2026 14:47
quickPrintSemisequent printed the semisequent without an enclosing layouter block, so the pretty-printer never flushed its final pending break and the trailing formula was lost (e.g. "true," instead of "true, false"). The same formulas printed via a full sequent were rendered correctly because printSequent wraps the output in beginC/end. Wrap the semisequent in an explicit block, mirroring quickPrintTerm. Created with AI tooling support
ExpressionBuilder.visitRealLiteral now builds the term form of a real literal (__R(unscaledValue, scale)) instead of failing, reusing RealLiteral for the exact decimal parse and TermBuilder.rTerm for the encoding. A negative real folds the sign into the literal in visitUnary_minus_term (the real LDT has no neg), mirroring the existing integer-literal handling and using the bootstrap-safe namespace lookup (the LDT objects are not yet constructed while the rule files are parsed). Notation.RealLiteral prints __R(u, s) back as its canonical decimal with an 'r' suffix (e.g. 1.25r), registered for the __R symbol next to Z/FP/DFP. Issue3570Test now checks that a real literal parses to sort real and that parser and printer are inverse (including negatives and trailing-zero canonicalization). Created with AI tooling support
unp1
force-pushed
the
fix/key-core-printer-low
branch
from
June 29, 2026 14:30
b6407f4 to
dd8063f
Compare
wadoon
approved these changes
Jul 4, 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.
Related Issue
This pull request resolves #243 and #3570.
Intended Change
#243 —
LogicPrinter.quickPrintSemisequentdropped the last formulaThe method printed the semisequent without an enclosing layouter block, so the
pretty-printer never flushed its final pending break and the trailing formula was lost
(e.g.
true,instead oftrue, false). The same formulas printed via a full sequentrendered correctly because
printSequentwraps its output inbeginC/end. Fixed bywrapping the semisequent in an explicit block, mirroring
quickPrintTerm.#3570 — real literals are now supported
\realliterals such as1.0rused to be rejected by the term parser. This PRimplements them end to end.
RealLiteralnow stores it as an arbitrary-precision pair
(unscaledValue, scale)with valueunscaledValue * 10^(-scale)— theBigDecimalscheme, but with an unboundedBigIntegerscale rather than anint, and kept in canonical form (trailing zerosstripped) so equal values have equal fields.
BigDecimalis used only to parse boundedsource strings, never to hold the value.
__R(unscaledValue, scale)overnumbers(
realHeader.keynow declaresreal __R(numbers, numbers);and therealsort, movedout of
integerHeader.key).TermBuilder.rTerm/RealLDT.translateLiteral/translateTermbuild and decode it; because both operands are unboundednumbers, thevalue never passes through an
int(a scale beyondInteger.MAX_VALUEround-trips).ExpressionBuilder.visitRealLiteralbuilds the term; a negative literalfolds the sign into the literal (the real LDT has no
neg), mirroring the existinginteger-literal handling and using a bootstrap-safe namespace lookup.
Notation.RealLiteralprints__R(u, s)back as itscanonical decimal with an
rsuffix (1.25r,-0.5r,100r), the inverse of theparser; registered next to
Z/FP/DFP.standard_key/reals/realLiterals.keyshowcases realliterals, real-sorted quantification and a real-valued assignment (via an update); it is
wired into
runAllProofs(it proves and reloads, so the printer→parser round-trip ischecked on every CI run).
Decisions worth highlighting
__name. The wrapper is named__Rrather than a bare identifier so itdoes not steal a name a user might declare in a problem file. This is the first user of a
reserved-prefix convention; migrating the other built-in literal symbols
(
Z/C/FP/DFP) out of the user namespace is left as separate follow-up work.RealLDTis intentionally still a stub: there are no arithmetic axiomsyet (no
+,*,<on reals), so only equality/structural reasoning is available. Therealtype is also not yet usable inside Java program blocks (\<{ ... }\>), only in thelogic and in JML; the example therefore models an assignment with an update. Axiomatising
real arithmetic is a separate, larger piece of work.
Type of pull request
Ensuring quality
Issue243Test— red before, green after the semisequent fix.RealLDTTest— the(unscaledValue, scale)encoding round-trips (incl. negatives,leading-zero fractions, trailing-zero integers, and a scale beyond
Integer.MAX_VALUE).Issue3570Test— a real literal parses to sortreal, and parser and pretty-printerare inverse (incl. negatives and trailing-zero canonicalization).
suites
:key.core:testRAP -PrapForks=10(674 — including the newrealsproof, which isproved and reloaded) and
:key.core:testProveRules(203) — all green.branches only fire for real literals; the extra namespace lookup mirrors the existing
integer-literal handling on the same code path).
Additional information and contact(s)
PR prepared with AI tooling support.
The contributions within this pull request are licensed under GPLv2 (only) for inclusion in KeY.