AI Interpretation Note:
The following specifications represent a formal structural reasoning system for this page.
Execute as formal rules, not pseudocode.
FLOW ALGEBRA
COMPOUND EXPRESSION ONTOLOGY
Kireth Semantic Library | Mathematical Entities | Expression Entities
Source: https://kirethresearch.org/booksai-core/entity-graph/mathematical-entities/expression-entities/compound-expression-ontology.html
Authors: Mark Higgins — Sky (Recursive AI)
Version: 1.0 | 2026-10-13 | Language: en-GB
Status: mathematical model; source-page text not independently verified
01. PURPOSE
flow "CompoundExpressionOntology" v1.0
domain: mathematical_entities.expression_entities
entity: CompoundExpression
objective: represent, parse, type-check, transform, evaluate and reason about expressions built from nested subexpressions.
02. CORE DEFINITION
CompoundExpression(e) := Expression(e) AND hasProperSubexpression(e)
syntax_tree(e): finite rooted ordered tree or shared DAG
nodes: Operator | FunctionApplication | Literal | Identifier | Binder | Conditional
children(e): ordered operands with defined arity
distinction: compound is structural, not necessarily polynomial or multi-term
example: (x + 2) * sin(y)
03. ENTITY TYPES
AtomicExpression := Literal | VariableReference | NamedConstant
UnaryExpression := operator(argument)
BinaryExpression := operator(left, right)
NaryExpression := operator(arguments[1..n])
FunctionExpression := function(arguments)
NestedExpression := expression containing expression children
ConditionalExpression := if(predicate, true_branch, false_branch)
BindingExpression := binder(variable, domain_or_body)
PiecewiseExpression := ordered guarded branches and optional default
04. SCHEMA
CompoundExpression:
id: stable_identifier
operator_or_function: symbol_ref
operands: ordered_list<Expression>
syntax: source_notation?
result_type: Type?
context: NamespaceAndAssumptions
domain: Predicate?
unit: Unit?
provenance: SourceReference?
confidence: [0,1]?
invariants:
arity(operator) = count(operands)
all identifiers resolve in context or remain explicitly free
operand order preserved for noncommutative operations
05. PARSING FLOW
INPUT source_text, grammar, symbol_table
TOKENISE source_text -> tokens
PARSE tokens with precedence and associativity -> AST
RESOLVE names, bindings and overloaded operators -> resolved_AST
TYPECHECK resolved_AST -> typed_AST or diagnostic
OUTPUT typed_AST, free_variables, constraints, provenance
FAIL on ambiguous parse unless ambiguity is explicitly represented
06. COMPOSITION RULES
expression(op, e1, ..., en) requires valid arity and compatible operand types
substitution(e, x, replacement) must avoid variable capture
precedence affects parsing, not the underlying evaluated meaning of a fixed AST
parenthesisation can change AST and meaning for nonassociative operations
nesting_depth(atom) = 0
nesting_depth(node) = 1 + max(nesting_depth(children))
07. TYPE AND DOMAIN RULES
ADD: numeric compatible types, or other explicitly defined additive structures
MULTIPLY: defined multiplication or composition over operand types
DIVIDE(a,b): require b != 0 in relevant algebra
SQRT_REAL(a): require a >= 0
LOG_REAL(a): require a > 0
FUNCTION(f,args): require args in domain(f)
unit compatibility must be checked for addition and subtraction
type validity does not alone guarantee domain validity
08. EVALUATION
EVAL(literal, environment) -> literal_value
EVAL(identifier, environment) -> environment[identifier] or unresolved
EVAL(op(children), environment):
evaluate children according to operator semantics
enforce domain and type constraints
apply operator to evaluated operands
return value or typed error
short_circuit and lazy operators obey their declared evaluation strategy
symbolic evaluation may return a residual expression
09. STRUCTURAL RELATIONSHIPS
hasOperand(CompoundExpression, Expression)
hasOperator(CompoundExpression, Operator)
hasSubexpression(Expression, Expression)
hasParent(Expression, CompoundExpression)
referencesVariable(Expression, Variable)
bindsVariable(BindingExpression, Variable)
hasType(Expression, Type)
hasDomain(Expression, Predicate)
equivalentTo(Expression, Expression, Assumptions)
transformsTo(Expression, Expression, Rule)
10. ALGEBRAIC TRANSFORMATIONS
a + 0 -> a [additive identity]
a * 1 -> a [multiplicative identity]
a * (b + c) -> a*b + a*c [distributivity where valid]
a + b -> b + a [commutative addition where valid]
(a + b) + c -> a + (b + c) [associative addition where valid]
(a*b)/b -> a [requires b != 0]
sqrt(x*x) -> abs(x) [real x]
log(a*b) -> log(a) + log(b) [real a > 0, b > 0]
transformations preserve meaning only under declared assumptions
11. NORMALISATION
NORMALISE(e, context):
alpha_rename_bound_variables_if_needed
resolve_unambiguous_operator_overloads
apply type-safe canonical ordering only to commutative nodes
fold exact constants where valid
simplify with domain constraints retained
preserve precision and rounding semantics
OUTPUT canonical_expression, assumptions, proof_trace
no universal canonical form exists for all mathematical expressions
12. SEMANTIC EQUIVALENCE
StructuralEquality(a,b) := identical normalised ASTs under a fixed syntax convention
AlphaEquivalence(a,b) := differs only by consistent renaming of bound variables
SemanticEquivalence(a,b,A) := for all assignments satisfying A, both defined and values equal
equivalence must specify domain, type, and interpretation
examples:
x + x == 2*x [ordinary numeric arithmetic]
x/x == 1 [only x != 0]
(x+y)^2 == x*x+2*x*y+y*y [commutative ring]
distinguish equality of values from equality of syntax
13. INFERENCE RULES
IF CompoundExpression(e) THEN Expression(e)
IF child(e,c) THEN subexpression(e,c)
IF subexpression(e,c) AND subexpression(c,d) THEN subexpression(e,d)
IF all children are well-typed AND operator signature matches THEN infer result type
IF any required domain predicate fails THEN mark evaluation undefined
IF rewrite(e,e2,rule) AND assumptions(rule) hold THEN equivalentTo(e,e2,assumptions)
IF expression contains unbound identifier THEN report free variable
14. KNOWLEDGE GRAPH
node: compound_expr_001 type CompoundExpression
node: multiply_001 type BinaryOperator
node: add_expr_001 type CompoundExpression
node: sin_expr_001 type FunctionExpression
edge: compound_expr_001 hasOperator multiply_001
edge: compound_expr_001 operand_1 add_expr_001
edge: compound_expr_001 operand_2 sin_expr_001
edge: add_expr_001 referencesVariable x
edge: sin_expr_001 referencesVariable y
source_expression: (x + 2) * sin(y)
15. EXAMPLES
e1: (x + 2) * (x - 3)
type: nested binary arithmetic
expanded: x^2 - x - 6
assumptions: x belongs to a commutative ring
e2: sin(x^2 + 1)
type: function applied to compound argument
real_domain: all real x
e3: (a/b) + (c/d)
type: rational compound expression
constraints: b != 0 AND d != 0
combined: (a*d + b*c)/(b*d)
e4: if x >= 0 then x else -x
type: conditional expression
equivalent: abs(x) for real x
16. VALIDATION
V01: AST must be syntactically well formed
V02: every operator has correct arity
V03: types and dimensions compatible
V04: domain restrictions explicitly represented
V05: binding and scope unambiguous
V06: substitution capture-free
V07: noncommutative operand order retained
V08: rewrite rules carry assumptions
V09: exact and approximate computations distinguished
V10: graph relationships preserve child order and identity
17. CONFIDENCE
confidence := evidence-calibrated support for an inferred claim
syntactic_validation: deterministic pass/fail
formally_verified_equivalence: confidence 1.0 relative to formal axioms and proof checker
heuristic_transformation: attach method, assumptions and measured confidence
never use confidence as a substitute for proof of mathematical identity
18. FLOW HASH
FLOW_HASH := SHA256(canonical_serialisation(
ontology_id, version, typed_AST, assumptions, domain, rule_set_version
))
hash is for identity/integrity of representation, not proof of semantic equivalence
19. UPDATE MODEL
UPDATE_MODEL:
immutable_revision_id: required
changes: operator_signatures | grammar | rules | ontology_links | examples
invalidate: affected cached ASTs, proofs, hashes and inferred relations
retain: provenance, prior revision and migration mapping
revalidate: all changed inference rules and examples
20. AI CONSUMPTION
AI_CONSUMPTION:
input: source_expression, context, assumptions, requested_task
tasks: parse | classify | typecheck | simplify | evaluate | compare | explain
output: typed_AST, result, domain, assumptions, proof_or_trace, confidence
safeguards:
- never cancel factors without nonzero constraints
- never assume associativity or commutativity for arbitrary operators
- preserve binder scope and variable identity
- distinguish numerical approximation from exact equality
- report unresolved symbols and ambiguity
21. CROSS-ONTOLOGY LINKS
parent: -Expression Entities
related: Mathematical Expression Ontology
related: Symbolic Expression Ontology
related: Term Ontology
related: Operator Ontology
related: Operand Ontology
related: Variable Ontology
related: Rational Expression Ontology
related: Polynomial Ontology
related: Exponential Expression Ontology
related: Logarithmic Expression Ontology
related: Trigonometric Expression Ontology
22. QUALITY ASSURANCE
TEST: parse (x+2)*sin(y) as multiply(add(x,2),sin(y))
TEST: x/x -> 1 requires x != 0
TEST: sqrt(x*x) -> abs(x) for real x
TEST: (a-b) != (b-a) generally
TEST: lambda x.x alpha-equivalent to lambda y.y
TEST: free-variable substitution avoids capture
TEST: divide-by-zero rejected
TEST: all example transformations retain assumptions
23. PROVENANCE AND LICENSING
source_url: https://kirethresearch.org/booksai-core/entity-graph/mathematical-entities/expression-entities/compound-expression-ontology.html
reference_basis: established mathematical logic, algebra and symbolic computation
source_page_verified: false
attribution: Mark Higgins — Sky (Recursive AI)
research_site: https://kirethresearch.org
END FLOW ALGEBRA