|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +## Project Overview |
| 4 | +Rust library for NP-hard problem reductions. Implements computational problems with reduction rules for transforming between equivalent formulations. |
| 5 | + |
| 6 | +## Build & Test |
| 7 | +```bash |
| 8 | +make test # Run all tests |
| 9 | +make clippy # Lint |
| 10 | +make export-graph # Regenerate reduction graph |
| 11 | +make paper # Build Typst paper |
| 12 | +make mdbook # Build and serve mdBook documentation |
| 13 | +make coverage # Generate coverage report |
| 14 | +``` |
| 15 | + |
| 16 | +## Architecture |
| 17 | + |
| 18 | +### Core Modules |
| 19 | +- `src/models/` - Problem implementations (SAT, Graph, Set, Optimization categories) |
| 20 | +- `src/rules/` - Reduction rules + inventory registration |
| 21 | +- `src/solvers/` - BruteForce solver, ILP solver (feature-gated) |
| 22 | +- `src/traits/` - `Problem`, `ConstraintSatisfactionProblem`, `ReduceTo<T>` traits |
| 23 | +- `src/registry/` - Compile-time reduction metadata collection |
| 24 | + |
| 25 | +### Reduction System |
| 26 | +```rust |
| 27 | +// Implement ReduceTo<TargetProblem> for SourceProblem |
| 28 | +impl ReduceTo<TargetProblem> for SourceProblem { |
| 29 | + type Result = ReductionSourceToTarget; |
| 30 | + fn reduce_to(&self) -> Self::Result { ... } |
| 31 | +} |
| 32 | + |
| 33 | +// Register with inventory for automatic discovery |
| 34 | +inventory::submit! { ReductionEntry { source_name, target_name, ... } } |
| 35 | +``` |
| 36 | + |
| 37 | +### Key Patterns |
| 38 | +- Problems parameterized by weight type `W` (i32, f64) |
| 39 | +- `ReductionResult` provides `target_problem()` and `extract_solution()` |
| 40 | +- Graph types: SimpleGraph, GridGraph, UnitDiskGraph, Hypergraph |
| 41 | + |
| 42 | +## Adding Reductions |
| 43 | +See GitHub Issue #3 for detailed coding rules: |
| 44 | +1. Create `src/rules/<source>_<target>.rs` with inventory registration |
| 45 | +2. Add closed-loop test (create instance -> reduce -> solve -> extract -> verify) |
| 46 | +3. Document in `docs/paper/reductions.typ` |
| 47 | +4. Regenerate graph with `cargo run --example export_graph --all-features` |
| 48 | + |
| 49 | +## Coverage Requirement |
| 50 | +New code must have >95% test coverage: |
| 51 | +```bash |
| 52 | +cargo tarpaulin --all-features --skip-clean --ignore-tests -- <module_name> |
| 53 | +``` |
0 commit comments