formal specification of cypher
play

Formal Specification of Cypher Nadime Francis University of - PowerPoint PPT Presentation

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


  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 knows since : 2010 Person , Postdoc Person , Professor name : ‘Nadime’ name : ‘Leonid’ institute : ‘UoE’ institute : ‘UoE’ 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 → 2 L : 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 : ( a 1 : v 1 , . . . , a n : v n ). A table is a bag of uniform records. � ( a : 1 , b : 3) , ( a : ‘oCIM 2’ , b : ‘London’ ) , � Example: ( a : ‘oCIM’ , b : ‘Walldorf’ ) , ( a : 1 , b : 3) a b a b 1 3 ‘oCIM’ ‘Walldorf’ = 1 3 ‘oCIM 2’ ‘London’ ‘oCIM’ ‘Walldorf’ ‘oCIM 2’ ‘London’ 1 3 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 ( α ) MATCH ( n : Person ) − [: knows ] − > ( m : Person ) Q = ( β ) 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 ( α ) MATCH ( n : Person ) − [: knows ] − > ( m : Person ) Q = ( β ) WHERE n . institute = m . institute ( γ ) RETURN n . name , m . name , n . institute AS institute Operations ] G : Tables → Tables [ [ op ] Semantics of a query by composition ] G ◦ [ ] G ◦ [ Ex: [ [ Q ] ] 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 ( α ) MATCH ( n : Person ) − [: knows ] − > ( m : Person ) Q = ( β ) WHERE n . institute = m . institute ( γ ) RETURN n . name , m . name , n . institute AS institute Operations ] G : Tables → Tables [ [ op ] Semantics of a query by composition ] G ◦ [ ] G ◦ [ Ex: [ [ Q ] ] G = [ [ α ] [ β ] [ γ ] ] G Answers to Q on G : [ [ Q ] ] G ( {} ) Expressions [ [ exp ] ] G , u ∈ V where u is a record, giving binding to variables � � u ∈ T | [ Ex: [ [ β ] ] G ( 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 u ′ is uniform with free( π ′ , u ) � � � � ( u , u ′ ) � [ [ MATCH π ] ] G ( T ) = � and ( p , G , ( u , u ′ )) | = π ′ � π ′ ∈ rigid( π ) u ∈ T , p ∈ paths 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 { k 1 : v 1 , . . . , k n : v n } = { ℓ 1 : w 1 , . . . , ℓ m : w m } return true , false or null ? { name : null } = {} { a : 1 , b : 2 } = { b : 2 , a : 1 } { name : null } = { name : null } { a : 1 , a : 2 } = { a : 2 } 9 / 16

  20. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases Map Comparisons When does { k 1 : v 1 , . . . , k n : v n } = { ℓ 1 : w 1 , . . . , ℓ m : w m } return true , false or null ? false true { a : 1 , b : 2 } = { b : 2 , a : 1 } { name : null } = {} true true { name : null } = { name : null } { a : 1 , a : 2 } = { a : 2 } Neither purely syntactic, nor ∀ k , m 1 . k = m 2 . 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 () MATCH () RETURN ∗ RETURN 1 11 / 16

  24. Semantics Overview Ambiguous and Edge Cases Incomplete and Inconsistent Cases MATCH with no Free Variables Fail Pass MATCH () MATCH () RETURN ∗ RETURN 1 RETURN ∗ is not allowed with Returns as many copies of 1 no variable in scope. as nodes in the database. After MATCH (), the active table is a bag containing multiple copies of the empty record. 11 / 16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend