Skip to content

Commit 3ead548

Browse files
GiggleLiuclaude
andauthored
docs: Add reduction classification and detailed survey (#9)
* docs: Add reduction classification and detailed survey - Add Typst document (docs/paper/reductions.typ) with: - Formal problem definitions - Reduction theorems with proofs - Classification of reductions as trivial vs non-trivial - Detailed survey of 7 non-trivial reductions with references - Auto-generated reduction graph from JSON - Add JSON export for reduction graph: - ReductionGraphJson, NodeJson, EdgeJson structs in graph.rs - Automatic layered layout algorithm - export_graph example to generate JSON - Update mdBook documentation: - Add Mermaid diagram to reductions/graph.md - Expand available.md with all 17 reductions and citations - Add CircuitSAT and Factoring to satisfiability.md - Add references.bib with academic citations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Correct citation for Factoring→CircuitSAT reduction Remove incorrect Shor 1994 reference (quantum algorithm) and add note that this is a folklore result using classical array multiplier circuits. The construction is standard in hardware verification and has no single canonical academic reference. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: Polish writing to NeurIPS academic standard - Tighten prose with concise mathematical definitions - Use consistent formal notation throughout - Improve theorem statements with compact formatting - Restructure sections for better flow - Use proper figure references (@fig:reduction-graph) - Condense detailed constructions while preserving rigor 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: Combine detailed constructions with theorem/proof structure - Merge Section 5 (Detailed Constructions) into Section 3 (Reductions) - Each theorem now includes full constructive proof - Wrap tables in figures with captions (tab:gadgets, tab:summary) - Add summary table with all reductions and references - Fix deprecated `sect` to `inter` for set intersection 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: Improve summary table with overhead column and gray highlighting - Remove Type column, use gray background for trivial reductions - Add Overhead column showing reduction complexity - Update caption to explain gray row meaning 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: Add notation section and improve symbol introductions - Add Notation subsection defining graph notation G=(V,E), complement, cardinality, negation, literals, clauses, CNF, and abbreviations - Expand definition titles to include abbreviations (IS, VC) - Clarify SAT definition with explicit mention of clauses and literals - Improve Spin Glass definition with Hamiltonian explanation - Clarify Circuit-SAT gate types and Factoring bit representation - Add introductory sentence for graph problems section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: Verify facts and fix references Reference verification: - Karp 1972: Verified for SAT→IS (Karp's 21 NP-complete problems) - Garey & Johnson 1979: Verified for SAT→Coloring, SAT→DominatingSet - Cook 1971: Verified for Cook-Levin theorem - Whitfield 2012: Verified for ground-state spin logic gate gadgets - Lucas 2014: Verified for comprehensive Ising formulations of NP problems - Barahona 1982: Verified for Ising/MaxCut NP-hardness Fixes: - Remove nguyen2023 from CircuitSAT→SpinGlass (paper is about tensor network inference, not circuit reductions) - Add lucas2014 to SpinGlass↔MaxCut summary table reference 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: Improve test coverage for ReductionGraph module Add comprehensive tests for: - categorize_type() function with all problem categories - simplify_type_name() function - SAT-based reductions (SAT→IS, SAT→Coloring, SAT→DominatingSet) - Circuit reductions (Factoring→CircuitSAT→SpinGlass path) - Optimization reductions (SpinGlass↔QUBO, MaxCut↔SpinGlass) - k-SAT reductions (SAT↔3-SAT bidirectional) - JSON layout positions validation - All categories presence in JSON output - Edge cases for ReductionPath (empty, single node) - Default trait implementation - File I/O for to_json_file() Test count increased from 11 to 23 tests for the graph module. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Fix clippy warnings and improve test coverage Clippy fixes: - Replace `.len() > 0` with `!.is_empty()` in JSON validation tests Additional tests for edge case coverage: - test_has_direct_reduction_unregistered_types - test_find_paths_unregistered_source - test_find_paths_unregistered_target - test_find_shortest_path_no_path - test_json_node_positions_all_finite - test_categorize_circuit_as_specialized Test count increased from 23 to 29 for the graph module. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Correct Factoring→CircuitSAT citation and remove unused refs - Change Shor 1994 to Folklore for Factoring→CircuitSAT reduction (Shor's paper is about quantum algorithms, not classical circuits) - Remove unused shor1994 and nguyen2023 from references.bib The Factoring→CircuitSAT reduction uses standard array multiplier circuits, a well-known technique in hardware verification with no single canonical academic reference. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * test: Add coverage tests for ReductionGraph layout - Add test_layout_layer_ordering to verify layer hierarchy - Add test_multiple_nodes_per_layer_spacing for x-coordinate spacing - Add test_edge_bidirectionality_detection for edge direction detection - Add test_simplify_type_name_edge_cases for edge case handling These tests improve patch coverage for the layout computation code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: Simplify layout code to remove dead branches Refactor compute_layered_layout to use direct name-based checks instead of categorize_type, eliminating unreachable code branches that caused coverage gaps. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: Remove unused iteration limit in BFS layout The iteration limit was defensive code that never executed since the BFS traverses a finite DAG. Removing it improves code coverage. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: Move layout computation from Rust to Typst - Remove x, y position fields from NodeJson struct - Remove compute_layered_layout function from Rust - Remove position-related tests - Add manual node-positions dictionary in Typst for layered layout - JSON now exports only topology (id, label, category, edges) This simplifies the Rust code and delegates visualization concerns to the presentation layer (Typst). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: Clean up Typst layout with explicit positions Fletcher doesn't support auto positioning for arbitrary nodes. Keep manual layered positions in Typst dictionary for clarity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: Optimize graph layout with compact node positions - Use node ID for position lookup (handles duplicate labels like SpinGlass) - Two-branch layout: SAT (left) + Physics (right) - Connected nodes placed close together - Clear hierarchical flow from top to bottom 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Unify SpinGlass types in ReductionGraph visualization Register only SpinGlass<f64> in the graph to avoid duplicate nodes with identical labels. Update edges and tests accordingly: - MaxCut<i32> -> SpinGlass<f64> - CircuitSAT<i32> -> SpinGlass<f64> The actual reduction implementations remain generic and work with any compatible weight type. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: Use type-erased names for ReductionGraph topology Change ReductionGraph to use base type names (e.g., "SpinGlass" instead of "SpinGlass<i32>") for graph topology. This allows finding reduction paths regardless of weight type parameters. Changes: - Graph nodes now store base type names, not TypeId - Multiple concrete types (e.g., MaxCut<i32>, MaxCut<f64>) map to same node - Add find_paths_by_name() and has_direct_reduction_by_name() methods - Update JSON export to use simplified names - Update Typst positions to match new node IDs This design separates topology (which problems reduce to which) from type-specific implementation details. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c64ac3f commit 3ead548

15 files changed

Lines changed: 4309 additions & 162 deletions

File tree

Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Makefile for problemreductions
22

3-
.PHONY: help build test fmt clippy doc clean coverage
3+
.PHONY: help build test fmt clippy doc mdbook paper clean coverage
44

55
# Default target
66
help:
@@ -10,7 +10,9 @@ help:
1010
@echo " fmt - Format code with rustfmt"
1111
@echo " fmt-check - Check code formatting"
1212
@echo " clippy - Run clippy lints"
13-
@echo " doc - Build and open documentation"
13+
@echo " doc - Build mdBook documentation"
14+
@echo " mdbook - Build and serve mdBook (with live reload)"
15+
@echo " paper - Build Typst paper (requires typst)"
1416
@echo " coverage - Generate coverage report (requires cargo-llvm-cov)"
1517
@echo " clean - Clean build artifacts"
1618
@echo " check - Quick check (fmt + clippy + test)"
@@ -35,9 +37,18 @@ fmt-check:
3537
clippy:
3638
cargo clippy --all-targets --all-features -- -D warnings
3739

38-
# Build and open documentation
40+
# Build mdBook documentation
3941
doc:
40-
cargo doc --all-features --no-deps --open
42+
mdbook build docs
43+
44+
# Build and serve mdBook with live reload
45+
mdbook:
46+
mdbook serve docs --open
47+
48+
# Build Typst paper
49+
paper:
50+
cargo run --example export_graph
51+
cd docs/paper && typst compile reductions.typ reductions.pdf
4152

4253
# Generate coverage report (requires: cargo install cargo-llvm-cov)
4354
coverage:

book.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ description = "A Rust library for reducing NP-hard problems"
55
language = "en"
66
src = "docs/src"
77

8+
[preprocessor.mermaid]
9+
command = "mdbook-mermaid"
10+
811
[output.html]
912
default-theme = "rust"
1013
git-repository-url = "https://github.com/liujinguo/problemreductions"
1114
edit-url-template = "https://github.com/liujinguo/problemreductions/edit/main/{path}"
1215
additional-css = []
13-
additional-js = []
16+
additional-js = ["mermaid.min.js", "mermaid-init.js"]
1417
no-section-label = false
1518

1619
[output.html.fold]

docs/paper/reduction_graph.json

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"nodes": [
3+
{
4+
"id": "MaxCut",
5+
"label": "MaxCut",
6+
"category": "graph"
7+
},
8+
{
9+
"id": "DominatingSet",
10+
"label": "DominatingSet",
11+
"category": "graph"
12+
},
13+
{
14+
"id": "SpinGlass",
15+
"label": "SpinGlass",
16+
"category": "optimization"
17+
},
18+
{
19+
"id": "QUBO",
20+
"label": "QUBO",
21+
"category": "optimization"
22+
},
23+
{
24+
"id": "IndependentSet",
25+
"label": "IndependentSet",
26+
"category": "graph"
27+
},
28+
{
29+
"id": "SetPacking",
30+
"label": "SetPacking",
31+
"category": "set"
32+
},
33+
{
34+
"id": "Satisfiability",
35+
"label": "Satisfiability",
36+
"category": "satisfiability"
37+
},
38+
{
39+
"id": "Coloring",
40+
"label": "Coloring",
41+
"category": "graph"
42+
},
43+
{
44+
"id": "VertexCovering",
45+
"label": "VertexCovering",
46+
"category": "graph"
47+
},
48+
{
49+
"id": "KSatisfiability",
50+
"label": "KSatisfiability",
51+
"category": "satisfiability"
52+
},
53+
{
54+
"id": "CircuitSAT",
55+
"label": "CircuitSAT",
56+
"category": "satisfiability"
57+
},
58+
{
59+
"id": "Factoring",
60+
"label": "Factoring",
61+
"category": "specialized"
62+
},
63+
{
64+
"id": "Matching",
65+
"label": "Matching",
66+
"category": "graph"
67+
},
68+
{
69+
"id": "SetCovering",
70+
"label": "SetCovering",
71+
"category": "set"
72+
}
73+
],
74+
"edges": [
75+
{
76+
"source": "CircuitSAT",
77+
"target": "SpinGlass",
78+
"bidirectional": false
79+
},
80+
{
81+
"source": "Matching",
82+
"target": "SetPacking",
83+
"bidirectional": false
84+
},
85+
{
86+
"source": "Satisfiability",
87+
"target": "KSatisfiability",
88+
"bidirectional": true
89+
},
90+
{
91+
"source": "Factoring",
92+
"target": "CircuitSAT",
93+
"bidirectional": false
94+
},
95+
{
96+
"source": "IndependentSet",
97+
"target": "SetPacking",
98+
"bidirectional": true
99+
},
100+
{
101+
"source": "SpinGlass",
102+
"target": "QUBO",
103+
"bidirectional": true
104+
},
105+
{
106+
"source": "MaxCut",
107+
"target": "SpinGlass",
108+
"bidirectional": true
109+
},
110+
{
111+
"source": "VertexCovering",
112+
"target": "SetCovering",
113+
"bidirectional": false
114+
},
115+
{
116+
"source": "Satisfiability",
117+
"target": "IndependentSet",
118+
"bidirectional": false
119+
},
120+
{
121+
"source": "Satisfiability",
122+
"target": "Coloring",
123+
"bidirectional": false
124+
},
125+
{
126+
"source": "IndependentSet",
127+
"target": "VertexCovering",
128+
"bidirectional": true
129+
},
130+
{
131+
"source": "Satisfiability",
132+
"target": "DominatingSet",
133+
"bidirectional": false
134+
}
135+
]
136+
}

0 commit comments

Comments
 (0)