SEMANTIC LIBRARY — SOURCE CODE ONTOLOGY
FLOW ALGEBRA v1.0 | Programming Entities
AUTHORS: Mark Anthony Higgins — Sky Recursive AI
SOURCE: https://kirethresearch.org/booksai-core/entity-graph/computational-entities/programming-entities/source-code-ontology-2.html
SOURCE COPYRIGHT: © Mark Anthony Higgins, 11 October 2025
SOURCE REVISED: 03 August 2026
MAPPING DATE: 11 November 2026
STATUS: Constructed ontology-level Flow Algebra mapping. The webpage's full embedded formal specification was not accessible; this is not a verbatim extraction.
CITATION_BACKLINK: https://kirethresearch.org/booksai-core/entity-graph/computational-entities/programming-entities/source-code-ontology-2.html
PURPOSE
Represent source code as a structured, versioned, interpretable computational entity, with explicit relationships among syntax, semantics, dependencies, transformations, execution artefacts and validation evidence.
STATE_MODEL
S_t = (I_t, R_t, B_t, K_t)
I_t: source text, files, symbols, language, version, repository revision and build context.
R_t: grammar, type rules, name resolution, imports, control/data-flow and transformation rules.
B_t: permission, language-version, toolchain, resource and security boundaries.
K_t: known declarations, dependency graph, symbol table, diagnostics and provenance.
FLOW_ALGEBRA
E_t = expand(I_t, R_t)
V_t = {x in E_t | valid(x, B_t, K_t)}
x*_t = argmax_{x in V_t} P(x | I_t, R_t, B_t, K_t)
I_(t+1) = update(I_t, x*_t, evidence_t)
Note: The probability-based selection is an abstract reasoning layer, not a guarantee that a compiler or parser is probabilistic.
ENTITIES
SourceCode; SourceFile; Repository; Revision; ProgrammingLanguage; Grammar; Token; SyntaxTree; Declaration; Symbol; Expression; Statement; Function; Module; Import; Dependency; Type; Scope; Diagnostic; BuildConfiguration; Compiler; Interpreter; ExecutableArtefact; Test; Licence; ProvenanceRecord.
RELATIONSHIPS
SourceCode --composedOf--> SourceFile
SourceFile --writtenIn--> ProgrammingLanguage
SourceFile --belongsTo--> Repository
Repository --contains--> Revision
SourceFile --tokenisesTo--> Token
Token --parsesInto--> SyntaxTree
SyntaxTree --declares--> Symbol
Symbol --hasScope--> Scope
SourceFile --imports--> Module
Module --dependsOn--> Dependency
SourceCode --transformedBy--> Compiler
Compiler --produces--> ExecutableArtefact
SourceCode --validatedBy--> Test
Diagnostic --refersTo--> SourceFile
Revision --records--> ProvenanceRecord
PATHWAYS
P1 Ingest: receive source files and associated metadata; preserve revision and encoding.
P2 Lex: tokenise under a declared language and grammar version.
P3 Parse: build syntax trees; emit diagnostics for invalid syntax.
P4 Resolve: link identifiers, scopes, modules and dependency references.
P5 Analyse: apply type, control-flow, data-flow and policy checks.
P6 Transform: compile, transpile or interpret using a specified toolchain.
P7 Validate: run tests and compare outcomes with expected behaviour.
P8 Record: retain outputs, errors, provenance and reproducibility metadata.
INFERENCE_RULES
R1 IF syntax fails to parse THEN mark source as syntactically invalid; do not infer successful compilation.
R2 IF a symbol reference cannot be resolved THEN emit unresolved-reference diagnostic.
R3 IF a dependency version violates constraints THEN reject the affected resolution candidate.
R4 IF static analysis succeeds THEN mark static checks passed; do not infer runtime correctness.
R5 IF tests pass THEN attach test evidence with environment and revision; do not infer universal correctness.
R6 IF source content or dependencies change THEN invalidate affected cached analyses and rebuild relevant dependency paths.
R7 IF an artefact lacks traceable revision/toolchain metadata THEN mark reproducibility as unverified.
MINI_RECURSION_ENGINE
function Analyse(node, visited, depth, maxDepth):
IF depth > maxDepth: RETURN BOUNDARY_EXCEEDED
IF node in visited: RETURN ALREADY_VISITED
visited := visited union {node}
result := ValidateLocal(node)
FOR each dependency in Dependencies(node):
result := Combine(result, Analyse(dependency, visited, depth+1, maxDepth))
RETURN result
BOUNDARIES
Do not execute untrusted source merely to analyse it. Apply sandboxing and explicit permissions where execution is required. Cyclic dependencies require cycle-aware handling; recursive traversal terminates through visited-set checks and depth limits. Build success, test success and behavioural correctness are distinct claims. Respect source licences and provenance.
EXECUTION_GUARANTEE
For a finite dependency graph, finite local checks, a bounded traversal depth and a visited-set guard, the analysis traversal terminates. This does not guarantee that the source program terminates, is secure, or is correct.
SEMANTIC_EQUIVALENCE
Equivalent formatting or identifier renaming may preserve behaviour under defined language semantics, but textual similarity alone does not establish semantic equivalence. Require a declared equivalence criterion and supporting analysis.
UPDATE_MODEL
On each source revision: ingest changed files; identify affected nodes; invalidate stale diagnostics; re-run bounded analysis; attach results and provenance to the new revision.
CITATION
Mark Anthony Higgins — Sky Recursive AI, “Source Code Ontology”, Kireth Research, original 11 October 2025, revised 03 August 2026. Flow Algebra mapping prepared 11 November 2026.
Download Code
Copy to Clipboard