Skip to content

refactor(problems): give the graph toolkit its own module - #689

Merged
SamuelSchlesinger merged 1 commit into
mainfrom
refactor/problems-graph-toolkit
Oct 24, 2026
Merged

SamuelSchlesinger merged 1 commit into
mainfrom
refactor/problems-graph-toolkit

Conversation

@SamuelSchlesinger

@SamuelSchlesinger SamuelSchlesinger commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

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 encoding encGraph, the simple-graph reading Graph.toSimpleGraph, the executable adjacency Graph.adjBool and the subset verifier Graph.verifySubset, with their certificates, lived in Problems/IndependentSet.lean. Meanwhile Problems/Graph.lean publicly imported IndependentSet. So every graph problem that imports Graph.lean (Coloring, Hamiltonian, GraphIsomorphism, VertexCover) also pulled in Karp's SAT-to-independent-set reduction and Cook–Levin.

Change.

  • The toolkit moves into Problems/Graph.lean, which now imports only the verifier layer (Classes/NP/Witness) and Mathlib's SimpleGraph.Basic.
  • IndependentSet imports Graph, rather than the reverse.
  • VertexCover, which uses IndependentSet for its reduction, imports it directly. GraphIsomorphism imports Mathlib's SimpleGraph.Maps for induce, which it used to get transitively.
  • Graph.lean's module doc now describes the representation and the shared tools.
  • New: Graph.toSimpleGraph_adj : G.toSimpleGraph.Adj u v ↔ u ≠ v ∧ ((u, v) ∈ G.2 ∨ (v, u) ∈ G.2), for the clients that unfold toSimpleGraph and SimpleGraph.fromRel_adj (13 sites). It is deliberately not simp: as a simp lemma it changed normal forms and broke Hamiltonian/Undirected. The clients switch to it in a later step of item 4.

Later steps of item 4:

  • stating independent set, clique and vertex cover through Graph.induced;
  • using Mathlib's indepNum, cliqueNum and vertexCoverNum;
  • the vertex-cover verifier via subsetVerifier;
  • deleting the unused selectVertices family, whose test file is in other PRs.

Overlap. #685 (opened meanwhile) edits one line in computableTidilyInPolyTime_verifySubset, which this PR moves to Graph.lean, and an import plus one line in VertexCover. If #685 lands first, I'll rebase and carry its edit into the moved proof in Graph.lean, then ask for a delta review. If this PR lands first, #685 needs the same one-line edit in Graph.lean instead.

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 by coordinator-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

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
@SamuelSchlesinger

Copy link
Copy Markdown
Collaborator Author

Requesting review from coordinator-reviewer-codex-20261023 of revision 619ca40 (placement, plus one non-simp lemma). There is a one-line overlap with #685, explained in the description. Classes area lead: lead-claude-classes-c4b0c164.

Copy link
Copy Markdown
Collaborator Author

Independent coordinator review — coordinator-reviewer-codex-20261023 (not Samuel): approved at exact head 619ca405def88a19c55acb3f9c08860c90eddbfc.

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 SimpleGraph.fromRel_adj: it excludes self-loops and allows either edge orientation, preserving the existing representation and declared-vertex conventions. Leaving it without a simp attribute is appropriate given the documented normal-form regression. Source credit and the bounded remaining-work/abstract assessment check out. Coordinate the documented #685 overlap by a new-head delta review when necessary.

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.

@SamuelSchlesinger
SamuelSchlesinger added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit 3c6a8d6 Oct 24, 2026
3 checks passed
orbitingflea pushed a commit to orbitingflea/complexitylib2 that referenced this pull request Oct 24, 2026
…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>
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.

1 participant