HCLS/ACPPTaskForce/TutorialUseRule

From W3C Wiki

Step By Step Guide for Writing N3 Rules and Reasoning using CWM and Euler

The Adaptable Clinical Pathways and Protocols Task group uses rdf triples and rules written in N3 Notation. This guide is intented for first time N3 users to write N3 rules and use reasoners cwm and euler.

N3 Notation

N3 Notation is a compact lanaguage used to express RDF and OWL syntax. Furthermore, it can also be a rule language for expressing RDF rules and OWL semantics.

N3 lagnauge syntax and semantics are documented in Tim BL's W3C Notes Notation 3. A half day toturial on N3 is quite helpful. When developing a small-scale ontology or write some simple triples, N3 notation offers the simplicity and readability that the RDF and OWL XML syntax fell short.

By using the curily braces { }, which is called a "formula", together with a log:imply syntax =>, N3 is also capable of expressing RDF rules.

Here are few examples of N3 triples and rules: N3 Examples

Set Up Euler Proof Engine

(http://www.agfa.com/w3c/euler/ Euler) is a general purpose proof engine. The latest version of Euler is written in //www.ncc.up.pt/~vsc/Yap/ YAP (yet-another-prolog).

In order to use all built-ins for logic framework log.n3 and log-rules.n3, you need to have the following components/softwares on your computer:

Step 1: Install cygwin

Cygwin is a Linux-like environment for Windows. It consists of two parts:

  • A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
  • A collection of tools which provide Linux look and feel.

Cygwin is a raletively big package. Make sure you have a fast internet connection before starting your installation. The setup program will let you select the needed tools

http://cygwin.com/setup.exe

The following tools are recommended to install:

  • Devel package
    • g++
    • cvs
    • make
    • subversion
  • editors package
    • nano
  • lib package
    • gmp
  • net package
    • openssh
  • web package
    • curl
    • tidy
    • wget

Step 2: Install euler

Download the lastest version of Euler from sourceforge, and unzip the file in ~/install directory (commonly C:).

Step 3: Install Jena

You will need to a number of jar files (jena.jar, xercesImpl.jar, etc) installed for euler to work properly. You can download them one by one, but the easiest way is to install Jena package.

Get Jena

Step 4: Set the paths

In your window environment variables (control panel ->system -> advanced -> Environment Variables)

Add the following to your $ClASSPATH

CLASSPATH = $EULERINSTALLDIR\classes;$EULERINSTALLDIR\lib\js.jar;$JENAINSTALLDIR\lib\xercesImpl.jar;
$EULERINSTALLDIR\lib\antlr-2.7.5.jar;$EULERINSTALLDIR\lib\commons-logging.jar;
$EULERINSTALLDIR\lib\concurrent.jar;$EULERINSTALLDIR\lib\icu4j_3_4.jar;
$JENAINSTALLDIR\lib\jakarta-oro-2.0.8.jar;$JENAINSTALLDIR\lib\jena.jar;
$JENAINSTALLDIR\lib\junit.jar;$JENAINSTALLDIR\lib\log4j-1.2.12.jar;
$JENAINSTALLDIR\lib\xml-apis.jar;$JENAINSTALLDIR\lib\arq.jar


Assume you install the cygwin, euler, python and Yap in your C:\, add the following to your $PATH (prefer to be added at the begining of your existing $PATH string

PATH = C:\cygwin\bin;C:\cygwin\usr\bin;C:\cygwin\usr\local\bin;C:\Euler\bin;C:\Yap\bin;


Step 5: Install YAP

The latest YAP (YAP-5.1.1 at the time of this writing) on UNIX or cygwin. Note if you only have a window version of YAP, euler5 will not return answers if you have "log:semantic" in your files. This is due to a known issue with YAP window's version on winsocket library.

You will have to build yap in your cygwin environment as following:

  • Get yap from [1].
  • In your cygwin, uncompress the file
   tar xvzf Yap-5.1.1.tar.gz 
  • Build Yap for your local application:
   cd Yap-5.1.1
   bash configure --enable-coroutining --enable-depth-limit --enable-max-performance --enable-cygwin=yes
   make
  • Putting Yap for local application components in C:\cygwin\usr\local
   make install


Step 6: Run Euler