Repository navigation
[VFDLIBM] Prove log10's words in long lanes, the form Varka's kernel emits - #147
Merged
Merged
Conversation
added 2 commits
November 23, 2026 02:00
Varka's PORT expansion of log10 (VarkaMathPort.log10, paired Varka branch varka-345d-log-r) holds e_log10.c's int words in long lanes, as Log does (L8), takes y = (double)(k+i) by L7 rather than I2D, and tests the rare lanes on the raw bits. L17 proves these the C's on the lanes kept, under H18 (the sign bit clear there). Its hinge tests loop over every exponent field and every significand word, check the compares at their edges and on samples, and check H18 on StrictMath, which fails if the C kept a negative lane. Log10 itself keeps int lanes, so its own section stands. Generated-by: Claude Code (Claude Opus 5.5)
The review's nits: H18 now names a NaN with the sign bit set among the lanes the C answers early; a kept lane's K tops at 1023, since field 0x7ff is always blended over; the significand loop drops the exponent fields it masked away; and the H18 witness asserts that K differs from the C's k on every sign-set pattern, not on some. Generated-by: Claude Code (Claude Opus 5.5)
Contributor
Author
|
Review at
Generated-by: Claude Code (Opus 5.5) |
added 2 commits
November 23, 2026 05:52
Generated-by: Claude Code (Claude Opus 5.5)
…C line numbers Reword L17's hinge-test paragraph so it no longer contradicts itself, call l17NegativeLanesAreAnsweredEarly a witness and the oracle's own check and drop its assertion that could not fail, name l17NegativeLanesAreBlendedOver and Varka's suite as the checks of H18, cite vecbricks/varka#1645 instead of the branch, and cite e_log10.c lines 80 and 84 in l17CK's Javadoc. Generated-by: Claude Code (Claude Opus 5.5)
Contributor
Author
|
Thanks for the review. All four points are fixed in 27bf8a4 (main is merged in first, in b25d175).
Generated-by: Claude Code (Claude Opus 5.5) |
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 were proposed in this pull request?
This PR adds lemma L17 to
PROOFS.md, in the log10 section, and its tests inProofsTest(l17LongWordsAreLog10sInts,l17RareComparesAreTheCs,l17NegativeLanesAreAnsweredEarly,l17NegativeLanesAreBlendedOver).The library code does not change.
Log10.javagets one comment pointer to L17.Varka's emitted
log10kernel keeps the C'sintwords in long lanes, asLogdoes (L8).L17 proves that these long words, and the kernel's tests on the raw bits, give the C's values on the lanes whose result is kept.
The paired Varka PR, the statement of L17 and the proof
The paired Varka pull request is vecbricks/varka#1645, "Emit fdlibm's log and log10 as kernel IR nodes, exact to StrictMath", which L17 cites.
Its kernel computes the operations of
Log10.log10Blendedin the same order.The difference is where the words live: the C's
intwordshx,kandiare long lanes, andy = (double)(k+i)is L7's exact add and subtract of0x1.8p52instead ofI2D.Log10here keeps int lanes, so the log10 section's sentence "needs no lemma of its own" still holds for this library. L17 is about Varka's kernel only, as L15's (a) to (c) are.L17 states three facts.
(a) With the sign bit clear, the long
K = (HX >>> 20) - 1023(less 54 on a scaled lane),I = K >>> 63and the new high word(HX & 0xfffff) | ((0x3ff - I) << 20)are the C'sk,iand newhx, widened. The new word is below 2^31, so its shift into place is the C's__HI(x) = hx.(b) For
Kin[-1077, 1024], the L7 conversion ofK + Iis the C's(double)(k+i).(c) For every lane, either sign, the signed long compares
b > 0x7ff00000_00000000 - 1andb < 0are the C'shx >= 0x7ff00000andhx < 0.The proof is range arithmetic.
With the sign clear, the high word is in
[0, 2^31), so the logical and the arithmetic shift agree, andKis in[-1077, 1024].Bit 63 of a long is its sign, so
K >>> 63is 1 exactly whenK < 0.The compares follow from
b = hx * 2^32 + lowith0 <= lo < 2^32(L9's argument on the raw bits).The hypothesis H18 is that the sign bit is clear on every kept lane.
A lane with the sign set is
x < 0or-0. The C answers it at line 79 or 78, and the kernel blends those answers over the general result.H18 is needed: on a negative lane the long
Kis not the C'sk.The change is on
mainafter #143.L12toL16andH17are taken, so the lemma is L17 and the hypothesis H18.On the old branch it was L13 with H17.
Why are the changes needed?
The Varka kernel writes
log10with long words and tests its rare lanes on the raw bits."Same result, proven" (
AGENTS.md) asks for a numbered lemma for any form that departs from the C.Without L17 the kernel's long words rest on an unwritten argument.
Does this PR introduce any user-facing change?
No.
Only
PROOFS.md, tests and one code comment change.No public method, result or requirement moves, so
CHANGELOG.mdhas no line.How was this patch tested?
mvn -B verifyon the head (27bf8a4, withmainat 7acd20d merged in): BUILD SUCCESS, 799 tests, 0 failures, 0 errors, 4 skipped, in 6 min 44 s.ProofsTestruns 50 tests.The four L17 tests are new.
Each hinge test is built to fail when its hinge is false.
l17NegativeLanesAreAnsweredEarlyis a witness, not a hinge test: it checks only the oracle, thatStrictMath.log10gives a NaN, or-inffor-0, on every sign-set input.l17NegativeLanesAreBlendedOverand Varka's suite are the checks of H18.l17NegativeLanesAreBlendedOverchecks H18 onLog10's own masks:Log10.log10Blendedat every width, with sign-set inputs beside their positive twins in one vector.A dropped rare blend is caught: with
Log10.log10Blended's blend for negative lanes commented out,l17NegativeLanesAreBlendedOverfailed at all four widths (a sign-set input gave a finite result instead of a NaN). The mutation was made by hand and reverted.Where the real check lives: that Varka's kernel uses these long words is checked only in Varka's
VarkaMathPortSuite, in vecbricks/varka#1645.l17LongWordsAreLog10sIntsis a Java loop over every exponent field and every significand word, the values the proof's bound allows.l17RareComparesAreTheCschecks the compares at their edges and on 2^20 samples, not over every word. A loop over every high word took 44 s, too long for a test.Not run:
dev/prove.sh,dev/jar-check.shand any benchmark.No
.smt2file changed, soprove.shhas nothing new to check.Only a comment changed in the main sources, so
jar-check.shhas nothing new to check.Nothing here is a speed claim, so no benchmark.
/code-review highon d78a0d7 found no bug and 5 nits, fixed in 7828ab2 and 27bf8a4. The review of 7828ab2 found no bug and four nits; all four are addressed in 27bf8a4. 27bf8a4 itself has not been reviewed.Test setup, the review items and the log1p lemma
The last run used
origin/mainat 7acd20d as base, JDK 25.0.5.1, Maven 3.9.16, on this laptop (not a timing).An earlier run on d78a0d7, before the review fixes, also gave BUILD SUCCESS with 799 tests, 0 failures and 4 skipped, in 15 min 22 s. The reviewer's own Maven run overlapped part of it.
The nits:
Kis in[-1074, 1023]. Field0x7ffgives 1024, but that lane is+infor a NaN and is always blended over.Ionly.Kdiffers on some sign-set pattern. That assertion could never fail, so 27bf8a4 drops it and calls the test a witness.varka-345d-log-r. It now cites [VARKA-345] Emit fdlibm's log and log10 as kernel IR nodes, exact to StrictMath varka#1645, as L15 cites a PR number.The review of 7828ab2 (four nits, all addressed in 27bf8a4): a self-contradicting sentence in L17's hinge-test paragraph, reworded; the witness test's assertion that could not fail, dropped, with
l17NegativeLanesAreBlendedOverand Varka's suite named as the checks of H18; the Varka branch cite, now vecbricks/varka#1645; andl17CK's Javadoc, now citinge_log10.clines 80 and 84.The log1p lemma (L14 on the old branch
varka-log1p-long-words) is not in this PR.AGENTS.mdsays each function comes in its own PR, paired with the Varka PR that emits it.The Varka PR for log1p is a later part. That lemma will be renumbered then.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)