occam-verify-cli 0.0.1065 → 0.0.1067
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/lib/assertion/contained.js +2 -1
- package/lib/assertion/defined.js +2 -1
- package/lib/combinator/bracketed.js +135 -0
- package/lib/conclusion.js +6 -2
- package/lib/consequent.js +6 -2
- package/lib/constants.js +3 -3
- package/lib/constructor/bracketed.js +30 -11
- package/lib/context/file.js +45 -9
- package/lib/context/local.js +67 -28
- package/lib/metavariable.js +15 -54
- package/lib/mixins/statement/unify.js +18 -3
- package/lib/mixins/statement/verify.js +2 -11
- package/lib/premise.js +6 -2
- package/lib/proofStep.js +22 -13
- package/lib/rule.js +6 -2
- package/lib/ruleNames.js +1 -5
- package/lib/statement/qualified.js +30 -17
- package/lib/statement/unqualified.js +5 -5
- package/lib/statement.js +41 -24
- package/lib/subproof.js +1 -1
- package/lib/substitution/frameForMetavariable.js +44 -21
- package/lib/substitution/statementForMetavariable.js +93 -54
- package/lib/substitution/termForVariable.js +38 -21
- package/lib/substitution.js +48 -13
- package/lib/substitutions.js +22 -19
- package/lib/supposition.js +6 -2
- package/lib/unifier/metaLevel.js +14 -12
- package/lib/unify/metavariableWithFrame.js +2 -2
- package/lib/utilities/brackets.js +5 -10
- package/lib/utilities/node.js +29 -15
- package/lib/utilities/string.js +34 -16
- package/lib/utilities/tokens.js +16 -8
- package/lib/variable.js +10 -10
- package/package.json +2 -2
- package/src/assertion/contained.js +2 -0
- package/src/assertion/defined.js +2 -0
- package/src/combinator/bracketed.js +49 -0
- package/src/conclusion.js +8 -1
- package/src/consequent.js +8 -1
- package/src/constants.js +2 -2
- package/src/constructor/bracketed.js +32 -9
- package/src/context/file.js +41 -13
- package/src/context/local.js +71 -35
- package/src/metavariable.js +24 -74
- package/src/mixins/statement/unify.js +25 -2
- package/src/mixins/statement/verify.js +1 -14
- package/src/premise.js +8 -1
- package/src/proofStep.js +28 -12
- package/src/rule.js +7 -1
- package/src/ruleNames.js +0 -1
- package/src/statement/qualified.js +38 -21
- package/src/statement/unqualified.js +4 -4
- package/src/statement.js +62 -41
- package/src/subproof.js +0 -1
- package/src/substitution/frameForMetavariable.js +62 -32
- package/src/substitution/statementForMetavariable.js +102 -61
- package/src/substitution/termForVariable.js +52 -32
- package/src/substitution.js +40 -11
- package/src/substitutions.js +32 -25
- package/src/supposition.js +8 -1
- package/src/unifier/metaLevel.js +23 -18
- package/src/unify/metavariableWithFrame.js +2 -2
- package/src/utilities/brackets.js +2 -3
- package/src/utilities/node.js +30 -22
- package/src/utilities/string.js +39 -23
- package/src/utilities/tokens.js +17 -8
- package/src/variable.js +7 -7
- package/lib/node/statement/bracketed.js +0 -16
- package/lib/node/statement/combinator/bracketed.js +0 -25
- package/lib/node/term/bracketed.js +0 -16
- package/lib/node/term/constructor/bracketed.js +0 -25
- package/lib/ocmbinator/bracketed.js +0 -157
- package/lib/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -62
- package/lib/resolve/substitution.js +0 -27
- package/lib/resolve/substitutions.js +0 -37
- package/lib/substitution/statement.js +0 -163
- package/lib/verifier/substitution.js +0 -161
- package/src/node/statement/bracketed.js +0 -9
- package/src/node/statement/combinator/bracketed.js +0 -10
- package/src/node/term/bracketed.js +0 -9
- package/src/node/term/constructor/bracketed.js +0 -10
- package/src/ocmbinator/bracketed.js +0 -26
- package/src/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -79
- package/src/resolve/substitution.js +0 -19
- package/src/resolve/substitutions.js +0 -31
- package/src/substitution/statement.js +0 -81
- package/src/verifier/substitution.js +0 -75
package/src/context/local.js
CHANGED
|
@@ -7,11 +7,12 @@ import Equivalence from "../equivalence";
|
|
|
7
7
|
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
8
8
|
import { mergeEquivalences, findEquivalenceByTerm, groundedTermsAndDefinedVariablesFromFromEquivalences } from "../utilities/equivalences";
|
|
9
9
|
|
|
10
|
-
const { last
|
|
10
|
+
const { last } = arrayUtilities;
|
|
11
11
|
|
|
12
12
|
class LocalContext {
|
|
13
|
-
constructor(context, variables, proofSteps, judgements, equivalences, metavariables) {
|
|
13
|
+
constructor(context, tokens, variables, proofSteps, judgements, equivalences, metavariables) {
|
|
14
14
|
this.context = context;
|
|
15
|
+
this.tokens = tokens;
|
|
15
16
|
this.variables = variables;
|
|
16
17
|
this.proofSteps = proofSteps;
|
|
17
18
|
this.judgements = judgements;
|
|
@@ -23,6 +24,10 @@ class LocalContext {
|
|
|
23
24
|
return this.context;
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
getTokens() {
|
|
28
|
+
return this.tokens;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
getVariables() {
|
|
27
32
|
let variables = this.context.getVariables();
|
|
28
33
|
|
|
@@ -161,9 +166,9 @@ class LocalContext {
|
|
|
161
166
|
addVariable(variable) {
|
|
162
167
|
let variableAdded = false;
|
|
163
168
|
|
|
164
|
-
const
|
|
169
|
+
const variableNode = variable.getNode(),
|
|
165
170
|
variablePresent = this.variables.some((variable) => {
|
|
166
|
-
const variableMatchesNode = variable.
|
|
171
|
+
const variableMatchesNode = variable.matchVariableNode(variableNode);
|
|
167
172
|
|
|
168
173
|
if (variableMatchesNode) {
|
|
169
174
|
return true;
|
|
@@ -227,26 +232,6 @@ class LocalContext {
|
|
|
227
232
|
return metavariableAdded;
|
|
228
233
|
}
|
|
229
234
|
|
|
230
|
-
unifyStatement(statementNode, localContext) {
|
|
231
|
-
let proofSteps = this.getProofSteps();
|
|
232
|
-
|
|
233
|
-
proofSteps = reverse(proofSteps); ///
|
|
234
|
-
|
|
235
|
-
const equivalences = this.getEquivalences(),
|
|
236
|
-
localContextA = this, ///
|
|
237
|
-
localContextB = localContext, ///
|
|
238
|
-
statementNodeB = statementNode, ///
|
|
239
|
-
statementUnified = proofSteps.some((proofStep) => {
|
|
240
|
-
const statementUnified = proofStep.unifyStatement(statementNodeB, equivalences, localContextA, localContextB);
|
|
241
|
-
|
|
242
|
-
if (statementUnified) {
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
return statementUnified;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
235
|
getTermType(term) {
|
|
251
236
|
let termType;
|
|
252
237
|
|
|
@@ -338,10 +323,9 @@ class LocalContext {
|
|
|
338
323
|
findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
339
324
|
|
|
340
325
|
findVariableByVariableName(variableName) {
|
|
341
|
-
const
|
|
342
|
-
variables = this.getVariables(),
|
|
326
|
+
const variables = this.getVariables(),
|
|
343
327
|
variable = variables.find((variable) => {
|
|
344
|
-
const nameMatches = variable.
|
|
328
|
+
const nameMatches = variable.matchVariableName(variableName);
|
|
345
329
|
|
|
346
330
|
if (nameMatches) {
|
|
347
331
|
return true;
|
|
@@ -365,10 +349,9 @@ class LocalContext {
|
|
|
365
349
|
}
|
|
366
350
|
|
|
367
351
|
findMetavariableByMetavariableName(metavariableName) {
|
|
368
|
-
const
|
|
369
|
-
metavariables = this.getMetavariables(),
|
|
352
|
+
const metavariables = this.getMetavariables(),
|
|
370
353
|
metavariable = metavariables.find((metavariable) => {
|
|
371
|
-
const nameMatches = metavariable.
|
|
354
|
+
const nameMatches = metavariable.matchMetavariableName(metavariableName);
|
|
372
355
|
|
|
373
356
|
if (nameMatches) {
|
|
374
357
|
return true;
|
|
@@ -394,9 +377,47 @@ class LocalContext {
|
|
|
394
377
|
|
|
395
378
|
findMetatheoremByReference(reference) { return this.context.findMetatheoremByReference(reference); }
|
|
396
379
|
|
|
397
|
-
nodeAsString(node
|
|
380
|
+
nodeAsString(node, tokens = null) {
|
|
381
|
+
if (tokens === null) {
|
|
382
|
+
tokens = this.tokens;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const string = this.context.nodeAsString(node, tokens);
|
|
386
|
+
|
|
387
|
+
return string;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
nodesAsString(node, tokens = null) {
|
|
391
|
+
if (tokens === null) {
|
|
392
|
+
tokens = this.tokens;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const string = this.context.nodesAsString(node, tokens);
|
|
396
|
+
|
|
397
|
+
return string;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
nodeAsTokens(node, tokens = null) {
|
|
401
|
+
if (tokens === null) {
|
|
402
|
+
tokens = this.tokens;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
tokens = this.context.nodeAsTokens(node, tokens); ///
|
|
406
|
+
|
|
407
|
+
return tokens;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
nodesAsTokens(node, tokens = null) {
|
|
411
|
+
if (tokens === null) {
|
|
412
|
+
tokens = this.tokens;
|
|
413
|
+
}
|
|
398
414
|
|
|
399
|
-
|
|
415
|
+
tokens = this.context.nodesAsTokens(node, tokens); ///
|
|
416
|
+
|
|
417
|
+
return tokens;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
tokensAsString(tokens) { return this.context.tokensAsString(tokens); }
|
|
400
421
|
|
|
401
422
|
trace(message, node) { this.context.trace(message, node); }
|
|
402
423
|
|
|
@@ -410,25 +431,40 @@ class LocalContext {
|
|
|
410
431
|
|
|
411
432
|
static fromFileContext(fileContext) {
|
|
412
433
|
const context = fileContext, ///
|
|
434
|
+
tokens = null,
|
|
413
435
|
variables = [],
|
|
414
436
|
proofSteps = [],
|
|
415
|
-
equivalences = [],
|
|
416
437
|
judgements = [],
|
|
438
|
+
equivalences = [],
|
|
417
439
|
metavariables = [],
|
|
418
|
-
localContext = new LocalContext(context, variables, proofSteps, judgements, equivalences, metavariables);
|
|
440
|
+
localContext = new LocalContext(context, tokens, variables, proofSteps, judgements, equivalences, metavariables);
|
|
419
441
|
|
|
420
442
|
return localContext;
|
|
421
443
|
}
|
|
422
444
|
|
|
423
445
|
static fromLocalContext(localContext) {
|
|
424
446
|
const context = localContext, ///
|
|
447
|
+
tokens = null,
|
|
425
448
|
variables = [],
|
|
426
449
|
proofSteps = [],
|
|
450
|
+
judgements = [],
|
|
427
451
|
equivalences = [],
|
|
452
|
+
metavariables = [];
|
|
453
|
+
|
|
454
|
+
localContext = new LocalContext(context, tokens, variables, proofSteps, judgements, equivalences, metavariables); ///
|
|
455
|
+
|
|
456
|
+
return localContext;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
static fromLocalContextAndTokens(localContext, tokens) {
|
|
460
|
+
const context = localContext, ///
|
|
461
|
+
variables = [],
|
|
462
|
+
proofSteps = [],
|
|
428
463
|
judgements = [],
|
|
464
|
+
equivalences = [],
|
|
429
465
|
metavariables = [];
|
|
430
466
|
|
|
431
|
-
localContext = new LocalContext(context, variables, proofSteps, judgements, equivalences, metavariables); ///
|
|
467
|
+
localContext = new LocalContext(context, tokens, variables, proofSteps, judgements, equivalences, metavariables); ///
|
|
432
468
|
|
|
433
469
|
return localContext;
|
|
434
470
|
}
|
package/src/metavariable.js
CHANGED
|
@@ -50,10 +50,10 @@ class Metavariable {
|
|
|
50
50
|
return metaTypeName;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
const
|
|
53
|
+
matchMetavariableName(metavariableName) {
|
|
54
|
+
const metavariableNameMatches = (this.name === metavariableName);
|
|
55
55
|
|
|
56
|
-
return
|
|
56
|
+
return metavariableNameMatches;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
matchMetavariableNode(metavariableNode) {
|
|
@@ -125,21 +125,29 @@ class Metavariable {
|
|
|
125
125
|
return verifiedAtTopLevel;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
unifyStatement(statement, substitutions, localContext) {
|
|
128
|
+
unifyStatement(statement, substitution, substitutions, localContext) {
|
|
129
129
|
let statementUnified = false;
|
|
130
130
|
|
|
131
131
|
const statementString = statement.getString(),
|
|
132
|
-
metavariableString = this.string
|
|
132
|
+
metavariableString = this.string, ///
|
|
133
|
+
substitutionString = (substitution !== null) ?
|
|
134
|
+
substitution.getString() :
|
|
135
|
+
null;
|
|
133
136
|
|
|
134
|
-
|
|
137
|
+
(substitutionString !== null) ?
|
|
138
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution...`) :
|
|
139
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
135
140
|
|
|
136
141
|
const statementNode = statement.getNode(),
|
|
137
142
|
metavariableNode = this.node, ///
|
|
138
|
-
|
|
139
|
-
|
|
143
|
+
substitutionNode = (substitution !== null) ?
|
|
144
|
+
substitution.getSubstitutionNode() :
|
|
145
|
+
null,
|
|
146
|
+
substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
140
147
|
|
|
141
|
-
if (
|
|
142
|
-
const
|
|
148
|
+
if (substitutionPresent) {
|
|
149
|
+
const substitution = substitutions.findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
|
|
150
|
+
statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
143
151
|
|
|
144
152
|
if (statementNodeMatches) {
|
|
145
153
|
statementUnified = true;
|
|
@@ -151,64 +159,21 @@ class Metavariable {
|
|
|
151
159
|
if (metavariable === statementMetavariable) {
|
|
152
160
|
statementUnified = true;
|
|
153
161
|
} else {
|
|
154
|
-
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.
|
|
155
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
156
|
-
|
|
157
|
-
substitutions.addSubstitution(substitution, localContext);
|
|
158
|
-
|
|
159
|
-
statementUnified = true;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (statementUnified) {
|
|
164
|
-
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return statementUnified;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
unifyStatementGivenSubstitution(statement, substitution, substitutions, localContext) {
|
|
171
|
-
let statementUnifiedGivenSubstitution = false;
|
|
172
|
-
|
|
173
|
-
const statementString = statement.getString(),
|
|
174
|
-
substitutionString = substitution.getString(),
|
|
175
|
-
metavariableString = this.string; ///
|
|
176
|
-
|
|
177
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the '${substitutionString}' substitution...`);
|
|
178
|
-
|
|
179
|
-
const statementNode = statement.getNode(),
|
|
180
|
-
metavariableNode = this.node, ///
|
|
181
|
-
substitutionNode = substitution.getNode(),
|
|
182
|
-
complexSubstitution = substitutions.findComplexSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
183
|
-
|
|
184
|
-
if (complexSubstitution !== null) {
|
|
185
|
-
const statementNodeMatches = complexSubstitution.matchStatementNode(statementNode);
|
|
186
|
-
|
|
187
|
-
if (statementNodeMatches) {
|
|
188
|
-
statementUnifiedGivenSubstitution = true;
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
const metavariable = metavariableFromStatementNode(statementNode, localContext);
|
|
192
|
-
|
|
193
|
-
if (this === metavariable) { ///
|
|
194
|
-
statementUnifiedGivenSubstitution = false; ///
|
|
195
|
-
} else {
|
|
196
|
-
const metavariable = this, ///
|
|
197
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
|
|
162
|
+
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
|
|
198
163
|
|
|
199
164
|
substitution = statementForMetavariableSubstitution; ///
|
|
200
165
|
|
|
201
166
|
substitutions.addSubstitution(substitution, localContext);
|
|
202
167
|
|
|
203
|
-
|
|
168
|
+
statementUnified = true;
|
|
204
169
|
}
|
|
205
170
|
}
|
|
206
171
|
|
|
207
|
-
|
|
208
|
-
localContext.
|
|
209
|
-
|
|
172
|
+
(substitutionString !== null) ?
|
|
173
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution.`) :
|
|
174
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
210
175
|
|
|
211
|
-
return
|
|
176
|
+
return statementUnified;
|
|
212
177
|
}
|
|
213
178
|
|
|
214
179
|
toJSON() {
|
|
@@ -292,21 +257,6 @@ function metaTypeFromJSON(json, fileContext) {
|
|
|
292
257
|
return metaType;
|
|
293
258
|
}
|
|
294
259
|
|
|
295
|
-
function metavariableFromStatementNode(statementNode, localContext) {
|
|
296
|
-
let metavariable = null;
|
|
297
|
-
|
|
298
|
-
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode)
|
|
299
|
-
|
|
300
|
-
if (statementMetavariableNode !== null) {
|
|
301
|
-
const metavariableNode = statementMetavariableNode, ///
|
|
302
|
-
metavariableName = metavariableNameFromMetavariableNode(metavariableNode);
|
|
303
|
-
|
|
304
|
-
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return metavariable;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
260
|
function statementMetavariableFromStatementNode(statementNode, localContext) {
|
|
311
261
|
let statementMetavariable = null;
|
|
312
262
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import BracketedCombinator from "../../combinator/bracketed";
|
|
4
6
|
import statementWithCombinatorUnifier from "../../unifier/statementWithCombinator";
|
|
5
7
|
|
|
8
|
+
const { reverse } = arrayUtilities;
|
|
9
|
+
|
|
6
10
|
function unifyWithBracketedCombinator(statement, assignments, stated, localContext) {
|
|
7
11
|
let unifiedWithBracketedCombinator;
|
|
8
12
|
|
|
@@ -43,9 +47,28 @@ function unifyWithCombinators(statement, assignments, stated, localContext) {
|
|
|
43
47
|
return unifiedWithCombinators;
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
function unifyWithProofSteps(statement, assignments, stated, localContext) {
|
|
51
|
+
let unifiedWithProofSteps;
|
|
52
|
+
|
|
53
|
+
let proofSteps = localContext.getProofSteps();
|
|
54
|
+
|
|
55
|
+
proofSteps = reverse(proofSteps); ///
|
|
56
|
+
|
|
57
|
+
unifiedWithProofSteps = proofSteps.some((proofStep) => {
|
|
58
|
+
const statementUnified = proofStep.unifyStatement(statement, localContext);
|
|
59
|
+
|
|
60
|
+
if (statementUnified) {
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return unifiedWithProofSteps;
|
|
66
|
+
}
|
|
67
|
+
|
|
46
68
|
const unifyMixins = [
|
|
47
69
|
unifyWithBracketedCombinator,
|
|
48
|
-
unifyWithCombinators
|
|
70
|
+
unifyWithCombinators,
|
|
71
|
+
unifyWithProofSteps
|
|
49
72
|
];
|
|
50
73
|
|
|
51
74
|
export default unifyMixins;
|
|
@@ -6,7 +6,6 @@ import TypeAssertion from "../../assertion/type";
|
|
|
6
6
|
import DefinedAssertion from "../../assertion/defined";
|
|
7
7
|
import SubproofAssertion from "../../assertion/subproof";
|
|
8
8
|
import ContainedAssertion from "../../assertion/contained";
|
|
9
|
-
import StatementSubstitution from "../../substitution/statement";
|
|
10
9
|
|
|
11
10
|
import verifyFrame from "../../verify/frame";
|
|
12
11
|
import verifyJudgement from "../../verify/judgement";
|
|
@@ -38,19 +37,7 @@ function verifyAsMetavariable(statement, assignments, stated, localContext) {
|
|
|
38
37
|
|
|
39
38
|
const metavariableVerified = metavariable.verify(localContext);
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
let substitutionVerified = true;
|
|
43
|
-
|
|
44
|
-
const statementSubstitution = StatementSubstitution.fromStatementNode(statementNode, localContext);
|
|
45
|
-
|
|
46
|
-
if (statementSubstitution !== null) {
|
|
47
|
-
const statementSubstitutionVerified = statementSubstitution.verify(assignments, stated, localContext);
|
|
48
|
-
|
|
49
|
-
substitutionVerified = statementSubstitutionVerified; ///
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
verifiedAsMetavariable = substitutionVerified; ///
|
|
53
|
-
}
|
|
40
|
+
verifiedAsMetavariable = metavariableVerified; ///
|
|
54
41
|
|
|
55
42
|
if (verifiedAsMetavariable) {
|
|
56
43
|
localContext.debug(`...verified the '${statementString}' statement as a metavariable.`);
|
package/src/premise.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
+
import LocalContext from "./context/local";
|
|
4
5
|
import SubproofAssertion from "./assertion/subproof";
|
|
5
6
|
import UnqualifiedStatement from "./statement/unqualified";
|
|
6
7
|
|
|
@@ -83,7 +84,13 @@ export default class Premise {
|
|
|
83
84
|
|
|
84
85
|
localContext.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
const localContextB = localContext;
|
|
88
|
+
|
|
89
|
+
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
90
|
+
|
|
91
|
+
const localContextA = localContext; ///
|
|
92
|
+
|
|
93
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
87
94
|
|
|
88
95
|
if (statementUnified) {
|
|
89
96
|
localContext.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
|
package/src/proofStep.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import Subproof from "./subproof";
|
|
5
|
+
import Substitutions from "./substitutions";
|
|
5
6
|
import QualifiedStatement from "./statement/qualified";
|
|
6
7
|
import UnqualifiedStatement from "./statement/unqualified";
|
|
7
8
|
|
|
@@ -44,18 +45,33 @@ class ProofStep {
|
|
|
44
45
|
return statement;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
unifyStatement(statement, localContext) {
|
|
49
|
+
let statementUnified = false;
|
|
50
|
+
|
|
51
|
+
const substitutions = Substitutions.fromNothing();
|
|
52
|
+
|
|
53
|
+
if (this.qualifiedStatement !== null) {
|
|
54
|
+
const localContextA = localContext, ///
|
|
55
|
+
localContextB = localContext; ///
|
|
56
|
+
|
|
57
|
+
statementUnified = this.qualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (this.unqualifiedStatement !== null) {
|
|
61
|
+
const localContextA = localContext, ///
|
|
62
|
+
localContextB = localContext; ///
|
|
63
|
+
|
|
64
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const substitutionsLength = substitutions.getLength();
|
|
68
|
+
|
|
69
|
+
if (substitutionsLength > 0) {
|
|
70
|
+
statementUnified = false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return statementUnified;
|
|
74
|
+
}
|
|
59
75
|
|
|
60
76
|
verify(substitutions, localContext) {
|
|
61
77
|
let verified = false;
|
package/src/rule.js
CHANGED
|
@@ -67,7 +67,13 @@ export default class Rule {
|
|
|
67
67
|
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
68
68
|
|
|
69
69
|
if (proofStepsUnified) {
|
|
70
|
-
|
|
70
|
+
const statementUnifiedWithConclusion = this.conclusion.unifyStatement(statement, substitutions, localContext); ///
|
|
71
|
+
|
|
72
|
+
if (statementUnifiedWithConclusion) {
|
|
73
|
+
const substitutionsResolved = substitutions.resolve(localContext);
|
|
74
|
+
|
|
75
|
+
statementUnified = substitutionsResolved; ///
|
|
76
|
+
}
|
|
71
77
|
}
|
|
72
78
|
|
|
73
79
|
return statementUnified;
|
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";
|
|
@@ -33,6 +33,44 @@ export default class QualifiedStatement {
|
|
|
33
33
|
|
|
34
34
|
getMetavariableNode() { return this.reference.getMetavariableNode(); }
|
|
35
35
|
|
|
36
|
+
unify(substitutions, localContext) {
|
|
37
|
+
let unified;
|
|
38
|
+
|
|
39
|
+
const qualifiedStatement = this, ///
|
|
40
|
+
qualifiedStatementString = this.string; ///
|
|
41
|
+
|
|
42
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement...`);
|
|
43
|
+
|
|
44
|
+
unified = unifyMixins.some((unifyMixin) => {
|
|
45
|
+
const unified = unifyMixin(qualifiedStatement, substitutions, localContext);
|
|
46
|
+
|
|
47
|
+
return unified;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (unified) {
|
|
51
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement.`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return unified;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
unifyStatement(statement, substitutions, localContextA, localContextB) {
|
|
58
|
+
let statementUnified;
|
|
59
|
+
|
|
60
|
+
const statementString = statement.getString(),
|
|
61
|
+
unqualifiedStatementString = this.getString(); ///
|
|
62
|
+
|
|
63
|
+
localContextB.trace(`Unifying the '${statementString}' statement with the '${unqualifiedStatementString}' qualified statement...`);
|
|
64
|
+
|
|
65
|
+
statementUnified = this.statement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
66
|
+
|
|
67
|
+
if (statementUnified) {
|
|
68
|
+
localContextB.debug(`...unified the '${statementString}' statement with the '${unqualifiedStatementString}' qualified statement.`);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return statementUnified;
|
|
72
|
+
}
|
|
73
|
+
|
|
36
74
|
verify(substitutions, localContext) {
|
|
37
75
|
let verified;
|
|
38
76
|
|
|
@@ -65,27 +103,6 @@ export default class QualifiedStatement {
|
|
|
65
103
|
return verified;
|
|
66
104
|
}
|
|
67
105
|
|
|
68
|
-
unify(substitutions, localContext) {
|
|
69
|
-
let unified;
|
|
70
|
-
|
|
71
|
-
const qualifiedStatement = this, ///
|
|
72
|
-
qualifiedStatementString = this.string; ///
|
|
73
|
-
|
|
74
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement...`);
|
|
75
|
-
|
|
76
|
-
unified = unifyMixins.some((unifyMixin) => {
|
|
77
|
-
const unified = unifyMixin(qualifiedStatement, substitutions, localContext);
|
|
78
|
-
|
|
79
|
-
return unified;
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
if (unified) {
|
|
83
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement.`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return unified;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
106
|
static fromQualifiedStatementNode(qualifiedStatementNode, fileContext) {
|
|
90
107
|
let qualifiedStatement = null;
|
|
91
108
|
|
|
@@ -45,18 +45,18 @@ export default class UnqualifiedStatement {
|
|
|
45
45
|
return verified;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
unifyStatement(statement, substitutions,
|
|
48
|
+
unifyStatement(statement, substitutions, localContextA, localContextB) {
|
|
49
49
|
let statementUnified;
|
|
50
50
|
|
|
51
51
|
const statementString = statement.getString(),
|
|
52
52
|
unqualifiedStatementString = this.getString(); ///
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
localContextB.trace(`Unifying the '${statementString}' statement with the '${unqualifiedStatementString}' unqualified statement...`);
|
|
55
55
|
|
|
56
|
-
statementUnified = this.statement.unifyStatement(statement, substitutions,
|
|
56
|
+
statementUnified = this.statement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
57
57
|
|
|
58
58
|
if (statementUnified) {
|
|
59
|
-
|
|
59
|
+
localContextB.debug(`...unified the '${statementString}' statement with the '${unqualifiedStatementString}' unqualified statement.`);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return statementUnified;
|