:- use_module(starlog).
% Solve equation
?- solve_equation((Y+5)/2 is 2, Y, Solution).
Solution = -1.solve_equation(Equation, Variable, Solution)
solve_equation(Equation, Solution) % Auto-detect variable| Equation Type | Example | Solution |
|---|---|---|
| Addition | Y+3 is 7 |
Y = 4 |
| Subtraction | Y-2 is 5 |
Y = 7 |
| Multiplication | Y*3 is 12 |
Y = 4 |
| Division | Y/4 is 2 |
Y = 8 |
| Multi-step | 2*Y+3 is 11 |
Y = 4 |
| Nested | (Y+1)*2 is 10 |
Y = 4 |
| Power | Y**2 is 16 |
Y = 4 |
The solver applies inverse operations:
- Division → Multiply both sides
- Multiplication → Divide both sides
- Addition → Subtract from both sides
- Subtraction → Add to both sides
- Power → Take nth root of both sides
?- solve_equation((Y+5)/2 is 2, Y, Solution).
Solution = -1.?- solve_equation(5+Y is 9, Y, Solution).
Solution = 4.
?- solve_equation(2*Y is 10, Y, Solution).
Solution = 5.?- solve_equation(((X+2)*3-1)/2 is 7, X, Solution).
Solution = 3.cd tests
swipl -s test_algebra_solver.pl # Run algebra solver tests
swipl -s test_integrated_algebra.pl # Run integration testsswipl -s demo_problem_statement.pl # Problem statement demo
swipl -s demo_algebra_solver.pl # Comprehensive demo
swipl -s interactive_algebra_demo.pl # Interactive visual demoalgebra_solver.pl- Core solver moduleALGEBRA_SOLVER_GUIDE.md- Complete user guideIMPLEMENTATION_SUMMARY_ALGEBRA.md- Technical details
✓ Addition (+)
✓ Subtraction (-)
✓ Multiplication (*)
✓ Division (/)
✓ Power (**)
- Single-variable equations only
- Variable must appear once in expression
- Algebraic operations only
See ALGEBRA_SOLVER_GUIDE.md for comprehensive documentation.