Multi-Step Symbolic Math Reasoning Harness Generator
Generate a robust Python evaluation harness to test and verify multi-step symbolic mathematical reasoning traces from AI agents.
Use this template when evaluating whether an autonomous agent's mathematical derivations are sound. It produces a fully functional verification script integrating symbolic math solvers to detect invalid deductive jumps.
Role: Principal Formal Verification and AI Alignment Researcher with 15+ years in computational logic and automated theorem proving.
Context
- Evaluation target dataset: {{agent_reasoning_dataset}}
- Target symbolic computation engine: {{symbolic_engine_target}}
- Numerical and symbolic equivalence tolerance: {{tolerance_threshold}}
- Expected JSON schema for proof step nodes: {{proof_step_schema}}
- Logic failure categorization schema: {{failure_classification_taxonomies}}
Task
Write an production-grade Python evaluation script that parses multi-step reasoning traces from {{agent_reasoning_dataset}}, checks equation balance and deductive step validity against {{symbolic_engine_target}}, and outputs a structured error diagnostic log.
Method
- Import verification libraries (such as SymPy, Z3, or NumPy) configured for {{symbolic_engine_target}}.
- Define structured Pydantic models to validate the agent trace structure according to {{proof_step_schema}}.
- Ingest and parse individual reasoning steps, isolating variable definitions, assumptions, intermediate assertions, and conclusions.
- Build a stateful symbolic context accumulator that tracks active mathematical constraints across successive derivation steps.
- Evaluate each derivation step against preceding context using symbolic subtraction and zero-equivalence checks within {{tolerance_threshold}}.
- Detect and categorize logical fallacies, circular definitions, and unjustified intermediate steps using {{failure_classification_taxonomies}}.
- Compute composite accuracy metrics: Step Accuracy Rate (SAR), Premise Consistency Score (PCS), and Global Soundness Index (GSI).
- Output executable CLI evaluation commands and export consolidated verification summaries to a JSON/CSV artifact.
Constraints
- The script MUST be self-contained, fully typed with Python type hints, and ready for immediate headless CI/CD execution.
- The script MUST NOT accept purely stochastic token-matching as proof of step correctness; verification must rely on symbolic execution.
- Handle symbolic timeouts and division-by-zero edge cases with graceful exception isolation.
- Include explicit assertion logging for any deduction step classified as invalid.
Output format
Provide the response organized in four distinct sections:
- Architecture Overview (100-150 words summarizing the evaluation pipeline and solver integration).
- Complete Python Evaluation Script (120-250 lines of robust, runnable code including docstrings and error handling).
- Test Fixture Example (A sample synthetic reasoning trace JSON demonstrating valid and invalid steps).
- CLI Execution & Analysis Guide (Step-by-step terminal instructions for running the test harness).
Self-review
- Does the script parse and validate trace data strictly against {{proof_step_schema}}?
- Are step evaluations strictly isolated so one broken proof step does not crash the evaluation of subsequent independent test cases?
- Does the code properly handle symbolic edge cases using {{tolerance_threshold}}?
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.