eyemind 0.9.15 → 0.9.16

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/LE-SPEC.md CHANGED
@@ -183,17 +183,27 @@ indentation of that line, and a line break without a connective joins the lines
183
183
  with `and` where both lines are conditions. eyemind reads the connectives as
184
184
  LE's indentation does: the conditions are split at the least indented
185
185
  connectives, joined from the top down, and each part is read in the same way.
186
- So a deeper indentation binds tighter:
186
+ So a deeper indentation binds tighter. These two rules differ only in the
187
+ indentation of `and`. With every connective at one indentation, this rule
188
+ means *(resident or citizen) and adult*:
187
189
 
188
190
  ```text
189
- a person is eligible a person is eligible
190
- if the person is a resident if the person is a resident
191
- or the person is a citizen or the person is a citizen
192
- and the person is an adult. and the person is an adult.
191
+ a person is eligible
192
+ if the person is a resident
193
+ or the person is a citizen
194
+ and the person is an adult.
193
195
  ```
194
196
 
195
- The left rule means *(resident or citizen) and adult*, the right one *resident
196
- or (citizen and adult)*. LE1 rejects different connectives at one indentation;
197
+ With `and` indented deeper, this one means *resident or (citizen and adult)*:
198
+
199
+ ```text
200
+ a person is eligible
201
+ if the person is a resident
202
+ or the person is a citizen
203
+ and the person is an adult.
204
+ ```
205
+
206
+ LE1 rejects different connectives at one indentation;
197
207
  eyemind reads them from the top down, as LE2 does. A body may start with `and`
198
208
  after `if`, as some LE1 programs write it.
199
209
 
package/LS-SPEC.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ```text
4
4
  Title: The Logic Script (LS) Language and Proof Format
5
- Version: eyemind 0.9.15
5
+ Version: eyemind 0.9.16
6
6
  ```
7
7
 
8
8
  This document specifies Logic Script (LS): the syntax and meaning of its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyemind",
3
- "version": "0.9.15",
3
+ "version": "0.9.16",
4
4
  "description": "A dependency-free Logic Script (LS) reasoner with forward and backward reasoning, checkable proofs, and RDF 1.2, Notation3 (N3), SPARQL 1.2 RL (SRL) and Logical English (LE) interoperability.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // The eyemind command line.
2
- import { run, unusedClauses } from './engine.js';
2
+ import { COMPILED_LIMITS, run, unusedClauses } from './engine.js';
3
3
  import { OUTPUT_FORMATS, RDF_PROFILES, defaultFormat, inputKind, loadInputs, loadMessageReasoner, rdfMessageFormat, scopeOf, writeConclusions } from './formats.js';
4
4
  import { explainLe } from './le-explain.js';
5
5
  import { isRdfMessageLog, replayMessages, RdfMessageReader } from './messages.js';
@@ -52,8 +52,6 @@ Exit codes: 0 success, 1 error, 2 invalid proof, 65 contradiction.
52
52
 
53
53
  const LIMITS = { '--max-depth': 'maxDepth', '--max-iterations': 'maxIterations', '--max-inferences': 'maxInferences' };
54
54
  const ALIASES = new Map([['-p', '--proof'], ['-c', '--prove-and-check'], ['-v', '--version'], ['-h', '--help']]);
55
- // N3 and SPARQL 1.2 RL programs run longer than eyemind's defaults allow.
56
- const COMPILED_LIMITS = { maxDepth: 1000000, maxIterations: 100000, maxInferences: 1000000000 };
57
55
 
58
56
  const RDF_FORMATS = ['turtle', 'trig', 'n-triples', 'n-quads'];
59
57
 
package/src/engine.js CHANGED
@@ -19,6 +19,10 @@ const CONTROL = 'control';
19
19
  const ABSENT = 'absent';
20
20
  const COLLECTED = 'collected';
21
21
 
22
+ // Programs compiled from RDF, N3 and SPARQL 1.2 RL run longer than eyemind's
23
+ // defaults allow.
24
+ export const COMPILED_LIMITS = { maxDepth: 1000000, maxIterations: 100000, maxInferences: 1000000000 };
25
+
22
26
  // One proof step: a goal, how it was justified, and the steps it used.
23
27
  export class Node {
24
28
  constructor(goal, by, bindings = NO_NODES, children = NO_NODES, collectedUses = null, final = false, scoped = NO_NODES) {
package/src/n3.js CHANGED
@@ -21,7 +21,7 @@
21
21
  // universals are qbnode(Label) and qvar(Name), and a rule's graph pattern
22
22
  // matches it as a set, up to a one-to-one renaming of those. Built-in
23
23
  // predicates of a body become goals defined in LS (n3-builtins.js).
24
- import { run } from './engine.js';
24
+ import { COMPILED_LIMITS, run } from './engine.js';
25
25
  import { loadText } from './lang.js';
26
26
  import { Program, Source } from './program.js';
27
27
  import { Struct, Var, conjunction, isGround } from './terms.js';
@@ -1135,15 +1135,12 @@ function conclusionsToN3(doc, { triples, contradiction }, { mode = 'new', string
1135
1135
  return { n3: writeN3(triples, { prefixes: doc.prefixes, strings, blankNodePrefix }), triples, contradiction };
1136
1136
  }
1137
1137
 
1138
- // Generous bounds: N3 programs often run longer than eyemind's defaults.
1139
- const N3_LIMITS = { maxDepth: 1000000, maxIterations: 100000, maxInferences: 1000000000 };
1140
-
1141
1138
  // Reason over N3 sources. Returns { n3, triples, contradiction, program,
1142
1139
  // result }; with proof, result.proof is eyemind's checked proof of the
1143
1140
  // compiled program.
1144
1141
  export function reasonN3(sources, { base = '', mode = 'new', strings = 'auto', limits = {}, proof = false, goals = [], readFile = null, readDocument = null } = {}) {
1145
1142
  const compiled = compileSources(sources, { base, readFile, readDocument, native: true });
1146
- const result = run(compiled.nativeProgram ?? loadText(compiled.program, 'compiled.js'), { ...N3_LIMITS, ...limits, proof, goals });
1143
+ const result = run(compiled.nativeProgram ?? loadText(compiled.program, 'compiled.js'), { ...COMPILED_LIMITS, ...limits, proof, goals });
1147
1144
  return { ...resultToN3(compiled.doc, result, { mode, strings }), get program() { return compiled.program; }, result };
1148
1145
  }
1149
1146
 
@@ -1,5 +1,5 @@
1
1
 
2
- import { compactIRI, iri, variable, termEquals } from './srl-term.js';
2
+ import { compactIRI, iri, variable, termEquals, termKey } from './srl-term.js';
3
3
  import { tripleHasBlankNode, tripleHasVariableTripleTerm } from './srl-assignments.js';
4
4
 
5
5
  function analyze(program, options = {}) {
@@ -212,7 +212,7 @@ function fixedTermIndexKey(term) {
212
212
  if (term.type === 'var') return null;
213
213
  if (term.type === 'path') return null;
214
214
  if (term.type === 'triple' && containsVariableTerm(term)) return null;
215
- return termIndexKey(term);
215
+ return termKey(term);
216
216
  }
217
217
 
218
218
  function containsVariableTerm(term) {
@@ -226,20 +226,6 @@ function containsVariableTerm(term) {
226
226
  return false;
227
227
  }
228
228
 
229
- function literalIndexValue(value) {
230
- if (typeof value === 'bigint') return `${value.toString()}n`;
231
- return JSON.stringify(value);
232
- }
233
-
234
- function termIndexKey(term) {
235
- if (!term) return 'null';
236
- if (term.type === 'iri') return `I:${term.value}`;
237
- if (term.type === 'blank') return `B:${term.value}`;
238
- if (term.type === 'literal') return `L:${literalIndexValue(term.value)}^^${term.datatype || ''}@${term.lang || ''}--${term.langDir || ''}`;
239
- if (term.type === 'triple') return `T:${termIndexKey(term.s)} ${termIndexKey(term.p)} ${termIndexKey(term.o)}`;
240
- return JSON.stringify(term);
241
- }
242
-
243
229
  function stratificationLayers(ruleCount, components, componentOf, edges) {
244
230
  if (ruleCount === 0) return [];
245
231
  const levels = Array(ruleCount).fill(0);
package/src/srl-term.js CHANGED
@@ -131,6 +131,7 @@ function formatTerm(term, prefixes = {}) {
131
131
  }
132
132
 
133
133
  export {
134
+ termKey,
134
135
  RDF_NS,
135
136
  RDF_TYPE,
136
137
  RDF_FIRST,
package/src/srl.js CHANGED
@@ -35,7 +35,7 @@ import { analyze } from './srl-analyze.js';
35
35
  import { BUILTIN_SIGNATURES, canonicalBuiltinName } from './srl-builtin-names.js';
36
36
  import { libraryText } from './srl-functions.js';
37
37
  import { Parser } from './srl-parser.js';
38
- import { run } from './engine.js';
38
+ import { COMPILED_LIMITS, run } from './engine.js';
39
39
  import { loadText, statementSources } from './lang.js';
40
40
  import { Program, Source } from './program.js';
41
41
  import { DEFAULT_GRAPH } from './rdf.js';
@@ -786,10 +786,6 @@ function collectClauseVars(clauses, out) {
786
786
  }
787
787
  }
788
788
 
789
-
790
- // Generous bounds: rule sets over real data run longer than eyemind's defaults.
791
- const SRL_LIMITS = { maxDepth: 1000000, maxIterations: 100000, maxInferences: 1000000000 };
792
-
793
789
  // Reason over a rule set. Options: base, filename, resolve (IMPORTS), data
794
790
  // (the base graph as RDF quads), all (the base graph too), limits and proof.
795
791
  // Returns { quads, program, prefixes, warnings, result }: the quads are the
@@ -797,7 +793,7 @@ const SRL_LIMITS = { maxDepth: 1000000, maxIterations: 100000, maxInferences: 10
797
793
  // proof of the compiled program.
798
794
  export function reasonSrl(text, { base = null, filename = '<input>', resolve = null, data = [], all = false, limits = {}, proof = false, context = null } = {}) {
799
795
  const compiled = compileSrl(text, { base, filename, resolve, data, context });
800
- const result = run(compiled.nativeProgram ?? loadText(compiled.program, 'compiled.js'), { ...SRL_LIMITS, ...limits, proof });
796
+ const result = run(compiled.nativeProgram ?? loadText(compiled.program, 'compiled.js'), { ...COMPILED_LIMITS, ...limits, proof });
801
797
  const { prefixes, warnings, context: execution } = compiled;
802
798
  return { quads: srlQuads(compiled, srlAnswers(result), { all }), get program() { return compiled.program; }, prefixes, warnings, result, context: execution };
803
799
  }
package/src/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // The release this checkout is; ./release keeps it in step with package.json.
2
- export const VERSION = '0.9.15';
2
+ export const VERSION = '0.9.16';