pub enum Operation {
Show 32 variants
AddBothSides(Expression),
SubtractBothSides(Expression),
MultiplyBothSides(Expression),
DivideBothSides(Expression),
PowerBothSides(Expression),
RootBothSides(Expression),
ApplyFunction(String),
Simplify,
Expand,
Factor,
CombineFractions,
Cancel,
Substitute {
variable: Variable,
value: Expression,
},
Isolate(Variable),
MoveTerm(Expression),
ApplyIdentity(String),
ApplyTrigIdentity(String),
ApplyLogProperty(String),
QuadraticFormula,
CompleteSquare,
NumericalApproximation,
Differentiate {
variable: Variable,
rule: String,
},
Integrate {
variable: Variable,
technique: String,
},
EvaluateLimit {
variable: Variable,
approaches: Expression,
method: String,
},
IntegrationByParts {
u: Expression,
dv: Expression,
},
USubstitution {
substitution: Expression,
},
SolveODE {
method: String,
},
MatrixOperation {
operation: String,
},
GaussianElimination,
ComputeDeterminant {
method: String,
},
ApproximationSubstitution {
original: Expression,
approximation: Expression,
error_bound: f64,
},
Custom(String),
}Expand description
Operations that can be performed during equation solving.
This enum represents all types of algebraic manipulations that can be applied when solving equations. Each variant captures a specific mathematical operation along with any necessary parameters.
§Operation Categories
§Both-Sides Operations
Operations that maintain equation equality by applying the same transformation
to both sides: AddBothSides,
SubtractBothSides,
MultiplyBothSides,
DivideBothSides,
PowerBothSides,
RootBothSides,
ApplyFunction.
§Expression Transformations
Operations that restructure expressions:
Simplify,
Expand,
Factor,
CombineFractions,
Cancel.
§Variable Manipulation
Operations for working with variables:
Substitute,
Isolate,
MoveTerm.
§Identity Applications
Operations that apply mathematical identities:
ApplyIdentity,
ApplyTrigIdentity,
ApplyLogProperty.
§Advanced Methods
Specialized solving techniques:
QuadraticFormula,
CompleteSquare,
NumericalApproximation.
§Example
use thales::resolution_path::Operation;
use thales::ast::{Expression, Variable};
// Both-sides operation
let op1 = Operation::AddBothSides(Expression::Integer(5));
assert_eq!(op1.describe(), "Add Integer(5) to both sides");
// Simplification
let op2 = Operation::Simplify;
assert_eq!(op2.describe(), "Simplify expression");
// Variable substitution
let x = Variable::new("x");
let op3 = Operation::Substitute {
variable: x,
value: Expression::Integer(10),
};
assert!(op3.describe().contains("Substitute"));Variants§
AddBothSides(Expression)
Add the same expression to both sides of the equation.
Used to eliminate negative terms or move constants across the equation.
§Example
Solving x - 3 = 7:
- Apply
AddBothSides(3)to getx = 10
SubtractBothSides(Expression)
Subtract the same expression from both sides of the equation.
Used to eliminate positive terms or move constants across the equation.
§Example
Solving x + 5 = 12:
- Apply
SubtractBothSides(5)to getx = 7
MultiplyBothSides(Expression)
Multiply both sides of the equation by the same expression.
Used to eliminate fractions or isolate variables with fractional coefficients.
§Example
Solving x/2 = 6:
- Apply
MultiplyBothSides(2)to getx = 12
DivideBothSides(Expression)
Divide both sides of the equation by the same expression.
Used to isolate variables with integer coefficients.
§Example
Solving 3x = 15:
- Apply
DivideBothSides(3)to getx = 5
PowerBothSides(Expression)
Raise both sides of the equation to the specified power.
Used to eliminate roots or solve radical equations.
§Example
Solving √x = 4:
- Apply
PowerBothSides(2)to getx = 16
RootBothSides(Expression)
Take the specified root of both sides.
Used to solve equations with powers.
§Example
Solving x² = 25:
- Apply
RootBothSides(2)to getx = ±5
ApplyFunction(String)
Apply a named function to both sides.
Used for inverse operations like taking logarithms, applying trig functions, etc.
§Example
Solving e^x = 10:
- Apply
ApplyFunction("ln")to getx = ln(10)
Simplify
Simplify the expression by combining like terms, reducing fractions, etc.
§Example
Transform 3x + 2x into 5x
Expand
Expand the expression by distributing multiplication over addition.
§Example
Transform (x + 2)(x - 3) into x² - x - 6
Factor
Factor the expression into a product of simpler expressions.
§Example
Transform x² - 5x + 6 into (x - 2)(x - 3)
CombineFractions
Cancel
Substitute
Substitute a variable with a specific value or expression.
§Example
In equation 2x + y = 10, substitute y = 3 to get 2x + 3 = 10
Fields
value: ExpressionThe value or expression to substitute
Isolate(Variable)
Isolate the specified variable on one side of the equation.
§Example
Transform 2x + 3y = 12 to x = (12 - 3y)/2 (isolating x)
MoveTerm(Expression)
Move a term from one side of the equation to the other.
Equivalent to adding or subtracting the term from both sides.
§Example
Transform x + 5 = 12 to x = 12 - 5
ApplyIdentity(String)
ApplyTrigIdentity(String)
ApplyLogProperty(String)
QuadraticFormula
Solve using the quadratic formula: x = (-b ± √(b² - 4ac)) / 2a
Used for equations in the form ax² + bx + c = 0
CompleteSquare
Solve by completing the square.
Transform x² + bx + c into (x + p)² + q form
NumericalApproximation
Use numerical methods to approximate the solution.
Applied when symbolic methods fail or exact solutions are impractical
Differentiate
Differentiate an expression with respect to a variable.
§Example
Differentiate x^3 + 2x with respect to x: 3x^2 + 2
Fields
Integrate
Integrate an expression with respect to a variable.
§Example
Integrate 2x with respect to x: x^2 + C
Fields
EvaluateLimit
Fields
approaches: ExpressionThe value being approached
IntegrationByParts
Apply integration by parts: ∫u dv = uv - ∫v du
USubstitution
Apply u-substitution for integration.
Fields
substitution: ExpressionThe substitution u = g(x)
SolveODE
Solve an ODE.
MatrixOperation
Perform a matrix operation.
GaussianElimination
Apply Gaussian elimination.
ComputeDeterminant
Compute determinant using a specific method.
ApproximationSubstitution
Apply approximation with error bounds.
Replaces an expression with an approximation (e.g., small angle approximation).
Fields
original: ExpressionThe original exact expression
approximation: ExpressionThe approximation expression
Custom(String)
Custom operation with a free-form description.
Use this for operations not covered by the other variants
Implementations§
Source§impl Operation
impl Operation
Sourcepub fn describe(&self) -> String
pub fn describe(&self) -> String
Get a human-readable description of this operation.
Returns a string describing what this operation does, suitable for display in educational contexts, hints, or step-by-step explanations.
§Example
use thales::resolution_path::Operation;
use thales::ast::{Expression, Variable};
let op = Operation::DivideBothSides(Expression::Integer(3));
assert_eq!(op.describe(), "Divide both sides by Integer(3)");
let op2 = Operation::Simplify;
assert_eq!(op2.describe(), "Simplify expression");
let x = Variable::new("x");
let op3 = Operation::Isolate(x);
assert_eq!(op3.describe(), "Isolate x");§Usage in Educational Applications
use thales::resolution_path::{ResolutionStep, Operation};
use thales::ast::Expression;
let step = ResolutionStep::new(
Operation::AddBothSides(Expression::Integer(7)),
"Add 7 to eliminate the negative term".to_string(),
Expression::Integer(14),
);
// Show just the operation type to student
println!("Hint: {}", step.operation.describe());
// Output: "Add Integer(7) to both sides"Sourcepub fn describe_latex(&self) -> String
pub fn describe_latex(&self) -> String
Get a LaTeX-friendly description of this operation.
Similar to describe() but with proper escaping for LaTeX text mode.
§Example
use thales::resolution_path::Operation;
use thales::ast::Expression;
let op = Operation::QuadraticFormula;
assert_eq!(op.describe_latex(), "Apply quadratic formula");Sourcepub fn category(&self) -> String
pub fn category(&self) -> String
Get the category of this operation for statistics.
Returns a string identifier for the operation category.
§Categories
"both_sides": Operations applied to both sides of equation"transformation": Expression transformations (simplify, expand, etc.)"variable": Variable manipulations (substitute, isolate)"identity": Identity applications (algebraic, trig, log)"advanced": Advanced methods (quadratic formula, etc.)"calculus": Calculus operations (differentiate, integrate, etc.)"matrix": Matrix operations"custom": Custom operations
§Example
use thales::resolution_path::Operation;
use thales::ast::Expression;
let op = Operation::Simplify;
assert_eq!(op.category(), "transformation");
let op2 = Operation::QuadraticFormula;
assert_eq!(op2.category(), "advanced");Sourcepub fn is_key_operation(&self) -> bool
pub fn is_key_operation(&self) -> bool
Check if this operation is a “key” operation for minimal verbosity.
Key operations are major transformations that significantly change the equation state. Simplification and other minor adjustments are typically not considered key operations.
§Example
use thales::resolution_path::Operation;
use thales::ast::Expression;
assert!(!Operation::Simplify.is_key_operation());
assert!(Operation::QuadraticFormula.is_key_operation());
assert!(Operation::DivideBothSides(Expression::Integer(2)).is_key_operation());Trait Implementations§
impl StructuralPartialEq for Operation
Auto Trait Implementations§
impl Freeze for Operation
impl RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnwindSafe for Operation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.