Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #661 +/- ##
==========================================
+ Coverage 96.92% 96.94% +0.01%
==========================================
Files 271 273 +2
Lines 36298 36505 +207
==========================================
+ Hits 35182 35388 +206
- Misses 1116 1117 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds first-class support for the SetBasis NP-complete set problem across the library (model implementation, registry/docs schema export), CLI creation flow, and canonical examples—addressing issue #400.
Changes:
- Introduces
SetBasismodel with brute-force-friendly boolean encoding and registers it viaProblemSchemaEntry+declare_variants!. - Adds unit tests (model behavior, brute-force satisfiable set, serde roundtrip) and integrates SetBasis into trait-consistency checks.
- Extends CLI
pred createto construct SetBasis instances; regenerates fixtures and docs JSON/typst content to include the new model.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/models/set/set_basis.rs | New SetBasis model implementation + schema registration + variant declaration + example-db spec |
| src/models/set/mod.rs | Exposes set_basis module and includes example-db specs |
| src/models/mod.rs | Re-exports SetBasis from models::set |
| src/lib.rs | Adds SetBasis to the public prelude |
| src/unit_tests/models/set/set_basis.rs | New unit test coverage for SetBasis semantics/serialization/solver |
| src/unit_tests/trait_consistency.rs | Adds SetBasis to trait consistency checks |
| problemreductions-cli/src/commands/create.rs | Adds pred create SetBasis ... support + help example string |
| problemreductions-cli/src/cli.rs | Documents SetBasis CLI flags and adds an example invocation |
| problemreductions-cli/tests/cli_tests.rs | Adds CLI tests for creating SetBasis and missing --k handling |
| src/example_db/fixtures/examples.json | Adds SetBasis canonical example; fixture regeneration updates other entries |
| docs/src/reductions/problem_schemas.json | Adds generated schema entry for SetBasis |
| docs/src/reductions/reduction_graph.json | Adds SetBasis node (and index shifts from regeneration) |
| docs/paper/references.bib | Adds Stockmeyer 1975 tech report reference |
| docs/paper/reductions.typ | Adds SetBasis section/definition/example + mapping entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn can_represent_target(basis: &[Vec<usize>], target: &[usize], universe_size: usize) -> bool { | ||
| let mut covered = vec![false; universe_size]; | ||
| for subset in basis { | ||
| if Self::is_subset(subset, target) { | ||
| for &element in subset { | ||
| covered[element] = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| target.iter().all(|&element| covered[element]) | ||
| } |
| #[test] | ||
| fn test_set_basis_rejects_wrong_config_length() { | ||
| let problem = issue_example_problem(3); | ||
| assert!(!problem.evaluate(&canonical_solution()[..11])); |
| //! Set Basis problem implementation. | ||
| //! | ||
| //! Given a collection of sets over a finite universe and an integer `k`, | ||
| //! determine whether there exist `k` basis sets such that every target set | ||
| //! can be reconstructed as a union of some subcollection of the basis. | ||
|
|
- harden SetBasis evaluation against malformed serialized input - validate SetBasis CLI subsets before construction - align problem-specific create help with actual CLI flags
Add targeted tests for uncovered code paths: - is_subset returning false (basis set not subset of target) - is_valid_solution wrapper method - k=0 with empty/non-empty collection (edge cases) - Empty collection with k > 0 (trivially satisfiable) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
zazabap
left a comment
There was a problem hiding this comment.
Final review passed — all CI green, coverage fixed, quality ~85%.
Summary
Implement the
SetBasismodel and wire it through the library, CLI, docs, and example fixtures for issue #400.Fixes #400