Skip to content

Commit dc2ccf1

Browse files
GiggleLiuclaude
andauthored
docs: polish reductions.typ with theorem labels and cleanup (#31)
* Add design doc for polishing reductions.typ 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Update design: integrate reference package insights - Add detailed metrics output inspired by UnitDiskMapping.jl - Use instances from reference packages for cross-verification - Document reference sources in example docstrings - Update example template with transformation metrics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Clarify: use existing export_petersen_mapping for unit disk example Unit disk mapping (IS → GridGraph IS) already has a working example. No need to create a new reduction example for it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Polish export_petersen_mapping example to match new format - Add detailed docstring with mathematical equivalence - Add structured output with transformation metrics - Reference UnitDiskMapping.jl source - Keep JSON export functionality for paper visualization - Format consistent with new example template 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Add JSON export requirement to example files All examples should export structured JSON data to docs/paper/examples/ for embedding in the Typst paper. Also clarify: - Split existing qubo_reductions.rs into 6 separate files - Add docs/paper/examples/ to gitignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Add docs/paper/examples/ to gitignore Example programs will generate JSON files in this directory for use in the Typst paper. These are build artifacts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * docs: add implementation plan for reductions.typ polish 5-pass approach with ~50-60 bite-sized tasks: - Pass 1: Add theorem labels (5 tasks) - Pass 2: Enhance problem definitions (7 tasks) - Pass 3: Expand proofs and add links (5 tasks) - Pass 4: Create 28 example files (5 tasks) - Pass 5: Final verification (5 tasks) Each task is 2-5 minutes with clear steps, commands, and expected outputs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * docs: add theorem labels and clean up problem definitions Pass 1 of reductions.typ polish: - Added <thm:*> labels to all 21 theorems for cross-referencing - Moved table of contents after abstract with pagebreak - Removed verbose impl Problem blocks from code examples Labels added: - Trivial: is-vc, is-to-setpacking, vc-to-setcovering, matching-to-setpacking, spinglass-qubo - QUBO: is-to-qubo, vc-to-qubo, coloring-to-qubo, setpacking-to-qubo, ksat-to-qubo, ilp-to-qubo - Non-trivial: sat-to-is, sat-to-coloring, sat-to-dominatingset, sat-ksat, circuit-to-spinglass, factoring-to-circuit, spinglass-maxcut, coloring-to-ilp, factoring-to-ilp, is-to-gridgraph 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: polish reductions paper and add 30 standalone example files - Enhance 15 problem definitions with field mapping paragraphs and theorem cross-references (replacing reduces-to/from problem links) - Add 7 new ILP formulation theorems (IS, VC, Matching, SetPacking, SetCovering, DominatingSet, Clique → ILP) with proofs - Expand trivial reduction proofs with explicit variable mappings - Add GitHub example links after all 28 theorem blocks - Create 30 standalone reduction example files with docstrings, closed-loop verification, and JSON export for paper visualization - Fix Typst compilation: replace invalid `ni` symbol with `in.rev`, enable theorem numbering for cross-references - Update summary table with ILP reduction rows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address 5 Copilot review comments on PR #31 - Add Clique definition (def:clique) and fix Clique→ILP theorem to reference it instead of def:independent-set - Fix misleading "Camera positions/cameras" wording in VC→QUBO example to use "Cover vertices/vertices" - Use bidirectional IS↔SetPacking in IS and SetPacking "Implemented reductions" lists since both directions are implemented - Fix SetPacking→ILP formulation to match implementation: uses overlapping pair constraints (x_i + x_j ≤ 1) not per-element constraints, with O(|S|²) bound - Fix Typst deprecation: sect → inter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: unify JSON schema across all 30 reduction examples Replace 3 inconsistent JSON schemas (flat, QUBO-rich, nested) with a single unified schema: ReductionData (source, target, overhead) and ResultData (solutions) written to separate .json/.result.json files. - Add src/export.rs with shared serialization types and helpers - Convert all 30 examples to use problemreductions::export::* - Update Typst paper to load unified schema (simplify load-example) - Add load-results() and instance-vars() Typst helpers - Use lookup_overhead_or_empty() for ILP reductions without inventory - Add examples integration test and make examples target Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address remaining review comments and add export.rs test coverage - Add unit tests for src/export.rs (17 tests covering all public functions) to fix codecov/patch CI failure (was 0% coverage on 49 lines) - Fix instance-vars: check num_variables first, handle Factoring as num_bits_first + num_bits_second - Guard against division by zero in reduction-example overhead calculation - Rename <thm:is-vc> to <thm:is-to-vc> for consistent label naming - Use unidirectional IS→SetPacking references (theorem only documents one direction) - Update all @thm:is-vc references to @thm:is-to-vc Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent cfad202 commit dc2ccf1

43 files changed

Lines changed: 5789 additions & 296 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@ tarpaulin-report.html
7171

7272
# Reference packages (downloaded for comparison)
7373
pkgref/
74+
75+
# Generated example outputs
76+
docs/paper/examples/

Makefile

Lines changed: 14 additions & 3 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 mdbook paper clean coverage rust-export compare qubo-testdata
3+
.PHONY: help build test fmt clippy doc mdbook paper examples clean coverage rust-export compare qubo-testdata
44

55
# Default target
66
help:
@@ -18,6 +18,7 @@ help:
1818
@echo " check - Quick check (fmt + clippy + test)"
1919
@echo " rust-export - Generate Rust mapping JSON exports"
2020
@echo " compare - Generate and compare Rust mapping exports"
21+
@echo " examples - Generate example JSON for paper"
2122
@echo " qubo-testdata - Regenerate QUBO test data (requires uv)"
2223

2324
# Build the project
@@ -48,8 +49,18 @@ doc:
4849
mdbook:
4950
mdbook serve docs --open
5051

51-
# Build Typst paper
52-
paper:
52+
# Generate all example JSON files for the paper
53+
REDUCTION_EXAMPLES := $(patsubst examples/%.rs,%,$(wildcard examples/reduction_*.rs))
54+
examples:
55+
@mkdir -p docs/paper/examples
56+
@for example in $(REDUCTION_EXAMPLES); do \
57+
echo "Running $$example..."; \
58+
cargo run --all-features --example $$example || exit 1; \
59+
done
60+
cargo run --all-features --example export_petersen_mapping
61+
62+
# Build Typst paper (generates examples first)
63+
paper: examples
5364
cargo run --example export_graph
5465
cd docs/paper && typst compile reductions.typ reductions.pdf
5566

docs/paper/reduction_graph.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -418,37 +418,37 @@
418418
},
419419
{
420420
"source": {
421-
"name": "Satisfiability",
421+
"name": "MaxCut",
422422
"variant": {
423423
"graph": "SimpleGraph",
424424
"weight": "Unweighted"
425425
}
426426
},
427427
"target": {
428-
"name": "DominatingSet",
428+
"name": "SpinGlass",
429429
"variant": {
430430
"graph": "SimpleGraph",
431431
"weight": "Unweighted"
432432
}
433433
},
434-
"bidirectional": false
434+
"bidirectional": true
435435
},
436436
{
437437
"source": {
438-
"name": "Satisfiability",
438+
"name": "QUBO",
439439
"variant": {
440440
"graph": "SimpleGraph",
441-
"weight": "Unweighted"
441+
"weight": "f64"
442442
}
443443
},
444444
"target": {
445-
"name": "IndependentSet",
445+
"name": "SpinGlass",
446446
"variant": {
447447
"graph": "SimpleGraph",
448-
"weight": "Unweighted"
448+
"weight": "f64"
449449
}
450450
},
451-
"bidirectional": false
451+
"bidirectional": true
452452
},
453453
{
454454
"source": {
@@ -459,10 +459,10 @@
459459
}
460460
},
461461
"target": {
462-
"name": "KColoring",
462+
"name": "DominatingSet",
463463
"variant": {
464464
"graph": "SimpleGraph",
465-
"weight": "i32"
465+
"weight": "Unweighted"
466466
}
467467
},
468468
"bidirectional": false
@@ -476,58 +476,58 @@
476476
}
477477
},
478478
"target": {
479-
"name": "KSatisfiability",
479+
"name": "IndependentSet",
480480
"variant": {
481481
"graph": "SimpleGraph",
482482
"weight": "Unweighted"
483483
}
484484
},
485-
"bidirectional": true
485+
"bidirectional": false
486486
},
487487
{
488488
"source": {
489-
"name": "SetPacking",
489+
"name": "Satisfiability",
490490
"variant": {
491491
"graph": "SimpleGraph",
492492
"weight": "Unweighted"
493493
}
494494
},
495495
"target": {
496-
"name": "IndependentSet",
496+
"name": "KColoring",
497497
"variant": {
498498
"graph": "SimpleGraph",
499-
"weight": "Unweighted"
499+
"weight": "i32"
500500
}
501501
},
502-
"bidirectional": true
502+
"bidirectional": false
503503
},
504504
{
505505
"source": {
506-
"name": "SetPacking",
506+
"name": "Satisfiability",
507507
"variant": {
508508
"graph": "SimpleGraph",
509-
"weight": "i32"
509+
"weight": "Unweighted"
510510
}
511511
},
512512
"target": {
513-
"name": "QUBO",
513+
"name": "KSatisfiability",
514514
"variant": {
515515
"graph": "SimpleGraph",
516-
"weight": "f64"
516+
"weight": "Unweighted"
517517
}
518518
},
519-
"bidirectional": false
519+
"bidirectional": true
520520
},
521521
{
522522
"source": {
523-
"name": "SpinGlass",
523+
"name": "SetPacking",
524524
"variant": {
525525
"graph": "SimpleGraph",
526526
"weight": "Unweighted"
527527
}
528528
},
529529
"target": {
530-
"name": "MaxCut",
530+
"name": "IndependentSet",
531531
"variant": {
532532
"graph": "SimpleGraph",
533533
"weight": "Unweighted"
@@ -537,10 +537,10 @@
537537
},
538538
{
539539
"source": {
540-
"name": "SpinGlass",
540+
"name": "SetPacking",
541541
"variant": {
542542
"graph": "SimpleGraph",
543-
"weight": "f64"
543+
"weight": "i32"
544544
}
545545
},
546546
"target": {
@@ -550,7 +550,7 @@
550550
"weight": "f64"
551551
}
552552
},
553-
"bidirectional": true
553+
"bidirectional": false
554554
},
555555
{
556556
"source": {

0 commit comments

Comments
 (0)