occam-verify-cli 0.0.1066 → 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/conclusion.js +6 -2
- package/lib/consequent.js +6 -2
- package/lib/context/file.js +7 -7
- package/lib/context/local.js +12 -25
- package/lib/metavariable.js +15 -54
- package/lib/mixins/statement/unify.js +17 -2
- 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/statement/qualified.js +30 -17
- package/lib/statement/unqualified.js +5 -5
- package/lib/statement.js +18 -9
- package/lib/subproof.js +1 -1
- package/lib/substitution/frameForMetavariable.js +35 -27
- package/lib/substitution/statementForMetavariable.js +93 -54
- package/lib/substitution/termForVariable.js +30 -31
- package/lib/substitution.js +48 -13
- package/lib/substitutions.js +22 -19
- package/lib/supposition.js +6 -2
- package/lib/unifier/metaLevel.js +14 -11
- package/lib/unify/metavariableWithFrame.js +2 -2
- 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/conclusion.js +8 -1
- package/src/consequent.js +8 -1
- package/src/context/file.js +6 -8
- package/src/context/local.js +12 -33
- package/src/metavariable.js +24 -74
- package/src/mixins/statement/unify.js +24 -1
- package/src/mixins/statement/verify.js +1 -15
- package/src/premise.js +8 -1
- package/src/proofStep.js +28 -12
- package/src/rule.js +7 -1
- package/src/statement/qualified.js +38 -21
- package/src/statement/unqualified.js +4 -4
- package/src/statement.js +18 -12
- package/src/subproof.js +0 -1
- package/src/substitution/frameForMetavariable.js +47 -42
- package/src/substitution/statementForMetavariable.js +102 -61
- package/src/substitution/termForVariable.js +41 -50
- package/src/substitution.js +40 -11
- package/src/substitutions.js +32 -25
- package/src/supposition.js +8 -1
- package/src/unifier/metaLevel.js +23 -17
- package/src/unify/metavariableWithFrame.js +2 -2
- package/src/variable.js +7 -7
- package/lib/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -62
- package/lib/resolve/substitution.js +0 -27
- package/lib/resolve/substitutions.js +0 -37
- package/src/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -79
- package/src/resolve/substitution.js +0 -19
- package/src/resolve/substitutions.js +0 -31
package/src/context/file.js
CHANGED
|
@@ -520,10 +520,9 @@ export default class FileContext {
|
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
findVariableByVariableName(variableName) {
|
|
523
|
-
const
|
|
524
|
-
variables = this.getVariables(),
|
|
523
|
+
const variables = this.getVariables(),
|
|
525
524
|
variable = variables.find((variable) => {
|
|
526
|
-
const nameMatches = variable.
|
|
525
|
+
const nameMatches = variable.matchVariableName(variableName);
|
|
527
526
|
|
|
528
527
|
if (nameMatches) {
|
|
529
528
|
return true;
|
|
@@ -547,10 +546,9 @@ export default class FileContext {
|
|
|
547
546
|
}
|
|
548
547
|
|
|
549
548
|
findMetavariableByMetavariableName(metavariableName) {
|
|
550
|
-
const
|
|
551
|
-
metavariables = this.getMetavariables(),
|
|
549
|
+
const metavariables = this.getMetavariables(),
|
|
552
550
|
metavariable = metavariables.find((metavariable) => {
|
|
553
|
-
const nameMatches = metavariable.
|
|
551
|
+
const nameMatches = metavariable.matchMetavariableName(metavariableName);
|
|
554
552
|
|
|
555
553
|
if (nameMatches) {
|
|
556
554
|
return true;
|
|
@@ -625,9 +623,9 @@ export default class FileContext {
|
|
|
625
623
|
addVariable(variable) {
|
|
626
624
|
let variableAdded = false;
|
|
627
625
|
|
|
628
|
-
const
|
|
626
|
+
const variableNode = variable.getNode(),
|
|
629
627
|
variablePresent = this.variables.some((variable) => {
|
|
630
|
-
const variableMatchesNode = variable.
|
|
628
|
+
const variableMatchesNode = variable.matchVariableNode(variableNode);
|
|
631
629
|
|
|
632
630
|
if (variableMatchesNode) {
|
|
633
631
|
return true;
|
package/src/context/local.js
CHANGED
|
@@ -7,7 +7,7 @@ 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
13
|
constructor(context, tokens, variables, proofSteps, judgements, equivalences, metavariables) {
|
|
@@ -166,9 +166,9 @@ class LocalContext {
|
|
|
166
166
|
addVariable(variable) {
|
|
167
167
|
let variableAdded = false;
|
|
168
168
|
|
|
169
|
-
const
|
|
169
|
+
const variableNode = variable.getNode(),
|
|
170
170
|
variablePresent = this.variables.some((variable) => {
|
|
171
|
-
const variableMatchesNode = variable.
|
|
171
|
+
const variableMatchesNode = variable.matchVariableNode(variableNode);
|
|
172
172
|
|
|
173
173
|
if (variableMatchesNode) {
|
|
174
174
|
return true;
|
|
@@ -232,26 +232,6 @@ class LocalContext {
|
|
|
232
232
|
return metavariableAdded;
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
unifyStatement(statementNode, localContext) {
|
|
236
|
-
let proofSteps = this.getProofSteps();
|
|
237
|
-
|
|
238
|
-
proofSteps = reverse(proofSteps); ///
|
|
239
|
-
|
|
240
|
-
const equivalences = this.getEquivalences(),
|
|
241
|
-
localContextA = this, ///
|
|
242
|
-
localContextB = localContext, ///
|
|
243
|
-
statementNodeB = statementNode, ///
|
|
244
|
-
statementUnified = proofSteps.some((proofStep) => {
|
|
245
|
-
const statementUnified = proofStep.unifyStatement(statementNodeB, equivalences, localContextA, localContextB);
|
|
246
|
-
|
|
247
|
-
if (statementUnified) {
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
return statementUnified;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
235
|
getTermType(term) {
|
|
256
236
|
let termType;
|
|
257
237
|
|
|
@@ -343,10 +323,9 @@ class LocalContext {
|
|
|
343
323
|
findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
344
324
|
|
|
345
325
|
findVariableByVariableName(variableName) {
|
|
346
|
-
const
|
|
347
|
-
variables = this.getVariables(),
|
|
326
|
+
const variables = this.getVariables(),
|
|
348
327
|
variable = variables.find((variable) => {
|
|
349
|
-
const nameMatches = variable.
|
|
328
|
+
const nameMatches = variable.matchVariableName(variableName);
|
|
350
329
|
|
|
351
330
|
if (nameMatches) {
|
|
352
331
|
return true;
|
|
@@ -370,10 +349,9 @@ class LocalContext {
|
|
|
370
349
|
}
|
|
371
350
|
|
|
372
351
|
findMetavariableByMetavariableName(metavariableName) {
|
|
373
|
-
const
|
|
374
|
-
metavariables = this.getMetavariables(),
|
|
352
|
+
const metavariables = this.getMetavariables(),
|
|
375
353
|
metavariable = metavariables.find((metavariable) => {
|
|
376
|
-
const nameMatches = metavariable.
|
|
354
|
+
const nameMatches = metavariable.matchMetavariableName(metavariableName);
|
|
377
355
|
|
|
378
356
|
if (nameMatches) {
|
|
379
357
|
return true;
|
|
@@ -478,14 +456,15 @@ class LocalContext {
|
|
|
478
456
|
return localContext;
|
|
479
457
|
}
|
|
480
458
|
|
|
481
|
-
static
|
|
482
|
-
const context =
|
|
459
|
+
static fromLocalContextAndTokens(localContext, tokens) {
|
|
460
|
+
const context = localContext, ///
|
|
483
461
|
variables = [],
|
|
484
462
|
proofSteps = [],
|
|
485
463
|
judgements = [],
|
|
486
464
|
equivalences = [],
|
|
487
|
-
metavariables = []
|
|
488
|
-
|
|
465
|
+
metavariables = [];
|
|
466
|
+
|
|
467
|
+
localContext = new LocalContext(context, tokens, variables, proofSteps, judgements, equivalences, metavariables); ///
|
|
489
468
|
|
|
490
469
|
return localContext;
|
|
491
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 { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
3
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,8 +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 TermForVariableSubstitution from "../../substitution/termForVariable";
|
|
10
|
-
import FrameForMetavariableSubstitution from "../../substitution/frameForMetavariable";
|
|
11
9
|
|
|
12
10
|
import verifyFrame from "../../verify/frame";
|
|
13
11
|
import verifyJudgement from "../../verify/judgement";
|
|
@@ -39,19 +37,7 @@ function verifyAsMetavariable(statement, assignments, stated, localContext) {
|
|
|
39
37
|
|
|
40
38
|
const metavariableVerified = metavariable.verify(localContext);
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
let substitutionVerified = true;
|
|
44
|
-
|
|
45
|
-
const substitution = FrameForMetavariableSubstitution.fromStatementNode(statementNode, localContext) ||
|
|
46
|
-
TermForVariableSubstitution.fromStatementNode(statementNode, localContext) ||
|
|
47
|
-
null;
|
|
48
|
-
|
|
49
|
-
if (substitution !== null) {
|
|
50
|
-
substitutionVerified = substitution.verify(assignments, stated, localContext);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
verifiedAsMetavariable = substitutionVerified; ///
|
|
54
|
-
}
|
|
40
|
+
verifiedAsMetavariable = metavariableVerified; ///
|
|
55
41
|
|
|
56
42
|
if (verifiedAsMetavariable) {
|
|
57
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;
|
|
@@ -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;
|
package/src/statement.js
CHANGED
|
@@ -51,7 +51,7 @@ class Statement {
|
|
|
51
51
|
const variableString = variable.getString(),
|
|
52
52
|
statementString = this.string; ///
|
|
53
53
|
|
|
54
|
-
localContext.trace(`
|
|
54
|
+
localContext.trace(`Is the '${variableString}' variable contained in the '${statementString}' statement...`);
|
|
55
55
|
|
|
56
56
|
const variableNode = variable.getNode(),
|
|
57
57
|
statementNode = this.node,
|
|
@@ -66,7 +66,7 @@ class Statement {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
if (variableContained) {
|
|
69
|
-
localContext.debug(`...the '${variableString}' variable is contained in
|
|
69
|
+
localContext.debug(`...the '${variableString}' variable is contained in the '${statementString}' statement.`);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
return variableContained;
|
|
@@ -78,7 +78,7 @@ class Statement {
|
|
|
78
78
|
const metavariableString = metavariable.getString(),
|
|
79
79
|
statementString = this.string; ///
|
|
80
80
|
|
|
81
|
-
localContext.trace(`
|
|
81
|
+
localContext.trace(`Is the '${metavariableString}' metavariable contained in the '${statementString}' statement...`);
|
|
82
82
|
|
|
83
83
|
const metavariableNode = metavariable.getNode(),
|
|
84
84
|
statementNode = this.node,
|
|
@@ -93,13 +93,19 @@ class Statement {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
if (metavariableContained) {
|
|
96
|
-
localContext.debug(`...the '${metavariableString}' metavariable is contained in
|
|
96
|
+
localContext.debug(`...the '${metavariableString}' metavariable is contained in the '${statementString}' statement.`);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
return metavariableContained;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
matchStatementNode(statementNode) {
|
|
103
|
+
const statementNodeMatches = this.node.match(statementNode);
|
|
104
|
+
|
|
105
|
+
return statementNodeMatches;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
unifyStatement(statement, substitutions, localContextA, localContextB) {
|
|
103
109
|
let statementUnified;
|
|
104
110
|
|
|
105
111
|
const statementA = this, ///
|
|
@@ -107,20 +113,20 @@ class Statement {
|
|
|
107
113
|
statementAString = statementA.getString(),
|
|
108
114
|
statementBString = statementB.getString();
|
|
109
115
|
|
|
110
|
-
|
|
116
|
+
localContextB.trace(`Unifying the '${statementBString}' statement with the '${statementAString}' statement...`);
|
|
111
117
|
|
|
112
118
|
const statementANode = statementA.getNode(),
|
|
113
119
|
statementBNode = statementB.getNode(),
|
|
114
120
|
nodeA = statementANode, ///
|
|
115
|
-
nodeB = statementBNode
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
nodeB = statementBNode; ///
|
|
122
|
+
|
|
123
|
+
localContextA = LocalContext.fromLocalContextAndTokens(localContextA, this.tokens);
|
|
124
|
+
|
|
125
|
+
const unifiedAtMetaLevel = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
120
126
|
|
|
121
127
|
statementUnified = unifiedAtMetaLevel; ///
|
|
122
128
|
|
|
123
|
-
|
|
129
|
+
localContextB.debug(`...unified the '${statementBString}' statement with the '${statementAString}' statement.`);
|
|
124
130
|
|
|
125
131
|
return statementUnified;
|
|
126
132
|
}
|