occam-verify-cli 0.0.1068 → 0.0.1069
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/bin/action/verify.js +3 -2
- package/lib/assertion/subproof.js +3 -3
- package/lib/axiom.js +11 -6
- package/lib/combinator.js +9 -9
- package/lib/conclusion.js +10 -7
- package/lib/conjecture.js +11 -6
- package/lib/consequent.js +10 -7
- package/lib/constructor.js +9 -9
- package/lib/context/file.js +34 -126
- package/lib/context/local.js +16 -5
- package/lib/context/release.js +2 -3
- package/lib/declaration.js +50 -43
- package/lib/equivalence.js +2 -2
- package/lib/frame.js +100 -80
- package/lib/index.js +22 -6
- package/lib/judgement.js +3 -3
- package/lib/label.js +12 -8
- package/lib/lemma.js +12 -12
- package/lib/metaLemma.js +120 -8
- package/lib/metatheorem.js +145 -9
- package/lib/metavariable.js +39 -22
- package/lib/mixins/statement/qualified/unify.js +6 -10
- package/lib/mixins/statement/unify.js +3 -3
- package/lib/mixins/term/unify.js +2 -2
- package/lib/premise.js +12 -8
- package/lib/reference.js +7 -9
- package/lib/rule.js +24 -39
- package/lib/ruleNames.js +1 -5
- package/lib/statement/unqualified.js +9 -8
- package/lib/statement.js +4 -4
- package/lib/substitution/frameForMetavariable.js +30 -26
- package/lib/substitution/statementForMetavariable.js +44 -26
- package/lib/substitution/termForVariable.js +33 -37
- package/lib/substitution.js +24 -21
- package/lib/substitutions.js +7 -1
- package/lib/supposition.js +12 -8
- package/lib/term.js +6 -11
- package/lib/theorem.js +11 -6
- package/lib/topLevelAssertion.js +24 -42
- package/lib/type.js +5 -12
- package/lib/unifier/metaLevel.js +3 -3
- package/lib/unifier/metavariable.js +6 -6
- package/lib/unifier/statementWithCombinator.js +16 -16
- package/lib/unifier/termWithConstructor.js +7 -7
- package/lib/utilities/brackets.js +10 -10
- package/lib/utilities/json.js +493 -0
- package/lib/utilities/node.js +15 -22
- package/lib/utilities/release.js +53 -0
- package/lib/utilities/releaseContext.js +4 -15
- package/lib/utilities/tokens.js +7 -7
- package/lib/variable.js +6 -11
- package/lib/verifier/topLevel.js +5 -5
- package/package.json +1 -1
- package/src/assertion/subproof.js +2 -3
- package/src/axiom.js +14 -6
- package/src/combinator.js +12 -13
- package/src/conclusion.js +12 -9
- package/src/conjecture.js +14 -6
- package/src/consequent.js +12 -9
- package/src/constructor.js +11 -13
- package/src/context/file.js +94 -202
- package/src/context/local.js +8 -6
- package/src/context/release.js +2 -3
- package/src/declaration.js +72 -44
- package/src/equivalence.js +2 -2
- package/src/frame.js +111 -86
- package/src/index.js +17 -1
- package/src/judgement.js +2 -2
- package/src/label.js +15 -10
- package/src/lemma.js +17 -10
- package/src/metaLemma.js +102 -1
- package/src/metatheorem.js +143 -2
- package/src/metavariable.js +50 -30
- package/src/mixins/statement/qualified/unify.js +7 -19
- package/src/mixins/statement/unify.js +2 -2
- package/src/mixins/term/unify.js +1 -1
- package/src/premise.js +18 -10
- package/src/reference.js +7 -11
- package/src/rule.js +33 -57
- package/src/ruleNames.js +0 -1
- package/src/statement/unqualified.js +10 -10
- package/src/statement.js +3 -2
- package/src/substitution/frameForMetavariable.js +39 -33
- package/src/substitution/statementForMetavariable.js +64 -31
- package/src/substitution/termForVariable.js +47 -37
- package/src/substitution.js +18 -16
- package/src/substitutions.js +2 -0
- package/src/supposition.js +18 -10
- package/src/term.js +5 -15
- package/src/theorem.js +14 -6
- package/src/topLevelAssertion.js +38 -64
- package/src/type.js +5 -20
- package/src/unifier/metaLevel.js +2 -2
- package/src/unifier/metavariable.js +5 -5
- package/src/unifier/statementWithCombinator.js +18 -18
- package/src/unifier/termWithConstructor.js +7 -7
- package/src/utilities/brackets.js +5 -5
- package/src/utilities/json.js +551 -0
- package/src/utilities/node.js +15 -26
- package/src/{verify → utilities}/release.js +5 -1
- package/src/utilities/releaseContext.js +2 -2
- package/src/utilities/tokens.js +10 -7
- package/src/variable.js +4 -14
- package/src/verifier/topLevel.js +6 -4
- package/lib/argument.js +0 -106
- package/lib/metaTypes.js +0 -19
- package/lib/unify/statementWithSttaemetnGivenEquivalences.js +0 -45
- package/lib/verify/metaLemma.js +0 -49
- package/lib/verify/metatheorem.js +0 -48
- package/lib/verify/release.js +0 -50
- package/src/argument.js +0 -79
- package/src/metaTypes.js +0 -11
- package/src/unify/statementWithSttaemetnGivenEquivalences.js +0 -51
- package/src/verify/metaLemma.js +0 -72
- package/src/verify/metatheorem.js +0 -67
package/src/metavariable.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import Argument from "./argument";
|
|
5
4
|
import LocalContext from "./context/local";
|
|
6
5
|
import metavariableUnifier from "./unifier/metavariable";
|
|
7
6
|
import FrameForMetavariableSubstitution from "./substitution/frameForMetavariable";
|
|
8
7
|
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
9
8
|
|
|
10
9
|
import { nodeQuery } from "./utilities/query";
|
|
11
|
-
import { metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
12
10
|
import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
11
|
+
import { metaTypeFromJSON, metaTypeToMetaTypeJSON } from "./utilities/json";
|
|
12
|
+
import { typeNameFromTypeNode, metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const termNodeQuery = nodeQuery("/metavariable/argument/term"),
|
|
15
|
+
typeNodeQuery = nodeQuery("/metavariable/argument/type"),
|
|
15
16
|
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
16
17
|
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
|
|
17
18
|
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
@@ -171,6 +172,30 @@ class Metavariable {
|
|
|
171
172
|
return statementUnified;
|
|
172
173
|
}
|
|
173
174
|
|
|
175
|
+
unifySubstitution(substitution, localContext) {
|
|
176
|
+
let substitutionUnified = false;
|
|
177
|
+
|
|
178
|
+
const metavariableString = this.string, ///
|
|
179
|
+
substitutionString = substitution.getString();
|
|
180
|
+
|
|
181
|
+
localContext.trace(`Unifying the '${substitutionString}' substitution with the '${metavariableString}' metavariable...`);
|
|
182
|
+
|
|
183
|
+
const metavariableName = this.name, ///
|
|
184
|
+
judgement = localContext.findJudgementByMetavariableName(metavariableName);
|
|
185
|
+
|
|
186
|
+
if (judgement !== null){
|
|
187
|
+
const declaration = judgement.getDeclaration();
|
|
188
|
+
|
|
189
|
+
substitutionUnified = declaration.unifySubstitution(substitution, localContext);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (substitutionUnified) {
|
|
193
|
+
localContext.debug(`...unified the '${substitutionString}' substitution with the '${metavariableString}' metavariable.`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return substitutionUnified;
|
|
197
|
+
}
|
|
198
|
+
|
|
174
199
|
verify(localContext) {
|
|
175
200
|
let verified;
|
|
176
201
|
|
|
@@ -212,15 +237,25 @@ class Metavariable {
|
|
|
212
237
|
if (metavariablePresent) {
|
|
213
238
|
fileContext.debug(`The metavariable '${metavariableString}' is already present.`);
|
|
214
239
|
} else {
|
|
215
|
-
const
|
|
216
|
-
argument = Argument.fromArgumentNode(argumentNode, fileContext);
|
|
240
|
+
const termNode = termNodeQuery(this.node);
|
|
217
241
|
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
} else {
|
|
221
|
-
const argumentVerified = argument.verify(fileContext);
|
|
242
|
+
if (termNode !== null) {
|
|
243
|
+
const termString = this.fileContext.nodeAsString(termNode);
|
|
222
244
|
|
|
223
|
-
|
|
245
|
+
this.fileContext.debug(`The '${termString}' term was found when a type should have been present.`);
|
|
246
|
+
} else {
|
|
247
|
+
const typeNode = typeNodeQuery(this.node);
|
|
248
|
+
|
|
249
|
+
if (typeNode !== null) {
|
|
250
|
+
const typeName = typeNameFromTypeNode(typeNode),
|
|
251
|
+
typePresent = this.fileContext.isTypePresentByTypeName(typeName);
|
|
252
|
+
|
|
253
|
+
if (typePresent) {
|
|
254
|
+
verifiedAtTopLevel = true;
|
|
255
|
+
} else {
|
|
256
|
+
this.fileContext.debug(`The '${typeName}' type is not present.`);
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
224
259
|
verifiedAtTopLevel = true;
|
|
225
260
|
}
|
|
226
261
|
}
|
|
@@ -259,11 +294,9 @@ class Metavariable {
|
|
|
259
294
|
}
|
|
260
295
|
|
|
261
296
|
toJSON() {
|
|
262
|
-
const metaTypeJSON = (this.metaType
|
|
263
|
-
this.metaType.toJSON() :
|
|
264
|
-
null,
|
|
265
|
-
string = this.string,
|
|
297
|
+
const metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
|
|
266
298
|
metaType = metaTypeJSON, ///
|
|
299
|
+
string = this.string,
|
|
267
300
|
json = {
|
|
268
301
|
string,
|
|
269
302
|
metaType
|
|
@@ -287,17 +320,17 @@ class Metavariable {
|
|
|
287
320
|
return metavariable;
|
|
288
321
|
}
|
|
289
322
|
|
|
290
|
-
static fromMetavariableNode(metavariableNode,
|
|
323
|
+
static fromMetavariableNode(metavariableNode, localContext) {
|
|
291
324
|
let metavariable = null;
|
|
292
325
|
|
|
293
326
|
if (metavariableNode !== null) {
|
|
294
327
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
295
328
|
node = metavariableNode, ///
|
|
296
329
|
name = metavariableName, ///
|
|
297
|
-
string =
|
|
330
|
+
string = localContext.nodeAsString(node),
|
|
298
331
|
metaType = null;
|
|
299
332
|
|
|
300
|
-
metavariable = new Metavariable(
|
|
333
|
+
metavariable = new Metavariable(localContext, string, node, name, metaType);
|
|
301
334
|
}
|
|
302
335
|
|
|
303
336
|
return metavariable;
|
|
@@ -326,19 +359,6 @@ Object.assign(shim, {
|
|
|
326
359
|
|
|
327
360
|
export default Metavariable;
|
|
328
361
|
|
|
329
|
-
function metaTypeFromJSON(json, fileContext) {
|
|
330
|
-
let { metaType } = json;
|
|
331
|
-
|
|
332
|
-
if (metaType !== null) {
|
|
333
|
-
const { name } = metaType,
|
|
334
|
-
metaTypeName = name; ///
|
|
335
|
-
|
|
336
|
-
metaType = fileContext.findMetaTypeByMetaTypeName(metaTypeName);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return metaType;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
362
|
function metavariableFromMetavariableNode(metavariableNode, localContext) {
|
|
343
363
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
344
364
|
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import metavariableUnifier from "../../../unifier/metavariable";
|
|
4
3
|
import StatementForMetavariableSubstitution from "../../../substitution/statementForMetavariable";
|
|
5
4
|
|
|
6
5
|
import { trim } from "../../../utilities/string";
|
|
@@ -137,33 +136,22 @@ function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
|
|
|
137
136
|
const reference = qualifiedStatement.getReference(),
|
|
138
137
|
metavariableNode = reference.getMetavariableNode(),
|
|
139
138
|
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
140
|
-
|
|
139
|
+
metavariablePresent = localContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
141
140
|
|
|
142
|
-
if (
|
|
141
|
+
if (metavariablePresent) {
|
|
143
142
|
const statement = qualifiedStatement.getStatement(),
|
|
144
143
|
statementString = statement.getString(),
|
|
145
144
|
referenceString = reference.getString();
|
|
146
145
|
|
|
147
146
|
localContext.trace(`Unifying the '${statementString}' qualified statement with the '${referenceString}' reference...`);
|
|
148
147
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
metavariableNodeB = metavariableNode, ///
|
|
153
|
-
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
148
|
+
const metavariable = reference.getMetavariable(),
|
|
149
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
|
|
150
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
154
151
|
|
|
155
|
-
|
|
156
|
-
const statementNode = statement.getNode(),
|
|
157
|
-
metavariableNode = metavariableNodeA, ///
|
|
158
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeAndMetavariableNode(statementNode, metavariableNode, localContextA, localContextB),
|
|
159
|
-
substitution = statementForMetavariableSubstitution, ///
|
|
160
|
-
localContextA = localContext, ///
|
|
161
|
-
localContextB = localContext; ///
|
|
152
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
162
153
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
unifiedWithReference = true;
|
|
166
|
-
}
|
|
154
|
+
unifiedWithReference = true;
|
|
167
155
|
|
|
168
156
|
if (unifiedWithReference) {
|
|
169
157
|
localContext.debug(`...unified the '${statementString}' qualified statement with the '${referenceString}' reference.`);
|
|
@@ -14,7 +14,7 @@ function unifyWithBracketedCombinator(statement, assignments, stated, localConte
|
|
|
14
14
|
|
|
15
15
|
localContext.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`);
|
|
16
16
|
|
|
17
|
-
unifiedWithBracketedCombinator = statementWithCombinatorUnifier.unify(
|
|
17
|
+
unifiedWithBracketedCombinator = statementWithCombinatorUnifier.unify(combinatorStatementNode, statementNode, assignments, stated, localContext);
|
|
18
18
|
|
|
19
19
|
if (unifiedWithBracketedCombinator) {
|
|
20
20
|
localContext.debug(`...unified the '${statementString}' statement with the bracketed combinator.`);
|
|
@@ -61,7 +61,7 @@ function unifyStatementWithCombinator(statement, combinator, assignments, stated
|
|
|
61
61
|
|
|
62
62
|
localContext.trace(`Unifying the '${statementString}' statement with the '${combinatorString}' combinator...`);
|
|
63
63
|
|
|
64
|
-
unifiedWithCombinator = statementWithCombinatorUnifier.unify(
|
|
64
|
+
unifiedWithCombinator = statementWithCombinatorUnifier.unify(combinatorStatementNode, statementNode, assignments, stated, localContext);
|
|
65
65
|
|
|
66
66
|
if (unifiedWithCombinator) {
|
|
67
67
|
localContext.debug(`...unified the '${statementString}' statement with the '${combinatorString}' combinator.`);
|
package/src/mixins/term/unify.js
CHANGED
|
@@ -87,7 +87,7 @@ function unifyTermWithConstructor(term, constructor, localContext, verifyAhead)
|
|
|
87
87
|
const termNode = term.getNode(),
|
|
88
88
|
constructorTerm = constructor.getTerm(),
|
|
89
89
|
constructorTermNode = constructorTerm.getNode(),
|
|
90
|
-
unified = termWithConstructorUnifier.unify(
|
|
90
|
+
unified = termWithConstructorUnifier.unify(constructorTermNode, termNode, localContext);
|
|
91
91
|
|
|
92
92
|
if (unified) {
|
|
93
93
|
let verifiedAhead;
|
package/src/premise.js
CHANGED
|
@@ -7,10 +7,11 @@ import UnqualifiedStatement from "./statement/unqualified";
|
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "./utilities/query";
|
|
9
9
|
import { assignAssignments } from "./utilities/assignments";
|
|
10
|
+
import { unqualifiedStatementFromJSON, unqualifiedStatementToUnqualifiedStatementJSON } from "./utilities/json";
|
|
10
11
|
|
|
11
12
|
const unqualifiedStatementNodeQuery = nodeQuery("/premise/unqualifiedStatement");
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
class Premise {
|
|
14
15
|
constructor(fileContext, unqualifiedStatement) {
|
|
15
16
|
this.fileContext = fileContext;
|
|
16
17
|
this.unqualifiedStatement = unqualifiedStatement;
|
|
@@ -40,7 +41,13 @@ export default class Premise {
|
|
|
40
41
|
|
|
41
42
|
const statement = this.unqualifiedStatement.getStatement(),
|
|
42
43
|
statementNode = statement.getNode(),
|
|
43
|
-
|
|
44
|
+
statementTokens = statement.getTokens(),
|
|
45
|
+
context = this.fileContext, ///
|
|
46
|
+
tokens = statementTokens; ///
|
|
47
|
+
|
|
48
|
+
localContext = LocalContext.fromContextAndTokens(context, tokens); ///
|
|
49
|
+
|
|
50
|
+
const subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, localContext);
|
|
44
51
|
|
|
45
52
|
if (subproofAssertion !== null) {
|
|
46
53
|
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
@@ -138,7 +145,7 @@ export default class Premise {
|
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
toJSON() {
|
|
141
|
-
const unqualifiedStatementJSON = this.unqualifiedStatement
|
|
148
|
+
const unqualifiedStatementJSON = unqualifiedStatementToUnqualifiedStatementJSON(this.unqualifiedStatement),
|
|
142
149
|
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
143
150
|
json = {
|
|
144
151
|
unqualifiedStatement
|
|
@@ -148,13 +155,8 @@ export default class Premise {
|
|
|
148
155
|
}
|
|
149
156
|
|
|
150
157
|
static fromJSON(json, fileContext) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
json = unqualifiedStatement; ///
|
|
154
|
-
|
|
155
|
-
unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
|
|
156
|
-
|
|
157
|
-
const premise = new Premise(fileContext, unqualifiedStatement);
|
|
158
|
+
const unqualifiedStatement = unqualifiedStatementFromJSON(json, fileContext),
|
|
159
|
+
premise = new Premise(fileContext, unqualifiedStatement);
|
|
158
160
|
|
|
159
161
|
return premise;
|
|
160
162
|
}
|
|
@@ -167,3 +169,9 @@ export default class Premise {
|
|
|
167
169
|
return premise
|
|
168
170
|
}
|
|
169
171
|
}
|
|
172
|
+
|
|
173
|
+
Object.assign(shim, {
|
|
174
|
+
Premise
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export default Premise;
|
package/src/reference.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Metavariable from "./metavariable";
|
|
4
|
+
import LocalContext from "./context/local";
|
|
4
5
|
|
|
5
6
|
import { nodeQuery } from "./utilities/query";
|
|
6
7
|
import { referenceMetaType } from "./metaType";
|
|
8
|
+
import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
|
|
7
9
|
|
|
8
10
|
const metavariableNodeQuery = nodeQuery("//reference/metavariable");
|
|
9
11
|
|
|
@@ -46,7 +48,7 @@ export default class Reference {
|
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
toJSON() {
|
|
49
|
-
const metavariableJSON = this.metavariable
|
|
51
|
+
const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
|
|
50
52
|
metavariable = metavariableJSON, ///
|
|
51
53
|
string = this.string,
|
|
52
54
|
json = {
|
|
@@ -58,22 +60,16 @@ export default class Reference {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
static fromJSON(json, fileContext) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
let { metavariable } = json;
|
|
64
|
-
|
|
65
|
-
json = metavariable; ///
|
|
66
|
-
|
|
67
|
-
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
68
|
-
|
|
69
|
-
const reference = new Reference(string, metavariable);
|
|
63
|
+
const metavariable = metavariableFromJSON(json, fileContext),
|
|
64
|
+
reference = new Reference(string, metavariable);
|
|
70
65
|
|
|
71
66
|
return reference;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
static fromReferenceNode(referenceNode, fileContext) {
|
|
75
70
|
const metavariableNode = metavariableNodeQuery(referenceNode),
|
|
76
|
-
|
|
71
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
72
|
+
metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
|
|
77
73
|
reference = new Reference(metavariable);
|
|
78
74
|
|
|
79
75
|
return reference;
|
package/src/rule.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
+
import shim from "./shim";
|
|
5
6
|
import Label from "./label";
|
|
6
7
|
import Proof from "./proof";
|
|
7
8
|
import Premise from "./premise";
|
|
@@ -9,7 +10,14 @@ import Conclusion from "./conclusion";
|
|
|
9
10
|
import LocalContext from "./context/local";
|
|
10
11
|
import Substitutions from "./substitutions";
|
|
11
12
|
|
|
13
|
+
import { stringFromLabels } from "./topLevelAssertion";
|
|
12
14
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
15
|
+
import { labelsFromJSON,
|
|
16
|
+
premisesFromJSON,
|
|
17
|
+
conclusionFromJSON,
|
|
18
|
+
labelsToLabelsJSON,
|
|
19
|
+
premisesToPremisesJSON,
|
|
20
|
+
conclusionToConclusionJSON } from "./utilities/json";
|
|
13
21
|
|
|
14
22
|
const { reverse, correlate } = arrayUtilities;
|
|
15
23
|
|
|
@@ -18,9 +26,10 @@ const proofNodeQuery = nodeQuery("/rule/proof"),
|
|
|
18
26
|
premiseNodesQuery = nodesQuery("/rule/premise"),
|
|
19
27
|
conclusionNodeQuery = nodeQuery("/rule/conclusion");
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
constructor(fileContext, labels, premises, conclusion, proof) {
|
|
29
|
+
class Rule {
|
|
30
|
+
constructor(fileContext, string, labels, premises, conclusion, proof) {
|
|
23
31
|
this.fileContext = fileContext;
|
|
32
|
+
this.string = string;
|
|
24
33
|
this.labels = labels;
|
|
25
34
|
this.premises = premises;
|
|
26
35
|
this.conclusion = conclusion;
|
|
@@ -31,6 +40,10 @@ export default class Rule {
|
|
|
31
40
|
return this.fileContext;
|
|
32
41
|
}
|
|
33
42
|
|
|
43
|
+
getString() {
|
|
44
|
+
return this.string;
|
|
45
|
+
}
|
|
46
|
+
|
|
34
47
|
getLabels() {
|
|
35
48
|
return this.labels;
|
|
36
49
|
}
|
|
@@ -108,9 +121,9 @@ export default class Rule {
|
|
|
108
121
|
verify() {
|
|
109
122
|
let verified = false;
|
|
110
123
|
|
|
111
|
-
const
|
|
124
|
+
const ruleString = this.string; ///
|
|
112
125
|
|
|
113
|
-
this.fileContext.trace(`Verifying the '${
|
|
126
|
+
this.fileContext.trace(`Verifying the '${ruleString}' rule...`);
|
|
114
127
|
|
|
115
128
|
const labelsVerifiedAtTopLevel = this.labels.every((label) => {
|
|
116
129
|
const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
|
|
@@ -154,24 +167,16 @@ export default class Rule {
|
|
|
154
167
|
}
|
|
155
168
|
|
|
156
169
|
if (verified) {
|
|
157
|
-
this.fileContext.debug(`...verified the '${
|
|
170
|
+
this.fileContext.debug(`...verified the '${ruleString}' rule.`);
|
|
158
171
|
}
|
|
159
172
|
|
|
160
173
|
return verified;
|
|
161
174
|
}
|
|
162
175
|
|
|
163
176
|
toJSON() {
|
|
164
|
-
const labelsJSON = this.labels
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
return labelJSON;
|
|
168
|
-
}),
|
|
169
|
-
premisesJSON = this.premises.map((premise) => {
|
|
170
|
-
const premiseJSON = premise.toJSON();
|
|
171
|
-
|
|
172
|
-
return premiseJSON;
|
|
173
|
-
}),
|
|
174
|
-
conclusionJSON = this.conclusion.toJSON(),
|
|
177
|
+
const labelsJSON = labelsToLabelsJSON(this.labels),
|
|
178
|
+
premisesJSON = premisesToPremisesJSON(this.premises),
|
|
179
|
+
conclusionJSON = conclusionToConclusionJSON(this.conclusion),
|
|
175
180
|
labels = labelsJSON, ///
|
|
176
181
|
premises = premisesJSON, ///
|
|
177
182
|
conclusion = conclusionJSON, ///
|
|
@@ -187,39 +192,13 @@ export default class Rule {
|
|
|
187
192
|
static fromJSON(json, fileContext) {
|
|
188
193
|
let rule;
|
|
189
194
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const json = labelJSON, ///
|
|
196
|
-
label = Label.fromJSON(json, fileContext);
|
|
197
|
-
|
|
198
|
-
return label;
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
let { premises } = json;
|
|
195
|
+
const proof = null,
|
|
196
|
+
labels = labelsFromJSON(json, fileContext),
|
|
197
|
+
premises = premisesFromJSON(json, fileContext),
|
|
198
|
+
conclusion = conclusionFromJSON(json, fileContext),
|
|
199
|
+
string = stringFromLabels(labels);
|
|
202
200
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
premises = premisesJSON.map((premiseJSON) => {
|
|
206
|
-
const json = premiseJSON, ///
|
|
207
|
-
premise = Premise.fromJSON(json, fileContext);
|
|
208
|
-
|
|
209
|
-
return premise;
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
let { conclusion } = json;
|
|
213
|
-
|
|
214
|
-
const conclusionJSON = conclusion; ///
|
|
215
|
-
|
|
216
|
-
json = conclusionJSON; ///
|
|
217
|
-
|
|
218
|
-
conclusion = Conclusion.fromJSON(json, fileContext);
|
|
219
|
-
|
|
220
|
-
const proof = null;
|
|
221
|
-
|
|
222
|
-
rule = new Rule(fileContext, labels, premises, conclusion, proof);
|
|
201
|
+
rule = new Rule(fileContext, string, labels, premises, conclusion, proof);
|
|
223
202
|
|
|
224
203
|
return rule;
|
|
225
204
|
}
|
|
@@ -240,19 +219,16 @@ export default class Rule {
|
|
|
240
219
|
return premise;
|
|
241
220
|
}),
|
|
242
221
|
conclusion = Conclusion.fromConclusionNode(conclusionNode, fileContext),
|
|
222
|
+
string = stringFromLabels(labels),
|
|
243
223
|
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
244
|
-
rule = new Rule(fileContext, labels, premises, conclusion, proof);
|
|
224
|
+
rule = new Rule(fileContext, string, labels, premises, conclusion, proof);
|
|
245
225
|
|
|
246
226
|
return rule;
|
|
247
227
|
}
|
|
248
228
|
}
|
|
249
229
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return labelString;
|
|
255
|
-
});
|
|
230
|
+
Object.assign(shim, {
|
|
231
|
+
Rule
|
|
232
|
+
});
|
|
256
233
|
|
|
257
|
-
|
|
258
|
-
}
|
|
234
|
+
export default Rule;
|
package/src/ruleNames.js
CHANGED
|
@@ -2,6 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
export const VARIABLE_RULE_NAME = "variable";
|
|
4
4
|
export const METAVARIABLE_RULE_NAME = "metavariable";
|
|
5
|
-
export const SUBSTITUTION_RULE_NAME = "substitution";
|
|
6
5
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
7
6
|
export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
|
|
@@ -7,12 +7,13 @@ import LocalContext from "../context/local";
|
|
|
7
7
|
|
|
8
8
|
import { trim } from "../utilities/string";
|
|
9
9
|
import { nodeQuery } from "../utilities/query";
|
|
10
|
+
import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
|
|
10
11
|
|
|
11
12
|
const { reverse } = arrayUtilities;
|
|
12
13
|
|
|
13
14
|
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement");
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
class UnqualifiedStatement {
|
|
16
17
|
constructor(string, statement) {
|
|
17
18
|
this.string = string;
|
|
18
19
|
this.statement = statement;
|
|
@@ -93,7 +94,7 @@ export default class UnqualifiedStatement {
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
toJSON() {
|
|
96
|
-
const statementJSON = this.statement
|
|
97
|
+
const statementJSON = statementToStatementJSON(this.statement),
|
|
97
98
|
statement = statementJSON, ///
|
|
98
99
|
string = this.string, ///
|
|
99
100
|
json = {
|
|
@@ -105,15 +106,8 @@ export default class UnqualifiedStatement {
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
static fromJSON(json, fileContext) {
|
|
108
|
-
const { Statement } = shim;
|
|
109
|
-
|
|
110
|
-
let { statement } = json;
|
|
111
|
-
|
|
112
|
-
json = statement; ///
|
|
113
|
-
|
|
114
|
-
statement = Statement.fromJSON(json, fileContext);
|
|
115
|
-
|
|
116
109
|
const { string } = json,
|
|
110
|
+
statement = statementFromJSON(json, fileContext),
|
|
117
111
|
unqualifiedStatement = new UnqualifiedStatement(string, statement);
|
|
118
112
|
|
|
119
113
|
return unqualifiedStatement;
|
|
@@ -141,3 +135,9 @@ export default class UnqualifiedStatement {
|
|
|
141
135
|
return unqualifiedStatement;
|
|
142
136
|
}
|
|
143
137
|
}
|
|
138
|
+
|
|
139
|
+
Object.assign(shim, {
|
|
140
|
+
UnqualifiedStatement
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export default UnqualifiedStatement;
|
package/src/statement.js
CHANGED
|
@@ -117,10 +117,11 @@ class Statement {
|
|
|
117
117
|
|
|
118
118
|
const statementANode = statementA.getNode(),
|
|
119
119
|
statementBNode = statementB.getNode(),
|
|
120
|
+
context = localContextA, ///
|
|
120
121
|
nodeA = statementANode, ///
|
|
121
122
|
nodeB = statementBNode; ///
|
|
122
123
|
|
|
123
|
-
localContextA = LocalContext.
|
|
124
|
+
localContextA = LocalContext.fromContextAndTokens(context, this.tokens);
|
|
124
125
|
|
|
125
126
|
const unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
126
127
|
|
|
@@ -221,9 +222,9 @@ class Statement {
|
|
|
221
222
|
|
|
222
223
|
static fromJSON(json, fileContext) {
|
|
223
224
|
const { string } = json,
|
|
224
|
-
statementString = string, ///
|
|
225
225
|
lexer = fileContext.getLexer(),
|
|
226
226
|
parser = fileContext.getParser(),
|
|
227
|
+
statementString = string, ///
|
|
227
228
|
unqualifiedStatementString = unqualifiedStatementStringFromStatementString(statementString),
|
|
228
229
|
unqualifiedStatementTokens = unqualifiedStatementTokensFromUnqualifiedStatementString(unqualifiedStatementString, lexer),
|
|
229
230
|
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser),
|