Fix #447: [Model] BoyceCoddNormalFormViolation#685
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #685 +/- ##
==========================================
+ Coverage 97.04% 97.06% +0.01%
==========================================
Files 284 286 +2
Lines 38037 38259 +222
==========================================
+ Hits 36914 37135 +221
- Misses 1123 1124 +1 ☔ 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}
Contributor
Author
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$? |
Comment on lines
26
to
+29
| mod subset_sum; | ||
|
|
||
| pub use bin_packing::BinPacking; | ||
| pub use boyce_codd_normal_form_violation::BoyceCoddNormalFormViolation; |
Comment on lines
+928
to
+946
| 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(), | ||
| ) |
Comment on lines
+72
to
+83
| /// 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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