MathematicalReasoningTask

Solve mathematical problems through rigorous step-by-step logical reasoning with verifiable steps, path exploration, and MathJax/LaTeX output.

Category: Reasoning Side-Effect Safe Model: GPT-4 Preferred
⚙️ MathematicalReasoningConfig.json
{
  "problem_statement": "Find the derivative of f(x) = x^2 * sin(x)",
  "goal": "find f'(x)",
  "domain": "calculus",
  "detail_level": "standard",
  "max_depth": 20,
  "max_alternatives": 3,
  "show_all_paths": false
}
👁️ Session UI (Solution Tab)
Step S1: algebraic
Apply the product rule: (uv)' = u'v + uv'
\frac{d}{dx}[x^2 \cdot \sin(x)] = \frac{d}{dx}[x^2] \cdot \sin(x) + x^2 \cdot \frac{d}{dx}[\sin(x)]
Justification: Product rule of differentiation

Step S2: simplification
f'(x) = 2x \cdot \sin(x) + x^2 \cdot \cos(x)

Execution Configuration

Field Type Description
problem_statement * String The mathematical problem or theorem to solve/prove. Must not be blank.
goal String The target result (e.g., 'prove equality', 'find x', 'simplify expression').
given_information List<String> Known facts, axioms, or given information.
domain String Mathematical domain (e.g., 'algebra', 'calculus', 'number_theory', 'geometry'). Default: general.
max_depth Int Maximum depth of reasoning steps (1-100). Default: 20.
max_alternatives Int Max alternative paths to explore (1-10). Default: 3.
show_all_paths Boolean Whether to show all explored paths or just the successful one.
detail_level String Level of detail in explanations: brief, standard, or detailed.

Task Process Lifecycle

  • Initialization: Analyzes the problem statement via analyzeInitialState to identify key variables and initial state (Step S0).
  • Path Search: Uses a PriorityQueue to explore solution paths based on step confidence and priority scores.
  • Step Generation: Atomic transformations (algebraic, substitution, etc.) are generated with justifications using the StepGenerator agent.
  • Verification: Every step is passed to a StepVerifier agent to ensure mathematical validity and logical flow.
  • Backtracking: If a path hits a dead end or verification fails, the task uses generateAlternatives to explore branches from the last valid step.
  • Finalization: Generates a Formal Proof (Q.E.D.) and a human-readable summary with MathJax/LaTeX notation.

Kotlin Boilerplate

val task = MathematicalReasoningTask(
    orchestrationConfig = config,
    planTask = MathematicalReasoningTaskExecutionConfigData(
        problem_statement = "Solve for x: 2x + 5 = 15",
        goal = "find x",
        domain = "algebra"
    )
)

Prompt Segment

The following logic is injected into the LLM context when this task is active:

MathematicalReasoning - Solve mathematical problems through step-by-step logical reasoning
  ** Specify the problem statement clearly
  ** Define the goal (prove, solve, simplify, etc.)
  ** Provide any given information or constraints
  ** Specify the mathematical domain if relevant
  ** Configure search parameters (depth, alternatives)
  ** The task will:
     - Break down the problem into atomic steps
     - Verify each step's mathematical validity
     - Explore alternative solution paths
     - Backtrack from dead ends
     - Generate a complete proof trail
     - Output results in MathJax/LaTeX format
  ** Useful for:
     - Solving algebraic equations
     - Proving mathematical theorems
     - Simplifying complex expressions
     - Step-by-step calculus problems
     - Number theory proofs
     - Geometric proofs