UNPKG

mathsteps-experimental-fork

Version:

Step by step math solutions. Experimental Fork

738 lines (671 loc) 40.3 kB
import { AccessorNode } from 'mathjs'; import { AccessorNodeCtor } from 'mathjs'; import { AssignmentNode } from 'mathjs'; import { BigNumber } from 'mathjs'; import { BlockNode } from 'mathjs'; import { BlockNodeCtor } from 'mathjs'; import { Complex } from 'mathjs'; import { ConditionalNode } from 'mathjs'; import { ConditionalNodeCtor } from 'mathjs'; import { ConstantNode } from 'mathjs'; import { ConstantNodeCtor } from 'mathjs'; import { Fraction } from 'mathjs'; import { FunctionAssignmentNode } from 'mathjs'; import { FunctionNode } from 'mathjs'; import { FunctionNodeCtor } from 'mathjs'; import { IndexNode } from 'mathjs'; import { IndexNodeCtor } from 'mathjs'; import { MathArray } from 'mathjs'; import { MathCollection } from 'mathjs'; import { MathExpression } from 'mathjs'; import { MathNode } from 'mathjs'; import { MathNumericType } from 'mathjs'; import { MathType } from 'mathjs'; import { Matrix } from 'mathjs'; import { NoLiteralType } from 'mathjs'; import { OperatorNode } from 'mathjs'; import { OperatorNodeCtor } from 'mathjs'; import { OperatorNodeFn } from 'mathjs'; import { OperatorNodeOp } from 'mathjs'; import { ParenthesisNode } from 'mathjs'; import { ParseFunction } from 'mathjs'; import { RangeNode } from 'mathjs'; import { SymbolNode } from 'mathjs'; import { SymbolNodeCtor } from 'mathjs'; import { Unit } from 'mathjs'; export declare type AChangeType = AChangeTypeCore | AChangeTypeWithCase; export declare type AChangeTypeCore = typeof ALL_CHANGE_TYPES[number]; export declare type AChangeTypeGroup = typeof CHANGE_TYPE_GROUPS[number]; export declare type AChangeTypeOnly = typeof CHANGE_TYPE_ONLY[number]; export declare type AChangeTypeWithCase = `${AChangeTypeCore}__CASE_${number}`; export declare type AEquationChangeType = typeof EQUATION_CHANGE_TYPES[number]; declare const ALL_CHANGE_TYPES: readonly [...("SIMPLIFY_ARITHMETIC__MULTIPLY" | "SIMPLIFY_ARITHMETIC__DIVIDE" | "SIMPLIFY_ARITHMETIC__ADD" | "SIMPLIFY_ARITHMETIC__SUBTRACT" | "KEMU_MULTIPLY_SQRTS" | "KEMU_MULTIPLY_SQRTS_WITH_COMMON_ROOT" | "KEMU_MULTIPLY_POWERS_WITH_COMMON_BASE" | "KEMU_DIVIDE_POWERS_WITH_COMMON_BASE" | "KEMU_REMOVE_DOUBLE_FRACTION" | "KEMU_POWER_FACTORS" | "KEMU_POWER_TO_MINUS_ONE" | "KEMU_POWER_TO_NEGATIVE_EXPONENT" | "KEMU_ROOT_FROM_FRACTION" | "MULTIPLY_FRACTIONS" | "PERCENTS_ADD" | "PERCENTS_SUB" | "PERCENTS_CONVERT_TO_FRACTION" | "KEMU_SHORT_MULTIPLICATION_AB2_ADD" | "KEMU_SHORT_MULTIPLICATION_AB3_ADD" | "KEMU_SHORT_MULTIPLICATION_ABN_ADD" | "KEMU_SHORT_MULTIPLICATION_AB2_SUB" | "KEMU_SHORT_MULTIPLICATION_AB3_SUB" | "KEMU_SHORT_MULTIPLICATION_ABN_SUB" | "KEMU_DISTRIBUTE_MUL_OVER_ADD" | "REDUCE_ZERO_NUMERATOR" | "CANCEL_TERMS_FOR_ADDITION" | "CANCEL_TERMS_FOR_FRACTION" | "EQ_CROSS_MULTIPLY" | "EQ_MULTIPLY_BOTH_SIDES_BY_NEGATIVE_ONE" | "RESOLVE_DOUBLE_MINUS" | "PEMDAS__ADD_INSTEAD_OF_MULTIPLY" | "ADDED_INSTEAD_OF_MULTIPLIED" | "SUBTRACTED_INSTEAD_OF_MULTIPLIED" | "MULTIPLIED_INSTEAD_OF_ADDED" | "MULTIPLIED_INSTEAD_OF_SUBTRACTED" | "MULTIPLIED_ONE_TOO_MANY" | "MULTIPLIED_ONE_TOO_FEW" | "ADDED_ONE_TOO_FEW" | "ADDED_ONE_TOO_MANY" | "SUBTRACTED_ONE_TOO_FEW" | "SUBTRACTED_ONE_TOO_MANY" | "UNKNOWN" | "NO_CHANGE" | "SUBTRACTED_INSTEAD_OF_ADDED" | "ADDED_INSTEAD_OF_SUBTRACTED" | "EQ_REMOVE_TERM" | "EQ_ADD_TERM" | "EQ_ADD_TERM_BY_ADDITION" | "EQ_ADD_TERM_BY_SUBTRACTION" | "EQ_ADD_TERM_BY_MULTIPLICATION" | "EQ_ADD_TERM_BY_DIVISION" | "EQ_REMOVE_TERM_BY_ADDITION" | "EQ_REMOVE_TERM_BY_SUBTRACTION" | "EQ_REMOVE_TERM_BY_MULTIPLICATION" | "EQ_REMOVE_TERM_BY_DIVISION")[], "SIMPLIFY_ARITHMETIC__POWER", "DIVISION_BY_NEGATIVE_ONE", "DIVISION_BY_ONE", "MULTIPLY_BY_ZERO", "MULTIPLY_NTH_ROOTS", "DISTRIBUTE_NEGATIVE_ONE", "KEMU_MULTIPLY_EXPONENTS", "REARRANGE_COEFF", "KEMU_FACTOR_EXPRESSION_UNDER_ROOT", "REDUCE_EXPONENT_BY_ZERO", "REMOVE_EXPONENT_BY_ONE", "REMOVE_EXPONENT_BASE_ONE", "REMOVE_EXPONENT_BASE_ZERO", "REMOVE_ADDING_ZERO", "REMOVE_MULTIPLYING_BY_NEGATIVE_ONE", "REMOVE_MULTIPLYING_BY_ONE", "RESOLVE_DOUBLE_MINUS", "SIMPLIFY_SIGNS", "COLLECT_AND_COMBINE_LIKE_TERMS", "KEMU_ORIGINAL_EXPRESSION", "ABSOLUTE_VALUE", "UNKNOWN", "NO_CHANGE", "ADD_FRACTIONS", "COMMON_DENOMINATOR", "KEMU_DECIMAL_TO_FRACTION", "KEMU_REMOVE_FRACTION_WITH_UNIT_NUMERATOR", "BREAK_UP_FRACTION", "KEMU_PYTHAGOREAN_IDENTITY", "KEMU_EVEN_FUNCTION_OF_NEGATIVE", "KEMU_ODD_FUNCTION_OF_NEGATIVE", "KEMU_CONVERT_SIN_PER_COS_TO_TAN", "KEMU_CONVERT_COS_PER_SIN_TO_COT", "KEMU_CANCEL_INVERSE_FUNCTION", "KEMU_FUNCTION_VALUE", "KEMU_LOG_XY_FROM_ONE", "KEMU_LOG_XY_FROM_BASE", "KEMU_LOG_XY_FROM_POWER", "KEMU_CONVERT_ROOT_TO_POWER", "KEMU_CONVERT_POWER_TO_ROOT", "KEMU_POWER_FRACTION", "KEMU_POWER_SQRT", "KEMU_SQRT_FROM_ZERO", "KEMU_SQRT_FROM_ONE", "KEMU_SQRT_FROM_POW", "KEMU_SQRT_FROM_CONST", "KEMU_ROOT_FROM_CONST", "EQ_SWAP_SIDES"]; export declare const ALL_MATH_RULES: readonly ["Addition_Property_Of_Equality", "Subtraction_Property_Of_Equality", "Multiplication_Property_Of_Equality", "Division_Property_Of_Equality", "Distributive_Property", "Combining_Like_Terms_Expressions", "Combining_Like_Terms_Fractions", "Simplify_Signs", "Cross_Multiply"]; export declare type AMathRule = typeof ALL_MATH_RULES[number]; export declare type AMistakeTypeOnly = typeof MISTAKE_ONLY[keyof typeof MISTAKE_ONLY]; declare type AOperator = typeof OPERATORS[number]; export declare function assessUserEquationStep(previousUserStep: string, userStep: string, startingStepAnswerForEquation: string): ProcessedEquation; export declare function assessUserEquationSteps(userSteps: string[]): ProcessedEquation[]; /** * * @param previousUserStep - The previous step before the user's step. ex. '2x + 2x + 2x' * @param userStep - The users step moving from the previous step to the current step. ex. '2x + 4x' * @param startingStepAnswer - The actual answer of the equation. If not provided, it will be calculated using the previous step. * @returns {StepInfo[]} * @see {StepInfo} for the structure of the returned object. * @see {assessUserSteps} for evaluating many steps at once. * @example * const userSteps = [ * '2x + 2x + 2x', // Initial expression * // '4x + 2x' -- Skipped by the user * '6x' // First user-provided step * ] * const assessedStep = assessUserStep(userSteps[0], userSteps[1]); // Returns an array of StepInfo[] * const skippedSteps = assessedStep.slice(0, stepSequence.length - 1); // All intermediate steps missed ('4x + 2x') * const userProvidedStep = assessedStep[stepSequence.length - 1]; // The step provided by the user (6x) * if(userProvidedStep.isValid) { * console.log('User provided a valid step!') * } */ export declare function assessUserStep(previousUserStep: string, userStep: string, startingStepAnswer?: string): StepInfo[]; /** * Evaluates the sequence of steps a user took to simplify an expression and returns a detailed breakdown of each step. * * @param userSteps - An array of strings representing the steps the user took to simplify the expression, in order. * @example * const userSteps = [ * '2x + 3x', // Initial expression * '5x' // First step by the user * ] * * @returns An array of StepInfo[][], where each StepInfo[][] represents a detailed sequence of steps leading to each user-provided step. * Each StepInfo[] in this array contains the intermediate steps needed to derive the corresponding user step. * @see {StepInfo} for the structure of the returned objects. * * @example * const userSteps = [ * '2x + 2x + 2x', // Initial expression * // '4x + 2x' -- Skipped by the user * '6x' // First user-provided step * ] * const assessedSteps = assessUserSteps(userSteps); // Returns an array of StepInfo[][] * * for (const stepSequence of assessedSteps) { * const skippedSteps = stepSequence.slice(0, stepSequence.length - 1); // All intermediate steps missed ('4x + 2x') * const userProvidedStep = stepSequence[stepSequence.length - 1]; // The step provided by the user (6x) * } */ export declare function assessUserSteps(userSteps: string[]): StepInfo[][]; /** * Change type groups are not used anywhere right now. We provide some exports for easier mapping to these changeTypes via these "groups". * We have a new concept called "MathRuleTypes" that provides mappings for "MathRules". Neither mappings are not really used directly anywhere in the repo, but are useful for other projects. */ declare const CHANGE_TYPE_GROUPS: readonly ["OriginalExpression", "SimplifyArithmetic", "AdditionRules", "SubtractionRules", "DivisionRules", "MultiplicationRules", "CoefficientSimplificationRules", "ExponentSimplificationRules", "ExpressionSimplificationRules", "AbsoluteValueRules", "FractionRules", "TrigonometricRules", "LogarithmRules", "PercentageRules", "RootAndPowerRules", "OrderOfOperations", "UNKNOWN", "NO_CHANGE", "EquationRules", "MistakeWrongOperationRules"]; declare const CHANGE_TYPE_ONLY: readonly [...("SIMPLIFY_ARITHMETIC__MULTIPLY" | "SIMPLIFY_ARITHMETIC__DIVIDE" | "SIMPLIFY_ARITHMETIC__ADD" | "SIMPLIFY_ARITHMETIC__SUBTRACT" | "KEMU_MULTIPLY_SQRTS" | "KEMU_MULTIPLY_SQRTS_WITH_COMMON_ROOT" | "KEMU_MULTIPLY_POWERS_WITH_COMMON_BASE" | "KEMU_DIVIDE_POWERS_WITH_COMMON_BASE" | "KEMU_REMOVE_DOUBLE_FRACTION" | "KEMU_POWER_FACTORS" | "KEMU_POWER_TO_MINUS_ONE" | "KEMU_POWER_TO_NEGATIVE_EXPONENT" | "KEMU_ROOT_FROM_FRACTION" | "MULTIPLY_FRACTIONS" | "PERCENTS_ADD" | "PERCENTS_SUB" | "PERCENTS_CONVERT_TO_FRACTION" | "KEMU_SHORT_MULTIPLICATION_AB2_ADD" | "KEMU_SHORT_MULTIPLICATION_AB3_ADD" | "KEMU_SHORT_MULTIPLICATION_ABN_ADD" | "KEMU_SHORT_MULTIPLICATION_AB2_SUB" | "KEMU_SHORT_MULTIPLICATION_AB3_SUB" | "KEMU_SHORT_MULTIPLICATION_ABN_SUB" | "KEMU_DISTRIBUTE_MUL_OVER_ADD" | "REDUCE_ZERO_NUMERATOR" | "CANCEL_TERMS_FOR_ADDITION" | "CANCEL_TERMS_FOR_FRACTION" | "EQ_CROSS_MULTIPLY" | "EQ_MULTIPLY_BOTH_SIDES_BY_NEGATIVE_ONE" | "RESOLVE_DOUBLE_MINUS" | "EQ_REMOVE_TERM" | "EQ_ADD_TERM" | "EQ_ADD_TERM_BY_ADDITION" | "EQ_ADD_TERM_BY_SUBTRACTION" | "EQ_ADD_TERM_BY_MULTIPLICATION" | "EQ_ADD_TERM_BY_DIVISION" | "EQ_REMOVE_TERM_BY_ADDITION" | "EQ_REMOVE_TERM_BY_SUBTRACTION" | "EQ_REMOVE_TERM_BY_MULTIPLICATION" | "EQ_REMOVE_TERM_BY_DIVISION")[], "SIMPLIFY_ARITHMETIC__POWER", "DIVISION_BY_NEGATIVE_ONE", "DIVISION_BY_ONE", "MULTIPLY_BY_ZERO", "MULTIPLY_NTH_ROOTS", "DISTRIBUTE_NEGATIVE_ONE", "KEMU_MULTIPLY_EXPONENTS", "REARRANGE_COEFF", "KEMU_FACTOR_EXPRESSION_UNDER_ROOT", "REDUCE_EXPONENT_BY_ZERO", "REMOVE_EXPONENT_BY_ONE", "REMOVE_EXPONENT_BASE_ONE", "REMOVE_EXPONENT_BASE_ZERO", "REMOVE_ADDING_ZERO", "REMOVE_MULTIPLYING_BY_NEGATIVE_ONE", "REMOVE_MULTIPLYING_BY_ONE", "RESOLVE_DOUBLE_MINUS", "SIMPLIFY_SIGNS", "COLLECT_AND_COMBINE_LIKE_TERMS", "KEMU_ORIGINAL_EXPRESSION", "ABSOLUTE_VALUE", "UNKNOWN", "NO_CHANGE", "ADD_FRACTIONS", "COMMON_DENOMINATOR", "KEMU_DECIMAL_TO_FRACTION", "KEMU_REMOVE_FRACTION_WITH_UNIT_NUMERATOR", "BREAK_UP_FRACTION", "KEMU_PYTHAGOREAN_IDENTITY", "KEMU_EVEN_FUNCTION_OF_NEGATIVE", "KEMU_ODD_FUNCTION_OF_NEGATIVE", "KEMU_CONVERT_SIN_PER_COS_TO_TAN", "KEMU_CONVERT_COS_PER_SIN_TO_COT", "KEMU_CANCEL_INVERSE_FUNCTION", "KEMU_FUNCTION_VALUE", "KEMU_LOG_XY_FROM_ONE", "KEMU_LOG_XY_FROM_BASE", "KEMU_LOG_XY_FROM_POWER", "KEMU_CONVERT_ROOT_TO_POWER", "KEMU_CONVERT_POWER_TO_ROOT", "KEMU_POWER_FRACTION", "KEMU_POWER_SQRT", "KEMU_SQRT_FROM_ZERO", "KEMU_SQRT_FROM_ONE", "KEMU_SQRT_FROM_POW", "KEMU_SQRT_FROM_CONST", "KEMU_ROOT_FROM_CONST", "EQ_SWAP_SIDES"]; export declare const changeTypeIsInGroup: (change: AChangeType, group: (typeof CHANGE_TYPE_GROUPS)[number]) => boolean; export declare const ChangeTypes: { [K in AChangeTypeCore]: K; }; export declare const cleanEquationForShow: (str: string) => string; export declare const convertAdditionToSubtractionErrorType: (errorType: AChangeType) => AChangeType; export declare const convertMistakeOnlyTypeToItsChangeType: (mistakeType_: AChangeType, isMistake?: boolean) => AChangeType | null; export declare function convertTextToTeX(text: string): string; declare const _default: { simplifyExpression: (optionsOrExpressionAsText: SimplifyOptions | string) => any; solveEquation: typeof solveEquation; ChangeTypes: { SIMPLIFY_ARITHMETIC__MULTIPLY: "SIMPLIFY_ARITHMETIC__MULTIPLY"; SIMPLIFY_ARITHMETIC__DIVIDE: "SIMPLIFY_ARITHMETIC__DIVIDE"; SIMPLIFY_ARITHMETIC__ADD: "SIMPLIFY_ARITHMETIC__ADD"; SIMPLIFY_ARITHMETIC__SUBTRACT: "SIMPLIFY_ARITHMETIC__SUBTRACT"; KEMU_MULTIPLY_SQRTS: "KEMU_MULTIPLY_SQRTS"; KEMU_MULTIPLY_SQRTS_WITH_COMMON_ROOT: "KEMU_MULTIPLY_SQRTS_WITH_COMMON_ROOT"; KEMU_MULTIPLY_POWERS_WITH_COMMON_BASE: "KEMU_MULTIPLY_POWERS_WITH_COMMON_BASE"; KEMU_DIVIDE_POWERS_WITH_COMMON_BASE: "KEMU_DIVIDE_POWERS_WITH_COMMON_BASE"; KEMU_REMOVE_DOUBLE_FRACTION: "KEMU_REMOVE_DOUBLE_FRACTION"; KEMU_POWER_FACTORS: "KEMU_POWER_FACTORS"; KEMU_POWER_TO_MINUS_ONE: "KEMU_POWER_TO_MINUS_ONE"; KEMU_POWER_TO_NEGATIVE_EXPONENT: "KEMU_POWER_TO_NEGATIVE_EXPONENT"; KEMU_ROOT_FROM_FRACTION: "KEMU_ROOT_FROM_FRACTION"; MULTIPLY_FRACTIONS: "MULTIPLY_FRACTIONS"; PERCENTS_ADD: "PERCENTS_ADD"; PERCENTS_SUB: "PERCENTS_SUB"; PERCENTS_CONVERT_TO_FRACTION: "PERCENTS_CONVERT_TO_FRACTION"; KEMU_SHORT_MULTIPLICATION_AB2_ADD: "KEMU_SHORT_MULTIPLICATION_AB2_ADD"; KEMU_SHORT_MULTIPLICATION_AB3_ADD: "KEMU_SHORT_MULTIPLICATION_AB3_ADD"; KEMU_SHORT_MULTIPLICATION_ABN_ADD: "KEMU_SHORT_MULTIPLICATION_ABN_ADD"; KEMU_SHORT_MULTIPLICATION_AB2_SUB: "KEMU_SHORT_MULTIPLICATION_AB2_SUB"; KEMU_SHORT_MULTIPLICATION_AB3_SUB: "KEMU_SHORT_MULTIPLICATION_AB3_SUB"; KEMU_SHORT_MULTIPLICATION_ABN_SUB: "KEMU_SHORT_MULTIPLICATION_ABN_SUB"; KEMU_DISTRIBUTE_MUL_OVER_ADD: "KEMU_DISTRIBUTE_MUL_OVER_ADD"; REDUCE_ZERO_NUMERATOR: "REDUCE_ZERO_NUMERATOR"; CANCEL_TERMS_FOR_ADDITION: "CANCEL_TERMS_FOR_ADDITION"; CANCEL_TERMS_FOR_FRACTION: "CANCEL_TERMS_FOR_FRACTION"; EQ_CROSS_MULTIPLY: "EQ_CROSS_MULTIPLY"; EQ_MULTIPLY_BOTH_SIDES_BY_NEGATIVE_ONE: "EQ_MULTIPLY_BOTH_SIDES_BY_NEGATIVE_ONE"; RESOLVE_DOUBLE_MINUS: "RESOLVE_DOUBLE_MINUS"; PEMDAS__ADD_INSTEAD_OF_MULTIPLY: "PEMDAS__ADD_INSTEAD_OF_MULTIPLY"; ADDED_INSTEAD_OF_MULTIPLIED: "ADDED_INSTEAD_OF_MULTIPLIED"; SUBTRACTED_INSTEAD_OF_MULTIPLIED: "SUBTRACTED_INSTEAD_OF_MULTIPLIED"; MULTIPLIED_INSTEAD_OF_ADDED: "MULTIPLIED_INSTEAD_OF_ADDED"; MULTIPLIED_INSTEAD_OF_SUBTRACTED: "MULTIPLIED_INSTEAD_OF_SUBTRACTED"; MULTIPLIED_ONE_TOO_MANY: "MULTIPLIED_ONE_TOO_MANY"; MULTIPLIED_ONE_TOO_FEW: "MULTIPLIED_ONE_TOO_FEW"; ADDED_ONE_TOO_FEW: "ADDED_ONE_TOO_FEW"; ADDED_ONE_TOO_MANY: "ADDED_ONE_TOO_MANY"; SUBTRACTED_ONE_TOO_FEW: "SUBTRACTED_ONE_TOO_FEW"; SUBTRACTED_ONE_TOO_MANY: "SUBTRACTED_ONE_TOO_MANY"; UNKNOWN: "UNKNOWN"; NO_CHANGE: "NO_CHANGE"; SUBTRACTED_INSTEAD_OF_ADDED: "SUBTRACTED_INSTEAD_OF_ADDED"; ADDED_INSTEAD_OF_SUBTRACTED: "ADDED_INSTEAD_OF_SUBTRACTED"; EQ_REMOVE_TERM: "EQ_REMOVE_TERM"; EQ_ADD_TERM: "EQ_ADD_TERM"; EQ_ADD_TERM_BY_ADDITION: "EQ_ADD_TERM_BY_ADDITION"; EQ_ADD_TERM_BY_SUBTRACTION: "EQ_ADD_TERM_BY_SUBTRACTION"; EQ_ADD_TERM_BY_MULTIPLICATION: "EQ_ADD_TERM_BY_MULTIPLICATION"; EQ_ADD_TERM_BY_DIVISION: "EQ_ADD_TERM_BY_DIVISION"; EQ_REMOVE_TERM_BY_ADDITION: "EQ_REMOVE_TERM_BY_ADDITION"; EQ_REMOVE_TERM_BY_SUBTRACTION: "EQ_REMOVE_TERM_BY_SUBTRACTION"; EQ_REMOVE_TERM_BY_MULTIPLICATION: "EQ_REMOVE_TERM_BY_MULTIPLICATION"; EQ_REMOVE_TERM_BY_DIVISION: "EQ_REMOVE_TERM_BY_DIVISION"; SIMPLIFY_ARITHMETIC__POWER: "SIMPLIFY_ARITHMETIC__POWER"; DIVISION_BY_NEGATIVE_ONE: "DIVISION_BY_NEGATIVE_ONE"; DIVISION_BY_ONE: "DIVISION_BY_ONE"; MULTIPLY_BY_ZERO: "MULTIPLY_BY_ZERO"; MULTIPLY_NTH_ROOTS: "MULTIPLY_NTH_ROOTS"; DISTRIBUTE_NEGATIVE_ONE: "DISTRIBUTE_NEGATIVE_ONE"; KEMU_MULTIPLY_EXPONENTS: "KEMU_MULTIPLY_EXPONENTS"; REARRANGE_COEFF: "REARRANGE_COEFF"; KEMU_FACTOR_EXPRESSION_UNDER_ROOT: "KEMU_FACTOR_EXPRESSION_UNDER_ROOT"; REDUCE_EXPONENT_BY_ZERO: "REDUCE_EXPONENT_BY_ZERO"; REMOVE_EXPONENT_BY_ONE: "REMOVE_EXPONENT_BY_ONE"; REMOVE_EXPONENT_BASE_ONE: "REMOVE_EXPONENT_BASE_ONE"; REMOVE_EXPONENT_BASE_ZERO: "REMOVE_EXPONENT_BASE_ZERO"; REMOVE_ADDING_ZERO: "REMOVE_ADDING_ZERO"; REMOVE_MULTIPLYING_BY_NEGATIVE_ONE: "REMOVE_MULTIPLYING_BY_NEGATIVE_ONE"; REMOVE_MULTIPLYING_BY_ONE: "REMOVE_MULTIPLYING_BY_ONE"; SIMPLIFY_SIGNS: "SIMPLIFY_SIGNS"; COLLECT_AND_COMBINE_LIKE_TERMS: "COLLECT_AND_COMBINE_LIKE_TERMS"; KEMU_ORIGINAL_EXPRESSION: "KEMU_ORIGINAL_EXPRESSION"; ABSOLUTE_VALUE: "ABSOLUTE_VALUE"; ADD_FRACTIONS: "ADD_FRACTIONS"; COMMON_DENOMINATOR: "COMMON_DENOMINATOR"; KEMU_DECIMAL_TO_FRACTION: "KEMU_DECIMAL_TO_FRACTION"; KEMU_REMOVE_FRACTION_WITH_UNIT_NUMERATOR: "KEMU_REMOVE_FRACTION_WITH_UNIT_NUMERATOR"; BREAK_UP_FRACTION: "BREAK_UP_FRACTION"; KEMU_PYTHAGOREAN_IDENTITY: "KEMU_PYTHAGOREAN_IDENTITY"; KEMU_EVEN_FUNCTION_OF_NEGATIVE: "KEMU_EVEN_FUNCTION_OF_NEGATIVE"; KEMU_ODD_FUNCTION_OF_NEGATIVE: "KEMU_ODD_FUNCTION_OF_NEGATIVE"; KEMU_CONVERT_SIN_PER_COS_TO_TAN: "KEMU_CONVERT_SIN_PER_COS_TO_TAN"; KEMU_CONVERT_COS_PER_SIN_TO_COT: "KEMU_CONVERT_COS_PER_SIN_TO_COT"; KEMU_CANCEL_INVERSE_FUNCTION: "KEMU_CANCEL_INVERSE_FUNCTION"; KEMU_FUNCTION_VALUE: "KEMU_FUNCTION_VALUE"; KEMU_LOG_XY_FROM_ONE: "KEMU_LOG_XY_FROM_ONE"; KEMU_LOG_XY_FROM_BASE: "KEMU_LOG_XY_FROM_BASE"; KEMU_LOG_XY_FROM_POWER: "KEMU_LOG_XY_FROM_POWER"; KEMU_CONVERT_ROOT_TO_POWER: "KEMU_CONVERT_ROOT_TO_POWER"; KEMU_CONVERT_POWER_TO_ROOT: "KEMU_CONVERT_POWER_TO_ROOT"; KEMU_POWER_FRACTION: "KEMU_POWER_FRACTION"; KEMU_POWER_SQRT: "KEMU_POWER_SQRT"; KEMU_SQRT_FROM_ZERO: "KEMU_SQRT_FROM_ZERO"; KEMU_SQRT_FROM_ONE: "KEMU_SQRT_FROM_ONE"; KEMU_SQRT_FROM_POW: "KEMU_SQRT_FROM_POW"; KEMU_SQRT_FROM_CONST: "KEMU_SQRT_FROM_CONST"; KEMU_ROOT_FROM_CONST: "KEMU_ROOT_FROM_CONST"; EQ_SWAP_SIDES: "EQ_SWAP_SIDES"; }; print: typeof printAscii; printAsTeX: typeof printAsTeX; math: { abs: <T extends MathType>(x: T) => T; AccessorNode: AccessorNodeCtor; add: { <T extends MathType>(x: T, y: T): T; <T extends MathType>(...values: T[]): T; (x: MathType, y: MathType): MathType; (...values: MathType[]): MathType; }; bignumber: { (x?: number | string | Fraction | BigNumber | bigint | Unit | boolean | null): BigNumber; <T extends MathCollection>(x: T): T; }; BlockNode: BlockNodeCtor; ConstantNode: ConstantNodeCtor; compare: (x: MathType | string, y: MathType | string) => number | BigNumber | Fraction | MathCollection; ConditionalNode: ConditionalNodeCtor; derivative: (expr: MathNode | string, variable: MathNode | string, options?: { simplify: boolean; }) => MathNode; divide: { (x: Unit, y: Unit): Unit | number; (x: Unit, y: number): Unit; (x: number, y: number): number; (x: MathType, y: MathType): MathType; }; equal: (x: MathType | string, y: MathType | string) => boolean | MathCollection; evaluate: { (expr: MathExpression | Matrix, scope?: object): any; (expr: MathExpression[], scope?: object): any[]; }; FunctionNode: FunctionNodeCtor; OperatorNode: OperatorNodeCtor; IndexNode: IndexNodeCtor; isAccessorNode: (x: unknown) => x is AccessorNode; isAssignmentNode: (x: unknown) => x is AssignmentNode; isBlockNode: (x: unknown) => x is BlockNode; isConditionalNode: (x: unknown) => x is ConditionalNode; isConstantNode: (x: unknown) => x is ConstantNode; isFraction: (x: unknown) => x is Fraction; isFunctionAssignmentNode: (x: unknown) => x is FunctionAssignmentNode; isFunctionNode: (x: unknown) => x is FunctionNode; isIndexNode: (x: unknown) => x is IndexNode; isInteger: (x: number | BigNumber | Fraction | MathCollection) => boolean; isNegative: (x: number | BigNumber | bigint | Fraction | MathCollection | Unit) => boolean; isNode: (x: unknown) => x is MathNode; isNumeric: (x: any) => x is number | BigNumber | bigint | Fraction | boolean; isOperatorNode: (x: unknown) => x is OperatorNode<OperatorNodeOp, OperatorNodeFn>; isParenthesisNode: (x: unknown) => x is ParenthesisNode; isPositive: (x: number | BigNumber | bigint | Fraction | MathCollection | Unit) => boolean; isRangeNode: (x: unknown) => x is RangeNode; isSymbolNode: (x: unknown) => x is SymbolNode; isZero: (x: MathType) => boolean; lcm: <T extends number | BigNumber | MathCollection>(a: T, b: T) => T; mod: <T extends number | BigNumber | bigint | Fraction | MathCollection>(x: T, y: number | BigNumber | bigint | Fraction | MathCollection) => NoLiteralType<T>; multiply: { <T extends Matrix>(x: T, y: MathType): Matrix; <T extends Matrix>(x: MathType, y: T): Matrix; <T extends MathNumericType[]>(x: T, y: T[]): T; <T extends MathNumericType[]>(x: T[], y: T): T; <T extends MathArray>(x: T, y: T): T; (x: Unit, y: Unit): Unit; (x: number, y: number): number; (x: MathType, y: MathType): MathType; <T extends MathType>(...values: T[]): T; (...values: MathType[]): MathType; }; parse: ParseFunction; pow: (x: MathType, y: number | BigNumber | bigint | Complex) => MathType; print: (template: string, values: any, precision?: number, options?: number | object) => void; subtract: { <T extends MathType>(x: T, y: T): T; (x: MathType, y: MathType): MathType; }; SymbolNode: SymbolNodeCtor; unequal: (x: MathType | string, y: MathType | string) => boolean | MathCollection; resolve: { (node: MathNode | string, scope?: Record<string, any>): MathNode; (node: (MathNode | string)[], scope?: Record<string, any>): MathNode[]; (node: Matrix, scope?: Record<string, any>): Matrix; }; sign: <T extends MathType>(x: T) => T; larger: (x: MathType | string, y: MathType | string) => boolean | MathCollection; gcd: { <T extends number | BigNumber | Fraction | MathCollection>(...args: T[]): T; <T extends number | BigNumber | Fraction | Matrix>(args: T[]): T; }; }; FunctionNode: FunctionNodeCtor; convertTextToTeX: typeof convertTextToTeX; parseText: typeof parseText; isOkAsSymbolicExpression: (expressionAsText: string) => boolean; registerPreprocessorBeforeParse: (cb: (text: string) => string) => void; registerPreprocessorAfterParse: (cb: (node: MathNode) => MathNode) => void; }; export default _default; export declare const doesChangeTypeEqual: (a: AChangeType, b: AChangeType) => boolean; declare interface EqLRStep { left: ProcessedStep; right: ProcessedStep; } declare interface EqLRStepWithNewTo extends EqLRStep { newTo: string; } declare class Equation { /** * @param {{ leftNode?: any; rightNode?: any; comparator?: any; unknownVariable: any; equationAsText?: any; parent?: any; onStepCb?: any; id?: any; }} options */ constructor(options: { leftNode?: any; rightNode?: any; comparator?: any; unknownVariable: any; equationAsText?: any; parent?: any; onStepCb?: any; id?: any; }); parent: any; unknownVariable: any; onStepCb: any; id: any; comparator: any; left: EquationTerm; right: EquationTerm; logWidthForStepName: number | undefined; logWidthForEquation: number | undefined; logWidthForScheme: number | undefined; logLastColumnEq: any; steps: any[]; solutions: any[] | SymbolNode[] | null; toString(): string; getAsTeX(): string; getScheme(): any; _log(...args: any[]): void; _logStep(msg: any, showRepeatedSteps?: boolean, ext?: {}): void; _unflattenNode(node: any): MathNode; _simplifySide(side: any): any; _parseNode(node: any): EquationTerm; swapSides(): void; simplifyLeft(): void; simplifyRight(): void; applyStep(stepName: any, newNodes: any, ext: any): void; applyRules(poolOfRules: any, options?: {}): void; _isOkAsSolution(node: any): boolean; applySolution(solutions: any): void; getSolutions(): any[] | SymbolNode[] | null; getSolutionsAsText(): string; isSolved(): boolean; getId(): any; } export declare const EQUATION_CHANGE_TYPES: readonly ["EQ_REMOVE_TERM", "EQ_ADD_TERM", "EQ_ATMPT_REMOVAL_BOTH_SIDES", "EQ_ADDED_DIFF_TERMS_TO_BOTH_SIDES", "EQ_NOT_SAME_OP_PERFORMED", "EQ_PLACED_LEFT_SIDE_ONLY", "EQ_PLACED_RIGHT_SIDE_ONLY", "EQ_ATMPT_OP_BOTH_SIDES", "EQ_SWAP_SIDES", "EQ_SIMPLIFY_RHS", "EQ_SIMPLIFY_LHS", "EQ_SIMPLIFY_BOTH", "EQ_NO_CHANGE", "EQ_CROSS_MULTIPLY", "EQ_MULTIPLY_BOTH_SIDES_BY_NEGATIVE_ONE"]; export declare const EquationChangeTypes: { [K in AEquationChangeType]: K; }; export declare class EquationCommander { private equationHistory; private readonly finalCorrectAnswer; private readonly correctAnswerSteps; private readonly assessedSteps; constructor(initialValue?: string); redo: () => void; undo: () => void; setValue: (newValue: string) => void; getValue: () => string; isSolved: () => boolean; getHistory: () => string[]; getFuture: () => string[]; swap(): void; getAssessedSteps: () => ProcessedEquation[]; getCorrectAnswerSteps: () => { equationString: string; }[]; getFastestAmountOfStepsToSolve: () => number; getCurrentNumberOfSteps: () => number; getCurrentMatches(): EqLRStepWithNewTo[]; getMatchesForRule(rule: AMathRule | 'all'): EqLRStepWithNewTo[]; } declare class EquationTerm { static createConstant(node: any): EquationTerm; static createPolynomial(node: any): EquationTerm; static createFunction(node: any): EquationTerm; static operator2(op: any, a: any, b: any): EquationTerm; static add(a: any, b: any): EquationTerm; static sub(a: any, b: any): EquationTerm; static mul(a: any, b: any): EquationTerm; static div(a: any, b: any): EquationTerm; static pow(a: any, b: any): EquationTerm; static neg(a: any): EquationTerm; constructor(type: any, node: any, data: any); type: any; node: any; data: any; toString(): any; } export declare const getChangesTypesForRule: (rule: AMathRule) => AChangeType[]; export declare const getChangeTypeGroups: (changeType_: AChangeType) => AChangeTypeGroup[]; export declare function getEveryChangeIdApplicable(changeTypeOrMistakeType_: AChangeType): (AChangeTypeGroup | AChangeType)[]; export declare const getMathRuleForChangeType: (changeType: AChangeTypeCore) => AMathRule | null; export declare const getRootChangeType: <T extends { includes: any; split?: any; } | null>(changeType_: T) => T; export declare const isChangeTypeInGroup: (changeType: AChangeType, group: AChangeTypeGroup) => boolean; export declare const isMistakeTypeOnly: (change: AChangeType) => boolean; export declare const isOkAsSymbolicExpression: (expressionAsText: string) => boolean; export declare const isSameRootChangeType: (rootChangeType: string | AChangeType, changeType: string | AChangeType) => boolean; declare const math_2: { abs: <T extends MathType>(x: T) => T; AccessorNode: AccessorNodeCtor; add: { <T extends MathType>(x: T, y: T): T; <T extends MathType>(...values: T[]): T; (x: MathType, y: MathType): MathType; (...values: MathType[]): MathType; }; bignumber: { (x?: number | string | Fraction | BigNumber | bigint | Unit | boolean | null): BigNumber; <T extends MathCollection>(x: T): T; }; BlockNode: BlockNodeCtor; ConstantNode: ConstantNodeCtor; compare: (x: MathType | string, y: MathType | string) => number | BigNumber | Fraction | MathCollection; ConditionalNode: ConditionalNodeCtor; derivative: (expr: MathNode | string, variable: MathNode | string, options?: { simplify: boolean; }) => MathNode; divide: { (x: Unit, y: Unit): Unit | number; (x: Unit, y: number): Unit; (x: number, y: number): number; (x: MathType, y: MathType): MathType; }; equal: (x: MathType | string, y: MathType | string) => boolean | MathCollection; evaluate: { (expr: MathExpression | Matrix, scope?: object): any; (expr: MathExpression[], scope?: object): any[]; }; FunctionNode: FunctionNodeCtor; OperatorNode: OperatorNodeCtor; IndexNode: IndexNodeCtor; isAccessorNode: (x: unknown) => x is AccessorNode; isAssignmentNode: (x: unknown) => x is AssignmentNode; isBlockNode: (x: unknown) => x is BlockNode; isConditionalNode: (x: unknown) => x is ConditionalNode; isConstantNode: (x: unknown) => x is ConstantNode; isFraction: (x: unknown) => x is Fraction; isFunctionAssignmentNode: (x: unknown) => x is FunctionAssignmentNode; isFunctionNode: (x: unknown) => x is FunctionNode; isIndexNode: (x: unknown) => x is IndexNode; isInteger: (x: number | BigNumber | Fraction | MathCollection) => boolean; isNegative: (x: number | BigNumber | bigint | Fraction | MathCollection | Unit) => boolean; isNode: (x: unknown) => x is MathNode; isNumeric: (x: any) => x is number | BigNumber | bigint | Fraction | boolean; isOperatorNode: (x: unknown) => x is OperatorNode<OperatorNodeOp, OperatorNodeFn>; isParenthesisNode: (x: unknown) => x is ParenthesisNode; isPositive: (x: number | BigNumber | bigint | Fraction | MathCollection | Unit) => boolean; isRangeNode: (x: unknown) => x is RangeNode; isSymbolNode: (x: unknown) => x is SymbolNode; isZero: (x: MathType) => boolean; lcm: <T extends number | BigNumber | MathCollection>(a: T, b: T) => T; mod: <T extends number | BigNumber | bigint | Fraction | MathCollection>(x: T, y: number | BigNumber | bigint | Fraction | MathCollection) => NoLiteralType<T>; multiply: { <T extends Matrix>(x: T, y: MathType): Matrix; <T extends Matrix>(x: MathType, y: T): Matrix; <T extends MathNumericType[]>(x: T, y: T[]): T; <T extends MathNumericType[]>(x: T[], y: T): T; <T extends MathArray>(x: T, y: T): T; (x: Unit, y: Unit): Unit; (x: number, y: number): number; (x: MathType, y: MathType): MathType; <T extends MathType>(...values: T[]): T; (...values: MathType[]): MathType; }; parse: ParseFunction; pow: (x: MathType, y: number | BigNumber | bigint | Complex) => MathType; print: (template: string, values: any, precision?: number, options?: number | object) => void; subtract: { <T extends MathType>(x: T, y: T): T; (x: MathType, y: MathType): MathType; }; SymbolNode: SymbolNodeCtor; unequal: (x: MathType | string, y: MathType | string) => boolean | MathCollection; resolve: { (node: MathNode | string, scope?: Record<string, any>): MathNode; (node: (MathNode | string)[], scope?: Record<string, any>): MathNode[]; (node: Matrix, scope?: Record<string, any>): Matrix; }; sign: <T extends MathType>(x: T) => T; larger: (x: MathType | string, y: MathType | string) => boolean | MathCollection; gcd: { <T extends number | BigNumber | Fraction | MathCollection>(...args: T[]): T; <T extends number | BigNumber | Fraction | Matrix>(args: T[]): T; }; }; export { math_2 as math } export declare const MATH_RULE_TO_CHANGE_TYPE_MAPPING: Record<AMathRule, AChangeType[]>; /** * Mistake types only. (not change types) * Mistake types are mistakes we found in mistake detection. At the current moment, Mistake detection only is checked if one side/expression is changed. */ declare const MISTAKE_ONLY: { readonly PEMDAS__ADD_INSTEAD_OF_MULTIPLY: "PEMDAS__ADD_INSTEAD_OF_MULTIPLY"; readonly ADDED_INSTEAD_OF_MULTIPLIED: "ADDED_INSTEAD_OF_MULTIPLIED"; readonly SUBTRACTED_INSTEAD_OF_MULTIPLIED: "SUBTRACTED_INSTEAD_OF_MULTIPLIED"; readonly MULTIPLIED_INSTEAD_OF_ADDED: "MULTIPLIED_INSTEAD_OF_ADDED"; readonly MULTIPLIED_INSTEAD_OF_SUBTRACTED: "MULTIPLIED_INSTEAD_OF_SUBTRACTED"; readonly MULTIPLIED_ONE_TOO_MANY: "MULTIPLIED_ONE_TOO_MANY"; readonly MULTIPLIED_ONE_TOO_FEW: "MULTIPLIED_ONE_TOO_FEW"; readonly ADDED_ONE_TOO_FEW: "ADDED_ONE_TOO_FEW"; readonly ADDED_ONE_TOO_MANY: "ADDED_ONE_TOO_MANY"; readonly SUBTRACTED_ONE_TOO_FEW: "SUBTRACTED_ONE_TOO_FEW"; readonly SUBTRACTED_ONE_TOO_MANY: "SUBTRACTED_ONE_TOO_MANY"; readonly UNKNOWN: "UNKNOWN"; readonly NO_CHANGE: "NO_CHANGE"; readonly SUBTRACTED_INSTEAD_OF_ADDED: "SUBTRACTED_INSTEAD_OF_ADDED"; readonly ADDED_INSTEAD_OF_SUBTRACTED: "ADDED_INSTEAD_OF_SUBTRACTED"; }; /** * @returns {string} */ export declare function myNodeToString(unknownThing: any, options: any, extraOptions?: {}): string; declare interface NumberOp { op: AOperator; number: string; dfsNodeId?: number; depth?: number; } declare const OPERATORS: readonly ["+", "-", "*", "/", "--", "+-"]; export declare function parseText(text: string): MathNode; declare const print_2: typeof printAscii; export { print_2 as print } export declare function printAscii(node: any): any; export declare function printAsTeX(node: MathNode): string; export declare interface ProcessedEquation { left: StepInfo[]; right: StepInfo[]; attemptedEquationChangeType: AEquationChangeType; equationErrorType?: AEquationChangeType; reachesOriginalAnswer: boolean; } /** * The processed step is the same as the raw step, but the 'to' is a string instead of an array of strings. We flattened it. TODO make a better name for this. IntermediateStep? * TODO: - A lot of this type is optional and is causing issues/confusion. It needs to be more strict and have less optional properties. * TODO: There is slight ambiguity between: the "attempted", things and the "actual" things. Its fixed in processed steps but multiple/shared/slightly different definitions here are slightly confusing. */ declare type ProcessedStep = Omit<RawStep, 'to'> & { to: string; availableChangeTypes: AChangeType[]; attemptedToGetTo?: string; attemptedChangeType?: AChangeType; allPossibleCorrectTos?: string[]; equationActionType?: AEquationChangeType; addedNumOp?: NumberOp; removeNumberOp?: NumberOp; deferDepth?: number; isDeferred?: boolean; }; /** * Creates a history of steps found from the previous step to get to the user's step. Requires processStepInfo to convert the history into the final StepInfo[] form. */ declare interface RawStep { from: string; to: string[]; changeType: AChangeType; isMistake: boolean; mTo?: { to: string; changeType: AChangeType; }[]; } export declare const registerPreprocessorAfterParse: (cb: (node: MathNode) => MathNode) => void; export declare const registerPreprocessorBeforeParse: (cb: (text: string) => string) => void; export declare const simplifyExpression: (optionsOrExpressionAsText: SimplifyOptions | string) => any; declare interface SimplifyOptions { expressionAsText?: string; expressionNode?: MathNode; isDebugMode?: boolean; expressionCtx?: any; getMistakes?: boolean; getAllNextStepPossibilities?: boolean; onStepCb?: Function; } export declare function solveEquation(options: SolveEquationOptions): Equation; declare interface SolveEquationOptions { leftNode?: any; rightNode?: any; comparator?: any; unknownVariable: any; equationAsText: string; parent?: any; onStepCb?: Function; id?: any; } /** * The final step info object that is returned to the user. Less optionals. */ export declare interface StepInfo { isValid: boolean; reachesOriginalAnswer: boolean; from: string; to: string; attemptedToGetTo: string; attemptedChangeType: AChangeType; mistakenChangeType: AChangeType | null; availableChangeTypes: AChangeType[]; allPossibleCorrectTos?: string[]; equationActionType?: AEquationChangeType; addedNumOp?: NumberOp; removeNumberOp?: NumberOp; } export { } declare namespace NodeCreator { function operator(op: any, args: any, implicit?: boolean): any; function unaryMinus(content: any): import("mathjs").ConstantNode<string | number> | import("mathjs").OperatorNode<"-", "unaryMinus", [any]>; function constant(val: any): import("mathjs").ConstantNode<any>; function symbol(name: any): import("mathjs").SymbolNode; function parenthesis(content: any): any; function list(content: any): any; function term(base: any, exponent: any, coeff: any, explicitCoeff?: boolean): any; function polynomialTerm(symbol: any, exponent: any, coeff: any, explicitCoeff?: boolean): any; function nthRoot(radicandNode: any, rootNode: any): import("mathjs").FunctionNode<import("mathjs").SymbolNode, [any, any]> | import("mathjs").FunctionNode<import("mathjs").SymbolNode, [any]>; function kemuCreateAbs(node: any): import("mathjs").FunctionNode<import("mathjs").SymbolNode, [any]>; function kemuCreateSqrt(node: any): import("mathjs").FunctionNode<import("mathjs").SymbolNode, [any]>; function kemuCreateBuiltInConstant(name: any): import("mathjs").AccessorNode<import("mathjs").SymbolNode>; function percent(node: any): import("mathjs").FunctionNode<string, [any]>; function kemuCreateByFn(fn: any, args: any): any; } declare namespace NodeType { function isOperator(node: any, operator?: null): boolean; function isUnaryMinus(node: any): boolean; function isFunction(node: any, functionName?: null): boolean; function isNthRoot(node: any): boolean; function getRootNode(node: any): any; function getRadicandNode(node: any): any; function isSymbol(node: any, allowUnaryMinus?: boolean): any; function isNamedSymbol(node: any, expectedName: any): boolean; function isConstant(node: any, allowUnaryMinus?: boolean): boolean; function isMixedNumber(node: any, _allowUnaryMinus?: boolean): boolean; function isConstantFraction(node: any, allowUnaryMinus?: boolean): any; function isConstantOrConstantFraction(node: any, allowUnaryMinus?: boolean): boolean; function isIntegerFraction(node: any, allowUnaryMinus?: boolean): boolean; function kemuIsConstantInteger(node: any, expectedValue: any): boolean | import("mathjs").MathCollection; function isZero(node: any): boolean; function kemuIsConstantNegative(node: any): boolean; function kemuIsConstantPositive(node: any): boolean; function kemuIsConstantOrSymbol(node: any): any; function doesContainSymbol(node: any, symbolName: any): any; function isPowerOfSymbol(node: any): any; function isSymbolOrPowerOfSymbol(node: any): any; function isPolynomialTerm(node: any): boolean; }