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/substitutions.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
|
|
3
5
|
import { arrayUtilities } from "necessary";
|
|
4
6
|
|
|
5
7
|
import { EMPTY_STRING } from "./constants";
|
|
6
8
|
|
|
7
9
|
const { find, first, prune, filter, compress } = arrayUtilities;
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
class Substitutions {
|
|
10
12
|
constructor(array, savedArray) {
|
|
11
13
|
this.array = array;
|
|
12
14
|
this.savedArray = savedArray;
|
|
@@ -34,24 +36,26 @@ export default class Substitutions {
|
|
|
34
36
|
return firstSubstitution;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
+
getMetavariableNodes() {
|
|
40
|
+
const metavariableNodes = [];
|
|
39
41
|
|
|
40
42
|
this.forEachSubstitution((substitution) => {
|
|
41
|
-
const
|
|
43
|
+
const metavariableNode = substitution.getMetavariableNode();
|
|
42
44
|
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
+
if (metavariableNode !== null) {
|
|
46
|
+
metavariableNodes.push(metavariableNode);
|
|
45
47
|
}
|
|
46
48
|
});
|
|
47
49
|
|
|
48
|
-
compress(
|
|
49
|
-
|
|
50
|
+
compress(metavariableNodes, (metavariableNodeA, metavariableNodeB) => {
|
|
51
|
+
const metavariableNodeAMatchesMetavariableNodeB = metavariableNodeB.match(metavariableNodeA);
|
|
52
|
+
|
|
53
|
+
if (metavariableNodeAMatchesMetavariableNodeB) {
|
|
50
54
|
return true;
|
|
51
55
|
}
|
|
52
56
|
});
|
|
53
57
|
|
|
54
|
-
return
|
|
58
|
+
return metavariableNodes;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
mapSubstitution(callback) { return this.array.map(callback); }
|
|
@@ -102,11 +106,11 @@ export default class Substitutions {
|
|
|
102
106
|
return substitution;
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
|
|
109
|
+
findSubstitutionByMetavariableNode(metavariableNode) {
|
|
106
110
|
const substitution = this.findSubstitution((substitution) => {
|
|
107
|
-
const
|
|
111
|
+
const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
|
|
108
112
|
|
|
109
|
-
if (
|
|
113
|
+
if (metavariableNodeMatches) {
|
|
110
114
|
return true;
|
|
111
115
|
}
|
|
112
116
|
});
|
|
@@ -114,11 +118,11 @@ export default class Substitutions {
|
|
|
114
118
|
return substitution;
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
findSubstitutionsByMetavariableNode(metavariableNode) {
|
|
118
122
|
const substitutions = this.findSubstitutions((substitution) => {
|
|
119
|
-
const
|
|
123
|
+
const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
|
|
120
124
|
|
|
121
|
-
if (
|
|
125
|
+
if (metavariableNodeMatches) {
|
|
122
126
|
return true;
|
|
123
127
|
}
|
|
124
128
|
});
|
|
@@ -126,8 +130,8 @@ export default class Substitutions {
|
|
|
126
130
|
return substitutions;
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
const substitutions = this.
|
|
133
|
+
findSimpleSubstitutionByMetavariableNode(metavariableNode) {
|
|
134
|
+
const substitutions = this.findSubstitutionsByMetavariableNode(metavariableNode),
|
|
131
135
|
simpleSubstitutions = substitutions.filterSubstitution((substitution) => {
|
|
132
136
|
const substitutionSimple = substitution.isSimple();
|
|
133
137
|
|
|
@@ -141,8 +145,8 @@ export default class Substitutions {
|
|
|
141
145
|
return simpleSubstitution;
|
|
142
146
|
}
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
const substitutions = this.
|
|
148
|
+
findComplexSubstitutionsByMetavariableNode(metavariableNode) {
|
|
149
|
+
const substitutions = this.findSubstitutionsByMetavariableNode(metavariableNode),
|
|
146
150
|
complexSubstitutions = substitutions.filterSubstitution((substitution) => {
|
|
147
151
|
const substitutionComplex = substitution.isComplex();
|
|
148
152
|
|
|
@@ -154,11 +158,11 @@ export default class Substitutions {
|
|
|
154
158
|
return complexSubstitutions;
|
|
155
159
|
}
|
|
156
160
|
|
|
157
|
-
|
|
161
|
+
findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
158
162
|
const substitutions = this.findSubstitutions((substitution) => {
|
|
159
|
-
const
|
|
163
|
+
const metavariableNodeAndSubstitutionNodeMatch = substitution.matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
160
164
|
|
|
161
|
-
if (
|
|
165
|
+
if (metavariableNodeAndSubstitutionNodeMatch) {
|
|
162
166
|
return true;
|
|
163
167
|
}
|
|
164
168
|
}),
|
|
@@ -168,15 +172,15 @@ export default class Substitutions {
|
|
|
168
172
|
return substitution;
|
|
169
173
|
}
|
|
170
174
|
|
|
171
|
-
|
|
172
|
-
const simpleSubstitution = this.
|
|
175
|
+
isSimpleSubstitutionPresentByMetavariableNode(metavariableNode) {
|
|
176
|
+
const simpleSubstitution = this.findSimpleSubstitutionByMetavariableNode(metavariableNode),
|
|
173
177
|
simpleSubstitutionPresent = (simpleSubstitution !== null);
|
|
174
178
|
|
|
175
179
|
return simpleSubstitutionPresent;
|
|
176
180
|
}
|
|
177
181
|
|
|
178
|
-
|
|
179
|
-
const substitution = this.
|
|
182
|
+
isSubstitutionPresentByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
|
|
183
|
+
const substitution = this.findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
|
|
180
184
|
substitutionPresent = (substitution !== null);
|
|
181
185
|
|
|
182
186
|
return substitutionPresent;
|
|
@@ -220,24 +224,46 @@ export default class Substitutions {
|
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
resolve(localContextA, localContextB) {
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
227
|
+
const metavariableNodes = this.getMetavariableNodes();
|
|
228
|
+
|
|
229
|
+
metavariableNodes.forEach((metavariableNode) => {
|
|
230
|
+
const complexSubstitutions = this.findComplexSubstitutionsByMetavariableNode(metavariableNode),
|
|
231
|
+
complexSubstitutionsResolved = complexSubstitutions.everySubstitution((complexSubstitution) => {
|
|
232
|
+
let resolved;
|
|
233
|
+
|
|
234
|
+
const substitutions = this,
|
|
235
|
+
substitution = complexSubstitution; ///
|
|
236
|
+
|
|
237
|
+
resolved = substitution.isResolved();
|
|
238
|
+
|
|
239
|
+
if (!resolved) {
|
|
240
|
+
substitution.resolve(substitutions, localContextA, localContextB);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
if (complexSubstitutionsResolved) {
|
|
245
|
+
return true;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
areResolved() {
|
|
251
|
+
const metavariableNodes = this.getMetavariableNodes(),
|
|
252
|
+
resolved = metavariableNodes.every((metavariableNode) => {
|
|
253
|
+
const complexSubstitutions = this.findComplexSubstitutionsByMetavariableNode(metavariableNode),
|
|
254
|
+
complexSubstitutionsResolved = complexSubstitutions.everySubstitution((complexSubstitution) => {
|
|
255
|
+
const complexSubstitutionResolved = complexSubstitution.isResolved();
|
|
256
|
+
|
|
257
|
+
if (complexSubstitutionResolved) {
|
|
237
258
|
return true;
|
|
238
259
|
}
|
|
239
260
|
});
|
|
240
261
|
|
|
262
|
+
if (complexSubstitutionsResolved) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
|
|
241
267
|
return resolved;
|
|
242
268
|
}
|
|
243
269
|
|
|
@@ -252,7 +278,7 @@ export default class Substitutions {
|
|
|
252
278
|
...this.array
|
|
253
279
|
];
|
|
254
280
|
|
|
255
|
-
|
|
281
|
+
leftDifference(array, this.savedArray);
|
|
256
282
|
|
|
257
283
|
array.forEach((substitution) => {
|
|
258
284
|
this.removeSubstitution(substitution, localContext);
|
|
@@ -303,11 +329,15 @@ export default class Substitutions {
|
|
|
303
329
|
}
|
|
304
330
|
}
|
|
305
331
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
332
|
+
Object.assign(shim, {
|
|
333
|
+
Substitutions
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
function leftDifference(arrayA, arrayB) {
|
|
337
|
+
filter(arrayA, (elementA) => {
|
|
338
|
+
const arrayBIncludesElementA = arrayB.includes(elementA);
|
|
309
339
|
|
|
310
|
-
if (!
|
|
340
|
+
if (!arrayBIncludesElementA) {
|
|
311
341
|
return true;
|
|
312
342
|
}
|
|
313
343
|
});
|
package/src/supposition.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";
|
|
@@ -60,37 +59,6 @@ class Supposition {
|
|
|
60
59
|
return verified;
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
unifySubproof(subproof, substitutions, localContext) {
|
|
64
|
-
let subproofUnified = false;
|
|
65
|
-
|
|
66
|
-
const supposition = this, ///
|
|
67
|
-
subproofString = subproof.getString(),
|
|
68
|
-
suppositionStatement = supposition.getStatement(),
|
|
69
|
-
suppositionStatementString = suppositionStatement.getString();
|
|
70
|
-
|
|
71
|
-
localContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
|
|
72
|
-
|
|
73
|
-
const statement = this.unqualifiedStatement.getStatement(),
|
|
74
|
-
statementNode = statement.getNode(),
|
|
75
|
-
statementTokens = statement.getTokens(),
|
|
76
|
-
context = this.fileContext, ///
|
|
77
|
-
tokens = statementTokens; ///
|
|
78
|
-
|
|
79
|
-
localContext = LocalContext.fromContextAndTokens(context, tokens); ///
|
|
80
|
-
|
|
81
|
-
const subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, localContext);
|
|
82
|
-
|
|
83
|
-
if (subproofAssertion !== null) {
|
|
84
|
-
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (subproofUnified) {
|
|
88
|
-
localContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return subproofUnified;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
62
|
unifyProofStep(proofStep, substitutions, localContext) {
|
|
95
63
|
let proofStepUnified = false;
|
|
96
64
|
|
|
@@ -99,12 +67,27 @@ class Supposition {
|
|
|
99
67
|
|
|
100
68
|
substitutions.snapshot();
|
|
101
69
|
|
|
70
|
+
let subproofUnified = false,
|
|
71
|
+
statementUnified = false;
|
|
72
|
+
|
|
102
73
|
if (false) {
|
|
103
74
|
///
|
|
104
75
|
} else if (subproof !== null) {
|
|
105
|
-
|
|
76
|
+
subproofUnified = this.unifySubproof(subproof, substitutions, localContext);
|
|
106
77
|
} else if (statement !== null) {
|
|
107
|
-
|
|
78
|
+
statementUnified = this.unifyStatement(statement, substitutions, localContext);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (subproofUnified || statementUnified) {
|
|
82
|
+
const localContextB = localContext; ///
|
|
83
|
+
|
|
84
|
+
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
85
|
+
|
|
86
|
+
const localContextA = localContext; ///
|
|
87
|
+
|
|
88
|
+
substitutions.resolve(localContextA, localContextB);
|
|
89
|
+
|
|
90
|
+
proofStepUnified = true;
|
|
108
91
|
}
|
|
109
92
|
|
|
110
93
|
proofStepUnified ?
|
|
@@ -137,6 +120,37 @@ class Supposition {
|
|
|
137
120
|
return statementUnified;
|
|
138
121
|
}
|
|
139
122
|
|
|
123
|
+
unifySubproof(subproof, substitutions, localContext) {
|
|
124
|
+
let subproofUnified = false;
|
|
125
|
+
|
|
126
|
+
const supposition = this, ///
|
|
127
|
+
subproofString = subproof.getString(),
|
|
128
|
+
suppositionStatement = supposition.getStatement(),
|
|
129
|
+
suppositionStatementString = suppositionStatement.getString();
|
|
130
|
+
|
|
131
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
|
|
132
|
+
|
|
133
|
+
const statement = this.unqualifiedStatement.getStatement(),
|
|
134
|
+
statementNode = statement.getNode(),
|
|
135
|
+
statementTokens = statement.getTokens(),
|
|
136
|
+
context = this.fileContext, ///
|
|
137
|
+
tokens = statementTokens; ///
|
|
138
|
+
|
|
139
|
+
localContext = LocalContext.fromContextAndTokens(context, tokens); ///
|
|
140
|
+
|
|
141
|
+
const subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, localContext);
|
|
142
|
+
|
|
143
|
+
if (subproofAssertion !== null) {
|
|
144
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (subproofUnified) {
|
|
148
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return subproofUnified;
|
|
152
|
+
}
|
|
153
|
+
|
|
140
154
|
toJSON() {
|
|
141
155
|
const unqualifiedStatementJSON = unqualifiedStatementToUnqualifiedStatementJSON(this.unqualifiedStatement),
|
|
142
156
|
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
@@ -155,7 +169,8 @@ class Supposition {
|
|
|
155
169
|
}
|
|
156
170
|
|
|
157
171
|
static fromSuppositionNode(suppositionNode, fileContext) {
|
|
158
|
-
const
|
|
172
|
+
const { UnqualifiedStatement } = shim,
|
|
173
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
159
174
|
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
160
175
|
supposition = new Supposition(fileContext, unqualifiedStatement);
|
|
161
176
|
|
package/src/term.js
CHANGED
|
@@ -213,12 +213,12 @@ class Term {
|
|
|
213
213
|
return verifiedGivenType;
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
verifyWhenDeclared(fileContext) {
|
|
217
217
|
let verifiedAtTopLevel;
|
|
218
218
|
|
|
219
219
|
const termString = this.string; ///
|
|
220
220
|
|
|
221
|
-
fileContext.trace(`Verifying the '${termString}' term
|
|
221
|
+
fileContext.trace(`Verifying the '${termString}' term when declared...`);
|
|
222
222
|
|
|
223
223
|
const termNode = this.node, ///
|
|
224
224
|
termVerifiedAsConstructor = termAsConstructorVerifier.verifyTerm(termNode, fileContext);
|
|
@@ -230,7 +230,7 @@ class Term {
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
if (verifiedAtTopLevel) {
|
|
233
|
-
fileContext.debug(`...verified the '${termString}' term
|
|
233
|
+
fileContext.debug(`...verified the '${termString}' term when declared.`);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
return verifiedAtTopLevel;
|
package/src/theorem.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import Label from "./label";
|
|
5
|
-
import Proof from "./proof";
|
|
6
|
-
import Consequent from "./consequent";
|
|
7
|
-
import Supposition from "./supposition";
|
|
8
4
|
import LocalContext from "./context/local";
|
|
9
|
-
import Substitutions from "./substitutions";
|
|
10
5
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
11
6
|
|
|
12
7
|
import { stringFromLabels } from "./topLevelAssertion";
|
|
@@ -25,15 +20,15 @@ class Theorem extends TopLevelAssertion {
|
|
|
25
20
|
|
|
26
21
|
this.fileContext.trace(`Verifying the '${theoremString}' theorem...`);
|
|
27
22
|
|
|
28
|
-
const
|
|
29
|
-
const
|
|
23
|
+
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
24
|
+
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
30
25
|
|
|
31
|
-
if (
|
|
26
|
+
if (labelVVerifiedWhenDeclared) {
|
|
32
27
|
return true;
|
|
33
28
|
}
|
|
34
29
|
});
|
|
35
30
|
|
|
36
|
-
if (
|
|
31
|
+
if (labelsVerifiedWhenDeclared) {
|
|
37
32
|
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
38
33
|
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
39
34
|
const suppositionVerified = supposition.verify(localContext);
|
|
@@ -47,7 +42,8 @@ class Theorem extends TopLevelAssertion {
|
|
|
47
42
|
const consequentVerified = this.consequent.verify(localContext);
|
|
48
43
|
|
|
49
44
|
if (consequentVerified) {
|
|
50
|
-
const
|
|
45
|
+
const { Substitutions } = shim,
|
|
46
|
+
substitutions = Substitutions.fromNothing(),
|
|
51
47
|
proofVerified = this.proof.verify(substitutions, this.consequent, localContext);
|
|
52
48
|
|
|
53
49
|
if (proofVerified) {
|
|
@@ -71,7 +67,8 @@ class Theorem extends TopLevelAssertion {
|
|
|
71
67
|
static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Theorem, json, fileContext); }
|
|
72
68
|
|
|
73
69
|
static fromTheoremNode(theoremNode, fileContext) {
|
|
74
|
-
const
|
|
70
|
+
const { Label, Proof, Consequent, Supposition } = shim,
|
|
71
|
+
proofNode = proofNodeQuery(theoremNode),
|
|
75
72
|
labelNodes = labelNodesQuery(theoremNode),
|
|
76
73
|
consequentNode = consequentNodeQuery(theoremNode),
|
|
77
74
|
suppositionNodes = suppositionNodesQuery(theoremNode),
|
package/src/topLevelAssertion.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import shim from "./shim";
|
|
6
|
+
import LocalContext from "./context/local";
|
|
6
7
|
|
|
7
8
|
import { EMPTY_STRING } from "./constants";
|
|
8
9
|
import { labelsFromJSON,
|
|
@@ -61,14 +62,22 @@ export default class TopLevelAssertion {
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
unifyStatement(statement, localContext) {
|
|
64
|
-
let statementUnified
|
|
65
|
+
let statementUnified;
|
|
65
66
|
|
|
66
|
-
const
|
|
67
|
-
substitutions = Substitutions.fromNothing()
|
|
68
|
-
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
67
|
+
const { Substitutions } = shim,
|
|
68
|
+
substitutions = Substitutions.fromNothing();
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
statementUnified = this.consequent.unifyStatement(statement, substitutions, localContext);
|
|
71
|
+
|
|
72
|
+
if (statementUnified) {
|
|
73
|
+
const proofSteps = localContext.getProofSteps(),
|
|
74
|
+
proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
|
|
75
|
+
|
|
76
|
+
if (proofStepsUnified) {
|
|
77
|
+
const substitutionsResolved = substitutions.areResolved();
|
|
78
|
+
|
|
79
|
+
statementUnified = substitutionsResolved; ///
|
|
80
|
+
}
|
|
72
81
|
}
|
|
73
82
|
|
|
74
83
|
return statementUnified;
|
package/src/type.js
CHANGED
|
@@ -109,12 +109,12 @@ class Type {
|
|
|
109
109
|
return typeNodeMatches;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
verifyWhenDeclared(fileContext) {
|
|
113
113
|
let verifiedAtTopLevel = false;
|
|
114
114
|
|
|
115
115
|
const typeString = this.string; ///
|
|
116
116
|
|
|
117
|
-
fileContext.trace(`Verifying the '${typeString}' type
|
|
117
|
+
fileContext.trace(`Verifying the '${typeString}' type when declared...`);
|
|
118
118
|
|
|
119
119
|
const typePresent = fileContext.isTypePresentByTypeName(this.name);
|
|
120
120
|
|
|
@@ -136,7 +136,7 @@ class Type {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
if (verifiedAtTopLevel) {
|
|
139
|
-
fileContext.debug(`...verified the '${typeString}' type
|
|
139
|
+
fileContext.debug(`...verified the '${typeString}' type when declared.`);
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
return verifiedAtTopLevel;
|
package/src/unifier/equality.js
CHANGED
|
@@ -5,7 +5,7 @@ import Unifier from "../unifier";
|
|
|
5
5
|
import { nodeQuery } from "../utilities/query";
|
|
6
6
|
import { findEquivalenceByTermNodes } from "../utilities/equivalences";
|
|
7
7
|
|
|
8
|
-
const termNodeQuery = nodeQuery("/term
|
|
8
|
+
const termNodeQuery = nodeQuery("/term");
|
|
9
9
|
|
|
10
10
|
class EqualityUnifier extends Unifier {
|
|
11
11
|
unify(leftTermNode, rightTermNode, localContext) {
|
package/src/unifier/metaLevel.js
CHANGED
|
@@ -6,11 +6,11 @@ import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
|
6
6
|
import FrameForMetavariableSubstitution from "../substitution/frameForMetavariable";
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "../utilities/query";
|
|
9
|
-
import { variableNameFromVariableNode
|
|
9
|
+
import { variableNameFromVariableNode } from "../utilities/name";
|
|
10
10
|
|
|
11
|
-
const termNodeQuery = nodeQuery("/term
|
|
12
|
-
frameNodeQuery = nodeQuery("/frame
|
|
13
|
-
statementNodeQuery = nodeQuery("/statement
|
|
11
|
+
const termNodeQuery = nodeQuery("/term"),
|
|
12
|
+
frameNodeQuery = nodeQuery("/frame"),
|
|
13
|
+
statementNodeQuery = nodeQuery("/statement"),
|
|
14
14
|
termVariableNodeQuery = nodeQuery("/term/variable!"),
|
|
15
15
|
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
16
16
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
@@ -56,8 +56,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
56
56
|
|
|
57
57
|
const { Statement } = shim,
|
|
58
58
|
metavariableNode = statementMetavariableNode, ///
|
|
59
|
-
|
|
60
|
-
metavariable = localContextA.findMetavariableByMetavariableName(metavariableName);
|
|
59
|
+
metavariable = localContextA.findMetavariableByMetavariableNode(metavariableNode, localContextB);
|
|
61
60
|
|
|
62
61
|
localContext = localContextB; ///
|
|
63
62
|
|
|
@@ -67,7 +66,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
67
66
|
|
|
68
67
|
statementUnified = metavariable.unifyStatement(statement, substitution, substitutions, localContext);
|
|
69
68
|
} else {
|
|
70
|
-
statementUnified =
|
|
69
|
+
statementUnified = unifyChildNodes(statementNodeA, statementNodeB, substitutions, localContextA, localContextB);
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
|
|
@@ -81,8 +80,7 @@ class MetaLevelUnifier extends Unifier {
|
|
|
81
80
|
let frameUnified = false;
|
|
82
81
|
|
|
83
82
|
const metavariableNode = frameMetavariableNodeA, ///
|
|
84
|
-
|
|
85
|
-
metavariablePresent = localContextA.isMetavariablePresentByMetavariableName(metavariableName);
|
|
83
|
+
metavariablePresent = localContextA.isMetavariablePresentByMetavariableNode(metavariableNode, localContextB);
|
|
86
84
|
|
|
87
85
|
if (metavariablePresent) {
|
|
88
86
|
const { Frame, Metavariable } = shim,
|
|
@@ -127,7 +125,7 @@ const metaLevelUnifier = new MetaLevelUnifier();
|
|
|
127
125
|
|
|
128
126
|
export default metaLevelUnifier;
|
|
129
127
|
|
|
130
|
-
function
|
|
128
|
+
function unifyChildNodes(statementNodeA, statementNodeB, substitutions, localContextA, localContextB) {
|
|
131
129
|
const nonTerminalNodeA = statementNodeA, ///
|
|
132
130
|
nonTerminalNodeB = statementNodeB, ///
|
|
133
131
|
nonTerminalNodeAChildNodes = nonTerminalNodeA.getChildNodes(),
|
|
@@ -6,8 +6,8 @@ import Unifier from "../unifier";
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
8
8
|
|
|
9
|
-
const typeNodeQuery = nodeQuery("/type
|
|
10
|
-
termNodeQuery = nodeQuery("/term
|
|
9
|
+
const typeNodeQuery = nodeQuery("/type"),
|
|
10
|
+
termNodeQuery = nodeQuery("/term");
|
|
11
11
|
|
|
12
12
|
class MetavariableUnifier extends Unifier {
|
|
13
13
|
unify(metavariableNodeA, metavariableNodeB, localContext) {
|
|
@@ -27,7 +27,7 @@ class MetavariableUnifier extends Unifier {
|
|
|
27
27
|
nodeQueryA: typeNodeQuery,
|
|
28
28
|
nodeQueryB: termNodeQuery,
|
|
29
29
|
unify: (typeNodeA, termNodeB, localContext) => {
|
|
30
|
-
let
|
|
30
|
+
let termUnified = false;
|
|
31
31
|
|
|
32
32
|
const { Term } = shim,
|
|
33
33
|
typeNode = typeNodeA, ///
|
|
@@ -40,11 +40,11 @@ class MetavariableUnifier extends Unifier {
|
|
|
40
40
|
termVerifiedGivenType = term.verifyGivenType(type, localContext);
|
|
41
41
|
|
|
42
42
|
if (termVerifiedGivenType) {
|
|
43
|
-
|
|
43
|
+
termUnified = true;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
return
|
|
47
|
+
return termUnified;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
];
|
|
@@ -6,11 +6,11 @@ import Unifier from "../unifier";
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
8
8
|
|
|
9
|
-
const termNodeQuery = nodeQuery("/term
|
|
10
|
-
typeNodeQuery = nodeQuery("/type
|
|
11
|
-
frameNodeQuery = nodeQuery("/frame
|
|
12
|
-
metaTypeNodeQuery = nodeQuery("/metaType
|
|
13
|
-
statementNodeQuery = nodeQuery("/statement
|
|
9
|
+
const termNodeQuery = nodeQuery("/term"),
|
|
10
|
+
typeNodeQuery = nodeQuery("/type"),
|
|
11
|
+
frameNodeQuery = nodeQuery("/frame"),
|
|
12
|
+
metaTypeNodeQuery = nodeQuery("/metaType"),
|
|
13
|
+
statementNodeQuery = nodeQuery("/statement");
|
|
14
14
|
|
|
15
15
|
class StatementWithCombinatorUnifier extends Unifier {
|
|
16
16
|
unify(combinatorStatementNode, statementNode, assignments, stated, localContext) {
|
|
@@ -5,8 +5,8 @@ import { bracketedTermNode } from "../constructor/bracketed";
|
|
|
5
5
|
import { bracketedStatementNode } from "../combinator/bracketed";
|
|
6
6
|
import { BRACKETED_TERM_DEPTH, BRACKETED_STATEMENT_DEPTH } from "../constants";
|
|
7
7
|
|
|
8
|
-
const bracketedTermChildNodeQuery = nodeQuery("/term/argument/term
|
|
9
|
-
bracketedStatementChildNodeQuery = nodeQuery("/statement/metaArgument/statement
|
|
8
|
+
const bracketedTermChildNodeQuery = nodeQuery("/term/argument/term"),
|
|
9
|
+
bracketedStatementChildNodeQuery = nodeQuery("/statement/metaArgument/statement");
|
|
10
10
|
|
|
11
11
|
export function stripBracketsFromTermNode(termNode) {
|
|
12
12
|
const bracketedTermChildNode = bracketedTermChildNodeFromTermNode(termNode);
|
package/src/utilities/node.js
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { parsersUtilities } from "occam-custom-grammars";
|
|
4
|
-
|
|
5
3
|
import { nodeQuery } from "../utilities/query";
|
|
6
|
-
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
7
4
|
import { VARIABLE_RULE_NAME,
|
|
8
5
|
METAVARIABLE_RULE_NAME,
|
|
9
6
|
UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
10
7
|
CONSTRUCTOR_DECLARATION_RULE_NAME } from "../ruleNames";
|
|
11
8
|
import { variableTokensFromVariableString,
|
|
12
9
|
metavariableTokensFromMetavariableString,
|
|
13
|
-
unqualifiedStatementTokensFromUnqualifiedStatementString,
|
|
14
10
|
constructorDeclarationTokensFromConstructorDeclarationString } from "../utilities/tokens";
|
|
15
11
|
|
|
16
|
-
const { nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
17
|
-
|
|
18
|
-
const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
19
|
-
nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
20
|
-
|
|
21
12
|
const termNodeQuery = nodeQuery("/constructorDeclaration/term"),
|
|
22
13
|
statementNodeQuery = nodeQuery("/unqualifiedStatement/statement"),
|
|
23
14
|
substitutionNodeQuery = nodeQuery("/unqualifiedStatement/statement/substitution");
|
|
@@ -114,7 +105,7 @@ export function constructorDeclarationNodeFromConstructorDeclarationTokens(const
|
|
|
114
105
|
return constructorDeclarationNode;
|
|
115
106
|
}
|
|
116
107
|
|
|
117
|
-
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser
|
|
108
|
+
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser) {
|
|
118
109
|
const ruleMap = parser.getRuleMap(),
|
|
119
110
|
rule = ruleMap[ruleName],
|
|
120
111
|
node = parser.parse(tokens, rule);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { lexersUtilities, parsersUtilities } from "occam-custom-grammars";
|
|
4
|
+
|
|
5
|
+
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
6
|
+
|
|
7
|
+
const { nominalLexerFromCombinedCustomGrammar } = lexersUtilities,
|
|
8
|
+
{ nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
9
|
+
|
|
10
|
+
const combinedCustomGrammar = combinedCustomGrammarFromNothing();
|
|
11
|
+
|
|
12
|
+
export const nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
13
|
+
|
|
14
|
+
export const nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar);
|