FuXi - 0.85b.dev-r107

8 views
Skip to first unread message

chim...@gmail.com

unread,
Aug 12, 2007, 3:02:39 AM8/12/07
to fuxi-discussion
A new version of FuXi has been uploaded to Cheeseshop [1]. So,
installing it should be as easy as:

wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
easy_install fuxi

The update change consists primarily of a full Description Logic
Programming (DLP) implementation [2], and an API [3] for the W3C Rule
Interchange Format (RIF) Core dialect currently in progress. This
first email will be a brief overview of usage and the next email will
be an overview of how the DLP implementation maps an RDFLib OWL graph
to a "custom" definite Horn ruleset which is extracted into a RETE-UL
network [4] for evaluation. The implementation has been checked
against the OWL tests - with a few exceptions. The following tests
are skipped for the reasons indicated:

'OWL/oneOf/Manifest003.rdf', #Nominialization (O) requires
disjunction operator
'OWL/differentFrom/Manifest002.rdf' ,#not in DHL
'OWL/distinctMembers/Manifest001.rdf',#not in DHL
'OWL/unionOf/Manifest002.rdf',#requires disjunction operator / set
theoretic union
'OWL/InverseFunctionalProperty/
Manifest001.rdf',#owl:sameIndividualAs deprecated
'OWL/FunctionalProperty/Manifest001.rdf', #owl:sameIndividualAs
deprecated
'OWL/Nothing/Manifest002.rdf',# owl:sameClassAs deprecated
'OWL/AllDifferent/Manifest001.rdf',#not in DHL

The entire test suite (minus the above exceptions) runs in about a
second:

{'OWL/FunctionalProperty/Manifest002.rdf': '9.86886024475 milli
seconds',
'OWL/FunctionalProperty/Manifest003.rdf': '3.89385223389 milli
seconds',
'OWL/FunctionalProperty/Manifest004.rdf': '7.73000717163 milli
seconds',
'OWL/InverseFunctionalProperty/Manifest002.rdf': '9.93990898132 milli
seconds',
'OWL/InverseFunctionalProperty/Manifest003.rdf': '2.68507003784 milli
seconds',
'OWL/InverseFunctionalProperty/Manifest004.rdf': '7.36784934998 milli
seconds',
'OWL/SymmetricProperty/Manifest001.rdf': '2.25186347961 milli
seconds',
'OWL/TransitiveProperty/Manifest001.rdf': '3.27301025391 milli
seconds',
'OWL/allValuesFrom/Manifest001.rdf': '10.0438594818 milli seconds',
'OWL/complementOf/Manifest001.rdf': '1.56593322754 milli seconds',
'OWL/differentFrom/Manifest001.rdf': '1.49297714233 milli seconds',
'OWL/disjointWith/Manifest001.rdf': '8.33606719971 milli seconds',
'OWL/disjointWith/Manifest002.rdf': '5.28693199158 milli seconds',
'OWL/intersectionOf/Manifest001.rdf': '19.4580554962 milli seconds',
'OWL/inverseOf/Manifest001.rdf': '2.97689437866 milli seconds',
'OWL/oneOf/Manifest002.rdf': '16.5951251984 milli seconds',
'OWL/unionOf/Manifest001.rdf': '9.56583023071 milli seconds'}
ok
----------------------------------------------------------------------
Ran 1 test in 1.593s

The easiest way to use the 'Fuxi' command-line. FuXi depends only on
RDFLib. Once you have installed it you can check out the options:

chimezie@otherland:~/workspace/python-dlp$ Fuxi
USAGE: Fuxi [options] factFile1 factFile2 ...
Options:
--closure If present, the inferred triples are
serialized
along with the original triples if asked
for. Otherwise
(the default behavior), only the inferred
triples
are serialized

--output=OUT Determines whether to serialize the
inferred triples
to STDOUT using the specified RDF syntax
('xml','pretty-xml',
'nt','turtle',or 'n3') or to print a
summary of the conflict set
(from the RETE network) if the value of
this option is
'conflict'
--help
--input-format=<FORMAT> Determines the format of the RDF
document(s) which
serve as the initial facts for the RETE
network.
One of 'xml','n3','trix', 'nt', or
'rdfa'. The default
is 'xml'.

--optimize Suggest inefficiencies in the ruleset and
exit

--stdin Parse STDIN as an RDF graph to contribute
to the
initial facts for the RETE network using
the
specified format

--ns=PREFIX=NSURI Register a namespace binding (QName
prefix to a
base URI). This can be used more than
once

--graphviz-out=<FILE> A filename to write a graphviz diagram of
the RETE
network to

--rules=FILE1,FILE2,.. The Notation 3 documents to use as
rulesets for the
RETE network

---ruleFacts Determines whether or not to attempt to
parse
initial facts from the rule graph.
Default by default

--dlp This switch turns on Description Logic
Programming
(DLP) inference. In this mode, the input
document
is considered an OWL ontology mostly
comprised of
Description Horn Logic (DHL) axioms.
ontology. An
additional ruleset is included to capture
those
semantics outside DHL but which can be
expressed in
definite Datalog Logic Programming. The
DHL-compiled
ruleset and the extensions are mapped
into a RETE-UL
Network for evaluateion.

The new DLP capabilities can be invoked. Invoking them, will cause
additional printouts which will describe the generated horn clauses
and the tautological transformation applied on them. For example:

chimezie@otherland:~/workspace/python-dlp/fuxi/test$ Fuxi --dlp --
input-format=n3 http://python-dlp.googlecode.com/svn/trunk/fuxi/test/DL-SHIOF-test.n3
[]
Time to build production rule (RDFLib): 0.00840711593628 seconds
## RIF BLD Horn Rules: Before LloydTopor: ##
_4:Human(?X) :- _4:Mother(?X)
## RIF BLD Horn Rules: After LloydTopor: ##
_4:Human(?X) :- _4:Mother(?X)
#######################
## RIF BLD Horn Rules: Before LloydTopor: ##
_4:LivingBeing(?X) :- Or( _4:Plant(?X) _4:Animal(?X) )
## RIF BLD Horn Rules: After LloydTopor: ##
_4:LivingBeing(?X) :- _4:Plant(?X)
_4:LivingBeing(?X) :- _4:Animal(?X)
#######################
## RIF BLD Horn Rules: Before LloydTopor: ##
_4:child(?X ?dCdwDBEC155) :- _4:mother(?dCdwDBEC155 ?X)
## RIF BLD Horn Rules: After LloydTopor: ##
_4:child(?X ?dCdwDBEC155) :- _4:mother(?dCdwDBEC155 ?X)
#######################
## RIF BLD Horn Rules: Before LloydTopor: ##
_4:mother(?dCdwDBEC164 ?X) :- _4:child(?X ?dCdwDBEC164)
## RIF BLD Horn Rules: After LloydTopor: ##
_4:mother(?dCdwDBEC164 ?X) :- _4:child(?X ?dCdwDBEC164)
#######################
## RIF BLD Horn Rules: Before LloydTopor: ##
_4:knows(?X ?dCdwDBEC174) :- And( _4:knows(?X ?dCdwDBEC173) _4:knows(?
dCdwDBEC173 ?dCdwDBEC174) )
## RIF BLD Horn Rules: After LloydTopor: ##
_4:knows(?X ?dCdwDBEC174) :- And( _4:knows(?X ?dCdwDBEC173) _4:knows(?
dCdwDBEC173 ?dCdwDBEC174) )
#######################
Time to calculate closure on working memory: 43.4050559998 milli
seconds

@prefix _3: <http://metacognition.info/FuXi/DL-SHIOF-test.n3#>.
@prefix _4: <http://www.w3.org/2002/07/owl#>.
@prefix _5: <http://www.w3.org/2000/10/swap/list#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.

_3:Animal _5:in _:dCdwDBEC23,
[].

_3:Cosi_fan_tutte a _3:DaPonteOperaOfMozart;
_5:in _:dCdwDBEC14,
_:dCdwDBEC15,
[].

_3:Don_Giovanni a _3:DaPonteOperaOfMozart;
_5:in _:dCdwDBEC14,
_:dCdwDBEC15.

_3:Lion a _3:LivingBeing.

_3:Nozze_di_Figaro a _3:DaPonteOperaOfMozart;
_5:in _:dCdwDBEC14.

_3:Plant _5:in _:dCdwDBEC23.

_3:maggie _3:child _3:marge.

_3:marge a _3:Human;
_3:knows _3:smithers.

_3:b _4:sameAs _3:b,
_3:bart.

_3:bart _4:sameAs _3:b,
_3:bart.
<Network: 22 rules, 71 nodes, 480 tokens in working memory, 20
inferred tokens>

Programmatically, Fuxi can be used with arbitrary OWL/RDF graphs:

from FuXi.Rete.RuleStore import N3RuleStore
from FuXi.DLP import
MapDLPtoNetwork,non_DHL_OWL_Semantics
from FuXi.Rete.Util import generateTokenSet
factGraph = .. some fact graph ..
ruleStore = N3RuleStore()
ruleGraph = Graph(ruleStore)
#Parse the non-DHL-OWL N3 ruleset

ruleGraph.parse(StringIO(non_DHL_OWL_Semantics),format='n3')
#create an initial network built around this
ruleset
network = ReteNetwork(ruleStore)
#extend the RETE network to include the DHL-
compiled
#horn clauses
MapDLPtoNetwork(self.network,factGraph)
#feed the facts to the network
#the inferred triples will be in
network.inferredFacts

network.feedFactsToAdd(generateTokenSet(factGraph))

Customized rulesets can be used in addition, or without DLP
capabilities (by parsing
a different N3 string into the ruleGraph before creating the network

[1] http://cheeseshop.python.org/pypi/FuXi/0.85b.dev-r107
[2] http://python-dlp.googlecode.com/svn/trunk/fuxi/lib/DLP/__init__.py
[3] http://python-dlp.googlecode.com/svn/trunk/fuxi/lib/Horn/
[4] http://reports-archive.adm.cs.cmu.edu/anon/1995/CMU-CS-95-113.pdf

josd...@gmail.com

unread,
Aug 13, 2007, 10:53:55 AM8/13/07
to fuxi-discussion
Hi Chime,

Impressive piece of work is very nifty!
I was able to reproduce your OWL test results:

[[
{'OWL/FunctionalProperty/Manifest002.rdf': '248.125076294 milli
seconds',
'OWL/FunctionalProperty/Manifest003.rdf': '246.366977692 milli
seconds',
'OWL/FunctionalProperty/Manifest004.rdf': '283.47492218 milli
seconds',
'OWL/InverseFunctionalProperty/Manifest002.rdf': '244.830846786 milli
seconds',
'OWL/InverseFunctionalProperty/Manifest003.rdf': '241.925001144 milli
seconds',
'OWL/InverseFunctionalProperty/Manifest004.rdf': '307.551860809 milli
seconds',
'OWL/SymmetricProperty/Manifest001.rdf': '194.499969482 milli
seconds',
'OWL/TransitiveProperty/Manifest001.rdf': '226.536035538 milli
seconds',
'OWL/allValuesFrom/Manifest001.rdf': '305.028915405 milli seconds',
'OWL/complementOf/Manifest001.rdf': '180.84192276 milli seconds',
'OWL/differentFrom/Manifest001.rdf': '215.888977051 milli seconds',
'OWL/disjointWith/Manifest001.rdf': '1.10723495483 seconds',
'OWL/disjointWith/Manifest002.rdf': '243.344068527 milli seconds',
'OWL/inverseOf/Manifest001.rdf': '194.241046906 milli seconds',
'OWL/oneOf/Manifest002.rdf': '313.205003738 milli seconds',
'OWL/unionOf/Manifest001.rdf': '276.375770569 milli seconds'}
ok

----------------------------------------------------------------------
Ran 1 test in 6.717s
]]

after 2 changes:

1/ skipping 'OWL/intersectionOf/Manifest001.rdf' as it gave

[[
OWL/intersectionOf/premises001
OWL/intersectionOf/conclusions001
<OWL/intersectionOf/conclusions001.rdf> :- <OWL/intersectionOf/
premises001.rdf>
<Network: 41 rules, 129 nodes, 0 tokens in working memory, 0 inferred
tokens>
[]
[]
Time to calculate closure on working memory: 312.090873718 milli
seconds
<Network: 41 rules, 129 nodes, 2300 tokens in working memory, 24
inferred tokens>
missing triple (rdflib.URIRef('http://www.w3.org/2002/03owlt/
intersectionOf/premises001#John'),
rdflib.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
rdflib.URIRef('http://www.w3.org/2002/03owlt/intersectionOf/
premises001#C'))
OWL/intersectionOf/Manifest001.rdf
feature: http://www.w3.org/2002/07/owl#intersectionOf
...
]]

2/ commenting line 5 in lib/Rete/__init__.py
# from DescriptionHornLogic import T
as it gave

[[
amdus@amdus-laptop:~/fuxi$ Fuxi
Traceback (most recent call last):
File "/usr/local/bin/Fuxi", line 8, in <module>
load_entry_point('FuXi==0.85b.dev-r107', 'console_scripts', 'Fuxi')
()
File "/usr/local/lib/python2.5/site-packages/setuptools-0.6c6-
py2.5.egg/pkg_resources.py", line 277, in load_entry_point
File "/usr/local/lib/python2.5/site-packages/setuptools-0.6c6-
py2.5.egg/pkg_resources.py", line 2179, in load_entry_point
File "/usr/local/lib/python2.5/site-packages/setuptools-0.6c6-
py2.5.egg/pkg_resources.py", line 1912, in load
File "/usr/local/lib/python2.5/site-packages/FuXi-0.85b.dev_r107-
py2.5.egg/FuXi/Rete/__init__.py", line 5, in <module>
from DescriptionHornLogic import T
ImportError: No module named DescriptionHornLogic
]]

Will test more,
Jos


On Aug 12, 9:02 am, "chime...@gmail.com" <chime...@gmail.com> wrote:
> A new version of FuXi has been uploaded to Cheeseshop [1]. So,
> installing it should be as easy as:
>

> wgethttp://peak.telecommunity.com/dist/ez_setup.py

> input-format=n3http://python-dlp.googlecode.com/svn/trunk/fuxi/test/DL-SHIOF-test.n3

chim...@gmail.com

unread,
Aug 21, 2007, 11:09:39 PM8/21/07
to fuxi-discussion
On Aug 13, 10:53 am, "josde...@gmail.com" <josde...@gmail.com> wrote:
> Hi Chime,

Hey Jos.

> Impressive piece of work is very nifty!

Thank you :)

> after 2 changes:
>
> 1/ skipping 'OWL/intersectionOf/Manifest001.rdf' as it gave

I was able to reproduce this even after the recent changes. I'm
following up on this. Thanks

> 2/ commenting line 5 in lib/Rete/__init__.py
> # from DescriptionHornLogic import T
> as it gave

This has been removed from the current version of FuXi

Reply all
Reply to author
Forward
0 new messages