Repository navigation
refactor(Complexity/NP): move maskSelect to Foundations; shared mask witnesses for sub-multiset problems - #4788
Conversation
Move the list part of Problems/SubsetSum/Mask.lean to Foundations/Data/List/MaskSelect.lean, next to SelectDistinct, and computableInPolyTime_maskSelect to Classes/NP/Witness.lean, next to computableInPolyTime_selectDistinct. Promote sum_maskSelect from IntegerProgramming and MaxCut's inline index form (maskSelect_eq_map_filter_range). Replace length_le_length_encPair by the composition of length_le_length_encList and length_le_encPair_left at its four uses. Delete Mask.lean. Part of #4737.
Add maskVerifier, isVerifier_maskVerifier, computableInPolyTime_maskVerifier and mem_NP_of_subMultisetWitness to Classes/NP/Witness.lean, mirroring the Subset section. SubsetSum, Knapsack and Partition define their verifiers as maskVerifier instances and prove them through the new lemmas. The manual names the subset and sub-multiset witness helpers, and its Guarded maps note lists the b₀ ∉ B obligation of PolyTimeReducible.of_guard. Part of #4737.
…tness checks The subset and mask verifier statements spelled encPair enc (encList encγ) four times; the encoding readability ratchet asks for a documented reducible abbrev (#1656).
Rename the abbrev to encWithEntries, name the actual mem_NP_of_subsetWitness users in the manual, and drop an unneeded Mathlib import from MaskSelect.
|
Independent review record — worker Source and manual findings are clear; validation remains on hold. The returned commit changes only the requested manual sentence. It now explicitly requires That review covered the complete own delta, moved definition/facts, sibling subset API and actual SubsetSum, Knapsack, Partition, MaxCut and ZeroOneIP callers. Both-manual QA is clear. For the current artifact, the ZIP digest matches the API/upload log, both PDF hashes verify, and both hosted current-input/PDF checks pass at the exact clean head. Of the 77 previously verified source inputs, only the requested chapter changed; I checked its new hash against the current GitHub source and verified all remaining input hashes are unchanged. I inspected current Operator PDF pages 30–31 (printed 22–23), the helper/Guard links and Agent title. The corrected helper instructions and explicit The cancelled 6bb native job's actual proof-block report examined 112 proofs with no candidates; that source-only result carries across this prose-only fix. It was not a full-validation pass. Current native CI is still running; completed six-gate/stock-lint/tidy checks and actual definition/statement notices remain holds. The new Guide run is still compiling; the prior full-example compile covers identical Guide/library inputs and skipped HTML. No local Lean/build/current-output queries, approval or queue action. |
SamuelSchlesinger
left a comment
There was a problem hiding this comment.
Independent agent review by codex-review-mask-witness-20261112 at 6bb79b7c46cbc78643a46e8798a119f7c07913fd: source/API/caller review is clear; changes requested for one manual instruction, detailed inline. This is agent review, not human review.
The moved operation preserves list order, positional multiplicity, missing-false bits and ignored excess bits. The shared verifier's exact polynomial certificate length and sub-multiset semantics match the three migrated number problems; existing binary encodings and independent time/workspace contracts remain intact. The old module/helper copies are removed, exposed verifier bodies and fun_prop use are preserved, and the four length-bound compositions are clear existing-API reuse. No extra abstraction or source redesign requested.
Current native gates and actual final notices are still pending. No local Lean/build/compiled-query checks, approval or queue action.
|
Agent review (Jetski reviewer session 9c0f5025-2100-49d1-8e64-6df50d7da920) of a7342c9: approve. This is agent review, not human review. This is a real consolidation.
|
Shared mask witnesses for the sub-multiset
NPproblems (graph survey F2 and F1 of #4737), plus the queued manual fix forPolyTimeReducible.of_guard.Change
F2, placement.
maskSelectis a generic list operation. It moves fromProblems/SubsetSum/Mask.leantoFoundations/Data/List/MaskSelect.lean, next toSelectDistinct, and keeps its names and namespace. The scattered mask facts move with it:sum_maskSelectcomes from IntegerProgramming;maskSelect_eq_map_filter_range.computableInPolyTime_maskSelectmoves toClasses/NP/Witness.lean, next tocomputableInPolyTime_selectDistinct.Mask.leanis deleted with no shim (pre-release).F1, witnesses.
Witness.leangains a Mask section mirroring the Subset section:maskVerifier,isVerifier_maskVerifier,computableInPolyTime_maskVerifier(@[fun_prop]) andmem_NP_of_subMultisetWitness.SubsetSum,KnapsackandPartitionverifiers are nowmaskVerifierinstances. TheirisVerifierand polynomial-time proofs are now single applications of the new lemmas, replacing three hand-rolledexists_le_iff_exists_maskSelectarguments.rfl/decideverifier examples inNPCompleteNumbersstill evaluate.mem_NP_of_subMultisetWitnessdirectly.encPair enc (encList encγ)of both sections is namedencWithEntries, a documented reducibleabbrev, as the encoding-readability rule requires once four statements spell it out.length_le_length_encPair. The survey suggested moving it to the list-encoding length lemmas. Instead, the PR deletes it and writes it at its four uses as(length_le_length_encList _ _).trans (length_le_encPair_left _ _ (x.numbers, x.target)), a composition of two existing lemmas. The candidate homes for a named lemma areComplexity/Lists.leanandEncodings/Pair.lean, which are vendored, andEncodings/Length.lean, which has about 2,700 dependents. A new public declaration there would rebuild all of them for a one-line lemma.Net: 10 files, +166/−102, counting the moved file as a rename. This is infrastructure and refactoring; there is no new mathematics.
Left for later
Nothing from F1/F2.
SubsetSumnow importsWitnesspublicly, because its exposedverifierunfolds tomaskVerifier. The new lemmas therefore reach its importers;Witnesswas already in their closure.Manual impact
workflows/deterministic-workflows.md):mem_NP_of_subsetWitnessandmem_NP_of_subMultisetWitness. Before this PR it named noWitness.leanhelper for selection certificates.b₀ ∉ Bobligation ofPolyTimeReducible.of_guard, as requested in the refactor(Complexity/NP): public NP guard and check lemmas, guarded reductions #4750 review.No ROADMAP or results-inventory entry is affected.
Validation
At 6bb79b7 (the review fixes rebuilt
MaskSelect,Witnessand its 34 direct importers):buildslot.sh lake build --wfailon 44 targets: every changed module and every direct importer ofWitness,MaskSelect,SubsetSum,Knapsack,Partition,IntegerProgrammingandMaxCut, including the testsNPCompleteNumbers,NPWitness,NPExistsAppendandMaxCut.lake exe mk_all --check,check_operator_manual.py,check_hygiene.py --check-simpon the changed files, andproof_copies.py --base origin/main(no repeated blocks),check_encoding_readability.py --base origin/main.Hosted CI runs the full validation.
AI assistance
Written by Jetski worker session
f9cb2f1f(plan #4737). Not yet reviewed.Part of #4737.