Fix #439: Add StringToStringCorrection model#675
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #675 +/- ##
==========================================
+ Coverage 97.15% 97.16% +0.01%
==========================================
Files 300 302 +2
Lines 39753 39923 +170
==========================================
+ Hits 38621 38791 +170
Misses 1132 1132 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add the String-to-String Correction satisfaction problem (Garey & Johnson SR20). Given source/target strings and bound K, determine if the target can be derived from the source using at most K deletions and adjacent swaps. - Model: src/models/misc/string_to_string_correction.rs - Tests: 11 unit tests + 1 doctest (creation, evaluation, solver, paper example) - CLI: --source-string, --target-string, --bound, --alphabet-size flags - Paper: problem-def with figure, Wagner 1974/1975 references - Example-db: canonical instance with 2 satisfying solutions
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new NP-complete satisfaction problem model, StringToStringCorrection, to the problemreductions model registry and CLI, including examples and documentation updates, to address issue #439.
Changes:
- Introduce
StringToStringCorrectionmodel with schema registration, variant declaration, evaluation logic, and example-db spec. - Add unit tests and example fixtures for the new model.
- Integrate the model into the CLI (
pred create) and regenerate docs JSON + paper references/definition section.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/models/misc/string_to_string_correction.rs | New model implementation, schema registration, variant declaration, and example-db spec |
| src/models/misc/mod.rs | Export and include the new misc model + example-db spec aggregation |
| src/models/mod.rs | Re-export StringToStringCorrection from the top-level models module |
| src/unit_tests/models/misc/string_to_string_correction.rs | New unit tests covering creation, evaluation, invalid ops, serialization, and brute-force solving |
| src/unit_tests/trait_consistency.rs | Add trait consistency check coverage for the new model |
| src/example_db/fixtures/examples.json | Add example instance + sample/optimal configs for StringToStringCorrection |
| problemreductions-cli/src/cli.rs | Add --source-string / --target-string flags and update help text |
| problemreductions-cli/src/commands/create.rs | Add pred create StringToStringCorrection ... parsing and example string |
| docs/src/reductions/problem_schemas.json | Add generated schema entry for the new model |
| docs/src/reductions/reduction_graph.json | Add generated graph node entry for the new model and adjust indices |
| docs/paper/references.bib | Add Wagner (1974/1975) references used by the paper |
| docs/paper/reductions.typ | Add paper definition + example figure block for String-to-String Correction |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let bound_k = args.bound.ok_or_else(|| { | ||
| anyhow::anyhow!("StringToStringCorrection requires --bound\n\n{usage}") | ||
| })? as usize; |
| if config.iter().any(|&v| v >= domain) { | ||
| return false; | ||
| } | ||
| let noop = 2 * n; |
…39-string-to-string-correction # Conflicts: # docs/src/reductions/problem_schemas.json # docs/src/reductions/reduction_graph.json # problemreductions-cli/src/commands/create.rs # src/models/mod.rs # src/unit_tests/trait_consistency.rs
- reject negative StringToStringCorrection bounds in CLI creation - tighten model pruning and add integration coverage for help/create/solve flows - align StringToStringCorrection help and docs with brute-force solver usage
Agentic Review ReportStructural Check
Issue Compliance (#439):
Semantic Review:
Build: Structural summary: 16/16 checks passed, 8/8 issue compliance passed, no blocking issues. Quality CheckDesign Principles:
HCI (CLI changes):
Test Quality: OK — 14 unit tests with concrete value assertions, boundary/adversarial coverage, full brute-force enumeration in paper example test, plus 4 CLI integration tests. Issues (all minor):
Quality summary: No critical or important issues. 4 minor suggestions. Agentic Feature Tests
Confirmed issues:
Agentic test summary: All functional tests PASS. 2 minor lint/format issues confirmed. Generated by review-pipeline |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous highlighting used value-based comparison via `.position()`, which finds the first occurrence and would produce incorrect highlights for strings with repeated symbols. Now compares by position index directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ShortestCommonSupersequence and other models use `bound` as the field name. Rename for consistency across the codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Add the StringToStringCorrection problem model — a classical NP-complete satisfaction problem from Garey & Johnson (A4 SR20) concerning minimum-cost string transformation using only deletions and adjacent swaps.
Fixes #439