Using Prolog to build a Semantic Web reasoning engine for Advanced Clinical Applications

2011-11

http://www.agfa.com/w3c/Talks/2011/11swig/

by Jos De Roo of AGFA

Overview

Logic

    * N3Logic
    * the Semantic Web context in which the research and advanced developments are done
  

Logic Programming

    * the EYE reasoning engine
    * why/how it is based on Prolog
  

Advanced Clinical Applications

    * concrete cases such as "leg length discrepancy measurement"
    * large scale projects such as DEBUGIT (Detecting and Eliminating Bacteria UsinG Information Technology)
  

Context is Semantic Web (slides from TimBL)

Subject, verb and object

All knowledge is just a set of statements

<#pat> <#knows> <#jo> .

### in classical logic: knows(pat,jo)

Object can be literal

<#pat> <#knows> <#jo> .
<#pat> <#age> 24 .

Note: noun form "age" preferred to the verb style "knows" for predicates.

Saving space: the comma and semicolon

<#pat> <#child>  <#al>, <#chaz>, <#mo> ;
       <#age>    24 ;
       <#eyecolor> "blue" .

Data .. e.g. a table

age eyecolor
pat 24 blue
al 3 green
jo 5 green

  <#pat>   <#age> 24;  <#eyecolor> "blue" .
  <#al>    <#age>  3;  <#eyecolor> "green" .
  <#jo>    <#age>  5;  <#eyecolor> "green" .

Unnamed things: Square brackets

<#pat> <#child> [ <#age> 4 ] , [ <#age> 3 ].

### in classical logic: ∃x ∃y child(pat,x) ∧ child(pat,y) ∧ age(x,4) ∧ age(y,3)

Note:

  [ <#name> "Pat"; <#age> 24;  <#eyecolor> "blue"  ].
  [ <#name> "Al" ; <#age>  3;  <#eyecolor> "green" ].
  [ <#name> "Jo" ; <#age>  5;  <#eyecolor> "green" ].

Local concept

<> <#title>  "A simple example of N3".

Who or what knows what <#title> is?

Shared concept

<> <http://purl.org/dc/elements/1.1/title>
 "Primer - Getting into the Semantic Web and RDF using N3".

To save space:

@prefix dc:  <http://purl.org/dc/elements/1.1/> .
<> dc:title
  "Primer - Getting into the Semantic Web and RDF using N3".

Note

Making vocabularies

Equivalent:

:Person rdf:type  rdfs:Class
:Person a rdfs:Class.

which we could use with data;

:Pat a :Person.

Examples: class and property

:Woman a rdfs:Class; rdfs:subClassOf :Person .

and a property:

:sister a rdf:Property.

Something about the Property :sister::

:sister rdfs:domain :Person;
        rdfs:range :Woman.

Use:

:Pat  :sister  :Jo.

Convention:

Rules Are Just Statements


#   subject        verb        object
#=============  ==========    ==============
{ ?x :son ?y }      =>        { ?y a :Male }.
{ ?x :son ?y }  log:implies   { ?y a :Male }.

### in classical logic: ∀x ∀y son(x,y) ⇒ male(y)

The terms in braces { } are formulas.

The rule statement relates two formulas.

More Complex Antecedent

{ ?x :son ?y.
  ?y!:age math:lessThan 15 }
 =>
{ ?y a :Boy }

More Complex Consequent

{ ?x :son ?y }
  =>
{ ?y a :Male.
  ?y :parent ?x.
  ?x a :Parent }.

Semantic Web Layer Cake

Semantic Web Layer Cake

EYE, an open source reasoning engine

Detailed design of EYE

EYE under the hood

In the current design things are layered and cascaded as follows:

                     .------------------.
        .------------|- - -   N3S       |
        |      PCL   |-----'------------|
        |------------|- - -'  YASAM     |
        |      YABC  |-----'------------|
        |------------|- - -'  YAAM      |
        |      ASM   |-----'------------|
        '------------|- - -'  CPU       |
                     '------------------'

	Legend
	------
		N3S	= Notation 3 Socket
		PCL	= Prolog Coherent Logic
		YASAM	= Yet Another Skolem Abstract Machine
		YABC	= Yet Another Byte Code
		YAAM	= Yet Another Abstract Machine
		ASM	= Assembly Code
		CPU	= Central Processing Unit

EYE intermediate code: Prolog Coherent Logic (PCL)

A PCL rule has the general form

	A1 , A2 , . . . , Am => C1 | C2 | . . . | Cn		(1)

where the Ai are atomic expressions and each Cj is a conjunction of atomic expressions, m, n >= 1. The left-hand side of a rule is called the antecedent of the rule (a conjunction) and the right-hand side is called the consequent (a disjunction). All atomic expressions can contain variables. If n = 1 then there is a single consequent for the rule (1), and the rule is said to be definite. Otherwise the rule is a splitting rule that requires a case distinction (case of C1 or case of C2 or . . . case of Cn). The separate cases (disjuncts) Cj must have a conjunctive form

	B1 , B2 , . . . , Bh					(2)

where the Bi are atomic expressions, and h >= 1 varies with j. Any free variables occurring in (2) other than those which occurred free in the antecedent of the rule are taken to be existential variables and their scope is this disjunct (2).


http://www.ii.uib.no/acl/description.pdf

EYE source code: Yet Another Prolog (YAP)

Plugins

EYE command line interface

Usage: eye <options>* <data>* <query>*
eye
	java -jar Euler.jar [--swipl] [--no-install]
	yap -q -f euler.yap -g main --
	swipl -q -f euler.yap -g main --
<options>
	--nope			no proof explanation
	--no-branch		no branch engine
	--no-qvars		no quantified variables in output
	--no-qnames		no qnames in output
	--no-span		no span control
	--quiet			incomplete e:falseModel explanation
	--quick-false		do not prove all e:falseModel
	--quick-possible	do not prove all e:possibleModel
	--quick-answer		do not prove all answers
	--think			generate e:consistentGives
	--ances			generate e:ancestorModel
	--plugin <yap_resource>	plugin yap_resource
	--wcache <uri> <file>	to tell that uri is cached as file
	--ignore-syntax-error	do not halt in case of syntax error
	--pcl			output PCL code
	--strings		output log:outputString objects
	--warn			output warning info
	--debug			output debug info
	--profile		output profile info
	--version		show version info
	--help			show help info
<data>
	<n3_resource>		n3 facts and rules
<query>
	--query <n3_resource>	output filtered with filter rules
	--pass			output deductive closure
	--pass-all		output deductive closure plus rules

Concrete Test Cases



=================================================================
swap/check.py --report for brain anatomy test case
http://lists.w3.org/Archives/Public/www-archive/2009Jan/0019.html
=================================================================

Deep taxonomy benchmark


        |      colog        cwm      eye   eulerj       jdrew        jena      pellet
--------|----------------------------------------------------------------------------
     10 |      0.007      0.071    0.000    0.006       0.004       0.121       0.075
    100 |      0.511      1.449    0.004    0.179       0.172       0.783       0.442
   1000 |    500.600    115.820    0.040    3.907      98.467      29.330      38.836
  10000 | 498137.000  16016.625    0.436  155.710   91614.000  (outOfMem)  (outOfMem)
 100000 |     16 year              4 sec                4 year


http://ruleml.org/WellnessRules/files/WellnessRulesN3-2009-11-10.pdf

EYE Server by Ruben Verborgh

Advanced Clinical Applications

Agfa on 'Connected Knowledge'

Advanced Clinical Applications: Using Semantic Web and Proof Technologies to Reduce Errors in Radiological Procedure Orders

Using Semantic Web and Proof Technologies to Reduce Errors in Radiological Procedure Orders

Advanced Clinical Applications: Leg Length Discrepancy Measurement

Leg Length Discrepancy Measuremen

Advanced Clinical Applications: DebugIT Project

DebugIT Project

Adaptable Clinical Workflow: The GPS way, responding to many types of changes

ACW GPS

Advanced Clinical Applications Summary

ACA Summary

TODO

Thank You

Thank you for your attention

http://www.agfa.com/w3c/Talks/2011/11swig/