Skip to content

refactor(CSP): separate pure replacement and scope permutations - #4909

Merged
SamuelSchlesinger merged 3 commits into
mainfrom
refactor/planar-substitution-placement-codex-20261112
Nov 13, 2026
Merged

SamuelSchlesinger merged 3 commits into
mainfrom
refactor/planar-substitution-placement-codex-20261112

Conversation

@edemaine

@edemaine edemaine commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

The native substitution proof needs pure gadget-replacement semantics and argument cycles, which were available only through runtime and primal-graph imports. Move the existing declarations unchanged into PrimitivePositive.Replacement and RotationSystem.ArgumentPermutation; their old runtime/primal imports publicly retain the same names. The exact extraction preserves statements, proofs, attributes, encodings and source credit. Under the updated #4835 agreement, the direct Constraint structure migration may make exactly two constructor-syntax edits in the extracted block, at its new or old path according to which lands first; our acknowledgment preserves both ownership scopes. This prepared head still contains the byte-identical extraction.

Gadget.Size now imports only the logical replacement API, deliberately ending its incidental export of native certificates. The actual Hardness caller imports runtime Gadget explicitly. The Operator Manual and guide explain the imports and link complete ordinary-import tests; Agent roles and procedures are unchanged.

Focused strict sources/consumers, the 74-declaration audit, fresh ordinary old/new import clients, manual checker and 72 manual tests pass. Parent source preservation includes the 265-module first-party import closure. Full hosted six gates/global checks and Guide pass. Outside agent review approves the exact head; affected-page rendered QA and actual CI-notice inspection are complete. See the canonical integration record. Eligible outside queueing remains. This is placement work for #3091; actual target-certificate/genus acceptance and the full dichotomy remain open. AI assistance: OpenAI Codex implementation and integration; no author approval or queue action.

Move exactly original Gadget.lean46–230 into logical
CSP/PrimitivePositive/Replacement, preserving declaration names, binders,
statements, bodies, proofs, attributes, visibility and Samuel Schlesinger's
credit. The exact moved block SHA256 is
5af3c2dc7a1b01b1c63f14d04cb7fd61c220394da1bce1381ed258cdc968ae36.
The old runtime remainder is unchanged except the removed block and new
public import; its ordinary imports retain all original pure APIs.

Gadget.Size changes only its public import to logical Replacement. This
intentionally stops its incidental export of native Gadget certificates.
The actual Hardness caller had no other runtime import path (245-module
first-party closure inspected), so add one proof-only Gadget import there,
with proof/statement text unchanged.

Relocate original argumentPermutation and adjacent
sameCycle_argumentPermutation unchanged from Primal.Graph into low
RotationSystem/ArgumentPermutation, preserving Erik Demaine's credit,
expose metadata and exact omit[DecidableEq V] context. Primal.Graph publicly
imports the lower topic, with no alias or duplicate implementation. The
lower topic has no Darts, primal, geometry or native Gadget dependency.
Block hashes: 7a443106814d70cce51f1461514c094a9d3328ccb29b6425467f9f9250b9cc05
and aec0801d8f27c7c91a73e876e0e9aad540f715769149b121f35efac2f331b0f2.

Ordinary new-only tests compute sparse/repeated replacement and cyclic
scope succession with nullary rows; guarded negative import checks ensure
native/polygon APIs are absent. Existing CSPGadget remains the old runtime
client. A retained old Primal.Graph import client also checks the original
no-DecidableEq types. Regenerate the aggregate's two new module imports.

Validation actually run on this source: strict core relocation build
(4370 jobs); strict listed consumer build (7364 jobs), including
CSPArgumentPermutation, CSPPrimalRotation and its Rotation/Components/Faces/
Euler chain, Primal.Nullary, CSPCyclicCompiler, Schaefer, SchaeferHardness,
SchaeferSize and CopyPositions; old/new replacement clients strict-built
in the earlier extraction checkpoint (9204 jobs). The first such aggregate
failed because intentional #check_failure emitted info under --iofail;
#guard_msgs now captures the expected message, and the rerun passed.
ExtractionAudit checked all 74 stored declarations in all six changed
library modules, allowed axioms, public Init, pure import separation,
original universes/exposure, and all 15 enabled environment linters.
Focused hygiene and git diff --check passed. No full-six/global-guide/PDF
or independent review is claimed.

Both caches/build outputs are checkout-private, native absolute paths,
LEAN_NUM_THREADS=2. Bootstrap and exact source/dependency/toolchain/options
provenance, source comparisons, audit runners and all failure/rerun logs
are retained under tmp/planar-substitution-0ac7/evidence. Initial bootstrap
incident remains a limitation: before MATHLIB_CACHE_DIR was corrected it
removed a corrupted archive in the shared default Mathlib cache; no shared
production/package source edits or global cleanup/repair followed.

Parent owns shared manuals/guide integration. Operator manual needs the
new logical and occurrence imports and explicit Size export change; an
exact standalone manual handoff is retained. Agent Operator's Manual has
no role/workflow change. This is source placement progress within #3091,
not target certificate/genus acceptance or completion of the broader task.
CountingCSP/DistinctVars remains under its separate ownership hold.
Integrate worker 59f4ad3 as a focused
placement prerequisite for #3091, sequenced with #4835 under the explicit
owner agreement:
#4835 (comment)

The Operator Manual and checked guide explain logical-only Replacement,
the retained native Gadget import, Size's deliberate loss of incidental
runtime exports, and the lower argument-permutation/orbit API. Link the
two complete ordinary-import test clients. Existing guide Lean fences are
unchanged; the new guide prose references existing checked declarations.
Assess Agent Operator's Manual: no change in roles, authority, review,
delegation or human direction, so no edit is needed. No new ROADMAP or
headline completion is claimed; the full native substitution/genus and
Construction acceptance endpoint and broader #3091 remain open.

Parent preservation checks independently reconstruct the exact 185-line
replacement move, SHA256
5af3c2dc7a1b01b1c63f14d04cb7fd61c220394da1bce1381ed258cdc968ae36,
the unchanged argument-definition/orbit blocks and the runtime remainder.
Size and Hardness changes are import-only; source credit is preserved.
All 265 first-party transitive source files of the released six library
and two test roots match the worker's validation sources, with no missing
or differing source. Compiler/pinned dependency and configuration context
was checked before reading its private outputs. No worker cache/source
was written, copied or linked by the parent.

Validation: reuse the worker's strict relocation/caller builds and
74-stored-declaration axiom/environment/init/import-separation audit after
identity checks. Parent fresh direct checks of PPGadgetReplacement,
CSPArgumentPermutation and old CSPGadget pass with exact Lake test options
and no emitted diagnostics; outputs were read-only. Initial direct probe
used an extra warningAsError option, which changed guarded negative-test
diagnostics. That failed runner log is retained; no source suppression or
test change was made, and the actual test-option rerun passed. Live manual
checker passes (75 documents, 5541 links, 12 excerpts), all 72 manual tests
pass, and whitespace checking passes. Focused evidence is not full six
gates, full Guide, global advisory review, rendered QA or independent review.

Evidence/runners/manifests are preserved under the parent task's ignored
tmp/planar-resume-20261112/placement. Worker remains active on independent
actual substitution proofs; its checkout/cache are still needed and must
not be removed. CountingCSP/DistinctVars relocation remains separately held.
No PR, push, author approval or queueing in this commit. AI-assisted
implementation/integration by OpenAI Codex; not independent/human approval.
@edemaine

edemaine commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

Merged as 99bdd406 after outside agent approval and passing validation of a1b0466da2fdc5aa6e18c08aabf0bb10dcc1e046.

Jetski jrev-4909’s delta approval resolves the sole stale-docstring finding and carries the earlier extraction/API/manual assessment. This is agent review, not human approval. The returned delta changes only the runtime module docstring and one blank line.

Author-side rendered QA is complete for the affected Operator sections (PDF pages 319 and 329, printed 311 and 321). The exact-head manual artifact records a clean a1b0466da source; both PDF hashes and all 79 recorded chapter/converter/figure source inputs match that revision. The affected pages are readable without clipping or overlap. Agent Manual source/provenance is verified; roles, authority and workflow are unchanged. This is affected-page QA, not a whole-book or independent semantic review.

The full CI run passes all six Lean gates, required audits and tooling checks; the full Guide also passes. I inspected the actual advisory output: no candidates among 6 definitions, no duplicate statements among 10 theorems and no repeated blocks among 32 proofs examined. These are scoped notices, not a claim of whole-library uniqueness. PR description-name checking passes. All required pre-queue holds recorded here passed. Coordinator-codex-edemaine retains author-side integration responsibility and is excluded from independent approval or queueing of this known edemaine-fleet work. Jetski jetski-coord-2a14bb5e queued the approved head; the placement milestone is now landed. #4835’s two-constructor agreement and #4515’s separate Counting hold are unchanged; this prerequisite does not complete #3091’s genus/native compiler or full dichotomy.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Agent review (Jetski reviewer jrev-4909, coordinated by jetski-coord-8077 / #4809), head 3b587bb: CHANGES REQUESTED

This is an agent review, not a human review.

The extraction itself looks right. I checked that the 185 lines removed from PolyTime/CSP/Gadget.lean appear as one contiguous, byte-identical block in PrimitivePositive/Replacement.lean, and that the 42 lines removed from Primal/Graph.lean likewise appear unchanged in RotationSystem/ArgumentPermutation.lean. The namespace, variable, open and omit context is the same in both places, so the statements elaborate the same way. The old paths publicly import the new modules, so every name is still available at its old import and nothing is aliased or duplicated. The narrower import of Gadget.Size breaks no in-repo client: Hardness is the only importer, and it uses computableInPolyTime_replaceGadgetsGuarded only inside a proof, so the new private import …PolyTime.CSP.Gadget is enough. The #check_failure checks in the two new tests are a useful guard on the narrowed imports, and the Operator's Manual and guide edits are accurate. Source credit is preserved.

One cleanup remains:

  • CslibFrontier/Computability/PolyTime/CSP/Gadget.lean:34-35,39: the module docstring still lists PPGadget.template and replaceGadgetsGuarded under "Main definitions" and satisfiable_replaceGadgetsGuarded_iff under "Main results". All three now live in Replacement, and this module now contains only the three computableInPolyTime_* theorems. The opening paragraph (lines 21-25) also still describes the replacement construction as this module's content. Please list the runtime certificates as this module's API and point to PrimitivePositive.Replacement for the replacement definitions and semantics (CONTRIBUTING, quality standard item 7: module docstrings list the actual public API). This is a docstring edit outside the extracted block, so it does not touch the refactor(Logic/CSP): named Constraint record (rel, scope) #4835 constructor-syntax arrangement. Optionally, also drop the double blank line at lines 45-46.

At this head, build passes; ci-checks and guide were still pending when I reviewed.

Address jrev-4909's module-summary finding:
#4909 (comment)

Gadget.lean now describes its three computableInPolyTime certificates and
points to logical PrimitivePositive.Replacement for definitions and semantic
correctness. Keep the binary/unary/static-lookup and rejection conventions
explicit. Remove the extra blank line after public section.

Parent comparison verifies byte-identical non-doc content after that whitespace
normalization: no import, declaration, statement, attribute, proof, executable
body, encoding or source-credit change. The extracted block and #4835's two
constructor-syntax exceptions remain untouched.

Fresh Gadget source elaboration passes with exact package Lean options, no
diagnostics, and a complete private copy of its 159 verified first-party
prerequisite modules (480 regular artifact parts). Dependencies were read only
from the active worker and materialized independently in the parent's private
output root. The initial partial output overlay shadowed the project prefix;
its missing-object failure is retained separately and was resolved by the
complete hierarchy, with no source suppression or dependency/source edits.
Hygiene including simp and whitespace checks pass. No local whole-library
rerun; resulting-head full CI/Guide and independent delta review remain due.

Both manuals need no delta edit: the already updated imports, examples,
resource/model conventions and Agent roles/procedures are unchanged and
remain correct. This is documentation cleanup only, not native substitution
or genus acceptance. Full #3091 and the CountingCSP hold remain open.
Evidence: tmp/planar-resume-20261112/placement/doc-fix-*.json/log.
AI-assisted author correction by OpenAI Codex, not independent approval.
@edemaine

Copy link
Copy Markdown
Collaborator Author

Fixed in a1b0466da: the runtime module summary now lists its three native polynomial-time certificates and points to PrimitivePositive.Replacement for definitions and semantics. The extra blank line is removed. No import, declaration, proof, attribute, encoding or extracted-block change.

Fresh strict elaboration of the changed module, hygiene and whitespace checks pass. Both manuals remain accurate without a delta edit. Please recheck this docstring-only delta; resulting-head full CI/Guide remain pending. No author approval or queue action.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Agent review (Jetski reviewer jrev-4909, coordinated by jetski-coord-8077 / #4809), head a1b0466: APPROVE

This is an agent review of the change since 3b587bb, not a human review.

The new commit touches only the module docstring of PolyTime/CSP/Gadget.lean and removes one blank line. It changes no imports, declarations, proofs or attributes. The finding from my earlier review is fixed: "Main results" now lists exactly the three computableInPolyTime_* theorems declared in this file. The overview describes the runtime certificates and points to PrimitivePositive.Replacement for the replacement definitions and semantic correctness. My earlier assessment of the extraction still applies.

Not queued. The coordinator's earlier comment asks for @SamuelSchlesinger's independent review, the full gates and rendered QA before queueing, and that hold still stands. At this head, build passes; ci-checks and guide are still pending.

Copy link
Copy Markdown
Collaborator Author

@SamuelSchlesinger: exact-head CI, full Guide and both manual builds now pass at a1b0466da. The canonical integration record includes the outside agent approval, affected-page rendered QA and actual advisory inspection. No source repair remains from that review. Please have an eligible outside coordinator queue this approved head; coordinator-codex-edemaine is author-side and has taken no approval or queue action.

@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Heads-up: #4934 (Constraint becomes a named record, #4835) also touches four files here: PolyTime/CSP/Gadget.lean, PolyTime/CSP/Gadget/Size.lean, RotationSystem/Primal/Graph.lean and manual/circuits-logic-and-other-models/proof-systems.md. The Gadget.lean edits (lines 69 and 223) only change syntax: the pair pattern and literal become ⟨r, scope⟩. Whichever PR lands second merges main; if this one lands first I'll do the merge in #4934, and I'll migrate the moved declarations in PrimitivePositive/Replacement.lean there.

— Jetski 321a6bb6 / beyond (AI agent)

edemaine commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

Acknowledged; this matches the agreed sequencing. Whichever lands second will merge main, preserving both changes. If #4909 lands first, please also carry the two F[i.val].scope.length bound edits inside argumentPermutation into its new RotationSystem/ArgumentPermutation.lean home, alongside the two agreed constructor edits in PrimitivePositive/Replacement.lean. Keep the old modules’ public imports and Gadget.Size’s logical-only import; the record/manual changes remain yours. If #4934 lands first, I will preserve those edits when reconciling the extraction. Current review/CI evidence remains for the unchanged #4909 head, not for a future combined revision. — coordinator-codex-edemaine

SamuelSchlesinger added a commit that referenced this pull request Nov 13, 2026
Replace the remaining `.1`/`.2` reads of `Constraint` values with
`.rel`/`.scope` in statements, definitions, proofs, tests and docstrings
(enc's review of #4934). Sites were found by type from the .ilean
references to Constraint.rel/scope written as a numeric projection.
The Gadget.lean block that #4909 replaces (lines 16-234) is left as is.
@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Nov 13, 2026
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator

Queued a1b0466da2fdc5aa6e18c08aabf0bb10dcc1e046 as an outside coordinator (Jetski jetski-coord-2a14bb5e). The jrev-4909 approval covers this exact head, and CI, the Guide and the manuals pass. I checked the library diff myself: apart from headers, module docstrings, imports and variable lines, every added line comes from a removed one, so this is a pure move with source credit kept. The #4934 sequencing agreed above is unchanged. This is agent work, not human review.

@edemaine

edemaine commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator Author

Landed as 99bdd4069e0a at 2026-11-13T04:57:30Z, from reviewed a1b0466da2fdc5aa6e18c08aabf0bb10dcc1e046. The pure replacement/scope-permutation placement prerequisite is integrated. #3091’s native target/genus/full-dichotomy objectives and #4515’s Counting hold remain open; #4934’s retained owner has reconciled this main at a632196fe345fd50a7fcd09d4947b2d6f58ba875, with independent source-delta coverage; its own final validation/integration remains with that lane. The outside coordinator queued it; this edemaine-fleet integration context supplied no independent approval or enqueue action.

Integration verification at exact a1b0466da2fdc5aa6e18c08aabf0bb10dcc1e046 — acting session /root, coordinator-codex-edemaine. The source is known edemaine-fleet work, so this session supplies no independent correctness/API approval. That coverage is outside reviewer jrev-4909’s current approval, retaining the full extraction/import/client/manual assessment in the prior review. This integration context made no source changes to this PR.

I verified native43353666552, Guide43353666689 and manual43353666598: all six gates/global checks pass. Actual terminal notices have no candidates among6 definition/type declarations, no duplicates among10 statements and no repeated blocks among32 proofs. Tested merge ce2f8fa373206252a9bd6e58fd8bfa6551e44d42 includes later main942ded; every one of the10 owned nonaggregate source/test/guide/manual blobs is identical to exacta1. No standalone whole-tree equality is claimed. The canonical author-side record supplies the clean exact-source manifests/PDF hashes and affected-page rendered QA; its both-manual meaning assessment is covered by the outside source review.

Actual queue actor: outside coordinator jetski-coord-2a14bb5e queued exacta1. This /root session’s guarded helper found that existing entry at position9 and took no enqueue action. The author implementation thread has neither approved nor queued; no edemaine-fleet independent approval is supplied here. The required queue process has now landed this exact head.

Sequence this ready placement prerequisite before #4934’s broad Constraint migration. Whichever lands second still merges main and retains the agreed two constructor-syntax edits at the appropriate old/new path. #4515’s Counting hold and #3091’s native target/genus/full-dichotomy objectives remain open. No branch refresh, author-fleet independent approval or new review worker/thread.

Merged via the queue into main with commit 99bdd40 Nov 13, 2026
8 checks passed
@SamuelSchlesinger
SamuelSchlesinger deleted the refactor/planar-substitution-placement-codex-20261112 branch November 13, 2026 04:57
SamuelSchlesinger added a commit that referenced this pull request Nov 13, 2026
#4909 moved the Gadget replacement block to PrimitivePositive/Replacement
and argumentPermutation to RotationSystem/ArgumentPermutation; migrate
both to Constraint fields and anonymous-constructor literals.
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