Operation

Enum Operation 

Source
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 get x = 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 get x = 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 get x = 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 get x = 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 get x = 16
§

RootBothSides(Expression)

Take the specified root of both sides.

Used to solve equations with powers.

§Example

Solving x² = 25:

  • Apply RootBothSides(2) to get x = ±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 get x = 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

Combine multiple fractions into a single fraction.

§Example

Transform 1/x + 2/y into (y + 2x)/(xy)

§

Cancel

Cancel common factors from numerator and denominator.

§Example

Transform (2x)/(4x) into 1/2

§

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

§variable: Variable

The variable being replaced

§value: Expression

The 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)

Apply a named algebraic identity.

§Example

Apply “difference of squares”: a² - b² = (a + b)(a - b)

§

ApplyTrigIdentity(String)

Apply a named trigonometric identity.

§Example

Apply “Pythagorean identity”: sin²θ + cos²θ = 1

§

ApplyLogProperty(String)

Apply a named logarithm property.

§Example

Apply “product rule”: log(ab) = log(a) + log(b)

§

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

§variable: Variable

The variable to differentiate with respect to

§rule: String

The differentiation rule applied (e.g., “power rule”, “chain rule”)

§

Integrate

Integrate an expression with respect to a variable.

§Example

Integrate 2x with respect to x: x^2 + C

Fields

§variable: Variable

The variable of integration

§technique: String

The integration technique used

§

EvaluateLimit

Evaluate a limit.

§Example

Evaluate lim_{x->0} sin(x)/x = 1

Fields

§variable: Variable

The variable approaching a value

§approaches: Expression

The value being approached

§method: String

The method used (e.g., “direct substitution”, “L’Hôpital’s rule”)

§

IntegrationByParts

Apply integration by parts: ∫u dv = uv - ∫v du

Fields

§u: Expression

The function chosen as u

§dv: Expression

The function chosen as dv

§

USubstitution

Apply u-substitution for integration.

Fields

§substitution: Expression

The substitution u = g(x)

§

SolveODE

Solve an ODE.

Fields

§method: String

The method used (e.g., “separation of variables”, “integrating factor”)

§

MatrixOperation

Perform a matrix operation.

Fields

§operation: String

The type of operation (e.g., “row reduction”, “transpose”, “inverse”)

§

GaussianElimination

Apply Gaussian elimination.

§

ComputeDeterminant

Compute determinant using a specific method.

Fields

§method: String

The method used (e.g., “cofactor expansion”, “LU decomposition”)

§

ApproximationSubstitution

Apply approximation with error bounds.

Replaces an expression with an approximation (e.g., small angle approximation).

Fields

§original: Expression

The original exact expression

§approximation: Expression

The approximation expression

§error_bound: f64

Upper bound on approximation error

§

Custom(String)

Custom operation with a free-form description.

Use this for operations not covered by the other variants

Implementations§

Source§

impl Operation

Source

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"
Source

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");
Source

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");
Source

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§

Source§

impl Clone for Operation

Source§

fn clone(&self) -> Operation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Operation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Operation

Source§

fn eq(&self, other: &Operation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Operation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,