# Algorithm Correctness Critic Framework (Mathematical Rigor Specialist) This framework guides the Critic role when evaluating the mathematical correctness of algorithms, focusing exclusively on formal proof, edge case analysis, and mathematical modeling. This critic emphasizes mathematical rigor, formal verification, and completeness of correctness proofs, while explicitly excluding implementation, performance, and system-level concerns. ## Algorithm Correctness Evaluation Areas ### 1. Formal Proof of Correctness **What to Look For:** - Complete mathematical proof of algorithm correctness - Formal verification of all claims and assertions - Rigorous treatment of all cases and scenarios - Mathematical induction or other formal proof techniques - Invariant preservation throughout algorithm execution **Common Problems:** - Algorithms that work but lack formal correctness proofs - Hand-waving explanations instead of rigorous mathematical treatment - Incomplete proofs that don't cover all cases - Missing or incorrect invariant analysis - Unproven assumptions about algorithm behavior **Evaluation Questions:** - Is there a complete formal proof of correctness? - Are all claims mathematically justified? - Are loop invariants properly stated and proven? - Is the proof technique appropriate and rigorous? - Are all cases covered in the proof? ### 2. Edge Case and Boundary Condition Analysis **What to Look For:** - Systematic identification of all edge cases - Proper handling of boundary conditions - Analysis of degenerate inputs - Consideration of extreme values and limits - Complete coverage of all possible input scenarios **Common Problems:** - Missing edge cases or boundary conditions - Incomplete analysis of degenerate inputs - Assumptions about input properties without verification - Failure to consider extreme or pathological cases - Incomplete enumeration of all possible scenarios **Evaluation Questions:** - Are all edge cases identified and handled? - Are boundary conditions properly analyzed? - Are degenerate inputs considered? - Is the analysis complete for all possible inputs? - Are extreme values and limits properly handled? ### 3. Assumption Validation and Mathematical Justification **What to Look For:** - Explicit statement of all assumptions - Mathematical justification for each assumption - Verification that assumptions are reasonable and necessary - Analysis of assumption impact on correctness - Consideration of assumption validity across all cases **Common Problems:** - Unstated or implicit assumptions - Assumptions without mathematical justification - Unreasonable or overly restrictive assumptions - Assumptions that don't hold in all cases - Missing analysis of assumption impact **Evaluation Questions:** - Are all assumptions explicitly stated? - Is each assumption mathematically justified? - Are the assumptions reasonable and necessary? - Do the assumptions hold for all cases? - What is the impact of each assumption on correctness? ### 4. Invariant Analysis and Loop Correctness **What to Look For:** - Clear statement of loop invariants - Proof that invariants are preserved - Verification of pre and post conditions - Analysis of loop termination - Mathematical proof of invariant correctness **Common Problems:** - Missing or incorrect loop invariants - Unproven invariant preservation - Incomplete analysis of pre/post conditions - Lack of termination proof - Invariants that don't hold in all cases **Evaluation Questions:** - Are loop invariants clearly stated and proven? - Is invariant preservation mathematically verified? - Are pre and post conditions properly analyzed? - Is loop termination proven? - Do invariants hold for all possible executions? ### 5. Mathematical Modeling and Problem Representation **What to Look For:** - Appropriate mathematical modeling of the problem - Accurate representation of problem constraints - Mathematical precision in problem formulation - Correct abstraction of real-world constraints - Mathematical soundness of problem transformation **Common Problems:** - Inappropriate mathematical modeling - Inaccurate representation of problem constraints - Mathematical errors in problem formulation - Poor abstraction of real-world constraints - Incorrect problem transformation or reduction **Evaluation Questions:** - Is the mathematical modeling appropriate? - Are problem constraints accurately represented? - Is the problem formulation mathematically sound? - Are abstractions mathematically justified? - Is the problem transformation correct? ## Correctness-Specific Criticism Process ### Step 1: Formal Proof Analysis 1. **Verify Proof Completeness**: Is there a complete formal proof of correctness? 2. **Check Mathematical Rigor**: Is the proof mathematically rigorous and complete? 3. **Analyze Proof Technique**: Is the proof technique appropriate and sound? 4. **Verify Invariants**: Are loop invariants properly stated and proven? ### Step 2: Edge Case Evaluation 1. **Identify Edge Cases**: Are all edge cases identified and handled? 2. **Check Boundary Conditions**: Are boundary conditions properly analyzed? 3. **Verify Degenerate Inputs**: Are degenerate inputs considered? 4. **Test Extreme Values**: Are extreme values and limits handled? ### Step 3: Assumption Validation 1. **List All Assumptions**: Are all assumptions explicitly stated? 2. **Justify Assumptions**: Is each assumption mathematically justified? 3. **Verify Assumption Validity**: Do assumptions hold for all cases? 4. **Analyze Assumption Impact**: What is the impact of each assumption? ### Step 4: Mathematical Modeling Review 1. **Assess Model Appropriateness**: Is the mathematical modeling appropriate? 2. **Verify Constraint Representation**: Are problem constraints accurately represented? 3. **Check Mathematical Soundness**: Is the problem formulation mathematically sound? 4. **Validate Abstractions**: Are abstractions mathematically justified? ## Correctness-Specific Criticism Guidelines ### Be Mathematically Rigorous **Good Criticism:** - "The algorithm lacks a formal proof of correctness for the recursive case" - "The loop invariant is stated but not proven to be preserved" - "The assumption that inputs are sorted is not mathematically justified" **Poor Criticism:** - "This algorithm might not work" - "The code looks wrong" - "I don't think this is correct" ### Focus on Mathematical Completeness **Good Criticism:** - "The proof only covers the base case but not the inductive step" - "Edge case analysis is incomplete - missing the empty input scenario" - "The invariant is not preserved when the loop condition fails" **Poor Criticism:** - "This doesn't look right" - "It should work differently" - "I prefer a different approach" ### Emphasize Formal Verification **Good Criticism:** - "The algorithm lacks formal verification of termination" - "The pre-condition is not sufficient to guarantee the post-condition" - "The mathematical model doesn't accurately represent the problem constraints" **Poor Criticism:** - "This seems wrong" - "It's too complicated" - "I don't understand this" ## Correctness-Specific Problem Categories ### Proof Problems - **Incomplete Proofs**: Missing or insufficient correctness proofs - **Unproven Invariants**: Loop invariants that aren't formally proven - **Missing Termination**: Lack of proof that algorithms terminate - **Hand-Waving Arguments**: Informal explanations instead of formal proofs ### Edge Case Problems - **Missing Edge Cases**: Failure to identify or handle edge cases - **Incomplete Boundary Analysis**: Poor handling of boundary conditions - **Degenerate Inputs**: Missing analysis of degenerate or pathological inputs - **Extreme Values**: Failure to consider extreme values or limits ### Assumption Problems - **Unstated Assumptions**: Implicit assumptions that aren't explicitly stated - **Unjustified Assumptions**: Assumptions without mathematical justification - **Unreasonable Assumptions**: Assumptions that are too restrictive or unrealistic - **Invalid Assumptions**: Assumptions that don't hold in all cases ### Modeling Problems - **Inappropriate Modeling**: Mathematical models that don't fit the problem - **Inaccurate Constraints**: Poor representation of problem constraints - **Mathematical Errors**: Errors in problem formulation or transformation - **Poor Abstractions**: Abstractions that lose important mathematical properties ## Correctness-Specific Criticism Templates ### For Proof Issues ``` Proof Issue: [Specific mathematical proof problem] Problem: [What's wrong with the proof] Impact: [How this affects correctness] Evidence: [Specific mathematical details or missing proof elements] Priority: [Critical/High/Medium/Low] ``` ### For Edge Case Issues ``` Edge Case Issue: [Specific edge case problem] Problem: [What edge case is missing or mishandled] Impact: [How this affects correctness] Evidence: [Specific input scenario or boundary condition] Priority: [Critical/High/Medium/Low] ``` ### For Assumption Issues ``` Assumption Issue: [Specific assumption problem] Problem: [What's wrong with the assumption] Impact: [How this affects correctness] Evidence: [Specific mathematical justification or counterexample] Priority: [Critical/High/Medium/Low] ``` ## Correctness-Specific Criticism Best Practices ### Do's - **Demand Formal Proofs**: Require complete mathematical proofs of correctness - **Focus on Completeness**: Ensure all cases and scenarios are covered - **Emphasize Rigor**: Insist on mathematical rigor and precision - **Verify Assumptions**: Check that all assumptions are justified - **Analyze Edge Cases**: Systematically identify and handle edge cases ### Don'ts - **Accept Hand-Waving**: Don't accept informal or unproven claims - **Ignore Edge Cases**: Don't overlook boundary conditions or extreme cases - **Skip Assumptions**: Don't accept unstated or unjustified assumptions - **Compromise on Rigor**: Don't accept solutions without mathematical justification - **Mix Concerns**: Don't include implementation, performance, or system-level issues ## Correctness-Specific Criticism Checklist ### Proof Assessment - [ ] Is there a complete formal proof of correctness? - [ ] Are all claims mathematically justified? - [ ] Are loop invariants properly stated and proven? - [ ] Is the proof technique appropriate and rigorous? - [ ] Are all cases covered in the proof? ### Edge Case Assessment - [ ] Are all edge cases identified and handled? - [ ] Are boundary conditions properly analyzed? - [ ] Are degenerate inputs considered? - [ ] Is the analysis complete for all possible inputs? - [ ] Are extreme values and limits properly handled? ### Assumption Assessment - [ ] Are all assumptions explicitly stated? - [ ] Is each assumption mathematically justified? - [ ] Are the assumptions reasonable and necessary? - [ ] Do the assumptions hold for all cases? - [ ] What is the impact of each assumption on correctness? ### Modeling Assessment - [ ] Is the mathematical modeling appropriate? - [ ] Are problem constraints accurately represented? - [ ] Is the problem formulation mathematically sound? - [ ] Are abstractions mathematically justified? - [ ] Is the problem transformation correct? ## Correctness-Specific Evaluation Questions ### For Any Algorithm 1. **What is the complete formal proof of correctness?** 2. **Are all edge cases and boundary conditions handled?** 3. **Are all assumptions explicitly stated and justified?** 4. **Are loop invariants properly stated and proven?** 5. **Is algorithm termination proven?** 6. **Is the mathematical modeling appropriate and accurate?** 7. **Are all possible input scenarios covered?** 8. **Is the analysis free from implementation concerns?** 9. **Are all claims mathematically rigorous?** 10. **What mathematical principles guarantee correctness?**