occam-verify-cli 0.0.1074 → 0.0.1077
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 +6 -4
- package/lib/assertion/defined.js +2 -2
- package/lib/assertion/subproof.js +46 -30
- package/lib/assertion/type.js +4 -5
- package/lib/assignment/variable.js +2 -2
- package/lib/axiom.js +9 -12
- package/lib/combinator/bracketed.js +3 -2
- package/lib/combinator.js +6 -6
- package/lib/conclusion.js +2 -3
- package/lib/conjecture.js +10 -15
- package/lib/consequent.js +2 -3
- package/lib/constructor/bracketed.js +3 -2
- package/lib/constructor.js +6 -6
- package/lib/context/file.js +48 -102
- package/lib/context/local.js +21 -20
- package/lib/declaration/combinator.js +5 -5
- package/lib/declaration/constructor.js +5 -5
- package/lib/declaration/metavariable.js +4 -5
- package/lib/declaration/type.js +3 -3
- package/lib/declaration/variable.js +5 -5
- package/lib/declaration.js +10 -9
- package/lib/derivation.js +6 -2
- package/lib/equality.js +6 -2
- package/lib/frame.js +11 -13
- package/lib/index.js +13 -1
- package/lib/judgement.js +11 -8
- package/lib/label.js +6 -7
- package/lib/lemma.js +10 -15
- package/lib/metaLemma.js +15 -15
- package/lib/metatheorem.js +9 -14
- package/lib/metavariable.js +22 -27
- package/lib/mixins/statement/qualified/unify.js +2 -2
- package/lib/mixins/statement/unify.js +2 -2
- package/lib/mixins/statement/verify.js +20 -54
- package/lib/mixins/term/verify.js +3 -3
- package/lib/premise.js +24 -21
- package/lib/proof.js +8 -4
- package/lib/proofStep.js +62 -28
- package/lib/reference.js +3 -3
- package/lib/rule.js +17 -24
- package/lib/statement/qualified.js +8 -4
- package/lib/statement.js +5 -5
- package/lib/subDerivation.js +6 -2
- package/lib/subproof.js +10 -7
- package/lib/substitution/statementForMetavariable.js +36 -27
- package/lib/substitution.js +13 -13
- package/lib/substitutions.js +73 -49
- package/lib/supposition.js +30 -23
- package/lib/term.js +5 -5
- package/lib/theorem.js +10 -15
- package/lib/topLevelAssertion.js +12 -6
- package/lib/type.js +5 -5
- package/lib/unifier/equality.js +2 -2
- package/lib/unifier/metaLevel.js +6 -6
- package/lib/unifier/metavariable.js +5 -5
- package/lib/unifier/statementWithCombinator.js +2 -2
- package/lib/utilities/brackets.js +2 -2
- package/lib/utilities/node.js +2 -7
- package/lib/utilities/nominal.js +26 -0
- package/lib/utilities/subproof.js +2 -2
- package/lib/utilities/tokens.js +3 -7
- package/lib/variable.js +6 -6
- package/lib/verifier/statementAsCombinator.js +4 -11
- package/lib/verifier/termAsConstructor.js +4 -4
- package/lib/verifier/topLevel.js +9 -15
- package/package.json +1 -1
- package/src/assertion/contained.js +7 -5
- package/src/assertion/defined.js +2 -2
- package/src/assertion/subproof.js +61 -42
- package/src/assertion/type.js +2 -2
- package/src/assignment/variable.js +2 -1
- package/src/axiom.js +6 -8
- package/src/combinator/bracketed.js +6 -3
- package/src/combinator.js +4 -4
- package/src/conclusion.js +2 -2
- package/src/conjecture.js +8 -11
- package/src/consequent.js +2 -2
- package/src/constructor/bracketed.js +6 -3
- package/src/constructor.js +4 -4
- package/src/context/file.js +46 -84
- package/src/context/local.js +15 -17
- package/src/declaration/combinator.js +5 -4
- package/src/declaration/constructor.js +5 -4
- package/src/declaration/metavariable.js +3 -4
- package/src/declaration/type.js +2 -2
- package/src/declaration/variable.js +5 -4
- package/src/declaration.js +12 -9
- package/src/derivation.js +7 -1
- package/src/equality.js +7 -1
- package/src/frame.js +10 -9
- package/src/index.js +12 -0
- package/src/judgement.js +11 -5
- package/src/label.js +5 -5
- package/src/lemma.js +8 -11
- package/src/metaLemma.js +13 -11
- package/src/metatheorem.js +6 -10
- package/src/metavariable.js +23 -42
- package/src/mixins/statement/qualified/unify.js +1 -2
- package/src/mixins/statement/unify.js +2 -2
- package/src/mixins/statement/verify.js +35 -88
- package/src/mixins/term/verify.js +3 -2
- package/src/premise.js +41 -33
- package/src/proof.js +10 -3
- package/src/proofStep.js +91 -32
- package/src/reference.js +3 -2
- package/src/rule.js +17 -24
- package/src/statement/qualified.js +9 -5
- package/src/statement.js +3 -3
- package/src/subDerivation.js +8 -2
- package/src/subproof.js +12 -5
- package/src/substitution/statementForMetavariable.js +45 -30
- package/src/substitution.js +9 -9
- package/src/substitutions.js +75 -45
- package/src/supposition.js +50 -35
- package/src/term.js +3 -3
- package/src/theorem.js +8 -11
- package/src/topLevelAssertion.js +16 -7
- package/src/type.js +3 -3
- package/src/unifier/equality.js +1 -1
- package/src/unifier/metaLevel.js +8 -10
- package/src/unifier/metavariable.js +5 -5
- package/src/unifier/statementWithCombinator.js +5 -5
- package/src/utilities/brackets.js +2 -2
- package/src/utilities/node.js +1 -10
- package/src/utilities/nominal.js +14 -0
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/tokens.js +2 -9
- package/src/variable.js +4 -4
- package/src/verifier/statementAsCombinator.js +4 -18
- package/src/verifier/termAsConstructor.js +4 -4
- package/src/verifier/topLevel.js +15 -14
- package/lib/assignment/metavariable.js +0 -62
- package/lib/unifier/intrinsicLevel.js +0 -144
- package/lib/utilities/unify.js +0 -24
- package/lib/verifier/intrinsicLevel.js +0 -140
- package/lib/verifier/metaLevel.js +0 -147
- package/src/assignment/metavariable.js +0 -30
- package/src/unifier/intrinsicLevel.js +0 -54
- package/src/utilities/unify.js +0 -23
- package/src/verifier/intrinsicLevel.js +0 -42
- package/src/verifier/metaLevel.js +0 -54
package/src/metavariable.js
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
|
-
import metavariableUnifier from "./unifier/metavariable";
|
|
6
5
|
import FrameForMetavariableSubstitution from "./substitution/frameForMetavariable";
|
|
7
6
|
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
8
7
|
|
|
9
8
|
import { nodeQuery } from "./utilities/query";
|
|
9
|
+
import { EMPTY_STRING } from "./constants";
|
|
10
10
|
import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
11
11
|
import { metaTypeFromJSON, metaTypeToMetaTypeJSON } from "./utilities/json";
|
|
12
12
|
import { typeNameFromTypeNode, metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
@@ -80,11 +80,11 @@ class Metavariable {
|
|
|
80
80
|
|
|
81
81
|
localContext.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
82
82
|
|
|
83
|
-
const
|
|
84
|
-
simpleSubstitutionPresent = substitutions.
|
|
83
|
+
const metavariableNode = this.node, ///
|
|
84
|
+
simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableNode(metavariableNode);
|
|
85
85
|
|
|
86
86
|
if (simpleSubstitutionPresent) {
|
|
87
|
-
const simpleSubstitution = substitutions.
|
|
87
|
+
const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
88
88
|
substitution = simpleSubstitution, ///
|
|
89
89
|
frameNodeMatches = substitution.matchFrameNode(frameNode);
|
|
90
90
|
|
|
@@ -123,22 +123,19 @@ class Metavariable {
|
|
|
123
123
|
metavariableString = this.string, ///
|
|
124
124
|
substitutionString = (substitution !== null) ?
|
|
125
125
|
substitution.getString() :
|
|
126
|
-
|
|
126
|
+
EMPTY_STRING;
|
|
127
127
|
|
|
128
|
-
(substitutionString
|
|
129
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution...`) :
|
|
130
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
128
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
|
|
131
129
|
|
|
132
130
|
const statementNode = statement.getNode(),
|
|
133
131
|
metavariableNode = this.node, ///
|
|
134
|
-
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
135
132
|
substitutionNode = (substitution !== null) ?
|
|
136
133
|
substitution.getSubstitutionNode() :
|
|
137
134
|
null,
|
|
138
|
-
substitutionPresent = substitutions.
|
|
135
|
+
substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
139
136
|
|
|
140
137
|
if (substitutionPresent) {
|
|
141
|
-
const substitution = substitutions.
|
|
138
|
+
const substitution = substitutions.findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
|
|
142
139
|
statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
143
140
|
|
|
144
141
|
if (statementNodeMatches) {
|
|
@@ -149,7 +146,7 @@ class Metavariable {
|
|
|
149
146
|
metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
|
|
150
147
|
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
151
148
|
|
|
152
|
-
if (metavariable === statementMetavariable) {
|
|
149
|
+
if ((metavariable !== null) && (metavariable === statementMetavariable)) {
|
|
153
150
|
statementUnified = true;
|
|
154
151
|
} else {
|
|
155
152
|
const metavariable = this, ///
|
|
@@ -164,9 +161,7 @@ class Metavariable {
|
|
|
164
161
|
}
|
|
165
162
|
|
|
166
163
|
if (statementUnified) {
|
|
167
|
-
(substitutionString
|
|
168
|
-
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution.`) :
|
|
169
|
-
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
164
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
|
|
170
165
|
}
|
|
171
166
|
|
|
172
167
|
return statementUnified;
|
|
@@ -180,8 +175,8 @@ class Metavariable {
|
|
|
180
175
|
|
|
181
176
|
localContext.trace(`Unifying the '${substitutionString}' substitution with the '${metavariableString}' metavariable...`);
|
|
182
177
|
|
|
183
|
-
const
|
|
184
|
-
judgement = localContext.
|
|
178
|
+
const metavariableNode = this.node, ///
|
|
179
|
+
judgement = localContext.findJudgementByMetavariableNode(metavariableNode);
|
|
185
180
|
|
|
186
181
|
if (judgement !== null){
|
|
187
182
|
const declaration = judgement.getDeclaration();
|
|
@@ -203,18 +198,10 @@ class Metavariable {
|
|
|
203
198
|
|
|
204
199
|
localContext.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
205
200
|
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
if (metavariable !== null) {
|
|
210
|
-
const metavariableA = metavariable, ///
|
|
211
|
-
metavariableB = this,
|
|
212
|
-
metavariableNodeA = metavariableA.getNode(), ///
|
|
213
|
-
metavariableNodeB = metavariableB.getNode(),
|
|
214
|
-
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
201
|
+
const metavariableNode = this.node,
|
|
202
|
+
metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode, localContext);
|
|
215
203
|
|
|
216
|
-
|
|
217
|
-
}
|
|
204
|
+
verified = metavariablePresent; ///
|
|
218
205
|
|
|
219
206
|
if (verified) {
|
|
220
207
|
localContext.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
@@ -223,12 +210,12 @@ class Metavariable {
|
|
|
223
210
|
return verified;
|
|
224
211
|
}
|
|
225
212
|
|
|
226
|
-
|
|
213
|
+
verifyWhenDeclared(fileContext) {
|
|
227
214
|
let verifiedAtTopLevel = false;
|
|
228
215
|
|
|
229
216
|
const metavariableString = this.string; ///
|
|
230
217
|
|
|
231
|
-
fileContext.trace(`Verifying the '${metavariableString}' metavariable
|
|
218
|
+
fileContext.trace(`Verifying the '${metavariableString}' metavariable when declared...`);
|
|
232
219
|
|
|
233
220
|
const metavariableNode = this.node, ///
|
|
234
221
|
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
@@ -262,7 +249,7 @@ class Metavariable {
|
|
|
262
249
|
}
|
|
263
250
|
|
|
264
251
|
if (verifiedAtTopLevel) {
|
|
265
|
-
fileContext.debug(`...verified the '${metavariableString}' metavariable
|
|
252
|
+
fileContext.debug(`...verified the '${metavariableString}' metavariable when declared.`);
|
|
266
253
|
}
|
|
267
254
|
|
|
268
255
|
return verifiedAtTopLevel;
|
|
@@ -276,9 +263,8 @@ class Metavariable {
|
|
|
276
263
|
|
|
277
264
|
localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
|
|
278
265
|
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
266
|
+
const metavariableNode = this.node, ///
|
|
267
|
+
metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode, localContext);
|
|
282
268
|
|
|
283
269
|
if (metavariable !== null) {
|
|
284
270
|
const metaTypeMatches = metavariable.matchMetaType(metaType);
|
|
@@ -360,8 +346,7 @@ Object.assign(shim, {
|
|
|
360
346
|
export default Metavariable;
|
|
361
347
|
|
|
362
348
|
function metavariableFromMetavariableNode(metavariableNode, localContext) {
|
|
363
|
-
const
|
|
364
|
-
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
349
|
+
const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode, localContext);
|
|
365
350
|
|
|
366
351
|
return metavariable;
|
|
367
352
|
}
|
|
@@ -372,9 +357,7 @@ function frameMetavariableFromStatementNode(frameNode, localContext) {
|
|
|
372
357
|
const frameMetavariableNode = frameMetavariableNodeQuery(frameNode);
|
|
373
358
|
|
|
374
359
|
if (frameMetavariableNode !== null) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
frameMetavariable = localContext.findMetavariableByMetavariableName(frameMetavariableName);
|
|
360
|
+
frameMetavariable = localContext.findMetavariableByMetavariableNode(frameMetavariableNode, localContext);
|
|
378
361
|
}
|
|
379
362
|
|
|
380
363
|
return frameMetavariable;
|
|
@@ -386,9 +369,7 @@ function statementMetavariableFromStatementNode(statementNode, localContext) {
|
|
|
386
369
|
const statementMetavariableNode = statementMetavariableNodeQuery(statementNode);
|
|
387
370
|
|
|
388
371
|
if (statementMetavariableNode !== null) {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
statementMetavariable = localContext.findMetavariableByMetavariableName(statementMetavariableName);
|
|
372
|
+
statementMetavariable = localContext.findMetavariableByMetavariableNode(statementMetavariableNode, localContext);
|
|
392
373
|
}
|
|
393
374
|
|
|
394
375
|
return statementMetavariable;
|
|
@@ -135,8 +135,7 @@ function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
|
|
|
135
135
|
|
|
136
136
|
const reference = qualifiedStatement.getReference(),
|
|
137
137
|
metavariableNode = reference.getMetavariableNode(),
|
|
138
|
-
|
|
139
|
-
metavariablePresent = localContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
138
|
+
metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode, localContext);
|
|
140
139
|
|
|
141
140
|
if (metavariablePresent) {
|
|
142
141
|
const statement = qualifiedStatement.getStatement(),
|
|
@@ -28,10 +28,10 @@ function unifyWithCombinators(statement, assignments, stated, localContext) {
|
|
|
28
28
|
|
|
29
29
|
const combinators = localContext.getCombinators();
|
|
30
30
|
|
|
31
|
-
assignments = null; ///
|
|
32
|
-
|
|
33
31
|
stated = true; ///
|
|
34
32
|
|
|
33
|
+
assignments = null; ///
|
|
34
|
+
|
|
35
35
|
unifiedWithCombinators = combinators.some((combinator) => {
|
|
36
36
|
const unifiedWithCombinator = unifyStatementWithCombinator(statement, combinator, assignments, stated, localContext);
|
|
37
37
|
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import Equality from "../../equality";
|
|
5
|
-
import Judgement from "../../judgement";
|
|
6
|
-
import Declaration from "../../declaration";
|
|
7
|
-
import Metavariable from "../../metavariable";
|
|
3
|
+
import shim from "../../shim";
|
|
8
4
|
import TypeAssertion from "../../assertion/type";
|
|
9
5
|
import DefinedAssertion from "../../assertion/defined";
|
|
10
6
|
import SubproofAssertion from "../../assertion/subproof";
|
|
@@ -12,20 +8,19 @@ import ContainedAssertion from "../../assertion/contained";
|
|
|
12
8
|
|
|
13
9
|
import { nodeQuery } from "../../utilities/query";
|
|
14
10
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
judgementNodeQuery = nodeQuery("/statement/judgement!"),
|
|
18
|
-
declarationNodeQuery = nodeQuery("/statement/declaration!"),
|
|
11
|
+
const equalityNodeQuery = nodeQuery("/statement/equality"),
|
|
12
|
+
judgementNodeQuery = nodeQuery("/statement/judgement"),
|
|
19
13
|
metavariableNodeQuery = nodeQuery("/statement/metavariable!"),
|
|
20
|
-
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion
|
|
21
|
-
definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion
|
|
22
|
-
subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion
|
|
23
|
-
containedAssertionNodeQuery = nodeQuery("/statement/containedAssertion
|
|
14
|
+
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion"),
|
|
15
|
+
definedAssertionNodeQuery = nodeQuery("/statement/definedAssertion"),
|
|
16
|
+
subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion"),
|
|
17
|
+
containedAssertionNodeQuery = nodeQuery("/statement/containedAssertion");
|
|
24
18
|
|
|
25
19
|
function verifyAsMetavariable(statement, assignments, stated, localContext) {
|
|
26
20
|
let verifiedAsMetavariable = false;
|
|
27
21
|
|
|
28
|
-
const
|
|
22
|
+
const { Metavariable } = shim,
|
|
23
|
+
statementNode = statement.getNode(),
|
|
29
24
|
metavariableNode = metavariableNodeQuery(statementNode),
|
|
30
25
|
metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext);
|
|
31
26
|
|
|
@@ -49,7 +44,8 @@ function verifyAsMetavariable(statement, assignments, stated, localContext) {
|
|
|
49
44
|
function verifyAsEquality(statement, assignments, stated, localContext) {
|
|
50
45
|
let verifiedAsEquality = false;
|
|
51
46
|
|
|
52
|
-
const
|
|
47
|
+
const { Equality } = shim,
|
|
48
|
+
statementNode = statement.getNode(),
|
|
53
49
|
equalityNode = equalityNodeQuery(statementNode),
|
|
54
50
|
equality = Equality.fromEqualityNode(equalityNode, localContext);
|
|
55
51
|
|
|
@@ -70,34 +66,11 @@ function verifyAsEquality(statement, assignments, stated, localContext) {
|
|
|
70
66
|
return verifiedAsEquality;
|
|
71
67
|
}
|
|
72
68
|
|
|
73
|
-
function verifyAsFrame(statement, assignments, stated, localContext) {
|
|
74
|
-
let verifiedAsFrame = false;
|
|
75
|
-
|
|
76
|
-
const statementNode = statement.getNode(),
|
|
77
|
-
frameNode = frameNodeQuery(statementNode),
|
|
78
|
-
frame = Frame.fromFrameNode(frameNode, localContext);
|
|
79
|
-
|
|
80
|
-
if (frame !== null) {
|
|
81
|
-
const statementString = statement.getString();
|
|
82
|
-
|
|
83
|
-
localContext.trace(`Verifying the '${statementString}' statement as a frame...`);
|
|
84
|
-
|
|
85
|
-
const frameVerified = frame.verify(assignments, stated, localContext);
|
|
86
|
-
|
|
87
|
-
verifiedAsFrame = frameVerified; ///
|
|
88
|
-
|
|
89
|
-
if (verifiedAsFrame) {
|
|
90
|
-
localContext.debug(`...verified the '${statementString}' statement as a frame.`);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return verifiedAsFrame;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
69
|
function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
98
70
|
let verifiedAsJudgement = false;
|
|
99
71
|
|
|
100
|
-
const
|
|
72
|
+
const { Judgement } = shim,
|
|
73
|
+
statementNode = statement.getNode(),
|
|
101
74
|
judgementNode = judgementNodeQuery(statementNode),
|
|
102
75
|
judgement = Judgement.fromJudgementNode(judgementNode, localContext);
|
|
103
76
|
|
|
@@ -118,30 +91,6 @@ function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
|
118
91
|
return verifiedAsJudgement;
|
|
119
92
|
}
|
|
120
93
|
|
|
121
|
-
function verifyAsDeclaration(statement, assignments, stated, localContext) {
|
|
122
|
-
let verifiedAsDeclaration = false;
|
|
123
|
-
|
|
124
|
-
const statementNode = statement.getNode(),
|
|
125
|
-
declarationNode = declarationNodeQuery(statementNode),
|
|
126
|
-
declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
127
|
-
|
|
128
|
-
if (declaration !== null) {
|
|
129
|
-
const statementString = statement.getString();
|
|
130
|
-
|
|
131
|
-
localContext.trace(`Verifying the '${statementString}' statement as a declaration...`);
|
|
132
|
-
|
|
133
|
-
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
134
|
-
|
|
135
|
-
verifiedAsDeclaration = declarationVerified; ///
|
|
136
|
-
|
|
137
|
-
if (verifiedAsDeclaration) {
|
|
138
|
-
localContext.debug(`...verified the '${statementString}' statement as a declaration.`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return verifiedAsDeclaration;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
94
|
function verifyAsTypeAssertion(statement, assignments, stated, localContext) {
|
|
146
95
|
let verifiedAsTypeAssertion = false;
|
|
147
96
|
|
|
@@ -190,60 +139,58 @@ function verifyAsDefinedAssertion(statement, assignments, stated, localContext)
|
|
|
190
139
|
return verifiedAsDefinedAssertion;
|
|
191
140
|
}
|
|
192
141
|
|
|
193
|
-
function
|
|
194
|
-
let
|
|
142
|
+
function verifyAsContainedAssertion(statement, assignments, stated, localContext) {
|
|
143
|
+
let verifiedAsContainedAssertion = false;
|
|
195
144
|
|
|
196
145
|
const statementNode = statement.getNode(),
|
|
197
|
-
|
|
198
|
-
|
|
146
|
+
containedAssertionNode = containedAssertionNodeQuery(statementNode),
|
|
147
|
+
containedAssertion = ContainedAssertion.fromContainedAssertionNode(containedAssertionNode, localContext);
|
|
199
148
|
|
|
200
|
-
if (
|
|
149
|
+
if (containedAssertion !== null) {
|
|
201
150
|
const statementString = statement.getString();
|
|
202
151
|
|
|
203
|
-
localContext.trace(`Verifying the '${statementString}' statement as a
|
|
152
|
+
localContext.trace(`Verifying the '${statementString}' statement as a contained assertion...`);
|
|
204
153
|
|
|
205
|
-
const
|
|
154
|
+
const containedAssertionVerified = containedAssertion.verify(assignments, stated, localContext);
|
|
206
155
|
|
|
207
|
-
|
|
156
|
+
verifiedAsContainedAssertion = containedAssertionVerified; ///
|
|
208
157
|
|
|
209
|
-
if (
|
|
210
|
-
localContext.debug(`...verified the '${statementString}' statement as a
|
|
158
|
+
if (verifiedAsContainedAssertion) {
|
|
159
|
+
localContext.debug(`...verified the '${statementString}' statement as a contained assertion.`);
|
|
211
160
|
}
|
|
212
161
|
}
|
|
213
162
|
|
|
214
|
-
return
|
|
163
|
+
return verifiedAsContainedAssertion;
|
|
215
164
|
}
|
|
216
165
|
|
|
217
|
-
function
|
|
218
|
-
let
|
|
166
|
+
function verifyAsSubproofAssertion(statement, assignments, stated, localContext) {
|
|
167
|
+
let verifiedAsSubproofAssertion = false;
|
|
219
168
|
|
|
220
169
|
const statementNode = statement.getNode(),
|
|
221
|
-
|
|
222
|
-
|
|
170
|
+
subproofAssertionNode = subproofAssertionNodeQuery(statementNode),
|
|
171
|
+
subproofAssertion = SubproofAssertion.fromSubproofAssertionNode(subproofAssertionNode, localContext);
|
|
223
172
|
|
|
224
|
-
if (
|
|
173
|
+
if (subproofAssertionNode !== null) {
|
|
225
174
|
const statementString = statement.getString();
|
|
226
175
|
|
|
227
|
-
localContext.trace(`Verifying the '${statementString}' statement as a
|
|
176
|
+
localContext.trace(`Verifying the '${statementString}' statement as a subproof assertion...`);
|
|
228
177
|
|
|
229
|
-
const
|
|
178
|
+
const subproofAssertionVerified = subproofAssertion.verify(assignments, stated, localContext);
|
|
230
179
|
|
|
231
|
-
|
|
180
|
+
verifiedAsSubproofAssertion = subproofAssertionVerified; ///
|
|
232
181
|
|
|
233
|
-
if (
|
|
234
|
-
localContext.debug(`...verified the '${statementString}' statement as a
|
|
182
|
+
if (verifiedAsSubproofAssertion) {
|
|
183
|
+
localContext.debug(`...verified the '${statementString}' statement as a subproof assertion.`);
|
|
235
184
|
}
|
|
236
185
|
}
|
|
237
186
|
|
|
238
|
-
return
|
|
187
|
+
return verifiedAsSubproofAssertion;
|
|
239
188
|
}
|
|
240
189
|
|
|
241
190
|
const verifyMixins = [
|
|
242
191
|
verifyAsMetavariable,
|
|
243
192
|
verifyAsEquality,
|
|
244
|
-
verifyAsFrame,
|
|
245
193
|
verifyAsJudgement,
|
|
246
|
-
verifyAsDeclaration,
|
|
247
194
|
verifyAsTypeAssertion,
|
|
248
195
|
verifyAsDefinedAssertion,
|
|
249
196
|
verifyAsSubproofAssertion,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "../../shim";
|
|
4
4
|
|
|
5
5
|
import { nodeQuery } from "../../utilities/query";
|
|
6
6
|
|
|
@@ -9,7 +9,8 @@ const variableNodeQuery = nodeQuery("/term/variable!");
|
|
|
9
9
|
function verifyTermAsVariable(term, localContext, verifyAhead) {
|
|
10
10
|
let termVerifiedAsVariable = false;
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const { Variable } = shim,
|
|
13
|
+
termNode = term.getNode(),
|
|
13
14
|
variableNode = variableNodeQuery(termNode),
|
|
14
15
|
variable = Variable.fromVariableNode(variableNode, localContext);
|
|
15
16
|
|
package/src/premise.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
5
|
import SubproofAssertion from "./assertion/subproof";
|
|
6
|
-
import UnqualifiedStatement from "./statement/unqualified";
|
|
7
6
|
|
|
8
7
|
import { nodeQuery } from "./utilities/query";
|
|
9
8
|
import { assignAssignments } from "./utilities/assignments";
|
|
@@ -29,37 +28,6 @@ class Premise {
|
|
|
29
28
|
|
|
30
29
|
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
31
30
|
|
|
32
|
-
unifySubproof(subproof, substitutions, localContext) {
|
|
33
|
-
let subproofUnified = false;
|
|
34
|
-
|
|
35
|
-
const premise = this, ///
|
|
36
|
-
subproofString = subproof.getString(),
|
|
37
|
-
premiseStatement = premise.getStatement(),
|
|
38
|
-
premiseStatementString = premiseStatement.getString();
|
|
39
|
-
|
|
40
|
-
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
41
|
-
|
|
42
|
-
const statement = this.unqualifiedStatement.getStatement(),
|
|
43
|
-
statementNode = statement.getNode(),
|
|
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);
|
|
51
|
-
|
|
52
|
-
if (subproofAssertion !== null) {
|
|
53
|
-
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (subproofUnified) {
|
|
57
|
-
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return subproofUnified;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
31
|
unifyProofStep(proofStep, substitutions, localContext) {
|
|
64
32
|
let proofStepUnified = false;
|
|
65
33
|
|
|
@@ -80,6 +48,14 @@ class Premise {
|
|
|
80
48
|
}
|
|
81
49
|
|
|
82
50
|
if (subproofUnified || statementUnified) {
|
|
51
|
+
const localContextB = localContext; ///
|
|
52
|
+
|
|
53
|
+
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
54
|
+
|
|
55
|
+
const localContextA = localContext; ///
|
|
56
|
+
|
|
57
|
+
substitutions.resolve(localContextA, localContextB);
|
|
58
|
+
|
|
83
59
|
proofStepUnified = true;
|
|
84
60
|
}
|
|
85
61
|
|
|
@@ -113,6 +89,37 @@ class Premise {
|
|
|
113
89
|
return statementUnified;
|
|
114
90
|
}
|
|
115
91
|
|
|
92
|
+
unifySubproof(subproof, substitutions, localContext) {
|
|
93
|
+
let subproofUnified = false;
|
|
94
|
+
|
|
95
|
+
const premise = this, ///
|
|
96
|
+
subproofString = subproof.getString(),
|
|
97
|
+
premiseStatement = premise.getStatement(),
|
|
98
|
+
premiseStatementString = premiseStatement.getString();
|
|
99
|
+
|
|
100
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
101
|
+
|
|
102
|
+
const statement = this.unqualifiedStatement.getStatement(),
|
|
103
|
+
statementNode = statement.getNode(),
|
|
104
|
+
statementTokens = statement.getTokens(),
|
|
105
|
+
context = this.fileContext, ///
|
|
106
|
+
tokens = statementTokens; ///
|
|
107
|
+
|
|
108
|
+
localContext = LocalContext.fromContextAndTokens(context, tokens); ///
|
|
109
|
+
|
|
110
|
+
const subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, localContext);
|
|
111
|
+
|
|
112
|
+
if (subproofAssertion !== null) {
|
|
113
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (subproofUnified) {
|
|
117
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return subproofUnified;
|
|
121
|
+
}
|
|
122
|
+
|
|
116
123
|
verify(localContext) {
|
|
117
124
|
let verified = false;
|
|
118
125
|
|
|
@@ -162,7 +169,8 @@ class Premise {
|
|
|
162
169
|
}
|
|
163
170
|
|
|
164
171
|
static fromPremiseNode(suppositionNode, fileContext) {
|
|
165
|
-
const
|
|
172
|
+
const { UnqualifiedStatement } = shim,
|
|
173
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
166
174
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
167
175
|
premise = new Premise(fileContext, unqualifiedStatement);
|
|
168
176
|
|
package/src/proof.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
4
|
import LocalContext from "./context/local";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "./utilities/query";
|
|
7
7
|
|
|
8
8
|
const derivationNodeQuery = nodeQuery("/proof/derivation");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
class Proof {
|
|
11
11
|
constructor(derivation) {
|
|
12
12
|
this.derivation = derivation;
|
|
13
13
|
}
|
|
@@ -47,7 +47,8 @@ export default class Proof {
|
|
|
47
47
|
let proof = null;
|
|
48
48
|
|
|
49
49
|
if (proofNode !== null) {
|
|
50
|
-
const
|
|
50
|
+
const { Derivation } = shim,
|
|
51
|
+
derivationNode = derivationNodeQuery(proofNode),
|
|
51
52
|
derivation = Derivation.fromDerivationNode(derivationNode, fileContext);
|
|
52
53
|
|
|
53
54
|
proof = new Proof(derivation);
|
|
@@ -56,3 +57,9 @@ export default class Proof {
|
|
|
56
57
|
return proof;
|
|
57
58
|
}
|
|
58
59
|
}
|
|
60
|
+
|
|
61
|
+
Object.assign(shim, {
|
|
62
|
+
Proof
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export default Proof;
|