# verify_pedagogy_logic.py import sys import os # Add current directory to path sys.path.append(os.getcwd()) from proof_graph import ProofStep, ProofGraph, validate_pedagogical_legality import curriculum_engine def test_grade_7_violation(): print("๐Ÿงช Testing Grade 7 Violation (Equation Systems)...") # 1. Fetch rules rules = curriculum_engine.get_allowed_math_operators("7", "4") print(f"๐Ÿ“‹ Rules for Grade 7: Forbidden={rules['forbidden']}") # 2. Mock a "bad" ProofGraph that uses SYSTEM_OF_EQUATIONS # This simulates the SmartSolver/LLM returning a solution that uses forbidden tools bad_steps = [ ProofStep(1, "x+y=10, x-y=2", "Original System"), ProofStep(2, "x=6, y=4", "Solved System", operator_used="SYSTEM_OF_EQUATIONS") ] bad_graph = ProofGraph(bad_steps) # 3. Validate is_legal, reason = validate_pedagogical_legality(bad_graph, rules) if not is_legal: print(f"โœ… Success: Pedagogy Guard correctly REJECTED Grade 7 system solver. Reason: {reason}") else: print("โŒ Failure: Pedagogy Guard ALLOWED forbidden operator.") def test_grade_8_allowed(): print("\n๐Ÿงช Testing Grade 8 Allowed (Equation Systems)...") # 1. Fetch rules rules = curriculum_engine.get_allowed_math_operators("8", "4") print(f"๐Ÿ“‹ Rules for Grade 8: Forbidden={rules['forbidden']}") # 2. Mock a "good" ProofGraph for Grade 8 steps = [ ProofStep(1, "x+y=10, x-y=2", "Original System"), ProofStep(2, "x=6, y=4", "Solved System", operator_used="SYSTEM_OF_EQUATIONS") ] graph = ProofGraph(steps) # 3. Validate is_legal, reason = validate_pedagogical_legality(graph, rules) if is_legal: print(f"โœ… Success: Pedagogy Guard correctly ALLOWED Grade 8 system solver.") else: print(f"โŒ Failure: Pedagogy Guard REJECTED allowed operator. Reason: {reason}") def test_grade_11_calculus_whitelist(): print("\n๐Ÿงช Testing Grade 11 Calculus (Derivative Allowed)...") # Grade 11 Rules rules = curriculum_engine.get_allowed_math_operators("11", "5") steps = [ ProofStep(1, "f(x)=x^2", "Function"), ProofStep(2, "f'(x)=2x", "Derivative", operator_used="DERIVATIVE") ] graph = ProofGraph(steps) is_legal, reason = validate_pedagogical_legality(graph, rules) if is_legal: print("โœ… Success: Grade 11 correctly allows DERIVATIVE.") else: print(f"โŒ Failure: Grade 11 rejected allowed DERIVATIVE. {reason}") if __name__ == "__main__": try: test_grade_7_violation() test_grade_8_allowed() test_grade_11_calculus_whitelist() print("\nโœจ All isolated pedagogical tests PASSED!") except Exception as e: print(f"\n๐Ÿ’ฅ Test Execution Failed: {e}") sys.exit(1)