Did you know ... Search Documentation:
Pack starlog -- ALGEBRA_QUICK_REF.md

Algebra Solver - Quick Reference

Quick Start

:- use_module(starlog).

% Solve equation
?- solve_equation((Y+5)/2 is 2, Y, Solution).
Solution = -1.

Basic Syntax

solve_equation(Equation, Variable, Solution)
solve_equation(Equation, Solution)  % Auto-detect variable

Common Patterns

Equation TypeExampleSolution
AdditionY+3 is 7Y = 4
SubtractionY-2 is 5Y = 7
MultiplicationY*3 is 12Y = 4
DivisionY/4 is 2Y = 8
Multi-step2*Y+3 is 11Y = 4
Nested(Y+1)*2 is 10Y = 4
PowerY**2 is 16Y = 4

How It Works

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

Examples

Problem Statement

?- solve_equation((Y+5)/2 is 2, Y, Solution).
Solution = -1.

Commutative Operations

?- solve_equation(5+Y is 9, Y, Solution).
Solution = 4.

?- solve_equation(2*Y is 10, Y, Solution).
Solution = 5.

Complex Nested

?- solve_equation(((X+2)*3-1)/2 is 7, X, Solution).
Solution = 3.

Testing

cd tests
swipl -s test_algebra_solver.pl      # Run algebra solver tests
swipl -s test_integrated_algebra.pl  # Run integration tests

Demos

swipl -s demo_problem_statement.pl    # Problem statement demo
swipl -s demo_algebra_solver.pl       # Comprehensive demo
swipl -s interactive_algebra_demo.pl  # Interactive visual demo

Files

  • algebra_solver.pl - Core solver module
  • ALGEBRA_SOLVER_GUIDE.md - Complete user guide
  • IMPLEMENTATION_SUMMARY_ALGEBRA.md - Technical details

Supported Operations

✓ Addition (+) ✓ Subtraction (-) ✓ Multiplication (*) ✓ Division (/) ✓ Power (**)

Limitations

  • Single-variable equations only
  • Variable must appear once in expression
  • Algebraic operations only

Learn More

See ALGEBRA_SOLVER_GUIDE.md for comprehensive documentation.