Skip to content

feat(WordRAM/PPSZ): one PPSZ round on the randomized word RAM with its exact law - #1986

Merged
SamuelSchlesinger merged 12 commits into
mainfrom
claude/ppsz-round-894
Oct 31, 2026
Merged

SamuelSchlesinger merged 12 commits into
mainfrom
claude/ppsz-round-894

Conversation

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

worker-claude-e6cf7b0d-ppsz-round (Claude Code, Opus), under coordinator-claude-e6cf7b0d. Part of #894 (M2). Stacked on #1980 (claude/ppsz-wordram-894), which is stacked on #1960 → #1954. Review the diff against #1980's branch. I'll merge main into this branch as the parents land.

Change

One round of PPSZ (w-implication, #1453) as a program of the randomized word RAM, with its exact law. This follows the handoff.

PPSZ.roundProgram_spec covers the input s :: encode φ of length L, at any word size with L + 2n + 2s + 3 < 2^w. One round:

  • halts within n (impliedTime s L + 25) + 12 L + 23 instructions;
  • makes at most 2n rand calls;
  • outputs whether the assignment it leaves satisfies φ;
  • leaves an assignment whose law is exactly PPSZ.round φ s.

The PPSZ success bounds (#1466/#1605) therefore apply to the program, and the tests instantiate round_success_of_satisfiable_three on it.

PPZ/Round.lean: the loop is generic in the oracle code.

  • IsOracleCode w φ C Tb M O oc T is the contract from the handoff. From the round frame, with v in xReg and τ stored at Tb, oc stores optCode (O τ v) in res within T instructions and leaves memory unchanged. It writes no frame register, xReg, iReg or jReg.
  • roundBodyWith, roundLoopWith and roundCoreWith, with their laws, take any such code. Their bounds are T + 16, d (T + 18) + 2 and n (T + 25) + 6, and the laws are stepWith O, roundOn O and roundWith O.
  • roundBody, roundLoop, roundCore and their laws keep their statements. They are the instances at forcedCode (forcedCode_isOracleCode), so PPZ/Amplify.lean is untouched.

PPSZ/Round.lean: the round.

Existing notions considered

IsOracleCode is new. It names the contract that #1954 used inline for forcedCode (via forcedCode_spec and ScanFrame). A structure keeps the generic laws readable, and PPZ and PPSZ discharge it once each. Everything else is reused: RoundFrame, LoopState, StepPost, roundCheck, cfgPartial, ExecRandLaw, and the lazy order roundOn with roundOn_succ and roundWith_eq_roundOn.

Source

The algorithm is PPSZ with w-implication, after [PaturiPudlakSaksZane2005] and [Hertli2011], as in #1453's Defs.lean. No theorem of either paper is claimed: the program is matched against the library's PPSZ.round, so no locator is cited.

Limits

Abstract impact: none.

Validation

  • scripts/check.sh --quick --base origin/claude/ppsz-wordram-894 fell back to all six gates (custom Lake library options), and all passed. lake exe mk_all --check and scripts/check_hygiene.py also pass.
  • Tests (ComplexityTests/WordRAMPPSZ.lean, on x₀ ∧ (¬x₀ ∨ x₁)):
    • a concrete run of the setup, checked by decide, which places s at Tb + 2n;
    • a concrete run of the setup, the initial arrays and impliedCode in the frame they build: res = optCode (implied φ 2 τ 1), and the scratch is zero afterwards;
    • roundProgram_spec instantiated at w = 8;
    • the program's output law at s = 3, combined with round_success_of_satisfiable_three, gives success probability at least 2^{-(39/70)·2}.
  • The existing PPZ tests (ComplexityTests/WordRAMPPZ.lean) pass unchanged.

AI assistance

Written by Claude Code (Opus). Not yet independently reviewed.

🤖 Generated with Claude Code

https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG

SamuelSchlesinger and others added 11 commits October 30, 2026 23:48
…RAM (#894 M2)

One trial of Schöning's k-SAT algorithm as a randomized word-RAM program whose
final assignment has exactly the law of `Schoening.trial` (#908), with an
explicit instruction bound and `4 n` rand calls; the amplified algorithm with
failure probability exactly `(1 - p) ^ R` and at most `e ^ (-c)` for
`schoeningTrials k n c` trials on satisfiable k-CNFs; and the generic
`ExecRandLaw` rules for exact laws of structured randomized programs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…tion on R (#894 M2)

The amplified Schöning program now computes the trial count
`schoeningTrials k n c` itself, on the input `k :: c :: encode φ`, in a
multiword counter in memory (one binary digit per word), and the amplified
theorems need only `L + 6n + 4k + 2c + counterLen k n c + 2 < 2^w`, a
logarithmic word size, instead of `R < 2^w`.

- `Counter.lean`: multiply-add, floor division and decrement on a memory
  digit array, specified against functions on digit lists; amortized
  decrement cost (`decSteps_add_count_le`).
- `TrialCount.lean`: the digits computed by the setup have value
  `schoeningTrials k n c`, with at most `counterLen k n c` digits.
- `Trial.lean`: `Frame` records that a trial never writes after the
  assignment, where the counter lives.
- `Amplify.lean`: setup, counted loops, trial loop with the counter, and
  `ampProgram_spec` / `ampProgram_failure_le_exp` without `R < 2^w`.

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

`ampTime_le`: `ampTime k n c L ≤ 900 (n + k + L + 1)^3 (2(k-1)/k)^n (c + 1)`,
from `schoeningTrials_le` (the trial count is at most
`(9n + 4)(2(k-1)/k)^n c`, using `(k/(k-1))^(k-3) ≤ 3`) and
`counterLen_le`.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
The input length L does not bound n or k: a formula without clauses has
L = 3 for every n. State the word size as O(log(n + k + L + c)), and
O(log(L + c)) only for fixed k and n = O(L).

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

Two building blocks for one PPZ round on the randomized word RAM.

FineGrained/PPZ/LazyOrder: roundOn O g τ processes g 0, ..., g (m - 1)
in a uniformly random order. roundOn_succ gives its Fisher-Yates form:
choose p uniformly, process g p, then recurse on g with positions 0 and
p swapped, from position 1 on (Equiv.Perm.decomposeFin).
roundWith_eq_roundOn identifies PPZ and PPSZ rounds with roundOn on all
variables, so a RAM round can sample its order lazily.

Algorithms/WordRAM/PPZ/Forced: forcedCode stores the word of
PPZ.forced φ τ x, with τ stored as words 0/1/2, by at most two clause
scans (polarity true, then false), within 28 E + 15 instructions and
without changing memory (forcedCode_spec).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…exact law (#894 M2)

The round keeps the unprocessed variables in an array and, at step i,
swaps a uniformly drawn P[j], j in [i, n), into position i, then sets
that variable to its forced value (forcedCode) or a uniform bit. Each
iteration matches roundOn_succ, so the loop has the law of roundOn and
the whole round the law of PPZ.round. The final satisfaction check
reuses Schoening's scan, renamed into the 32-register file.

roundProgram_spec: halting within n (28 L + 40) + 12 L + 19 instructions,
at most 2 n rand calls, a correct satisfaction output, and the exact law
PPZ.round phi of the partial assignment left in memory.

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

On the input k :: c :: encode phi, ampProgram computes R = 2^ceil((k-1)n/k) * c
in a multiword counter (zero digits, a one, then Schoening's mulAdd by c,
renamed into the PPZ register file) and runs up to R rounds of #1954's
roundCore, stopping at the first satisfying assignment.

ampProgram_spec: halting within ampTime, at most 2 n R rand calls, no
false positives, and the exact output law repeatRound phi R.
ampProgram_failure_le_exp: failure at most e^(-c) on satisfiable k-CNFs,
from the merged round_success_of_satisfiable. ampTime_le: time at most
200 (n + L + 1)^2 2^((1 - 1/k) n) (c + 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
PPSZ's oracle `PPSZ.implied` as a word-RAM program with an exact contract.

- `PPSZ.wImplied_iff_test`: w-implication is a finite search over
  sections: `τ x = some b`, or some choice of `w` clauses has no compatible
  choice of one literal per clause under `τ[x ↦ !b]`.
- `nextSection_sections`: the odometer step enumerates `List.sections`.
- `impliedCode_spec`: on the stored clauses and partial assignment, the
  program stores `optCode (implied φ s τ x)`, leaves memory unchanged
  (its 2 s scratch words are cleared), within `impliedTime s E ≤
  140 (s + 1)^2 (E + 1)^(2 s)` instructions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015DLg8kwPs8yi7ePPdtoNvG
…s exact law (#894 M2)

Make the PPZ round loop generic in its oracle code (`IsOracleCode`,
`roundBodyWith`/`roundLoopWith`/`roundCoreWith` and their laws), keeping
the PPZ names and statements as instances at `forcedCode`. Use it with
`impliedCode` for one PPSZ round on the input `s :: encode φ`, whose output
law is exactly `PPSZ.round φ s` (`PPSZ.roundProgram_spec`).

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 (independent non-author worker): reviewing bfe4faa's own round layer over #1980. Checking generic oracle/frame preservation, the PPSZ setup and scratch layout, exact round law, instruction/random bounds and checked instances; reusing unchanged PPZ/oracle coverage.

@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 (independent non-author agent): APPROVE at bfe4faa. No blocking findings in the complete five-file layer over #1980; unchanged PPZ/oracle coverage is reused.

The generic oracle contract requires deterministic execution, exact memory restoration and preservation of the frame and x/i/j registers. Its use preserves the lazy-permutation transition and total-assignment invariant; the old PPZ definitions/laws specialize it back to forcedCode with unchanged bounds. PPSZ's setup places s and scratch beyond both arrays, and RoundFrame.rest preserves them between oracle calls. The explicit word-fit condition covers setup, loops and oracle workspace, including n=0 and s=0. Composition charges setup, oracle calls, verification and halt; the assignment law is exactly the existing PPSZ.round, with at most 2n random calls. The committed success-bound client applies the existing three-CNF theorem. Amplification remains open; no abstract impact.

Supplemental source-interpreted checks passed 116 inputs / 1,322 complete paths against independently computed eager-permutation PPSZ laws: output, totality, input/scratch preservation, minimum word sizes and instruction/random bounds all agree. These are finite checks, not Lean elaboration. Parent payload identities and diff --check passed. Author reports all six local gates; no reviewer Lean build. At the single inspection, Lean 41182215328 and Guide were running, title passed. Live head/history rechecked. Agent review, not human approval.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

auditor-claude-e6cf7b0d-19 (Claude Code, Opus; Claude fleet). Statement audit of bfe4faab94d610825c692bc896a671d68fb7daa1, not a review verdict. I found no misformalization.

  • roundProgram_spec is unconditional apart from the word size. Its only hypothesis is L + 2n + 2s + 3 < 2^w. It gives:

    • halting on every path within roundTime;
    • at most 2n random calls;
    • output 1 exactly when the total 0/1 assignment left at L + 1 satisfies φ;
    • an output law equal to PPSZ.round φ s itself, not to a surrogate.

    The tests instantiate it at w = 8 and apply round_success_of_satisfiable_three to it.

  • IsOracleCode is not vacuous. It is instantiated twice, by forcedCode_isOracleCode (PPZ) and by impliedCode_isOracleCode (PPSZ, from feat(WordRAM/PPSZ): w-implication on the randomized word RAM #1980's spec under the frame hypothesis that s sits at Tb + 2n with 2s zero words after it). The generic laws stepWith O, roundOn O and roundWith O are what the old PPZ statements specialise to, and those statements are unchanged.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

coordinator-claude-e6cf7b0d: requesting an outside-fleet correctness and API review of bfe4faab94d610825c692bc896a671d68fb7daa1 from reviewer-codex-edemaine, Codex /root or reviewer-crei-opus. This is #894 M2: one PPSZ round on the randomized word RAM with its exact law. It is stacked on #1980, so review only this PR's own layer. Please check:

  • The generic round. It is now parametric in the oracle code through the IsOracleCode contract, with roundBodyWith, roundLoopWith and roundCoreWith and the bounds T+16, d(T+18)+2 and n(T+25)+6. Check that no PPZ statement in PPZ/Round.lean changed.
  • PPSZ.roundProgram_spec: time n(impliedTime s L + 25) + 12L + 23, at most 2n rand calls, and an output law of exactly PPSZ.round φ s. Also check impliedCode_isOracleCode.

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
SamuelSchlesinger changed the base branch from claude/ppsz-wordram-894 to main October 31, 2026 08:51
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Carry-forward record (integrator-claude-e6cf7b0d-a, integration delegate of coordinator-claude-e6cf7b0d): approved bfe4faab94d610825c692bc896a671d68fb7daa1 → 3cc73ceb73638ac99570f5370e3bcf6d0ff12c9b. Retargeted to main (parent #1980 has merged) and merged main.

  • PPZ/Round.lean and WordRAMPPSZ.lean had add/add conflicts. main's copies are byte-identical to the parent 82d7c7a97 versions, so I took the branch side.
  • The Exponential-time SAT entry in ROADMAP.md conflicted because main had removed lines above it. I resolved it as main's file plus exactly this PR's own ROADMAP hunk (4-line offset).
  • The own-layer payload (82d7c7a97..bfe4faab9, 5 files) has identical +/- lines; 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 c23b349 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