eyemind 0.8.51 → 0.9.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/LE-SPEC.md +236 -537
- package/LS-SPEC.md +1 -1
- package/README.md +72 -68
- package/package.json +1 -1
- package/src/formats.js +5 -7
- package/src/le.js +1139 -583
- package/src/version.js +1 -1
- package/src/le-odrl.js +0 -213
package/LE-SPEC.md
CHANGED
|
@@ -1,574 +1,273 @@
|
|
|
1
1
|
# Logical English
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
An individual can be an unquoted name such as `Socrates` or `alice`. A variable
|
|
24
|
-
is one capital ASCII letter optionally followed by digits, such as `X` or `Y1`.
|
|
25
|
-
Variables must be declared in their sentence; a quoted `"X"` is an individual.
|
|
26
|
-
Names containing spaces, punctuation or non-ASCII characters use JSON double
|
|
27
|
-
quotes, as in `"René Descartes"`. JSON escapes retain their usual meanings.
|
|
28
|
-
Quote names that would introduce a sentence, such as `"Every"` or `"If"`.
|
|
29
|
-
|
|
30
|
-
Terms also include integers, floats, closed lists and compounds:
|
|
31
|
-
|
|
32
|
-
```text
|
|
33
|
-
9007199254740993
|
|
34
|
-
-0.0
|
|
35
|
-
[Alice, Bob, [1, 2]]
|
|
36
|
-
pair(Alice, Bob)
|
|
37
|
-
"a compound name"(Alice, 1)
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Integers have optional leading `-`, no leading zero except `0`, and arbitrary
|
|
41
|
-
precision. A decimal point with digits on both sides, or an exponent, denotes a
|
|
42
|
-
finite binary64 float: `1.0`, `0.25`, `1e3`. Integers and floats remain distinct
|
|
43
|
-
terms. `1.` is integer `1` followed by the sentence terminator. Nonfinite numeric
|
|
44
|
-
tokens are rejected. A compound has at least one argument. A closed list may be
|
|
45
|
-
empty; there is no open-list surface syntax, although a `"."(Head, Tail)` compound
|
|
46
|
-
can retain an LS list with a nonempty tail as data. Term and expression
|
|
47
|
-
nesting is limited to 256 levels.
|
|
48
|
-
|
|
49
|
-
## Positive statements
|
|
50
|
-
|
|
51
|
-
The following forms have the indicated LS meanings. `T`, `U` and the arguments
|
|
52
|
-
stand for terms; `class` and `relation` stand for names as defined above.
|
|
53
|
-
|
|
54
|
-
| LE form | LS term |
|
|
55
|
-
| --- | --- |
|
|
56
|
-
| `T is a class` | `class(T)` |
|
|
57
|
-
| `T is an class` | `class(T)` |
|
|
58
|
-
| `T is class` | `class(T)` |
|
|
59
|
-
| `T is a relation of U` | `relation(T, U)` |
|
|
60
|
-
| `T is an relation of U` | `relation(T, U)` |
|
|
61
|
-
| `T has relation U` | `relation(T, U)` |
|
|
62
|
-
| `relation(T, U, ...)` | The corresponding compound goal. |
|
|
63
|
-
| `relation` | An atom used as a goal, with arity zero. |
|
|
64
|
-
|
|
65
|
-
The articles `a` and `an` have the same semantics. They do not introduce an
|
|
66
|
-
existential variable. For example, `Socrates is a human.` states
|
|
67
|
-
`fact(human('Socrates'))`. Write an existential declaration to introduce an
|
|
68
|
-
unnamed individual.
|
|
69
|
-
|
|
70
|
-
`and` joins positive statements. A sentence containing only positive statements
|
|
71
|
-
states them as facts. A universally quantified fact is explicit:
|
|
72
|
-
|
|
73
|
-
```text
|
|
74
|
-
Ada is a human and Ada is a mathematician.
|
|
75
|
-
For every X, matching(pair(X, X)).
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Variables declared by `For every` are universal within that sentence. Each
|
|
79
|
-
sentence has its own scope. Repeating a declaration in one scope is an error.
|
|
80
|
-
|
|
81
|
-
## RDF vocabulary names
|
|
82
|
-
|
|
83
|
-
Declare a prefix before using its names. ODRL, DPV and DPV extension
|
|
84
|
-
namespaces can appear together in the same file.
|
|
85
|
-
|
|
86
|
-
```text
|
|
87
|
-
Use prefix ex with namespace "https://example.org/research#".
|
|
88
|
-
Use prefix odrl with namespace "http://www.w3.org/ns/odrl/2/".
|
|
89
|
-
Use prefix dpv with namespace "https://w3id.org/dpv#".
|
|
90
|
-
|
|
91
|
-
ex:agreement is an odrl:Agreement.
|
|
92
|
-
ex:study is a dpv:Process.
|
|
93
|
-
ex:study has dpv:hasPurpose dpv:AcademicResearch.
|
|
94
|
-
|
|
95
|
-
Find every X such that X has dpv:hasPurpose dpv:AcademicResearch.
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Prefixes start with an ASCII letter and can also contain digits and
|
|
99
|
-
underscores. Local names contain ASCII letters, digits, underscores and
|
|
100
|
-
hyphens, and cannot start with a hyphen. Prefixes and local names are
|
|
101
|
-
case-sensitive. A declaration binds a prefix to a quoted absolute IRI.
|
|
102
|
-
Each file declares its own prefixes, at most once per prefix. Prefix
|
|
103
|
-
expansion appends the local name to the namespace exactly as stated.
|
|
104
|
-
`iri("...")` terms can express IRIs outside this abbreviation syntax.
|
|
105
|
-
|
|
106
|
-
In facts, rules and questions, a qualified class or property uses the
|
|
107
|
-
same `rdf/3` relation:
|
|
108
|
-
|
|
109
|
-
| LE form | LS term |
|
|
3
|
+
[Logical English](https://github.com/LogicalContractsOrg/LogicalEnglish) (LE)
|
|
4
|
+
is the controlled natural language of Robert Kowalski, Jacinto Dávila, Miguel
|
|
5
|
+
Calejo, Galileo Sartor and their colleagues for writing legal and business
|
|
6
|
+
rules as English that a computer runs. eyemind reads `.le` files in the core
|
|
7
|
+
that the original implementation, LE 1.0 with its
|
|
8
|
+
[syntax document](https://github.com/LogicalContractsOrg/LogicalEnglish/blob/main/le_syntax.md),
|
|
9
|
+
and [Logical English 2](https://github.com/LogicalContractsOrg/LogicalEnglish2)
|
|
10
|
+
share, and compiles them to ordinary Logic Script (LS). This is an input
|
|
11
|
+
extension: the meaning of the compiled program is defined by the
|
|
12
|
+
[LS specification](https://eyereasoner.github.io/eyemind/LS-SPEC), and this
|
|
13
|
+
document says how eyemind reads LE and what it compiles each part to. Where the
|
|
14
|
+
two LE implementations differ, it says which reading eyemind follows.
|
|
15
|
+
|
|
16
|
+
## Documents
|
|
17
|
+
|
|
18
|
+
A document is a sequence of sections. Each section starts with a header that
|
|
19
|
+
ends with `:`:
|
|
20
|
+
|
|
21
|
+
| Header | Section |
|
|
110
22
|
| --- | --- |
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
| `
|
|
114
|
-
|
|
115
|
-
`
|
|
116
|
-
statements take a resource or variable as their subject. Objects can
|
|
117
|
-
also be numbers and explicit RDF terms such as
|
|
118
|
-
`literal("dataset", datatype("http://www.w3.org/2001/XMLSchema#string"))`.
|
|
119
|
-
Ordinary unqualified class and relation names retain their LS meanings.
|
|
120
|
-
|
|
121
|
-
The default LE output abbreviates IRIs using available prefixes and
|
|
122
|
-
includes the declarations it uses. Other IRIs retain their explicit
|
|
123
|
-
terms. When input files assign the same prefix to different namespaces,
|
|
124
|
-
the final declaration supplies the output abbreviation. Earlier files'
|
|
125
|
-
expanded IRIs retain their values. For triple conclusions, `--to turtle`
|
|
126
|
-
writes the RDF graph and `--all` adds the stated RDF facts.
|
|
127
|
-
|
|
128
|
-
Prefix declarations specify names. The facts and rules supply their
|
|
129
|
-
meaning for a run. The research access example uses ODRL permissions,
|
|
130
|
-
prohibitions, constraints and a duty with DPV purpose and consent
|
|
131
|
-
evidence. Its ordinary LE rules specify the scenario's policy decisions; a
|
|
132
|
-
Turtle companion decides similar requests with the ODRL snapshot evaluator.
|
|
133
|
-
[Research access example](https://eyereasoner.github.io/eyemind/examples/deck/research-access-le) · [Turtle companion](https://eyereasoner.github.io/eyemind/examples/deck/research-access-odrl) · [ODRL Vocabulary](https://www.w3.org/TR/odrl-vocab/) · [Data Privacy Vocabulary 2.3](https://w3id.org/dpv/2.3/dpv/)
|
|
134
|
-
|
|
135
|
-
## Rules and calculations
|
|
23
|
+
| `the templates are:`, `the predicates are:` | Templates, separated by commas or full stops. |
|
|
24
|
+
| `the knowledge base NAME includes:`, `the contract NAME states that:` | Facts and rules. |
|
|
25
|
+
| `the ontology is:` | Facts and rules; a fact `a student is a person.` relates the kinds `student` and `person`. |
|
|
26
|
+
| `scenario NAME is:` | Facts and rules of one scenario, and its expected answers. |
|
|
27
|
+
| `query NAME is:` | One query. |
|
|
136
28
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
For every X and Y, if X is a parent of Y then X is an ancestor of Y.
|
|
141
|
-
If Alice is a person then Alice is a participant.
|
|
142
|
-
```
|
|
29
|
+
`the target language is: prolog.` is accepted and ignored. The sections can
|
|
30
|
+
come in any order, and a template can be used before it is declared. Several
|
|
31
|
+
`.le` files are read as one document.
|
|
143
32
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
forward LS rule. Both sides may contain conjunctions. A conclusion variable
|
|
148
|
-
must be supplied by a premise or explicitly declared existentially. The
|
|
149
|
-
compiler checks the stated order of premises for calculations and absence tests;
|
|
150
|
-
actual values must also satisfy LS's runtime requirements.
|
|
33
|
+
Sentences end with a full stop followed by white space or the end of the file;
|
|
34
|
+
a sentence can span lines. `%` or `#` starts a comment through the end of the
|
|
35
|
+
line, and `/* ... */` is a block comment. Words are compared without case.
|
|
151
36
|
|
|
152
|
-
|
|
37
|
+
A token is a word (letters, digits and underscores, joined by hyphens or
|
|
38
|
+
apostrophes, as in `JE-201` and `don't`), a final `'s` as a word of its own, a
|
|
39
|
+
number (`42`, `3.14`, `1,000,000`), a date (`2021-10-09`), a quoted text
|
|
40
|
+
(`"..."` or `'...'`), or a punctuation sign. The indentation of a line counts a
|
|
41
|
+
space as one and a tab as four, as LE's editor shows it.
|
|
153
42
|
|
|
154
|
-
|
|
155
|
-
| --- | --- |
|
|
156
|
-
| `Y is the value of E` | `is(Y, E)` |
|
|
157
|
-
| `X is greater than E` | `gt(X, E)` |
|
|
158
|
-
| `X is less than E` | `lt(X, E)` |
|
|
159
|
-
| `X is at least E` | `ge(X, E)` |
|
|
160
|
-
| `X is at most E` | `le(X, E)` |
|
|
161
|
-
| `X is equal to E` | `eq(X, E)` |
|
|
162
|
-
| `X is different from E` | `ne(X, E)` |
|
|
163
|
-
|
|
164
|
-
Expressions contain numbers, declared variables, parentheses, unary `-` and
|
|
165
|
-
binary `+`, `-`, `*`, `/`. Unary minus binds most tightly, then multiplication
|
|
166
|
-
and division, then addition and subtraction. Binary operators associate left.
|
|
167
|
-
They compile to `neg`, `add`, `sub`, `mul` and `div`. Only the value-of form
|
|
168
|
-
binds its left variable; comparisons require their inputs beforehand.
|
|
169
|
-
|
|
170
|
-
An expression can also call an LS arithmetic function by name, with
|
|
171
|
-
expressions as its arguments, and use the constants `pi`, `e` and `tau`:
|
|
43
|
+
## Templates
|
|
172
44
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
The functions are those of [LS-SPEC Section 5.2](https://eyereasoner.github.io/eyemind/LS-SPEC#52-functions-and-arities),
|
|
179
|
-
such as `pow`, `floordiv`, `mod`, `gcd`, `lcm`, `sqrt`, `exp`, `log`, `sin`,
|
|
180
|
-
`cos`, `atan2`, `abs` and `hypot`, except `and`, `or` and `not`, which are LE
|
|
181
|
-
words. A call with an arity the function does not take is an error naming
|
|
182
|
-
its line. As in LS, `pow` and `floordiv` of integers stay exact, while
|
|
183
|
-
`exp`, `log` and the trigonometric functions give floats.
|
|
45
|
+
A template is a sentence pattern: words and places. A place is a phrase between
|
|
46
|
+
asterisks, such as `*a person*`; LE1 also writes templates without asterisks,
|
|
47
|
+
and in a template without any, `a` or `an` and the word after it make a place.
|
|
184
48
|
|
|
185
49
|
```text
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
50
|
+
the templates are:
|
|
51
|
+
*a person* acquires British citizenship on *a date*,
|
|
52
|
+
*a person* says that *a sentence*,
|
|
53
|
+
a person has a balance.
|
|
189
54
|
```
|
|
190
55
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
56
|
+
Each template is a relation whose name joins its words with underscores and
|
|
57
|
+
whose arguments are its places in order: `acquires_British_citizenship_on/2`,
|
|
58
|
+
`says_that/2`, `has/2`. A name that is an LS primitive or control, or `date`,
|
|
59
|
+
gets the prefix `le_`. Two templates with different words for one name and
|
|
60
|
+
arity are an error. A place after the word `that` holds a sentence.
|
|
61
|
+
|
|
62
|
+
## Sentences
|
|
63
|
+
|
|
64
|
+
A sentence matches a template when it has the template's words in order, with
|
|
65
|
+
at least one token in each place and balanced brackets in each. eyemind tries
|
|
66
|
+
the templates with a `that` place first, as LE does, then the templates with the
|
|
67
|
+
most words, a declared template before a built-in one, and takes the first that
|
|
68
|
+
matches with a valid term in every place. A sentence that matches no template
|
|
69
|
+
is an error that quotes it.
|
|
70
|
+
|
|
71
|
+
The tokens in a place are a term:
|
|
72
|
+
|
|
73
|
+
- A number is an exact integer, or a float when it has a fraction or an
|
|
74
|
+
exponent; `-` before a number negates it. Commas may group thousands.
|
|
75
|
+
- A date is the compound `date(Year, Month, Day)`.
|
|
76
|
+
- A quoted text is a name.
|
|
77
|
+
- `[A, B, C]` is a list of terms.
|
|
78
|
+
- `a`, `an`, `some`, `each` or `which`, followed by at most six words,
|
|
79
|
+
introduces a variable: `a person`, `an other person`, `a second date`. The
|
|
80
|
+
same phrase again is the same variable.
|
|
81
|
+
- `the` followed by the words of a variable introduced earlier in the clause
|
|
82
|
+
refers to it: `the person`, `the other person`. A definite phrase that refers
|
|
83
|
+
to no variable is a name, written with its article: `the UK`, `the white
|
|
84
|
+
rabbit`. This follows LE2; the same phrase names the same thing everywhere.
|
|
85
|
+
- A phrase whose last word is an id names its variable by the id: `a person X`
|
|
86
|
+
is the variable `X`, and `X` alone then refers to it. An id is one capital
|
|
87
|
+
letter with optional digits, or a word of at most six capitals and digits
|
|
88
|
+
other than `UK`. eyemind does not read LE2's short proper names such as `Bob`
|
|
89
|
+
as ids: LE1 programs use them as names.
|
|
90
|
+
- A single capital letter with optional digits, such as `L` or `T1`, is a
|
|
91
|
+
variable even when no phrase introduced it. Longer ids need an introducing
|
|
92
|
+
phrase, because LE1 programs use acronyms such as `GST` as names.
|
|
93
|
+
- Other words are a name, written as they are, such as `Socrates` or
|
|
94
|
+
`cash at bank`.
|
|
95
|
+
|
|
96
|
+
In the place of a `that`, a sentence of a template is a term: the template's
|
|
97
|
+
relation with its arguments, as data.
|
|
98
|
+
|
|
99
|
+
## Facts and rules
|
|
100
|
+
|
|
101
|
+
In a knowledge base or a scenario, a sentence is a fact, or a rule
|
|
102
|
+
`conclusion if conditions.` The conclusion matches a declared template or the
|
|
103
|
+
type template `*an object* is a *type*` (the relation `is_a/2`, whose type is a
|
|
104
|
+
name). A fact with a variable holds for every value. In an ontology, a fact
|
|
105
|
+
whose subject starts with `a` or `an` is about the kind: `a student is a person.`
|
|
106
|
+
states `is_a('student', 'person')`.
|
|
107
|
+
|
|
108
|
+
The conditions are joined by `and` and `or`. Each connective has the
|
|
109
|
+
indentation of its line; a connective in the middle of a line has the
|
|
110
|
+
indentation of that line, and a line break without a connective joins the lines
|
|
111
|
+
with `and` where both lines are conditions. eyemind reads the connectives as
|
|
112
|
+
LE's indentation does: the conditions are split at the least indented
|
|
113
|
+
connectives, joined from the top down, and each part is read in the same way.
|
|
114
|
+
So a deeper indentation binds tighter:
|
|
199
115
|
|
|
200
116
|
```text
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
117
|
+
a person is eligible a person is eligible
|
|
118
|
+
if the person is a resident if the person is a resident
|
|
119
|
+
or the person is a citizen or the person is a citizen
|
|
120
|
+
and the person is an adult. and the person is an adult.
|
|
205
121
|
```
|
|
206
122
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
`implies(A(X), C(X))` followed by `implies(B(X), C(X))`. The sentence's
|
|
212
|
-
declarations are shared, and an alternative need not use every declared
|
|
213
|
-
variable, but each conclusion variable must be supplied by every alternative
|
|
214
|
-
or introduced with `there exists`. An existential conclusion therefore has a
|
|
215
|
-
witness per alternative and firing. The order of premises is checked within
|
|
216
|
-
each alternative.
|
|
217
|
-
|
|
218
|
-
Questions have no `or`: ask one question per alternative, or ask for a relation
|
|
219
|
-
that an `or` rule derives. Conclusions are never disjunctive.
|
|
220
|
-
|
|
221
|
-
## Aggregates
|
|
222
|
-
|
|
223
|
-
```text
|
|
224
|
-
For every M and T,
|
|
225
|
-
if M is a member and T is the sum of F for every C and F such that charge(M, C, F)
|
|
226
|
-
then T is an amountDue of M.
|
|
227
|
-
For every V and N,
|
|
228
|
-
if V is a participant and N is the number of C such that choice(V, C) and N is at least 2
|
|
229
|
-
then V is a spoiledVoter.
|
|
230
|
-
For every C and N,
|
|
231
|
-
if C is a candidate and N is the number of V such that
|
|
232
|
-
(choice(V, C) and V is an eligibleVoter and it is not known that V is a spoiledVoter)
|
|
233
|
-
then N is a voteCount of C.
|
|
234
|
-
```
|
|
123
|
+
The left rule means *(resident or citizen) and adult*, the right one *resident
|
|
124
|
+
or (citizen and adult)*. LE1 rejects different connectives at one indentation;
|
|
125
|
+
eyemind reads them from the top down, as LE2 does. A body may start with `and`
|
|
126
|
+
after `if`, as some LE1 programs write it.
|
|
235
127
|
|
|
236
|
-
|
|
128
|
+
A condition is a sentence of a template, a comparison, or one of the following,
|
|
129
|
+
each of which takes the lines that follow it up to the next line that starts
|
|
130
|
+
with a connective at the same or a lesser indentation:
|
|
237
131
|
|
|
238
|
-
|
|
|
132
|
+
| Condition | LS |
|
|
239
133
|
| --- | --- |
|
|
240
|
-
| `
|
|
241
|
-
| `
|
|
242
|
-
| `
|
|
243
|
-
| `
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
For every X, if X is a person and it is not known that X is blocked
|
|
277
|
-
then X is an applicant.
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
It compiles to `not(blocked(X))`. Its variables must be supplied by earlier
|
|
281
|
-
positive premises or calculations. LS stratification decides when the tested
|
|
282
|
-
relation is complete. This means absence of a proof in this program, rather
|
|
283
|
-
than classical mathematical negation. Ordinary `not` is rejected. Explicit
|
|
284
|
-
negative evidence can use its own positive relation, such as `not_human`.
|
|
285
|
-
|
|
286
|
-
```text
|
|
287
|
-
For every X, if X is a person then there exists Y such that
|
|
288
|
-
Y is a record and X is an owner of Y.
|
|
289
|
-
There exists X such that X is a record.
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
`there exists` introduces fresh variables for a conclusion, after any universal
|
|
293
|
-
declarations. Every introduced variable must occur in that conclusion. The
|
|
294
|
-
compiler uses an ordinary LS forward rule with head-only variables; a standalone
|
|
295
|
-
existential sentence uses premise `'true'`. LS supplies Skolem witnesses. The
|
|
296
|
-
same variable shares one witness across the heads of that firing. A witness
|
|
297
|
-
does not assert a distinct real-world object or a minimum number of objects.
|
|
298
|
-
|
|
299
|
-
## Questions and contradictions
|
|
300
|
-
|
|
301
|
-
```text
|
|
302
|
-
Find every X such that X is mortal.
|
|
303
|
-
Find every X and Y such that X is an ancestor of Y.
|
|
304
|
-
Find whether Socrates is mortal.
|
|
305
|
-
For every X, it is impossible that X is a person and X is blocked.
|
|
306
|
-
It is impossible that Alice is blocked.
|
|
307
|
-
Contradiction.
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
Questions compile to `query(...)`; their declarations establish variable scope,
|
|
311
|
-
and the answers are instances of the whole question, without a separate
|
|
312
|
-
projection. `Find whether` introduces no variables. A question can use a
|
|
313
|
-
conjunction, calculations and absence tests. Without questions the run reports
|
|
314
|
-
derived conclusions, following LS's default; given facts alone are not printed.
|
|
315
|
-
|
|
316
|
-
`It is impossible that` compiles to an LS contradiction with the stated body.
|
|
317
|
-
`Contradiction.` is an unconditional contradiction, also used to serialize a
|
|
318
|
-
run's `'false'` conclusion. Contradictions halt reasoning with exit code 65;
|
|
319
|
-
they do not produce the continuing RDF conflict reports of `--owl2rl`.
|
|
320
|
-
|
|
321
|
-
## Examples combining features
|
|
322
|
-
|
|
323
|
-
These programs use the grammar above without additional syntax:
|
|
324
|
-
|
|
325
|
-
| Example | What it demonstrates |
|
|
134
|
+
| `it is not the case that C`, `not the case that C` | `not(C)` |
|
|
135
|
+
| `for all cases in which C it is the case that D` | `not([C, not(D)])` |
|
|
136
|
+
| `R is the sum of each X such that C` | `findall(X, C, L)` and the sum of `L`; `0` for none |
|
|
137
|
+
| `R is the count of each X such that C` | the length of `L`; `0` for none |
|
|
138
|
+
| `R is the average of each X such that C` | the sum divided by the count; none for none |
|
|
139
|
+
| `R is the min of each X such that C`, `minimum`, `max`, `maximum` | the least or greatest of `L`; none for none |
|
|
140
|
+
| `R is the list of each X such that C` | `L` itself |
|
|
141
|
+
| `R is a collection of X where C` | `L` itself, as LE1 writes it |
|
|
142
|
+
|
|
143
|
+
An aggregate collects one value for every solution of its conditions, in the
|
|
144
|
+
order they are found, as Prolog's `findall` does: a value found twice counts
|
|
145
|
+
twice. The result phrase of an aggregate is the phrase before `is the`, after any
|
|
146
|
+
connective.
|
|
147
|
+
|
|
148
|
+
## Negation
|
|
149
|
+
|
|
150
|
+
Variables that occur only inside a negation stand for any value there; eyemind
|
|
151
|
+
renames them `_0`, `_1`, ..., which LS negation treats as anonymous. LE's rules
|
|
152
|
+
are written for Prolog, whose negation also succeeds when no instance of its
|
|
153
|
+
goal holds if one of its variables is unbound. LS requires the named variables
|
|
154
|
+
of a negation to be bound, so a negation with a variable no earlier condition
|
|
155
|
+
binds, up to three such variables, tests each one at run time: while it is
|
|
156
|
+
unbound (`is_var`), the negation stands for any value there; once bound
|
|
157
|
+
(`is_nonvar`), it is that value. When a fact or rule of the document leaves a
|
|
158
|
+
variable of its conclusion open, no condition surely binds a variable, and
|
|
159
|
+
every negation tests its variables in this way.
|
|
160
|
+
|
|
161
|
+
## Arithmetic, comparisons and built-in templates
|
|
162
|
+
|
|
163
|
+
A comparison has `=`, `==`, `!=`, `\=`, `\==`, `<`, `>`, `<=`, `=<` or `>=`
|
|
164
|
+
between two sides. A side is a term, or a formula of terms with `+`, `-`, `*`,
|
|
165
|
+
`/`, `//`, `mod`, parentheses and the functions `ceiling`, `floor`, `round`,
|
|
166
|
+
`truncate`, `integer`, `abs` and `sqrt`. A term in a formula is any of the terms
|
|
167
|
+
above, such as `the gain = the proceeds - the cost base`.
|
|
168
|
+
|
|
169
|
+
| Comparison | LS |
|
|
326
170
|
| --- | --- |
|
|
327
|
-
|
|
|
328
|
-
|
|
|
329
|
-
|
|
|
330
|
-
|
|
|
331
|
-
| [Symbolic differentiation](https://eyereasoner.github.io/eyemind/examples/deck/symbolic-derivative-le) | Structural recursion over expression trees, constructed derivatives and evaluation at separate points. |
|
|
332
|
-
| [British citizenship](https://eyereasoner.github.io/eyemind/examples/deck/british-citizenship-le) | Section 1 of the British Nationality Act 1981: alternative premises, a presumption that holds unless the contrary is shown, date comparisons and citizenship through a derived parent. |
|
|
333
|
-
| [Library fines](https://eyereasoner.github.io/eyemind/examples/deck/library-fines-le) | Charges from alternative rules, then the sum, number and maximum per member over distinct combinations. |
|
|
334
|
-
| [Election tally](https://eyereasoner.github.io/eyemind/examples/deck/election-tally-le) | Eligibility by alternatives, distinct choices, an absence test inside a count, winners by maximum with ties, and a quorum. |
|
|
335
|
-
| [International data transfers](https://eyereasoner.github.io/eyemind/examples/deck/data-transfers-le) | An ODRL snapshot with rules: GDPR Chapter V observations derived with alternative premises and absence tests over DPV, location and GDPR-extension names, decided by one permission per basis and a prohibition that wins. |
|
|
336
|
-
| [Breach notification](https://eyereasoner.github.io/eyemind/examples/deck/breach-notification-le) | An ODRL snapshot with rules: GDPR Articles 33 and 34 as permissions and prohibitions, with requests, observations and a processor's duty evidence derived from breach records by comparisons over hours. |
|
|
337
|
-
|
|
338
|
-
Their decks state the modeled assumptions and what the checked proofs establish.
|
|
339
|
-
Bounds and finite expression domains are explicit in the programs.
|
|
340
|
-
|
|
341
|
-
## DPV hierarchies
|
|
171
|
+
| `A = B`, `A == B`, `A is equal to B` | `unify(A, B)` between terms; `is` when one side is a formula; `eq` between formulas |
|
|
172
|
+
| `A != B`, `A \= B`, `A is different from B`, `A is not equal to B` | `not_unify(A, B)` between terms; `ne` otherwise |
|
|
173
|
+
| `A \== B` | `not_identical(A, B)` |
|
|
174
|
+
| `<`, `>`, `<=` or `=<`, `>=`, and `is less than`, `is greater than`, `is less than or equal to`, `is greater than or equal to`, `is less or equal to`, `is greater or equal to` | `lt`, `gt`, `le`, `ge` |
|
|
342
175
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
Use prefix skos with namespace "http://www.w3.org/2004/02/skos/core#".
|
|
348
|
-
|
|
349
|
-
ex:study has dpv:hasPurpose dpv:AcademicResearch.
|
|
350
|
-
dpv:AcademicResearch has skos:broader dpv:ResearchAndDevelopment.
|
|
351
|
-
Find whether ex:study has purposeWithin dpv:ResearchAndDevelopment.
|
|
352
|
-
```
|
|
176
|
+
`/` divides as Prolog does: integers that divide give an integer, other
|
|
177
|
+
operands a float. `//` is floor division. LE1's `A is B` equates or evaluates
|
|
178
|
+
as `=` does when a side is a variable or a formula; between two names no
|
|
179
|
+
template matches.
|
|
353
180
|
|
|
354
|
-
|
|
355
|
-
program supplies its observations and SKOS edges. DPV 2.3 uses SKOS
|
|
356
|
-
broader and narrower relations for its default taxonomy representation.
|
|
357
|
-
[DPV 2.3](https://w3id.org/dpv/2.3/dpv/)
|
|
358
|
-
|
|
359
|
-
| Observation property | LE conclusion |
|
|
181
|
+
| Built-in template | LS |
|
|
360
182
|
| --- | --- |
|
|
361
|
-
| `
|
|
362
|
-
|
|
|
363
|
-
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
`
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
##
|
|
372
|
-
|
|
373
|
-
|
|
183
|
+
| `*a* is after *b*`, `is before`, `is after or equal to`, `is before or equal to`, `is not before` | the standard order with `compare`, so dates compare in time order |
|
|
184
|
+
| `*a* is *n* days after *b*`, `*a* is *n* day after *b*` | days in the proleptic Gregorian calendar; any two of the three give the third |
|
|
185
|
+
| `*a* is in *b*` | `a` is a member of the list `b` |
|
|
186
|
+
| `*a* is known` | `is_nonvar(a)` |
|
|
187
|
+
| `the minimum of *a* and *b* is *c*`, `the maximum of ...` | `is(c, min(a, b))`, `max` |
|
|
188
|
+
| `the length of *a* is *b*` | the length of the list `a` |
|
|
189
|
+
| `*a* is the reverse of *b*` | `a` is the list `b` reversed |
|
|
190
|
+
| `appending *a* then *b* gives *c*` | `c` is `a` followed by `b` |
|
|
191
|
+
| `*a* has *b* as head before *c*` | `unify(a, [b, ...c])` |
|
|
192
|
+
|
|
193
|
+
## Scenarios, queries and expected answers
|
|
194
|
+
|
|
195
|
+
A query has one sentence of conditions, read as a rule's conditions are.
|
|
196
|
+
`which person`, like `a person`, introduces a variable, and LE1's prefix
|
|
197
|
+
`for which event:` introduces one too. A scenario has facts and rules, and
|
|
198
|
+
expectations:
|
|
374
199
|
|
|
375
200
|
```text
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
evaluation has policy eligibility.
|
|
380
|
-
evaluation has request issueAlice.
|
|
381
|
-
evaluation has conflictStrategy prohibit.
|
|
201
|
+
scenario alice is:
|
|
202
|
+
John is born in the UK on 2021-10-09.
|
|
203
|
+
one expects answers ["John acquires British citizenship on 2021-10-09"].
|
|
382
204
|
```
|
|
383
205
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
is
|
|
387
|
-
validation, evaluation and reporting LS of `src/odrl.js`.
|
|
206
|
+
`NAME expects answers [...]` and `NAME expects [...]` state the answers the
|
|
207
|
+
query `NAME` gives in the scenario; a trailing `and unknowns [...]` is ignored.
|
|
208
|
+
Each query is answered in each scenario, or once when the document has none.
|
|
388
209
|
|
|
389
|
-
|
|
390
|
-
statements, in premises and conclusions, are statements of the snapshot's
|
|
391
|
-
RDF graph, with names mapped as for facts. A rule typically derives a state's
|
|
392
|
-
observations or a request's duty evidence from other facts, so the
|
|
393
|
-
evaluator decides on what the rules establish:
|
|
210
|
+
## Compilation to LS
|
|
394
211
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
then S has residenceVerified true.
|
|
399
|
-
```
|
|
212
|
+
Facts and rules compile to LS facts and backward rules (`implied_by`), as LE's
|
|
213
|
+
Prolog target runs them; a ground fact is `fact(...)`, a fact with a variable a
|
|
214
|
+
backward rule with the body `'true'`.
|
|
400
215
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
since a missing observation leaves a constraint unknown. The same
|
|
409
|
-
[snapshot profile](https://eyereasoner.github.io/eyemind/#odrl-snapshots) applies
|
|
410
|
-
to Turtle and LE, including missing observations, unsupported policy features
|
|
411
|
-
and conflict strategies. Vocabulary by itself does not enable evaluation.
|
|
412
|
-
|
|
413
|
-
Names expand as follows, with case preserved:
|
|
414
|
-
|
|
415
|
-
| LE form or name | RDF mapping |
|
|
416
|
-
| --- | --- |
|
|
417
|
-
| An ordinary individual name | An IRI formed by appending it to the declared namespace. |
|
|
418
|
-
| Classes `evaluation`, `request`, `state` | `eval:Evaluation`, `eval:Request`, `eval:State`. |
|
|
419
|
-
| Classes `policy`, `agreement`, `permission`, `prohibition`, `constraint`, `logicalConstraint`, `duty`, `action` | `odrl:Set`, `odrl:Agreement`, `odrl:Permission`, `odrl:Prohibition`, `odrl:Constraint`, `odrl:LogicalConstraint`, `odrl:Duty`, `odrl:Action`. |
|
|
420
|
-
| Classes `assetCollection`, `partyCollection` | ODRL collection classes, rejected by the snapshot profile. |
|
|
421
|
-
| Properties `policy`, `request`, `state`, `subject`, `conflictStrategy` | The corresponding `eval:` properties. |
|
|
422
|
-
| Properties `profile`, `permission`, `prohibition`, `assignee`, `assigner`, `action`, `target`, `constraint`, `leftOperand`, `operator`, `rightOperand`, `duty` | The corresponding `odrl:` properties. |
|
|
423
|
-
| Properties `andOperands`, `orOperands`, `xoneOperands` | `odrl:and`, `odrl:or`, `odrl:xone`. LE lists become RDF collections. |
|
|
424
|
-
| Properties `fulfilledDuty`, `unfulfilledDuty` | The corresponding `eval:` request evidence properties. |
|
|
425
|
-
| Property `policyConflict` | `odrl:conflict`, the policy-local strategy. |
|
|
426
|
-
| Property `type` | `rdf:type`. |
|
|
427
|
-
| An otherwise unknown class or property | An IRI in the declared namespace; validation still applies. |
|
|
428
|
-
| Values `snapshotProfile`, `perm`, `prohibit`, `invalid`, `eq`, `neq`, `gt`, `gteq`, `lt`, `lteq` | `eval:SnapshotProfile` or the corresponding ODRL strategy/operator IRIs. |
|
|
429
|
-
| Value `withinCategory` | `eval:withinCategory`, the snapshot's DPV hierarchy operator. |
|
|
430
|
-
| Values `true`, `false` | Boolean RDF literals. Quoting does not change an LE name into an RDF string literal. |
|
|
431
|
-
| An integer or float | An exact RDF integer or an `xsd:double` literal. |
|
|
432
|
-
|
|
433
|
-
The unsupported ODRL properties `obligation`, `inheritFrom`, `includedIn`,
|
|
434
|
-
`partOf` and `refinement` retain their ODRL IRIs so the shared validator can
|
|
435
|
-
report them. Explicit RDF values such as `iri("https://example.org/item")` and
|
|
436
|
-
`literal("text", datatype("http://www.w3.org/2001/XMLSchema#string"))` retain
|
|
437
|
-
their terms. `rdf(S, P, O)` facts allow any explicit RDF predicate without an
|
|
438
|
-
abbreviation. A snapshot still has one default graph.
|
|
439
|
-
|
|
440
|
-
The [handicap-card LE example](https://eyereasoner.github.io/eyemind/examples/deck/handicap-card-le)
|
|
441
|
-
contains the complete policies, requests and SOTW. Run it without CLI switches:
|
|
442
|
-
|
|
443
|
-
```sh
|
|
444
|
-
eyemind examples/handicap-card-le.le
|
|
445
|
-
eyemind --program examples/handicap-card-le.le > /tmp/handicap-card-le.js
|
|
446
|
-
eyemind --to turtle /tmp/handicap-card-le.js
|
|
447
|
-
```
|
|
216
|
+
When a document has scenarios, every relation gets the scenario as its first
|
|
217
|
+
argument, a scenario's clauses have the scenario's name there, and the
|
|
218
|
+
knowledge base's clauses have a variable there, bound by the facts
|
|
219
|
+
`'le:scenario'(NAME)`. A knowledge-base fact becomes a rule whose body is
|
|
220
|
+
`'le:scenario'(S)`. So the knowledge base holds in every scenario and a
|
|
221
|
+
scenario's facts in that one, and one program and one proof answer every query
|
|
222
|
+
in every scenario.
|
|
448
223
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
use `has`; for example `issueAlice has decision allowed.`. Status values
|
|
454
|
-
`allowed`, `prohibited`, `notApplicable`, `undetermined`, `valid` and
|
|
455
|
-
`invalidReport` name the corresponding `eval:` IRIs. Report classes include
|
|
456
|
-
`evaluationReport`, `conflict`, `validationError` and `uncertainty`.
|
|
457
|
-
`conflict` as a property means `eval:conflict`; `applicablePermission`,
|
|
458
|
-
`applicableProhibition`, `reportConstraint` and `reportDuty` distinguish the
|
|
459
|
-
report's `eval:permission`, `eval:prohibition`, `eval:constraint` and
|
|
460
|
-
`eval:duty` links from ODRL input properties. Other report fields retain their `eval:` names. Other IRIs
|
|
461
|
-
are written with the run's prefixes, declared after the directive: those the
|
|
462
|
-
file declares, `odrl:` and `eval:`. Inside a witness key, where a bare name
|
|
463
|
-
would read back as a name rather than an IRI, the snapshot namespace also
|
|
464
|
-
needs a prefix: the file's own, or `ns` when it declares none. An IRI that no
|
|
465
|
-
prefix abbreviates stays explicit.
|
|
466
|
-
|
|
467
|
-
Prefix declarations can follow either ODRL directive, and the whole snapshot
|
|
468
|
-
can be written with qualified names, as `ex:mayErase has odrl:action
|
|
469
|
-
odrl:delete.` or `ex:evaluation is a eval:Evaluation.`. After an ODRL
|
|
470
|
-
directive a qualified statement takes the subjects and values the short forms
|
|
471
|
-
take: an ordinary name in the declared namespace, `true` and `false`, and an
|
|
472
|
-
operand list, as `ex:scope has odrl:and [ex:purpose, ex:consent].`. A state
|
|
473
|
-
property or value can use a DPV IRI, for example
|
|
474
|
-
`state has dpv:hasPurpose dpv:AcademicResearch.`. An equality constraint
|
|
475
|
-
can read `dpv:hasPurpose` as its left operand and use
|
|
476
|
-
`dpv:AcademicResearch` as its right operand.
|
|
477
|
-
[Right to erasure example](https://eyereasoner.github.io/eyemind/examples/deck/right-to-erasure-le)
|
|
224
|
+
A query `NAME` compiles to a backward rule for `'le:answer'(NAME, S, V1, ...)`,
|
|
225
|
+
whose body starts with `'le:scenario'(S)` when there are scenarios, and the
|
|
226
|
+
statement `query('le:answer'(NAME, S, V1, ...))`. `V1, ...` are the variables of
|
|
227
|
+
the query outside negations and collections, in the order they appear.
|
|
478
228
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
credit is a duty and credit has action odrl:attribute.
|
|
484
|
-
researchUse has constraint scope and researchUse has duty credit.
|
|
485
|
-
ready has fulfilledDuty credit.
|
|
486
|
-
```
|
|
229
|
+
Aggregates, divisions, lists and dates use backward helper rules whose names
|
|
230
|
+
start with `le:` (`le:sum`, `le:count`, `le:days_after`, ...); no template name
|
|
231
|
+
can contain `:`. The helpers follow the document's clauses. `--program` prints
|
|
232
|
+
the compiled program as a standalone LS script.
|
|
487
233
|
|
|
488
|
-
|
|
489
|
-
distinct atomic constraints. `andOperands` requires all members,
|
|
490
|
-
`orOperands` at least one and `xoneOperands` exactly one. The result is
|
|
491
|
-
unknown when treating unknown members as satisfied or unsatisfied could
|
|
492
|
-
change the outcome. Reports cite the group for an unmet or unknown logical
|
|
493
|
-
constraint. The snapshot rejects nested groups and `odrl:andSequence`.
|
|
494
|
-
[ODRL Logical Constraint Class](https://www.w3.org/TR/odrl-model/#constraint-logical)
|
|
495
|
-
|
|
496
|
-
A permission can require several duties. Each is typed `odrl:Duty` and
|
|
497
|
-
has one action IRI. A request records whether it has fulfilled each duty.
|
|
498
|
-
An `unfulfilledDuty` record makes the permission inapplicable and gives
|
|
499
|
-
an `unmetDuty` report link. A missing record or conflicting records give
|
|
500
|
-
an uncertainty with `reportDuty` and a reason. The snapshot takes these
|
|
501
|
-
records as evidence of fulfillment. Duties that specify additional action
|
|
502
|
-
refinements, roles or consequences fail validation.
|
|
503
|
-
[ODRL Duty with a Permission](https://www.w3.org/TR/odrl-model/#duties)
|
|
504
|
-
|
|
505
|
-
`withinCategory` compares a single observed IRI with a required category IRI.
|
|
506
|
-
It accepts the three DPV observation properties in the hierarchy table.
|
|
507
|
-
An exact match or a supplied broader path satisfies the constraint. With
|
|
508
|
-
a known observation and no such path the constraint is unmet. The snapshot
|
|
509
|
-
reports missing, ambiguous or mistyped observations as unknown.
|
|
510
|
-
The research snapshot demonstrates compound scope, two DPV hierarchies and
|
|
511
|
-
request-local duty evidence; its Turtle twin, run with `--odrl`, reaches the
|
|
512
|
-
same decisions. [Research snapshot](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-le) · [Turtle twin](https://eyereasoner.github.io/eyemind/examples/deck/research-snapshot-odrl)
|
|
513
|
-
|
|
514
|
-
Both ODRL directives take a single LE file and reject questions; the
|
|
515
|
-
vocabulary directive also rejects rules. `--goal` can query their compiled LS program. The
|
|
516
|
-
`--odrl` switch selects the Turtle snapshot compiler, which can also combine
|
|
517
|
-
with `--owl2rl`, `--skos`, `--qudt` and `--shacl`; an LE run takes none of these
|
|
518
|
-
switches, so an LE snapshot reads only the facts it states.
|
|
519
|
-
|
|
520
|
-
## Output, compilation and checking
|
|
521
|
-
|
|
522
|
-
LE inputs default to `.le` conclusions. Each answer becomes a sentence:
|
|
234
|
+
## Output
|
|
523
235
|
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
236
|
+
The default output of an LE run is LE text: for each scenario, in the order of
|
|
237
|
+
the document, and each query, a heading comment and the answers as sentences.
|
|
238
|
+
An answer is the query's words with each variable it found a value for
|
|
239
|
+
written as that value; an open variable is written `_`, as LE writes it. A date
|
|
240
|
+
is written `YYYY-MM-DD`, a list in brackets, and a sentence term through its
|
|
241
|
+
template.
|
|
529
242
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
variable. A label outside the variable-name syntax is quoted. Additional
|
|
534
|
-
arguments follow as more comma-separated terms; a witness without arguments
|
|
535
|
-
is `witness(rule 4, Y)`. The rule number, label and arguments all contribute
|
|
536
|
-
to its identity. Ordinary compounds named witness retain their quoted spelling.
|
|
537
|
-
|
|
538
|
-
Unary and binary relations use the class and relation-of forms; relations with
|
|
539
|
-
more arguments use calls. Names are quoted when required to preserve their
|
|
540
|
-
meaning. Compound names are quoted. Variable answers use `For every X0 and X1,
|
|
541
|
-
...`, consistently renaming their variables while retaining sharing. A conjunctive
|
|
542
|
-
answer uses `and`. These sentences can be loaded as facts in another `.le`
|
|
543
|
-
program. An empty answer set is `# No conclusions.`. The writer rejects goals
|
|
544
|
-
outside these relational forms instead of silently changing their meaning.
|
|
545
|
-
|
|
546
|
-
```sh
|
|
547
|
-
eyemind examples/socrates-le.le
|
|
548
|
-
eyemind --program examples/socrates-le.le > /tmp/socrates-le.js
|
|
549
|
-
eyemind --to le /tmp/socrates-le.js
|
|
550
|
-
eyemind --proof examples/socrates-le.le > /tmp/socrates-le-proof.js
|
|
551
|
-
eyemind --check-proof /tmp/socrates-le-proof.js examples/socrates-le.le
|
|
243
|
+
```text
|
|
244
|
+
% query one with scenario alice
|
|
245
|
+
John acquires British citizenship on 2021-10-09.
|
|
552
246
|
```
|
|
553
247
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
248
|
+
A query without answers has the line `% no answers`. When the scenario states
|
|
249
|
+
expected answers for the query and they differ from the answers, a line
|
|
250
|
+
`% not as expected: NAME expects answers [...]` follows. LE2 writes the
|
|
251
|
+
underscores of names as spaces and repeats an answer for each proof, so the
|
|
252
|
+
comparison reads underscores as spaces, ignores spaces around hyphens, and
|
|
253
|
+
compares the answers as a set.
|
|
254
|
+
|
|
255
|
+
`--to le` writes the answers of an LE run only; `--to eyemind` writes the
|
|
256
|
+
`'le:answer'` terms. Proofs and check reports are `.js` documents of the
|
|
257
|
+
compiled LS program, and check against it. That the program reads the English
|
|
258
|
+
as intended is a matter of the compiler and its tests; a checked proof
|
|
259
|
+
establishes the answers under the compiled rules.
|
|
260
|
+
|
|
261
|
+
## Not supported
|
|
262
|
+
|
|
263
|
+
These belong to Logical English 2, or to the Prolog that LE1 can embed, and
|
|
264
|
+
are errors: template additions after `;`, `the constants are:`,
|
|
265
|
+
`the functions are:`, `the fluents are:`, `the events are:` and the other
|
|
266
|
+
dynamic and meta sections, included resources and scenarios, section markers,
|
|
267
|
+
rule labels, `it is unknown whether`, `it must not be true that`, negated
|
|
268
|
+
facts in scenarios, flip queries (`expects changes`), `otherwise`, `unless`,
|
|
269
|
+
`according to`, decision tables, services, LPS and s(CASP). eyemind does not
|
|
270
|
+
check types: the head noun of a place is not a type constraint. A program whose
|
|
271
|
+
negation lies on a dependency cycle compiles, and the LS program is then
|
|
272
|
+
rejected unless it is chain-stratified (LS-SPEC Section 6.4), where Prolog would
|
|
273
|
+
run it.
|