Stream Reasoning For Linked Data
J-P Calbimonte, D. Dell'Aglio,
- E. Della Valle, M.I. Ali and A. Mileo
http://streamreasoning.org/events/sr4ld2015
Stream Reasoning with ASP Alessandra Mileo - - PowerPoint PPT Presentation
Stream Reasoning For Linked Data J-P Calbimonte, D. Dell'Aglio, E. Della Valle, M.I. Ali and A. Mileo http://streamreasoning.org/events/sr4ld2015 Stream Reasoning with ASP Alessandra Mileo alessandra.mileo@insight-centre.org
http://streamreasoning.org/events/sr4ld2015
http://streamreasoning.org/events/sr4ld2015
– These slides are partially based on “Streaming Reasoning for Linked Data 2015” by J-P Calbimonte, D. Dell'Aglio, E. Della Valle, M. I. Ali and A. Mileo http://streamreasoning.org/sr4ld2015
2
http://streamreasoning.org/events/sr4ld2015
3
http://streamreasoning.org/events/sr4ld2015
– Negation, disjunction, integrity constraints, weak constraints, aggregates, …
– Based on guess/check/optimize strategy – Relies on CWA
4
http://streamreasoning.org/events/sr4ld2015
l{a1,…,an}u :- b1,…,bk, not bk+1,…, not bm
head body
:- b1,…,bk, not bk+1,…, not bm
a1 .
“a1 is true.”
5
http://streamreasoning.org/events/sr4ld2015
6
% generating plausible colorings 1{col_V(V,C) : col(C)}1 :- vertex(V). % defining constraints :- col_V(V,C), col_V(V1,C), edge(V,V1). col(red). col(green). col(blue). vertex(a). vertex(b). vertex(c). vertex(d). vertex(e). edge(a,b). edge(a,c). edge(a,d). edge(b,e). edge(c,d). edge(d,e). col_V(a,red). col_V(b,blue). col_V(c,blue). col_V(d,green). col_V(e,red).
http://streamreasoning.org/events/sr4ld2015
7
http://streamreasoning.org/events/sr4ld2015
8
http://streamreasoning.org/events/sr4ld2015
AS = B U {atFloor(2,1), goal(1)}
E[t]={request(3,1).}
AS = B U E[1] U {requested(3,1), atFloor(2,1), atFloor(3,2),goal(2)}
9 Three floors Elevator is at floor 1 at time 0
http://streamreasoning.org/events/sr4ld2015
– Base B: static knowledge (independent of parameter t) – Cumulative P[t]: knowledge cumulating with increasing t – External E[t]: external requests coming at time t – Volatile Qn[t] consider changes for each time t considering a time span of n steps
10
http://streamreasoning.org/events/sr4ld2015
11
http://streamreasoning.org/events/sr4ld2015
12
http://streamreasoning.org/events/sr4ld2015
13
http://streamreasoning.org/events/sr4ld2015
relevant events complex events
solution sets
14
http://streamreasoning.org/events/sr4ld2015
15
11/10/15
http://streamreasoning.org/events/sr4ld2015
16
http://streamreasoning.org/events/sr4ld2015
17
http://streamreasoning.org/events/sr4ld2015
18
11/10/15
http://streamreasoning.org/events/sr4ld2015
19
http://streamreasoning.org/events/sr4ld2015
Web
Data
Filtered Stream
Middle- layer Processor Query Logic Program Solutions
Facts
Stream Rule
Stream query processor Non-Monotonic Rule Engine
20
C- SPARQL CQELS
LSD Wrappers
11/10/15
http://streamreasoning.org/events/sr4ld2015
21
http://streamreasoning.org/events/sr4ld2015
22
http://streamreasoning.org/events/sr4ld2015
23
11/10/15
http://streamreasoning.org/events/sr4ld2015
24
11/10/15
http://streamreasoning.org/events/sr4ld2015
25
#const window=3. #const offset=2. #base. % people IDs, areas IDs and connected areas are also part of the base program.
risk(Y) :- offbounds(X), connected(X,Y), area(X), area(Y). #cumulative t. % generating plausible positions 0{position(P,A,t) : area(A)}1 :- person(P). % detecting times when when risks and violations occur breach(P,A,t) :- position(P,A,t), offbounds(A). at_risk(P,t) :- position(P,A1,t-1), risk(A1), not noisy_data(P,A1,t-1). % identify inconsistent movements: noisy_data(P,A2,t) :- position(P,A1,t-1), position(P,A2,t), not connected(A1,A2), neq(A1,A2). #external detectedat(P,A,t+offset). #volatile t. % eliminate positions for which no detection exists (reduces the instance size). :- detectedat(P,A,t), not position(P,A,t), person(P), area(A). :- not detectedat(P,A,t), position(P,A,t), person(P), area(A).
11/10/15
http://streamreasoning.org/events/sr4ld2015
26
11/10/15
http://streamreasoning.org/events/sr4ld2015
27
http://streamreasoning.org/events/sr4ld2015
28
S W ⎡ ⎢ ⎢ ⎤ ⎥ ⎥×T(W)
http://streamreasoning.org/events/sr4ld2015
29
( )≤U
Clingo Translator Translator facts answer set events answers Asp Rules Reasoner
http://streamreasoning.org/events/sr4ld2015
event(type, name, value, latitude, longitude)
E.g. event(weather, strong-wind, 2014-11-26T13:00:00, 38.011736, 12.186724)
30
http://streamreasoning.org/events/sr4ld2015
31
Tω 20000, 5000
5000 ⎡ ⎢ ⎢ ⎤ ⎥ ⎥×T(5000) = 4×216 ms = 864 ms T 20000
T 5000
Tω 20000, 2000
2000 ⎡ ⎢ ⎢ ⎤ ⎥ ⎥×T(2000) =10×72 ms = 720 ms
http://streamreasoning.org/events/sr4ld2015
32
http://streamreasoning.org/events/sr4ld2015
33
http://streamreasoning.org/events/sr4ld2015
34
http://streamreasoning.org/events/sr4ld2015
35
http://streamreasoning.org/events/sr4ld2015
36
http://streamreasoning.org/events/sr4ld2015
37
http://streamreasoning.org/events/sr4ld2015
38
http://streamreasoning.org/events/sr4ld2015
39
http://streamreasoning.org/events/sr4ld2015
probabilities of the possible worlds where φ is true
– in solving the system of inequalities – in counting weighted answer sets
answer sets (hard in ASP due to the solving heuristics)
– Works with any ASP solver, can be obtained with parallel calls to the ASP solver
40
http://streamreasoning.org/events/sr4ld2015
41
Queries Examples Hypotheses
PrASP 0.6 inference core
ASP grounder/ solver
(default: Clingo 3)
PrASP program (given
knowledge base)
Pre-processing
(translation of FOL syntax, ...)
Spanning program
(disjunctions from weighted formulas)
F2LP
(optional)
Filtering
with no or very little influence
Possible worlds
(sampled answer sets)
System of linear equations (or inequalities) CVC4
(SMT solver;
Probability distribution over possible worlds
(maximum entropy solution of equations)
Query probabilities Simplification
independent events
Native solver for linear systems
PrASP learning core
http://streamreasoning.org/events/sr4ld2015
1 face(1..6). 2 [[:]] result(F) :- face(F). 3 1{result(F):face(F)}1. 4 win :- result(6). 5 [0.8|win] :- happy. 6 :- happy, not win.
2 result(1) :- {not result(1)}0, true. 2 … 2 result(6) :- {not result(6)}0, true. 5 happy :- {not happy}0, true. 42
http://streamreasoning.org/events/sr4ld2015
{result(1)} {result(2)} {result(3)} {result(4)} {result(5)} {result(6), win} {result(6), win, happy}
[?] happy. [?|result(6)] happy. 43 [0.167] [0.167] [0.167] [0.167] [0.167] [0.033] [0.133] [0.133] [0.8] = Pr(happy∧result(6))/Pr(result(6)) = 0.133/(0.033+0.133)
http://streamreasoning.org/events/sr4ld2015
44
http://streamreasoning.org/events/sr4ld2015
45
http://streamreasoning.org/events/sr4ld2015
46
http://streamreasoning.org/events/sr4ld2015
47
PrASP
ASP grounder/ solver PrASP CQELS client (RDF filtering client)
RDF data stream
Probabilistic ASP/FOL beliefs/examples stream CQELS/SPARQL query PrASP program (knowledge base) Probabilistic queries Static learning examples
CQELS
Incremental results Hypotheses trans- formation pattern t t
Query & learning results
t
window window
http://streamreasoning.org/events/sr4ld2015
48
http://streamreasoning.org/events/sr4ld2015
49
PREFIX lv: <http://deri.org/floorplan/> SELECT ?person1 ?loc1 PRASP E5 atPos(?person1,?loc1,TIMESTAMP). [OMIT http://deri.org/dblp/persons/] FROM NAMED <http://deri.org/floorplan/> WHERE { GRAPH <http://deri.org/floorplan/> {?loc1 lv:connected ?loc2} STREAM <http://deri.org/streams/rfid> [NOW] {?person1 lv:detectedAt ?loc1}}
Bn[weight] f En e
http://streamreasoning.org/events/sr4ld2015
50
http://streamreasoning.org/events/sr4ld2015
51
1 time(1..5). row(1..3). col(1..3). 2 location(loc(X,Y)) :- row(X), col(Y). 3 1{atPos(L,T) : location(L) : not invalid(L)}1 :- time(T). 4 invalid(L) :- 1{wall(L), locked(L)}, location(L). 5 :- atPos(L,T), not speed_coherent(L,T), time(T). 6 speed_coherent(L,1) :- atPos(L,1), location(L). 7 speed_coherent(L,T) :- speed(X,T-1), atPos(L1,T-1), distanceT(L,L1,X,T). 8 distanceT(loc(X,Y),loc(U,V),#abs(X-U) + #abs(Y-V),T) :- atPos(loc(X,Y),T), atPos(loc(U,V),T-1). 9 [0.8] atPos(loc(1,1),1). 10 sensedspeed(1,1). 11 speed(S,T) :- sensedspeed(S,T). 12 speed(X,T) :- speed(X,T-1), not n_speed(X,T), time(T). 13 n_speed(X,T) :- sensedspeed(Z,T), speed(X,T-1), Z!=X.
Generate Test Speed Coherence Probabilistic Background Knowledge Speed Inertia
http://streamreasoning.org/events/sr4ld2015
52
sensedspeed(1,1).
[?] atPos(loc(2,2),1) [?] atPos(loc(2,2),3) [?] atPos(loc(2,2),5)
B [0.7] sensedspeed(3,2) B1 [0.5] sensedspeed(1,4)
[0.387..] atPos(loc(2,2),1) [0.448..] atPos(loc(2,2),3) [0.298..] atPos(loc(2,2),5)
[0.387..] atPos(loc(2,2),1) [0.216..] atPos(loc(2,2),3) [0.144..] atPos(loc(2,2),5) [0.387..] atPos(loc(2,2),1) [0.216..] atPos(loc(2,2),3) [0.233..] atPos(loc(2,2),5)
http://streamreasoning.org/events/sr4ld2015
– Used as a fall-back approach to constraint solving in addition to the built-in equation solver
– Used to transform First-Order formulas into ASP
53
http://streamreasoning.org/events/sr4ld2015
54
http://streamreasoning.org/events/sr4ld2015
55
http://streamreasoning.org/events/sr4ld2015
relevant events complex events
solution sets
56
http://streamreasoning.org/events/sr4ld2015
57
http://streamreasoning.org/events/sr4ld2015