This project transforms any Ollama LLM into a geometric reasoning agent that uses visual thinking to solve complex geometry problems.
The fundamental insight behind this agent is that thoughts are not temporal but etched - when we work through complex problems, creating spatial, visual representations of our thinking process helps us reason more effectively.
The GeometryNotebook serves as an "external memory" for the LLM, allowing it to:
- Explore geometric properties visually
- Document its reasoning process step by step
- Test conjectures with concrete constructions
- Build on previous insights to make discoveries
- Visual Reasoning: The agent uses geometric constructions to think through problems spatially
- Reasoning Documentation: Each significant thinking step is captured using
add_reasoning() - Multi-step Reasoning: Complex problems can be solved through multiple iterations, with each building on insights from previous steps
- Reasoning Flow Visualization: Creates a graph visualization showing how reasoning steps connect
- Interactive Exploration: Users can have conversations with the agent to explore geometric concepts
- Python 3.8+
- Ollama installed locally (https://ollama.ai/)
- LLM models downloaded via Ollama (e.g.,
ollama pull llama3)
- Clone this repository
- Install dependencies:
pip install numpy matplotlib ollama ipython networkxfrom ollama_geometry_agent import OllamaGeometryAgent
# Create a reasoning agent (higher temperature encourages creative thinking)
agent = OllamaGeometryAgent(model_name="llama3", temperature=0.7)
# Solve a geometric problem
results = agent.solve_problem(
"Find the locus of points equidistant from two given points A(-2,0) and B(2,0)"
)
# View the reasoning steps
for step in agent.notebook.reasoning_steps:
print(f"- {step}")# For more complex problems, use multi-step reasoning
results = agent.multi_step_reasoning(
"""
Given triangle ABC with vertices A(0,0), B(6,0), and C(3,4),
explore the Euler line connecting its orthocenter,
centroid, and circumcenter.
""",
steps=3 # Number of reasoning iterations
)
# Visualize the reasoning flow
flow_file = agent.visualize_reasoning_flow(results)# Start an interactive session
agent.interactive_session()In the interactive session, you can use the special command multi:N your problem here to trigger multi-step reasoning with N iterations.
The agent excels at reasoning through problems like:
-
Locus Problems:
- "Find the locus of points P such that |PA|^2 - |PB|^2 = k for constant k"
- "Describe the locus of points equidistant from a point and a line"
-
Triangle Centers:
- "Explore the relationship between the centroid, orthocenter, and circumcenter of a triangle"
- "Discover the properties of the nine-point circle"
-
Geometric Relationships:
- "Prove that the angle bisector of angle A in triangle ABC divides the opposite side BC in the ratio AB:AC"
- "Investigate the power of a point with respect to a circle"
-
Constructions with Verification:
- "Construct the center of a circle passing through three non-collinear points and verify the construction"
- "Construct the common tangents to two circles and explain your reasoning"
- The agent receives a geometric problem from the user
- It analyzes the problem by breaking it down and identifying key relationships
- For each reasoning step, it:
- Documents its thinking using
add_reasoning() - Creates geometric constructions to test ideas
- Observes patterns and relationships in the visualization
- Documents its thinking using
- As it discovers insights, it refines its approach
- The agent continues this process until it reaches a solution
The agent's reasoning process is fully transparent - you can see both its visual constructions and its documented thought process.
To adapt the agent for your specific needs:
- Adjust Temperature: Lower for more deterministic reasoning, higher for more creative exploration
- Modify System Prompt: Edit the
_create_system_prompt()method to emphasize different reasoning aspects - Add Custom Geometric Functions: Extend the GeometryNotebook with additional methods
- The quality of reasoning depends on the capabilities of the underlying LLM
- Very abstract geometric problems may require multiple iterations to solve
- The agent works best when problems can be approached through constructive geometry