occam-verify-cli 0.0.1066 → 0.0.1068
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 +3 -2
- package/lib/assertion/defined.js +3 -2
- package/lib/assignment/judgement.js +3 -3
- package/lib/conclusion.js +8 -4
- package/lib/consequent.js +8 -4
- package/lib/context/file.js +7 -7
- package/lib/context/local.js +12 -25
- package/lib/declaration.js +90 -3
- package/lib/frame.js +109 -48
- package/lib/judgement.js +84 -5
- package/lib/metaType.js +24 -3
- package/lib/metavariable.js +94 -65
- package/lib/mixins/statement/unify.js +1 -1
- package/lib/mixins/statement/verify.js +14 -23
- package/lib/premise.js +14 -6
- package/lib/proofStep.js +22 -13
- package/lib/reference.js +11 -9
- package/lib/rule.js +9 -2
- package/lib/ruleNames.js +5 -1
- package/lib/statement/qualified.js +30 -17
- package/lib/statement/unqualified.js +30 -6
- package/lib/statement.js +20 -9
- package/lib/subproof.js +1 -1
- package/lib/substitution/frameForMetavariable.js +80 -71
- package/lib/substitution/statementForMetavariable.js +118 -56
- package/lib/substitution/termForVariable.js +75 -75
- package/lib/substitution.js +68 -33
- package/lib/substitutions.js +58 -49
- package/lib/supposition.js +8 -4
- package/lib/unifier/intrinsicLevel.js +4 -4
- package/lib/unifier/metaLevel.js +23 -16
- package/lib/unifier/statementWithCombinator.js +2 -2
- package/lib/utilities/node.js +24 -10
- package/lib/utilities/tokens.js +8 -1
- package/lib/variable.js +17 -13
- package/package.json +2 -2
- package/src/assertion/contained.js +3 -1
- package/src/assertion/defined.js +3 -1
- package/src/assignment/judgement.js +3 -4
- package/src/conclusion.js +10 -3
- package/src/consequent.js +10 -3
- package/src/context/file.js +6 -8
- package/src/context/local.js +12 -33
- package/src/declaration.js +57 -4
- package/src/frame.js +149 -90
- package/src/judgement.js +109 -3
- package/src/metaType.js +29 -3
- package/src/metavariable.js +140 -87
- package/src/mixins/statement/unify.js +1 -0
- package/src/mixins/statement/verify.js +16 -28
- package/src/premise.js +19 -5
- package/src/proofStep.js +28 -12
- package/src/reference.js +11 -7
- package/src/rule.js +13 -1
- package/src/ruleNames.js +1 -0
- package/src/statement/qualified.js +38 -21
- package/src/statement/unqualified.js +35 -5
- package/src/statement.js +20 -12
- package/src/subproof.js +0 -1
- package/src/substitution/frameForMetavariable.js +90 -104
- package/src/substitution/statementForMetavariable.js +133 -61
- package/src/substitution/termForVariable.js +83 -113
- package/src/substitution.js +55 -26
- package/src/substitutions.js +59 -47
- package/src/supposition.js +10 -3
- package/src/unifier/intrinsicLevel.js +4 -3
- package/src/unifier/metaLevel.js +42 -24
- package/src/unifier/statementWithCombinator.js +1 -1
- package/src/utilities/node.js +26 -10
- package/src/utilities/tokens.js +7 -0
- package/src/variable.js +20 -11
- package/lib/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -62
- package/lib/resolve/substitution.js +0 -27
- package/lib/resolve/substitutions.js +0 -37
- package/lib/unify/metavariableWithFrame.js +0 -40
- package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -31
- package/lib/verify/declaration.js +0 -83
- package/lib/verify/frame.js +0 -120
- package/lib/verify/judgement.js +0 -88
- package/lib/verify/metavariableGivenMetaType.js +0 -44
- package/src/resolve/complexSubstitutionAgainstSimpleSubstitution.js +0 -79
- package/src/resolve/substitution.js +0 -19
- package/src/resolve/substitutions.js +0 -31
- package/src/unify/metavariableWithFrame.js +0 -40
- package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -27
- package/src/verify/declaration.js +0 -113
- package/src/verify/frame.js +0 -157
- package/src/verify/judgement.js +0 -127
- package/src/verify/metavariableGivenMetaType.js +0 -45
package/src/metavariable.js
CHANGED
|
@@ -4,6 +4,7 @@ import shim from "./shim";
|
|
|
4
4
|
import Argument from "./argument";
|
|
5
5
|
import LocalContext from "./context/local";
|
|
6
6
|
import metavariableUnifier from "./unifier/metavariable";
|
|
7
|
+
import FrameForMetavariableSubstitution from "./substitution/frameForMetavariable";
|
|
7
8
|
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
8
9
|
|
|
9
10
|
import { nodeQuery } from "./utilities/query";
|
|
@@ -13,6 +14,7 @@ import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
|
13
14
|
const argumentNodeQuery = nodeQuery("/metavariable/argument"),
|
|
14
15
|
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
15
16
|
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
|
|
17
|
+
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
16
18
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
17
19
|
|
|
18
20
|
class Metavariable {
|
|
@@ -50,10 +52,16 @@ class Metavariable {
|
|
|
50
52
|
return metaTypeName;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
+
matchMetaType(metaType) {
|
|
56
|
+
const metaTypeMatches = (this.metaType === metaType);
|
|
55
57
|
|
|
56
|
-
return
|
|
58
|
+
return metaTypeMatches;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
matchMetavariableName(metavariableName) {
|
|
62
|
+
const metavariableNameMatches = (this.name === metavariableName);
|
|
63
|
+
|
|
64
|
+
return metavariableNameMatches;
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
matchMetavariableNode(metavariableNode) {
|
|
@@ -62,6 +70,107 @@ class Metavariable {
|
|
|
62
70
|
return metavariableNodeMatches;
|
|
63
71
|
}
|
|
64
72
|
|
|
73
|
+
unifyFrame(frame, substitutions, localContext) {
|
|
74
|
+
let frameUnified = false;
|
|
75
|
+
|
|
76
|
+
const frameNode = frame.getNode(),
|
|
77
|
+
frameString = frame.getString(),
|
|
78
|
+
metavariableString = this.string; ///
|
|
79
|
+
|
|
80
|
+
localContext.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
81
|
+
|
|
82
|
+
const metavariableName = this.name, ///
|
|
83
|
+
simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableName(metavariableName);
|
|
84
|
+
|
|
85
|
+
if (simpleSubstitutionPresent) {
|
|
86
|
+
const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableName(metavariableName),
|
|
87
|
+
substitution = simpleSubstitution, ///
|
|
88
|
+
frameNodeMatches = substitution.matchFrameNode(frameNode);
|
|
89
|
+
|
|
90
|
+
if (frameNodeMatches) {
|
|
91
|
+
frameUnified = true;
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
const metavariableNode = this.node, ///
|
|
95
|
+
metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
|
|
96
|
+
frameMetavariable = frameMetavariableFromStatementNode(frameNode, localContext);
|
|
97
|
+
|
|
98
|
+
if (metavariable === frameMetavariable) {
|
|
99
|
+
frameUnified = true;
|
|
100
|
+
} else {
|
|
101
|
+
const metavariable = this, ///
|
|
102
|
+
frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameAndMetavariable(frame, metavariable, localContext),
|
|
103
|
+
substitution = frameForMetavariableSubstitution; ///
|
|
104
|
+
|
|
105
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
106
|
+
|
|
107
|
+
frameUnified = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (frameUnified) {
|
|
112
|
+
localContext.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return frameUnified;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
unifyStatement(statement, substitution, substitutions, localContext) {
|
|
119
|
+
let statementUnified = false;
|
|
120
|
+
|
|
121
|
+
const statementString = statement.getString(),
|
|
122
|
+
metavariableString = this.string, ///
|
|
123
|
+
substitutionString = (substitution !== null) ?
|
|
124
|
+
substitution.getString() :
|
|
125
|
+
null;
|
|
126
|
+
|
|
127
|
+
(substitutionString !== null) ?
|
|
128
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution...`) :
|
|
129
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
130
|
+
|
|
131
|
+
const statementNode = statement.getNode(),
|
|
132
|
+
metavariableNode = this.node, ///
|
|
133
|
+
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
134
|
+
substitutionNode = (substitution !== null) ?
|
|
135
|
+
substitution.getSubstitutionNode() :
|
|
136
|
+
null,
|
|
137
|
+
substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode);
|
|
138
|
+
|
|
139
|
+
if (substitutionPresent) {
|
|
140
|
+
const substitution = substitutions.findSubstitutionByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode),
|
|
141
|
+
statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
142
|
+
|
|
143
|
+
if (statementNodeMatches) {
|
|
144
|
+
statementUnified = true;
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
const metavariableNode = this.node, ///
|
|
148
|
+
metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
|
|
149
|
+
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
150
|
+
|
|
151
|
+
if (metavariable === statementMetavariable) {
|
|
152
|
+
statementUnified = true;
|
|
153
|
+
} else {
|
|
154
|
+
const metavariable = this, ///
|
|
155
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
|
|
156
|
+
|
|
157
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
158
|
+
|
|
159
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
160
|
+
|
|
161
|
+
statementUnified = true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (statementUnified) {
|
|
166
|
+
(substitutionString !== null) ?
|
|
167
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution.`) :
|
|
168
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return statementUnified;
|
|
172
|
+
}
|
|
173
|
+
|
|
65
174
|
verify(localContext) {
|
|
66
175
|
let verified;
|
|
67
176
|
|
|
@@ -80,7 +189,6 @@ class Metavariable {
|
|
|
80
189
|
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
81
190
|
|
|
82
191
|
verified = metavariableUnified; ///
|
|
83
|
-
|
|
84
192
|
}
|
|
85
193
|
|
|
86
194
|
if (verified) {
|
|
@@ -125,90 +233,29 @@ class Metavariable {
|
|
|
125
233
|
return verifiedAtTopLevel;
|
|
126
234
|
}
|
|
127
235
|
|
|
128
|
-
|
|
129
|
-
let
|
|
130
|
-
|
|
131
|
-
const statementString = statement.getString(),
|
|
132
|
-
metavariableString = this.string; ///
|
|
133
|
-
|
|
134
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
135
|
-
|
|
136
|
-
const statementNode = statement.getNode(),
|
|
137
|
-
metavariableNode = this.node, ///
|
|
138
|
-
simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
139
|
-
substitution = simpleSubstitution; ///
|
|
140
|
-
|
|
141
|
-
if (substitution !== null) {
|
|
142
|
-
const statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
143
|
-
|
|
144
|
-
if (statementNodeMatches) {
|
|
145
|
-
statementUnified = true;
|
|
146
|
-
}
|
|
147
|
-
} else {
|
|
148
|
-
const metavariable = this, ///
|
|
149
|
-
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
150
|
-
|
|
151
|
-
if (metavariable === statementMetavariable) {
|
|
152
|
-
statementUnified = true;
|
|
153
|
-
} else {
|
|
154
|
-
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
|
|
155
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
236
|
+
verifyGivenMetaType(metaType, localContext) {
|
|
237
|
+
let verifiedGivenMetaType = false;
|
|
156
238
|
|
|
157
|
-
|
|
239
|
+
const metavariableString = this.string, ///
|
|
240
|
+
metaTypeString = metaType.getString();
|
|
158
241
|
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
}
|
|
242
|
+
localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
|
|
162
243
|
|
|
163
|
-
|
|
164
|
-
|
|
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);
|
|
198
|
-
|
|
199
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
244
|
+
const name = this.getName(),
|
|
245
|
+
metavariableName = name, ///
|
|
246
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
200
247
|
|
|
201
|
-
|
|
248
|
+
if (metavariable !== null) {
|
|
249
|
+
const metaTypeMatches = metavariable.matchMetaType(metaType);
|
|
202
250
|
|
|
203
|
-
|
|
204
|
-
}
|
|
251
|
+
verifiedGivenMetaType = metaTypeMatches; ///
|
|
205
252
|
}
|
|
206
253
|
|
|
207
|
-
if (
|
|
208
|
-
localContext.
|
|
254
|
+
if (verifiedGivenMetaType) {
|
|
255
|
+
localContext.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type.`);
|
|
209
256
|
}
|
|
210
257
|
|
|
211
|
-
return
|
|
258
|
+
return verifiedGivenMetaType;
|
|
212
259
|
}
|
|
213
260
|
|
|
214
261
|
toJSON() {
|
|
@@ -292,19 +339,25 @@ function metaTypeFromJSON(json, fileContext) {
|
|
|
292
339
|
return metaType;
|
|
293
340
|
}
|
|
294
341
|
|
|
295
|
-
function
|
|
296
|
-
|
|
342
|
+
function metavariableFromMetavariableNode(metavariableNode, localContext) {
|
|
343
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
344
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
297
345
|
|
|
298
|
-
|
|
346
|
+
return metavariable;
|
|
347
|
+
}
|
|
299
348
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
metavariableName = metavariableNameFromMetavariableNode(metavariableNode);
|
|
349
|
+
function frameMetavariableFromStatementNode(frameNode, localContext) {
|
|
350
|
+
let frameMetavariable = null;
|
|
303
351
|
|
|
304
|
-
|
|
352
|
+
const frameMetavariableNode = frameMetavariableNodeQuery(frameNode);
|
|
353
|
+
|
|
354
|
+
if (frameMetavariableNode !== null) {
|
|
355
|
+
const frameMetavariableName = metavariableNameFromMetavariableNode(frameMetavariableNode);
|
|
356
|
+
|
|
357
|
+
frameMetavariable = localContext.findMetavariableByMetavariableName(frameMetavariableName);
|
|
305
358
|
}
|
|
306
359
|
|
|
307
|
-
return
|
|
360
|
+
return frameMetavariable;
|
|
308
361
|
}
|
|
309
362
|
|
|
310
363
|
function statementMetavariableFromStatementNode(statementNode, localContext) {
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Frame from "../../frame";
|
|
3
4
|
import Equality from "../../equality";
|
|
5
|
+
import Judgement from "../../judgement";
|
|
6
|
+
import Declaration from "../../declaration";
|
|
4
7
|
import Metavariable from "../../metavariable";
|
|
5
8
|
import TypeAssertion from "../../assertion/type";
|
|
6
9
|
import DefinedAssertion from "../../assertion/defined";
|
|
7
10
|
import SubproofAssertion from "../../assertion/subproof";
|
|
8
11
|
import ContainedAssertion from "../../assertion/contained";
|
|
9
|
-
import TermForVariableSubstitution from "../../substitution/termForVariable";
|
|
10
|
-
import FrameForMetavariableSubstitution from "../../substitution/frameForMetavariable";
|
|
11
|
-
|
|
12
|
-
import verifyFrame from "../../verify/frame";
|
|
13
|
-
import verifyJudgement from "../../verify/judgement";
|
|
14
|
-
import verifyDeclaration from "../../verify/declaration";
|
|
15
12
|
|
|
16
13
|
import { nodeQuery } from "../../utilities/query";
|
|
17
14
|
|
|
@@ -39,19 +36,7 @@ function verifyAsMetavariable(statement, assignments, stated, localContext) {
|
|
|
39
36
|
|
|
40
37
|
const metavariableVerified = metavariable.verify(localContext);
|
|
41
38
|
|
|
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
|
-
}
|
|
39
|
+
verifiedAsMetavariable = metavariableVerified; ///
|
|
55
40
|
|
|
56
41
|
if (verifiedAsMetavariable) {
|
|
57
42
|
localContext.debug(`...verified the '${statementString}' statement as a metavariable.`);
|
|
@@ -89,14 +74,15 @@ function verifyAsFrame(statement, assignments, stated, localContext) {
|
|
|
89
74
|
let verifiedAsFrame = false;
|
|
90
75
|
|
|
91
76
|
const statementNode = statement.getNode(),
|
|
92
|
-
frameNode = frameNodeQuery(statementNode)
|
|
77
|
+
frameNode = frameNodeQuery(statementNode),
|
|
78
|
+
frame = Frame.fromFrameNode(frameNode, localContext);
|
|
93
79
|
|
|
94
|
-
if (
|
|
80
|
+
if (frame !== null) {
|
|
95
81
|
const statementString = statement.getString();
|
|
96
82
|
|
|
97
83
|
localContext.trace(`Verifying the '${statementString}' statement as a frame...`);
|
|
98
84
|
|
|
99
|
-
const frameVerified =
|
|
85
|
+
const frameVerified = frame.verify(assignments, stated, localContext);
|
|
100
86
|
|
|
101
87
|
verifiedAsFrame = frameVerified; ///
|
|
102
88
|
|
|
@@ -112,14 +98,15 @@ function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
|
112
98
|
let verifiedAsJudgement = false;
|
|
113
99
|
|
|
114
100
|
const statementNode = statement.getNode(),
|
|
115
|
-
judgementNode = judgementNodeQuery(statementNode)
|
|
101
|
+
judgementNode = judgementNodeQuery(statementNode),
|
|
102
|
+
judgement = Judgement.fromJudgementNode(judgementNode, localContext);
|
|
116
103
|
|
|
117
|
-
if (
|
|
104
|
+
if (judgement !== null) {
|
|
118
105
|
const statementString = statement.getString();
|
|
119
106
|
|
|
120
107
|
localContext.trace(`Verifying the '${statementString}' statement as a judgement...`);
|
|
121
108
|
|
|
122
|
-
const judgementVerified =
|
|
109
|
+
const judgementVerified = judgement.verify(assignments, stated, localContext);
|
|
123
110
|
|
|
124
111
|
verifiedAsJudgement = judgementVerified; ///
|
|
125
112
|
|
|
@@ -135,14 +122,15 @@ function verifyAsDeclaration(statement, assignments, stated, localContext) {
|
|
|
135
122
|
let verifiedAsDeclaration = false;
|
|
136
123
|
|
|
137
124
|
const statementNode = statement.getNode(),
|
|
138
|
-
declarationNode = declarationNodeQuery(statementNode)
|
|
125
|
+
declarationNode = declarationNodeQuery(statementNode),
|
|
126
|
+
declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
139
127
|
|
|
140
|
-
if (
|
|
128
|
+
if (declaration !== null) {
|
|
141
129
|
const statementString = statement.getString();
|
|
142
130
|
|
|
143
131
|
localContext.trace(`Verifying the '${statementString}' statement as a declaration...`);
|
|
144
132
|
|
|
145
|
-
const declarationVerified =
|
|
133
|
+
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
146
134
|
|
|
147
135
|
verifiedAsDeclaration = declarationVerified; ///
|
|
148
136
|
|
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
|
|
|
@@ -60,12 +61,19 @@ export default class Premise {
|
|
|
60
61
|
|
|
61
62
|
substitutions.snapshot();
|
|
62
63
|
|
|
64
|
+
let subproofUnified = false,
|
|
65
|
+
statementUnified = false;
|
|
66
|
+
|
|
63
67
|
if (false) {
|
|
64
68
|
///
|
|
65
69
|
} else if (subproof !== null) {
|
|
66
|
-
|
|
70
|
+
subproofUnified = this.unifySubproof(subproof, substitutions, localContext);
|
|
67
71
|
} else if (statement !== null) {
|
|
68
|
-
|
|
72
|
+
statementUnified = this.unifyStatement(statement, substitutions, localContext);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (subproofUnified || statementUnified) {
|
|
76
|
+
proofStepUnified = true;
|
|
69
77
|
}
|
|
70
78
|
|
|
71
79
|
proofStepUnified ?
|
|
@@ -81,12 +89,18 @@ export default class Premise {
|
|
|
81
89
|
const statementString = statement.getString(),
|
|
82
90
|
premiseString = this.getString();
|
|
83
91
|
|
|
84
|
-
|
|
92
|
+
const localContextB = localContext; ///
|
|
93
|
+
|
|
94
|
+
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
95
|
+
|
|
96
|
+
const localContextA = localContext; ///
|
|
97
|
+
|
|
98
|
+
localContextB.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
|
|
85
99
|
|
|
86
|
-
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions,
|
|
100
|
+
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
87
101
|
|
|
88
102
|
if (statementUnified) {
|
|
89
|
-
|
|
103
|
+
localContextB.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
|
|
90
104
|
}
|
|
91
105
|
|
|
92
106
|
return statementUnified;
|
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/reference.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import Metavariable from "./metavariable";
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "./utilities/query";
|
|
6
|
+
import { referenceMetaType } from "./metaType";
|
|
6
7
|
|
|
7
8
|
const metavariableNodeQuery = nodeQuery("//reference/metavariable");
|
|
8
9
|
|
|
@@ -25,20 +26,23 @@ export default class Reference {
|
|
|
25
26
|
return metavariableNode;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
let
|
|
29
|
+
verify(localContext) {
|
|
30
|
+
let verified;
|
|
30
31
|
|
|
31
32
|
const referenceString = this.getString(); ///
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
localContext.trace(`Verifying the '${referenceString}' reference...`);
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
const metaType = referenceMetaType, ///
|
|
37
|
+
metavariableVerifiedGivenMetaType = this.metavariable.verifyGivenMetaType(metaType, localContext);
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
verified = metavariableVerifiedGivenMetaType; ///
|
|
40
|
+
|
|
41
|
+
if (verified) {
|
|
42
|
+
localContext.debug(`...verified the '${referenceString}' reference.`);
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
return
|
|
45
|
+
return verified;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
toJSON() {
|
package/src/rule.js
CHANGED
|
@@ -67,7 +67,19 @@ 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 localContextB = localContext; ///
|
|
74
|
+
|
|
75
|
+
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
76
|
+
|
|
77
|
+
const localContextA = localContext; ///
|
|
78
|
+
|
|
79
|
+
const substitutionsResolved = substitutions.resolve(localContextA, localContextB);
|
|
80
|
+
|
|
81
|
+
statementUnified = substitutionsResolved; ///
|
|
82
|
+
}
|
|
71
83
|
}
|
|
72
84
|
|
|
73
85
|
return statementUnified;
|
package/src/ruleNames.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
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";
|
|
5
6
|
export const UNQUALIFIED_STATEMENT_RULE_NAME = "unqualifiedStatement";
|
|
6
7
|
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
|
|