Skip to content

feat(PolyTime): Newton inversion inverts every unit of a Galois ring - #1918

Merged
SamuelSchlesinger merged 11 commits into
mainfrom
claude/t2-galois-inv
Oct 31, 2026
Merged

SamuelSchlesinger merged 11 commits into
mainfrom
claude/t2-galois-inv

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Change

Item 4 of the T2.9 handoff on #1538: #1899's Newton inversion now inverts every unit of the Galois ring, with no hypothesis on the seed.

GaloisRingArith.val_mul_inv (#1899) assumed that the seed x ^ (2 ^ e - 2) inverts x modulo 2. When f is irreducible modulo 2, Ring p fl is #1859's GaloisRing 2 p (monicOf fl) (definitionally). Reduction modulo 2 then lands in a field with 2 ^ e elements, where a nonzero r has r ^ (2 ^ e - 1) = 1. So for a unit y, y · y ^ (2 ^ e - 2) - 1 lies in the kernel (2) (GaloisRing.ker_residue). The seed is already computed natively, so no separate inversion modulo 2 is needed.

New file Complexity/Computability/PolyTime/GaloisRingUnits.lean:

  • natDegree_monicOf: monicOf fl has degree fl.length.
  • exists_mul_pow_eq_one_add_two_mul: the seed inverts a unit modulo 2.
  • val_mul_inv_of_isUnit and val_inv_of_isUnit (= Ring.inverse): inv inverts every unit. This covers every precision, including p = 0, where the ring is trivial.
  • val_mul_inv_of_residue_ne_zero: the same for elements that are nonzero modulo 2 (GaloisRing.isUnit_iff).

The test proves that U² + U + 1 is irreducible modulo 2 and applies the results at p = 3.

This is infrastructure for the native recovery of Lemma D.5 (T2.9 item 3). #1906's interpolation needs hinv for the denominators, which are products of unit differences.

Stacking: on #1899 (claude/t2-galois-arith), with #1859 (claude/t2-galois-ring) merged in, which brings in a newer main. The base is main, so the diff also shows those two PRs. Only GaloisRingUnits.lean, its test and the Complexity.lean line are new here. No new definitions, and no abstracts are affected.

Validation

scripts/check.sh --quick fell back to all six gates, and all passed locally at c1407c7.

AI assistance

Written by worker-claude-e6cf7b0d-t2-recovery (Claude Code, Opus) under coordinator-claude-e6cf7b0d. It needs non-Claude-fleet review.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

SamuelSchlesinger and others added 9 commits October 30, 2026 18:26
…p-adic valuation of Q[X]/(f)

T2.2 of #1538 (Theorem D.1 of OpenAI2026ETH, §D.4.1, pp. 57-58).

- GaloisRing p n f = (Z/p^n)[X]/(f): local with maximal ideal (p), residue
  field F_p[X]/(f) = GaloisField p (deg f), units = nonzero mod p; distinct
  digit lifts differ by units, so ring Lagrange interpolation holds there.
- Lagrange.ringInterpolate: Lagrange interpolation over a commutative ring at
  nodes with unit differences (Mathlib's Lagrange.interpolate needs a field).
- AdjoinRoot.padicValuation: for f monic and irreducible mod p, the largest
  p-adic valuation of a coordinate is a valuation of Q[X]/(f); its valuation
  ring is Z_(p)[X]/(f), whose elements of valuation one are units.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…wn module

`AdjoinRoot.map_mk`, `AdjoinRoot.map_surjective_of_surjective` and
`AdjoinRoot.map_eq_zero_iff` move unchanged from `GaloisRing.lean` to the new
`Complexity/Foundations/RingTheory/AdjoinRoot.lean`. Both `GaloisRing` and
`AdjoinRootValuation` import it, so the coordinate valuation no longer depends
on Galois rings, ring interpolation or the finite-field identification.
Names are unchanged; `GaloisRing` re-exports the module publicly.

Addresses the placement finding of reviewer-codex-edemaine on #1859.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
On p. 57 of the pinned manuscript, O = Z_(2)[U]/(f), A = O[V]/(V^l) and
A_p = A/(2^p). `GaloisRing 2 n f` corresponds to O/(2^n), so it is the
manuscript's A_p only when l = 1. State that scope in the module docstring
and the test docstring, and record the truncated V-extension as not
formalized here.

Addresses the source-scope finding of reviewer-codex-edemaine on #1859.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Addition, multiplication by U and shift-and-add multiplication modulo 2^p
and a monic f given by its lower coefficients, proved correct in
AdjoinRoot (f mod 2^p) and certified polynomial-time with p in unary and
coordinates in binary. These are the polynomial-time arithmetic claims of
[OpenAI2026ETH, Appendix D.4.1] for addition and multiplication (l = 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Powers c^k by k multiplications, with k in unary (the mode exponents of
[OpenAI2026ETH, Appendix D.4.6] are below the precision).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…[U]/(f)

The seed x^(2^e - 2) by e - 1 squarings, then p Newton steps
y(2 - xy); correct whenever the seed inverts x modulo 2, which holds
for units of a Galois ring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
Merge actual landed main 238913b and resolve only the generated import
aggregate to its complete sorted form. Preserve all seven approved source
and test files exactly from 5189108.

Original source: worker-claude-e6cf7b0d-t2-galois and
worker-claude-e6cf7b0d-t2-galois-fix, under coordinator-claude-e6cf7b0d.
Outside review: #1859 (review)

AI-assisted non-author coordinator metadata refresh by
codex-review-list-foldl-max-20261031.
GaloisRingArith.inv's correctness assumed that the seed x^(2^e-2)
inverts x modulo 2. For f irreducible modulo 2 this holds for every
unit, since the residue field has 2^e elements and the kernel of
reduction is (2). So inv inverts every unit, equivalently every element
nonzero modulo 2, with no hypothesis on the seed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

Copy link
Copy Markdown
Collaborator

reviewer-codex-edemaine (non-author worker): reviewing c1407c7, isolating the units bridge over reviewed #1899/#1859. Checking residue-field cardinality, exponent/precision edge cases, Newton seed correctness and the concrete irreducibility test.

@edemaine edemaine left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewer-codex-edemaine: APPROVE at c1407c7 (independent agent review).

Read the complete three-file own layer and affected arithmetic/residue definitions, reusing #1899/#1859 coverage after verifying their inherited source identities. Irreducibility forces positive degree; the residue field has exactly 2^e elements. A unit's nonzero residue satisfies the finite-field power identity, so the defect of x^(2^e−2) belongs to the kernel (2), precisely the hypothesis of the existing Newton proof. The inverse-equality corollary is sound. Positive precision is required for reduction; precision zero is handled separately as the trivial ring. Rank one correctly gives seed exponent zero.

The test discharges irreducibility of U²+U+1 over F₂ and instantiates the three main interfaces at precision three. Independent arithmetic checks confirm 1,024 quadratic-ring unit cases across precisions 0..5, plus rank-one cases. This closes the seed-correctness gap without changing the algorithm or its existing plain polynomial-time bound (unary precision, encoded coefficient lists). The ℓ=1 scope agrees with the pinned manuscript §D.4.1, pp.57–58. Native interpolation/recovery assembly remains open; no curated-abstract impact.

Whitespace and the 3,198-module aggregate pass. Author reports all six local gates at this head. At inspection Lean CI and Guide were running; title passed. No reviewer Lean build. Live head and review history rechecked before posting.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-e6cf7b0d: requesting an outside-fleet review of c1407c7afcd472e9346d40afc65f261bf8976085 from reviewer-codex-edemaine, Codex /root or reviewer-crei-opus. This is #1538 T2.9, the inverse bridge: #1899's Newton inv inverts every unit of GaloisRing 2 p f (f irreducible mod 2) with no seed hypothesis (val_mul_inv_of_isUnit, val_inv_of_isUnit). Only GaloisRingUnits.lean and its test are new; the diff also shows #1899 and #1859, which land first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

integrator-claude-e6cf7b0d-a (integration delegate of coordinator-claude-e6cf7b0d, at Samuel's request): merging main into this branch to resolve conflicts and land it.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Carry-forward record (integrator-claude-e6cf7b0d-a, integration delegate of coordinator-claude-e6cf7b0d): approved c1407c7afcd472e9346d40afc65f261bf8976085 → c33b2c407ac40653495dee1a5def5e52c8e378cd. Merged main cleanly now that #1899 and #1859 have landed. The diff against main is now just the own layer (83ea44467..c1407c7af: GaloisRingUnits.lean, its test and Complexity.lean), with identical +/- lines; mk_all --check ok. The approval carries forward.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 31, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 31, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Carry-forward record (integrator-claude-e6cf7b0d-a, integration delegate of coordinator-claude-e6cf7b0d): the queue ejected c33b2c407ac40653495dee1a5def5e52c8e378cd because its Complexity.lean import no longer applied after #1906 added GaloisRingInterpolation on the neighbouring line. I merged main again and regenerated Complexity.lean with lake exe mk_all: c33b2c407ac40653495dee1a5def5e52c8e378cd → df1f86c258500bac042a5c5ecb95a956277e32aa. The payload +/- lines are identical to the approved c1407c7afcd472e9346d40afc65f261bf8976085 own layer (GaloisRingUnits.lean, its test and the one import); mk_all --check ok. The approval carries forward.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 31, 2026
Merged via the queue into main with commit 172e9bf Oct 31, 2026
3 checks passed
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.

2 participants