@@ -33,12 +33,11 @@ def _check_minimality(fsa: FSA) -> Tuple[bool, Optional[ValidationError]]:
3333 try :
3434 minimized = hopcroft_minimization (fsa )
3535 if len (minimized .states ) < len (fsa .states ):
36- diff = len (fsa .states ) - len (minimized .states )
3736 return False , ValidationError (
38- message = f"Your FSA works correctly, but it's not minimal! You have { len (fsa .states )} states, but only { len (minimized .states )} are needed. You could remove { diff } state(s). " ,
37+ message = f"FSA is not minimal: has { len (fsa .states )} states but can be reduced to { len (minimized .states )} " ,
3938 code = ErrorCode .NOT_MINIMAL ,
4039 severity = "error" ,
41- suggestion = "Look for states that behave identically (same transitions and acceptance) - these can be merged into one "
40+ suggestion = "Minimize your FSA by merging equivalent states "
4241 )
4342 return True , None
4443 except Exception :
@@ -70,11 +69,9 @@ def _build_feedback(
7069 hints = [e .suggestion for e in all_errors if e .suggestion ]
7170 if structural_info :
7271 if structural_info .unreachable_states :
73- unreachable = ", " .join (structural_info .unreachable_states )
74- hints .append (f"Tip: States {{{ unreachable } }} can't be reached from your start state - you might want to remove them or add transitions to them" )
72+ hints .append ("Consider removing unreachable states" )
7573 if structural_info .dead_states :
76- dead = ", " .join (structural_info .dead_states )
77- hints .append (f"Tip: States {{{ dead } }} can never lead to acceptance - this might be intentional (trap states) or a bug" )
74+ hints .append ("Dead states can never lead to acceptance" )
7875
7976 # Build language comparison
8077 language = LanguageComparison (are_equivalent = len (equivalence_errors ) == 0 )
@@ -95,20 +92,17 @@ def _summarize_errors(errors: List[ValidationError]) -> str:
9592 for error in errors :
9693 msg = error .message .lower ()
9794 if "alphabet" in msg :
98- error_types .add ("alphabet issue " )
99- elif "states " in msg and ( "many " in msg or "few" in msg or "needed" in msg ) :
100- error_types .add ("incorrect number of states " )
101- elif "accepting" in msg or "accept " in msg :
102- error_types .add ("accepting states issue " )
103- elif "transition" in msg or "reading" in msg :
104- error_types .add ("transition issue " )
95+ error_types .add ("alphabet mismatch " )
96+ elif "state " in msg and "count " in msg :
97+ error_types .add ("state count mismatch " )
98+ elif "accepting" in msg or "incorrectly marked " in msg :
99+ error_types .add ("acceptance error " )
100+ elif "transition" in msg :
101+ error_types .add ("transition error " )
105102
106- if len (error_types ) == 1 :
107- issue = list (error_types )[0 ]
108- return f"Almost there! Your FSA has an { issue } . Check the details below."
109- elif error_types :
110- return f"Your FSA doesn't quite match the expected language. Issues found: { ', ' .join (error_types )} "
111- return f"Your FSA doesn't accept the correct language. Found { len (errors )} issue(s) to fix."
103+ if error_types :
104+ return f"Languages differ: { ', ' .join (error_types )} "
105+ return f"Languages differ: { len (errors )} issue(s)"
112106
113107
114108# =============================================================================
@@ -140,11 +134,7 @@ def analyze_fsa_correction(
140134 # Step 1: Validate student FSA structure
141135 student_errors = is_valid_fsa (student_fsa )
142136 if student_errors :
143- num_errors = len (student_errors )
144- if num_errors == 1 :
145- summary = "Your FSA has a structural problem that needs to be fixed first. See the details below."
146- else :
147- summary = f"Your FSA has { num_errors } structural problems that need to be fixed first. See the details below."
137+ summary = "FSA has structural errors"
148138 return Result (
149139 is_correct = False ,
150140 feedback = summary ,
@@ -156,7 +146,7 @@ def analyze_fsa_correction(
156146 if expected_errors :
157147 return Result (
158148 is_correct = False ,
159- feedback = "Oops! There's an issue with the expected answer. Please contact your instructor. "
149+ feedback = "Internal error: expected FSA is invalid "
160150 )
161151
162152 # Step 3: Check minimality if required
@@ -172,18 +162,15 @@ def analyze_fsa_correction(
172162 equivalence_errors = fsas_accept_same_language (student_fsa , expected_fsa )
173163
174164 if not equivalence_errors and not validation_errors :
175- # Success message with some stats
176- state_count = len (student_fsa .states )
177- feedback = f"Correct! Your FSA with { state_count } state(s) accepts exactly the right language. Well done!"
178165 return Result (
179166 is_correct = True ,
180- feedback = feedback ,
181- fsa_feedback = _build_feedback ("Your FSA is correct! " , [], [], structural_info )
167+ feedback = "Correct! FSA accepts the expected language." ,
168+ fsa_feedback = _build_feedback ("FSA is correct" , [], [], structural_info )
182169 )
183170
184171 # Build result with errors
185172 is_correct = len (equivalence_errors ) == 0 and len (validation_errors ) == 0
186- summary = _summarize_errors (equivalence_errors ) if equivalence_errors else "Your FSA has some issues to address. "
173+ summary = _summarize_errors (equivalence_errors ) if equivalence_errors else "FSA has issues"
187174
188175 return Result (
189176 is_correct = is_correct ,
0 commit comments