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.
Files changed (141) hide show
  1. package/lib/assertion/contained.js +6 -4
  2. package/lib/assertion/defined.js +2 -2
  3. package/lib/assertion/subproof.js +46 -30
  4. package/lib/assertion/type.js +4 -5
  5. package/lib/assignment/variable.js +2 -2
  6. package/lib/axiom.js +9 -12
  7. package/lib/combinator/bracketed.js +3 -2
  8. package/lib/combinator.js +6 -6
  9. package/lib/conclusion.js +2 -3
  10. package/lib/conjecture.js +10 -15
  11. package/lib/consequent.js +2 -3
  12. package/lib/constructor/bracketed.js +3 -2
  13. package/lib/constructor.js +6 -6
  14. package/lib/context/file.js +48 -102
  15. package/lib/context/local.js +21 -20
  16. package/lib/declaration/combinator.js +5 -5
  17. package/lib/declaration/constructor.js +5 -5
  18. package/lib/declaration/metavariable.js +4 -5
  19. package/lib/declaration/type.js +3 -3
  20. package/lib/declaration/variable.js +5 -5
  21. package/lib/declaration.js +10 -9
  22. package/lib/derivation.js +6 -2
  23. package/lib/equality.js +6 -2
  24. package/lib/frame.js +11 -13
  25. package/lib/index.js +13 -1
  26. package/lib/judgement.js +11 -8
  27. package/lib/label.js +6 -7
  28. package/lib/lemma.js +10 -15
  29. package/lib/metaLemma.js +15 -15
  30. package/lib/metatheorem.js +9 -14
  31. package/lib/metavariable.js +22 -27
  32. package/lib/mixins/statement/qualified/unify.js +2 -2
  33. package/lib/mixins/statement/unify.js +2 -2
  34. package/lib/mixins/statement/verify.js +20 -54
  35. package/lib/mixins/term/verify.js +3 -3
  36. package/lib/premise.js +24 -21
  37. package/lib/proof.js +8 -4
  38. package/lib/proofStep.js +62 -28
  39. package/lib/reference.js +3 -3
  40. package/lib/rule.js +17 -24
  41. package/lib/statement/qualified.js +8 -4
  42. package/lib/statement.js +5 -5
  43. package/lib/subDerivation.js +6 -2
  44. package/lib/subproof.js +10 -7
  45. package/lib/substitution/statementForMetavariable.js +36 -27
  46. package/lib/substitution.js +13 -13
  47. package/lib/substitutions.js +73 -49
  48. package/lib/supposition.js +30 -23
  49. package/lib/term.js +5 -5
  50. package/lib/theorem.js +10 -15
  51. package/lib/topLevelAssertion.js +12 -6
  52. package/lib/type.js +5 -5
  53. package/lib/unifier/equality.js +2 -2
  54. package/lib/unifier/metaLevel.js +6 -6
  55. package/lib/unifier/metavariable.js +5 -5
  56. package/lib/unifier/statementWithCombinator.js +2 -2
  57. package/lib/utilities/brackets.js +2 -2
  58. package/lib/utilities/node.js +2 -7
  59. package/lib/utilities/nominal.js +26 -0
  60. package/lib/utilities/subproof.js +2 -2
  61. package/lib/utilities/tokens.js +3 -7
  62. package/lib/variable.js +6 -6
  63. package/lib/verifier/statementAsCombinator.js +4 -11
  64. package/lib/verifier/termAsConstructor.js +4 -4
  65. package/lib/verifier/topLevel.js +9 -15
  66. package/package.json +1 -1
  67. package/src/assertion/contained.js +7 -5
  68. package/src/assertion/defined.js +2 -2
  69. package/src/assertion/subproof.js +61 -42
  70. package/src/assertion/type.js +2 -2
  71. package/src/assignment/variable.js +2 -1
  72. package/src/axiom.js +6 -8
  73. package/src/combinator/bracketed.js +6 -3
  74. package/src/combinator.js +4 -4
  75. package/src/conclusion.js +2 -2
  76. package/src/conjecture.js +8 -11
  77. package/src/consequent.js +2 -2
  78. package/src/constructor/bracketed.js +6 -3
  79. package/src/constructor.js +4 -4
  80. package/src/context/file.js +46 -84
  81. package/src/context/local.js +15 -17
  82. package/src/declaration/combinator.js +5 -4
  83. package/src/declaration/constructor.js +5 -4
  84. package/src/declaration/metavariable.js +3 -4
  85. package/src/declaration/type.js +2 -2
  86. package/src/declaration/variable.js +5 -4
  87. package/src/declaration.js +12 -9
  88. package/src/derivation.js +7 -1
  89. package/src/equality.js +7 -1
  90. package/src/frame.js +10 -9
  91. package/src/index.js +12 -0
  92. package/src/judgement.js +11 -5
  93. package/src/label.js +5 -5
  94. package/src/lemma.js +8 -11
  95. package/src/metaLemma.js +13 -11
  96. package/src/metatheorem.js +6 -10
  97. package/src/metavariable.js +23 -42
  98. package/src/mixins/statement/qualified/unify.js +1 -2
  99. package/src/mixins/statement/unify.js +2 -2
  100. package/src/mixins/statement/verify.js +35 -88
  101. package/src/mixins/term/verify.js +3 -2
  102. package/src/premise.js +41 -33
  103. package/src/proof.js +10 -3
  104. package/src/proofStep.js +91 -32
  105. package/src/reference.js +3 -2
  106. package/src/rule.js +17 -24
  107. package/src/statement/qualified.js +9 -5
  108. package/src/statement.js +3 -3
  109. package/src/subDerivation.js +8 -2
  110. package/src/subproof.js +12 -5
  111. package/src/substitution/statementForMetavariable.js +45 -30
  112. package/src/substitution.js +9 -9
  113. package/src/substitutions.js +75 -45
  114. package/src/supposition.js +50 -35
  115. package/src/term.js +3 -3
  116. package/src/theorem.js +8 -11
  117. package/src/topLevelAssertion.js +16 -7
  118. package/src/type.js +3 -3
  119. package/src/unifier/equality.js +1 -1
  120. package/src/unifier/metaLevel.js +8 -10
  121. package/src/unifier/metavariable.js +5 -5
  122. package/src/unifier/statementWithCombinator.js +5 -5
  123. package/src/utilities/brackets.js +2 -2
  124. package/src/utilities/node.js +1 -10
  125. package/src/utilities/nominal.js +14 -0
  126. package/src/utilities/subproof.js +2 -2
  127. package/src/utilities/tokens.js +2 -9
  128. package/src/variable.js +4 -4
  129. package/src/verifier/statementAsCombinator.js +4 -18
  130. package/src/verifier/termAsConstructor.js +4 -4
  131. package/src/verifier/topLevel.js +15 -14
  132. package/lib/assignment/metavariable.js +0 -62
  133. package/lib/unifier/intrinsicLevel.js +0 -144
  134. package/lib/utilities/unify.js +0 -24
  135. package/lib/verifier/intrinsicLevel.js +0 -140
  136. package/lib/verifier/metaLevel.js +0 -147
  137. package/src/assignment/metavariable.js +0 -30
  138. package/src/unifier/intrinsicLevel.js +0 -54
  139. package/src/utilities/unify.js +0 -23
  140. package/src/verifier/intrinsicLevel.js +0 -42
  141. package/src/verifier/metaLevel.js +0 -54
@@ -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
- export default class Substitutions {
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
- getMetavariableNames() {
38
- const metavariableNames = [];
39
+ getMetavariableNodes() {
40
+ const metavariableNodes = [];
39
41
 
40
42
  this.forEachSubstitution((substitution) => {
41
- const metavariableName = substitution.getMetavariableName();
43
+ const metavariableNode = substitution.getMetavariableNode();
42
44
 
43
- if (metavariableName !== null) {
44
- metavariableNames.push(metavariableName);
45
+ if (metavariableNode !== null) {
46
+ metavariableNodes.push(metavariableNode);
45
47
  }
46
48
  });
47
49
 
48
- compress(metavariableNames, (metavariableNameA, metavariableNameB) => {
49
- if (metavariableNameA === metavariableNameB) {
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 metavariableNames;
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
- findSubstitutionByMetavariableName(metavariableName) {
109
+ findSubstitutionByMetavariableNode(metavariableNode) {
106
110
  const substitution = this.findSubstitution((substitution) => {
107
- const metavariableNameMatches = substitution.matchMetavariableName(metavariableName);
111
+ const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
108
112
 
109
- if (metavariableNameMatches) {
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
- findSubstitutionsByMetavariableName(metavariableName) {
121
+ findSubstitutionsByMetavariableNode(metavariableNode) {
118
122
  const substitutions = this.findSubstitutions((substitution) => {
119
- const metavariableNameMatches = substitution.matchMetavariableName(metavariableName);
123
+ const metavariableNodeMatches = substitution.matchMetavariableNode(metavariableNode);
120
124
 
121
- if (metavariableNameMatches) {
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
- findSimpleSubstitutionByMetavariableName(metavariableName) {
130
- const substitutions = this.findSubstitutionsByMetavariableName(metavariableName),
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
- findComplexSubstitutionsByMetavariableName(metavariableName) {
145
- const substitutions = this.findSubstitutionsByMetavariableName(metavariableName),
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
- findSubstitutionByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode) {
161
+ findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode) {
158
162
  const substitutions = this.findSubstitutions((substitution) => {
159
- const metavariableNameAndSubstitutionNodeMatch = substitution.matchMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode);
163
+ const metavariableNodeAndSubstitutionNodeMatch = substitution.matchMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
160
164
 
161
- if (metavariableNameAndSubstitutionNodeMatch) {
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
- isSimpleSubstitutionPresentByMetavariableName(metavariableName) {
172
- const simpleSubstitution = this.findSimpleSubstitutionByMetavariableName(metavariableName),
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
- isSubstitutionPresentByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode) {
179
- const substitution = this.findSubstitutionByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode),
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 metavariableNames = this.getMetavariableNames(),
224
- resolved = metavariableNames.every((metavariableName) => {
225
- const complexSubstitutions = this.findComplexSubstitutionsByMetavariableName(metavariableName),
226
- complexSubstitutionsResolved = complexSubstitutions.everySubstitution((complexSubstitution) => {
227
- const substitution = complexSubstitution, ///
228
- substitutions = this, ///
229
- substitutionResolved = substitution.resolve(substitutions, localContextA, localContextB);
230
-
231
- if (substitutionResolved) {
232
- return true;
233
- }
234
- });
235
-
236
- if (complexSubstitutionsResolved) {
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
- rightDifference(this.savedArray, array);
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
- function rightDifference(arrayA, arrayB) {
307
- filter(arrayB, (elementB) => {
308
- const arrayAIncludesElementB = arrayA.includes(elementB);
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 (!arrayAIncludesElementB) {
340
+ if (!arrayBIncludesElementA) {
311
341
  return true;
312
342
  }
313
343
  });
@@ -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
- proofStepUnified = this.unifySubproof(subproof, substitutions, localContext);
76
+ subproofUnified = this.unifySubproof(subproof, substitutions, localContext);
106
77
  } else if (statement !== null) {
107
- proofStepUnified = this.unifyStatement(statement, substitutions, localContext);
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 unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
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
- verifyAtTopLevel(fileContext) {
216
+ verifyWhenDeclared(fileContext) {
217
217
  let verifiedAtTopLevel;
218
218
 
219
219
  const termString = this.string; ///
220
220
 
221
- fileContext.trace(`Verifying the '${termString}' term at top level...`);
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 at top level.`);
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 labelsVerifiedAtTopLevel = this.labels.every((label) => {
29
- const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
23
+ const labelsVerifiedWhenDeclared = this.labels.every((label) => {
24
+ const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
30
25
 
31
- if (labelVVerifiedAtTopLevel) {
26
+ if (labelVVerifiedWhenDeclared) {
32
27
  return true;
33
28
  }
34
29
  });
35
30
 
36
- if (labelsVerifiedAtTopLevel) {
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 substitutions = Substitutions.fromNothing(),
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 proofNode = proofNodeQuery(theoremNode),
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),
@@ -2,7 +2,8 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import Substitutions from "./substitutions";
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 = false;
65
+ let statementUnified;
65
66
 
66
- const proofSteps = localContext.getProofSteps(),
67
- substitutions = Substitutions.fromNothing(),
68
- proofStepsUnified = this.unifyProofSteps(proofSteps, substitutions, localContext);
67
+ const { Substitutions } = shim,
68
+ substitutions = Substitutions.fromNothing();
69
69
 
70
- if (proofStepsUnified) {
71
- statementUnified = this.consequent.unifyStatement(statement, substitutions, localContext);
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
- verifyAtTopLevel(fileContext) {
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 at top level...`);
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 at top level.`);
139
+ fileContext.debug(`...verified the '${typeString}' type when declared.`);
140
140
  }
141
141
 
142
142
  return verifiedAtTopLevel;
@@ -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) {
@@ -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, metavariableNameFromMetavariableNode } from "../utilities/name";
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
- metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
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 = unifyStatementWithStatement(statementNodeA, statementNodeB, substitutions, localContextA, localContextB);
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
- metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
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 unifyStatementWithStatement(statementNodeA, statementNodeB, substitutions, localContextA, localContextB) {
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 unified = false;
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
- unified = true;
43
+ termUnified = true;
44
44
  }
45
45
  }
46
46
 
47
- return unified;
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);
@@ -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 = nominalParser) {
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);