Skip to main content
QUICK REVIEW

[Paper Review] Formal Semantics of the Language Cypher

Nadime Francis, Alastair Green|arXiv (Cornell University)|Feb 27, 2018
Graph Theory and AlgorithmsComputer Science5 citations
TL;DR

This paper presents a formal denotational semantics for the core read-only fragment of Cypher, a widely used query language for property graphs. It defines the meaning of pattern matching, filtering, and relational operations using mathematical functions over tables, enabling precise reasoning about query equivalence and optimization across implementations.

ABSTRACT

Cypher is a query language for property graphs. It was originally designed and implemented as part of the Neo4j graph database, and it is currently used in a growing number of commercial systems, industrial applications and research projects. In this work, we provide denotational semantics of the core fragment of the read-only part of Cypher, which features in particular pattern matching, filtering, and most relational operations on tables.

Motivation & Objective

  • To establish a formal, denotational semantics for the core read-only part of Cypher, addressing the lack of a standardized specification.
  • To enable precise reasoning about query equivalence and correctness of query optimization across different Cypher implementations.
  • To provide a reference model for implementing and verifying Cypher in diverse systems, including commercial and research databases.
  • To formalize key Cypher constructs such as pattern matching, filtering, and table operations in a mathematically rigorous way.

Proposed method

  • Defining a formal data model that includes values (integers, strings, lists, maps, trilean), property graphs, records, and tables as bags of records.
  • Specifying pattern matching via rigid patterns and path satisfaction, where a pattern matches a path if it satisfies structural and label constraints.
  • Defining the semantics of Cypher expressions as functions mapping a graph and a record to a value, using a denotational approach.
  • Formalizing clauses such as MATCH, WHERE, RETURN, WITH, and UNWIND as functions from input tables to output tables, preserving table structure and semantics.
  • Using mathematical constructs like domain restriction, record extension, and disjoint union to model variable binding and result construction.
  • Defining evaluation of expressions and clauses recursively, with semantics grounded in the graph structure and variable bindings.

Experimental results

Research questions

  • RQ1How can the core read-only features of Cypher be formally specified using denotational semantics to ensure consistent interpretation across implementations?
  • RQ2What mathematical framework best captures the behavior of pattern matching and path matching in property graphs?
  • RQ3How can filtering, projection, and table manipulation in Cypher be modeled as functions over tables with well-defined input-output behavior?
  • RQ4What are the formal conditions under which a pattern matches a path in a graph, and how can this be expressed mathematically?
  • RQ5How can the semantics of Cypher's query clauses (MATCH, WHERE, WITH, RETURN, UNWIND) be composed to yield a complete query evaluation function?

Key findings

  • The formal semantics successfully captures the intended behavior of Cypher’s core read-only features, including pattern matching, filtering, and relational operations on tables.
  • The semantics enables precise reasoning about query equivalence, allowing for the formal verification of query optimization techniques.
  • The model correctly handles variable binding and path satisfaction, as demonstrated by the evaluation of a concrete example with four nodes and three relationships.
  • The semantics of the WITH clause is formally defined to support both projection and selection, including handling of * and aliasing.
  • The UNWIND clause is formally specified to expand lists into multiple rows, with correct handling of empty lists and non-list values.
  • The semantics provides a foundation for a reference implementation and enables cross-implementational consistency in Cypher query processing.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.