Skip to content

t27b: std.math.inf, std.math.log with base e, std.math.log1p and an f64 @round, from libm_plan.t27 (Closes #7923) - #7925

Merged
gHashTag merged 12 commits into
masterfrom
t27b-libm-std-math-7923
Oct 9, 2026
Merged

gHashTag merged 12 commits into
masterfrom
t27b-libm-std-math-7923

Conversation

@gHashTag

@gHashTag gHashTag commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Closes #7923. Part of #6063 (t27b coverage), item C10 of #6488. Builds on #7819's libm_plan.t27.

Decision

specs/port/trinity/src/brain/weber_tuning.t27 (reference 12/12) stopped at std.math.log(f64, std.math.e, abs_v + 1.0) and std.math.log1p(@abs(magnitude)); its f64 @round sat behind them. specs/numeric/formats.t27 stopped at std.math.inf(f32) (6 sites). All of these become calls of t27 routines, as @exp, @log and std.math.nan already are:

  • std.math.inf(T) names its type, as nan does. Its routine is +inf by its bits (0x7FF0000000000000, 0x7F800000).
  • std.math.log(T, base, x) is @log(x) in Zig 0.16 when the base is std.math.e (std/math/log.zig). So it calls log, which libm.t27 already holds.
  • std.math.log1p of an f64 calls std/math/log1p.zig's log1p_64 (musl's log1p.c), ported step for step. An f32 is refused as REFUSE_NO_F32, because log1p_32 is a different routine and is not ported.
  • @round of an f64 calls compiler_rt's round, ported step for step. @floor, @ceil, @trunc, @rem, @log2 and @log10 of an f64 stay refused.
  • On master's restructured plan. t27b: @log, @log2 and @log10 of an f32 call t27 ports of compiler_rt (Closes #7822) #7918 removed has_f32 and REFUSE_NO_ROUTINE, and gave @log2 and @log10 codes 11 and 12. This PR sits on top of that:
    • std.math.inf, std.math.log1p and std.math.log are codes 13 to 15;
    • has_f32 is back, false only for log1p;
    • the refusals REFUSE_BASE, REFUSE_TYPE and REFUSE_NO_F32 are 6, 7 and 8.
  • The glue (libm_call) reads the value operand where the plan says (operand) and passes only the operands after it. It asks the plan (with_base) about std.math.log's base, which must be the std.math.e that std_math_const already recognizes, and about its type.

formats.t27 now stops at ExprArrayLiteral (line 628): a typed list that gen-zig prints as a tuple and indexes inside an invariant. That is tuple work and is not in this PR.

Evidence

Reference: t27c test-report on the t27c lab, zig 0.16.0. t27b: aarch64 under qemu, built from the final head (this PR merged with master 19e0971).

spec reference t27b on master t27b with this PR
specs/port/trinity/src/brain/weber_tuning.t27 12/12 blocked ExprCall(std.*) 12/12
specs/numeric/formats.t27 pass blocked ExprCall(std.*) blocked ExprArrayLiteral (see #7930)
specs/tri/t27b/conformance/libm_std_math.t27 (new) 7/7, 0 vacuous -- 7/7
specs/tri/t27b/libm.t27 21/21, 0 vacuous 17/17 21/21
specs/tri/t27b/libm_plan.t27 11/11, 0 vacuous 9/9 11/11
conformance/libm_logf.t27, libm_rounding.t27, bit_cast.t27 pass 6/6, 5/5, 9/9 6/6, 5/5, 9/9
  • The ports, against the reference. The conformance spec's sweeps hold libm.t27's round and log1p (brought in by use tri::t27b::libm;) bit for bit to Zig's @round and std.math.log1p of a run-time f64. Both give 0 differences:

    • round: 72000 points over [-1000, 1000], around +-0.5 and near 2^52;
    • log1p: 120000 points over (-1, 11100), plus 4800 from 5e-324 up by a factor of 1.37, both signs.

    libm.t27 keeps the fixed-value tests (-0, +-inf, NaN, -1, x < -1, ties). The sweeps sit in the conformance spec so that libm.t27's interpreter check keeps its fuel.

  • The conformance spec's expected values were printed by Zig 0.16 on the t27c lab, including an f32 std.math.log (logf). log(3.0) and log1p(2.0) differ in the last bit, so swapping the two routines fails it.

  • Mutants, on the final specs:

    • Assert flips all fail under both t27b and the reference: 36 of 36 in the conformance spec (run next to it, so its use resolves), 41 of 41 in the plan's new tests, and 20 of 20 in libm.t27's new tests.
    • Generating operand(LOG_E) as 0 fails log_base_e_log1p_inf_and_an_f64_round (measured before the merge).
    • So does changing log1p's ln2_hi (also measured before the merge).
    • A one-ulp change to log1p's innermost polynomial coefficient is not visible at the fixed points. The reference sweeps hold those digits.
  • cargo test --release -p t27b (aarch64, qemu): 14 suites, exit 0. tests/tail.rs:

  • Seals: libm_plan.t27, libm.t27 and conformance/libm_std_math.t27 verified on the final head (all hashes MATCH).

  • Policy gates: master's check_budget() and check_all() (with master's foreign-exceptions.txt) exit 0.

  • Ledger: weber_tuning moves from blocked to pass, formats' blocker becomes ExprArrayLiteral, and the new conformance row is a pass.

Lines by file

On the final head, against master:

file kind added removed
cli/t27b/src/lower.rs hand-written glue 6 3
cli/t27b/tests/tail.rs hand-written test 23 2
gen/rust/tri/t27b/libm_plan.rs generated (t27c gen-rust) 84 6
specs/tri/t27b/libm_plan.t27 .t27 127 19
specs/tri/t27b/libm.t27 .t27 139 3
specs/tri/t27b/conformance/libm_std_math.t27 .t27 167 0
.trinity/seals/* (3), docs/reports/t27b_expectations.json, AGENTS.md data / prose

Hand-written lines: 29 added in total (owner rule #7371: 40 per file, 80 per PR).

Receipt

Base 430c522 (master, the lab's own signed run). Head ac1c2b7, this PR's change merged with that base, requested from the t27b lab with a fresh challenge (#7686). The compare was run on t27b-lab from /work/t27 as /work/t27c-master corpus-receipt compare BASE HEAD --challenge-head <challenge>:

base "430c52293506130c5be6e175ad2e6fbb733da395" AUTH_MISSING_NONE AUTHOR leaves-bound true
head "ac1c2b74fd20c0b7f49752662bd355c634f8926f" AUTH_MISSING_NONE FRESH leaves-bound true
  input only-head specs/tri/t27b/conformance/libm_std_math.t27
  input changed specs/tri/t27b/libm.t27
  input changed specs/tri/t27b/libm_plan.t27
  verdict changed specs/port/trinity/src/brain/weber_tuning.t27
  verdict only-head specs/tri/t27b/conformance/libm_std_math.t27
  output only-head specs/port/trinity/src/brain/weber_tuning.t27
  output changed specs/port/trinity/src/tri/gen_cross_entropy.t27
  output changed specs/port/trinity/src/tri/gen_sigmoid.t27
  output changed specs/port/trinity/src/tri/gen_softmax.t27
  output changed specs/tri/t27b/conformance/bit_cast.t27
  output changed specs/tri/t27b/conformance/libm_rounding.t27
  output only-head specs/tri/t27b/conformance/libm_std_math.t27
  output changed specs/tri/t27b/libm.t27
  output changed specs/tri/t27b/libm_plan.t27
  lane improved specs/port/trinity/src/brain/weber_tuning.t27
  lane neutral specs/port/trinity/src/tri/gen_cross_entropy.t27
  lane neutral specs/port/trinity/src/tri/gen_sigmoid.t27
  lane neutral specs/port/trinity/src/tri/gen_softmax.t27
  lane neutral specs/tri/t27b/conformance/bit_cast.t27
  lane neutral specs/tri/t27b/conformance/libm_rounding.t27
  lane improved specs/tri/t27b/conformance/libm_std_math.t27
  lane neutral specs/tri/t27b/libm.t27
  lane neutral specs/tri/t27b/libm_plan.t27
totals false inputs false verdicts false outputs false: IMPROVED_ONLY

Exit 3, IMPROVED_ONLY.

base 430c522 head ac1c2b7
files 1667 1668 (+1: the new spec)
t27b pass / pass_vacuous 996 / 153 998 / 153
blocked / fail / timeout 495 / 19 / 4 494 / 19 / 4
jit_interp_mismatch / crash 0 / 0 0 / 0
reference pass 1182 1183
reference disagree (files / tests) 0 / 0 0 / 0
cargo test --release -p t27b (aarch64, qemu) 147 passed 148 passed, 0 failed

Commits after ac1c2b7.

On the final tree, on the t27c lab:

  • cargo test --release -p t27b passes (14 suites);
  • every spec in the table above gives the verdict shown;
  • the three seals verify;
  • the mutants above were run there.

Native arm64 (t27b-native-ratchet): reference disagree 0. No line names a file of this PR.

Generated with Claude Code

@round, from libm_plan.t27 (Closes #7923)

Part of #6063 (t27b coverage), item C10 of #6488.

- libm_plan.t27: std.math.inf names its type as nan does;
  std.math.log(T, base, x) takes the value third, calls `log` when the
  base is std.math.e (std/math/log.zig returns @log(x) there) and
  refuses by name another base or a type that is not the value's;
  std.math.log1p of an f64 and @round of an f64 get their routines.
- libm.t27: inf / inff, compiler_rt `round` and std/math/log1p.zig's
  `log1p_64`, step for step. Under the reference they agree bit for bit
  with @round on 72000 points and with std.math.log1p on 124800.
- conformance/libm_std_math.t27: weber_tuning's and formats' shapes,
  4 tests, reference 4/4, 0 vacuous.
- weber_tuning.t27 passes 12/12; formats.t27 moves to ExprArrayLiteral.
- Glue: lower.rs +6 -3, tests/tail.rs +18 -2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AGENTS.md keeps #7803's line and re-measures this PR's after it (wc -l);
the ledger's counts are recounted from its rows: 925 / 151 / 34.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 21:07:27 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 36
PRs with All Checks Green 14
READY 2
FAILING 36
PENDING 0
NO CHECKS YET 0

These columns do not partition: 2 + 36 + 0 + 0 = 38, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=3c0ade9e73e4 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

tests/tail.rs keeps #7810's test and this PR's; AGENTS.md keeps #7810's and
#7811's lines and re-measures this PR's after them (wc -l); the ledger's
counts are recounted from its rows: 933 / 151 / 32.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-08 22:19:31 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 43
PRs with All Checks Green 7
READY 3
FAILING 43
PENDING 0
NO CHECKS YET 0

These columns do not partition: 3 + 43 + 0 + 0 = 46, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=3c0ade9e73e4 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

The ledger keeps master's rows and this PR's; its counts are recounted from
its rows: 944 / 140 / 32. No t27b source changed on master, so AGENTS.md's line stands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ledger takes master's rows (with #8059's bless) and this PR's three; AGENTS.md is re-measured with wc -l.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-09 09:38:06 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 49
PRs with All Checks Green 1
READY 0
FAILING 49
PENDING 0
NO CHECKS YET 0

These columns do not partition: 0 + 49 + 0 + 0 = 49, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=3c0ade9e73e4 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

The ledger takes master's rows and this PR's three; AGENTS.md is re-measured with wc -l on the merge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-09 10:04:22 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 37
PRs with All Checks Green 13
READY 0
FAILING 37
PENDING 0
NO CHECKS YET 0

These columns do not partition: 0 + 37 + 0 + 0 = 37, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=3c0ade9e73e4 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

PR Dashboard

Generated at: 2026-10-09 10:41:51 UTC

Summary

Status Count
Total Open PRs 50
PRs with Failing Checks 42
PRs with All Checks Green 8
READY 0
FAILING 42
PENDING 0
NO CHECKS YET 0

These columns do not partition: 0 + 42 + 0 + 0 = 42, and there are 50 open PRs. A PR is being counted twice or not at all.

Seal Status

  • ⚠️ STALE -- sha256(compiler.rs)=3c0ade9e73e4 != manifest seal=87e5cbd3ad94.
    The committed NMSE numbers were certified against an older compiler.rs.
    Run scripts/reseal-check.sh locally for the two-step reseal command (advisory; not a merge gate).

@gHashTag
gHashTag merged commit 4d6cf7f into master Oct 9, 2026
30 of 33 checks passed
gHashTag pushed a commit that referenced this pull request Oct 9, 2026
AGENTS.md takes master's and adds this branch's step: 15279 plus 1239 and
8264, on master a97cb9e's 15276 plus 1239 and 8247. The ledger takes master's and
re-applies this branch's rows; max_not_pass recomputed from the entries: 24.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@gHashTag
gHashTag deleted the t27b-libm-std-math-7923 branch October 9, 2026 15:16
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.

t27b: std.math.inf, std.math.log (base e), std.math.log1p and an f64 @round from libm_plan.t27 (weber_tuning, formats)

2 participants