Problem decomposition
Problem decomposition is the structured art of breaking a complex problem into smaller, solvable pieces. Unlike simple planning, decomposition explicitly identifies dependencies between sub-problems and determines the optimal solving order.
Problem decomposition tree
Planning produces a sequential to-do list. Decomposition maps out dependencies between sub-problems, so you know which ones can run in parallel and which must wait. It is more structured and enables smarter execution ordering.
def problem_decomposition(problem, llm):
"""Break a complex problem into sub-problems."""
prompt = f"""Break down this complex problem:
Problem: {problem}
Decompose into:
1. What are the main components?
2. What are the sub-problems?
3. What dependencies exist between them?
4. What is the optimal solving order?
Provide a structured breakdown."""
return llm.generate(prompt).content
# Usage
result = problem_decomposition(
"Design a system for managing a library's book inventory",
llm
)
# Returns structured breakdown with sub-problems,
# dependencies, and recommended solving orderLLM-driven decomposition that identifies sub-problems and their order.
Quiz: Quiz
Loading practice…
Ordering exercise: Order the decomposition process
Loading practice…
Flashcards: Flashcards
Loading practice…
You can now break complex problems into manageable pieces with clear dependencies. That wraps up our reasoning patterns module.