rdf-reasoner-konclude 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +165 -0
- package/NOTICE +44 -0
- package/README.md +253 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +208 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.mjs +32 -0
- package/dist/konclude.mjs +25 -0
- package/dist/konclude.wasm +0 -0
- package/dist/konclude.wat +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/worker-node.mjs +11 -0
- package/dist/worker.d.ts +45 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +112 -0
- package/dist/worker.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
rdf-reasoner-konclude
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
TypeScript wrapper and build scripts: GNU Lesser General Public License v3.
|
|
5
|
+
Copyright (c) 2026 Thomas Hanke. See LICENSE.
|
|
6
|
+
|
|
7
|
+
-------------------------------------------------------------------------------
|
|
8
|
+
Third-party component: Konclude OWL-DL Reasoning Kernel
|
|
9
|
+
-------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
The file dist/konclude.wasm is compiled from the Konclude reasoning kernel,
|
|
12
|
+
which is copyright (c) University of Ulm and released under the GNU Lesser
|
|
13
|
+
General Public License v3.0 (LGPLv3).
|
|
14
|
+
|
|
15
|
+
Liebig, T., Jaeger, M., Möller, R., & Möller, B. (2014).
|
|
16
|
+
Konclude: System Description.
|
|
17
|
+
Web Semantics, 27–28, 78–85. doi:10.1016/j.websem.2014.06.003
|
|
18
|
+
|
|
19
|
+
As required by LGPLv3 §4, the complete Konclude source with all applied
|
|
20
|
+
modifications is available at:
|
|
21
|
+
|
|
22
|
+
https://github.com/ThHanke/rdf-reasoner-konclude
|
|
23
|
+
|
|
24
|
+
Clone with --recurse-submodules to obtain vendor/konclude/ (the Konclude source)
|
|
25
|
+
and patches/ (every modification applied to it). To recompile the WASM binary:
|
|
26
|
+
|
|
27
|
+
git clone --recurse-submodules https://github.com/ThHanke/rdf-reasoner-konclude
|
|
28
|
+
docker compose run --rm build
|
|
29
|
+
|
|
30
|
+
The full text of the LGPLv3 is available at:
|
|
31
|
+
https://www.gnu.org/licenses/lgpl-3.0.txt
|
|
32
|
+
|
|
33
|
+
-------------------------------------------------------------------------------
|
|
34
|
+
Development acknowledgement: Claude (Anthropic)
|
|
35
|
+
-------------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
This WebAssembly port — including the Qt-elimination shim layer, Emscripten
|
|
38
|
+
build pipeline, threading architecture, TypeScript API, and test suite — was
|
|
39
|
+
developed with substantial AI assistance from Claude, an AI assistant made by
|
|
40
|
+
Anthropic (https://www.anthropic.com).
|
|
41
|
+
|
|
42
|
+
The reasoning algorithm, correctness, and all intellectual property of the
|
|
43
|
+
Konclude OWL-DL reasoner belong entirely to its original authors at the
|
|
44
|
+
University of Ulm.
|
package/README.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# rdf-reasoner-konclude
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/rdf-reasoner-konclude)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
OWL-DL tableau reasoning via [Konclude](https://github.com/konclude/Konclude) compiled to WebAssembly, with an async TypeScript API using RDF.js Quad types.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install rdf-reasoner-konclude n3
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`n3` is a required peer dependency (used for NTriples serialization/deserialization).
|
|
15
|
+
|
|
16
|
+
## Node.js quick-start
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { RdfReasoner, INFERRED_GRAPH_IRI } from 'rdf-reasoner-konclude';
|
|
20
|
+
import { Store, Parser } from 'n3';
|
|
21
|
+
|
|
22
|
+
// Load your ontology into an N3 Store
|
|
23
|
+
const store = new Store();
|
|
24
|
+
const parser = new Parser({ format: 'Turtle' });
|
|
25
|
+
parser.parse(`
|
|
26
|
+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
|
27
|
+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
|
28
|
+
:A rdfs:subClassOf :B .
|
|
29
|
+
:B rdfs:subClassOf :C .
|
|
30
|
+
`, (err, quad) => { if (quad) store.addQuad(quad); });
|
|
31
|
+
|
|
32
|
+
const reasoner = new RdfReasoner();
|
|
33
|
+
await reasoner.ready;
|
|
34
|
+
|
|
35
|
+
await reasoner.reason(store);
|
|
36
|
+
|
|
37
|
+
// Inferred triples are written into the INFERRED_GRAPH_IRI named graph
|
|
38
|
+
const inferred = store.getQuads(null, null, null, INFERRED_GRAPH_IRI);
|
|
39
|
+
console.log(inferred.map(q => `${q.subject.value} → ${q.object.value}`));
|
|
40
|
+
// e.g. [ ':A → :C' ] (transitive subClassOf)
|
|
41
|
+
|
|
42
|
+
reasoner.terminate();
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
No Worker setup needed — Node.js 18+ picks up the `"node"` export condition which installs a `worker_threads` shim automatically.
|
|
46
|
+
|
|
47
|
+
## Browser / Vite quick-start
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { RdfReasoner, INFERRED_GRAPH_IRI } from 'rdf-reasoner-konclude';
|
|
51
|
+
import { Store } from 'n3';
|
|
52
|
+
|
|
53
|
+
const store = new Store(/* ... your quads ... */);
|
|
54
|
+
const reasoner = new RdfReasoner();
|
|
55
|
+
await reasoner.ready;
|
|
56
|
+
|
|
57
|
+
await reasoner.reason(store);
|
|
58
|
+
|
|
59
|
+
const inferred = store.getQuads(null, null, null, INFERRED_GRAPH_IRI);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
The browser build requires COOP/COEP HTTP headers for `SharedArrayBuffer` (used by pthreads). See [Browser Deployment](#browser-deployment) for server configuration.
|
|
63
|
+
|
|
64
|
+
## API reference
|
|
65
|
+
|
|
66
|
+
### `RdfReasoner`
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const reasoner = new RdfReasoner();
|
|
70
|
+
await reasoner.ready; // resolves when WASM module is loaded
|
|
71
|
+
|
|
72
|
+
await reasoner.reason(store); // classify + write inferred triples into store
|
|
73
|
+
await reasoner.classify(store); // alias for reason(store)
|
|
74
|
+
const ok = await reasoner.checkConsistency(store); // returns boolean
|
|
75
|
+
|
|
76
|
+
reasoner.terminate(); // shut down the Worker
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`reason(store)` and `classify(store)` write inferred triples into the
|
|
80
|
+
`INFERRED_GRAPH_IRI` named graph inside the store. The graph is cleared before
|
|
81
|
+
each call — do not store ontology triples there.
|
|
82
|
+
|
|
83
|
+
Named graphs in the input are dropped at the WASM boundary (NTriples wire
|
|
84
|
+
format is triple-only). Reasoning runs over the union of all graphs.
|
|
85
|
+
|
|
86
|
+
Options for `reason(store, opts)` and `classify(store, opts)`:
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
interface StoreReasoningOptions {
|
|
90
|
+
inferredGraph?: string; // IRI of the named graph for inferred triples
|
|
91
|
+
// default: INFERRED_GRAPH_IRI
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### `INFERRED_GRAPH_IRI`
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
import { INFERRED_GRAPH_IRI } from 'rdf-reasoner-konclude';
|
|
99
|
+
// "urn:konclude:inferred"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The default named graph where inferred triples are written by `reason(store)`.
|
|
103
|
+
|
|
104
|
+
### Deprecated overloads
|
|
105
|
+
|
|
106
|
+
`reason(quads: Iterable<Quad>)` and `classify(quads)` / `checkConsistency(quads)` accept a raw `Iterable<Quad>` and return `Promise<Quad[]>` / `Promise<boolean>`. These overloads are deprecated — use the `Store`-based API instead.
|
|
107
|
+
|
|
108
|
+
## Browser deployment
|
|
109
|
+
|
|
110
|
+
The WASM binary uses pthreads, which requires `SharedArrayBuffer`. Browsers
|
|
111
|
+
block `SharedArrayBuffer` unless the page is cross-origin isolated:
|
|
112
|
+
|
|
113
|
+
```http
|
|
114
|
+
Cross-Origin-Opener-Policy: same-origin
|
|
115
|
+
Cross-Origin-Embedder-Policy: require-corp
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Vite dev server
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
// vite.config.js
|
|
122
|
+
export default {
|
|
123
|
+
server: {
|
|
124
|
+
headers: {
|
|
125
|
+
'Cross-Origin-Opener-Policy': 'same-origin',
|
|
126
|
+
'Cross-Origin-Embedder-Policy': 'require-corp',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### nginx (production)
|
|
133
|
+
|
|
134
|
+
```nginx
|
|
135
|
+
add_header Cross-Origin-Opener-Policy same-origin;
|
|
136
|
+
add_header Cross-Origin-Embedder-Policy require-corp;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Caddy (production)
|
|
140
|
+
|
|
141
|
+
```caddyfile
|
|
142
|
+
header {
|
|
143
|
+
Cross-Origin-Opener-Policy same-origin
|
|
144
|
+
Cross-Origin-Embedder-Policy require-corp
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### webpack 5
|
|
149
|
+
|
|
150
|
+
```js
|
|
151
|
+
// webpack.config.js
|
|
152
|
+
module.exports = { experiments: { asyncWebAssembly: true } }
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Performance
|
|
156
|
+
|
|
157
|
+
Benchmarked on an 8-core Linux host. Native = Konclude v0.7.0 binary; TS = Node.js 20 via this package. Threads: 8 (both native and WASM pthreads).
|
|
158
|
+
|
|
159
|
+
| Ontology | Expressivity | NTriples | Native classify | TS total | Ratio |
|
|
160
|
+
| --- | --- | --- | --- | --- | --- |
|
|
161
|
+
| LUBM schema | SHI | 307 | 35 ms | 266 ms | ~7.3× |
|
|
162
|
+
| GALEN | SHIF | 30 817 | 225 ms | 941 ms | ~4.2× |
|
|
163
|
+
| Roberts family | SROIQ | 3 866 | 1 801 ms | 2 603 ms | ~1.4× |
|
|
164
|
+
| LUBM schema + data | SHI | 100 850 | 160 ms | 2 104 ms | ~13× |
|
|
165
|
+
|
|
166
|
+
TS total includes NTriples serialization/deserialization (the main JS overhead).
|
|
167
|
+
The WASM classify step alone is within 1.4×–7.3× of native. Run `npm run bench`
|
|
168
|
+
to reproduce (requires a built WASM binary — see [Build from source](#build-from-source)).
|
|
169
|
+
|
|
170
|
+
## How it works
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
main thread
|
|
174
|
+
RdfReasoner.reason(store)
|
|
175
|
+
→ serialize Store quads to NTriples (n3.js Writer)
|
|
176
|
+
→ postMessage to Worker
|
|
177
|
+
|
|
178
|
+
Worker (pthreads WASM)
|
|
179
|
+
→ KoncludeReasoner::loadNTriples() // NTriples → librdf model (Raptor2)
|
|
180
|
+
→ mapTriples() // librdf → OWL expression model
|
|
181
|
+
→ KoncludeReasoner::classify() // OWL-DL tableau (KPSet, parallel)
|
|
182
|
+
→ KoncludeReasoner::getInferredNTriples()
|
|
183
|
+
→ postMessage result back
|
|
184
|
+
|
|
185
|
+
main thread
|
|
186
|
+
→ parse NTriples → Quad[] (n3.js Parser)
|
|
187
|
+
→ write into store[INFERRED_GRAPH_IRI]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The WASM binary is compiled from Konclude's C++ tableau engine with Qt removed
|
|
191
|
+
(replaced by `std::` shims) and pthreads enabled. The KPSet classifier requires
|
|
192
|
+
real threads — cooperative dispatch deadlocks.
|
|
193
|
+
|
|
194
|
+
## Build from source
|
|
195
|
+
|
|
196
|
+
Requires Docker. First build (Raptor2 + librdf cross-compile + kernel) takes
|
|
197
|
+
roughly 20–30 minutes. Subsequent runs use ccache and skip already-built libs.
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# 1. Populate submodule and pre-apply Qt-removal patches
|
|
201
|
+
git submodule update --init
|
|
202
|
+
bash scripts/apply-patches.sh
|
|
203
|
+
|
|
204
|
+
# 2. Cross-compile Raptor2/librdf for WASM and build the kernel
|
|
205
|
+
docker compose run --rm build
|
|
206
|
+
|
|
207
|
+
# 3. Verify
|
|
208
|
+
docker compose run --rm smoke-test
|
|
209
|
+
|
|
210
|
+
# 4. Compile TypeScript
|
|
211
|
+
npm run build
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Incremental rebuild (Raptor/librdf already built):
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
docker compose run --rm build
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Interactive shell:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
docker compose run --rm shell
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Licence
|
|
227
|
+
|
|
228
|
+
The TypeScript wrapper and build scripts in this repository are licensed under
|
|
229
|
+
**LGPL-3.0-or-later**. See [LICENSE](LICENSE).
|
|
230
|
+
|
|
231
|
+
The WASM binary (`dist/konclude.wasm`) contains the Konclude reasoning kernel,
|
|
232
|
+
which is © University of Ulm and also released under **LGPLv3**.
|
|
233
|
+
|
|
234
|
+
As required by LGPLv3 §4, complete Konclude source with all applied
|
|
235
|
+
modifications is available at:
|
|
236
|
+
|
|
237
|
+
<https://github.com/ThHanke/rdf-reasoner-konclude>
|
|
238
|
+
|
|
239
|
+
Clone with `--recurse-submodules` to obtain `vendor/konclude/` (Konclude source)
|
|
240
|
+
and `patches/` (every modification). To recompile: `docker compose run --rm build`.
|
|
241
|
+
|
|
242
|
+
See [NOTICE](NOTICE) for full third-party notices.
|
|
243
|
+
|
|
244
|
+
> Liebig, T., Jaeger, M., Möller, R., & Möller, B. (2014). *Konclude: System Description.*
|
|
245
|
+
> Web Semantics, 27–28, 78–85. doi:10.1016/j.websem.2014.06.003
|
|
246
|
+
|
|
247
|
+
## Acknowledgements
|
|
248
|
+
|
|
249
|
+
Konclude was developed at the Institute of Artificial Intelligence, University
|
|
250
|
+
of Ulm, by Thorsten Liebig, Murat Özcep, Stefan Wandelt, and others. All
|
|
251
|
+
credit for the reasoning algorithm belongs to the Konclude authors. This
|
|
252
|
+
package is an independent WebAssembly port developed with AI assistance from
|
|
253
|
+
[Claude](https://anthropic.com) (Anthropic).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main thread TypeScript wrapper for the Konclude OWL-DL reasoner.
|
|
3
|
+
*
|
|
4
|
+
* `RdfReasoner` is the public API. It spawns a Web Worker running the WASM
|
|
5
|
+
* reasoning kernel and exposes:
|
|
6
|
+
* - `ready` — resolves when the Worker has finished loading the WASM module
|
|
7
|
+
* - `reason(quads, opts?)` — runs OWL-DL inference over the input quads
|
|
8
|
+
* - `classify(quads)` — alias for reason(quads, {mode:'classify'})
|
|
9
|
+
* - `checkConsistency(quads)` — checks whether the ontology is consistent
|
|
10
|
+
* - `terminate()` — terminates the underlying Worker
|
|
11
|
+
*
|
|
12
|
+
* Named graphs in the input quads are silently dropped (NTriples is
|
|
13
|
+
* triple-only). All returned quads are placed in the DefaultGraph.
|
|
14
|
+
*/
|
|
15
|
+
import type { Quad } from "@rdfjs/types";
|
|
16
|
+
import { Store } from "n3";
|
|
17
|
+
export type { ReasoningOptions, ReasoningResult, StoreReasoningOptions } from "./types.js";
|
|
18
|
+
export { INFERRED_GRAPH_IRI } from "./types.js";
|
|
19
|
+
import type { ReasoningOptions, StoreReasoningOptions } from "./types.js";
|
|
20
|
+
export declare class RdfReasoner {
|
|
21
|
+
/** Resolves when the Worker WASM module is ready; rejects on init failure. */
|
|
22
|
+
readonly ready: Promise<void>;
|
|
23
|
+
private readonly worker;
|
|
24
|
+
private nextId;
|
|
25
|
+
private readonly pending;
|
|
26
|
+
/**
|
|
27
|
+
* Serialization queue: each reason() / checkConsistency() call chains onto
|
|
28
|
+
* this promise so that concurrent calls never interleave their
|
|
29
|
+
* loadNTriples → classify → getInferredNTriples sequences.
|
|
30
|
+
*/
|
|
31
|
+
private _queue;
|
|
32
|
+
constructor();
|
|
33
|
+
/**
|
|
34
|
+
* Send a method call to the Worker and return a Promise for the result.
|
|
35
|
+
*/
|
|
36
|
+
private _call;
|
|
37
|
+
/** Run OWL-DL reasoning over a Store. Inferred triples are written into
|
|
38
|
+
* `opts.inferredGraph` (default `INFERRED_GRAPH_IRI`). The graph is cleared
|
|
39
|
+
* before each call. Concurrent calls are serialized. */
|
|
40
|
+
reason(store: Store, opts?: StoreReasoningOptions): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use `reason(store)` instead.
|
|
43
|
+
*
|
|
44
|
+
* Run OWL-DL reasoning over the provided quads.
|
|
45
|
+
*
|
|
46
|
+
* Named graphs in the input are dropped (NTriples wire format is
|
|
47
|
+
* triple-only). All returned quads are in the DefaultGraph.
|
|
48
|
+
*
|
|
49
|
+
* Concurrent calls are serialized: each call waits for the previous one to
|
|
50
|
+
* complete before sending its first Worker message.
|
|
51
|
+
*/
|
|
52
|
+
reason(quads: Iterable<Quad>, opts?: ReasoningOptions): Promise<Quad[]>;
|
|
53
|
+
private _reasonOnStore;
|
|
54
|
+
private _reasonOnQuads;
|
|
55
|
+
/** Classify a Store (alias for `reason(store)`). */
|
|
56
|
+
classify(store: Store, opts?: StoreReasoningOptions): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated Use `classify(store)` instead.
|
|
59
|
+
*
|
|
60
|
+
* Classify the given quads (alias for `reason(quads, { mode: 'classify' })`).
|
|
61
|
+
*
|
|
62
|
+
* Returns the inferred rdfs:subClassOf quads in the default graph.
|
|
63
|
+
*/
|
|
64
|
+
classify(quads: Iterable<Quad>): Promise<Quad[]>;
|
|
65
|
+
/** Check consistency of a Store. Does not write inferred triples. */
|
|
66
|
+
checkConsistency(store: Store): Promise<boolean>;
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated Use `checkConsistency(store)` instead.
|
|
69
|
+
*
|
|
70
|
+
* Check whether the given quads form a consistent ontology.
|
|
71
|
+
*
|
|
72
|
+
* Internally: loadNTriples → classify → isConsistent.
|
|
73
|
+
*
|
|
74
|
+
* Concurrent calls are serialized: each call waits for the previous one to
|
|
75
|
+
* complete before sending its first Worker message.
|
|
76
|
+
*/
|
|
77
|
+
checkConsistency(quads: Iterable<Quad>): Promise<boolean>;
|
|
78
|
+
/** Terminate the underlying Worker and reject all pending calls. */
|
|
79
|
+
terminate(): void;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAkB,KAAK,EAAe,MAAM,IAAI,CAAC;AAExD,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAmE1E,qBAAa,WAAW;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGpB;IAEJ;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAoC;;IAoElD;;OAEG;IACH,OAAO,CAAC,KAAK;IAab;;6DAEyD;IACzD,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IACjE;;;;;;;;;;OAUG;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAWvE,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,cAAc;IAgCtB,oDAAoD;IACpD,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IACnE;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAehD,qEAAqE;IACrE,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC;IAChD;;;;;;;;;OASG;IACH,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBzD,oEAAoE;IACpE,SAAS,IAAI,IAAI;CAQlB"}
|