arXiv:2608.24565cs.PLAug 2026

Manuscript Offprint

arXiv:2608.24565

MGQL: An Executable, Small-Step Semantics of GQL

Aditya Thimmaiah, Tong-Nong Lin, Milos Gligoric

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ADITYA THIMMAIAH, University of Texas at Austin, USA

TONG-NONG LIN, University of Texas at Austin, USA

MILOS GLIGORIC, University of Texas at Austin, USA

Research and development of graph query languages has been gaining traction with the increase in popularity of graph databases, specifically due to the flexible schema and other rich semantic offerings of the latter's most common underlying data model: the property graph. This has culminated in the standardization of the ISO Graph Query Language (GQL) as ISO/IEC 39075 in 2024, the first international standard for property graph-based graph query languages. However, ISO/IEC 39075 codifies its semantics informally across 600+ pages of prose, making it difficult to formally reason about the standard or for a standard-faithful implementation.

Existing formalizations are not adequate because they either: (1) significantly reduce the semantic complexity by omitting bag semantics, schemas, and composite queries on multiple graphs; (2) or significantly reduce the syntactic complexity by only considering isolated fragments such as pattern-matching, leaving the full query pipeline unformalized. Yet it is these semantic–syntactic features that make formalizing GQL non-trivial.

We present MGQL, the first mechanized, small-step operational semantics for a substantial read-only fragment of GQL that is grounded in the ISO/IEC 39075 standard. Our formalization models multi-graph property graphs with mixed edge directionality and supports a large fraction of GQL pattern constructs: quantified paths and edges, directional and undirected matching, label expressions, pattern lists, and composite queries. The semantics is supported by a schema-aware type system that refines variable types via closed-graph schemas, tracks nullability, supports multiple composite query operators, and models quantified-path bindings with list types. We prove that our type system is sound, ensuring an end-to-end guarantee of well-formed queries yielding results that conform to their declared schemas. MGQL provides the first bridge between GQL's informal specification and a mechanized implementation, enabling formal reasoning about correctness.

CCS Concepts: • Theory of computation → Type theory; Operational semantics; • Software and its engineering → Semantics; • Information systems → Query languages for non-relational engines.

Additional Key Words and Phrases: ISO GQL, Cypher, Graph Query Language, Formal Semantics, Lean, Mechanization

ACM Reference Format:

Aditya Thimmaiah, Tong-Nong Lin, and Milos Gligoric. 2026. MGQL: An Executable, Small-Step Semantics of GQL. Proc. ACM Program. Lang. 10, OOPSLA2, Article 327 (October 2026), 27 pages. https://doi.org/10.1145/3839459

1 Introduction

Graph databases have become foundational for modern data management and power many applications from social networks and fraud detection to drug discovery and knowledge graphs [1,27][1, 27]. The Graph Query Language (GQL) [11,16][11, 16], standardized in 2024 as ISO/IEC 39075, is the first international standard of graph query languages that query property graphs [1][1]. The standard

Authors' Contact Information: Aditya Thimmaiah, University of Texas at Austin, Austin, USA, auditt@utexas.edu; Tong-Nong Lin, University of Texas at Austin, Austin, USA, tong-nong@utexas.edu; Milos Gligoric, University of Texas at Austin, Austin, USA, gligoric@utexas.edu.

Figure

This work is licensed under a Creative Commons Attribution 4.0 International License.

© 2026 Copyright held by the owner/author(s).

ACM 2475-1421/2026/10-ART327

https://doi.org/10.1145/3839459

327:2

Aditya Thimmaiah, Tong-Nong Lin, and Milos Gligoric

unified language features from other graph query languages such as Cypher [15], PGQL [30], and G-CORE [2]. It defines the semantics specification which implementations are expected to conform.

However, the semantics is specified informally, spanning more than 600 pages of prose that interleave data flow, typing, query evaluation pipelines, and pattern-matching, etc., making formally reasoning about GQL, such as verifying implementations or proving query equivalences, difficult.

Existing formalizations do not address this adequately. Francis et al. [13] distilled GQL's pattern matching into a Graph Pattern Calculus (GPC) with typing rules and a denotational semantics, and Gheerbrant et al. [16] defined Core GQL and Core PGQ to study its expressive power, but both leave out graph schemas [4] and bag semantics. Ye et al. [31] formalized a gradually typed calculus for GQL path patterns in isolation from the rest of the language, implementing it in Python. No mechanized semantics exists for a fragment of GQL rich enough to model the interaction between graph schemas, bag semantics, and composite queries, etc., some of the key unique features of GQL.

We present MGQL, the first mechanized, executable, small-step operational semantics for a large read-only fragment of GQL, together with a schema-aware type system and a type soundness theorem, all machine-checked in Lean4 [9]; providing a foundation for rigorous formal reasoning.

We handle the complexity of GQL’s semantics by stratifying our static typing rules and small-step operational semantics into compositional layers—expressions, patterns, and queries. This allows us to capture the key non-trivial features of GQL. First, graph element types in GQL are graph-scoped and refined by graph schemas, allowing for label and property constraints to enable statically detecting patterns that cannot match, but requiring a typing system that propagates refined types across the query pipeline. Second, GQL’s three-valued semantics identifies null with the truth value Unknown, requiring every operator to participate in Kleene-style null propagation and every type to track nullability. Third, GQL’s path modes and match modes impose additional constraints on pattern matching such as the TRAIL path mode which constrains a pattern-match by forbidding repeated edges, thus breaking naïve path composition. We handle this by introducing auxiliary execution constructs besides those specified in the standard, which carry the edges visited during pattern-matching alongside the matched elements, making it trivial to enforce edge-disjointness. Fourth, quantified path patterns iterate over graph structure and bind their variables to sequences rather than single elements. We compute their repetitions with a frontier. Finally, composite queries combine bags whose records carry the same attributes but not necessarily the same types, yielding heterogeneous unions that the type system must track to formalize well-formedness of queries.

We make the following contributions:

• We define a formal calculus ( §2.2§2.2) for a rich read-only fragment of GQL, covering graph resolution, pattern matching, filtering, projection, and composite queries over multiple graphs.

• We develop the first schema-aware type system ( §3§3) for GQL, supporting graph-scoped refinement, nullability tracking, heterogeneous unions, and list-typed quantified path bindings.

• We give the first small-step operational semantics ( §5§5) for GQL, capturing TRAIL-aware pattern matching, quantified patterns, nulls, and composite queries; all under bag semantics.

• We prove a layered type soundness theorem ( §6§6) guaranteeing that well-formed queries (on complete evaluation) produce results that conform to the types assigned to them statically.

• We mechanize ( §7§7) our semantics in Lean4, and validate it on queries of the Linked Data Benchmark Council’s (LDBC) Social Network Benchmark (SNB) Interactive v2 workload [22].

All references to the GQL standard are with respect to the ISO/IEC 39075 First Edition 2024, which we henceforth refer to as just ISO. We also abbreviate normative syntax rules from the standard as SR when referring to them. MGQL is available at https://github.com/EngineeringSoftware/mgql.

327:3

References (24)