SlideShare ist ein Scribd-Unternehmen logo
1 von 127
Downloaden Sie, um offline zu lesen
Learning Timed Automata with Cypher
Gábor Szárnyas, Rebeka Farkas, Márton Elekes, Anna Gujgiczer
Budapest Neo4j Meetup 13 February 2018
Sicco Verwer, Mathijs de Weerdt, Cees Witteveen:
An algorithm for learning real-time automata.
Benelearn 2007
Automaton learning
STATE MACHINE
Off
Stop
Continue
Prepare
Go
switchPhase
switchPhase
switch
Phase
onOff
onOff
onOff onOff
onOff
switch
Phase
switch
Phase
STATE MACHINE
Off
Stop
Continue
Prepare
Go
switchPhase
switchPhase
switch
Phase
onOff
onOff
onOff onOff
onOff
switch
Phase
switch
Phase
AUTOMATON
 States: accepting/rejecting
 Run: (finite) event sequence
 Accepted run:
ends in an accepting state
 Modelled behaviour:
accepted runsOff
Stop
Continue
Prepare
Go
switchPhase
switchPhase
switch
Phase
onOff
onOff
onOff onOff
onOff
switch
Phase
switch
Phase
AUTOMATON
 States: accepting/rejecting
 Run: (finite) event sequence
 Accepted run:
ends in an accepting state
 Modelled behaviour:
accepted runsOff
Stop
Continue
Prepare
Go
switchPhase
switchPhase
switch
Phase
onOff
onOff
onOff onOff
onOff
switch
Phase
+
- -
- -
switch
Phase
TIMING
 Time spent in a state
 Guard condition: an interval
Off
Stop
Continue
Prepare
Go
switchPhase
switchPhase
switch
Phase
onOff
onOff
onOff onOff
onOff
switch
Phase
+
- -
- -
switch
Phase
TIMING
 Time spent in a state
 Guard condition: an interval
Off
Stop
Continue
Prepare
Go
switchPhase
switchPhase
switch
Phase
onOff
onOff
onOff onOff
onOff
switch
Phase
+
- -
- -
[3,5]
[30,35]
[1,2]
switch
Phase
[30,35]
[0,∞]
[0,∞]
[0,∞]
[0,∞]
[0,∞]
[0,∞]
AUTOMATON LEARNING
 System: unknown internal implementation (black box)
 Goal: determine the internal operation of the system
(~reverse engineering)
 Approach: observation  runs  automaton
 Application: monitor synthesis, testing
AUTOMATON LEARNING: THE BASICS
+
-
-
+
a,1
a,5
+
a,3
a,5 a,7
a,2
+ -
a,[1,2]
+
a,[1,5]
+
a,[3,5]
-
a,[1,5]
+ -
a, [1,2]
a,[1,2]
a, [3,5] a, [3,5]
AUTOMATON LEARNING: AN ALGORITHM
 Repeating three operations
o Split inconsistent states
+ -
a,[1,2]
+
a,[1,5]
+
a,[3,5]
-
a,[1,5]
+ +/-
a,[1,5]
+/-
a,[1,5]
+
-
-
+
a,1
a,5
+
a,3
a,5 a,7
a,2
AUTOMATON LEARNING: AN ALGORITHM
 Repeating three operations
o Split inconsistent states
o Merge similar states
-
-
b
+
+
a
a
-b
+
+
a
a
-b +
a
AUTOMATON LEARNING: AN ALGORITHM
 Repeating three operations
o Split inconsistent states
o Merge similar states
o Color to finalise a state
 Selecting an operation
o Using metrics based on the result
of the operation
 Operations have to be executed
Select operation
Split Merge Color
Implementation
INTERESTING QUERIES
 How to select a “longest path”
o i.e. a maximal path that cannot be extended further
o Use WHERE NOT
 Merge
o Transitive closure for the states to-be-merged
 Split: categorisation/copying subtrees
o Merge might result in multiple origNext edges
o Which one to use for categorisation?
WHERE NOT «PATTERN»
 Finding the end of a path
WHERE NOT (v)-[:Next]->()
:Next :Next
… …v :Next
WHERE NOT «PATTERN»
 Finding the end of a path
WHERE NOT (v)-[:Next]->()
:Next :Next
… …v :Next
WHERE NOT «PATTERN»
 Finding the end of a path
 Finding the beginning of a path
WHERE NOT (v)-[:Next]->()
WHERE NOT ()-[:Next]->(root)
:Next :Next
… …:Next
root
WHERE NOT «PATTERN»
 Finding the end of a path
 Finding the beginning of a path
WHERE NOT (v)-[:Next]->()
WHERE NOT ()-[:Next]->(root)
:Next :Next
… …:Next
root
WHERE NOT «PATTERN»
 Finding the end of a path
 Finding the beginning of a path
 These two can be used to select the complete path
WHERE NOT (v)-[:Next]->()
WHERE NOT ()-[:Next]->(root)
:Next :Next
… …:Next
root
MERGE
:indexPair :indexPair
-
-:Next
:Next
+
+
:Next
:Next
…
…
:indexPair
-:Next
+:Next
…
 Select states to merge
 Calculate metrics
 Filter inconsistencies
 Return result
MERGE +
-
:indexPair
:indexPair
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
:indexPair
:indexPair
+
-:Next
:Next
MERGE +
-
:indexPair
:indexPair
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
:indexPair
:indexPair
+
-:Next
:Next
while (driver.run(createIndexPairs, mergeMap))
MERGE +
-
:indexPair
:indexPair
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
:indexPair
:indexPair
+
-:Next
:Next
MATCH (s1:IndexedMerge)-[:IndexPair*..]-(s2:IndexedMerge),
s1p = (s1)-[:Next*0..]->(s12:State), s2p = (s2)-[:Next*0..]->(s22:State)
WHERE id(s1) > id(s2) AND length(s1p) = length(s2p)
AND NOT (s12)-[:IndexPair*0..]-(s22)
WITH s12, s22, s1p, s2p,[s1r IN rels(s1p) | s1r.symbol] AS s1ss, [s2r IN rels(s2p) | s2r.symbol] AS s2ss,
[s1r IN rels(s1p) | s1r.Tmin] AS s1mins, [s2r IN rels(s2p) | s2r.Tmin ] AS s2mins,
[s1r IN rels(s1p) | s1r.Tmax] AS s1maxs, [s2r IN rels(s2p) | s2r.Tmax ] AS s2maxs
WHERE s1ss = s2ss AND s1mins = s2mins AND s1maxs = s2maxs
WITH collect([s12, s22]) as pairs
MATCH ()-[ip:IndexPair]->()
WITH max(ip.index) + 1 as nextIndex, pairs
UNWIND range(0, length(pairs)-1) as idx
WITH pairs[idx][0] as s12, pairs[idx][1] as s22, idx + nextIndex as edgeIndex
CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22)
SET s12:IndexedMerge, s22:IndexedMerge
while (driver.run(createIndexPairs, mergeMap))
MERGE +
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Next
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
MERGE
MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge),
s1p = (s1)-[:Next*0..]->(s12:State),
s2p = (s2)-[:Next*0..]->(s22:State)
WHERE id(s1) > id(s2) AND length(s1p) = length(s2p)
AND NOT (s12)-[:IndexPair*0..]-(s22)
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Next
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
MERGE
MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge),
s1p = (s1)-[:Next*0..]->(s12:State),
s2p = (s2)-[:Next*0..]->(s22:State)
WHERE id(s1) > id(s2) AND length(s1p) = length(s2p)
AND NOT (s12)-[:IndexPair*0..]-(s22)
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Next
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
Find critical state pairs
MERGE
MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge),
s1p = (s1)-[:Next*0..]->(s12:State),
s2p = (s2)-[:Next*0..]->(s22:State)
WHERE id(s1) > id(s2) AND length(s1p) = length(s2p)
AND NOT (s12)-[:IndexPair*0..]-(s22)
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Next
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
s1 s1
s2 s2
Find critical state pairs
MERGE
MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge),
s1p = (s1)-[:Next*0..]->(s12:State),
s2p = (s2)-[:Next*0..]->(s22:State)
WHERE id(s1) > id(s2) AND length(s1p) = length(s2p)
AND NOT (s12)-[:IndexPair*0..]-(s22)
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Next
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
s1 s1
s2 s2
WITH s12, s22, s1p, s2p,
[s1r IN rels(s1p) | s1r.symbol] AS s1ss, [s2r IN rels(s2p) | s2r.symbol] AS s2ss,
[s1r IN rels(s1p) | s1r.Tmin] AS s1mins, [s2r IN rels(s2p) | s2r.Tmin ] AS s2mins,
[s1r IN rels(s1p) | s1r.Tmax] AS s1maxs, [s2r IN rels(s2p) | s2r.Tmax ] AS s2maxs
WHERE s1ss = s2ss AND s1mins = s2mins AND s1maxs = s2maxs
...
Find critical state pairs
MERGE
MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge),
s1p = (s1)-[:Next*0..]->(s12:State),
s2p = (s2)-[:Next*0..]->(s22:State)
WHERE id(s1) > id(s2) AND length(s1p) = length(s2p)
AND NOT (s12)-[:IndexPair*0..]-(s22)
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Next
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
s1 s1
s2 s2
WITH s12, s22, s1p, s2p,
[s1r IN rels(s1p) | s1r.symbol] AS s1ss, [s2r IN rels(s2p) | s2r.symbol] AS s2ss,
[s1r IN rels(s1p) | s1r.Tmin] AS s1mins, [s2r IN rels(s2p) | s2r.Tmin ] AS s2mins,
[s1r IN rels(s1p) | s1r.Tmax] AS s1maxs, [s2r IN rels(s2p) | s2r.Tmax ] AS s2maxs
WHERE s1ss = s2ss AND s1mins = s2mins AND s1maxs = s2maxs
...
• Paths of same length,
• Event sequences of same
lengths, etc.
Find critical state pairs
MERGE
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Nexts1 s1
s2 s2
MERGE
CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22)
SET s12:IndexedMerge, s22:IndexedMerge
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Nexts1 s1
s2 s2
MERGE
CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22)
SET s12:IndexedMerge, s22:IndexedMerge
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Nexts1 s1
s2 s2
Mark newly found
index pairs
MERGE
CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22)
SET s12:IndexedMerge, s22:IndexedMerge
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Nexts1 s1
s2 s2
:indexPair :indexPair
Mark newly found
index pairs
MERGE
CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22)
SET s12:IndexedMerge, s22:IndexedMerge
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Nexts1 s1
s2 s2
:indexPair :indexPair
Mark newly found
index pairs
while (driver.run(createIndexPairs, mergeMap))
MERGE
CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22)
SET s12:IndexedMerge, s22:IndexedMerge
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Nexts1 s1
s2 s2
:indexPair :indexPair
Mark newly found
index pairs
while (driver.run(createIndexPairs, mergeMap))
Repeatedly called from
Java code until fixpoint
MERGE
CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22)
SET s12:IndexedMerge, s22:IndexedMerge
 Problem:
o Inconsistencies can be transitive
 Solution:
o Variable length path
+
-
:indexPair
:indexPair
:indexPair
:indexPair
+
-:Next
:Nexts1 s1
s2 s2
:indexPair :indexPair
Mark newly found
index pairs
while (driver.run(createIndexPairs, mergeMap))
Repeatedly called from
Java code until fixpoint
SPLIT
:Origin
:Origin
:Origin
:Origin
[1,6]
1
6
 Splits an edge
 Based on timestamp: t
o Original transition
 The two endpoints…
o Smaller: < t
o Larger: ≥ t
2
:Origin :Origin
+
+
-
+/-
SPLIT
:Origin
:Origin
:Origin
:Origin
[1,6]
1
6
2
:Origin :Origin
 Splits an edge
 Based on timestamp: 5
o Original transition
 The two endpoints…
o Smaller: < t
o Larger: ≥ t
+
+
-
+/-
SPLIT
 Splits an edge
 Based on timestamp: 5
o Original transition
 The two endpoints…
o Smaller: < t
o Larger: ≥ t
 Results
[1,4]
[5,6]
+
-
SPLIT
 Problem
o Node a is a result of an earlier
merge operation
o The subtree regenerated from
node b should belong to the…
• Larger subtree because of 6
• Smaller subtree because of 1
:Origin
:Origin :Origin
[1,6]
1
6
b
6
:Origin :Origin
…
a
 Solution
o “Shortest” path to node a
o Based on the last number: 6
SPLIT
:Origin
:Origin :Origin
[1,6]
1
6
b
6
:Origin :Origin
…
a
SPLIT
MATCH (r:Red)-[n:Next]->(b:Blue)
WITH r, b, n.Tmax as Tmax, n.Tmin as Tmin, n.symbol as symbol
UNWIND range(Tmin, Tmax-1) AS t
MATCH (b)-[:Next*0..]->(s1:State)-[:Origin]->(so1:OrigState), trace1=(so1)<-[OrigNext*0..]-(redOrigNext:OrigState), (redOrigNext)<-[no1:OrigNext]-(redOrig:OrigState)<-[:Origin]-(r)
WHERE none(x IN nodes(trace1) WHERE (x)<-[:Origin]-(r))
WITH r, b, t, Tmin, Tmax, symbol, s1, no1, so1
MATCH (b)-[:Next*0..]->(s2:State)-[:Origin]->(so2:OrigState), trace2=(so2)<-[OrigNext*0..]-(redOrigNext:OrigState), (redOrigNext)<-[no2:OrigNext]-(redOrig:OrigState)<-[:Origin]-(r)
WHERE none(x IN nodes(trace2) WHERE (x)<-[:Origin]-(r))
WITH t, r, b, s1, s2, toInteger(no1.time)>t as cat1, toInteger(no2.time)>t as cat2, Tmin, Tmax, symbol, so1, so2
WHERE s1 = s2
AND cat1 <> cat2
AND id(so1) < id(so2)
WITH r, b, t, Tmin, Tmax, symbol,
[coalesce(so1.accepting, false), coalesce(so1.rejecting, false)] AS so1ar,
[coalesce(so2.accepting, false), coalesce(so2.rejecting, false)] AS so2ar
WITH
r, b, t, Tmin, Tmax, symbol,
CASE
WHEN so1ar[0] <> so2ar[0] AND so1ar[1] <> so2ar[1] THEN 1
WHEN so1ar = so2ar AND (so1ar = [false, true] OR so1ar = [true, false]) THEN -1 // there is at least one true
ELSE 0
END AS score
WITH r, b, t, sum(score) AS metric, Tmin, Tmax, symbol
ORDER BY metric DESC
LIMIT 1
WITH r, b, t, metric, Tmin, Tmax, symbol
MATCH (b)-[:Next*0..]->(s1:State)-[:Origin]->(so1:OrigState), trace1=(so1)<-[OrigNext*0..]-(redOrigNext:OrigState), (redOrigNext)<-[no1:OrigNext]-(redOrig:OrigState)<-[:Origin]-(r)
WHERE none(x IN nodes(trace1) WHERE (x)<-[:Origin]-(r)) AND toInteger(no1.time)>t
WITH r, b, t, metric, Tmin, Tmax, symbol, collect(so1) as so1s
MATCH (b)-[:Next*0..]->(s2:State)-[:Origin]->(so2:OrigState), trace2=(so2)<-[OrigNext*0..]-(redOrigNext:OrigState), (redOrigNext)<-[no2:OrigNext]-(redOrig:OrigState)<-[:Origin]-(r)
WHERE none(x IN nodes(trace2) WHERE (x)<-[:Origin]-(r)) AND toInteger(no2.time)<=t
RETURN r, b, t, metric, Tmin, Tmax, symbol, so1s, collect(so2) as so2s
SPLIT
:Origin
:Origin :Origin
[1,6]
1
6
6
:Origin :Origin
…
a s2
ao
an
b
 Solution
o “Shortest” path to node a
o Based on the last number: 6
MATCH
(a)-[:Next*0..]->(s2:State)-[:Origin]->(b:OrigState),
trace=(b)<-[OrigNext*0..]-(an:OrigState),
(an)<-[no:OrigNext]-(ao:OrigState)<-[:Origin]-(a)
The split candidate in
the original runs
SPLIT
The split candidate in
the original runs
:Origin
:Origin :Origin
[1,6]
1
6
6
:Origin :Origin
…ao
a
an
s2
b
MATCH
(a)-[:Next*0..]->(s2:State)-[:Origin]->(b:OrigState),
trace=(b)<-[OrigNext*0..]-(an:OrigState),
(an)<-[no:OrigNext]-(ao:OrigState)<-[:Origin]-(a)
 Solution
o “Shortest” path to node a
o Based on the last number: 6
SPLIT
WHERE none(x IN nodes(trace) WHERE (x)<-[:Origin]-(a))
The shortest possible trail, i.e.
a node, from which node a can
only be reached directly.
 Solution
o “Shortest” path to node a
o Based on the last number: 6
:Origin
:Origin :Origin
[1,6]
1
6
6
:Origin :Origin
…
a s2
ao
b
an
MATCH
(a)-[:Next*0..]->(s2:State)-[:Origin]->(b:OrigState),
trace=(b)<-[OrigNext*0..]-(an:OrigState),
(an)<-[no:OrigNext]-(ao:OrigState)<-[:Origin]-(a)
Technical details
 Visualisation
ADVANTAGES OF NEO4J
 Visualisation
 Flexible data model
o New labels, properties
o No need to define the schema upfront
ADVANTAGES OF NEO4J
 Visualisation
 Flexible data model
o New labels, properties
o No need to define the schema upfront
 Cypher: high-level declarative graph query language
ADVANTAGES OF NEO4J
WORKFLOW
 Neo4j web browser UI
WORKFLOW
MATCH (n)
RETURN n
 Neo4j web browser UI
WORKFLOW
MATCH (n)
RETURN n
 Neo4j web browser UI
WORKFLOW
 Neo4j web browser UI
WORKFLOW
 Neo4j web browser UI
WORKFLOW
 Neo4j web browser UI
WORKFLOW
 Neo4j web browser UI
We should combine
transformation and
visualisation
WORKFLOW
 Neo4j web browser UI
We should combine
transformation and
visualisation
WORKFLOW
 Neo4j web browser UI
We should combine
transformation and
visualisation
WORKFLOW
 Neo4j web browser UI
We should combine
transformation and
visualisation
WORKFLOW
 Neo4j web browser UI
We should combine
transformation and
visualisation
CHAINING QUERIES
 Chaining queries to write a complex step of the algorithm
with a single Cypher query
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
RETURN *
node
:Red {prop1: "val1"}
:Red {prop1: "val2"}
CHAINING QUERIES
 Chaining queries to write a complex step of the algorithm
with a single Cypher query
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
RETURN *
node
:Red {prop1: "val1"}
:Red {prop1: "val2"}
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH 1 AS dummy
RETURN *
dummy
1
1
CHAINING QUERIES
 Chaining queries to write a complex step of the algorithm
with a single Cypher query
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
RETURN *
node
:Red {prop1: "val1"}
:Red {prop1: "val2"}
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH 1 AS dummy
RETURN *
dummy
1
1
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH 1 AS dummy
MATCH (n)
RETURN *
node dummy
:Red {prop1: "val1"} 1
:Red {prop1: "val2"} 1
:Green {value: 13} 1
:Red {prop1: "val1"} 1
:Red {prop1: "val2"} 1
:Green {value: 13} 1
CHAINING QUERIES
 Chaining queries to write a complex step of the algorithm
with a single Cypher query
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
RETURN *
node
:Red {prop1: "val1"}
:Red {prop1: "val2"}
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH 1 AS dummy
RETURN *
dummy
1
1
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH 1 AS dummy
MATCH (n)
RETURN *
node dummy
:Red {prop1: "val1"} 1
:Red {prop1: "val2"} 1
:Green {value: 13} 1
:Red {prop1: "val1"} 1
:Red {prop1: "val2"} 1
:Green {value: 13} 1
Cartesian product
 all rows are
displayed twice
CHAINING QUERIES
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
RETURN *
node
:Red {prop1: "val1"}
:Red {prop1: "val2"}
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH count(*) as dummy
RETURN *
dummy
2
 Chaining queries to write a complex step of the algorithm
with a single Cypher query
CHAINING QUERIES
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
RETURN *
node
:Red {prop1: "val1"}
:Red {prop1: "val2"}
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH count(*) as dummy
RETURN *
dummy
2
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH count(*) as dummy
MATCH (n)
RETURN *
node dummy
:Red {prop1: "val1"} 2
:Red {prop1: "val2"} 2
:Green {value: 13} 2
 Chaining queries to write a complex step of the algorithm
with a single Cypher query
CHAINING QUERIES
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
RETURN *
node
:Red {prop1: "val1"}
:Red {prop1: "val2"}
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH count(*) as dummy
RETURN *
dummy
2
MATCH (node:Blue)
REMOVE node:Blue
SET node:Red
WITH count(*) as dummy
MATCH (n)
RETURN *
node dummy
:Red {prop1: "val1"} 2
:Red {prop1: "val2"} 2
:Green {value: 13} 2
Exactly 1 result
 The second query will not
produce unnecessary
duplicates
 Chaining queries to write a complex step of the algorithm
with a single Cypher query
RUNNING AND VISUALISING THE ALGORITHM
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
RUNNING AND VISUALISING THE ALGORITHM
...
WITH count(*) as dummy
MATCH (n)
RETURN n
EXECUTING QUERIES
Passing information between queries:
EXECUTING QUERIES
Passing information between queries:
 Node labels
EXECUTING QUERIES
Passing information between queries:
 Node labels
 Nodes with temporary information
EXECUTING QUERIES
Passing information between queries:
 Node labels
 Nodes with temporary information
 Passing nodes/edges as parameters
(only supported in embedded mode)
EXECUTING QUERIES
Passing information between queries:
 Node labels
 Nodes with temporary information
 Passing nodes/edges as parameters
(only supported in embedded mode)
redNode num
:Red {prop1: "val1"} 1
EXECUTING QUERIES
Passing information between queries:
 Node labels
 Nodes with temporary information
 Passing nodes/edges as parameters
(only supported in embedded mode)
redNode num
:Red {prop1: "val1"} 1
Exactly
1 result
EXECUTING QUERIES
Passing information between queries:
 Node labels
 Nodes with temporary information
 Passing nodes/edges as parameters
(only supported in embedded mode)
redNode num
:Red {prop1: "val1"} 1
WITH $redNode AS redNode
MATCH (g:Green {num: $num})
CREATE (redNode)-[:Edge]->(g)
Exactly
1 result
LOOPS
 Many loop-like problems can be solved using lists:
o List comprehensions: [x IN xs WHERE condition | f(x)]
o Reduce: reduce(acc = "", x IN list | acc + x.prop)
LOOPS
 Many loop-like problems can be solved using lists:
o List comprehensions: [x IN xs WHERE condition | f(x)]
o Reduce: reduce(acc = "", x IN list | acc + x.prop)
 However, loops still might be necessary:
o Run queries from Java code
gds.execute(step1Query);
gds.execute(step2Query);
LOOPS
 Many loop-like problems can be solved using lists:
o List comprehensions: [x IN xs WHERE condition | f(x)]
o Reduce: reduce(acc = "", x IN list | acc + x.prop)
 However, loops still might be necessary:
o Run queries from Java code
o The loop condition checks the number of rows in the result
while (gds.execute(conditionQuery).hasNext()) {
gds.execute(step1Query);
gds.execute(step2Query);
}
IMPORT-EXPORT
 Save current state of the algorithm
IMPORT-EXPORT
 Save current state of the algorithm
 APOC* GraphML import-export
*Awesome Procedures on Cypher
IMPORT-EXPORT
 Save current state of the algorithm
 APOC* GraphML import-export
*Awesome Procedures on Cypher
// save
CALL apoc.export.graphml.all('my.graphml',
{storeNodeIds:true, readLabels:true, useTypes:true})
IMPORT-EXPORT
 Save current state of the algorithm
 APOC* GraphML import-export
*Awesome Procedures on Cypher
// save
CALL apoc.export.graphml.all('my.graphml',
{storeNodeIds:true, readLabels:true, useTypes:true})
// load
MATCH (n) // delete all
DETACH DELETE n
WITH count(*) AS dummy //-----------------
CALL apoc.import.graphml('my.graphml',
{storeNodeIds:true, readLabels:true, useTypes:true})
YIELD nodes, relationships
WITH count(*) AS dummy //-----------------
MATCH (n) RETURN n // show all
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm ?
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm ?
Metrics:
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm ?
Metrics: 5
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm ?
Metrics: 5 12
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm ?
Metrics: 5 12 8
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm ?
Metrics: 5 12 8
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm
 Solutions:
o Export -> Re-import
o Use transactions:
?
Metrics: 5 12 8
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm
 Solutions:
o Export -> Re-import
o Use transactions:
• Abort transaction
?
Metrics: 5 12 8
BACKTRACKING
 In many cases, we need to restore a previous
state and continue from that one
o Next step is based on metrics in the algorithm
 Solutions:
o Export -> Re-import
o Use transactions:
• Abort transaction
• Only applicable to one level of backtracking
?
Metrics: 5 12 8
DEBUGGING
 Save and play back the states that occurred during execution
DEBUGGING
 Save and play back the states that occurred during execution
o A counter for the states is stored in a node
DEBUGGING
 Save and play back the states that occurred during execution
o A counter for the states is stored in a node
o Saved query to step back
DEBUGGING
 Save and play back the states that occurred during execution
o A counter for the states is stored in a node
o Saved query to step back
DEBUGGING
 Save and play back the states that occurred during execution
o A counter for the states is stored in a node
o Saved query to step back
DEBUGGING
 For complex errors
DEBUGGING
 For complex errors
o Formulate an error pattern in Cypher
MATCH (node:Faulty)
RETURN node
DEBUGGING
 For complex errors
o Formulate an error pattern in Cypher
o Use this to define a breakpoint in the code
MATCH (node:Faulty)
RETURN node
if (gds.execute(query).hasNext())
// breakpoint
DEBUGGING
 For complex errors
o Formulate an error pattern in Cypher
o Use this to define a breakpoint in the code
o Load the state where
the error occurred
o Debug step by step
MATCH (node:Faulty)
RETURN node
if (gds.execute(query).hasNext())
// breakpoint
Lessons learnt
Sicco Verwer:
Efficient identification of timed automata.
PhD disszertáció
PSEUDOCODE
Sicco Verwer:
Efficient identification of timed automata.
PhD disszertáció
PSEUDOCODE
Sicco Verwer:
Efficient identification of timed automata.
PhD disszertáció
PSEUDOCODE
Sicco Verwer:
Efficient identification of timed automata.
PhD disszertáció
PSEUDOCODE
Sicco Verwer:
Efficient identification of timed automata.
PhD disszertáció
PSEUDOCODE
EXPRESSIVE POWER OF CYPHER
 Most graph queries can be decided in polynomial time (P)
 Checking whether two disjoint paths exist is NP-complete
 Cypher is Turing-complete
o List comprehensions, reduce
o The graph can be used to store the tape of the Turing machine
 Cypher 9 (current version)
 Cypher 10 (multiple graph support)
SUMMARY
 Neo4j prototype
o Rapid development
o Lots of APOC procedures for specific problems (e.g. mergeNodes)
 Issues
o APOC bug (hangs after)
o Visualisation glitches
o Lack of fixpoint algorithms
 For graph algorithms, we’d recommend to
o create a prototype in Neo4j,
o once the algorithm is understood, rewrite it in imperative code.
OUR TEAM
Thanks to: Oszkár Semeráth, Tamás Tóth, András Vörös
ACKNOWLEDGEMENTS
 This work partially supported by the ÚNKP-17-1-I. grant by
the Ministry of Human Capacities.
 The advisors were partially supported by the MTA-BME
Lendület Cyber-Physical Systems Research Group.
Ω

Weitere ähnliche Inhalte

Ähnlich wie Learning Timed Automata with Cypher

Learning Timed Automata with Cypher
Learning Timed Automata with CypherLearning Timed Automata with Cypher
Learning Timed Automata with CypheropenCypher
 
Compiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark CatalystCompiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark CatalystGábor Szárnyas
 
Parallel sorting algorithm
Parallel sorting algorithmParallel sorting algorithm
Parallel sorting algorithmRicha Kumari
 
Session 13 - Single Source Shortest Path Method.pptx
Session 13 - Single Source Shortest Path Method.pptxSession 13 - Single Source Shortest Path Method.pptx
Session 13 - Single Source Shortest Path Method.pptxSATHWIKCHAKRI
 
Documento de acrobat2
Documento de acrobat2Documento de acrobat2
Documento de acrobat2fraytuck
 
ingraph: Live Queries on Graphs
ingraph: Live Queries on Graphs ingraph: Live Queries on Graphs
ingraph: Live Queries on Graphs Neo4j
 
SICP勉強会について
SICP勉強会についてSICP勉強会について
SICP勉強会についてYusuke Sasaki
 
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdfDKTaxation
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve CryptographyJorgeVillamarin5
 
Introduction To PostGIS
Introduction To PostGISIntroduction To PostGIS
Introduction To PostGISmleslie
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageWayne Tsai
 
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...Austin Benson
 
Filter design and simulation
Filter design and simulationFilter design and simulation
Filter design and simulationSandesh Agrawal
 
When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)Sylvain Hallé
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?jonbodner
 
Megadata With Python and Hadoop
Megadata With Python and HadoopMegadata With Python and Hadoop
Megadata With Python and Hadoopryancox
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor ConcurrencyAlex Miller
 
Incremental Graph Queries for Cypher
Incremental Graph Queries for CypherIncremental Graph Queries for Cypher
Incremental Graph Queries for CypheropenCypher
 

Ähnlich wie Learning Timed Automata with Cypher (20)

Learning Timed Automata with Cypher
Learning Timed Automata with CypherLearning Timed Automata with Cypher
Learning Timed Automata with Cypher
 
Compiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark CatalystCompiling openCypher graph queries with Spark Catalyst
Compiling openCypher graph queries with Spark Catalyst
 
Parallel sorting algorithm
Parallel sorting algorithmParallel sorting algorithm
Parallel sorting algorithm
 
Session 13 - Single Source Shortest Path Method.pptx
Session 13 - Single Source Shortest Path Method.pptxSession 13 - Single Source Shortest Path Method.pptx
Session 13 - Single Source Shortest Path Method.pptx
 
Documento de acrobat2
Documento de acrobat2Documento de acrobat2
Documento de acrobat2
 
ingraph: Live Queries on Graphs
ingraph: Live Queries on Graphs ingraph: Live Queries on Graphs
ingraph: Live Queries on Graphs
 
SICP勉強会について
SICP勉強会についてSICP勉強会について
SICP勉強会について
 
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
01-05-2023, SOL_DU_MBAFT_6202_Dijkstra’s Algorithm Dated 1st May 23.pdf
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
 
Introduction To PostGIS
Introduction To PostGISIntroduction To PostGIS
Introduction To PostGIS
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usage
 
Lifting 1
Lifting 1Lifting 1
Lifting 1
 
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
QR Factorizations and SVDs for Tall-and-skinny Matrices in MapReduce Architec...
 
Filter design and simulation
Filter design and simulationFilter design and simulation
Filter design and simulation
 
When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)When RV Meets CEP (RV 2016 Tutorial)
When RV Meets CEP (RV 2016 Tutorial)
 
Go Says WAT?
Go Says WAT?Go Says WAT?
Go Says WAT?
 
Groovy
GroovyGroovy
Groovy
 
Megadata With Python and Hadoop
Megadata With Python and HadoopMegadata With Python and Hadoop
Megadata With Python and Hadoop
 
Actor Concurrency
Actor ConcurrencyActor Concurrency
Actor Concurrency
 
Incremental Graph Queries for Cypher
Incremental Graph Queries for CypherIncremental Graph Queries for Cypher
Incremental Graph Queries for Cypher
 

Mehr von Gábor Szárnyas

GraphBLAS: A linear algebraic approach for high-performance graph queries
GraphBLAS: A linear algebraic approach for high-performance graph queriesGraphBLAS: A linear algebraic approach for high-performance graph queries
GraphBLAS: A linear algebraic approach for high-performance graph queriesGábor Szárnyas
 
What Makes Graph Queries Difficult?
What Makes Graph Queries Difficult?What Makes Graph Queries Difficult?
What Makes Graph Queries Difficult?Gábor Szárnyas
 
Mapping Graph Queries to PostgreSQL
Mapping Graph Queries to PostgreSQLMapping Graph Queries to PostgreSQL
Mapping Graph Queries to PostgreSQLGábor Szárnyas
 
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...Gá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 QueriesGábor Szárnyas
 
Writing a Cypher Engine in Clojure
Writing a Cypher Engine in ClojureWriting a Cypher Engine in Clojure
Writing a Cypher Engine in ClojureGábor Szárnyas
 
Időzített automatatanulás Cypherrel
Időzített automatatanulás CypherrelIdőzített automatatanulás Cypherrel
Időzített automatatanulás CypherrelGábor Szárnyas
 
Towards the Characterization of Realistic Models: Evaluation of Multidiscipli...
Towards the Characterization of Realistic Models: Evaluation of Multidiscipli...Towards the Characterization of Realistic Models: Evaluation of Multidiscipli...
Towards the Characterization of Realistic Models: Evaluation of Multidiscipli...Gábor Szárnyas
 
Sharded Joins for Scalable Incremental Graph Queries
Sharded Joins for Scalable Incremental Graph QueriesSharded Joins for Scalable Incremental Graph Queries
Sharded Joins for Scalable Incremental Graph QueriesGábor Szárnyas
 
Towards a Macrobenchmark Framework for Performance Analysis of Java Applications
Towards a Macrobenchmark Framework for Performance Analysis of Java ApplicationsTowards a Macrobenchmark Framework for Performance Analysis of Java Applications
Towards a Macrobenchmark Framework for Performance Analysis of Java ApplicationsGábor Szárnyas
 
IncQuery-D: Distributed Incremental Graph Queries
IncQuery-D: Distributed Incremental Graph QueriesIncQuery-D: Distributed Incremental Graph Queries
IncQuery-D: Distributed Incremental Graph QueriesGábor Szárnyas
 
IncQuery-D: Incremental Queries in the Cloud
IncQuery-D: Incremental Queries in the CloudIncQuery-D: Incremental Queries in the Cloud
IncQuery-D: Incremental Queries in the CloudGábor Szárnyas
 

Mehr von Gábor Szárnyas (13)

GraphBLAS: A linear algebraic approach for high-performance graph queries
GraphBLAS: A linear algebraic approach for high-performance graph queriesGraphBLAS: A linear algebraic approach for high-performance graph queries
GraphBLAS: A linear algebraic approach for high-performance graph queries
 
What Makes Graph Queries Difficult?
What Makes Graph Queries Difficult?What Makes Graph Queries Difficult?
What Makes Graph Queries Difficult?
 
Mapping Graph Queries to PostgreSQL
Mapping Graph Queries to PostgreSQLMapping Graph Queries to PostgreSQL
Mapping Graph Queries to PostgreSQL
 
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
An early look at the LDBC Social Network Benchmark's Business Intelligence wo...
 
Incremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher QueriesIncremental View Maintenance for openCypher Queries
Incremental View Maintenance for openCypher Queries
 
Writing a Cypher Engine in Clojure
Writing a Cypher Engine in ClojureWriting a Cypher Engine in Clojure
Writing a Cypher Engine in Clojure
 
Időzített automatatanulás Cypherrel
Időzített automatatanulás CypherrelIdőzített automatatanulás Cypherrel
Időzített automatatanulás Cypherrel
 
Parsing process
Parsing processParsing process
Parsing process
 
Towards the Characterization of Realistic Models: Evaluation of Multidiscipli...
Towards the Characterization of Realistic Models: Evaluation of Multidiscipli...Towards the Characterization of Realistic Models: Evaluation of Multidiscipli...
Towards the Characterization of Realistic Models: Evaluation of Multidiscipli...
 
Sharded Joins for Scalable Incremental Graph Queries
Sharded Joins for Scalable Incremental Graph QueriesSharded Joins for Scalable Incremental Graph Queries
Sharded Joins for Scalable Incremental Graph Queries
 
Towards a Macrobenchmark Framework for Performance Analysis of Java Applications
Towards a Macrobenchmark Framework for Performance Analysis of Java ApplicationsTowards a Macrobenchmark Framework for Performance Analysis of Java Applications
Towards a Macrobenchmark Framework for Performance Analysis of Java Applications
 
IncQuery-D: Distributed Incremental Graph Queries
IncQuery-D: Distributed Incremental Graph QueriesIncQuery-D: Distributed Incremental Graph Queries
IncQuery-D: Distributed Incremental Graph Queries
 
IncQuery-D: Incremental Queries in the Cloud
IncQuery-D: Incremental Queries in the CloudIncQuery-D: Incremental Queries in the Cloud
IncQuery-D: Incremental Queries in the Cloud
 

Kürzlich hochgeladen

Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 

Kürzlich hochgeladen (20)

Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 

Learning Timed Automata with Cypher

  • 1. Learning Timed Automata with Cypher Gábor Szárnyas, Rebeka Farkas, Márton Elekes, Anna Gujgiczer Budapest Neo4j Meetup 13 February 2018
  • 2. Sicco Verwer, Mathijs de Weerdt, Cees Witteveen: An algorithm for learning real-time automata. Benelearn 2007
  • 6. AUTOMATON  States: accepting/rejecting  Run: (finite) event sequence  Accepted run: ends in an accepting state  Modelled behaviour: accepted runsOff Stop Continue Prepare Go switchPhase switchPhase switch Phase onOff onOff onOff onOff onOff switch Phase switch Phase
  • 7. AUTOMATON  States: accepting/rejecting  Run: (finite) event sequence  Accepted run: ends in an accepting state  Modelled behaviour: accepted runsOff Stop Continue Prepare Go switchPhase switchPhase switch Phase onOff onOff onOff onOff onOff switch Phase + - - - - switch Phase
  • 8. TIMING  Time spent in a state  Guard condition: an interval Off Stop Continue Prepare Go switchPhase switchPhase switch Phase onOff onOff onOff onOff onOff switch Phase + - - - - switch Phase
  • 9. TIMING  Time spent in a state  Guard condition: an interval Off Stop Continue Prepare Go switchPhase switchPhase switch Phase onOff onOff onOff onOff onOff switch Phase + - - - - [3,5] [30,35] [1,2] switch Phase [30,35] [0,∞] [0,∞] [0,∞] [0,∞] [0,∞] [0,∞]
  • 10. AUTOMATON LEARNING  System: unknown internal implementation (black box)  Goal: determine the internal operation of the system (~reverse engineering)  Approach: observation  runs  automaton  Application: monitor synthesis, testing
  • 11. AUTOMATON LEARNING: THE BASICS + - - + a,1 a,5 + a,3 a,5 a,7 a,2 + - a,[1,2] + a,[1,5] + a,[3,5] - a,[1,5] + - a, [1,2] a,[1,2] a, [3,5] a, [3,5]
  • 12. AUTOMATON LEARNING: AN ALGORITHM  Repeating three operations o Split inconsistent states + - a,[1,2] + a,[1,5] + a,[3,5] - a,[1,5] + +/- a,[1,5] +/- a,[1,5] + - - + a,1 a,5 + a,3 a,5 a,7 a,2
  • 13. AUTOMATON LEARNING: AN ALGORITHM  Repeating three operations o Split inconsistent states o Merge similar states - - b + + a a -b + + a a -b + a
  • 14. AUTOMATON LEARNING: AN ALGORITHM  Repeating three operations o Split inconsistent states o Merge similar states o Color to finalise a state  Selecting an operation o Using metrics based on the result of the operation  Operations have to be executed Select operation Split Merge Color
  • 16. INTERESTING QUERIES  How to select a “longest path” o i.e. a maximal path that cannot be extended further o Use WHERE NOT  Merge o Transitive closure for the states to-be-merged  Split: categorisation/copying subtrees o Merge might result in multiple origNext edges o Which one to use for categorisation?
  • 17. WHERE NOT «PATTERN»  Finding the end of a path WHERE NOT (v)-[:Next]->() :Next :Next … …v :Next
  • 18. WHERE NOT «PATTERN»  Finding the end of a path WHERE NOT (v)-[:Next]->() :Next :Next … …v :Next
  • 19. WHERE NOT «PATTERN»  Finding the end of a path  Finding the beginning of a path WHERE NOT (v)-[:Next]->() WHERE NOT ()-[:Next]->(root) :Next :Next … …:Next root
  • 20. WHERE NOT «PATTERN»  Finding the end of a path  Finding the beginning of a path WHERE NOT (v)-[:Next]->() WHERE NOT ()-[:Next]->(root) :Next :Next … …:Next root
  • 21. WHERE NOT «PATTERN»  Finding the end of a path  Finding the beginning of a path  These two can be used to select the complete path WHERE NOT (v)-[:Next]->() WHERE NOT ()-[:Next]->(root) :Next :Next … …:Next root
  • 22. MERGE :indexPair :indexPair - -:Next :Next + + :Next :Next … … :indexPair -:Next +:Next …  Select states to merge  Calculate metrics  Filter inconsistencies  Return result
  • 23. MERGE + - :indexPair :indexPair  Problem: o Inconsistencies can be transitive  Solution: o Variable length path :indexPair :indexPair + -:Next :Next
  • 24. MERGE + - :indexPair :indexPair  Problem: o Inconsistencies can be transitive  Solution: o Variable length path :indexPair :indexPair + -:Next :Next while (driver.run(createIndexPairs, mergeMap))
  • 25. MERGE + - :indexPair :indexPair  Problem: o Inconsistencies can be transitive  Solution: o Variable length path :indexPair :indexPair + -:Next :Next MATCH (s1:IndexedMerge)-[:IndexPair*..]-(s2:IndexedMerge), s1p = (s1)-[:Next*0..]->(s12:State), s2p = (s2)-[:Next*0..]->(s22:State) WHERE id(s1) > id(s2) AND length(s1p) = length(s2p) AND NOT (s12)-[:IndexPair*0..]-(s22) WITH s12, s22, s1p, s2p,[s1r IN rels(s1p) | s1r.symbol] AS s1ss, [s2r IN rels(s2p) | s2r.symbol] AS s2ss, [s1r IN rels(s1p) | s1r.Tmin] AS s1mins, [s2r IN rels(s2p) | s2r.Tmin ] AS s2mins, [s1r IN rels(s1p) | s1r.Tmax] AS s1maxs, [s2r IN rels(s2p) | s2r.Tmax ] AS s2maxs WHERE s1ss = s2ss AND s1mins = s2mins AND s1maxs = s2maxs WITH collect([s12, s22]) as pairs MATCH ()-[ip:IndexPair]->() WITH max(ip.index) + 1 as nextIndex, pairs UNWIND range(0, length(pairs)-1) as idx WITH pairs[idx][0] as s12, pairs[idx][1] as s22, idx + nextIndex as edgeIndex CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22) SET s12:IndexedMerge, s22:IndexedMerge while (driver.run(createIndexPairs, mergeMap))
  • 26. MERGE + - :indexPair :indexPair :indexPair :indexPair + -:Next :Next  Problem: o Inconsistencies can be transitive  Solution: o Variable length path
  • 27. MERGE MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge), s1p = (s1)-[:Next*0..]->(s12:State), s2p = (s2)-[:Next*0..]->(s22:State) WHERE id(s1) > id(s2) AND length(s1p) = length(s2p) AND NOT (s12)-[:IndexPair*0..]-(s22) + - :indexPair :indexPair :indexPair :indexPair + -:Next :Next  Problem: o Inconsistencies can be transitive  Solution: o Variable length path
  • 28. MERGE MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge), s1p = (s1)-[:Next*0..]->(s12:State), s2p = (s2)-[:Next*0..]->(s22:State) WHERE id(s1) > id(s2) AND length(s1p) = length(s2p) AND NOT (s12)-[:IndexPair*0..]-(s22) + - :indexPair :indexPair :indexPair :indexPair + -:Next :Next  Problem: o Inconsistencies can be transitive  Solution: o Variable length path Find critical state pairs
  • 29. MERGE MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge), s1p = (s1)-[:Next*0..]->(s12:State), s2p = (s2)-[:Next*0..]->(s22:State) WHERE id(s1) > id(s2) AND length(s1p) = length(s2p) AND NOT (s12)-[:IndexPair*0..]-(s22) + - :indexPair :indexPair :indexPair :indexPair + -:Next :Next  Problem: o Inconsistencies can be transitive  Solution: o Variable length path s1 s1 s2 s2 Find critical state pairs
  • 30. MERGE MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge), s1p = (s1)-[:Next*0..]->(s12:State), s2p = (s2)-[:Next*0..]->(s22:State) WHERE id(s1) > id(s2) AND length(s1p) = length(s2p) AND NOT (s12)-[:IndexPair*0..]-(s22) + - :indexPair :indexPair :indexPair :indexPair + -:Next :Next  Problem: o Inconsistencies can be transitive  Solution: o Variable length path s1 s1 s2 s2 WITH s12, s22, s1p, s2p, [s1r IN rels(s1p) | s1r.symbol] AS s1ss, [s2r IN rels(s2p) | s2r.symbol] AS s2ss, [s1r IN rels(s1p) | s1r.Tmin] AS s1mins, [s2r IN rels(s2p) | s2r.Tmin ] AS s2mins, [s1r IN rels(s1p) | s1r.Tmax] AS s1maxs, [s2r IN rels(s2p) | s2r.Tmax ] AS s2maxs WHERE s1ss = s2ss AND s1mins = s2mins AND s1maxs = s2maxs ... Find critical state pairs
  • 31. MERGE MATCH (s1:IndexedMerge)-[:IndexPair*]-(s2:IndexedMerge), s1p = (s1)-[:Next*0..]->(s12:State), s2p = (s2)-[:Next*0..]->(s22:State) WHERE id(s1) > id(s2) AND length(s1p) = length(s2p) AND NOT (s12)-[:IndexPair*0..]-(s22) + - :indexPair :indexPair :indexPair :indexPair + -:Next :Next  Problem: o Inconsistencies can be transitive  Solution: o Variable length path s1 s1 s2 s2 WITH s12, s22, s1p, s2p, [s1r IN rels(s1p) | s1r.symbol] AS s1ss, [s2r IN rels(s2p) | s2r.symbol] AS s2ss, [s1r IN rels(s1p) | s1r.Tmin] AS s1mins, [s2r IN rels(s2p) | s2r.Tmin ] AS s2mins, [s1r IN rels(s1p) | s1r.Tmax] AS s1maxs, [s2r IN rels(s2p) | s2r.Tmax ] AS s2maxs WHERE s1ss = s2ss AND s1mins = s2mins AND s1maxs = s2maxs ... • Paths of same length, • Event sequences of same lengths, etc. Find critical state pairs
  • 32. MERGE  Problem: o Inconsistencies can be transitive  Solution: o Variable length path + - :indexPair :indexPair :indexPair :indexPair + -:Next :Nexts1 s1 s2 s2
  • 33. MERGE CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22) SET s12:IndexedMerge, s22:IndexedMerge  Problem: o Inconsistencies can be transitive  Solution: o Variable length path + - :indexPair :indexPair :indexPair :indexPair + -:Next :Nexts1 s1 s2 s2
  • 34. MERGE CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22) SET s12:IndexedMerge, s22:IndexedMerge  Problem: o Inconsistencies can be transitive  Solution: o Variable length path + - :indexPair :indexPair :indexPair :indexPair + -:Next :Nexts1 s1 s2 s2 Mark newly found index pairs
  • 35. MERGE CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22) SET s12:IndexedMerge, s22:IndexedMerge  Problem: o Inconsistencies can be transitive  Solution: o Variable length path + - :indexPair :indexPair :indexPair :indexPair + -:Next :Nexts1 s1 s2 s2 :indexPair :indexPair Mark newly found index pairs
  • 36. MERGE CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22) SET s12:IndexedMerge, s22:IndexedMerge  Problem: o Inconsistencies can be transitive  Solution: o Variable length path + - :indexPair :indexPair :indexPair :indexPair + -:Next :Nexts1 s1 s2 s2 :indexPair :indexPair Mark newly found index pairs while (driver.run(createIndexPairs, mergeMap))
  • 37. MERGE CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22) SET s12:IndexedMerge, s22:IndexedMerge  Problem: o Inconsistencies can be transitive  Solution: o Variable length path + - :indexPair :indexPair :indexPair :indexPair + -:Next :Nexts1 s1 s2 s2 :indexPair :indexPair Mark newly found index pairs while (driver.run(createIndexPairs, mergeMap)) Repeatedly called from Java code until fixpoint
  • 38. MERGE CREATE (s12)-[:IndexPair {index: edgeIndex}]->(s22) SET s12:IndexedMerge, s22:IndexedMerge  Problem: o Inconsistencies can be transitive  Solution: o Variable length path + - :indexPair :indexPair :indexPair :indexPair + -:Next :Nexts1 s1 s2 s2 :indexPair :indexPair Mark newly found index pairs while (driver.run(createIndexPairs, mergeMap)) Repeatedly called from Java code until fixpoint
  • 39. SPLIT :Origin :Origin :Origin :Origin [1,6] 1 6  Splits an edge  Based on timestamp: t o Original transition  The two endpoints… o Smaller: < t o Larger: ≥ t 2 :Origin :Origin + + - +/-
  • 40. SPLIT :Origin :Origin :Origin :Origin [1,6] 1 6 2 :Origin :Origin  Splits an edge  Based on timestamp: 5 o Original transition  The two endpoints… o Smaller: < t o Larger: ≥ t + + - +/-
  • 41. SPLIT  Splits an edge  Based on timestamp: 5 o Original transition  The two endpoints… o Smaller: < t o Larger: ≥ t  Results [1,4] [5,6] + -
  • 42. SPLIT  Problem o Node a is a result of an earlier merge operation o The subtree regenerated from node b should belong to the… • Larger subtree because of 6 • Smaller subtree because of 1 :Origin :Origin :Origin [1,6] 1 6 b 6 :Origin :Origin … a
  • 43.  Solution o “Shortest” path to node a o Based on the last number: 6 SPLIT :Origin :Origin :Origin [1,6] 1 6 b 6 :Origin :Origin … a
  • 44. SPLIT MATCH (r:Red)-[n:Next]->(b:Blue) WITH r, b, n.Tmax as Tmax, n.Tmin as Tmin, n.symbol as symbol UNWIND range(Tmin, Tmax-1) AS t MATCH (b)-[:Next*0..]->(s1:State)-[:Origin]->(so1:OrigState), trace1=(so1)<-[OrigNext*0..]-(redOrigNext:OrigState), (redOrigNext)<-[no1:OrigNext]-(redOrig:OrigState)<-[:Origin]-(r) WHERE none(x IN nodes(trace1) WHERE (x)<-[:Origin]-(r)) WITH r, b, t, Tmin, Tmax, symbol, s1, no1, so1 MATCH (b)-[:Next*0..]->(s2:State)-[:Origin]->(so2:OrigState), trace2=(so2)<-[OrigNext*0..]-(redOrigNext:OrigState), (redOrigNext)<-[no2:OrigNext]-(redOrig:OrigState)<-[:Origin]-(r) WHERE none(x IN nodes(trace2) WHERE (x)<-[:Origin]-(r)) WITH t, r, b, s1, s2, toInteger(no1.time)>t as cat1, toInteger(no2.time)>t as cat2, Tmin, Tmax, symbol, so1, so2 WHERE s1 = s2 AND cat1 <> cat2 AND id(so1) < id(so2) WITH r, b, t, Tmin, Tmax, symbol, [coalesce(so1.accepting, false), coalesce(so1.rejecting, false)] AS so1ar, [coalesce(so2.accepting, false), coalesce(so2.rejecting, false)] AS so2ar WITH r, b, t, Tmin, Tmax, symbol, CASE WHEN so1ar[0] <> so2ar[0] AND so1ar[1] <> so2ar[1] THEN 1 WHEN so1ar = so2ar AND (so1ar = [false, true] OR so1ar = [true, false]) THEN -1 // there is at least one true ELSE 0 END AS score WITH r, b, t, sum(score) AS metric, Tmin, Tmax, symbol ORDER BY metric DESC LIMIT 1 WITH r, b, t, metric, Tmin, Tmax, symbol MATCH (b)-[:Next*0..]->(s1:State)-[:Origin]->(so1:OrigState), trace1=(so1)<-[OrigNext*0..]-(redOrigNext:OrigState), (redOrigNext)<-[no1:OrigNext]-(redOrig:OrigState)<-[:Origin]-(r) WHERE none(x IN nodes(trace1) WHERE (x)<-[:Origin]-(r)) AND toInteger(no1.time)>t WITH r, b, t, metric, Tmin, Tmax, symbol, collect(so1) as so1s MATCH (b)-[:Next*0..]->(s2:State)-[:Origin]->(so2:OrigState), trace2=(so2)<-[OrigNext*0..]-(redOrigNext:OrigState), (redOrigNext)<-[no2:OrigNext]-(redOrig:OrigState)<-[:Origin]-(r) WHERE none(x IN nodes(trace2) WHERE (x)<-[:Origin]-(r)) AND toInteger(no2.time)<=t RETURN r, b, t, metric, Tmin, Tmax, symbol, so1s, collect(so2) as so2s
  • 45. SPLIT :Origin :Origin :Origin [1,6] 1 6 6 :Origin :Origin … a s2 ao an b  Solution o “Shortest” path to node a o Based on the last number: 6 MATCH (a)-[:Next*0..]->(s2:State)-[:Origin]->(b:OrigState), trace=(b)<-[OrigNext*0..]-(an:OrigState), (an)<-[no:OrigNext]-(ao:OrigState)<-[:Origin]-(a) The split candidate in the original runs
  • 46. SPLIT The split candidate in the original runs :Origin :Origin :Origin [1,6] 1 6 6 :Origin :Origin …ao a an s2 b MATCH (a)-[:Next*0..]->(s2:State)-[:Origin]->(b:OrigState), trace=(b)<-[OrigNext*0..]-(an:OrigState), (an)<-[no:OrigNext]-(ao:OrigState)<-[:Origin]-(a)  Solution o “Shortest” path to node a o Based on the last number: 6
  • 47. SPLIT WHERE none(x IN nodes(trace) WHERE (x)<-[:Origin]-(a)) The shortest possible trail, i.e. a node, from which node a can only be reached directly.  Solution o “Shortest” path to node a o Based on the last number: 6 :Origin :Origin :Origin [1,6] 1 6 6 :Origin :Origin … a s2 ao b an MATCH (a)-[:Next*0..]->(s2:State)-[:Origin]->(b:OrigState), trace=(b)<-[OrigNext*0..]-(an:OrigState), (an)<-[no:OrigNext]-(ao:OrigState)<-[:Origin]-(a)
  • 50.  Visualisation  Flexible data model o New labels, properties o No need to define the schema upfront ADVANTAGES OF NEO4J
  • 51.  Visualisation  Flexible data model o New labels, properties o No need to define the schema upfront  Cypher: high-level declarative graph query language ADVANTAGES OF NEO4J
  • 53. WORKFLOW MATCH (n) RETURN n  Neo4j web browser UI
  • 54. WORKFLOW MATCH (n) RETURN n  Neo4j web browser UI
  • 58. WORKFLOW  Neo4j web browser UI We should combine transformation and visualisation
  • 59. WORKFLOW  Neo4j web browser UI We should combine transformation and visualisation
  • 60. WORKFLOW  Neo4j web browser UI We should combine transformation and visualisation
  • 61. WORKFLOW  Neo4j web browser UI We should combine transformation and visualisation
  • 62. WORKFLOW  Neo4j web browser UI We should combine transformation and visualisation
  • 63. CHAINING QUERIES  Chaining queries to write a complex step of the algorithm with a single Cypher query MATCH (node:Blue) REMOVE node:Blue SET node:Red RETURN * node :Red {prop1: "val1"} :Red {prop1: "val2"}
  • 64. CHAINING QUERIES  Chaining queries to write a complex step of the algorithm with a single Cypher query MATCH (node:Blue) REMOVE node:Blue SET node:Red RETURN * node :Red {prop1: "val1"} :Red {prop1: "val2"} MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH 1 AS dummy RETURN * dummy 1 1
  • 65. CHAINING QUERIES  Chaining queries to write a complex step of the algorithm with a single Cypher query MATCH (node:Blue) REMOVE node:Blue SET node:Red RETURN * node :Red {prop1: "val1"} :Red {prop1: "val2"} MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH 1 AS dummy RETURN * dummy 1 1 MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH 1 AS dummy MATCH (n) RETURN * node dummy :Red {prop1: "val1"} 1 :Red {prop1: "val2"} 1 :Green {value: 13} 1 :Red {prop1: "val1"} 1 :Red {prop1: "val2"} 1 :Green {value: 13} 1
  • 66. CHAINING QUERIES  Chaining queries to write a complex step of the algorithm with a single Cypher query MATCH (node:Blue) REMOVE node:Blue SET node:Red RETURN * node :Red {prop1: "val1"} :Red {prop1: "val2"} MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH 1 AS dummy RETURN * dummy 1 1 MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH 1 AS dummy MATCH (n) RETURN * node dummy :Red {prop1: "val1"} 1 :Red {prop1: "val2"} 1 :Green {value: 13} 1 :Red {prop1: "val1"} 1 :Red {prop1: "val2"} 1 :Green {value: 13} 1 Cartesian product  all rows are displayed twice
  • 67. CHAINING QUERIES MATCH (node:Blue) REMOVE node:Blue SET node:Red RETURN * node :Red {prop1: "val1"} :Red {prop1: "val2"} MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH count(*) as dummy RETURN * dummy 2  Chaining queries to write a complex step of the algorithm with a single Cypher query
  • 68. CHAINING QUERIES MATCH (node:Blue) REMOVE node:Blue SET node:Red RETURN * node :Red {prop1: "val1"} :Red {prop1: "val2"} MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH count(*) as dummy RETURN * dummy 2 MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH count(*) as dummy MATCH (n) RETURN * node dummy :Red {prop1: "val1"} 2 :Red {prop1: "val2"} 2 :Green {value: 13} 2  Chaining queries to write a complex step of the algorithm with a single Cypher query
  • 69. CHAINING QUERIES MATCH (node:Blue) REMOVE node:Blue SET node:Red RETURN * node :Red {prop1: "val1"} :Red {prop1: "val2"} MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH count(*) as dummy RETURN * dummy 2 MATCH (node:Blue) REMOVE node:Blue SET node:Red WITH count(*) as dummy MATCH (n) RETURN * node dummy :Red {prop1: "val1"} 2 :Red {prop1: "val2"} 2 :Green {value: 13} 2 Exactly 1 result  The second query will not produce unnecessary duplicates  Chaining queries to write a complex step of the algorithm with a single Cypher query
  • 70. RUNNING AND VISUALISING THE ALGORITHM
  • 71. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 72. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 73. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 74. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 75. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 76. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 77. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 78. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 79. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 80. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 81. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 82. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 83. RUNNING AND VISUALISING THE ALGORITHM ... WITH count(*) as dummy MATCH (n) RETURN n
  • 85. EXECUTING QUERIES Passing information between queries:  Node labels
  • 86. EXECUTING QUERIES Passing information between queries:  Node labels  Nodes with temporary information
  • 87. EXECUTING QUERIES Passing information between queries:  Node labels  Nodes with temporary information  Passing nodes/edges as parameters (only supported in embedded mode)
  • 88. EXECUTING QUERIES Passing information between queries:  Node labels  Nodes with temporary information  Passing nodes/edges as parameters (only supported in embedded mode) redNode num :Red {prop1: "val1"} 1
  • 89. EXECUTING QUERIES Passing information between queries:  Node labels  Nodes with temporary information  Passing nodes/edges as parameters (only supported in embedded mode) redNode num :Red {prop1: "val1"} 1 Exactly 1 result
  • 90. EXECUTING QUERIES Passing information between queries:  Node labels  Nodes with temporary information  Passing nodes/edges as parameters (only supported in embedded mode) redNode num :Red {prop1: "val1"} 1 WITH $redNode AS redNode MATCH (g:Green {num: $num}) CREATE (redNode)-[:Edge]->(g) Exactly 1 result
  • 91. LOOPS  Many loop-like problems can be solved using lists: o List comprehensions: [x IN xs WHERE condition | f(x)] o Reduce: reduce(acc = "", x IN list | acc + x.prop)
  • 92. LOOPS  Many loop-like problems can be solved using lists: o List comprehensions: [x IN xs WHERE condition | f(x)] o Reduce: reduce(acc = "", x IN list | acc + x.prop)  However, loops still might be necessary: o Run queries from Java code gds.execute(step1Query); gds.execute(step2Query);
  • 93. LOOPS  Many loop-like problems can be solved using lists: o List comprehensions: [x IN xs WHERE condition | f(x)] o Reduce: reduce(acc = "", x IN list | acc + x.prop)  However, loops still might be necessary: o Run queries from Java code o The loop condition checks the number of rows in the result while (gds.execute(conditionQuery).hasNext()) { gds.execute(step1Query); gds.execute(step2Query); }
  • 94. IMPORT-EXPORT  Save current state of the algorithm
  • 95. IMPORT-EXPORT  Save current state of the algorithm  APOC* GraphML import-export *Awesome Procedures on Cypher
  • 96. IMPORT-EXPORT  Save current state of the algorithm  APOC* GraphML import-export *Awesome Procedures on Cypher // save CALL apoc.export.graphml.all('my.graphml', {storeNodeIds:true, readLabels:true, useTypes:true})
  • 97. IMPORT-EXPORT  Save current state of the algorithm  APOC* GraphML import-export *Awesome Procedures on Cypher // save CALL apoc.export.graphml.all('my.graphml', {storeNodeIds:true, readLabels:true, useTypes:true}) // load MATCH (n) // delete all DETACH DELETE n WITH count(*) AS dummy //----------------- CALL apoc.import.graphml('my.graphml', {storeNodeIds:true, readLabels:true, useTypes:true}) YIELD nodes, relationships WITH count(*) AS dummy //----------------- MATCH (n) RETURN n // show all
  • 98. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm ?
  • 99. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm ? Metrics:
  • 100. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm ? Metrics: 5
  • 101. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm ? Metrics: 5 12
  • 102. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm ? Metrics: 5 12 8
  • 103. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm ? Metrics: 5 12 8
  • 104. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm  Solutions: o Export -> Re-import o Use transactions: ? Metrics: 5 12 8
  • 105. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm  Solutions: o Export -> Re-import o Use transactions: • Abort transaction ? Metrics: 5 12 8
  • 106. BACKTRACKING  In many cases, we need to restore a previous state and continue from that one o Next step is based on metrics in the algorithm  Solutions: o Export -> Re-import o Use transactions: • Abort transaction • Only applicable to one level of backtracking ? Metrics: 5 12 8
  • 107. DEBUGGING  Save and play back the states that occurred during execution
  • 108. DEBUGGING  Save and play back the states that occurred during execution o A counter for the states is stored in a node
  • 109. DEBUGGING  Save and play back the states that occurred during execution o A counter for the states is stored in a node o Saved query to step back
  • 110. DEBUGGING  Save and play back the states that occurred during execution o A counter for the states is stored in a node o Saved query to step back
  • 111. DEBUGGING  Save and play back the states that occurred during execution o A counter for the states is stored in a node o Saved query to step back
  • 113. DEBUGGING  For complex errors o Formulate an error pattern in Cypher MATCH (node:Faulty) RETURN node
  • 114. DEBUGGING  For complex errors o Formulate an error pattern in Cypher o Use this to define a breakpoint in the code MATCH (node:Faulty) RETURN node if (gds.execute(query).hasNext()) // breakpoint
  • 115. DEBUGGING  For complex errors o Formulate an error pattern in Cypher o Use this to define a breakpoint in the code o Load the state where the error occurred o Debug step by step MATCH (node:Faulty) RETURN node if (gds.execute(query).hasNext()) // breakpoint
  • 117. Sicco Verwer: Efficient identification of timed automata. PhD disszertáció PSEUDOCODE
  • 118. Sicco Verwer: Efficient identification of timed automata. PhD disszertáció PSEUDOCODE
  • 119. Sicco Verwer: Efficient identification of timed automata. PhD disszertáció PSEUDOCODE
  • 120. Sicco Verwer: Efficient identification of timed automata. PhD disszertáció PSEUDOCODE
  • 121. Sicco Verwer: Efficient identification of timed automata. PhD disszertáció PSEUDOCODE
  • 122.
  • 123. EXPRESSIVE POWER OF CYPHER  Most graph queries can be decided in polynomial time (P)  Checking whether two disjoint paths exist is NP-complete  Cypher is Turing-complete o List comprehensions, reduce o The graph can be used to store the tape of the Turing machine  Cypher 9 (current version)  Cypher 10 (multiple graph support)
  • 124. SUMMARY  Neo4j prototype o Rapid development o Lots of APOC procedures for specific problems (e.g. mergeNodes)  Issues o APOC bug (hangs after) o Visualisation glitches o Lack of fixpoint algorithms  For graph algorithms, we’d recommend to o create a prototype in Neo4j, o once the algorithm is understood, rewrite it in imperative code.
  • 125. OUR TEAM Thanks to: Oszkár Semeráth, Tamás Tóth, András Vörös
  • 126. ACKNOWLEDGEMENTS  This work partially supported by the ÚNKP-17-1-I. grant by the Ministry of Human Capacities.  The advisors were partially supported by the MTA-BME Lendület Cyber-Physical Systems Research Group.
  • 127. Ω