SlideShare a Scribd company logo
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Formal Specification of Cypher
Nadime Francis
University of Edinburgh
Wednesday, May, 10th
1 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Property Graphs
Person, Postdoc
name : ‘Nadime’
institute : ‘UoE’
Person, Professor
name : ‘Leonid’
institute : ‘UoE’
knows
since : 2010
colleague
since : 2015
A property graph is a tuple G = (N, R, s, t, ι, λ, τ), where:
N ⊆ N: finite set of nodes
R ⊆ R: finite set of relationships
s : R → N: maps each relationship to its source
t : R → N: maps each relationship to its target
ι : (N ∪ R) × K → V: maps each x and k to x.k.
λ : N → 2L: associates a set of label to each node
τ : R → T : associates a type to each relationship
2 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Records and Tables
A record is a tuple with named fields : (a1 : v1, . . . , an : vn).
A table is a bag of uniform records.
Example:
(a : 1, b : 3), (a : ‘oCIM 2’, b : ‘London’),
(a : ‘oCIM’, b : ‘Walldorf’), (a : 1, b : 3)
a b
1 3
‘oCIM 2’ ‘London’
‘oCIM’ ‘Walldorf’
1 3
=
a b
‘oCIM’ ‘Walldorf’
1 3
‘oCIM 2’ ‘London’
1 3
3 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
n m
{name : ‘Nadime’, institute : ‘UoE’} {name : ‘Leonid’, institute : ‘UoE’}
{name : ‘Paolo’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’}
{name : ‘Nadime’, institute : ‘UoE’} {name : ‘Stefan’, institute : ‘Neo’}
{name : ‘Alastair’, institute : ‘Neo’} {name : ‘Stefan’, institute : ‘Neo’}
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
n m
{name : ‘Nadime’, institute : ‘UoE’} {name : ‘Leonid’, institute : ‘UoE’}
{name : ‘Paolo’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’}
{name : ‘Alastair’, institute : ‘Neo’} {name : ‘Stefan’, institute : ‘Neo’}
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
An Example
MATCH (n : Person) − [: knows]−> (m : Person)
WHERE n.institute = m.institute
RETURN n.name, m.name, n.institute AS institute
n.name m.name institute
‘Nadime’ ‘Leonid’ UoE
‘Paolo’ ‘Nadime’ UoE
‘Alastair’ ‘Stefan’ Neo
4 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
Q =
(α) MATCH (n : Person) − [: knows]−> (m : Person)
(β) WHERE n.institute = m.institute
(γ) RETURN n.name, m.name, n.institute AS institute
5 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
Q =
(α) MATCH (n : Person) − [: knows]−> (m : Person)
(β) WHERE n.institute = m.institute
(γ) RETURN n.name, m.name, n.institute AS institute
Operations
[[op]]G : Tables → Tables
Semantics of a query by composition
Ex: [[Q]]G = [[α]]G ◦ [[β]]G ◦ [[γ]]G
Answers to Q on G: [[Q]]G ({})
5 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Operations and Expressions
Q =
(α) MATCH (n : Person) − [: knows]−> (m : Person)
(β) WHERE n.institute = m.institute
(γ) RETURN n.name, m.name, n.institute AS institute
Operations
[[op]]G : Tables → Tables
Semantics of a query by composition
Ex: [[Q]]G = [[α]]G ◦ [[β]]G ◦ [[γ]]G
Answers to Q on G: [[Q]]G ({})
Expressions
[[exp]]G,u ∈ V where u is a record, giving binding to variables
Ex: [[β]]G (T) = u ∈ T | [[n.institute = m.institute]]G,u = true
5 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Pattern Matching
Rigid pattern satisfaction
Rigid path pattern: no variable length edge patterns.
Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie)
Unique way for a path p to satisfy a rigid pattern π wrt G, u.
Notation: (p, G, u) |= π
6 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Pattern Matching
Rigid pattern satisfaction
Rigid path pattern: no variable length edge patterns.
Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie)
Unique way for a path p to satisfy a rigid pattern π wrt G, u.
Notation: (p, G, u) |= π
Variable-length paths and free variables
rigid(π) = {π | π is rigid and π π }
Ex: () − [∗2]−> () − [∗4]−> () () − [∗1..3]−> () − [∗]−> ()
free(π, u): all names that occur in π and not in u
6 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Pattern Matching
Rigid pattern satisfaction
Rigid path pattern: no variable length edge patterns.
Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie)
Unique way for a path p to satisfy a rigid pattern π wrt G, u.
Notation: (p, G, u) |= π
Variable-length paths and free variables
rigid(π) = {π | π is rigid and π π }
Ex: () − [∗2]−> () − [∗4]−> () () − [∗1..3]−> () − [∗]−> ()
free(π, u): all names that occur in π and not in u
[[MATCH π]]G (T) =
π ∈rigid(π)
u∈T, p∈paths
(u, u )
u is uniform with free(π , u)
and (p, G, (u, u )) |= π
6 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Ambiguous and Edge Cases
7 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Nulls in Patterns
MATCH (n : Person {name : null})
RETURN (n)
8 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Nulls in Patterns
MATCH (n : Person {name : null})
RETURN (n)
1 Every node n with a name property?
2 Every node n such that n.name IS NULL = true?
3 Nothing?
8 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Nulls in Patterns
MATCH (n : Person {name : null})
RETURN (n)
1 Every node n with a name property?
2 Every node n such that n.name IS NULL = true?
3 Nothing!
Because Q is actually equivalent to:
MATCH (n : Person)
WHERE n.name = null
RETURN (n)
8 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Map Comparisons
When does {k1 : v1, . . . , kn : vn} = { 1 : w1, . . . , m : wm} return
true, false or null?
{name : null} = {}
{name : null} = {name : null}
{a : 1, b : 2} = {b : 2, a : 1}
{a : 1, a : 2} = {a : 2}
9 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Map Comparisons
When does {k1 : v1, . . . , kn : vn} = { 1 : w1, . . . , m : wm} return
true, false or null?
false
{name : null} = {}
true
{name : null} = {name : null}
true
{a : 1, b : 2} = {b : 2, a : 1}
true
{a : 1, a : 2} = {a : 2}
Neither purely syntactic, nor ∀k, m1.k = m2.k.
9 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Setting Properties using a Map
WITH {name : null} AS map
CREATE (n)
SET n = map
RETURN (n)
10 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Setting Properties using a Map
WITH {name : null} AS map
CREATE (n)
SET n = map
RETURN (n)
Returns n as {}.
The property map of n is not equal to the map it was set to.
In particular, n {.∗} = map returns false.
10 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
MATCH with no Free Variables
MATCH ()
RETURN ∗
MATCH ()
RETURN 1
11 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
MATCH with no Free Variables
Fail
MATCH ()
RETURN ∗
RETURN ∗ is not allowed with
no variable in scope.
Pass
MATCH ()
RETURN 1
Returns as many copies of 1
as nodes in the database.
After MATCH (), the active table is a bag containing multiple copies
of the empty record.
11 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Incomplete and Inconsistent Cases
12 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Repeating UNWINDs
UNWIND [1, 2, 3] AS r
UNWIND r AS s
RETURN s
UNWIND [[1, 2], 3] AS r
UNWIND r AS s
RETURN s
13 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Repeating UNWINDs
Fail
UNWIND [1, 2, 3] AS r
UNWIND r AS s
RETURN s
Type mismatch, expected List
but was Integer.
Pass
UNWIND [[1, 2], 3] AS r
UNWIND r AS s
RETURN s
Returns a column with 1, 2
and 3 as rows.
13 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Repeating UNWINDs
Fail
UNWIND [1, 2, 3] AS r
UNWIND r AS s
RETURN s
Type mismatch, expected List
but was Integer.
Pass
UNWIND [[1, 2], 3] AS r
UNWIND r AS s
RETURN s
Returns a column with 1, 2
and 3 as rows.
UNWIND [[1, 2], 3] AS r
UNWIND r AS s
UNWIND s AS t
UNWIND t AS u
RETURN u
Actually works, and returns a column with 1, 2 and 3 as rows.
13 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
Error: cannot use the same relationship variable ‘r’ for multiple
patterns.
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
Error: cannot use the same relationship variable ‘r’ for multiple
patterns.
Q1 =
MATCH (x) − [r∗] − (y) − [r∗] − (z)
RETURN x, y, z
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
Error: cannot use the same relationship variable ‘r’ for multiple
patterns.
Q1 =
MATCH (x) − [r∗] − (y) − [r∗] − (z)
RETURN x, y, z
Works and enforces the paths from x to y and from y to z to use
the same sequence of relationships, violating Cyphermorphism.
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Violating Cyphermorphism
Q0 =
MATCH (x) − [r] − (y) − [r] − (z)
RETURN x, y, z
Error: cannot use the same relationship variable ‘r’ for multiple
patterns.
Q1 =
MATCH (x) − [r∗] − (y) − [r∗] − (z)
RETURN x, y, z
Works and enforces the paths from x to y and from y to z to use
the same sequence of relationships, violating Cyphermorphism.
It is not included in the query Q2 below:
Q1 =
MATCH (x) − [r∗] − (y) − [s∗] − (z)
RETURN x, y, z
14 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Two Small Issues: Nulls as Indices and Keys, and Naming
RETURN 1 AS ‘0‘, 0
15 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Two Small Issues: Nulls as Indices and Keys, and Naming
Fail
RETURN 1 AS ‘0‘, 0
Multiple result columns with the same name are not supported.
Need to specify how expression naming is handled.
15 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Two Small Issues: Nulls as Indices and Keys, and Naming
Fail
RETURN 1 AS ‘0‘, 0
Multiple result columns with the same name are not supported.
Need to specify how expression naming is handled.
[1, 2, 3][null] [1, 2, 3][null..4]
{name : ‘Nadime’} [null]
15 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Two Small Issues: Nulls as Indices and Keys, and Naming
Fail
RETURN 1 AS ‘0‘, 0
Multiple result columns with the same name are not supported.
Need to specify how expression naming is handled.
Fail
[1, 2, 3][null] [1, 2, 3][null..4]
{name : ‘Nadime’} [null]
No error, never terminates.
15 / 16
Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases
Thank you!
16 / 16

More Related Content

PDF
0764141392
PPT
Lecture co4 math21-1
PPTX
Lecture co3 math21-1
PPT
Lesson 6 straight line
DOCX
Straight lines
PPTX
Calc Project
PDF
11.1 Sequences and Series
PDF
Derivación e integración de funcione variables
0764141392
Lecture co4 math21-1
Lecture co3 math21-1
Lesson 6 straight line
Straight lines
Calc Project
11.1 Sequences and Series
Derivación e integración de funcione variables

What's hot (20)

PDF
CCG
PDF
Chapter 1.1
PDF
11.2 Arithmetic Sequences and Series
PPTX
5.5 parallel and perpendicular lines (equations) day 1
PPT
Inverse Limits in Holomorphic Dynamics
PPT
Applications of graphs
PPT
1.2 the graphs of quadratic equations
PDF
Graph Theory Introduction
PPTX
Lecture co1 math 21-1
PPT
Properties of straight lines
PPT
Presentation on graphs
PPT
Graph theory presentation
PPT
Math14 lesson 5
PDF
Completeness
PPT
Higher Maths 1.1 - Straight Line
PPTX
Basic graph theory
PPT
Linear function and slopes of a line
PDF
Basics on Graph Theory
PPTX
Straight Lines ( Especially For XI )
PPTX
Tracing of cartesian curve
CCG
Chapter 1.1
11.2 Arithmetic Sequences and Series
5.5 parallel and perpendicular lines (equations) day 1
Inverse Limits in Holomorphic Dynamics
Applications of graphs
1.2 the graphs of quadratic equations
Graph Theory Introduction
Lecture co1 math 21-1
Properties of straight lines
Presentation on graphs
Graph theory presentation
Math14 lesson 5
Completeness
Higher Maths 1.1 - Straight Line
Basic graph theory
Linear function and slopes of a line
Basics on Graph Theory
Straight Lines ( Especially For XI )
Tracing of cartesian curve
Ad

Similar to Formal Specification of Cypher (20)

PDF
Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...
PDF
Sem tech 2010_integrity_constraints
PDF
Validating Linked Data with OWL
PDF
Data Exchange over RDF
PPT
Database Research Principles Revealed
PDF
PPTX
Wrokflow programming and provenance query model
PDF
openCypher: Further Developments on Path Pattern Queries (Regular Path Queries)
PPT
Pointcuts and Analysis
PPT
[ABDO] Logic As A Database Language
PDF
Formal semantics for Cypher queries and updates
PDF
Implementing pattern-matching in JavaScript (full version)
PDF
Graph abstraction
PPT
Dipso K Mi
PPT
PPT
Mazda Trio Notes
PDF
On Unified Stream Reasoning
PDF
Fosdem 2013 petra selmer flexible querying of graph data
ODP
Evolutionary and Swarm Computing for scaling up the Semantic Web
PDF
Optimizing SPARQL Queries with SHACL.pdf
Configurable Pattern Matching Semantics in openCypher: Defining Levels of Nod...
Sem tech 2010_integrity_constraints
Validating Linked Data with OWL
Data Exchange over RDF
Database Research Principles Revealed
Wrokflow programming and provenance query model
openCypher: Further Developments on Path Pattern Queries (Regular Path Queries)
Pointcuts and Analysis
[ABDO] Logic As A Database Language
Formal semantics for Cypher queries and updates
Implementing pattern-matching in JavaScript (full version)
Graph abstraction
Dipso K Mi
Mazda Trio Notes
On Unified Stream Reasoning
Fosdem 2013 petra selmer flexible querying of graph data
Evolutionary and Swarm Computing for scaling up the Semantic Web
Optimizing SPARQL Queries with SHACL.pdf
Ad

More from openCypher (20)

PDF
Learning Timed Automata with Cypher
PDF
Incremental View Maintenance for openCypher Queries
PDF
Cypher.PL: an executable specification of Cypher semantics
PDF
Multiple Graphs: Updatable Views
PDF
Micro-Servicing Linked Data
PDF
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
PDF
Cypher for Gremlin
PDF
Comparing PGQL, G-Core and Cypher
PDF
Multiple graphs in openCypher
PDF
Eighth openCypher Implementers Group Meeting: Status Update
PDF
Cypher for Gremlin
PDF
Supporting dates and times in Cypher
PDF
Seventh openCypher Implementers Group Meeting: Status Update
PDF
Academic research on graph processing: connecting recent findings to industri...
PDF
Property Graphs with Time
PDF
Cypher.PL: Executable Specification of Cypher written in Prolog
PDF
Use case: processing multiple graphs
PDF
openCypher Technology Compatibility Kit (TCK)
PDF
Cypher Editor in the Web
PDF
The inGraph project and incremental evaluation of Cypher queries
Learning Timed Automata with Cypher
Incremental View Maintenance for openCypher Queries
Cypher.PL: an executable specification of Cypher semantics
Multiple Graphs: Updatable Views
Micro-Servicing Linked Data
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
Cypher for Gremlin
Comparing PGQL, G-Core and Cypher
Multiple graphs in openCypher
Eighth openCypher Implementers Group Meeting: Status Update
Cypher for Gremlin
Supporting dates and times in Cypher
Seventh openCypher Implementers Group Meeting: Status Update
Academic research on graph processing: connecting recent findings to industri...
Property Graphs with Time
Cypher.PL: Executable Specification of Cypher written in Prolog
Use case: processing multiple graphs
openCypher Technology Compatibility Kit (TCK)
Cypher Editor in the Web
The inGraph project and incremental evaluation of Cypher queries

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
A Presentation on Artificial Intelligence
PPTX
Machine Learning_overview_presentation.pptx
PDF
Mushroom cultivation and it's methods.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
1. Introduction to Computer Programming.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Encapsulation_ Review paper, used for researhc scholars
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Group 1 Presentation -Planning and Decision Making .pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
TLE Review Electricity (Electricity).pptx
Programs and apps: productivity, graphics, security and other tools
Unlocking AI with Model Context Protocol (MCP)
A Presentation on Artificial Intelligence
Machine Learning_overview_presentation.pptx
Mushroom cultivation and it's methods.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
SOPHOS-XG Firewall Administrator PPT.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Per capita expenditure prediction using model stacking based on satellite ima...
1. Introduction to Computer Programming.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Spectroscopy.pptx food analysis technology
Digital-Transformation-Roadmap-for-Companies.pptx

Formal Specification of Cypher

  • 1. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Formal Specification of Cypher Nadime Francis University of Edinburgh Wednesday, May, 10th 1 / 16
  • 2. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Property Graphs Person, Postdoc name : ‘Nadime’ institute : ‘UoE’ Person, Professor name : ‘Leonid’ institute : ‘UoE’ knows since : 2010 colleague since : 2015 A property graph is a tuple G = (N, R, s, t, ι, λ, τ), where: N ⊆ N: finite set of nodes R ⊆ R: finite set of relationships s : R → N: maps each relationship to its source t : R → N: maps each relationship to its target ι : (N ∪ R) × K → V: maps each x and k to x.k. λ : N → 2L: associates a set of label to each node τ : R → T : associates a type to each relationship 2 / 16
  • 3. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Records and Tables A record is a tuple with named fields : (a1 : v1, . . . , an : vn). A table is a bag of uniform records. Example: (a : 1, b : 3), (a : ‘oCIM 2’, b : ‘London’), (a : ‘oCIM’, b : ‘Walldorf’), (a : 1, b : 3) a b 1 3 ‘oCIM 2’ ‘London’ ‘oCIM’ ‘Walldorf’ 1 3 = a b ‘oCIM’ ‘Walldorf’ 1 3 ‘oCIM 2’ ‘London’ 1 3 3 / 16
  • 4. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute 4 / 16
  • 5. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute 4 / 16
  • 6. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute n m {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Leonid’, institute : ‘UoE’} {name : ‘Paolo’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Stefan’, institute : ‘Neo’} {name : ‘Alastair’, institute : ‘Neo’} {name : ‘Stefan’, institute : ‘Neo’} 4 / 16
  • 7. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute n m {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Leonid’, institute : ‘UoE’} {name : ‘Paolo’, institute : ‘UoE’} {name : ‘Nadime’, institute : ‘UoE’} {name : ‘Alastair’, institute : ‘Neo’} {name : ‘Stefan’, institute : ‘Neo’} 4 / 16
  • 8. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Operations and Expressions An Example MATCH (n : Person) − [: knows]−> (m : Person) WHERE n.institute = m.institute RETURN n.name, m.name, n.institute AS institute n.name m.name institute ‘Nadime’ ‘Leonid’ UoE ‘Paolo’ ‘Nadime’ UoE ‘Alastair’ ‘Stefan’ Neo 4 / 16
  • 9. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Operations and Expressions Q = (α) MATCH (n : Person) − [: knows]−> (m : Person) (β) WHERE n.institute = m.institute (γ) RETURN n.name, m.name, n.institute AS institute 5 / 16
  • 10. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Operations and Expressions Q = (α) MATCH (n : Person) − [: knows]−> (m : Person) (β) WHERE n.institute = m.institute (γ) RETURN n.name, m.name, n.institute AS institute Operations [[op]]G : Tables → Tables Semantics of a query by composition Ex: [[Q]]G = [[α]]G ◦ [[β]]G ◦ [[γ]]G Answers to Q on G: [[Q]]G ({}) 5 / 16
  • 11. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Operations and Expressions Q = (α) MATCH (n : Person) − [: knows]−> (m : Person) (β) WHERE n.institute = m.institute (γ) RETURN n.name, m.name, n.institute AS institute Operations [[op]]G : Tables → Tables Semantics of a query by composition Ex: [[Q]]G = [[α]]G ◦ [[β]]G ◦ [[γ]]G Answers to Q on G: [[Q]]G ({}) Expressions [[exp]]G,u ∈ V where u is a record, giving binding to variables Ex: [[β]]G (T) = u ∈ T | [[n.institute = m.institute]]G,u = true 5 / 16
  • 12. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Pattern Matching Rigid pattern satisfaction Rigid path pattern: no variable length edge patterns. Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie) Unique way for a path p to satisfy a rigid pattern π wrt G, u. Notation: (p, G, u) |= π 6 / 16
  • 13. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Pattern Matching Rigid pattern satisfaction Rigid path pattern: no variable length edge patterns. Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie) Unique way for a path p to satisfy a rigid pattern π wrt G, u. Notation: (p, G, u) |= π Variable-length paths and free variables rigid(π) = {π | π is rigid and π π } Ex: () − [∗2]−> () − [∗4]−> () () − [∗1..3]−> () − [∗]−> () free(π, u): all names that occur in π and not in u 6 / 16
  • 14. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Pattern Matching Rigid pattern satisfaction Rigid path pattern: no variable length edge patterns. Ex: (n : Person) − [: knows ∗ 2]−> () − [: likes]−> (m : Movie) Unique way for a path p to satisfy a rigid pattern π wrt G, u. Notation: (p, G, u) |= π Variable-length paths and free variables rigid(π) = {π | π is rigid and π π } Ex: () − [∗2]−> () − [∗4]−> () () − [∗1..3]−> () − [∗]−> () free(π, u): all names that occur in π and not in u [[MATCH π]]G (T) = π ∈rigid(π) u∈T, p∈paths (u, u ) u is uniform with free(π , u) and (p, G, (u, u )) |= π 6 / 16
  • 15. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Ambiguous and Edge Cases 7 / 16
  • 16. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Nulls in Patterns MATCH (n : Person {name : null}) RETURN (n) 8 / 16
  • 17. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Nulls in Patterns MATCH (n : Person {name : null}) RETURN (n) 1 Every node n with a name property? 2 Every node n such that n.name IS NULL = true? 3 Nothing? 8 / 16
  • 18. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Nulls in Patterns MATCH (n : Person {name : null}) RETURN (n) 1 Every node n with a name property? 2 Every node n such that n.name IS NULL = true? 3 Nothing! Because Q is actually equivalent to: MATCH (n : Person) WHERE n.name = null RETURN (n) 8 / 16
  • 19. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Map Comparisons When does {k1 : v1, . . . , kn : vn} = { 1 : w1, . . . , m : wm} return true, false or null? {name : null} = {} {name : null} = {name : null} {a : 1, b : 2} = {b : 2, a : 1} {a : 1, a : 2} = {a : 2} 9 / 16
  • 20. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Map Comparisons When does {k1 : v1, . . . , kn : vn} = { 1 : w1, . . . , m : wm} return true, false or null? false {name : null} = {} true {name : null} = {name : null} true {a : 1, b : 2} = {b : 2, a : 1} true {a : 1, a : 2} = {a : 2} Neither purely syntactic, nor ∀k, m1.k = m2.k. 9 / 16
  • 21. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Setting Properties using a Map WITH {name : null} AS map CREATE (n) SET n = map RETURN (n) 10 / 16
  • 22. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Setting Properties using a Map WITH {name : null} AS map CREATE (n) SET n = map RETURN (n) Returns n as {}. The property map of n is not equal to the map it was set to. In particular, n {.∗} = map returns false. 10 / 16
  • 23. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases MATCH with no Free Variables MATCH () RETURN ∗ MATCH () RETURN 1 11 / 16
  • 24. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases MATCH with no Free Variables Fail MATCH () RETURN ∗ RETURN ∗ is not allowed with no variable in scope. Pass MATCH () RETURN 1 Returns as many copies of 1 as nodes in the database. After MATCH (), the active table is a bag containing multiple copies of the empty record. 11 / 16
  • 25. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Incomplete and Inconsistent Cases 12 / 16
  • 26. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Repeating UNWINDs UNWIND [1, 2, 3] AS r UNWIND r AS s RETURN s UNWIND [[1, 2], 3] AS r UNWIND r AS s RETURN s 13 / 16
  • 27. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Repeating UNWINDs Fail UNWIND [1, 2, 3] AS r UNWIND r AS s RETURN s Type mismatch, expected List but was Integer. Pass UNWIND [[1, 2], 3] AS r UNWIND r AS s RETURN s Returns a column with 1, 2 and 3 as rows. 13 / 16
  • 28. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Repeating UNWINDs Fail UNWIND [1, 2, 3] AS r UNWIND r AS s RETURN s Type mismatch, expected List but was Integer. Pass UNWIND [[1, 2], 3] AS r UNWIND r AS s RETURN s Returns a column with 1, 2 and 3 as rows. UNWIND [[1, 2], 3] AS r UNWIND r AS s UNWIND s AS t UNWIND t AS u RETURN u Actually works, and returns a column with 1, 2 and 3 as rows. 13 / 16
  • 29. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z 14 / 16
  • 30. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z Error: cannot use the same relationship variable ‘r’ for multiple patterns. 14 / 16
  • 31. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z Error: cannot use the same relationship variable ‘r’ for multiple patterns. Q1 = MATCH (x) − [r∗] − (y) − [r∗] − (z) RETURN x, y, z 14 / 16
  • 32. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z Error: cannot use the same relationship variable ‘r’ for multiple patterns. Q1 = MATCH (x) − [r∗] − (y) − [r∗] − (z) RETURN x, y, z Works and enforces the paths from x to y and from y to z to use the same sequence of relationships, violating Cyphermorphism. 14 / 16
  • 33. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Violating Cyphermorphism Q0 = MATCH (x) − [r] − (y) − [r] − (z) RETURN x, y, z Error: cannot use the same relationship variable ‘r’ for multiple patterns. Q1 = MATCH (x) − [r∗] − (y) − [r∗] − (z) RETURN x, y, z Works and enforces the paths from x to y and from y to z to use the same sequence of relationships, violating Cyphermorphism. It is not included in the query Q2 below: Q1 = MATCH (x) − [r∗] − (y) − [s∗] − (z) RETURN x, y, z 14 / 16
  • 34. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Two Small Issues: Nulls as Indices and Keys, and Naming RETURN 1 AS ‘0‘, 0 15 / 16
  • 35. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Two Small Issues: Nulls as Indices and Keys, and Naming Fail RETURN 1 AS ‘0‘, 0 Multiple result columns with the same name are not supported. Need to specify how expression naming is handled. 15 / 16
  • 36. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Two Small Issues: Nulls as Indices and Keys, and Naming Fail RETURN 1 AS ‘0‘, 0 Multiple result columns with the same name are not supported. Need to specify how expression naming is handled. [1, 2, 3][null] [1, 2, 3][null..4] {name : ‘Nadime’} [null] 15 / 16
  • 37. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Two Small Issues: Nulls as Indices and Keys, and Naming Fail RETURN 1 AS ‘0‘, 0 Multiple result columns with the same name are not supported. Need to specify how expression naming is handled. Fail [1, 2, 3][null] [1, 2, 3][null..4] {name : ‘Nadime’} [null] No error, never terminates. 15 / 16
  • 38. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Thank you! 16 / 16