with ASP Alessandra Mileo Share, Remix, Reuse Legally This work is - - PowerPoint PPT Presentation

with asp
SMART_READER_LITE
LIVE PREVIEW

with ASP Alessandra Mileo Share, Remix, Reuse Legally This work is - - PowerPoint PPT Presentation

How to Build a Stream Reasoning Application D. Dell'Aglio, E. Della Valle, T. Le-Pham, A. Mileo, and R. Tommasini http://streamreasoning.org/events/streamapp2017 Expressive Stream Reasoning with ASP Alessandra Mileo Share, Remix, Reuse


slide-1
SLIDE 1

How to Build a Stream Reasoning Application

  • D. Dell'Aglio, E. Della Valle,
  • T. Le-Pham, A. Mileo, and R. Tommasini

http://streamreasoning.org/events/streamapp2017

Expressive Stream Reasoning with ASP

Alessandra Mileo

slide-2
SLIDE 2

http://streamreasoning.org/events/sr4ld2015

Share, Remix, Reuse — Legally

  • This work is licensed under the Creative Commons

Attribution 3.0 Unported License.

  • Your are free:
  • to Share — to copy, distribute and transmit the work
  • to Remix — to adapt the work
  • Under the following conditions
  • Attribution — You must attribute the work by inserting a

credits slide stating

– These slides are partially based on “How to Build a Stream Reasoning Application 2017” by D. Dell'Aglio, E. Della Valle,

  • T. Le-Pham, Mileo, and R. Tommasini available online at

http://streamreasoning.org/events/streamapp2017

  • To view a copy of this license, visit

http://creativecommons.org/licenses/by/3.0/

2

slide-3
SLIDE 3

http://streamreasoning.org/events/sr4ld2015

Data Streams

Stream Query Processing DL-Stream Reasoning

relevant events entailed events Non-monotonic Stream Reasoning solution sets

Data Streams Data Streams Applications

Scalability Expressivity

3

slide-4
SLIDE 4

http://streamreasoning.org/events/sr4ld2015

Agenda

  • Overview and ASP basics
  • StreamRule: A combined approach
  • Scalability vs. Expressivity trade-off
  • Ongoing work
  • Boosting scalability: Distributed StreamRule

4

slide-5
SLIDE 5

http://streamreasoning.org/events/sr4ld2015

Agenda

  • Overview and ASP basics
  • StreamRule: A combined approach
  • Scalability vs. Expressivity trade-off
  • Ongoing work
  • Boosting scalability: Distributed StreamRule

5

slide-6
SLIDE 6

http://streamreasoning.org/events/sr4ld2015

Answer Set Programming (ASP)

  • Goal: Declarative problem solving

“what is the problem?” instead of “how to solve the problem?”

(set of rules)

6

Problem Solution Representation Output

Computation Modelling Interpretation

slide-7
SLIDE 7

http://streamreasoning.org/events/sr4ld2015

Answer Set Programming (ASP) Features

  • ASP combines:
  • Rich yet simple modeling language

– Default Reasoning, non-determinism, constraints, preferences, aggregates, …

  • High-performance solving capabilities

– Based on guess/check/optimize strategy (generate & test) – Relies on CWA

  • ASP has its roots in:
  • Deductive databases
  • Logic programming (with negation)
  • KR and NMR
  • Constraint solving (mostly SAT)

7

ASP = KR + DB + Search

slide-8
SLIDE 8

http://streamreasoning.org/events/sr4ld2015

ASP Syntax & intuitive Semantics (1/2)

  • Inference (deduction) Rule

a1 :- b1,…,bk, not bk+1,…, not bm

head body “if all b1,…,bk are true and none of the bk+1,…,bm is true, then a1 is true”

  • (Disjunctive) Rule or Cardinality Constraint

l{a1,…,an}u :- b1,…,bk, not bk+1,…, not bm

head body “if all b1,…,bk are true and none of the bk+1,…,bm is true, then at least l and at most u among a1,…,an are true”

8

slide-9
SLIDE 9

http://streamreasoning.org/events/sr4ld2015

ASP Syntax & intuitive Semantics (2/2)

  • Consistency constraint (rule with empty head):

:- b1,…,bk, not bk+1,…, not bm

“it is not possible that all b1,…,bk are true and none of the bk+1,…,bm is true”

  • Fact (rule with empty body):

a1 . “a1 is true.”

  • Other constructs allow for aggregates and preferences

(soft constraints)

9

slide-10
SLIDE 10

http://streamreasoning.org/events/sr4ld2015

Example: graph colouring

  • Problem encoding P:
  • Input instance I:
  • Answer Set(s) of P U I (one solution of the problem)

10

% 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).

slide-11
SLIDE 11

http://streamreasoning.org/events/sr4ld2015

Stream Reasoning with ASP: What’s new?

  • Normal Answer Set Programs are written to work with

static knowledge and non-monotonic rules

  • Streaming ASP allows to externally input data into logic

programs and reason upon them to produce dynamic solutions (answer sets) to dynamic problems

  • Implements windows for logic inference
  • Note:

reasoning over streams ≠ reasoning about time

11

30/10/2017

Incremental ASP

slide-12
SLIDE 12

http://streamreasoning.org/events/sr4ld2015

Agenda

  • Overview and ASP basics
  • StreamRule: A combined approach
  • Scalability vs. Expressivity trade-off
  • Ongoing work
  • Boosting scalability: Distributed StreamRule

13

slide-13
SLIDE 13

http://streamreasoning.org/events/sr4ld2015

The StreamRule idea

14

  • What do we need?

– 2-tier approach: not all dynamic data streams are relevant for complex reasoning

  • Reduced input = better scalability
  • Leverage existing engines from both semantic stream

processing and non-monotonic reasoning fields

in practice ...

slide-14
SLIDE 14

http://streamreasoning.org/events/sr4ld2015

StreamRule Architecture

Query Processing

15

RDF Files (e.g. maps) Sensor Streams

Clingo

C-SPARQL CQELS

Application

Controller Rule-based Expressive Reasoning Web of Data

LSD Wrappers

30/10/2017

slide-15
SLIDE 15

http://streamreasoning.org/events/sr4ld2015

Example: Optimal Parking

16

  • Scenario:
  • Parkings are equipped with sensors for vehicle count that

dynamically updates when cars go in and out

  • Users want to find the best parking spot at anytime, based
  • n their location/point of interest and their optimized

distance and/or cost, considering available space

  • Features:
  • Multicriteria optimization
  • Non-deterministic solutions generation (any of the

available parking would do, with preference for those with a better value for distance and/or cost)

  • Defeasible reasoning (e.g. a parking is full unless I know

there are spaces)

30/10/2017

slide-16
SLIDE 16

http://streamreasoning.org/events/sr4ld2015

Optimal Parking

17

#input cost_per_hour/2, vacancy/2, walkingDistance/2, parkingCost/2, parking/1. %define parking full parkingStatus(ParkingID, "full") :- vacancy(ParkingID,NUMBER), NUMBER == 0. parkingStatus(ParkingID, "full") :- parking(ParkingID), not vacancy(ParkingID,_). %define available parking availableParkingLocation(ParkingID) :- not parkingStatus(ParkingID,"full”), parking(ParkingID). %generation (must choose one parking among the available ones) 1{selected(ParkingID):availableParkingLocation(ParkingID)}1. %projection: distance of selected parking valueOf("DISTANCE", D) :- selected(ParkingID), walkingDistance((ParkingID,D)). %projection: cost of selected parking valueOf("COST", C):- selected(ParkingID),parkingCost(ParkingID, C). %weak constraints :~ valueOf("DISTANCE", AV). [AV@2] %optimization statement :~ valueOf("COST", AV). [AV@1] %optimization statement #show selected/1. #show valueOf/2.

30/10/2017

slide-17
SLIDE 17

http://streamreasoning.org/events/sr4ld2015

Limitations

18

  • Grounding is a bottleneck in ASP
  • Does not scale when results are returned slower than

the new input window arrives

How far can we go?

slide-18
SLIDE 18

http://streamreasoning.org/events/sr4ld2015

Agenda

  • Overview and ASP basics
  • StreamRule: A combined approach
  • Scalability vs. Expressivity trade-off
  • Ongoing work
  • Boosting scalability: Distributed StreamRule

19

slide-19
SLIDE 19

http://streamreasoning.org/events/sr4ld2015

Initial investigation

  • If I divide the streaming window in partitions of size K, the

sum of the time needed to reason upon a number N of such partitions is smaller than the time needed to process the whole window of size N*K.

  • For fixed complexity and streaming rate, I can find the

best partition size to handle the input within a certain unit

  • f processing time (and keep the system scalable)
  • No assumption is made on how the partitions are

generated (random)

Stefano Germano, Thu-Le Pham, Alessandra Mileo: Web Stream Reasoning in Practice: On the Expressivity vs. Scalability Tradeoff. RR 2015: 105-112

slide-20
SLIDE 20

http://streamreasoning.org/events/sr4ld2015

Open issues and ongoing work

  • Limitations
  • Independence assumption
  • Experiments with a fixed logic program (i.e. fixed complexity)
  • How to relax the independence assumption?
  • Input dependency plays a role
  • For connected graphs, need heuristics to decide how to split

then

  • How to guarantee correctness?

21

slide-21
SLIDE 21

http://streamreasoning.org/events/sr4ld2015

Agenda

  • Overview and ASP basics
  • StreamRule: A combined approach
  • Scalability vs. Expressivity trade-off
  • Ongoing work
  • Boosting scalability: Distributed StreamRule

Thu-Le Pham, Alessandra Mileo, Muhammad Intizar Ali: Towards Scalable Non- Monotonic Stream Reasoning via Input Dependency Analysis. ICDE 2017: 1553-1558 22

slide-22
SLIDE 22

http://streamreasoning.org/events/sr4ld2015

23

Extended Dependency Graph

23

(r1) very_slow_speed(X) :- average_speed(X,Y), Y < 20. (r2) many_cars(X) :- car_number(X,Y), Y > 40. (r3) traffic_jam(X) :- very_slow_speed(X), many_cars(X), not traffic_light(X). ....

Rules Dependency Graph Extended

very_slow_speed average_speed car_number many_cars traffic_light traffic_jam

slide-23
SLIDE 23

http://streamreasoning.org/events/sr4ld2015

24

Input Dependency Analysis

very_slow_speed(X) :- average_speed(X,Y), Y < 20. many_cars(X) :- car_number(X,Y), Y > 40. traffic_jam(X) :- very_slow_speed(X), many_cars(X), not traffic_light(X). car_fire(X) :- car_in_smoke(C,high), car_speed(C,0), car_location(C,X). .......

Rules Extended Dependency Graph Input Dependency graph Duplication

slide-24
SLIDE 24

http://streamreasoning.org/events/sr4ld2015

25

Extended StreamRule

Thu-Le Pham, Muhammad Intizar Ali, Alessandra Mileo: Enhancing the Scalability of Expressive Stream Reasoning via input-driven parallelisation. Submitted to the Semantic Web Journal

slide-25
SLIDE 25

http://streamreasoning.org/events/sr4ld2015

Limitations and ongoing work

  • Correctness is guaranteed only when the logic program is

stratified (although recursion and negation are supported, recursion through negation changes the game)

  • Using input dependency paves the way for run-time

parallelisation: how do we adapt the approach to capture run-time changes?

  • We have empirically tested positive rules, rules with

negation and rules with recursion, but…

  • Missing a benchmark for testing different levels of complexity

systematically (ongoing work)

26

slide-26
SLIDE 26

http://streamreasoning.org/events/sr4ld2015

Data Streams

Stream Query Processing DL-Stream Reasoning

relevant events entailed events Non-monotonic Stream Reasoning solution sets

Data Streams Data Streams Applications

Scalability Expressivity

39

slide-27
SLIDE 27

How to Build a Stream Reasoning Application

  • D. Dell'Aglio, E. Della Valle,
  • T. Le-Pham, A. Mileo, and R. Tommasini

http://streamreasoning.org/events/streamapp2017

Stream Reasoning with ASP

Alessandra Mileo alessandra.mileo@insight-centre.org http://www.insight-centre.org/users/alessandra-mileo http://www.linkedin.com/in/alessandramileo