Add variant-level aliases; introduce 2SAT and 3SAT#1054
Merged
Conversation
Variant-level aliases attach to a specific reduction-graph node rather than a canonical problem name, so shorthand like `3SAT` can resolve to `KSatisfiability<K3>` directly instead of going through the problem's default variant (which is `KN`, not what `3SAT` means in the literature). - `VariantEntry` gains an `aliases: &'static [&'static str]` field. - `declare_variants!` accepts optional `aliases ["X", ...]` trailing each entry and emits the field. - `registry::find_variant_by_alias()` returns both the entry and its variant map. - CLI `parse_problem_spec` and `resolve_alias` try variant-level aliases before problem-level ones, injecting the alias's variant tokens into the spec; problem-level resolution is unchanged for `MIS`, `SAT`, etc. - Adds `2SAT` on `KSatisfiability<K2>` and `3SAT` on `KSatisfiability<K3>`. - `pred list` now shows variant-level aliases on their own rows. - `MAX2SAT` remains a problem-level alias on `Maximum2Satisfiability` (standalone problem, no variants). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1054 +/- ##
==========================================
- Coverage 97.94% 97.92% -0.03%
==========================================
Files 979 964 -15
Lines 100890 99869 -1021
==========================================
- Hits 98816 97793 -1023
- Misses 2074 2076 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Refactor validation into a testable `validate_aliases_inner` that accepts mock data, so every conflict branch (empty alias, canonical-name collision, problem-alias collision, duplicate variant alias, multi-conflict) is exercised without depending on inventory state. Also test `variant_label` with both empty and non-empty variant dimensions. Patch coverage: 15 uncovered lines → ~2 (the inventory integration test panic branch, which is inherently unreachable on a healthy codebase). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
Aliases in this codebase used to resolve only to a canonical problem name, never to a specific variant. That forced
3SATto be excluded as an alias (see the old comment atproblem_name.rs), because a plain alias3SAT → KSatisfiabilitywould silently give users the default variantKN, notK3.This PR makes aliases a first-class per-variant concept so shorthand like
3SATlines up with the actual reduction-graph node (KSatisfiability<K3>), not just the problem type. Problem-level aliases (MIS,SAT,MVC,MAX2SAT, ...) are unchanged.What changes
VariantEntrygainsaliases: &'static [&'static str].declare_variants!accepts optional trailingaliases ["X", ...]:registry::find_variant_by_alias(input) -> Option<(&VariantEntry, BTreeMap<_, _>)>— returns the matched entry and its variant map.
parse_problem_specandresolve_aliastry variant-level aliases first,injecting the alias's variant tokens into the parsed spec. Problem-level alias
resolution is untouched.
pred listshows variant-level aliases on their own rows (e.g.,KSatisfiability/K2shows2SAT,KSatisfiability/K3shows3SAT).Scope
Only the three aliases the user asked for:
2SAT,3SAT,MAX2SAT.MAX2SATwas already a problem-level alias on the standaloneMaximum2Satisfiabilitytype and is left untouched. No other aliases changed.End-to-end verification
Test plan
cargo fmt --checkcargo clippy --all-targets --features ilp-highs -- -D warningsmake test(5092 unit tests + all integration/doc tests pass)pred show {3SAT,2SAT,MAX2SAT}resolve correctlypred path 3SAT MaximumIndependentSetfinds a path from K3pred listshows 2SAT/3SAT on the correct variant rows🤖 Generated with Claude Code