Skip to main content

Matrix Ontology

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

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

FLOW:
MatrixOntology

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 matrices, matrix structure, operations,
row reduction, determinants, inverses, rank, systems of equations,
matrix transformations, special matrix classes, decompositions,
spectral properties and validation rules.

AI INTERPRETATION NOTE:
Execute the following specification as formal semantic and reasoning
rules. Preserve dimensions, scalar fields, index ranges, operation
preconditions, structural invariants and equivalence conditions.

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

FLOW MatrixOntology {

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

DOMAIN := Matrix_Theory

PARENT_DOMAIN := Algebra

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

DOMAIN_INTENT := {
    represent_matrices,
    represent_entries,
    represent_rows_and_columns,
    represent_matrix_shapes,
    represent_matrix_operations,
    represent_transpose,
    represent_conjugate_transpose,
    represent_special_matrices,
    represent_row_operations,
    represent_echelon_forms,
    represent_determinants,
    represent_inverses,
    represent_rank,
    represent_nullity,
    represent_matrix_equations,
    represent_linear_systems,
    represent_eigenstructure,
    represent_decompositions,
    support_dimension_aware_reasoning,
    support_recursive_matrix_validation
}

DEFAULT_SCALAR_FIELD := RealNumber | ComplexNumber

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

TYPE Scalar
TYPE RealNumber <: Scalar
TYPE ComplexNumber <: Scalar
TYPE Index
TYPE Dimension
TYPE Matrix
TYPE SquareMatrix <: Matrix
TYPE RowMatrix <: Matrix
TYPE ColumnMatrix <: Matrix
TYPE ZeroMatrix <: Matrix
TYPE IdentityMatrix <: SquareMatrix
TYPE DiagonalMatrix <: SquareMatrix
TYPE ScalarMatrix <: DiagonalMatrix
TYPE TriangularMatrix <: SquareMatrix
TYPE UpperTriangularMatrix <: TriangularMatrix
TYPE LowerTriangularMatrix <: TriangularMatrix
TYPE SymmetricMatrix <: SquareMatrix
TYPE SkewSymmetricMatrix <: SquareMatrix
TYPE HermitianMatrix <: SquareMatrix
TYPE SkewHermitianMatrix <: SquareMatrix
TYPE OrthogonalMatrix <: SquareMatrix
TYPE UnitaryMatrix <: SquareMatrix
TYPE InvertibleMatrix <: SquareMatrix
TYPE SingularMatrix <: SquareMatrix
TYPE PermutationMatrix <: SquareMatrix
TYPE ElementaryMatrix <: SquareMatrix
TYPE SparseMatrix <: Matrix
TYPE DenseMatrix <: Matrix
TYPE Determinant
TYPE Trace
TYPE Rank
TYPE Nullity
TYPE Eigenvalue
TYPE Eigenvector
TYPE Derivation
TYPE Constraint
TYPE ValidationResult

----------------------------------------------------------------------
3. MATRIX ENTITY
----------------------------------------------------------------------

ENTITY Matrix A {
    rows: m
    columns: n
    scalar_field: F
    entries: a_ij
    shape: m x n
}

INVARIANT MAT_01:
    m,n are positive integers unless empty-matrix convention declared.

INVARIANT MAT_02:
    valid indices satisfy:
        1 <= i <= m
        1 <= j <= n

FUNCTION ENTRY(A,i,j):
    REQUIRE valid_index(A,i,j)
    RETURN a_ij

FUNCTION ROW(A,i):
    RETURN [a_i1,...,a_in]

FUNCTION COLUMN(A,j):
    RETURN [a_1j,...,a_mj]^T

----------------------------------------------------------------------
4. MATRIX EQUALITY
----------------------------------------------------------------------

MATRIX_EQUAL(A,B) iff
    shape(A)=shape(B)
    AND forall i,j:
        A[i,j]=B[i,j]

RULE EQ_01:
    matrices of different shape are not equal.

----------------------------------------------------------------------
5. MATRIX ADDITION
----------------------------------------------------------------------

MATRIX_ADD(A,B):

    REQUIRE:
        shape(A)=shape(B)

    DEFINE:
        C[i,j]=A[i,j]+B[i,j]

    RETURN C

RULE ADD_01:
    A+B=B+A

RULE ADD_02:
    (A+B)+C=A+(B+C)

RULE ADD_03:
    A+0=A

RULE ADD_04:
    A+(-A)=0

----------------------------------------------------------------------
6. SCALAR MULTIPLICATION
----------------------------------------------------------------------

SCALAR_MULTIPLY(c,A):

    DEFINE:
        (cA)[i,j]=c*A[i,j]

RULE SCAL_01:
    c(A+B)=cA+cB

RULE SCAL_02:
    (c+d)A=cA+dA

RULE SCAL_03:
    c(dA)=(cd)A

RULE SCAL_04:
    1A=A

----------------------------------------------------------------------
7. MATRIX MULTIPLICATION
----------------------------------------------------------------------

MATRIX_MULTIPLY(A,B):

    REQUIRE:
        columns(A)=rows(B)

    OUTPUT_SHAPE:
        rows(A) x columns(B)

    DEFINE:
        C[i,j]=SUM_k A[i,k]*B[k,j]

RULE MUL_01:
    A(BC)=(AB)C

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

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

RULE MUL_04:
    generally AB != BA

RULE MUL_05:
    if AB and BA are both defined,
    they may have different values.

----------------------------------------------------------------------
8. ZERO MATRIX
----------------------------------------------------------------------

ZERO_MATRIX(m,n):
    O[i,j]=0

RULE ZERO_01:
    A+O=A

RULE ZERO_02:
    compatible A*O=O

RULE ZERO_03:
    compatible O*A=O

----------------------------------------------------------------------
9. IDENTITY MATRIX
----------------------------------------------------------------------

IDENTITY_MATRIX(n):

    I[i,j]=1 if i=j
    I[i,j]=0 if i!=j

RULE ID_01:
    I_m*A=A for A shape m x n

RULE ID_02:
    A*I_n=A for A shape m x n

RULE ID_03:
    identity matrix unique for each square dimension.

----------------------------------------------------------------------
10. POWERS OF MATRICES
----------------------------------------------------------------------

MATRIX_POWER(A,k):

    REQUIRE:
        A square
        k nonnegative_integer

    BASE:
        A^0=I

    RECURSIVE:
        A^(k+1)=A^k*A

RULE POW_01:
    A^m*A^n=A^(m+n)

RULE POW_02:
    (A^m)^n=A^(mn)

RULE POW_03:
    (AB)^n != A^n B^n in general.

----------------------------------------------------------------------
11. TRANSPOSE
----------------------------------------------------------------------

TRANSPOSE(A):

    DEFINE:
        A^T[j,i]=A[i,j]

RULE TRANS_01:
    (A^T)^T=A

RULE TRANS_02:
    (A+B)^T=A^T+B^T

RULE TRANS_03:
    (cA)^T=cA^T

RULE TRANS_04:
    (AB)^T=B^T A^T

----------------------------------------------------------------------
12. CONJUGATE TRANSPOSE
----------------------------------------------------------------------

CONJUGATE_TRANSPOSE(A):

    DEFINE:
        A*[j,i]=conjugate(A[i,j])

RULE CTRANS_01:
    (A*)*=A

RULE CTRANS_02:
    (A+B)*=A*+B*

RULE CTRANS_03:
    (AB)*=B* A*

----------------------------------------------------------------------
13. DIAGONAL MATRICES
----------------------------------------------------------------------

IS_DIAGONAL(A) iff
    square(A)
    AND forall i!=j:
        A[i,j]=0

RULE DIAG_01:
    product of diagonal matrices is diagonal.

RULE DIAG_02:
    diagonal matrices commute with each other.

RULE DIAG_03:
    determinant(diagonal A)=product diagonal entries.

----------------------------------------------------------------------
14. SCALAR MATRICES
----------------------------------------------------------------------

IS_SCALAR_MATRIX(A) iff
    exists c:
        A=cI

RULE SCMAT_01:
    scalar matrices commute with every compatible square matrix.

----------------------------------------------------------------------
15. TRIANGULAR MATRICES
----------------------------------------------------------------------

IS_UPPER_TRIANGULAR(A) iff
    square(A)
    AND forall i>j:
        A[i,j]=0

IS_LOWER_TRIANGULAR(A) iff
    square(A)
    AND forall i<j:
        A[i,j]=0

RULE TRI_01:
    product of upper triangular matrices is upper triangular.

RULE TRI_02:
    product of lower triangular matrices is lower triangular.

RULE TRI_03:
    determinant(triangular A)=product diagonal entries.

----------------------------------------------------------------------
16. SYMMETRIC AND SKEW-SYMMETRIC MATRICES
----------------------------------------------------------------------

IS_SYMMETRIC(A) iff
    square(A)
    AND A^T=A

IS_SKEW_SYMMETRIC(A) iff
    square(A)
    AND A^T=-A

RULE SYM_01:
    diagonal entries of skew-symmetric matrix are zero
    over fields with characteristic !=2.

----------------------------------------------------------------------
17. HERMITIAN AND SKEW-HERMITIAN
----------------------------------------------------------------------

IS_HERMITIAN(A) iff
    square(A)
    AND A*=A

IS_SKEW_HERMITIAN(A) iff
    square(A)
    AND A*=-A

RULE HERM_01:
    Hermitian matrices have real diagonal entries.

RULE HERM_02:
    eigenvalues of Hermitian matrices are real.

----------------------------------------------------------------------
18. ORTHOGONAL AND UNITARY MATRICES
----------------------------------------------------------------------

IS_ORTHOGONAL(A) iff
    A^T A=I

IS_UNITARY(A) iff
    A* A=I

RULE ORTH_01:
    orthogonal A -> A^(-1)=A^T

RULE UNIT_01:
    unitary A -> A^(-1)=A*

RULE ORTH_02:
    orthogonal transformations preserve Euclidean norm.

RULE UNIT_02:
    unitary transformations preserve inner products.

----------------------------------------------------------------------
19. ELEMENTARY ROW OPERATIONS
----------------------------------------------------------------------

ROW_OP_1:
    swap row_i,row_j

ROW_OP_2:
    row_i <- c row_i
    REQUIRE c!=0

ROW_OP_3:
    row_i <- row_i+c row_j
    REQUIRE i!=j

RULE ROW_01:
    elementary row operations are reversible.

RULE ROW_02:
    row operations preserve solution set of associated system.

----------------------------------------------------------------------
20. ELEMENTARY MATRICES
----------------------------------------------------------------------

ELEMENTARY_MATRIX(E):
    E obtained from I by exactly one elementary row operation.

RULE ELEM_01:
    applying row operation to A
    equals left multiplication E*A.

RULE ELEM_02:
    every elementary matrix is invertible.

RULE ELEM_03:
    inverse of elementary matrix is elementary.

----------------------------------------------------------------------
21. ROW ECHELON FORM
----------------------------------------------------------------------

IS_REF(A) iff
    all zero rows below nonzero rows
    AND each leading entry occurs right of one above
    AND entries below pivots are zero

----------------------------------------------------------------------
22. REDUCED ROW ECHELON FORM
----------------------------------------------------------------------

IS_RREF(A) iff
    IS_REF(A)
    AND each pivot=1
    AND pivot is only nonzero entry in its column

THEOREM RREF_UNIQUENESS:
    every matrix is row-equivalent to exactly one RREF.

PROCEDURE TO_RREF(A):

    locate pivot
    swap row if necessary
    scale pivot row
    eliminate pivot column
    recurse on remaining submatrix

    RETURN RREF(A)

----------------------------------------------------------------------
23. ROW EQUIVALENCE
----------------------------------------------------------------------

ROW_EQUIVALENT(A,B) iff
    B obtainable from A by finite elementary row operations

RULE REQ_01:
    row equivalence is an equivalence relation.

RULE REQ_02:
    row-equivalent matrices have equal row space and rank.

----------------------------------------------------------------------
24. RANK
----------------------------------------------------------------------

RANK(A) :=
    number_of_pivots(RREF(A))

EQUIVALENT:
    rank(A)=dimension(column_space(A))
    rank(A)=dimension(row_space(A))

RULE RANK_01:
    rank(A)<=min(rows(A),columns(A))

RULE RANK_02:
    rank(A)=rank(A^T)

RULE RANK_03:
    rank(AB)<=min(rank(A),rank(B))

RULE RANK_04:
    square A invertible iff rank(A)=n.

----------------------------------------------------------------------
25. NULLITY
----------------------------------------------------------------------

NULL_SPACE(A):={x | A*x=0}

NULLITY(A):=dimension(NULL_SPACE(A))

THEOREM RANK_NULLITY:
    rank(A)+nullity(A)=number_of_columns(A)

----------------------------------------------------------------------
26. DETERMINANT
----------------------------------------------------------------------

DETERMINANT(A):

    REQUIRE:
        square(A)

BASE:
    det([a])=a

FOR 2x2:
    det([[a,b],[c,d]])=ad-bc

RECURSIVE:
    det(A)
    =
    SUM_j (-1)^(i+j) a_ij det(M_ij)

RULE DET_01:
    det(I)=1

RULE DET_02:
    det(AB)=det(A)det(B)

RULE DET_03:
    det(A^T)=det(A)

RULE DET_04:
    row swap multiplies determinant by -1

RULE DET_05:
    scaling one row by c scales determinant by c

RULE DET_06:
    adding multiple of one row to another leaves determinant unchanged

RULE DET_07:
    A invertible iff det(A)!=0

----------------------------------------------------------------------
27. MINORS AND COFACTORS
----------------------------------------------------------------------

MINOR_MATRIX(A,i,j):
    delete row i and column j

MINOR(A,i,j):
    det(MINOR_MATRIX(A,i,j))

COFACTOR(A,i,j):
    (-1)^(i+j)*MINOR(A,i,j)

COFACTOR_MATRIX(A):
    C[i,j]=COFACTOR(A,i,j)

ADJUGATE(A):
    transpose(COFACTOR_MATRIX(A))

----------------------------------------------------------------------
28. MATRIX INVERSE
----------------------------------------------------------------------

INVERTIBLE(A) iff
    exists B:
        AB=BA=I

DEFINE:
    B=A^(-1)

RULE INV_01:
    inverse unique.

RULE INV_02:
    (A^(-1))^(-1)=A

RULE INV_03:
    (AB)^(-1)=B^(-1)A^(-1)

RULE INV_04:
    (A^T)^(-1)=(A^(-1))^T

RULE INV_05:
    A invertible iff det(A)!=0

PROCEDURE INVERSE_BY_RREF(A):

    REQUIRE square(A)

    form [A|I]

    reduce to RREF

    if left block=I:
        RETURN right block

    else:
        RETURN singular

PROCEDURE INVERSE_BY_ADJUGATE(A):

    REQUIRE det(A)!=0

    RETURN adj(A)/det(A)

----------------------------------------------------------------------
29. TRACE
----------------------------------------------------------------------

TRACE(A):
    REQUIRE square(A)
    RETURN SUM_i A[i,i]

RULE TR_01:
    tr(A+B)=tr(A)+tr(B)

RULE TR_02:
    tr(cA)=c tr(A)

RULE TR_03:
    tr(AB)=tr(BA)

RULE TR_04:
    similar matrices have equal trace.

----------------------------------------------------------------------
30. MATRIX EQUATIONS
----------------------------------------------------------------------

PROCEDURE SOLVE_AX_EQUALS_B(A,B):

    if A invertible:
        X=A^(-1)B

    otherwise:
        reduce corresponding system
        and determine consistency

PROCEDURE SOLVE_XA_EQUALS_B(A,B):

    if A invertible:
        X=B A^(-1)

    otherwise:
        use structural solving method

RULE MEQ_01:
    multiplication order must be preserved.

----------------------------------------------------------------------
31. LINEAR SYSTEM REPRESENTATION
----------------------------------------------------------------------

LINEAR_SYSTEM:
    A*x=b

A := coefficient_matrix
x := unknown_column_vector
b := constant_column_vector

PROCEDURE SOLVE_SYSTEM(A,b):

    form [A|b]

    compute RREF

    detect contradiction row

    identify pivots

    identify free variables

    parameterise solution

    validate A*x=b

    RETURN solution_set

----------------------------------------------------------------------
32. CONSISTENCY
----------------------------------------------------------------------

SYSTEM_CONSISTENT(A,b) iff
    rank(A)=rank([A|b])

UNIQUE_SOLUTION iff
    rank(A)=rank([A|b])=number_of_unknowns

INFINITE_SOLUTIONS iff
    rank(A)=rank([A|b])<number_of_unknowns

NO_SOLUTION iff
    rank(A)<rank([A|b])

----------------------------------------------------------------------
33. EIGENVALUES
----------------------------------------------------------------------

EIGENVALUE(lambda,A) iff
    exists v!=0:
        A*v=lambda*v

CHARACTERISTIC_POLYNOMIAL(A):
    p_A(lambda)=det(A-lambda I)

RULE EIG_01:
    lambda eigenvalue iff p_A(lambda)=0.

----------------------------------------------------------------------
34. EIGENVECTORS
----------------------------------------------------------------------

EIGENVECTOR(v,lambda,A) iff
    v!=0
    AND (A-lambda I)v=0

EIGENSPACE(A,lambda):
    null_space(A-lambda I)

RULE EIGV_01:
    eigenspace is a vector subspace.

----------------------------------------------------------------------
35. DIAGONALISATION
----------------------------------------------------------------------

DIAGONALISABLE(A) iff
    exists invertible P
    and diagonal D:
        A=PDP^(-1)

RULE DIA_01:
    n x n A diagonalizable iff it has n linearly independent eigenvectors.

PROCEDURE DIAGONALISE(A):

    compute eigenvalues

    compute eigenvectors

    if n independent eigenvectors:
        P:=columns(eigenvectors)
        D:=diag(corresponding eigenvalues)
        validate A=PDP^(-1)
        RETURN P,D

    else:
        RETURN not_diagonalizable

----------------------------------------------------------------------
36. SIMILARITY
----------------------------------------------------------------------

SIMILAR(A,B) iff
    exists invertible P:
        B=P^(-1)AP

RULE SIM_01:
    similarity is equivalence relation.

RULE SIM_02:
    similar matrices have same:
        characteristic polynomial,
        determinant,
        trace,
        eigenvalues,
        rank.

----------------------------------------------------------------------
37. CHARACTERISTIC POLYNOMIAL
----------------------------------------------------------------------

CHAR_POLY(A,t):
    det(tI-A)
    OR declared equivalent convention det(A-tI)

INVARIANT:
    convention must remain consistent during derivation.

----------------------------------------------------------------------
38. CAYLEY-HAMILTON
----------------------------------------------------------------------

THEOREM CAYLEY_HAMILTON:
    every square matrix satisfies its own characteristic polynomial.

IF:
    p_A(t)=c0+c1 t+...+cn t^n

THEN:
    p_A(A)=c0 I+c1 A+...+cn A^n=0

----------------------------------------------------------------------
39. MINIMAL POLYNOMIAL
----------------------------------------------------------------------

MINIMAL_POLYNOMIAL(A):
    unique monic polynomial m_A of least positive degree
    such that:
        m_A(A)=0

RULE MIN_01:
    m_A divides p_A.

RULE MIN_02:
    A diagonalizable over splitting field
    iff minimal polynomial splits into distinct linear factors.

----------------------------------------------------------------------
40. LU DECOMPOSITION
----------------------------------------------------------------------

LU_DECOMPOSITION(A):

    seek:
        A=L*U

where:
    L lower triangular
    U upper triangular

RULE LU_01:
    existence conditions depend on pivot structure or permutation.

WITH_PIVOTING:
    P*A=L*U

----------------------------------------------------------------------
41. QR DECOMPOSITION
----------------------------------------------------------------------

QR_DECOMPOSITION(A):

    seek:
        A=Q*R

where:
    Q has orthonormal columns
    R upper triangular

RULE QR_01:
    full-column-rank matrix admits standard QR decomposition.

----------------------------------------------------------------------
42. SVD
----------------------------------------------------------------------

SINGULAR_VALUE_DECOMPOSITION(A):

    A=U*Sigma*V*

where:
    U unitary/orthogonal
    V unitary/orthogonal
    Sigma diagonal rectangular with nonnegative singular values

RULE SVD_01:
    every finite real or complex matrix has an SVD.

RULE SVD_02:
    rank(A)=number_of_nonzero_singular_values.

----------------------------------------------------------------------
43. POSITIVE DEFINITE MATRICES
----------------------------------------------------------------------

IS_POSITIVE_DEFINITE(A) iff
    Hermitian_or_symmetric(A)
    AND forall x!=0:
        x* A x > 0

RULE PD_01:
    real symmetric positive definite A
    has all positive eigenvalues.

RULE PD_02:
    positive definite matrices are invertible.

----------------------------------------------------------------------
44. SPARSE AND DENSE MATRICES
----------------------------------------------------------------------

IS_SPARSE(A) iff
    zero_entry_fraction exceeds declared sparsity threshold

IS_DENSE(A) iff
    not_sparse under declared context

NOTE:
    sparse/dense classification is implementation/context dependent,
    not purely algebraic.

----------------------------------------------------------------------
45. BLOCK MATRICES
----------------------------------------------------------------------

ENTITY BlockMatrix A {
    entries:
        submatrices
}

BLOCK_OPERATION_RULE:
    block arithmetic valid when internal dimensions are compatible.

RULE BLOCK_01:
    block multiplication follows standard matrix multiplication pattern.

RULE BLOCK_02:
    block partitioning must be conformable.

----------------------------------------------------------------------
46. KRONECKER PRODUCT
----------------------------------------------------------------------

KRONECKER_PRODUCT(A,B):
    A ⊗ B
    :=
    block matrix [a_ij B]

OUTPUT_SHAPE:
    (rows(A)*rows(B))
    x
    (cols(A)*cols(B))

RULE KRON_01:
    (A⊗B)(C⊗D)=(AC)⊗(BD)
    when products are defined.

----------------------------------------------------------------------
47. HADAMARD PRODUCT
----------------------------------------------------------------------

HADAMARD_PRODUCT(A,B):

    REQUIRE:
        shape(A)=shape(B)

    DEFINE:
        (A∘B)[i,j]=A[i,j]B[i,j]

RULE HAD_01:
    Hadamard product is commutative.

RULE HAD_02:
    Hadamard product differs from matrix multiplication.

----------------------------------------------------------------------
48. PERMUTATION MATRICES
----------------------------------------------------------------------

IS_PERMUTATION_MATRIX(P) iff
    square(P)
    AND every row contains exactly one 1
    AND every column contains exactly one 1
    AND all other entries are 0

RULE PERM_01:
    permutation matrices are orthogonal.

RULE PERM_02:
    left multiplication permutes rows.

RULE PERM_03:
    right multiplication permutes columns.

----------------------------------------------------------------------
49. MATRIX NORMS
----------------------------------------------------------------------

FROBENIUS_NORM(A):
    sqrt(SUM_i,j |a_ij|^2)

RULE FN_01:
    ||A||_F >=0

RULE FN_02:
    ||A||_F=0 iff A=0

RULE FN_03:
    ||cA||_F=|c| ||A||_F

----------------------------------------------------------------------
50. SEMANTIC RELATIONSHIPS
----------------------------------------------------------------------

RELATION HAS_ENTRY(Matrix,Scalar)
RELATION HAS_ROW(Matrix,RowMatrix)
RELATION HAS_COLUMN(Matrix,ColumnMatrix)
RELATION HAS_SHAPE(Matrix,DimensionPair)
RELATION TRANSPOSE_OF(Matrix,Matrix)
RELATION INVERSE_OF(Matrix,Matrix)
RELATION SIMILAR_TO(Matrix,Matrix)
RELATION ROW_EQUIVALENT_TO(Matrix,Matrix)
RELATION HAS_RANK(Matrix,Rank)
RELATION HAS_DETERMINANT(SquareMatrix,Determinant)
RELATION HAS_TRACE(SquareMatrix,Trace)
RELATION HAS_EIGENVALUE(SquareMatrix,Eigenvalue)
RELATION HAS_EIGENVECTOR(SquareMatrix,Eigenvector)

----------------------------------------------------------------------
51. SEMANTIC EQUIVALENCE
----------------------------------------------------------------------

SEMANTIC_EQUIVALENCE {

    "matrix order" ~= matrix_dimensions
    "matrix size" ~= matrix_shape
    "row reduce" ~= apply_elementary_row_operations
    "Gaussian elimination" ~= forward_row_reduction
    "Gauss-Jordan elimination" ~= reduction_to_RREF
    "non-singular" ~= invertible
    "singular" ~= not_invertible
    "unit matrix" ~= identity_matrix
    "transpose" ~= interchange_rows_and_columns
    "adjoint" ~= context_dependent:
        conjugate_transpose OR adjugate
    "rank" ~= pivot_count ~= dimension_of_column_space
    "nullity" ~= dimension_of_null_space
    "characteristic equation" ~= det(A-lambda I)=0
}

----------------------------------------------------------------------
52. QUERY INTERPRETATION
----------------------------------------------------------------------

QUERY Q1:
    "add A and B"
    -> MATRIX_ADD(A,B)

QUERY Q2:
    "multiply A and B"
    -> MATRIX_MULTIPLY(A,B)

QUERY Q3:
    "transpose A"
    -> TRANSPOSE(A)

QUERY Q4:
    "inverse of A"
    -> INVERSE_BY_RREF(A) or validated equivalent method

QUERY Q5:
    "determinant of A"
    -> DETERMINANT(A)

QUERY Q6:
    "rank of A"
    -> RANK(A)

QUERY Q7:
    "solve Ax=b"
    -> SOLVE_SYSTEM(A,b)

QUERY Q8:
    "eigenvalues"
    -> solve characteristic polynomial

QUERY Q9:
    "diagonalise A"
    -> DIAGONALISE(A)

----------------------------------------------------------------------
53. VALIDATION ENGINE
----------------------------------------------------------------------

PROCEDURE VALIDATE_MATRIX_OPERATION(operation,inputs,result):

    check scalar fields

    check dimensions

    check required square conditions

    check index ranges

    independently recompute key invariants where feasible

    verify result shape

    verify defining relation

    return:
        VALID
        INVALID(reason)
        UNRESOLVED

----------------------------------------------------------------------
54. RECURSIVE REASONING ENGINE
----------------------------------------------------------------------

PROCEDURE MATRIX_REASONER(input):

    parse matrices

    infer/verify dimensions

    infer scalar field

    classify requested operation

    extract constraints

    select valid matrix rules

    execute atomic transformations

    preserve multiplication order

    preserve dimensions

    validate intermediate states

    recurse until target achieved

    validate final result

    RETURN:
        result,
        derivation,
        dimension_constraints,
        semantic_status,
        confidence

----------------------------------------------------------------------
55. RECURSIVE TRANSITION
----------------------------------------------------------------------

RECURSIVE_RULE RR_01:

    INPUT state S_n

    identify unresolved matrix structure

    choose rule R with satisfied dimensional preconditions

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

    validate dimensions and invariant preservation

    recurse(S_(n+1))

TERMINATION_CONDITIONS := {
    target_matrix_found,
    canonical_form_found,
    contradiction_detected,
    dimensional_failure,
    singularity_blocks_operation,
    no_valid_rule
}

----------------------------------------------------------------------
56. ERROR MODEL
----------------------------------------------------------------------

ERROR E_DIMENSION_MISMATCH
ERROR E_INVALID_INDEX
ERROR E_NONSQUARE_DETERMINANT
ERROR E_NONSQUARE_INVERSE
ERROR E_SINGULAR_MATRIX
ERROR E_INVALID_PRODUCT
ERROR E_INVALID_ROW_OPERATION
ERROR E_EIGENVECTOR_ZERO
ERROR E_DIAGONALISATION_FAILURE
ERROR E_FIELD_MISMATCH
ERROR E_BLOCK_NONCONFORMABLE
ERROR E_LOST_MULTIPLICATION_ORDER

----------------------------------------------------------------------
57. CONFIDENCE MODEL
----------------------------------------------------------------------

CONFIDENCE {

    base:=1.00

    deduct 0.10 if dimensions inferred
    deduct 0.10 if scalar field inferred
    deduct 0.15 if determinant/inverse validation incomplete
    deduct 0.15 if eigenstructure numerically approximated
    deduct 0.20 if decomposition conditions unresolved
    deduct 0.25 if operation precondition ambiguous

    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
}

----------------------------------------------------------------------
58. AI CONSUMPTION MODEL
----------------------------------------------------------------------

AI_CONSUMPTION {

    read_order := [
        matrix_structure,
        dimensions,
        basic_operations,
        special_matrices,
        row_operations,
        echelon_forms,
        determinant,
        inverse,
        rank,
        systems,
        eigenstructure,
        decompositions,
        validation
    ]

    execution_policy := {
        preserve_dimensions,
        preserve_scalar_field,
        preserve_multiplication_order,
        distinguish_entrywise_from_matrix_product,
        require_square_when_needed,
        validate_inverse,
        validate_eigenpairs,
        distinguish_transpose_from_conjugate_transpose,
        distinguish_adjugate_from_adjoint_when_ambiguous
    }
}

----------------------------------------------------------------------
59. UPDATE MODEL
----------------------------------------------------------------------

UPDATE_MODEL {

    extensible:=true

    new_matrix_class_requires:
        defining_predicate,
        inherited_constraints

    new_operation_requires:
        input_shapes,
        output_shape,
        algebraic_definition

    new_decomposition_requires:
        existence_conditions,
        factor_constraints,
        validation_identity

    conflict_policy:
        explicit_versioning

    standard_linear_algebra_meaning_has_priority:=true
}

----------------------------------------------------------------------
60. SELF-CHECK
----------------------------------------------------------------------

SELF_CHECK {

    CHECK every matrix has valid shape
    CHECK every referenced index valid
    CHECK additions use equal shapes
    CHECK multiplications use conformable dimensions
    CHECK determinant only applied to square matrices
    CHECK inverse only returned for invertible matrices
    CHECK row operations are legal
    CHECK RREF satisfies canonical conditions
    CHECK eigenvectors are nonzero
    CHECK diagonalisation identity verified
    CHECK decomposition products reconstruct original matrix
    CHECK final result validated
}

----------------------------------------------------------------------
61. COMPLETION CONDITIONS
----------------------------------------------------------------------

COMPLETE iff {

    matrix_structure_defined
    AND addition_defined
    AND scalar_multiplication_defined
    AND matrix_multiplication_defined
    AND transpose_defined
    AND special_matrices_defined
    AND row_operations_defined
    AND RREF_defined
    AND determinant_defined
    AND inverse_defined
    AND rank_defined
    AND nullity_defined
    AND systems_defined
    AND eigenstructure_defined
    AND similarity_defined
    AND decompositions_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

----------------------------------------------------------------------
62. FLOW TERMINATION
----------------------------------------------------------------------

TERMINATE WHEN:

    requested matrix goal achieved
    AND result validated

OR

    dimensional incompatibility makes operation undefined

OR

    singularity prevents requested inverse/solution method

OR

    structural preconditions fail

OR

    no valid matrix transformation remains

FINAL_STATE := {
    matrix_result,
    derivation,
    dimensions,
    structural_classification,
    semantic_status,
    confidence
}

} // END FLOW MatrixOntology

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

FLOW STATUS:
Complete

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

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