Euler YAP Engine, a birds EYE view

2011-01

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

by Jos De Roo of AGFA

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 }.

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

EYE supports MONADIC reasoning

Instead, he identified the three reasoning forms
- abduction, deduction and induction - with the
three stages of scientific inquiry:
hypothesis generation, prediction and evaluation.

When confronted with a number of observations she
seeks to explain, the scientist comes up with an
initial hypothesis; then she investigates what
other consequences this theory, were it true,
would have; and finally she evaluates the extent
to which these predicted consequences agree with
reality.
Flach and Kakas

A concrete example: wet grass

The background theory
true => (
	{:loc001 :ascribed :Cloudy, :NonSprinkler, :Rain, :WetGrass, []}
	{:loc001 :ascribed :NonCloudy, :Sprinkler, :NonRain, :WetGrass, []}
	{:loc001 :ascribed :Cloudy, :NonSprinkler, :Rain, :WetGrass, []}

	...

	{:loc001 :ascribed :Cloudy, :NonSprinkler, :NonRain, :NonWetGrass, []}

	...

	)!e:disjunction

{?S :ascribed :Cloudy, :NonCloudy} => false.
{?S :ascribed :Sprinkler, :NonSprinkler} => false.
{?S :ascribed :Rain, :NonRain} => false.
{?S :ascribed :WetGrass, :NonWetGrass} => false.

A concrete example: wet grass

The observation
:loc001 :ascribed :WetGrass.

A concrete example: wet grass

The queries, expressed as "filter" rules
{?S :ascribed :Sprinkler} => {?S :ascribed :Sprinkler}.

{?S :ascribed :Rain} => {?S :ascribed :Rain}.

A concrete example: wet grass

Was the sprinkler causing wet grass?
[ e:counterModel {:loc001 :ascribed :Cloudy. :loc001 :ascribed :NonSprinkler.
                  :loc001 :ascribed :Rain. :loc001 :ascribed :WetGrass. :loc001 :ascribed _:sk0}
].

[ e:possibleModel {:loc001 :ascribed :NonCloudy. :loc001 :ascribed :Sprinkler.
                   :loc001 :ascribed :NonRain. :loc001 :ascribed :WetGrass. :loc001 :ascribed _:sk0}
; r:gives {
   :loc001 :ascribed :Sprinkler.
  }
].

[ e:falseModel {:loc001 :ascribed :Cloudy. :loc001 :ascribed :NonSprinkler.
                :loc001 :ascribed :NonRain. :loc001 :ascribed :NonWetGrass. :loc001 :ascribed _:sk0}
; e:because [ e:integrityConstraint {{:loc001 :ascribed :WetGrass. :loc001 :ascribed :NonWetGrass} => false}
  ]
].

...

[ e:inductivity 0.567901234567901].

A concrete example: wet grass

Was the rain causing wet grass?
[ e:possibleModel {:loc001 :ascribed :Cloudy. :loc001 :ascribed :NonSprinkler.
                   :loc001 :ascribed :Rain. :loc001 :ascribed :WetGrass. :loc001 :ascribed _:sk0}
; r:gives {
   :loc001 :ascribed :Rain.
  }
].

[ e:counterModel {:loc001 :ascribed :NonCloudy. :loc001 :ascribed :Sprinkler.
                  :loc001 :ascribed :NonRain. :loc001 :ascribed :WetGrass. :loc001 :ascribed _:sk0}
].

...

[ e:inductivity 0.666666666666667].

A concrete example: wet grass

The color prediction experiment from Pieter Pauwels

A single EYE reasoning run is MONADIC



=================================================================
Re: Monotonic abduction and Bayes theorem in N3 coherent logic
http://lists.w3.org/Archives/Public/www-archive/2010Nov/0004.html
=================================================================

More 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

Thank You

Thank you for your attention

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