-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstans.txt
More file actions
213 lines (211 loc) · 14.1 KB
/
instans.txt
File metadata and controls
213 lines (211 loc) · 14.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
CL-INST ANS
Instructions for Installation and Use
Authors: Esko Nuutila, Mikko Rinne, ... Document History:
Pvm:
Versio:
Kuvaus:
Tekijät:
5.12.2013
0.0.1
First version created
Mikko
8.12.2013
0.0.2
Added description on installing and running
Esko
11.12.2013
0.0.3
Added some notes to explain that only SBCL and the "configure"script are needed. Added the list of commands from "bin/instans"
Mikko
19.3.2014
0.0.4
Updates to the latest version. Added comments on configuration scripts side effects. Went through the command line parameters and added descriptions.
Mikko, Esko
Table of Contents:
Environment
Common Lisp Installation
Downloading, configuring and building INSTANS on OS X (Mac) Other tools
Using INSTANS from the commandline
Directory (d or directory) [Status: Implemented]
Base (b or base) [Status: Implemented]
Graph (g or graph) [Status: Implemented]
Rules (r or rules) [Status: Implemented]
Input (i, t, input or triples) [Status: Implemented]
Output (o or output) [Status: File support implemented]
Read options from <file or url> (f or file) [Status: Implemented] Execute the system (e or execute) [Status: Implemented]
Define system name (n or name) [Status: Implemented]
Rete HTML Visualization (retehtmlpagedir) [Status: Implemented] Triple input policy (tripleinputpolicy)
Triple processing operations (tripleprocessingoperations)
Rule Instance Removal Policy (ruleinstanceremovalpolicy)

Queue Execution Policy (queueexecutionpolicy)
Verbose output for debugging (debug or verbose) Running tests
Syntax tests (SPARQL Compliance Test Set)
Close Friends (a.k.a Friends Nearby) Using INSTANS with SBCL on commandline Using INSTANS with Emacs and Slime Working with INSTANS
Changes from INSTANS 0.1 & 0.2:

Environment
The current version of INSTANS has been developed using Steel Bank Common Lisp (SBCL). The code is likely to work also in other Common Lisp environments, but has not been tested in any others yet.
After installing INSTANS it can be run from the command line (shell) either by using SBCL or directly by giving command line arguments listing the Sparql rule and RDF triples files to be used.
The system has been developed and tested in an OS X (Mac) environment. It is should be straightforward to operate also in other *nixlike environments. Windows is likely to be a bit more exotic.
Common Lisp Installation
Note: In OS X everything else except SBCL is currently installed if needed with the configurescript explained below, so the other components are only listed here for reference.
Steel Bank Common Lisp: We are currently using v. 1.1.16, but v. 1.1.12 and higher are expected to work.
Steel Bank Mac OS X Installation: SBCL is available on Brew. Once Brew is installed, SBCL can be installed from the shell with:
$ brew install sbcl
Brew is highly recommended for keeping uptodate with future SBCL releases!
ASDF: Included in the latest SBCL:s. If using another platform you may need to install it separately.
Quicklisp: A truly excellent library manager, musthave also for other reasons than INSTANS. Installation instructions are here, but if you don't have it yet, the configuration script below will install it.
Downloading, configuring and building INSTANS on OS X (Mac)
1. Clone the repository from github.
git clone https://github.com/aaltodsg/instans.git

2. Change to directory instans cd instans
3. Run the configuration and build script
./configure
It initializes the system:
● Checks that your Lisp configuration is suitable for INSTANS
● Downloads and installs quicklisp.lisp, if it is not installed yet
● Creates a custom SBCL core that contains INSTANS
● Downloads Sparql test cases from w3.org.
● Downloads JQuery DataTables that are used to present the Sparql test case
coverage.
The ./configurescript assumes that curl, tar, and unzipare installed in your system.
Additional options:
./configure clean
Recompiles everything, i.e. cleans any previous installations of INSTANS. WARNING: The clean option also reinstalls quicklisp, removing e.g. quicklispslimehelper in the process. Use with caution, if you already have a custom installation!
Other tools
If you have any plans for developing in Common Lisp, three other components are highly recommended:
1. A good Emacs. We are using Aquamacs on OS X.
2. Slime: Creates the Lisp development environment on emacs. It is available also on
quicklisp, which makes updating easier.
3. Quicklispslimehelper: "Makes it easy to use Slime from quicklisp"
Some configuration is needed. The following slimerelated lines in your "~/.emacs" file do the trick:
.emacs .emacs
(load "~/quicklisp/slimehelper.el") ; your quicklisp directory
(addtolist 'loadpath "~/Dev/Lisp/Slime/") ; your SLIME directory (addtolist 'loadpath "~/Dev/Lisp/Slime/contrib") ; your SLIME directory (setq inferiorlispprogram "/usr/local/bin/sbcl") ; your Lisp system path (require 'slime)
(require 'slimeautoloads)
(slimesetup '(slimefancy slimeasdf))
(slimesetup '(slimerepl slimeeditingcommands slimescratch slimeasdf))

(addhook 'slimemodehook (lambda ()
(unless (slimeconnectedp) (saveexcursion (slime)))))
Using INSTANS from the command-line
Use the command
instans/bin/instans [ arguments ]
to run INSTANS on command line. Running instanswith no arguments prints the following
list:
Usage: instans [ h | help | v
General options: h | help
v | version
| version | { <configurationoption> } ]
Print this message and exit.
Print version information and exit.
Use <string> as the name of the system. Use <dir> as the prefix for file lookup. You can use a file or an URL as <dir> Use <url> as the base.
If <graph> is 'default' add the following inputs to the default graph. If it is <url> add them to the graph named by <url>
Use rules in <rules>.
Read input based on <input>. Same as i.
Write output based on <output>. Read options from <commands>. See the documentation.
See the documentation.
Create an HTML page about the Rete network. See the documentation.
Execute the system. This is done by default at
See the documentation. Same as debug.
Configuration n <string> d <dir>
b <url> g <graph>
options:
| name <string> | directory <dir>
| base <url>
| graph <graph>
| rules <rules> | input <input> | triples <input> | output <output> | file <commands>
r <rules>
i <input>
t <input>
o <output>
f <commands> tripleprocessingpolicy <policy> ruleinstanceremovalpolicy <policy> retehtmlpagedir <dir> queueexecutionpolicy <policy>
e | execute
the end of processing all arguments. debug <phases>
verbose <phases>
See the documentation for description of the parameters of the options above.
Command line specifiers (d, g, n or b) persist until replaced by a new instance of the same specifier.
Directory (-d or --directory) [Status: Implemented]
Use <dir> as the prefix for all file or URI lookups (until changed with another d option). The default is the current directory. Both a file system name and URL are valid.
Base (-b or --base) [Status: Implemented]
Use <url> as the base for triple input parsing & IRI expansion (as specified in section 5 of RFC 3986). The default value is "http://".
Examples:
● "b file:///." is the current directory of the file system.
Graph (-g or --graph) [Status: Implemented]
If <graph> is 'default' or not specified, add the following inputs to the default graph. If it is <url> add them to the graph named <url>. Multiple g parameters can be used in one command line to input to multiple graphs.
One file can currently only contain input to one graph.
Rules (-r or --rules) [Status: Implemented]
Use SPARQL rules in <rules>. Valid rules can be either in the local file system or URI:s, in which case the file is fetched from the specified address. Expansion is based on the prefix specified with d.
Input (-i, -t, --input or --triples) [Status: Implemented]
Read triple input from <input>. Valid inputs can be either in the local file system or URI:s, in which case the file is fetched from the specified address. Expansion is based on the prefix specified with d.
Currently only turtle serialization is supported.
Output (-o or --output) [Status: File support implemented]
Write output to <output>. Currently <output> can only be a file. If not specified, the results are sent to the standard output.
Future additions are to include definition of an output format and separation of SELECT and CONSTRUCT outputs.
Read options from <file or url> (-f or --file) [Status: Implemented]
The file may contain the same options as the command line. The file must contain the LONG names of the options WITHOUT the "" prefix. E.g. option "rules rulefile.rq" would become "rules rulefile.rq".

Execute the system (-e or --execute) [Status: Implemented]
By default the Retenetwork is executed at the end of processing all arguments. The e parameter can be used to request earlier execution of Rete.
Define system name (-n or --name) [Status: Implemented]
Shows as a "key" when executing the system and as the name of the (GraphViz) graph in the HTML representation of a generated Rete network.
Rete HTML Visualization (--rete-html-page-dir) [Status: Implemented]
Creates an HTML page of the constructed Rete network to the specified directory.
Triple input policy (--triple-input-policy)
Specifies how many triples are processed at once from the input. The default is singletriple.
● singletriple: Process one triple at a time
● triplesblock: Processing takes place every time a nonterminal according to Turtle
grammar rule 6 is identified.
● all: Reads the whole input before doing any processing
Implemented in: src/rete/interpreter/lisp: processtripleinput
Triple processing operations (--triple-processing-operations)
A ':'separated list of (add|remove|execute). The default is add:execute.
● add: Add the triples, which have been read based on the triple input policy, to the Rete engine.
● remove: Remove the triples, which have been read based on the triple input policy, from the Rete engine.
● execute: Execute the rule instances based on the queue execution policy.
Rule Instance Removal Policy (--rule-instance-removal-policy)
Relates to the rule instance execution queue processing. A ':'separated list of (remove|...).
● Remove: Removes a rule instance from the queue without executing, if the rule condition is not satisfied anymore.
● Keep: Keeps the rule in the queue despite the original condition not being satisfied. Implemented in: src/rete/interpreter/lisp: reteremoveruleinstance

Queue Execution Policy (--queue-execution-policy)
A ':'separated list of (first|snapshot|repeatfirst|repeatsnapshot). The default is "repeatfirst". src/rete/interpreter/lisp: executerules
● first: Takes the first rule from the queue and executes it.
● repeatfirst: Repeats "first".
● snapshot: Removes all rules from the current queue and processes them. Only takes
new rules after the current snapshot has been processed.
● repeatsnapshot: Repeats "snapshot".
Verbose output for debugging (--debug or --verbose)
Print out internal information of the Rete engine for debugging purposes. <phases> can be "true" or "false".
Running tests
The package comes with a few test scripts, which can be used to verify that the installation is working correctly. All tests are in directory "tests":
$ cd tests
Syntax tests (SPARQL Compliance Test Set)
Tests INSTANS against the SPARQL test set available from http://www.w3.org/2009/sparql/docs/tests/. Run with
$ make syntaxtests
The results are written to the "syntaxtestresults" subdirectory and HTMLformatted in "index.html".
Note: The current testing procedure cannot identify tests, which have been "removed" late in the process. Therefore the compilation of results also includes tests, which are no longer compliant with the latest syntax.
Close Friends (a.k.a Friends Nearby)
This case is described in:

Rinne, M., Abdullah, H., Törmä, S., Nuutila, E.: Processing Heterogeneous RDF Events with Standing SPARQL Update Rules. In: Meersman, R., Dillon, T. (eds.) OTM 2012 Conferences, Part II. pp. 793–802. SpringerVerlag (2012)
And in this simulation report:
Rinne, M., Abdullah, H., Törmä, S., Nuutila, E.: INSTANS Comparison with CSPARQL on Close Friends. Available online: http://www.cs.hut.fi/~mjrinne/sw/instans/INSTANSSimulationsMarch2012.pdf
At the time of writing the reports the tests were executed with INSTANS v. 0.1 available from the project homepage. To run Close Friends with CLINSTANS:
1) With 100 location events: $ make fnb100 2) With 1000 location events: $ make fnb1000
The query results are compared with an earlier execution and the success or failure (based on similarity) is reported.
Using INSTANS with SBCL on command-line
These instructions are for running INSTANS with SBCL from the shell, and do not require or use emacs or slime. The easiest way to start SBCL with INSTANS installed is to use
instans/bin/sbclinstans [ sbclarguments ]
You can use SBCL command line arguments to load Lisp files (loadfilename)or evaluate expressions (evalexpr) before you enter the readevalprintloop. See the documentation of SBCL for all available arguments.
Using INSTANS with Emacs and Slime
TBA.
Working with INSTANS
Changes from INSTANS 0.1 & 0.2:
1) Multiple queries and rules in a single file are separated by a semicolon (";").
(Old: A dot (".") was used as the separator. Semicolon is more compliant with SPARQL.) 2) The graph for each triple input can be specified with a command line parameter.

(Old: A comment line in the beginning of a triple file was used to specify the graph) 3) Turtle input with abbreviations.