29
Pieter PAUWELS – [email protected] Ana ROXIN – [email protected] Pieter Pauwels [email protected] Ana Roxin [email protected]

Reasoning with rules - Application to N3/EYE and Stardog

Embed Size (px)

Citation preview

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Pieter Pauwels

[email protected]

Ana Roxin

[email protected]

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Agenda

Scenario

EYE/N3 approach

STARDOG approach

Results

Further generalisation

2

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

SCENARIO

3

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Input files

◼ 2 IFC files converted into ifcOWL (Turtle format)

� facts1.ttl

� facts2.ttl

◼ Additional statements� @prefix add: <http://www.additionalelements.org/> .

� inst:IfcSpace_1021 add:isConnectedToStair inst:IfcStair_593 .

� inst:IfcSpace_983 add:isConnectedToStair inst:IfcStair_593 .

� inst:IfcSpace_1021 add:isConnectedToStair inst:IfcStair_613 .

� inst:IfcSpace_983 add:isConnectedToStair inst:IfcStair_613 .

◼ An ensemble of 8 rules (IF -> THEN)

4

But, this can

also be

handled

through the

proper

elements in

IFC

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Example Rule – R#7

• A stair is connected to an object having an exit to ground floor

• The distance from the stair to the exit is not greater than 30000IF

• The stair is a valid exitTHEN

5

PREFIX kba: <http://koreanbuildingcode.org/KR-BA-34-01/>PREFIX math: <http://www.w3.org/2000/10/swap/math#>PREFIX add: <http://www.additionalelements.org/>

IF {?s add:isConnectedToStair ?obj .?obj kba:hasExitOnGroundFloor "true" .?s kba:hasEscapeDistanceToStaircase ?value .?value math:notGreaterThan 30000 .

}

THEN {?s kba:isValid "true" .

}

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

THE EYE/N3 APPROACH

6

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

The N3/EYE Approach

7

inference engine

OWL ontologies

query

User

RDF Repository

interface

IF-THEN rule repository

response in

RDF graph

EYE reasoning

engine

N3 OWLRDF

SPARQL

RDF / CSV

English

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Rules in EYE/N3

8

RDF graphLog:implies(IF THEN)

N3Logic

@prefix kba: <http://koreanbuildingcode.org/KR-BA-34-01/> .@prefix add: <http://www.additionalelements.org/> .@prefix math: <http://www.w3.org/2000/10/swap/math#> .

{?s add:isConnectedToStair ?obj .?obj kba:hasExitOnGroundFloor "true" .?s kba:hasEscapeDistanceToStaircase ?value .?value math:notGreaterThan 30000 .

}=>{?s kba:isValid "true" .

} .

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Serialisation formats for the RDF data model

9

Source: https://www.w3.org/DesignIssues/diagrams/n3/venn

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

THE STARDOG APPROACH

10

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Stardog

11

Source: http://stardog.com/

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Scenario implementation on Stardog

Adapting rules

• Stardog Rule Syntax

Creating the repositories

• 1 per IFC file

• Rules are added on top of each repository

Querying the data

• Inferences are made on query execution

12

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Stardog Rule Syntax

13

SPARQL "basic graph

patterns" (BGPs)

explicit new bits (IF-THEN)

Stardog RuleSyntax

PREFIX rule: <tag:stardog:api:rule:>[] a rule:SPARQLRule ;

rule:content """PREFIX kba: <http://koreanbuildingcode.org/KR-BA-34-01/>PREFIX add: <http://www.additionalelements.org/>

IF {?s add:isConnectedToStair ?obj .?obj kba:hasExitOnGroundFloor "true" .?s kba:hasEscapeDistanceToStaircase ?value .FILTER (?value <= 30000) .

}

THEN {?s kba:isValid "true" .

}""" .

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Scenario

◼ 2 repositories

� Facts1.ttl + rs1.ttl

� Facts2.ttl + rs1.ttl

◼ SPARQL queries addressing the properties being

impacted by the rules in the rule set (rs1.ttl)

� As Stardog performs reasoning at query time

◼ Web interface for

� Uploading files

� Addressing SPARQL queries

14

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

RESULTS

15

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Inferences – validating R#1

◼ Query 1

◼ Output Facts1.ttl

◼ Output Facts2.ttl

16

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Inferences – Validating R#2

◼ Query 2

◼ Output (same for Facts1.ttl & Facts2.ttl)

17

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Inferences – Validating R#3

◼ Query 3

◼ Output Facts1.ttl

◼ Output Facts2.ttl

18

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Inferences – Validating R#4

◼ Query 4

◼ Output Facts1.ttl

◼ Output Facts2.ttl

19

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Inferences – Validating R#5

◼ Query 5

◼ Output (same for Facts1.ttl & Facts2.ttl)

20

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Inferences – Validating R#6

◼ Query 6

◼ Output Facts1.ttl

◼ Output Facts2.ttl

21

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

R#7 and R#8 – Facts1.ttl

22

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

R#7 and R#8 – Facts2.ttl

23

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

FURTHER GENERALISATION

24

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Candidate languages

RASE Ifc Constraint

Model Procedural

Coding SWRL

SPARQL and SPIN

DROOLS Legal Doc ML

and Legal Rule ML

BIMRL

Rule Tables JenaRules NLP and Prolog

Commercial Rule Engines (e.g. Stardog)

BERA N3logic

25

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Structure ????

26

SWRL

N3Logic

StarDog

Prolog

SPARQL/SPIN

BERA

RASEIfcConstraint

Procedural

coding

DROOLS

RuleML

BIMRL

Rule

Tables

Jena

Rules

RIF

Natural Language

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Language ‘families’

27

SWRLN3Logic StarDog

Prolog SPARQL/SPIN

BERA

RASE

IfcConstraint

Procedural

coding

DROOLS

LegalRuleML

BIMRL

Rule

Tables

Jena RIF

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Cascading the families

28

SWRLN3Logic StarDog

Prolog SPARQL/SPIN

BERA

RASE IfcConstraint

Procedural

coding

DROOLS

LegalRuleML

BIMRL

Jena RIF

Natural Language

IMPLEMENTATION

MARKUP

STANDARD

Pie

ter

PA

UW

EL

S –

pip

au

we

ls@

ug

en

t.b

eA

na

RO

XIN

–a

na

-ma

ria

.ro

xin

@u

-bo

urg

og

ne

.fr

Pieter Pauwels

[email protected]

Ana Roxin

[email protected]

Thank you for your attention !