Pychinko is a python implementation of the classic Rete algorithm which provides the inferencing capabilities needed by an Expert System. Part of Pychinko works ontop of cwm / afon out of the box. However, it's Interpreter only relies on rdflib to formally represent the terms of an RDF statement.
FuXi only relies on Pychinko itself, the N3 deserializer for persisting N3 rules, and rdflib's Literal and UriRef to formally represent the corresponding terms of a Pychinko Fact. FuXi consists of 3 components (in addition to a 4RDF model for Versa queries):
I. FtRdfReteReasoner
Uses Pychinko and N3RuleExtractor to reason over a scoped 4RDF model.
II. N3RuleExtractor
Extracts Pychinko rules from a scoped model with statements deserialized from an N3 rule document
III. 4RDF N3 Deserializer
see: N3 Deserializer
The rule extractor reverses the reification of statements contained in formulae/contexts as performed by the N3 processor. It uses three Versa queries for this
Using the namespace mappings:
Extract ancendent statements of logical implications
distribute( all() |- log:implies -> *, '.', '. - n3r:statement -> *' )
Extract implied / consequent statements of logical implications
distribute( all() - log:implies -> *, '.', '. - n3r:statement -> *' )
Extract the terms of an N3 reified statement
distribute( <statement>, '. - n3r:subject -> *', '. - n3r:predicate -> *', '. - n3r:object -> *' )
The FuXi class provides methods for performing scoped Versa queries on a model extended via inference or on just the inferred statements:
For example, take the following fact document deserialized into a model:
@prefix : <http://foo/bar#> . :chimezie :is :snoring .
Now consider the following rule:
@prefix ex: <http://foo/bar#> . {?x ex:is ex:snoring} => {?x a ex:SleepingPerson} .
Below is a snapshot of Fuxi perforing the Versa query “type(ex:SleepingPerson)” on a model extended by inference using the above rule:
Who was FuXi? Author of the predecessor to the King Wen Sequence