Skip to main content

Algebraic Expression Ontology

Algebra Ontologies
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 20 September 2026
Audio Overview
======================================================================
KIRETH SEMANTIC RESEARCH ARCHIVE
FLOW ALGEBRA — ALGEBRAIC EXPRESSION ONTOLOGY
======================================================================

PAGE:
https://kirethresearch.org/booksai-core/ontologies/mathematical-ontologies/algebra-ontologies/algebraic-expression-ontology.html

FLOW:
AlgebraicExpressionOntology

VERSION:
1.0

LANGUAGE:
en-GB

AUTHORS:
Mark Anthony Higgins — Sky Recursive AI

PURPOSE:
To provide a machine-readable, recursively executable semantic and
reasoning specification for algebraic expressions, including constants,
variables, coefficients, terms, operators, powers, products, sums,
fractions, radicals, function applications, expression trees,
simplification, expansion, factorisation, substitution, evaluation,
equivalence, normal forms, domain restrictions and validation.

AI INTERPRETATION NOTE:
Execute the following specification as formal semantic and reasoning
rules. Preserve operator precedence, grouping, domains, variable
bindings, coefficient domains, expression equivalence and all
restrictions introduced by division, roots, logarithms or other
partial operations.

======================================================================
START FLOW
======================================================================

FLOW AlgebraicExpressionOntology {

----------------------------------------------------------------------
1. DOMAIN DECLARATION
----------------------------------------------------------------------

DOMAIN := Algebraic_Expression_Theory

PARENT_DOMAIN := Algebra

SUPER_DOMAINS := {
    Mathematics,
    Mathematical_Ontologies,
    Algebra_Ontologies,
    Elementary_Algebra
}

DOMAIN_INTENT := {
    represent_algebraic_expressions,
    represent_constants,
    represent_variables,
    represent_coefficients,
    represent_terms,
    represent_factors,
    represent_operators,
    represent_expression_trees,
    represent_grouping,
    represent_powers,
    represent_products,
    represent_sums,
    represent_fractions,
    represent_radicals,
    represent_function_applications,
    represent_domain_restrictions,
    represent_substitution,
    represent_evaluation,
    represent_simplification,
    represent_expansion,
    represent_factorisation,
    represent_equivalence,
    represent_normal_forms,
    support_recursive_expression_reasoning,
    support_domain_preserving_validation
}

----------------------------------------------------------------------
2. PRIMITIVE TYPES
----------------------------------------------------------------------

TYPE Scalar
TYPE Constant <: Scalar
TYPE Variable
TYPE Coefficient <: Scalar
TYPE Operator
TYPE UnaryOperator <: Operator
TYPE BinaryOperator <: Operator
TYPE NaryOperator <: Operator
TYPE Factor
TYPE Term
TYPE AlgebraicExpression
TYPE PolynomialExpression <: AlgebraicExpression
TYPE RationalExpression <: AlgebraicExpression
TYPE RadicalExpression <: AlgebraicExpression
TYPE ExponentialExpression <: AlgebraicExpression
TYPE LogarithmicExpression <: AlgebraicExpression
TYPE FunctionApplication <: AlgebraicExpression
TYPE Equation
TYPE Identity
TYPE DomainRestriction
TYPE Assignment
TYPE ExpressionTree
TYPE Node
TYPE LeafNode <: Node
TYPE OperatorNode <: Node
TYPE Constraint
TYPE Derivation
TYPE ValidationResult

----------------------------------------------------------------------
3. ALGEBRAIC EXPRESSION DEFINITION
----------------------------------------------------------------------

ENTITY AlgebraicExpression E {
    symbols: constants | variables
    operators: Operator*
    grouping: explicit_or_implicit
    syntax_tree: -ExpressionTree
}

RULE EXPR_01:
    every valid algebraic expression has a well-formed syntax tree.

RULE EXPR_02:
-
    expression semantics are determined by:
        symbols,
        operator meanings,
        precedence,
        grouping,
        declared domains.

RULE EXPR_03:
    same printed symbols under different grouping may represent different
    expressions.

----------------------------------------------------------------------
4. CONSTANTS
----------------------------------------------------------------------

ENTITY Constant c {
    value: fixed_within_context
    domain: ScalarDomain
}

EXAMPLES:
    integer constants
    rational constants
    real constants
    complex constants
    named constants such as pi or e

RULE CONST_01:
    constant contains no free algebraic variable.

----------------------------------------------------------------------
5. VARIABLES
----------------------------------------------------------------------

ENTITY Variable x {
    name: Symbol
    domain: declared_or_inferred_domain
    constraints: Constraint*
}

RULE VAR_01:
    variable may represent unknown, parameter or free input depending
    on contextual role.

RULE VAR_02:
    variable identity depends on symbol and binding scope.

----------------------------------------------------------------------
6. COEFFICIENTS
----------------------------------------------------------------------

ENTITY Coefficient a {
    role:
        scalar_multiplier_of_term_or_factor
}

EXAMPLE:
    in 5x^2:
        coefficient=5

RULE COEF_01:
    coefficient domain must be compatible with expression domain.

----------------------------------------------------------------------
7. FACTORS
----------------------------------------------------------------------

ENTITY Factor F {
    multiplicative_component_of_term
}

EXAMPLES:
    constant
    variable
    power
    bracketed expression
    function application

RULE FACT_01:
    product expression consists of one or more factors.

----------------------------------------------------------------------
8. TERMS
----------------------------------------------------------------------

ENTITY Term T {
    sign: optional
    coefficient: optional
    factors: Factor*
}

RULE TERM_01:
    terms in additive expressions are separated by top-level addition
    or subtraction.

RULE TERM_02:
    internal addition inside grouping does not split outer term.

----------------------------------------------------------------------
9. SUM EXPRESSIONS
----------------------------------------------------------------------

SUM(E1,...,En):
    E1+...+En

RULE SUM_01:
    addition is associative where domain operation is associative.

RULE SUM_02:
    addition is commutative where domain operation is commutative.

RULE SUM_03:
    zero is additive identity.

----------------------------------------------------------------------
10. PRODUCT EXPRESSIONS
----------------------------------------------------------------------

PRODUCT(E1,...,En):
    E1*...*En

RULE PROD_01:
    multiplication associative in standard scalar algebra.

RULE PROD_02:
    multiplication commutative for scalar expressions over commutative
    coefficient domains.

RULE PROD_03:
    multiplication by 1 leaves expression unchanged.

RULE PROD_04:
    multiplication by 0 yields 0 when expression is defined.

----------------------------------------------------------------------
11. POWERS
----------------------------------------------------------------------

POWER(base,exponent):
    base^exponent

RULE POW_01:
    exponent meaning depends on exponent domain.

RULE POW_02:
    for integer n>=0:
        x^n represents repeated multiplication.

RULE POW_03:
    x^0=1 where x!=0 under ordinary exponent convention.

RULE POW_04:
    x^(-n)=1/x^n where x!=0.

----------------------------------------------------------------------
12. RADICAL EXPRESSIONS
----------------------------------------------------------------------

ROOT_n(E):
    nth_root(E)

FOR REAL DOMAIN:
    if n even:
        REQUIRE E>=0

RULE RAD_01:
    sqrt(E^2)=|E| over real domain.

RULE RAD_02:
    radical simplification must preserve domain assumptions.

----------------------------------------------------------------------
13. FRACTION / QUOTIENT EXPRESSIONS
----------------------------------------------------------------------

QUOTIENT(N,D):
    N/D

REQUIRE:
    D!=0

RULE FRAC_01:
    denominator contributes domain restriction D!=0.

RULE FRAC_02:
    cancelling factor F requires F!=0 on equivalence domain.

----------------------------------------------------------------------
14. FUNCTION APPLICATIONS
----------------------------------------------------------------------

FUNCTION_APPLICATION:
    f(E1,...,En)

RULE FUN_01:
    function arity must match supplied arguments.

RULE FUN_02:
    function domain restrictions propagate to containing expression.

EXAMPLES:
    log(E) requires E>0 over reals
    sqrt(E) requires E>=0 over reals

----------------------------------------------------------------------
15. EXPRESSION TREE
----------------------------------------------------------------------

ENTITY ExpressionTree {
    root: Node
}

LEAF_NODE:
    constant | variable

OPERATOR_NODE:
    operator with child expressions

RULE TREE_01:
    evaluation proceeds recursively from child nodes.

RULE TREE_02:
    tree structure removes ambiguity from infix notation.

----------------------------------------------------------------------
16. OPERATOR PRECEDENCE
----------------------------------------------------------------------

PRECEDENCE := [
    grouping,
    function_application,
    powers_and_roots,
    multiplication_and_division,
    addition_and_subtraction
]

RULE PREC_01:
    explicit grouping overrides default precedence.

RULE PREC_02:
    equal-precedence operations follow declared associativity.

----------------------------------------------------------------------
17. GROUPING
----------------------------------------------------------------------

GROUP(E):
    parenthesised expression

RULE GROUP_01:
    removing parentheses valid only if precedence and associativity
    preserve meaning.

RULE GROUP_02:
    unary minus applied to group distributes sign only when explicitly
    transformed.

----------------------------------------------------------------------
18. UNARY NEGATION
----------------------------------------------------------------------

NEGATE(E):=-E

RULE NEG_01:
    -(-E)=E

RULE NEG_02:
    -(A+B)=-A-B

RULE NEG_03:
    -(A-B)=-A+B

----------------------------------------------------------------------
19. LIKE TERMS
----------------------------------------------------------------------

LIKE_TERMS(T1,T2) iff
    same symbolic multiplicative part
    under canonical factor/exponent normalisation

RULE LIKE_01:
    aM+bM=(a+b)M

RULE LIKE_02:
    unlike terms must not be combined by coefficient addition.

----------------------------------------------------------------------
20. EXPRESSION NORMALISATION
----------------------------------------------------------------------

NORMALISE(E):

    parse expression tree

    normalise constants

    normalise signs

    normalise factor order where commutative

    combine repeated powers

    combine like terms

    remove identity elements

    preserve domain restrictions

    RETURN canonical_or_contextual_normal_form

----------------------------------------------------------------------
21. SIMPLIFICATION
----------------------------------------------------------------------

PROCEDURE SIMPLIFY(E):

    repeat until stable:

        evaluate numeric subexpressions

        remove additive zeros

        remove multiplicative ones

        simplify signs

        combine like terms

        combine powers where legal

        reduce numeric fractions

        cancel common proven-nonzero factors

        simplify nested grouping

    validate equivalence

    RETURN simplified_expression

----------------------------------------------------------------------
22. EXPANSION
----------------------------------------------------------------------

EXPAND(E):

    apply distributive law recursively

RULE EXP_01:
    A(B+C)=AB+AC

RULE EXP_02:
    (A+B)C=AC+BC

RULE EXP_03:
    (A+B)(C+D)=AC+AD+BC+BD

RULE EXP_04:
    expansion preserves algebraic equivalence on same domain.

----------------------------------------------------------------------
23. COMMON IDENTITIES
----------------------------------------------------------------------

IDENTITY SQ_SUM:
    (a+b)^2=a^2+2ab+b^2

IDENTITY SQ_DIFF:
    (a-b)^2=a^2-2ab+b^2

IDENTITY DIFF_SQUARES:
    (a+b)(a-b)=a^2-b^2

IDENTITY CUBE_SUM_EXP:
    (a+b)^3=a^3+3a^2b+3ab^2+b^3

IDENTITY CUBE_DIFF_EXP:
    (a-b)^3=a^3-3a^2b+3ab^2-b^3

----------------------------------------------------------------------
24. FACTORISATION
----------------------------------------------------------------------

FACTORISE(E):

    identify common factors

    recognise algebraic identities

    search valid product form

    validate by expansion

RULE FAC_01:
    AB+AC=A(B+C)

RULE FAC_02:
    a^2-b^2=(a-b)(a+b)

RULE FAC_03:
    a^2+2ab+b^2=(a+b)^2

RULE FAC_04:
    factorisation is inverse-style transformation of expansion.

----------------------------------------------------------------------
25. SUBSTITUTION
----------------------------------------------------------------------

SUBSTITUTE(E, mapping):

    replace each variable occurrence by mapped expression

    preserve grouping

    recursively reparse resulting expression

    propagate domain restrictions

    RETURN substituted_expression

RULE SUB_01:
    substitution of negative value into power requires grouping.

EXAMPLE:
    x^2, x=-3
    -> (-3)^2
    -> 9

----------------------------------------------------------------------
26. EVALUATION
----------------------------------------------------------------------

EVALUATE(E,assignment):

    verify all required variables assigned

    verify assignment satisfies variable constraints

    SUBSTITUTE(E,assignment)

    check operation domains

    evaluate recursively according to tree

    RETURN value

----------------------------------------------------------------------
27. FREE VARIABLES
----------------------------------------------------------------------

FREE_VARIABLES(E):
    variables appearing unbound in E

RULE FV_01:
    pure algebraic expressions usually treat all variables as free unless
    contextual binding exists.

----------------------------------------------------------------------
28. DOMAIN RESTRICTIONS
----------------------------------------------------------------------

EXTRACT_DOMAIN_RESTRICTIONS(E):

    for every denominator D:
        add D!=0

    for every real even root R:
        add radicand>=0

    for every real logarithm:
        add argument>0

    for every declared partial function:
        add function-domain constraints

    RETURN conjunction_of_constraints

----------------------------------------------------------------------
29. ALGEBRAIC EQUIVALENCE
----------------------------------------------------------------------

ALGEBRAIC_EQUIVALENT(A,B,D) iff
    for every valid assignment in D:
        A and B are both defined
        AND evaluate(A)=evaluate(B)

RULE EQV_01:
    matching canonical normal forms may establish equivalence.

RULE EQV_02:
    valid bidirectional transformation derivation may establish equivalence.

RULE EQV_03:
    numerical testing alone cannot generally prove universal equivalence.

----------------------------------------------------------------------
30. DOMAIN-SENSITIVE EQUIVALENCE
----------------------------------------------------------------------

EXAMPLE:
    (x^2-1)/(x-1)
    simplifies algebraically to x+1

ORIGINAL DOMAIN:
    x!=1

RULE DSEQ_01:
    reduced representation must preserve original restriction x!=1.

RULE DSEQ_02:
-
    expression equivalence may be relative to a specified domain.

----------------------------------------------------------------------
31. IDENTITIES
----------------------------------------------------------------------

IDENTITY(A,B) iff
    ALGEBRAIC_EQUIVALENT(A,B,all_permitted_values)

RULE ID_01:
    identity is universally true over its declared domain.

RULE ID_02:
    equation true at isolated assignments is not necessarily identity.

----------------------------------------------------------------------
32. CONSTANT EXPRESSIONS
----------------------------------------------------------------------

CONSTANT_EXPRESSION(E) iff
    FREE_VARIABLES(E)=empty
    after simplification/context resolution

RULE CE_01:
    constant expression may still contain named constants/functions.

----------------------------------------------------------------------
33. POLYNOMIAL EXPRESSIONS
----------------------------------------------------------------------

IS_POLYNOMIAL_EXPRESSION(E) iff
    expression is finite sum of monomials
    with nonnegative integer variable exponents
    and coefficients in declared ring/domain

RULE PE_01:
    variables may not appear in denominators in ordinary polynomial expression.

----------------------------------------------------------------------
34. RATIONAL EXPRESSIONS
----------------------------------------------------------------------

IS_RATIONAL_EXPRESSION(E) iff
    E=P/Q
    where P,Q polynomial expressions
    and Q nonzero polynomial

RULE RE_01:
    rational expression includes denominator restrictions.

----------------------------------------------------------------------
35. RADICAL EXPRESSIONS
----------------------------------------------------------------------

IS_RADICAL_EXPRESSION(E) iff
    expression contains root operation or fractional exponent interpreted
    as radical.

RULE RADE_01:
    radical-expression domain depends on scalar domain.

----------------------------------------------------------------------
36. EXPONENTIAL EXPRESSIONS
----------------------------------------------------------------------

IS_EXPONENTIAL_EXPRESSION(E) iff
    variable occurs in exponent position.

EXAMPLE:
    a^x

RULE EXPE_01:
    distinguishes exponential expression from polynomial power.

----------------------------------------------------------------------
37. LOGARITHMIC EXPRESSIONS
----------------------------------------------------------------------

IS_LOGARITHMIC_EXPRESSION(E) iff
    contains log operation

REAL_LOG_CONSTRAINT:
    argument>0

RULE LOGE_01:
    log base requires base>0 and base!=1 when explicitly declared.

----------------------------------------------------------------------
38. COMPLEXITY MODEL
----------------------------------------------------------------------

COMPLEXITY(E) :=
    operator_count
    + term_count
    + factor_count
    + nesting_depth
    + domain_restriction_weight

RULE CX_01:
    simplification usually prefers lower complexity,
    but temporary expansion may increase complexity to achieve target.

----------------------------------------------------------------------
39. CANONICAL FORMS
----------------------------------------------------------------------

CANONICAL_FORMS may include:

    simplified_form
    expanded_form
    factored_form
    polynomial_standard_form
    rational_reduced_form
    power_product_form

RULE CF_01:
    canonical form depends on expression class and requested reasoning task.

----------------------------------------------------------------------
40. SYMBOLIC DIFFERENTIATION LINK
----------------------------------------------------------------------

NOTE:
    derivative execution belongs to calculus ontology.

STRUCTURAL_LINK:
    algebraic expression is valid operand for differentiation where
    function semantics are defined.

RULE DIFFLINK_01:
    derivative result is another expression subject to simplification.

----------------------------------------------------------------------
41. SYMBOLIC INTEGRATION LINK
----------------------------------------------------------------------

NOTE:
    integration belongs to calculus ontology.

RULE INTLINK_01:
    algebraic expression may act as integrand under declared variable/domain.

----------------------------------------------------------------------
42. EQUATIONS FROM EXPRESSIONS
----------------------------------------------------------------------

BUILD_EQUATION(A,B):
    A=B

RULE EQN_01:
-
    expression ontology supplies sides;
    equation ontology supplies relation semantics and solving rules.

----------------------------------------------------------------------
43. INEQUALITIES FROM EXPRESSIONS
----------------------------------------------------------------------

BUILD_INEQUALITY(A,relation,B)

RULE INEQ_01:
    domain restrictions from both sides remain active.

----------------------------------------------------------------------
44. EXPRESSION REWRITING
----------------------------------------------------------------------

REWRITE_RULE R:
    pattern -> replacement
    with preconditions

VALID_REWRITE(R,E) iff
    pattern matches
    AND preconditions hold
    AND semantics preserved for claimed relation type

RULE RW_01:
    each rewrite step should be auditable.

----------------------------------------------------------------------
45. REWRITE SYSTEM
----------------------------------------------------------------------

ENTITY RewriteSystem {
    rules: RewriteRule*
    strategy: selection_policy
}

PROPERTIES may include:
    terminating
    confluent
    normalising

RULE RS_01:
    if rewrite system terminating and confluent,
    normal form is unique.

----------------------------------------------------------------------
46. PATTERN MATCHING
----------------------------------------------------------------------

MATCH(pattern,E):

    compare tree structure

    bind metavariables

    enforce pattern constraints

    RETURN substitution or failure

RULE PM_01:
    commutative matching may require factor/term normalisation first.

----------------------------------------------------------------------
47. TREE TRANSFORMATIONS
----------------------------------------------------------------------

TREE_REWRITE(E,node,R):

    replace matched subtree

    rebuild ancestors

    update domain restrictions

    validate resulting expression

----------------------------------------------------------------------
48. EXPRESSION HASH / STRUCTURAL ID
----------------------------------------------------------------------

STRUCTURAL_HASH(E):

    serialise canonical syntax tree

    include operator identities

    include variable identities

    exclude superficial formatting

RULE HASH_01:
    structurally equivalent canonical expressions may share hash.

RULE HASH_02:
    semantic equivalence does not always imply same structural hash.

----------------------------------------------------------------------
49. PARSING AMBIGUITY
----------------------------------------------------------------------

AMBIGUITY examples:

    -x^2
    a/bc
    implicit multiplication
    nested fraction notation
    function application without parentheses

RULE AMB_01:
    materially ambiguous parse must be resolved before formal reasoning.

----------------------------------------------------------------------
50. IMPLICIT MULTIPLICATION
----------------------------------------------------------------------

EXAMPLES:
    2x := 2*x
    ab := a*b under scalar-symbol convention
    3(x+1):=3*(x+1)

RULE IM_01:
    implicit multiplication precedence must be explicitly standardised.

----------------------------------------------------------------------
51. SEMANTIC RELATIONSHIPS
----------------------------------------------------------------------

RELATION HAS_TERM(AlgebraicExpression,Term)
RELATION HAS_FACTOR(Term,Factor)
RELATION HAS_VARIABLE(AlgebraicExpression,Variable)
RELATION HAS_CONSTANT(AlgebraicExpression,Constant)
RELATION HAS_OPERATOR(AlgebraicExpression,Operator)
RELATION HAS_DOMAIN_RESTRICTION(AlgebraicExpression,Constraint)
RELATION SIMPLIFIES_TO(AlgebraicExpression,AlgebraicExpression)
RELATION EXPANDS_TO(AlgebraicExpression,AlgebraicExpression)
RELATION FACTORISES_TO(AlgebraicExpression,AlgebraicExpression)
RELATION EQUIVALENT_TO(AlgebraicExpression,AlgebraicExpression)
RELATION SUBSTITUTES_IN(AlgebraicExpression,Variable)

----------------------------------------------------------------------
52. SEMANTIC EQUIVALENCE
----------------------------------------------------------------------

SEMANTIC_EQUIVALENCE {

    "algebraic expression" ~= symbolic_combination_of_values_variables_and_operations

    "term" ~= top_level_additive_component

    "factor" ~= multiplicative_component

    "coefficient" ~= scalar_multiplier

    "simplify" ~= transform_to_equivalent_less_complex_form

    "expand" ~= distribute_products_over_sums

    "factorise" ~= rewrite_sum_or_expression_as_product

    "substitute" ~= replace_variable_by_value_or_expression

    "evaluate" ~= compute_expression_value_under_assignment

    "equivalent expressions" ~= same_value_for_all_valid_assignments_in_domain

    "normal form" ~= canonical_or_strategy_selected_representation
}

----------------------------------------------------------------------
53. QUERY INTERPRETATION
----------------------------------------------------------------------

QUERY Q1:
    "simplify E"
    -> SIMPLIFY(E)

QUERY Q2:
    "expand E"
    -> EXPAND(E)

QUERY Q3:
    "factorise E"
    -> FACTORISE(E)

QUERY Q4:
    "evaluate E when ..."
    -> EVALUATE(E,assignment)

QUERY Q5:
    "substitute ..."
    -> SUBSTITUTE(E,mapping)

QUERY Q6:
    "are A and B equivalent"
    -> ALGEBRAIC_EQUIVALENT with domain validation

QUERY Q7:
    "what is the domain"
    -> EXTRACT_DOMAIN_RESTRICTIONS(E)

QUERY Q8:
    "what type of expression"
    -> classify expression tree and operators

----------------------------------------------------------------------
54. VALIDATION ENGINE
----------------------------------------------------------------------

PROCEDURE VALIDATE_EXPRESSION(E):

    parse syntax tree

    check operator arities

    check variable domains

    check function domains

    extract restrictions

    verify well-formedness

    return:
        VALID
        INVALID(reason)
        AMBIGUOUS(parse_options)

PROCEDURE VALIDATE_TRANSFORMATION(A,B):

    compare domain constraints

    attempt symbolic derivation

    compare canonical forms where applicable

    optionally test representative values as supplementary evidence

    return:
        VALID
        INVALID(counterexample_or_rule_failure)
        UNRESOLVED

----------------------------------------------------------------------
55. RECURSIVE REASONING ENGINE
----------------------------------------------------------------------

PROCEDURE ALGEBRAIC_EXPRESSION_REASONER(input):

    parse expression syntax

    resolve grouping and precedence

    classify expression type

    extract free variables

    infer/verify domains

    extract restrictions

    identify requested operation

    select valid rewrite rules

    apply transformations atomically

    update expression tree

    preserve restrictions

    validate intermediate states

    recurse until target or normal form

    validate final result

    RETURN:
        result,
        derivation,
        expression_type,
        domain_restrictions,
        semantic_status,
        confidence

----------------------------------------------------------------------
56. RECURSIVE TRANSITION
----------------------------------------------------------------------

RECURSIVE_RULE RR_01:

    INPUT state S_n

    identify unresolved expression structure

    choose rule R such that:
        pattern_matches
        AND preconditions_hold
        AND domain_preserved

    S_(n+1):=apply(R,S_n)

    validate local equivalence

    recurse(S_(n+1))

TERMINATION_CONDITIONS := {
    requested_form_reached,
    simplification_fixed_point,
    canonical_form_reached,
    invalid_expression_detected,
    domain_failure,
    ambiguity_unresolved,
    no_valid_rule
}

----------------------------------------------------------------------
57. ERROR MODEL
----------------------------------------------------------------------

ERROR E_MALFORMED_EXPRESSION
ERROR E_OPERATOR_ARITY
ERROR E_PRECEDENCE_AMBIGUITY
ERROR E_GROUPING_AMBIGUITY
ERROR E_DOMAIN_VIOLATION
ERROR E_DIVISION_BY_ZERO
ERROR E_INVALID_REAL_ROOT
ERROR E_INVALID_LOG_ARGUMENT
ERROR E_COMBINE_UNLIKE_TERMS
ERROR E_INVALID_CANCELLATION
ERROR E_LOST_DOMAIN_RESTRICTION
ERROR E_NON_EQUIVALENT_REWRITE
ERROR E_VARIABLE_BINDING

----------------------------------------------------------------------
58. CONFIDENCE MODEL
----------------------------------------------------------------------

CONFIDENCE {

    base:=1.00

    deduct 0.10 if implicit multiplication ambiguous
    deduct 0.10 if variable domain inferred
    deduct 0.15 if grouping inferred
    deduct 0.15 if function semantics inferred
    deduct 0.20 if symbolic equivalence unresolved
    deduct 0.20 if domain restrictions incomplete
    deduct 0.25 if multiple material parses remain

    clamp_to_[0,1]

    classification:
        [0.95,1.00] -> very_high
        [0.85,0.95) -> high
        [0.70,0.85) -> moderate
        [0.50,0.70) -> low
        [0.00,0.50) -> insufficient
}

----------------------------------------------------------------------
59. AI CONSUMPTION MODEL
----------------------------------------------------------------------

AI_CONSUMPTION {

    read_order := [
        expression_definition,
        syntax_tree,
        operators,
        precedence,
        terms_and_factors,
        domain_restrictions,
        simplification,
        expansion,
        factorisation,
        substitution,
        evaluation,
        equivalence,
        validation
    ]

    execution_policy := {
        parse_before_transform,
        preserve_grouping,
        preserve_variable_domains,
        preserve_domain_restrictions,
        distinguish_structure_from_semantics,
        distinguish_identity_from_pointwise_equality,
        never_cancel_without_nonzero_condition,
        validate_every_rewrite,
        prefer_exact_symbolic_reasoning
    }
}

----------------------------------------------------------------------
60. UPDATE MODEL
----------------------------------------------------------------------

UPDATE_MODEL {

    extensible:=true

    new_operator_requires:
        arity,
        precedence,
        associativity,
        domain,
        codomain

    new_expression_class_requires:
        structural_predicate,
        domain_rules

    new_rewrite_rule_requires:
        pattern,
        replacement,
        preconditions,
        equivalence_status

    new_function_requires:
        arity,
        domain,
        codomain

    conflicts_require:
        explicit_versioning

    standard_algebraic_meaning_has_priority:=true
}

----------------------------------------------------------------------
61. SELF-CHECK
----------------------------------------------------------------------

SELF_CHECK {

    CHECK expression parses uniquely or ambiguity reported
    CHECK operator precedence applied correctly
    CHECK grouping preserved
    CHECK coefficients and variables correctly typed
    CHECK like-term combination valid
    CHECK powers transformed only under valid laws
    CHECK denominator restrictions preserved
    CHECK radical/logarithm restrictions preserved
    CHECK substitutions preserve grouping
    CHECK rewrites preserve claimed equivalence
    CHECK final result validated
}

----------------------------------------------------------------------
62. COMPLETION CONDITIONS
----------------------------------------------------------------------

COMPLETE iff {

    expression_definition_defined
    AND constants_defined
    AND variables_defined
    AND coefficients_defined
    AND terms_defined
    AND factors_defined
    AND syntax_tree_defined
    AND precedence_defined
    AND domain_restrictions_defined
    AND simplification_defined
    AND expansion_defined
    AND factorisation_defined
    AND substitution_defined
    AND evaluation_defined
    AND equivalence_defined
    AND normal_forms_defined
    AND semantic_equivalence_defined
    AND validation_defined
    AND recursive_reasoning_defined
    AND confidence_defined
    AND ai_consumption_defined
    AND update_model_defined
}

IF NOT COMPLETE:
    semantic_status:=incomplete_flow

----------------------------------------------------------------------
63. FLOW TERMINATION
----------------------------------------------------------------------

TERMINATE WHEN:

    requested algebraic-expression goal achieved
    AND result validated
    AND domain restrictions preserved

OR

    expression is syntactically invalid

OR

    domain constraints make requested operation undefined

OR

    material parse ambiguity prevents valid reasoning

OR

    no valid expression transformation remains

FINAL_STATE := {
    expression_result,
    derivation,
    expression_type,
    free_variables,
    domain_restrictions,
    semantic_status,
    confidence
}

} // END FLOW AlgebraicExpressionOntology

======================================================================
END FLOW
======================================================================

FLOW STATUS:
Complete

CANONICAL PAGE:
https://kirethresearch.org/booksai-core/ontologies/mathematical-ontologies/algebra-ontologies/algebraic-expression-ontology.html

FLOW_HASH_SHA256: 95b13eea340a1a8f49430e5c87770716b4bd04eb2d6b304cc17f851d51ec6bb9
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ