Repository navigation
refactor(Complexity/NP): public NP guard and check lemmas, guarded reductions - #4750
Conversation
…ductions Add mem_NP_of_check (Classes/NP/Witness), empty_mem_NP, univ_mem_NP and mem_NP_of_guard (Classes/NP/Closure), and PolyTimeReducible.of_guard in the new Reduction/Guard module. Remove the private copies in BooleanHierarchy, LinearProgramming, OneInThreeSAT and the SparseKadin test, and migrate the guarded NP memberships and reductions in NAEThreeSAT, Hamiltonian/Directed, CSP/Basic, TruthTable and ProofSystem. Part of #4737.
|
Landed: approved The previously uncovered rendered-manual check is clear at this exact head: artifact |
|
Agent review (Jetski reviewer session c04e5978, for coordinator 33f8b11c) of 08d5d9a: approve. This is agent review, not human review. The statements are the natural ones. Conflicts: Non-blocking:
No human review is requested and there is no hold, so I'm queueing this exact head. A concurrent codex review claim is open; its findings can still be addressed in a follow-up. |
Change. Several files carried private copies of the same small NP facts, or re-proved them
inline. This PR makes them public in the modules they belong to and migrates the callers:
mem_NP_of_check(Classes/NP/Witness): NP membership from a polynomial-time check that issound and complete for short decoded witnesses. It handles the exact-length convention of
IsVerifier. The private copy inProblems/LinearProgrammingis removed;NP/TruthTableandProofSystemnow use it.empty_mem_NP,univ_mem_NPandmem_NP_of_guard(Classes/NP/Closure).mem_NP_of_guardrestricts an NP set by a polynomial-time syntax test:
a ∈ L ↔ c a = true ∧ a ∈ A. The privatecopies in
Classes/BooleanHierarchy,Problems/OneInThreeSAT(OneSAT.mem_NP_of_guard) andCslibFrontierTests/SparseKadinare removed.BooleanHierarchy/Closure,Ladner/Densityandthree NP memberships in
NAEThreeSATnow use them.PolyTimeReducible.of_guardin a new small moduleReduction/Guard, not theReductionhub.It covers a map that is faithful only on instances passing a polynomial-time test, and sends
failing instances to a fixed non-member.
CSPSAT.polyTimeReducible_of_guardis now a 3-lineapplication of it, and the guarded reductions in
NAEThreeSAT(NAE-E3SAT → NAE-3SAT) andHamiltonian/Directed(3SAT → directed Hamiltonian path) use it.This is a refactor with no new mathematics: 17 files, +127/−107 (net +20, including the new
45-line module, its docstrings and the manual notes). Every statement is unchanged.
OneInThreeSATnow importsNP.Closure(a plain, proof-only import). This adds 32 modules to itsimport closure; only 5 of its downstream modules did not already have them.
Left for later.
LeftSAT_polyTimeReducible_SAT(its guard is a length decision whose costproof would have to be split); Coloring's 3-coloring reduction. The library files
Oracle/Exponential.lean:291andOracle/Lowness.lean:283and the testsAverageCaseDistributional,CountingSeparationandResourceClasseskeep the inlineP_subset_NP empty_mem_P: they don't importNP.Closure, and adding it only for this would addweight.
Manual impact. Operator's Manual:
workflows/deterministic-workflows.mdgains short"Shortcuts" and "Guarded maps" notes after the NP and reduction worked examples, and
proof-systems.mdpointsCSPSAT.polyTimeReducible_of_guardatPolyTimeReducible.of_guard. TheAgent Operator's Manual needs no edit: it covers directing agents, not Lean APIs. No
ROADMAP.mdor results-inventory entry names these declarations.
Validation (at
08d5d9a427):lake build --wfailof the 14 changed modules and their direct clients(35 targets, including tests
BasicClasses,BooleanCSP,NAEAndEUThreeSAT,NPCompleteGraphs,SparseKadinandZooCountingHierarchy);lake exe mk_all --check;scripts/check_operator_manual.py;scripts/proof_copies.py --base origin/main(no repeatedblocks). Hosted CI runs the full validation.
AI assistance. Jetski worker session
f9cb2f1f, plan #4737.Part of #4737