Fix #448: [Model] ConjunctiveQueryFoldability#687
Conversation
Add the Conjunctive Query Foldability problem (Garey & Johnson A4 SR30). NP-complete satisfaction problem from database theory — determines if one conjunctive query can be folded into another via substitution of undistinguished variables. - Model in src/models/misc/ with Term enum, validation, declare_variants! - 7 unit tests (YES/NO instances, solver, serialization, constants) - Paper entry with formal definition, CeTZ diagram, worked example - CLI discovery via ProblemSchemaEntry, example-db canonical instance
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new NP-complete satisfaction model, ConjunctiveQueryFoldability, to the misc model suite, including schema registration and example/CLI/docs integration.
Changes:
- Introduces
ConjunctiveQueryFoldabilitymodel +Termrepresentation, with schema registration, validation, evaluation, and variant complexity declaration. - Adds unit tests and an example-db fixture entry for the new model.
- Updates CLI
pred createmessaging and the paper docs to include the new problem.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/models/misc/conjunctive_query_foldability.rs |
New model implementation, schema entry, evaluation logic, variants, and example-db spec hook. |
src/models/misc/mod.rs |
Registers the new misc module and re-exports ConjunctiveQueryFoldability/Term; adds example-db spec extension. |
src/models/mod.rs |
Re-exports the new misc model (and Term) at the top-level models module. |
src/unit_tests/models/misc/conjunctive_query_foldability.rs |
Adds unit tests covering dims, evaluation semantics, brute-force solving, and serde roundtrip. |
src/example_db/fixtures/examples.json |
Adds a canonical example instance and satisfying configs for the example DB. |
problemreductions-cli/src/commands/create.rs |
Adds an example_for entry and an explicit pred create bail-out message for complex nested input. |
docs/paper/reductions.typ |
Adds problem name mapping and a formal definition + example/figure to the paper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// distinguished variables `X`, and undistinguished variables `Y`, this problem | ||
| /// asks: do there exist two conjunctive queries Q1 and Q2 (over `X ∪ Y`) such | ||
| /// that a substitution `σ: Y → X ∪ Y ∪ D` maps every atom of Q1 to an atom | ||
| /// of Q2? |
| /// ], | ||
| /// vec![ | ||
| /// (0, vec![Term::Distinguished(0), Term::Distinguished(0)]), | ||
| /// (0, vec![Term::Distinguished(0), Term::Distinguished(0)]), |
| pub use misc::{ | ||
| BinPacking, Factoring, FlowShopScheduling, Knapsack, LongestCommonSubsequence, | ||
| MinimumTardinessSequencing, PaintShop, SequencingWithinIntervals, ShortestCommonSupersequence, | ||
| SubsetSum, | ||
| BinPacking, ConjunctiveQueryFoldability, Factoring, FlowShopScheduling, Knapsack, | ||
| LongestCommonSubsequence, MinimumTardinessSequencing, PaintShop, SequencingWithinIntervals, | ||
| ShortestCommonSupersequence, SubsetSum, Term, | ||
| }; |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #687 +/- ##
==========================================
+ Coverage 97.36% 97.39% +0.03%
==========================================
Files 337 339 +2
Lines 43123 43413 +290
==========================================
+ Hits 41988 42284 +296
+ Misses 1135 1129 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Agentic Review ReportNote: CI is currently failing (1 failing check). Patch coverage is 84.73% (project: 96.97%). Structural Check
Issue Compliance:
Build: Semantic Review:
Issues found:
Quality CheckDesign Principles: DRY OK, KISS OK, HC/LC OK HCI (CLI changes): Error messages OK, discoverability OK, consistency OK Issues found:
Agentic Feature Tests
All tests pass. The model is correctly integrated: appears in catalog, displays proper details, produces valid example, solves correctly with brute-force. The example is mathematically sound (triangle+self-loop folds into lollipop, 4 satisfying configs confirmed). Suggestions (pre-existing, not regressions):
Generated by review-pipeline |
Resolve conflicts: keep ConjunctiveQueryFoldability alongside newly added models (ConjunctiveBooleanQuery, PartiallyOrderedKnapsack, etc.). Adapt ModelExampleSpec to the new API. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix struct doc: clarify Q1/Q2 are instance, σ is the decision - Simplify doctest Q2 to single atom (duplicates irrelevant) - Add ConjunctiveQueryFoldability and Term to lib.rs prelude - Add getter tests, edge-case tests, and validation panic tests to improve coverage Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix incorrect comment in doctest (index = 0, not 1) - Strengthen serialization roundtrip test (check all fields) - Add num_undistinguished==0 edge case tests (trivial fold) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Final review notes:
All local checks pass ( |
zazabap
left a comment
There was a problem hiding this comment.
Final review passed. All inline comments and agentic review items addressed. Coverage improved with 10 additional tests. LGTM.
Resolve conflicts: keep ConjunctiveQueryFoldability alongside newly added ResourceConstrainedScheduling and PartitionIntoPathsOfLength2. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
Add the ConjunctiveQueryFoldability problem model (Garey & Johnson A4 SR30). This is a classical NP-complete satisfaction problem from database theory that asks whether one conjunctive query can be folded into another via substitution of undistinguished variables.
Fixes #448