Fix #447: [Model] BoyceCoddNormalFormViolation#685
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #685 +/- ##
========================================
Coverage 97.42% 97.42%
========================================
Files 347 349 +2
Lines 44459 44686 +227
========================================
+ Hits 43315 43537 +222
- Misses 1144 1149 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add the Boyce-Codd Normal Form Violation satisfaction problem model
(Garey & Johnson A4 SR29). Given attributes, functional dependencies,
and a target subset, determines whether a BCNF violation exists.
- Model: src/models/misc/boyce_codd_normal_form_violation.rs
- Tests: 20 unit tests covering evaluation, solver, serialization, edge cases
- CLI: create support with --n, --sets (lhs:rhs format), --target
- Paper: problem-def entry in docs/paper/reductions.typ
- Example-db: canonical example with violation witness X={2}
Implementation SummaryChanges
Deviations from Plan
Open Questions
|
There was a problem hiding this comment.
Pull request overview
Adds a new satisfaction problem model for Boyce–Codd Normal Form Violation (G&J A4 SR29) and wires it into the library, CLI instance creation, example database fixtures, and the reductions paper.
Changes:
- Introduces
BoyceCoddNormalFormViolationmodel with schema registration, variant declaration, and example-db spec. - Adds comprehensive unit tests covering evaluation behavior, validation, solver integration, and serialization.
- Integrates the model into the CLI
pred createflow and the curated example fixtures/docs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/models/misc/boyce_codd_normal_form_violation.rs |
New model implementation + schema registration + variants + example-db spec + test module hook |
src/models/misc/mod.rs |
Exposes the new model and includes its canonical example spec |
problemreductions-cli/src/commands/create.rs |
Adds CLI construction/parsing for BoyceCoddNormalFormViolation |
src/unit_tests/models/misc/boyce_codd_normal_form_violation.rs |
Unit tests for correctness, validation, solver behavior, and serde roundtrip |
src/example_db/fixtures/examples.json |
Adds canonical model example fixture entry (samples + satisfying solutions) |
docs/paper/reductions.typ |
Adds name mapping and formal problem definition to the paper |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
docs/paper/reductions.typ
Outdated
| #problem-def("BoyceCoddNormalFormViolation")[ | ||
| *Instance:* A set $A$ of attribute names, a collection $F$ of functional dependencies on $A$, and a subset $A' subset.eq A$. | ||
|
|
||
| *Question:* Is there a subset $X subset.eq A'$ and two attributes $y, z in A' without X$ such that $y in X^+$ but $z in.not X^+$, where $X^+$ is the closure of $X$ under $F$? |
| mod subset_sum; | ||
|
|
||
| pub use bin_packing::BinPacking; | ||
| pub use boyce_codd_normal_form_violation::BoyceCoddNormalFormViolation; |
| let fds: Vec<(Vec<usize>, Vec<usize>)> = sets_str | ||
| .split(';') | ||
| .map(|fd_str| { | ||
| let parts: Vec<&str> = fd_str.split(':').collect(); | ||
| anyhow::ensure!( | ||
| parts.len() == 2, | ||
| "Each FD must be lhs:rhs, got '{}'", | ||
| fd_str | ||
| ); | ||
| let lhs: Vec<usize> = util::parse_comma_list(parts[0])?; | ||
| let rhs: Vec<usize> = util::parse_comma_list(parts[1])?; | ||
| Ok((lhs, rhs)) | ||
| }) | ||
| .collect::<Result<_>>()?; | ||
| let target: Vec<usize> = util::parse_comma_list(target_str)?; | ||
| ( | ||
| ser(BoyceCoddNormalFormViolation::new(n, fds, target))?, | ||
| resolved_variant.clone(), | ||
| ) |
| /// Create a new Boyce-Codd Normal Form Violation instance. | ||
| /// | ||
| /// # Panics | ||
| /// | ||
| /// Panics if any attribute index in `functional_deps` or `target_subset` is | ||
| /// out of range (≥ `num_attributes`), if `target_subset` is empty, or if any | ||
| /// functional dependency has an empty LHS. | ||
| pub fn new( | ||
| num_attributes: usize, | ||
| functional_deps: Vec<(Vec<usize>, Vec<usize>)>, | ||
| target_subset: Vec<usize>, | ||
| ) -> Self { |
Agentic Review ReportStructural Check
Semantic Review:
Issue Compliance: 8/8 checks passed Findings:
Quality CheckDesign Principles:
HCI (CLI changed):
Test Quality:
Findings:
Agentic Feature Tests
Findings:
Generated by review-pipeline |
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Summary
Add the BoyceCoddNormalFormViolation satisfaction problem model (Garey & Johnson A4 SR29). Given attributes, functional dependencies, and a target subset, determines whether the subset violates Boyce-Codd Normal Form.
Fixes #447