@@ -14,8 +14,12 @@ pub struct ProblemSpec {
1414///
1515/// Searches both variant-level aliases (e.g., `"3SAT"` → `KSatisfiability`) and
1616/// problem-level aliases (e.g., `"MIS"` → `MaximumIndependentSet`). When a
17- /// variant-level alias is matched, only the canonical name is returned here;
18- /// use [`parse_problem_spec`] to also recover the variant tokens.
17+ /// variant-level alias is matched, only the canonical name is returned here.
18+ /// The older pass-through behavior where `3SAT` resolved to `"3SAT"` has been
19+ /// intentionally replaced by `3SAT` resolving to `"KSatisfiability"` so aliases
20+ /// behave consistently. Callers that need variant semantics such as
21+ /// `3SAT` → `KSatisfiability { k = K3 }` should use [`parse_problem_spec`] or
22+ /// [`resolve_problem_ref`].
1923pub fn resolve_alias ( input : & str ) -> String {
2024 if input. eq_ignore_ascii_case ( "UndirectedFlowLowerBounds" ) {
2125 return "UndirectedFlowLowerBounds" . to_string ( ) ;
@@ -418,6 +422,58 @@ mod tests {
418422 assert_eq ! ( spec. variant_values, vec![ "K2" ] ) ;
419423 }
420424
425+ #[ test]
426+ fn test_resolve_problem_ref_variant_alias_3sat ( ) {
427+ let graph = problemreductions:: rules:: ReductionGraph :: new ( ) ;
428+ let expected = ProblemRef {
429+ name : "KSatisfiability" . to_string ( ) ,
430+ variant : BTreeMap :: from ( [ ( "k" . to_string ( ) , "K3" . to_string ( ) ) ] ) ,
431+ } ;
432+
433+ assert_eq ! ( resolve_problem_ref( "3SAT" , & graph) . unwrap( ) , expected) ;
434+ }
435+
436+ #[ test]
437+ fn test_resolve_problem_ref_variant_alias_2sat ( ) {
438+ let graph = problemreductions:: rules:: ReductionGraph :: new ( ) ;
439+ let expected = ProblemRef {
440+ name : "KSatisfiability" . to_string ( ) ,
441+ variant : BTreeMap :: from ( [ ( "k" . to_string ( ) , "K2" . to_string ( ) ) ] ) ,
442+ } ;
443+
444+ assert_eq ! ( resolve_problem_ref( "2SAT" , & graph) . unwrap( ) , expected) ;
445+ }
446+
447+ #[ test]
448+ fn test_resolve_problem_ref_3sat_k2_rejects_duplicate_dimension ( ) {
449+ let spec = parse_problem_spec ( "3SAT/K2" ) . unwrap ( ) ;
450+ assert_eq ! ( spec. name, "KSatisfiability" ) ;
451+ assert_eq ! ( spec. variant_values, vec![ "K3" , "K2" ] ) ;
452+
453+ let graph = problemreductions:: rules:: ReductionGraph :: new ( ) ;
454+ let err = resolve_problem_ref ( "3SAT/K2" , & graph) . unwrap_err ( ) ;
455+ assert ! (
456+ err. to_string( ) . contains( "specified more than once" ) ,
457+ "expected duplicate-dimension error, got: {err}"
458+ ) ;
459+ }
460+
461+ #[ test]
462+ fn test_resolve_problem_ref_3sat_simple_graph_rejects_unknown_token ( ) {
463+ let spec = parse_problem_spec ( "3SAT/SimpleGraph" ) . unwrap ( ) ;
464+ assert_eq ! ( spec. name, "KSatisfiability" ) ;
465+ assert_eq ! ( spec. variant_values, vec![ "K3" , "SimpleGraph" ] ) ;
466+
467+ let graph = problemreductions:: rules:: ReductionGraph :: new ( ) ;
468+ let err = resolve_problem_ref ( "3SAT/SimpleGraph" , & graph) . unwrap_err ( ) ;
469+ assert ! (
470+ err. to_string( )
471+ . to_lowercase( )
472+ . contains( "unknown variant token" ) ,
473+ "expected unknown-token error, got: {err}"
474+ ) ;
475+ }
476+
421477 #[ test]
422478 fn test_parse_problem_spec_max2sat_problem_level ( ) {
423479 // MAX2SAT is a problem-level alias on Maximum2Satisfiability (standalone problem,
0 commit comments