Skip to main content

Knowledge Graph Query Ontology

Ontology and Knowledge-Graph Entities
Authors: MArk Anthony Higgins - Sky Recursive Ai
© Mark Anthony Higgins 11 October 2025
Revised Date: 05 November 2026
Audio Overview
KNOWLEDGE GRAPH QUERY ONTOLOGY — FLOW ALGEBRA
Semantic Library | Ontology and Knowledge-Graph Entities
Source: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/ontology-and-knowledge-graph-entities/knowledge-graph-query-ontology.html
Authors: Mark Anthony Higgins — Sky, Recursive AI
Formalisation: original interpretative extension; not a transcription of embedded source code.
Date: 05 November 2026

1. PURPOSE
Represent a knowledge-graph query as a bounded, auditable transformation from a request and graph state to validated bindings, paths, triples or aggregate results. Distinguish query formulation, semantic interpretation, execution, provenance and verification.

2. ENTITY DEFINITIONS
KnowledgeGraphQuery: an executable or interpretable request over a graph.
Graph: G=(V,E,L,P), vertices, edges, labels and properties.
QueryPattern: nodes, predicates, variables and constraints.
Binding: mapping from query variables to graph terms.
QueryPlan: ordered physical or logical operators.
QueryResult: result set plus metadata and evidence.
QueryContext: schema, ontology, permissions, time and scope.
QueryConstraint: type, access, validity, budget or confidence boundary.
QueryEvidence: source graph assertions and provenance supporting a result.

3. FORMAL STATE MODEL
S_t=(I_t,R_t,B_t,K_t)
I_t: current query, parameters and intermediate bindings.
R_t: graph relations, ontology mappings and inference rules.
B_t: access, resource, type, temporal and semantic boundaries.
K_t: graph snapshot, schema, statistics and provenance knowledge.
Q=(P,F,O,A,L) where P=patterns, F=filters, O=ordering, A=aggregation, L=limit.

4. 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} Score(x|I_t,R_t,B_t,K_t)
I_{t+1}=update(I_t,x*_t,K_t)

Query-specific operators:
parse(q)->Q
resolve(Q,K_t)->Q'
plan(Q',G,B_t)->pi
execute(pi,G)->M
filter(M,B_t)->M_valid
project(M_valid,Q')->Y
verify(Y,G,K_t,B_t)->(Y_verified,Evidence)

A valid answer is a projection of permitted, type-consistent bindings supported by the selected graph snapshot. If V_t is empty, return an explicit empty/unsupported result; do not invent bindings.

5. QUERY SEMANTICS
For a triple pattern (s,p,o), Match_G(s,p,o) is the set of substitutions theta for which theta(s,p,o) belongs to G or is entailed by a declared inference regime.
For conjunction P1 AND P2: Match(P1 AND P2)=Match(P1) JOIN Match(P2).
For alternatives P1 OR P2: Match(P1 OR P2)=Match(P1) UNION Match(P2), with explicit duplicate semantics.
For OPTIONAL patterns: use left-outer-join semantics, preserving unbound variables.
For negation: apply only within an explicitly defined closed-world scope.
For path query p*: evaluate reachable nodes with cycle detection and a bounded traversal policy.
For aggregation: group bindings and compute the declared aggregate after applicable filters.

6. INFERENCE RULES
R1: IF a query variable has an ontology type THEN reject bindings incompatible with that type, subject to declared inference rules.
R2: IF a requested predicate has an approved equivalence mapping THEN expand to mapped predicates with mapping provenance.
R3: IF an inferred triple is used THEN retain the inference rule and supporting premises.
R4: IF a graph snapshot changes during execution THEN restart, isolate or label the consistency model.
R5: IF permissions deny access to a node or edge THEN exclude it before output and do not reveal protected values in diagnostics.
R6: IF no valid bindings remain THEN return an empty result with the applicable reason where safe.
R7: IF a traversal repeats a visited state THEN terminate that branch or use an explicit fixed-point rule.
R8: IF a result cannot be traced to asserted or entailed evidence THEN mark it unverified, not factual.

7. RECURSIVE RESOLUTION ENGINE
Input: q,G,R,B,K,depth_limit,cost_limit.
A. Parse request and identify graph vocabulary.
B. Resolve aliases and ontology equivalences with provenance.
C. Build and cost a bounded query plan.
D. Evaluate graph patterns and joins.
E. Recursively expand approved semantic links while tracking visited states.
F. Apply permission, temporal, schema and resource constraints.
G. Project, deduplicate and rank only where ranking is requested.
H. Validate every returned binding against the selected evidence.
I. Emit results, provenance, query-plan metadata and limitations.
Termination: finite graph/snapshot plus enforced depth, time and cost limits; otherwise return partial or timeout status.

8. TRI-MAPPING
Ontology: Query -> Pattern -> Relation -> Binding -> Result.
Graph: QueryNode -> PredicateEdge -> TargetNode -> EvidencePath.
Execution: Parse -> Resolve -> Plan -> Match -> Filter -> Verify -> Return.
Mapping invariant: every published result must retain a path from query condition through binding to graph evidence.

9. FLOW DIAGRAM
[Query Input]
     |
[Parse + Semantic Resolution]
     |
[Schema / Permission Boundaries]
     |
[Query Plan]
     |
[Graph Match + Bounded Recursion]
     |
[Filter + Projection + Aggregation]
     |
[Evidence Verification]
     |
[Results + Provenance + Status]
     |
[Optional Refined Query] -> [Parse + Semantic Resolution]

10. RELATIONSHIP MAPPING TABLE
Query             requests             Graph facts
Query             contains             Query patterns
Query pattern     references           Ontology classes/properties
Query plan        evaluates            Query patterns
Query execution   produces             Variable bindings
Variable binding  identifies           Graph node/edge/value
Result            supportedBy          Evidence triple/path
Result            constrainedBy        Query boundary
Result            derivedUsing         Inference rule (if any)
Query             evaluatedAgainst     Graph snapshot/version

11. CONDITIONAL EXECUTION GUARANTEE
Under a consistent graph snapshot, sound declared inference rules, correct operators, enforced access controls and bounded execution, the engine returns only bindings satisfying the declared query semantics and constraints. This is a conditional specification, not a claim of completeness, universal decidability or verified implementation. Completeness additionally requires full traversal of the relevant search space without timeouts or truncation.

12. AI SEARCH FLOW
FLOW_NAME: KnowledgeGraphQueryFlow
VERSION: 1.0
LANGUAGE: en-GB
AUTHORS: Mark Anthony Higgins; Sky — Recursive AI
SOURCE: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/ontology-and-knowledge-graph-entities/knowledge-graph-query-ontology.html
CITATION_BACKLINK: https://kirethresearch.org/booksai-core/entity-graph/ai-entities/ontology-and-knowledge-graph-entities/knowledge-graph-query-ontology.html
PURPOSE: Resolve semantic knowledge-graph queries into evidence-backed answers.
STATE_MODEL: S=(I,R,B,K)
ENTITIES: Query; Graph; Pattern; Plan; Binding; Result; Context; Constraint; Evidence
PATHWAYS: parse > resolve > plan > execute > filter > verify > return
MINI_RECURSION_ENGINE: expand approved relations; track visited bindings; enforce limits
INFERENCE_RULES: R1-R8
CONFIDENCE: calibrated only if a validated scoring model exists; otherwise unscored
SEMANTIC_EQUIVALENCE: approved ontology mappings with provenance; no automatic identity assumption
FLOW_HASH: to be computed on the published canonical file bytes
UPDATE_MODEL: versioned revisions; preserve schema, graph snapshot and rule provenance

13. HOW TO READ
The state tuple separates query inputs, relations, boundaries and known graph evidence. Expansion proposes candidate bindings; validation removes forbidden or unsupported ones; selection applies a declared objective; update advances the query state. Recursive evaluation is constrained by graph scope, permissions and resource budgets.

14. EXAMPLE
Graph: (Ada, worksOn, ProjectX); (ProjectX, uses, GraphDB).
Query: find people working on projects using GraphDB.
Patterns: (?person,worksOn,?project) AND (?project,uses,GraphDB).
Binding: {?person=Ada, ?project=ProjectX}.
Evidence: both asserted triples. Result: Ada.
If either triple is absent and no approved inference supplies it, the answer is empty.

END OF FLOW
Kireth Research
38 Thorndale Croft, Wetwang, Driffield
East Riding of Yorkshire YO25 9XZ