SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Downloaden Sie, um offline zu lesen
Cypher.PL
Executable Specification of Cypher
written in Prolog
{jan.posiadala,pawel.susicki}@gmail.com
Cypher.PL
Cypher.PL
â—Ź executable specification
â—Ź of declarative query language (Cypher)
â—Ź in formal declarative language of logic (Prolog)
â—Ź as close to the semantics as possible
â—Ź as far from the implementation issues as possible
â—Ź a tool for collective designing, verification, validation
Why Prolog
Cypher.PL
Prolog's enticements:
â—Ź declarative langauge
â—Ź with built-in unification...
â—Ź ...which is more general than pattern matching
â—Ź super-native data (structures) representation
â—Ź multiple solutions/evident ambiguity
â—Ź easy constraint verification
â—Ź DCG: notation for grammars
â—Ź meta-programming
Nothing New Under The Sun
Cypher.PL
Series of symposiums:
Programming Language Implementation and Logic Programming
Many papers on the topic but most defining
Specifications Are (Preferably) Executable
by Norbert E. Fuchs, Software Engineering Journal, September 1992
and many, many others
Cypher.PL in openCypher ecosystem
Cypher.PL
Cypher.g4
Antlr4ToDCG
TCK features
Cypher Queries
Cypher Grammar
in DCG
Cypher Query
Parse Tree (AST)
Cypher Query
Term Representation
AST to IR (DSL)
compiler
DCG Grammar
of Antlr4
Execution in
Specification
TCK features
Scenarios Results
IR Specification
Syntactic (and semantic) exercise
Cypher.PL
Strictly and evident syntactic and semantic ambiguity of query:
with 1 as x
return [x in [1,2]] as result
Result 1 (the neo4j’s one)
+--------+
| result |
+--------+
| [1,2] |
+--------+
Result 2
+--------------+
| result |
+--------------+
| [true] |
+--------------+
oCIG 67th of SEPTEMBER 2017
Cypher.PL
singleQuery |
|
LIST
____________________________________________|____________________________________________
/ 
clause clause
| |
| |
with return
__________________________________|__________________________________ ___________________________________________|___________________________________________
/ |  / 
no_modifier returnBody no_where no_modifier returnBody
__________________|__________________ _____________________|____________________
/ | |  / | | 
returnItems no_order no_skip no_limit returnItems no_order no_skip no_limit
| |
| |
LIST LIST
| |
| |
returnItem returnItem
______|______ ____________|___________
/  / 
expression variable expression variable
| | | |
| | | |
cypher_integer symbolicName listComprehension symbolicName
| | ____________|____________ |
| | /  |
1 X filterExpression identity _value
_______________|_______________
/ 
idInColl no_where
__________|__________
/ 
variable expression
| |
| |
symbolicName cypher_list
| |
| |
X LIST
_______|______
/ 
expression expression
| |
| |
cypher_integer cypher_integer
| |
| |
1 2
oCIG 67th of SEPTEMBER 2017
Cypher.PL
singleQuery
|
|
LIST
_______________________________________|______________________________________
/ 
clause clause
| |
| |
with return
__________________________________|__________________________________ ________________________________|_______________________________
/ |  / 
no_modifier returnBody no_where no_modifier returnBody
__________________|__________________ _______________________|_______________________
/ | |  / | | 
returnItems no_order no_skip no_limit returnItems no_order no_skip no_limit
| |
| |
LIST LIST
| |
| |
returnItem returnItem
______|______ ________________|________________
/  / 
expression variable expression variable
| | | |
| | | |
cypher_integer symbolicName cypher_list symbolicName
| | | |
| | | |
1 X LIST _value
|
|
expression
|
|
in
__________|__________
/ 
variable cypher_list
| |
| |
symbolicName LIST
| _______|______
| / 
X expression expression
| |
| |
cypher_integer cypher_integer
| |
| |
1 2
#206: On the interpretation of range comparison expressions
1<2=3>4
comparisonExpression([cypher_integer(1), lt, cypher_integer(2), eq, cypher_integer(3), gt, cypher_integer(4)]),
comparisonExpression
|
|
LIST
_____________________________|____________________________
/ | | | | | 
cypher_integer lt cypher_integer eq cypher_integer gt cypher_integer
| | | |
| | | |
1 2 3 4
and
__________________________|_________________________
/ 
binaryTrenaryComparisionExpression and
| _________________|________________
| / 
LIST binaryTrenaryComparisionExpression binaryTrenaryComparisionExpression
_________|________ | |
/ |  | |
cypher_integer lt cypher_integer LIST LIST
| | _________|________ _________|________
| | / |  / | 
1 2 cypher_integer eq cypher_integer cypher_integer gt cypher_integer
| | | |
| | | |
2 3 3 4
binaryTrenaryComparisionExpression
|
|
LIST
___________________|__________________
/ | 
binaryTrenaryComparisionExpression gt cypher_integer
| |
| |
LIST 4
___________________|__________________
/ | | | 
cypher_integer lt cypher_integer eq cypher_integer
| | |
| | |
1 2 3
Thobe
Mats
Intermediate
Representation
Implied group by is neat but, two following queries give (in neo4j) two different
results:
unwind [{a:1,b:2,c:3},{a:2,b:3,c:1},{a:3,b:1,c:2}] as x
return x.a + count(*) + x.b + count(*) + x.c;
Query Results
+----------------------------------------+
| x.a + count(*) + x.b + count(*) + x.c |
+----------------------------------------+
| 8 |
| 8 |
| 8 |
+----------------------------------------+
3 rows
96 ms
unwind [{a:1,b:2,c:3},{a:2,b:3,c:1},{a:3,b:1,c:2}] as x
return x.a + x.b + x.c + count(*) + count(*) ;
Query Results
+----------------------------------------+
| x.a + x.b + x.c + count(*) + count(*) |
+----------------------------------------+
| 12 |
+----------------------------------------+
1 row
77 ms
No adjustment in oC TCK
Cypher.PL use case: implied group by
Cypher.PL
Basic Concepts
Cypher.PL
Basic Cypher.PL concepts:
I. Expression (intermediate representation)
II. Environment
III. Evaluation (partial) of expression in environment
and additionally:
IV. Equivalences on forms of expression
I. Expression
Cypher.PL
Expression:
%definition of expression
%literal value from domain
expression(Value) :- value(Value).
%identifiers
expression(var(Id)) :- string(Id).
%grouping function call: sum, max, count... etc
expression(gc).
%plus operator
expression(plus(X,Y)) :- expression(X),expression(Y).
%times operator
expression(times(X,Y)) :- expression(X),expression(Y).
Domain of values is limited to integers:
value(Value) :- integer(Value).
%expression
plus
__|_
/ 
1 times
_|_
/ 
var gc
|
|
b
II. Environment
Cypher.PL
Mapping between identifiers and values and it is expressed
as pairs of string identifier name and value
%environment as list of pairs
%of string identifier name and value
environment(env(Environment))
:-
maplist(environment_entry,Environment).
environment_entry(EE) :-
EE = (Id,Value),
string(Id),value(Value).
%environment
env
|
|
LIST
_____|____
/ | 
, , ,
| | |
/  /  / 
a 2 b 3 c 1
III. Expression Evaluation in Environment (full)
Cypher.PL
%evaluation of variable
%eval_expression(++Environment,++Expression,-EvaluatedExpression)
eval_expression(env(Environment),Id,Value)
:-
member((Id,Value),Environment),!.
%out environment exception
eval_expression(_,Id,_) :- string(Id),throw(out_of_environment),!.
%identity evaluation of literal value
eval_expression(_,X,X) :- value(Value).
%full recursive evaluation of plus operator
eval_expression(Environment,plus(X,Y),E) :-
eval_expression(Environment,X,EX),value(EX),
eval_expression(Environment,Y,EY),value(EY),
E is EX + EY,!.
%for multiplication analogously
Expression Evaluation in Environment (partial)
Cypher.PL
%identity evaluation of literal value
eval_expression(_,gc,gc).
%partial evaluation of operator (plus, times)
eval_expression(Environment,T,ET) :-
%operator term decomposition
T =.. [TN|Args], % plus(times(3,2),gc) =.. [plus | [times(3,2), gc] ]
%evaluation on operator arguments
maplist(eval_expression(Environment),Args,EArgs),
%operator term recomposition
ET =.. [TN|EArgs], plus(6,gc) =.. [plus | [6, gc] ]
!.
plus
__|_
/ 
times gc
|
/ 
3 2
plus
_|
/ 
6 gc
IV. Equivalences on forms of expression
Cypher.PL
%Expression equivalence is reflexive, symmetric, transitive
ex_equivalence(A,A).
ex_equivalence(A,B) :- ex_equivalence(B,A).
ex_equivalence(A,C) :- ex_equivalence(A,B),ex_equivalence(B,C).
%Operator properties we want to preserve
%plus commutativity
ex_equivalence(plus(X,Y),plus(Y,X)).
%plus associativity
ex_equivalence(plus(plus(X,Y),Z),plus(X,plus(Y,Z))).
%times commutativity
ex_equivalence(times(X,Y),times(Y,X)).
%times associativity
ex_equivalence(times(times(X,Y),Z),times(X,times(Y,Z))).
%plus/times distributivity
ex_equivalence(times(plus(X,Y),Z),plus(times(X,Z),times(Y,Z))).
Operators properties to be preserved plus plus
| |
/  / 
X Y Y X
plus plus
_|_ _|
/  / 
plus Z X plus
| |
/  / 
X Y Y Z
times plus
_|_ __|__
/  / 
plus Z times times
| | |
/  /  / 
X Y X Z Y Z
Grouping Definition
Cypher.PL
%grouping Environments list with respect
%to value of Expression evaluated in environment
cypher_gr_by(Expression,Environments,EnvironmentsGroups)
:-
gr_by(env_equality(Expression),Environments,EnvironmentsGroups).
%test equality of pair of environment
%by comparing partial evaluation of equivalent form of expression
env_equality(Expression,Environment1,Environment2) :-
%generates all possible equivalent form of expression
mapterm(ex_equivalence,Expression,EquivalentExpression),
%test equality of (partial) evaluation in both environments
eval_expression(Environment1,EquivalentExpression,Value),
eval_expression(Environment2,EquivalentExpression,Value).
Example: Query 1
Cypher.PL
unwind [{a:1,b:2,c:3},{a:3,b:1,c:2},{a:2,b:3,c:1}] as x
with x.a as a, x.b as b, x.c as c
return a + count(*) + b + count(*) + c
%environment
LIST
_________________|________________
/ | 
env env env
| | |
| | |
LIST LIST LIST
_____|____ _____|____ _____|____
/ |  / |  / | 
, , , , , , , , ,
| | | | | | | | |
/  /  /  /  /  /  /  /  / 
a 1 b 2 c 3 a 3 b 1 c 2 a 2 b 3 c 1
%expression
plus
___|__
/ 
var plus
| __|__
| / 
a gc plus
__|__
/ 
var plus
| _|
| / 
b gc var
|
|
c
Example: Query 1
Cypher.PL
%equivalent expression form
plus
__|__
/ 
gc plus
__|__
/ 
gc plus
__|__
/ 
var plus
| _|_
| / 
b var var
| |
| |
c a
%value of equivalent expression form
plus
_|_
/ 
gc plus
|
/ 
gc 6
Example: Query 1
Cypher.PL
%therefore the result is one group
LIST
|
|
LIST
_________________|________________
/ | 
env env env
| | |
| | |
LIST LIST LIST
_____|____ _____|____ _____|____
/ |  / |  / | 
, , , , , , , , ,
| | | | | | | | |
/  /  /  /  /  /  /  /  / 
a 2 b 3 c 1 a 3 b 1 c 2 a 1 b 2 c 3
Example: Query 2
Cypher.PL
unwind [{a:1,b:2,c:3},{a:3,b:1,c:2},{a:2,b:3,c:1}] as x
with x.a as a, x.b as b, x.c as c
return a + b + c + count(*) + count(*)
%expression
plus
___|___
/ 
var plus
| ___|__
| / 
a var plus
| __|__
| / 
b var plus
| _|
| / 
c gc gc
%equivalent expression form
plus
__|__
/ 
gc plus
__|__
/ 
gc plus
__|__
/ 
var plus
| _|_
| / 
a var var
| |
| |
b c
%value of equivalent
%expression form
plus
_|_
/ 
gc plus
|
/ 
gc 6
Cypher.PL: Database
Cypher.PL
%Property graph model facts
node(NodeId) %V
relationship(RelationshipId,NodeStartId,NodeEndId) %E,st
label(NodeId,LabelName) %L,l
type(RelationshipId,RelationshipType) %T,t
nodeProperty(Id,Key,Value) %Pv,D
relationshipProperty(Id,Key,Value) %Pe,D
%Asserting/Retracting PGM facts
%create_node(-NodeId:integer)
create_node(NodeId)
%set_label(++NodeId:integer, --LabelName)
set_label(NodeId,LabelName)
%remove_label(++NodeId:integer, ++LabelName)
remove_label(NodeId,LabelName)
%create_relationship(++NodeStartId:integer,++NodeEndId:integer,RelationshipType,--RelationshipId:integer)
create_relationship(NodeStartId,NodeEndId,RelationshipType,RelationshipId)
%delete_relationship(--RelationshipId:integer)
delete_relationship(RelationshipId)
%set_property(++Id:integer,++Key,++Value)
set_node_property(Id,Key,Value)
set_relationship_property(Id,Key,Value)
%remove_property(++Id:integer,++Key)
remove_node_property(Id,Key)
remove_relationship_property(Id,Key)
Cypher.PL: Core
Cypher.PL
Environment:
environment(env(Environment))
:-
maplist(environment_entry,Environment).
environment_entry(bind(Name,Value))
:-
variable_name(Name),cypher_value(Value).
%entities: cypher_node, cypher_relationship, cypher_path
%primitives: cypher_string, cypher_integer, cypher_float, cypher_boolean,
%structures: cypher_list (recursive), cypher_map (recursive)
Query evaluation: folding of subsequent clause evaluations:
%foldl(:Goal, +List, +V0, -V)
foldl(eval_clause, Clauses, [env([])], ResultEnvironment).
% eval_clause(++Clause:clause,++Environments:list,-ReturnEnvironments:list)
%True if ReturnEnvironments are evaluation of Claused in Environments
eval_clause(Clause,Environments,ReturnEnvironments)
Feedfront: Intermediate Representation
Cypher.PL
Machine-oriented
â—Ź Verbose
â—Ź Explicit
â—Ź Unambiguous
Planner-friendly
â—Ź Minimal ordering constraints
â—Ź Unique variable names
â—Ź Human-friendly
Mainly for debugging, not a primary goal
cypher(statement(query(regularQuery(singleQuery([clause(with(no_modifier,returnBody(returnItems([returnItem(expression(cypher_int
eger(1)),variable(symbolicName('X')))]),no_order,no_skip,no_limit),no_where)),clause(return(no_modifier,returnBody(returnItems([retur
nItem(expression(listComprehension(filterExpression(idInColl(variable(symbolicName('X')),expression(cypher_list([expression(cypher_
integer(1)),expression(cypher_integer(2))]))),no_where),identity)),variable(symbolicName('_value')))]),no_order,no_skip,no_limit)))]),[]))
),[])
Feedfront: Intermediate Representation
Cypher.PL
Simple model for query planner
â—Ź grounded in property graph model
â—Ź easy formal treatment
Point of collaboration between implementers
â—Ź language agnostic
â—Ź engine agnostic
â—Ź discuss impact of language changes / extensions
Summary: Cypher.PL features...
Cypher.PL
readability, declarativeness, explicitness, consistency, comparability,
easiness of branching, easiness of versioning, evolvability, meatiness,
pithiness, preciseness, easiness of (remote!) thoughts exchange
(collective thinking), closeness to mathematical formalism,
language/engine agnostic, verifiability, validatablity, executability
...as an oC artifact of type fourth - Cypher Language Specification
Q&A
Cypher.PL
The general question to the oC community and to the oC leaders:
Is such executable specification of Cypher a desired artifact of openCypher?
Leading question:
Is there a current issue (CIR/CIP) to be executively specified in Cypher.PL as grouping issue to
make collaborative thinking easier?

Weitere ähnliche Inhalte

Was ist angesagt?

R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examplesDennis
 
R programming language
R programming languageR programming language
R programming languageAlberto Minetti
 
R learning by examples
R learning by examplesR learning by examples
R learning by examplesMichelle Darling
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlSway Wang
 
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsPython Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsRanel Padon
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)Logan Palanisamy
 
Functional programming from its fundamentals
Functional programming from its fundamentalsFunctional programming from its fundamentals
Functional programming from its fundamentalsMauro Palsgraaf
 
Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'Philip Schwarz
 
Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Lucas Witold Adamus
 
Recursion part 2
Recursion part 2Recursion part 2
Recursion part 2Keerty Smile
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsPhilip Schwarz
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4Saranya saran
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with RShareThis
 
R Workshop for Beginners
R Workshop for BeginnersR Workshop for Beginners
R Workshop for BeginnersMetamarkets
 
Scala. Introduction to FP. Monads
Scala. Introduction to FP. MonadsScala. Introduction to FP. Monads
Scala. Introduction to FP. MonadsKirill Kozlov
 
statistical computation using R- an intro..
statistical computation using R- an intro..statistical computation using R- an intro..
statistical computation using R- an intro..Kamarudheen KV
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programmingizahn
 
Fp in scala with adts part 2
Fp in scala with adts part 2Fp in scala with adts part 2
Fp in scala with adts part 2Hang Zhao
 

Was ist angesagt? (20)

R programming intro with examples
R programming intro with examplesR programming intro with examples
R programming intro with examples
 
R programming language
R programming languageR programming language
R programming language
 
R learning by examples
R learning by examplesR learning by examples
R learning by examples
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Python Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular ExpressionsPython Programming - XI. String Manipulation and Regular Expressions
Python Programming - XI. String Manipulation and Regular Expressions
 
Language R
Language RLanguage R
Language R
 
SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)SQL for pattern matching (Oracle 12c)
SQL for pattern matching (Oracle 12c)
 
Functional programming from its fundamentals
Functional programming from its fundamentalsFunctional programming from its fundamentals
Functional programming from its fundamentals
 
Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'
 
Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?
 
Recursion part 2
Recursion part 2Recursion part 2
Recursion part 2
 
Monoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and CatsMonoids - Part 1 - with examples using Scalaz and Cats
Monoids - Part 1 - with examples using Scalaz and Cats
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Monad Fact #2
Monad Fact #2Monad Fact #2
Monad Fact #2
 
Data analysis with R
Data analysis with RData analysis with R
Data analysis with R
 
R Workshop for Beginners
R Workshop for BeginnersR Workshop for Beginners
R Workshop for Beginners
 
Scala. Introduction to FP. Monads
Scala. Introduction to FP. MonadsScala. Introduction to FP. Monads
Scala. Introduction to FP. Monads
 
statistical computation using R- an intro..
statistical computation using R- an intro..statistical computation using R- an intro..
statistical computation using R- an intro..
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
Fp in scala with adts part 2
Fp in scala with adts part 2Fp in scala with adts part 2
Fp in scala with adts part 2
 

Ă„hnlich wie Cypher.PL: Executable Specification of Cypher written in Prolog

Cypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsCypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsopenCypher
 
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...openCypher
 
Functional programming in ruby
Functional programming in rubyFunctional programming in ruby
Functional programming in rubyKoen Handekyn
 
Procedure Typing for Scala
Procedure Typing for ScalaProcedure Typing for Scala
Procedure Typing for Scalaakuklev
 
Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Soham Kulkarni
 
Ejercicios de estilo en la programaciĂłn
Ejercicios de estilo en la programaciĂłnEjercicios de estilo en la programaciĂłn
Ejercicios de estilo en la programaciĂłnSoftware Guru
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structuresPradipta Mishra
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures Pradipta Mishra
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed worldDebasish Ghosh
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Peng Cheng
 
Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014alex_perry
 
Loops and functions in r
Loops and functions in rLoops and functions in r
Loops and functions in rmanikanta361
 
Learning with classification and clustering, neural networks
Learning with classification and clustering, neural networksLearning with classification and clustering, neural networks
Learning with classification and clustering, neural networksShaun D'Souza
 
Perm winter school 2014.01.31
Perm winter school 2014.01.31Perm winter school 2014.01.31
Perm winter school 2014.01.31Vyacheslav Arbuzov
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java ProgrammersEric Pederson
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesGábor Szárnyas
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesopenCypher
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 

Ă„hnlich wie Cypher.PL: Executable Specification of Cypher written in Prolog (20)

Cypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semanticsCypher.PL: an executable specification of Cypher semantics
Cypher.PL: an executable specification of Cypher semantics
 
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
Future features for openCypher: Schema, Constraints, Subqueries, Configurable...
 
Functional programming in ruby
Functional programming in rubyFunctional programming in ruby
Functional programming in ruby
 
An Intoduction to R
An Intoduction to RAn Intoduction to R
An Intoduction to R
 
Procedure Typing for Scala
Procedure Typing for ScalaProcedure Typing for Scala
Procedure Typing for Scala
 
Compiler Construction for DLX Processor
Compiler Construction for DLX Processor Compiler Construction for DLX Processor
Compiler Construction for DLX Processor
 
Ejercicios de estilo en la programaciĂłn
Ejercicios de estilo en la programaciĂłnEjercicios de estilo en la programaciĂłn
Ejercicios de estilo en la programaciĂłn
 
Introduction to programming c and data structures
Introduction to programming c and data structuresIntroduction to programming c and data structures
Introduction to programming c and data structures
 
Introduction to programming c and data-structures
Introduction to programming c and data-structures Introduction to programming c and data-structures
Introduction to programming c and data-structures
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed world
 
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
Shape Safety in Tensor Programming is Easy for a Theorem Prover -SBTB 2021
 
Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014Regular expressions, Alex Perry, Google, PyCon2014
Regular expressions, Alex Perry, Google, PyCon2014
 
Loops and functions in r
Loops and functions in rLoops and functions in r
Loops and functions in r
 
Learning with classification and clustering, neural networks
Learning with classification and clustering, neural networksLearning with classification and clustering, neural networks
Learning with classification and clustering, neural networks
 
Perm winter school 2014.01.31
Perm winter school 2014.01.31Perm winter school 2014.01.31
Perm winter school 2014.01.31
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Dafunctor
DafunctorDafunctor
Dafunctor
 

Mehr von openCypher

Learning Timed Automata with Cypher
Learning Timed Automata with CypherLearning Timed Automata with Cypher
Learning Timed Automata with CypheropenCypher
 
Formal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesFormal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesopenCypher
 
Multiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsMultiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsopenCypher
 
Micro-Servicing Linked Data
Micro-Servicing Linked DataMicro-Servicing Linked Data
Micro-Servicing Linked DataopenCypher
 
Graph abstraction
Graph abstractionGraph abstraction
Graph abstractionopenCypher
 
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...openCypher
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for GremlinopenCypher
 
Comparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypherComparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypheropenCypher
 
Multiple graphs in openCypher
Multiple graphs in openCypherMultiple graphs in openCypher
Multiple graphs in openCypheropenCypher
 
Eighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateEighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateopenCypher
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for GremlinopenCypher
 
Supporting dates and times in Cypher
Supporting dates and times in CypherSupporting dates and times in Cypher
Supporting dates and times in CypheropenCypher
 
Seventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateSeventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateopenCypher
 
Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...openCypher
 
Property Graphs with Time
Property Graphs with TimeProperty Graphs with Time
Property Graphs with TimeopenCypher
 
Use case: processing multiple graphs
Use case: processing multiple graphsUse case: processing multiple graphs
Use case: processing multiple graphsopenCypher
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher
 
Cypher Editor in the Web
Cypher Editor in the WebCypher Editor in the Web
Cypher Editor in the WebopenCypher
 
The inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesThe inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesopenCypher
 
Formal Specification of Cypher
Formal Specification of CypherFormal Specification of Cypher
Formal Specification of CypheropenCypher
 

Mehr von openCypher (20)

Learning Timed Automata with Cypher
Learning Timed Automata with CypherLearning Timed Automata with Cypher
Learning Timed Automata with Cypher
 
Formal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updatesFormal semantics for Cypher queries and updates
Formal semantics for Cypher queries and updates
 
Multiple Graphs: Updatable Views
Multiple Graphs: Updatable ViewsMultiple Graphs: Updatable Views
Multiple Graphs: Updatable Views
 
Micro-Servicing Linked Data
Micro-Servicing Linked DataMicro-Servicing Linked Data
Micro-Servicing Linked Data
 
Graph abstraction
Graph abstractionGraph abstraction
Graph abstraction
 
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
From Cypher 9 to GQL: Conceptual overview of multiple named graphs and compos...
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for Gremlin
 
Comparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and CypherComparing PGQL, G-Core and Cypher
Comparing PGQL, G-Core and Cypher
 
Multiple graphs in openCypher
Multiple graphs in openCypherMultiple graphs in openCypher
Multiple graphs in openCypher
 
Eighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status UpdateEighth openCypher Implementers Group Meeting: Status Update
Eighth openCypher Implementers Group Meeting: Status Update
 
Cypher for Gremlin
Cypher for GremlinCypher for Gremlin
Cypher for Gremlin
 
Supporting dates and times in Cypher
Supporting dates and times in CypherSupporting dates and times in Cypher
Supporting dates and times in Cypher
 
Seventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status UpdateSeventh openCypher Implementers Group Meeting: Status Update
Seventh openCypher Implementers Group Meeting: Status Update
 
Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...Academic research on graph processing: connecting recent findings to industri...
Academic research on graph processing: connecting recent findings to industri...
 
Property Graphs with Time
Property Graphs with TimeProperty Graphs with Time
Property Graphs with Time
 
Use case: processing multiple graphs
Use case: processing multiple graphsUse case: processing multiple graphs
Use case: processing multiple graphs
 
openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)openCypher Technology Compatibility Kit (TCK)
openCypher Technology Compatibility Kit (TCK)
 
Cypher Editor in the Web
Cypher Editor in the WebCypher Editor in the Web
Cypher Editor in the Web
 
The inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queriesThe inGraph project and incremental evaluation of Cypher queries
The inGraph project and incremental evaluation of Cypher queries
 
Formal Specification of Cypher
Formal Specification of CypherFormal Specification of Cypher
Formal Specification of Cypher
 

KĂĽrzlich hochgeladen

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel AraĂşjo
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

KĂĽrzlich hochgeladen (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Cypher.PL: Executable Specification of Cypher written in Prolog

  • 1. Cypher.PL Executable Specification of Cypher written in Prolog {jan.posiadala,pawel.susicki}@gmail.com
  • 2. Cypher.PL Cypher.PL â—Ź executable specification â—Ź of declarative query language (Cypher) â—Ź in formal declarative language of logic (Prolog) â—Ź as close to the semantics as possible â—Ź as far from the implementation issues as possible â—Ź a tool for collective designing, verification, validation
  • 3. Why Prolog Cypher.PL Prolog's enticements: â—Ź declarative langauge â—Ź with built-in unification... â—Ź ...which is more general than pattern matching â—Ź super-native data (structures) representation â—Ź multiple solutions/evident ambiguity â—Ź easy constraint verification â—Ź DCG: notation for grammars â—Ź meta-programming
  • 4. Nothing New Under The Sun Cypher.PL Series of symposiums: Programming Language Implementation and Logic Programming Many papers on the topic but most defining Specifications Are (Preferably) Executable by Norbert E. Fuchs, Software Engineering Journal, September 1992 and many, many others
  • 5. Cypher.PL in openCypher ecosystem Cypher.PL Cypher.g4 Antlr4ToDCG TCK features Cypher Queries Cypher Grammar in DCG Cypher Query Parse Tree (AST) Cypher Query Term Representation AST to IR (DSL) compiler DCG Grammar of Antlr4 Execution in Specification TCK features Scenarios Results IR Specification
  • 6. Syntactic (and semantic) exercise Cypher.PL Strictly and evident syntactic and semantic ambiguity of query: with 1 as x return [x in [1,2]] as result Result 1 (the neo4j’s one) +--------+ | result | +--------+ | [1,2] | +--------+ Result 2 +--------------+ | result | +--------------+ | [true] | +--------------+
  • 7. oCIG 67th of SEPTEMBER 2017 Cypher.PL singleQuery | | LIST ____________________________________________|____________________________________________ / clause clause | | | | with return __________________________________|__________________________________ ___________________________________________|___________________________________________ / | / no_modifier returnBody no_where no_modifier returnBody __________________|__________________ _____________________|____________________ / | | / | | returnItems no_order no_skip no_limit returnItems no_order no_skip no_limit | | | | LIST LIST | | | | returnItem returnItem ______|______ ____________|___________ / / expression variable expression variable | | | | | | | | cypher_integer symbolicName listComprehension symbolicName | | ____________|____________ | | | / | 1 X filterExpression identity _value _______________|_______________ / idInColl no_where __________|__________ / variable expression | | | | symbolicName cypher_list | | | | X LIST _______|______ / expression expression | | | | cypher_integer cypher_integer | | | | 1 2
  • 8. oCIG 67th of SEPTEMBER 2017 Cypher.PL singleQuery | | LIST _______________________________________|______________________________________ / clause clause | | | | with return __________________________________|__________________________________ ________________________________|_______________________________ / | / no_modifier returnBody no_where no_modifier returnBody __________________|__________________ _______________________|_______________________ / | | / | | returnItems no_order no_skip no_limit returnItems no_order no_skip no_limit | | | | LIST LIST | | | | returnItem returnItem ______|______ ________________|________________ / / expression variable expression variable | | | | | | | | cypher_integer symbolicName cypher_list symbolicName | | | | | | | | 1 X LIST _value | | expression | | in __________|__________ / variable cypher_list | | | | symbolicName LIST | _______|______ | / X expression expression | | | | cypher_integer cypher_integer | | | | 1 2
  • 9. #206: On the interpretation of range comparison expressions 1<2=3>4 comparisonExpression([cypher_integer(1), lt, cypher_integer(2), eq, cypher_integer(3), gt, cypher_integer(4)]), comparisonExpression | | LIST _____________________________|____________________________ / | | | | | cypher_integer lt cypher_integer eq cypher_integer gt cypher_integer | | | | | | | | 1 2 3 4 and __________________________|_________________________ / binaryTrenaryComparisionExpression and | _________________|________________ | / LIST binaryTrenaryComparisionExpression binaryTrenaryComparisionExpression _________|________ | | / | | | cypher_integer lt cypher_integer LIST LIST | | _________|________ _________|________ | | / | / | 1 2 cypher_integer eq cypher_integer cypher_integer gt cypher_integer | | | | | | | | 2 3 3 4 binaryTrenaryComparisionExpression | | LIST ___________________|__________________ / | binaryTrenaryComparisionExpression gt cypher_integer | | | | LIST 4 ___________________|__________________ / | | | cypher_integer lt cypher_integer eq cypher_integer | | | | | | 1 2 3 Thobe Mats Intermediate Representation
  • 10. Implied group by is neat but, two following queries give (in neo4j) two different results: unwind [{a:1,b:2,c:3},{a:2,b:3,c:1},{a:3,b:1,c:2}] as x return x.a + count(*) + x.b + count(*) + x.c; Query Results +----------------------------------------+ | x.a + count(*) + x.b + count(*) + x.c | +----------------------------------------+ | 8 | | 8 | | 8 | +----------------------------------------+ 3 rows 96 ms unwind [{a:1,b:2,c:3},{a:2,b:3,c:1},{a:3,b:1,c:2}] as x return x.a + x.b + x.c + count(*) + count(*) ; Query Results +----------------------------------------+ | x.a + x.b + x.c + count(*) + count(*) | +----------------------------------------+ | 12 | +----------------------------------------+ 1 row 77 ms No adjustment in oC TCK Cypher.PL use case: implied group by Cypher.PL
  • 11. Basic Concepts Cypher.PL Basic Cypher.PL concepts: I. Expression (intermediate representation) II. Environment III. Evaluation (partial) of expression in environment and additionally: IV. Equivalences on forms of expression
  • 12. I. Expression Cypher.PL Expression: %definition of expression %literal value from domain expression(Value) :- value(Value). %identifiers expression(var(Id)) :- string(Id). %grouping function call: sum, max, count... etc expression(gc). %plus operator expression(plus(X,Y)) :- expression(X),expression(Y). %times operator expression(times(X,Y)) :- expression(X),expression(Y). Domain of values is limited to integers: value(Value) :- integer(Value). %expression plus __|_ / 1 times _|_ / var gc | | b
  • 13. II. Environment Cypher.PL Mapping between identifiers and values and it is expressed as pairs of string identifier name and value %environment as list of pairs %of string identifier name and value environment(env(Environment)) :- maplist(environment_entry,Environment). environment_entry(EE) :- EE = (Id,Value), string(Id),value(Value). %environment env | | LIST _____|____ / | , , , | | | / / / a 2 b 3 c 1
  • 14. III. Expression Evaluation in Environment (full) Cypher.PL %evaluation of variable %eval_expression(++Environment,++Expression,-EvaluatedExpression) eval_expression(env(Environment),Id,Value) :- member((Id,Value),Environment),!. %out environment exception eval_expression(_,Id,_) :- string(Id),throw(out_of_environment),!. %identity evaluation of literal value eval_expression(_,X,X) :- value(Value). %full recursive evaluation of plus operator eval_expression(Environment,plus(X,Y),E) :- eval_expression(Environment,X,EX),value(EX), eval_expression(Environment,Y,EY),value(EY), E is EX + EY,!. %for multiplication analogously
  • 15. Expression Evaluation in Environment (partial) Cypher.PL %identity evaluation of literal value eval_expression(_,gc,gc). %partial evaluation of operator (plus, times) eval_expression(Environment,T,ET) :- %operator term decomposition T =.. [TN|Args], % plus(times(3,2),gc) =.. [plus | [times(3,2), gc] ] %evaluation on operator arguments maplist(eval_expression(Environment),Args,EArgs), %operator term recomposition ET =.. [TN|EArgs], plus(6,gc) =.. [plus | [6, gc] ] !. plus __|_ / times gc | / 3 2 plus _| / 6 gc
  • 16. IV. Equivalences on forms of expression Cypher.PL %Expression equivalence is reflexive, symmetric, transitive ex_equivalence(A,A). ex_equivalence(A,B) :- ex_equivalence(B,A). ex_equivalence(A,C) :- ex_equivalence(A,B),ex_equivalence(B,C). %Operator properties we want to preserve %plus commutativity ex_equivalence(plus(X,Y),plus(Y,X)). %plus associativity ex_equivalence(plus(plus(X,Y),Z),plus(X,plus(Y,Z))). %times commutativity ex_equivalence(times(X,Y),times(Y,X)). %times associativity ex_equivalence(times(times(X,Y),Z),times(X,times(Y,Z))). %plus/times distributivity ex_equivalence(times(plus(X,Y),Z),plus(times(X,Z),times(Y,Z))). Operators properties to be preserved plus plus | | / / X Y Y X plus plus _|_ _| / / plus Z X plus | | / / X Y Y Z times plus _|_ __|__ / / plus Z times times | | | / / / X Y X Z Y Z
  • 17. Grouping Definition Cypher.PL %grouping Environments list with respect %to value of Expression evaluated in environment cypher_gr_by(Expression,Environments,EnvironmentsGroups) :- gr_by(env_equality(Expression),Environments,EnvironmentsGroups). %test equality of pair of environment %by comparing partial evaluation of equivalent form of expression env_equality(Expression,Environment1,Environment2) :- %generates all possible equivalent form of expression mapterm(ex_equivalence,Expression,EquivalentExpression), %test equality of (partial) evaluation in both environments eval_expression(Environment1,EquivalentExpression,Value), eval_expression(Environment2,EquivalentExpression,Value).
  • 18. Example: Query 1 Cypher.PL unwind [{a:1,b:2,c:3},{a:3,b:1,c:2},{a:2,b:3,c:1}] as x with x.a as a, x.b as b, x.c as c return a + count(*) + b + count(*) + c %environment LIST _________________|________________ / | env env env | | | | | | LIST LIST LIST _____|____ _____|____ _____|____ / | / | / | , , , , , , , , , | | | | | | | | | / / / / / / / / / a 1 b 2 c 3 a 3 b 1 c 2 a 2 b 3 c 1 %expression plus ___|__ / var plus | __|__ | / a gc plus __|__ / var plus | _| | / b gc var | | c
  • 19. Example: Query 1 Cypher.PL %equivalent expression form plus __|__ / gc plus __|__ / gc plus __|__ / var plus | _|_ | / b var var | | | | c a %value of equivalent expression form plus _|_ / gc plus | / gc 6
  • 20. Example: Query 1 Cypher.PL %therefore the result is one group LIST | | LIST _________________|________________ / | env env env | | | | | | LIST LIST LIST _____|____ _____|____ _____|____ / | / | / | , , , , , , , , , | | | | | | | | | / / / / / / / / / a 2 b 3 c 1 a 3 b 1 c 2 a 1 b 2 c 3
  • 21. Example: Query 2 Cypher.PL unwind [{a:1,b:2,c:3},{a:3,b:1,c:2},{a:2,b:3,c:1}] as x with x.a as a, x.b as b, x.c as c return a + b + c + count(*) + count(*) %expression plus ___|___ / var plus | ___|__ | / a var plus | __|__ | / b var plus | _| | / c gc gc %equivalent expression form plus __|__ / gc plus __|__ / gc plus __|__ / var plus | _|_ | / a var var | | | | b c %value of equivalent %expression form plus _|_ / gc plus | / gc 6
  • 22. Cypher.PL: Database Cypher.PL %Property graph model facts node(NodeId) %V relationship(RelationshipId,NodeStartId,NodeEndId) %E,st label(NodeId,LabelName) %L,l type(RelationshipId,RelationshipType) %T,t nodeProperty(Id,Key,Value) %Pv,D relationshipProperty(Id,Key,Value) %Pe,D %Asserting/Retracting PGM facts %create_node(-NodeId:integer) create_node(NodeId) %set_label(++NodeId:integer, --LabelName) set_label(NodeId,LabelName) %remove_label(++NodeId:integer, ++LabelName) remove_label(NodeId,LabelName) %create_relationship(++NodeStartId:integer,++NodeEndId:integer,RelationshipType,--RelationshipId:integer) create_relationship(NodeStartId,NodeEndId,RelationshipType,RelationshipId) %delete_relationship(--RelationshipId:integer) delete_relationship(RelationshipId) %set_property(++Id:integer,++Key,++Value) set_node_property(Id,Key,Value) set_relationship_property(Id,Key,Value) %remove_property(++Id:integer,++Key) remove_node_property(Id,Key) remove_relationship_property(Id,Key)
  • 23. Cypher.PL: Core Cypher.PL Environment: environment(env(Environment)) :- maplist(environment_entry,Environment). environment_entry(bind(Name,Value)) :- variable_name(Name),cypher_value(Value). %entities: cypher_node, cypher_relationship, cypher_path %primitives: cypher_string, cypher_integer, cypher_float, cypher_boolean, %structures: cypher_list (recursive), cypher_map (recursive) Query evaluation: folding of subsequent clause evaluations: %foldl(:Goal, +List, +V0, -V) foldl(eval_clause, Clauses, [env([])], ResultEnvironment). % eval_clause(++Clause:clause,++Environments:list,-ReturnEnvironments:list) %True if ReturnEnvironments are evaluation of Claused in Environments eval_clause(Clause,Environments,ReturnEnvironments)
  • 24. Feedfront: Intermediate Representation Cypher.PL Machine-oriented â—Ź Verbose â—Ź Explicit â—Ź Unambiguous Planner-friendly â—Ź Minimal ordering constraints â—Ź Unique variable names â—Ź Human-friendly Mainly for debugging, not a primary goal cypher(statement(query(regularQuery(singleQuery([clause(with(no_modifier,returnBody(returnItems([returnItem(expression(cypher_int eger(1)),variable(symbolicName('X')))]),no_order,no_skip,no_limit),no_where)),clause(return(no_modifier,returnBody(returnItems([retur nItem(expression(listComprehension(filterExpression(idInColl(variable(symbolicName('X')),expression(cypher_list([expression(cypher_ integer(1)),expression(cypher_integer(2))]))),no_where),identity)),variable(symbolicName('_value')))]),no_order,no_skip,no_limit)))]),[])) ),[])
  • 25. Feedfront: Intermediate Representation Cypher.PL Simple model for query planner â—Ź grounded in property graph model â—Ź easy formal treatment Point of collaboration between implementers â—Ź language agnostic â—Ź engine agnostic â—Ź discuss impact of language changes / extensions
  • 26. Summary: Cypher.PL features... Cypher.PL readability, declarativeness, explicitness, consistency, comparability, easiness of branching, easiness of versioning, evolvability, meatiness, pithiness, preciseness, easiness of (remote!) thoughts exchange (collective thinking), closeness to mathematical formalism, language/engine agnostic, verifiability, validatablity, executability ...as an oC artifact of type fourth - Cypher Language Specification
  • 27. Q&A Cypher.PL The general question to the oC community and to the oC leaders: Is such executable specification of Cypher a desired artifact of openCypher? Leading question: Is there a current issue (CIR/CIP) to be executively specified in Cypher.PL as grouping issue to make collaborative thinking easier?