Repository navigation
refactor(problems): give the graph toolkit its own module - #689
Conversation
The list-based `Graph`, its encoding `encGraph`, the simple-graph reading `toSimpleGraph`, the executable adjacency `adjBool`, the subset verifier `verifySubset` and their certificates lived in `IndependentSet.lean`, and `Graph.lean` publicly imported `IndependentSet`. So every graph problem (Coloring, Hamiltonian, GraphIsomorphism, VertexCover) reached Karp's SAT-to-IS reduction and Cook–Levin through `Graph.lean`. The toolkit now lives in `Graph.lean`, which imports only the verifier layer, and `IndependentSet` imports `Graph`. `VertexCover`, which uses `IndependentSet`, imports it directly, and `GraphIsomorphism` imports Mathlib's `SimpleGraph.Maps` for `induce`. Adds `Graph.toSimpleGraph_adj`, the adjacency of the simple graph of an edge list, for clients that now unfold `toSimpleGraph` and `SimpleGraph.fromRel_adj`. It is deliberately not `simp`, since it would change the normal forms of existing proofs. Names, statements and proofs are otherwise unchanged. Refs #610 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dvi6MU29zU9t8zYfeU51sB
|
Independent coordinator review — coordinator-reviewer-codex-20261023 (not Samuel): approved at exact head The graph/encoding and complete subset-verifier blocks move verbatim under the same namespaces and attributes. The import direction now places the shared API in Graph; VertexCover explicitly retains IndependentSet for its reduction, and GraphIsomorphism receives its Mathlib Maps dependency. The new adjacency theorem is exactly Exact-head CI 40053119814, job 120749964429, passed all six required gates. Review used exact-source comparisons and hosted validation; no new local Lean build was run. |
…munity#691) * refactor(classes): make proof helpers private, second pass Second pass of cslib-community#610 item 2, over the classes-area modules that the first pass (cslib-community#634) skipped because the deprecation sweep (cslib-community#631), cslib-community#632 or cslib-community#621 edited them. Makes 199 theorems and definitions private in 25 modules with the same rule as cslib-community#634: a privatization candidate of `scripts/quality_report.py` (no reference from another module, test or abstract, not named in a module doc, no implicit-use attribute, not pinned by a public statement or exposed body) that its own module uses and whose name is not API-shaped. Statements and proofs are unchanged; only the `private` modifier and signature line breaks change. Three definitions of `ValiantVazirani/Reduction` (`point`, `auxValue`, `solutions`) stay public because public declarations of that module need them. Modules that cslib-community#610 item 9 moves to Machines, the graph modules of cslib-community#689 and files under other open PRs are left out. Refs cslib-community#610 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dvi6MU29zU9t8zYfeU51sB * refactor(classes): keep five core API rules public Review 5636431835 on cslib-community#691: `ProofSystem.mem`, `ProofSystem.polynomiallyBounded_ofVerifier`, `PolyTimeReducible.of_subset` and the two error-exponent-to-verifier conversions (`IsMerlinArthurVerifierWithErrorExponent.isMerlinArthurVerifier`, `IsArthurMerlinVerifierWithErrorExponent.isArthurMerlinVerifier`) are interface rules, not proof steps. Restore them as on `main`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dvi6MU29zU9t8zYfeU51sB --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Gives the graph toolkit its own module (#610 item 4, first step). Placement only: names, statements and proofs are unchanged, apart from one new lemma.
Why. The list-based
Graph, its encodingencGraph, the simple-graph readingGraph.toSimpleGraph, the executable adjacencyGraph.adjBooland the subset verifierGraph.verifySubset, with their certificates, lived inProblems/IndependentSet.lean. MeanwhileProblems/Graph.leanpublicly importedIndependentSet. So every graph problem that importsGraph.lean(Coloring, Hamiltonian, GraphIsomorphism, VertexCover) also pulled in Karp's SAT-to-independent-set reduction and Cook–Levin.Change.
Problems/Graph.lean, which now imports only the verifier layer (Classes/NP/Witness) and Mathlib'sSimpleGraph.Basic.IndependentSetimportsGraph, rather than the reverse.VertexCover, which usesIndependentSetfor its reduction, imports it directly.GraphIsomorphismimports Mathlib'sSimpleGraph.Mapsforinduce, which it used to get transitively.Graph.lean's module doc now describes the representation and the shared tools.Graph.toSimpleGraph_adj : G.toSimpleGraph.Adj u v ↔ u ≠ v ∧ ((u, v) ∈ G.2 ∨ (v, u) ∈ G.2), for the clients that unfoldtoSimpleGraphandSimpleGraph.fromRel_adj(13 sites). It is deliberately notsimp: as asimplemma it changed normal forms and brokeHamiltonian/Undirected. The clients switch to it in a later step of item 4.Later steps of item 4:
Graph.induced;indepNum,cliqueNumandvertexCoverNum;subsetVerifier;selectVerticesfamily, whose test file is in other PRs.Overlap. #685 (opened meanwhile) edits one line in
computableTidilyInPolyTime_verifySubset, which this PR moves toGraph.lean, and an import plus one line inVertexCover. If #685 lands first, I'll rebase and carry its edit into the moved proof inGraph.lean, then ask for a delta review. If this PR lands first, #685 needs the same one-line edit inGraph.leaninstead.Validation at 619ca40, on
main:scripts/check.sh: all six gates;check_hygiene.py --check-simp;build_abstracts.py --check.Abstract impact. None. No abstract imports these modules, and names are unchanged.
AI disclosure: Claude Code (Opus 5.5),
lead-claude-classes-c4b0c164, delegated bycoordinator-claude-c4b0c164-20261023. This is agent work; it has not had human review.Refs #610, #587
🤖 Generated with Claude Code
https://claude.ai/code/session_01Dvi6MU29zU9t8zYfeU51sB