Skip to content
Open
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8b6513b
Add proposal for isomorphic pattern matching in response to #174
boggle Jan 25, 2017
ed1a824
Support walks, trails, paths; shortest and cheapest paths matching
boggle Jul 16, 2017
6117618
Rework CIP
boggle Jul 16, 2017
5742fdf
Simplified set of match modes and default handling
boggle Jul 19, 2017
13f3711
Fix example
boggle Jul 19, 2017
fe68d48
Small fixups
boggle Jul 23, 2017
856ae1b
Removed duplicate line
boggle Jul 23, 2017
dd397a5
Restructure CIP and improve language
Mats-SX Jul 24, 2017
ce78377
Rename pattern binder to pattern variable
Mats-SX Jul 24, 2017
cd54871
Remove section on multiline patterns
Mats-SX Jul 24, 2017
9386b70
Remove section on pre-parser options
Mats-SX Jul 24, 2017
048ac32
Move functions to appendix
Mats-SX Jul 24, 2017
00dc3c1
Rename Walks section to walks, trails, paths
Mats-SX Jul 24, 2017
91622f5
Morphism CIP: add definitions of WTP
Jul 24, 2017
db32e46
Structural improvements
Jul 24, 2017
7cccfff
Tie pattern variable classes together with formal definitions
Jul 24, 2017
8f2982d
Tidy up referencing
Jul 24, 2017
254b890
Added plural forms to grammar
boggle Jul 24, 2017
d6384c2
Mandate correct cardinality warnings consistently
boggle Jul 24, 2017
b789402
Updated grammar to include all proposed syntactic forms
boggle Jul 24, 2017
e908196
Update grammar to allow match modes etc without giving a variable name
boggle Jul 24, 2017
dd74857
Reinstated pre-parser suggestions
Jul 25, 2017
f98570c
Add exemplar data graph: used for examples in CIPs
Jul 25, 2017
fce68fa
Clarified relationship of WTP to *morphisms
boggle Jul 26, 2017
40713bb
Add expansive example using data graph
Jul 26, 2017
50e7ac3
Added a detailed example; fix-ups; language changes
Jul 26, 2017
5a8436d
Formatted query headings so they are more readable in default GH view
Jul 26, 2017
08afc88
Added TOC
Jul 26, 2017
efb9fee
Removed Cycles and Circuits for now
boggle Jul 26, 2017
1c39c76
Change to minimize breaking existing queries
boggle Jul 26, 2017
f8c45b4
Update examples to reflect latest changes
boggle Jul 26, 2017
c6b01b5
Textual tidy-ups
Jul 27, 2017
ac72e91
Updated default rules + Moved disjoint back into proposal
boggle Jul 27, 2017
c139130
Reformatted title
Jan 17, 2018
8cb74ae
Updated to reflect recent discussions
boggle Mar 26, 2018
ad333a0
Merge remote-tracking branch 'me/isomatch' into isomatch
boggle Mar 26, 2018
3b4255f
Fix query result blocks
boggle Mar 26, 2018
b74e09e
Clarified DIFFERENT(vars) modifier
boggle Mar 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions cip/1.accepted/CIP2017-01-18-isomorphic-matching.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
= CIP2017-01-18 - Isomorphic Matching Semantics
:numbered:
:toc:
:toc-placement: macro
:source-highlighter: codemirror

*Author:* Stefan Plantikow <stefan.plantikow@neotechnology.com>

This proposal is a response to CIR-2017-174.

=== Proposal: Add new uniqueness modes

It is proposed to add the capability to select one of three uniqueness modes for a uniqueness scope:

* `MATCH ALL`: Impose no uniqueness requirements on candidate matches
* `MATCH UNIQUE RELATIONSHIPS`: Only consider candidate matches that are relationship-unique
* `MATCH UNIQUE NODES`: Only consider candidate matches that are node-unique

The default uniqueness mode used by `MATCH` (without a further specification of the preferred uniqueness mode) is relationship-unique matching.

`MATCH ALL` does not reject any paths - not even paths containing cycles - and hence can lead to infinite result sets for the whole query.
It is recommended that implementations generate at least a warning when static analysis is not able to proof query termination due to the chosen uniqueness mode.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proof -> prove


It is conceivable that this approach for the specification of uniqueness is extensible by adding further ways to restrict uniqueness.

=== Proposal: Specifying the uniqueness mode of a subquery

Changing the uniqueness mode of a sub query recursively changes the default uniqueness mode for all contained `MATCH` clauses unless it is overridden again. Examples:

* `MATCH <uniqueness-modes> { MATCH ... } ...`
* `DO <uniqueness-modes> { MATCH ... } ...`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are MATCH and DO (this is the first time it appears on this repo I think) the two cases where you'd be able to supply these modes? What about MERGE?


=== Proposal: Default uniqueness mode

Additionally, it is proposed that a conforming implementation should provide a pre-parser option for defining a default uniqueness level for use with regular pattern matching.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced this kind of recommendation belongs in a CIP. Is it not well understood that an implementing system would provide ways of changing defaults?


* `unique=nodes` for configuring node-uniqueness as the default for `MATCH`
* `unique=relationships` for configuring relationship-uniqueness as the default for `MATCH`

=== Proposal: Path classes

Graph theory has defined various classes of paths.
Cypher so far only supports a single notion of path.

To improve expressivity and to help preventing the generation of infinite result sets when working with non-unique matches, it is proposed to introduce additional predicates for testing paths:

* `open(p)`: true if the start and the end node of `p` are not the same node
* `closed(p)`: true if the start and the end node of `p` are the same node
* `trail(p)`: true if `p` contains no duplicate relationships
* `simple(p)`: true if `p` contains no duplicate relationships and either no duplicate nodes at all or the start node and the end node are the same node
* `trek(p)`: true if `p` contains two identical consecutive relationships
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does identical mean here? Same rel-type? Same type and properties? Equal?

* `repetetive(p)`: true if `p` contains any closed subpath `q` of `size > 1` that is immediately repeated after itself in `p`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repetitive


Using `repetetive` allows ensuring variable length path matching under no-uniqueness yields a finite result set:

[source, Cypher]
----
MATCH ALL p=(a)-[*]->(b), (b)-[*2..4]->(c) WHERE NOT repetetive(p)
RETURN p
----

Note that these functions naturally extend to lists.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean lists generally, or lists containing only nodes and relationships? I'm not sure I follow; what does trail(list) yielding true mean? That the list is a trail?


Path predicates may be used to further restrict which paths are enumerated by pattern matching.
All uniqueness modes naturally correspond to default path classes:

* Non-uniqueness implies no restrictions on the path class.
* Relationship-uniqueness implies that all matched paths are trails.
* Node-uniqueness implies that all matched paths are simple paths.

== Benefits to this proposal

Cypher is able to express more general classes of patterns.

== Caveats to this proposal

Non-uniqueness allows for non-terminating queries.

A moderate increase in language complexity.