occam-verify-cli 0.0.1067 → 0.0.1069

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 (137) hide show
  1. package/bin/action/verify.js +3 -2
  2. package/lib/assertion/contained.js +2 -2
  3. package/lib/assertion/defined.js +2 -2
  4. package/lib/assertion/subproof.js +3 -3
  5. package/lib/assignment/judgement.js +3 -3
  6. package/lib/axiom.js +11 -6
  7. package/lib/combinator.js +9 -9
  8. package/lib/conclusion.js +13 -10
  9. package/lib/conjecture.js +11 -6
  10. package/lib/consequent.js +13 -10
  11. package/lib/constructor.js +9 -9
  12. package/lib/context/file.js +34 -126
  13. package/lib/context/local.js +16 -5
  14. package/lib/context/release.js +2 -3
  15. package/lib/declaration.js +96 -2
  16. package/lib/equivalence.js +2 -2
  17. package/lib/frame.js +179 -98
  18. package/lib/index.js +22 -6
  19. package/lib/judgement.js +84 -5
  20. package/lib/label.js +12 -8
  21. package/lib/lemma.js +12 -12
  22. package/lib/metaLemma.js +120 -8
  23. package/lib/metaType.js +24 -3
  24. package/lib/metatheorem.js +145 -9
  25. package/lib/metavariable.js +128 -43
  26. package/lib/mixins/statement/qualified/unify.js +6 -10
  27. package/lib/mixins/statement/unify.js +4 -19
  28. package/lib/mixins/statement/verify.js +13 -13
  29. package/lib/mixins/term/unify.js +2 -2
  30. package/lib/premise.js +21 -13
  31. package/lib/reference.js +17 -17
  32. package/lib/rule.js +28 -40
  33. package/lib/statement/unqualified.js +34 -9
  34. package/lib/statement.js +7 -5
  35. package/lib/substitution/frameForMetavariable.js +75 -70
  36. package/lib/substitution/statementForMetavariable.js +83 -42
  37. package/lib/substitution/termForVariable.js +65 -68
  38. package/lib/substitution.js +46 -43
  39. package/lib/substitutions.js +52 -40
  40. package/lib/supposition.js +15 -11
  41. package/lib/term.js +6 -11
  42. package/lib/theorem.js +11 -6
  43. package/lib/topLevelAssertion.js +24 -42
  44. package/lib/type.js +5 -12
  45. package/lib/unifier/intrinsicLevel.js +4 -4
  46. package/lib/unifier/metaLevel.js +11 -7
  47. package/lib/unifier/metavariable.js +6 -6
  48. package/lib/unifier/statementWithCombinator.js +16 -16
  49. package/lib/unifier/termWithConstructor.js +7 -7
  50. package/lib/utilities/brackets.js +10 -10
  51. package/lib/utilities/json.js +493 -0
  52. package/lib/utilities/node.js +26 -19
  53. package/lib/utilities/release.js +53 -0
  54. package/lib/utilities/releaseContext.js +4 -15
  55. package/lib/utilities/tokens.js +8 -1
  56. package/lib/variable.js +14 -15
  57. package/lib/verifier/topLevel.js +5 -5
  58. package/package.json +1 -1
  59. package/src/assertion/contained.js +1 -1
  60. package/src/assertion/defined.js +1 -1
  61. package/src/assertion/subproof.js +2 -3
  62. package/src/assignment/judgement.js +3 -4
  63. package/src/axiom.js +14 -6
  64. package/src/combinator.js +12 -13
  65. package/src/conclusion.js +16 -13
  66. package/src/conjecture.js +14 -6
  67. package/src/consequent.js +16 -13
  68. package/src/constructor.js +11 -13
  69. package/src/context/file.js +94 -202
  70. package/src/context/local.js +8 -6
  71. package/src/context/release.js +2 -3
  72. package/src/declaration.js +126 -45
  73. package/src/equivalence.js +2 -2
  74. package/src/frame.js +225 -141
  75. package/src/index.js +17 -1
  76. package/src/judgement.js +109 -3
  77. package/src/label.js +15 -10
  78. package/src/lemma.js +17 -10
  79. package/src/metaLemma.js +102 -1
  80. package/src/metaType.js +29 -3
  81. package/src/metatheorem.js +143 -2
  82. package/src/metavariable.js +189 -66
  83. package/src/mixins/statement/qualified/unify.js +7 -19
  84. package/src/mixins/statement/unify.js +3 -25
  85. package/src/mixins/statement/verify.js +15 -13
  86. package/src/mixins/term/unify.js +1 -1
  87. package/src/premise.js +31 -16
  88. package/src/reference.js +18 -18
  89. package/src/rule.js +40 -58
  90. package/src/statement/unqualified.js +41 -11
  91. package/src/statement.js +6 -3
  92. package/src/substitution/frameForMetavariable.js +85 -98
  93. package/src/substitution/statementForMetavariable.js +109 -45
  94. package/src/substitution/termForVariable.js +83 -94
  95. package/src/substitution.js +36 -34
  96. package/src/substitutions.js +53 -46
  97. package/src/supposition.js +22 -14
  98. package/src/term.js +5 -15
  99. package/src/theorem.js +14 -6
  100. package/src/topLevelAssertion.js +38 -64
  101. package/src/type.js +5 -20
  102. package/src/unifier/intrinsicLevel.js +4 -3
  103. package/src/unifier/metaLevel.js +19 -7
  104. package/src/unifier/metavariable.js +5 -5
  105. package/src/unifier/statementWithCombinator.js +19 -19
  106. package/src/unifier/termWithConstructor.js +7 -7
  107. package/src/utilities/brackets.js +5 -5
  108. package/src/utilities/json.js +551 -0
  109. package/src/utilities/node.js +28 -23
  110. package/src/{verify → utilities}/release.js +5 -1
  111. package/src/utilities/releaseContext.js +2 -2
  112. package/src/utilities/tokens.js +10 -0
  113. package/src/variable.js +18 -19
  114. package/src/verifier/topLevel.js +6 -4
  115. package/lib/argument.js +0 -106
  116. package/lib/metaTypes.js +0 -19
  117. package/lib/unify/metavariableWithFrame.js +0 -40
  118. package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -31
  119. package/lib/unify/statementWithSttaemetnGivenEquivalences.js +0 -45
  120. package/lib/verify/declaration.js +0 -83
  121. package/lib/verify/frame.js +0 -120
  122. package/lib/verify/judgement.js +0 -88
  123. package/lib/verify/metaLemma.js +0 -49
  124. package/lib/verify/metatheorem.js +0 -48
  125. package/lib/verify/metavariableGivenMetaType.js +0 -44
  126. package/lib/verify/release.js +0 -50
  127. package/src/argument.js +0 -79
  128. package/src/metaTypes.js +0 -11
  129. package/src/unify/metavariableWithFrame.js +0 -40
  130. package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -27
  131. package/src/unify/statementWithSttaemetnGivenEquivalences.js +0 -51
  132. package/src/verify/declaration.js +0 -113
  133. package/src/verify/frame.js +0 -157
  134. package/src/verify/judgement.js +0 -127
  135. package/src/verify/metaLemma.js +0 -72
  136. package/src/verify/metatheorem.js +0 -67
  137. package/src/verify/metavariableGivenMetaType.js +0 -45
package/src/frame.js CHANGED
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ import { arrayUtilities } from "necessary";
4
+
3
5
  import shim from "./shim";
4
6
  import Declaration from "./declaration";
5
7
  import Metavariable from "./metavariable";
@@ -7,13 +9,17 @@ import Metavariable from "./metavariable";
7
9
  import { FRAME_META_TYPE_NAME } from "./metaTypeNames";
8
10
  import { nodeQuery, nodesQuery } from "./utilities/query";
9
11
 
10
- const declarationNodesQuery = nodesQuery("/frame/declaration"),
11
- metavariableNodesQuery = nodesQuery("/frame/metavariable"),
12
- frameMetavariableNodeQuery = nodeQuery("/*/frame/metavariable!");
12
+ const frameNodeQuery = nodeQuery("/*/frame"),
13
+ declarationNodesQuery = nodesQuery("/frame/declaration"),
14
+ metavariableNodeQuery = nodeQuery("/frame/metavariable!"),
15
+ metavariableNodesQuery = nodesQuery("/frame/metavariable");
16
+
17
+ const { first } = arrayUtilities;
13
18
 
14
19
  class Frame {
15
- constructor(string, declarations, metavariables) {
20
+ constructor(string, node, declarations, metavariables) {
16
21
  this.string = string;
22
+ this.node = node;
17
23
  this.declarations = declarations;
18
24
  this.metavariables = metavariables;
19
25
  }
@@ -22,6 +28,10 @@ class Frame {
22
28
  return this.string;
23
29
  }
24
30
 
31
+ getNode() {
32
+ return this.node;
33
+ }
34
+
25
35
  getDeclarations() {
26
36
  return this.declarations;
27
37
  }
@@ -31,82 +41,113 @@ class Frame {
31
41
  }
32
42
 
33
43
  getMetavariable() {
34
- let metavariable;
44
+ let metavariable = null;
45
+
46
+ const declarationsLength = this.declarations.length;
35
47
 
36
- const metavariablesLength = this.metavariables.length;
48
+ if (declarationsLength === 0) {
49
+ const metavariablesLength = this.metavariables.length;
37
50
 
38
- if (metavariablesLength === 1) {
39
- const firstMetavariable = first(this.metavariables);
51
+ if (metavariablesLength === 1) {
52
+ const firstMetavariable = first(this.metavariables);
40
53
 
41
- metavariable = firstMetavariable; ///
54
+ metavariable = firstMetavariable; ///
55
+ }
42
56
  }
43
57
 
44
58
  return metavariable;
45
59
  }
46
60
 
47
- // getMetavariableNode() {
48
- // let metavariableNode = null;
49
- //
50
- // const declarationsLength = this.declarations.length;
51
- //
52
- // if (declarationsLength === 0) {
53
- // const metavariableNodesLength = this.metavariableNodes.length;
54
- //
55
- // if (metavariableNodesLength === 1) {
56
- // const firstMetavariableNode = first(this.metavariableNodes);
57
- //
58
- // metavariableNode = firstMetavariableNode; ///
59
- // }
60
- // }
61
- //
62
- // return metavariableNode;
63
- // }
64
- //
65
- // matchMetavariableName(metavariableName) {
66
- // let metavariableNameMatches = false;
67
- //
68
- // const metavariableNode = this.getMetavariableNode();
69
- //
70
- // if (metavariableNode !== null) {
71
- // const name = metavariableName; ///
72
- //
73
- // metavariableName = metavariableNameFromMetavariableNode(metavariableNode); ///
74
- //
75
- // const nameMatchesMetavariableName = (name === metavariableName);
76
- //
77
- // metavariableNameMatches = nameMatchesMetavariableName; ///
78
- // }
79
- //
80
- // return metavariableNameMatches;
81
- // }
82
- //
83
- // unifySubstitution(substitution) {
84
- // const substitutionUnified = this.declarations.some((declaration) => {
85
- // const substitutionUnifiedWithDeclaration = declaration.unifySubstitution(substitution);
86
- //
87
- // if (substitutionUnifiedWithDeclaration) {
88
- // return true;
89
- // }
90
- // });
91
- //
92
- // return substitutionUnified;
93
- // }
94
- //
95
- // unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem) {
96
- // const substitutions = metaLemmaMetatheorem.getSubstitutions(),
97
- // substitutionsUnified = substitutions.everySubstitution((substitution) => {
98
- // const substitutionUnified = this.unifySubstitution(substitution);
99
- //
100
- // if (substitutionUnified) {
101
- // return true;
102
- // }
103
- // }),
104
- // metaLemmaOrMetaTheoremUnified = substitutionsUnified; ///
105
- //
106
- // return metaLemmaOrMetaTheoremUnified;
107
- // }
108
-
109
- verify(localContext) {
61
+ getMetavariableNode() {
62
+ let metavariableNode = null;
63
+
64
+ const metavariable = this.getMetavariable();
65
+
66
+ if (metavariable !== null) {
67
+ metavariableNode = metavariable.getNode();
68
+ }
69
+
70
+ return metavariableNode;
71
+ }
72
+
73
+ matchFrameNode(frameNode) {
74
+ const frameNodeMatches = this.node.match(frameNode);
75
+
76
+ return frameNodeMatches;
77
+ }
78
+
79
+ matchMetavariableName(metavariableName) {
80
+ let metavariableNameMatches = false;
81
+
82
+ const metavariable = this.getMetavariable();
83
+
84
+ if (metavariable !== null) {
85
+ metavariableNameMatches = metavariable.matchMetavariableName(metavariableName);
86
+ }
87
+
88
+ return metavariableNameMatches;
89
+ }
90
+
91
+ unifySubstitution(substitution, localContext) {
92
+ let substitutionUnified = false;
93
+
94
+ const substitutionString = substitution.getString();
95
+
96
+ localContext.trace(`Unifying the '${substitutionString}' substitution...`)
97
+
98
+ if (!substitutionUnified) {
99
+ substitutionUnified = this.declarations.some((declaration) => {
100
+ const substitutionUnified = declaration.unifySubstitution(substitution, localContext);
101
+
102
+ if (substitutionUnified) {
103
+ return true;
104
+ }
105
+ });
106
+ }
107
+
108
+ if (!substitutionUnified) {
109
+ substitutionUnified = this.metavariables.some((metavariable) => {
110
+ const substitutionUnified = metavariable.unifySubstitution(substitution, localContext);
111
+
112
+ if (substitutionUnified) {
113
+ return true;
114
+ }
115
+ });
116
+ }
117
+
118
+ if (substitutionUnified) {
119
+ localContext.debug(`...unified the '${substitutionString}' substitution...`)
120
+ }
121
+
122
+ return substitutionUnified;
123
+ }
124
+
125
+ unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, localContext) {
126
+ let metaLemmaOrMetaTheoremUnified;
127
+
128
+ const metaLemmaMetatheoremString = metaLemmaMetatheorem.getString();
129
+
130
+ localContext.trace(`Unifying the '${metaLemmaMetatheoremString}' metatheorem or meta-lemma...`);
131
+
132
+ const substitutions = metaLemmaMetatheorem.getSubstitutions(),
133
+ substitutionsUnified = substitutions.everySubstitution((substitution) => {
134
+ const substitutionUnified = this.unifySubstitution(substitution, localContext);
135
+
136
+ if (substitutionUnified) {
137
+ return true;
138
+ }
139
+ });
140
+
141
+ metaLemmaOrMetaTheoremUnified = substitutionsUnified; ///
142
+
143
+ if (metaLemmaOrMetaTheoremUnified) {
144
+ localContext.debug(`...unified the '${metaLemmaMetatheoremString}' metatheorem or meta-lemma.`);
145
+ }
146
+
147
+ return metaLemmaOrMetaTheoremUnified;
148
+ }
149
+
150
+ verify(assignments, stated, localContext) {
110
151
  let verified;
111
152
 
112
153
  const frameString = this.string; ///
@@ -114,19 +155,29 @@ class Frame {
114
155
  localContext.trace(`Verifying the '${frameString}' frame...`);
115
156
 
116
157
  const declarationsVerified = this.declarations.every((declaration) => {
117
- const declarationVerified = declaration.verify(localContext);
158
+ const declarationVerified = declaration.verify(assignments, stated, localContext);
118
159
 
119
- return declarationVerified;
120
- });
160
+ return declarationVerified;
161
+ }),
162
+ metavariablesVerified = this.metavariables.every((metavariable) => {
163
+ const metavariableVerified = metavariable.verify(localContext);
121
164
 
122
- if (declarationsVerified) {
123
- const metavariablesVerified = this.metavariables.every((metavariable) => {
124
- const metavariableVerified = metavariable.verify(localContext);
165
+ return metavariableVerified;
166
+ });
125
167
 
126
- return metavariableVerified;
127
- });
168
+ if (declarationsVerified && metavariablesVerified) {
169
+ let verifiedWhenStated = false,
170
+ verifiedWhenDerived = false;
128
171
 
129
- verified = metavariablesVerified; ///
172
+ if (stated) {
173
+ verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
174
+ } else {
175
+ verifiedWhenDerived = this.verifyWhenDerived(assignments, localContext);
176
+ }
177
+
178
+ if (verifiedWhenStated || verifiedWhenDerived) {
179
+ verified = true;
180
+ }
130
181
  }
131
182
 
132
183
  if (verified) {
@@ -136,7 +187,52 @@ class Frame {
136
187
  return verified;
137
188
  }
138
189
 
139
- verifyGivenMetaType(metaType, localContext) {
190
+ verifyWhenStated(assignments, localContext) {
191
+ let verifiedWhenStated = false;
192
+
193
+ const frameString = this.string; ///
194
+
195
+ localContext.trace(`Verifying the '${frameString}' frame when stated...`);
196
+
197
+ const declarationsLength = this.declarations.length;
198
+
199
+ if (declarationsLength === 0) {
200
+ const metavariablesLength = this.metavariables.length;
201
+
202
+ if (metavariablesLength === 1) {
203
+ verifiedWhenStated = true;
204
+ } else {
205
+ localContext.trace(`The '${frameString}' stated frame cannot have more than one metavariable.`);
206
+ }
207
+ } else {
208
+ localContext.trace(`The '${frameString}' stated frame cannot have declarations.`);
209
+ }
210
+
211
+
212
+ if (verifiedWhenStated) {
213
+ localContext.debug(`...verified the '${frameString}' frame when stated.`);
214
+ }
215
+
216
+ return verifiedWhenStated;
217
+ }
218
+
219
+ verifyWhenDerived(assignments, localContext) {
220
+ let verifiedWhenDerived;
221
+
222
+ const frameString = this.string; ///
223
+
224
+ localContext.trace(`Verifying the '${frameString}' frame when derived...`);
225
+
226
+ verifiedWhenDerived = true;
227
+
228
+ if (verifiedWhenDerived) {
229
+ localContext.debug(`...verified the '${frameString}' frame when derived.`);
230
+ }
231
+
232
+ return verifiedWhenDerived;
233
+ }
234
+
235
+ verifyGivenMetaType(metaType, assignments, stated, localContext) {
140
236
  let verifiedGivenMetaType = false;
141
237
 
142
238
  const frameString = this.string, ///
@@ -147,7 +243,7 @@ class Frame {
147
243
  const metaTypeName = metaType.getName();
148
244
 
149
245
  if (metaTypeName === FRAME_META_TYPE_NAME) {
150
- const verified = this.verify(localContext)
246
+ const verified = this.verify(assignments, stated, localContext)
151
247
 
152
248
  verifiedGivenMetaType = verified; ///
153
249
  }
@@ -160,21 +256,26 @@ class Frame {
160
256
  }
161
257
 
162
258
  static fromFrameNode(frameNode, localContext) {
163
- const declarationNodes = declarationNodesQuery(frameNode),
164
- metavariableNodes = metavariableNodesQuery(frameNode),
165
- declarations = declarationNodes.map((declarationNode) => {
166
- const declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
259
+ let frame = null;
167
260
 
168
- return declaration;
169
- }),
170
- metavariables = metavariableNodes.map((metavariableNode) => {
171
- const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext);
261
+ if (frameNode !== null) {
262
+ const declarationNodes = declarationNodesQuery(frameNode),
263
+ metavariableNodes = metavariableNodesQuery(frameNode),
264
+ declarations = declarationNodes.map((declarationNode) => {
265
+ const declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
172
266
 
173
- return metavariable;
174
- }),
175
- node = frameNode, ///
176
- string = localContext.nodeAsString(node),
177
- frame = new Frame(string, declarations, metavariables);
267
+ return declaration;
268
+ }),
269
+ metavariables = metavariableNodes.map((metavariableNode) => {
270
+ const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext);
271
+
272
+ return metavariable;
273
+ }),
274
+ node = frameNode, ///
275
+ string = localContext.nodeAsString(node);
276
+
277
+ frame = new Frame(string, node, declarations, metavariables);
278
+ }
178
279
 
179
280
  return frame;
180
281
  }
@@ -182,19 +283,22 @@ class Frame {
182
283
  static fromDefinedAssertionNode(definedAssertionNode, localContext) {
183
284
  let frame = null;
184
285
 
185
- const frameMetavariableNode = frameMetavariableNodeQuery(definedAssertionNode);
286
+ const frameNode = frameNodeQuery(definedAssertionNode);
186
287
 
187
- if (frameMetavariableNode !== null) {
188
- const metavariableNode = frameMetavariableNode, ///
189
- metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
190
- declarations = [],
191
- metavariables = [
192
- metavariable
193
- ],
194
- node = metavariableNode, ///
195
- string = localContext.nodeAsString(node);
288
+ if (frameNode !== null) {
289
+ const metavariableNode = metavariableNodeQuery(frameNode);
290
+
291
+ if (metavariableNode !== null) {
292
+ const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
293
+ declarations = [],
294
+ metavariables = [
295
+ metavariable
296
+ ],
297
+ node = frameNode, ///
298
+ string = localContext.nodeAsString(node);
196
299
 
197
- frame = new Frame(string, declarations, metavariables);
300
+ frame = new Frame(string, node, declarations, metavariables);
301
+ }
198
302
  }
199
303
 
200
304
  return frame;
@@ -203,46 +307,26 @@ class Frame {
203
307
  static fromContainedAssertionNode(containedAssertionNode, localContext) {
204
308
  let frame = null;
205
309
 
206
- const frameMetavariableNode = frameMetavariableNodeQuery(containedAssertionNode);
310
+ const frameNode = frameNodeQuery(containedAssertionNode);
207
311
 
208
- if (frameMetavariableNode !== null) {
209
- const metavariableNode = frameMetavariableNode, ///
210
- metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
211
- declarations = [],
212
- metavariables = [
213
- metavariable
214
- ],
215
- node = metavariableNode, ///
216
- string = localContext.nodeAsString(node);
312
+ if (frameNode !== null) {
313
+ const metavariableNode = metavariableNodeQuery(frameNode);
217
314
 
218
- frame = new Frame(string, declarations, metavariables);
315
+ if (metavariableNode !== null) {
316
+ const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
317
+ declarations = [],
318
+ metavariables = [
319
+ metavariable
320
+ ],
321
+ node = frameNode, ///
322
+ string = localContext.nodeAsString(node);
323
+
324
+ frame = new Frame(string, node, declarations, metavariables);
325
+ }
219
326
  }
220
327
 
221
328
  return frame;
222
329
  }
223
-
224
- // static fromDeclarations(declarations) {
225
- // const metavariableNodes = [],
226
- // frame = new Frame(declarations, metavariableNodes);
227
- //
228
- // return frame;
229
- // }
230
- //
231
- // static fromMetavariableNode(metavariableNode) {
232
- // const declarations = [],
233
- // metavariableNodes = [
234
- // metavariableNode
235
- // ],
236
- // frame = new Frame(declarations, metavariableNodes);
237
- //
238
- // return frame;
239
- // }
240
- //
241
- // static fromDeclarationsAndMetavariableNodes(declarations, metavariableNodes) {
242
- // const frame = new Frame(declarations, metavariableNodes);
243
- //
244
- // return frame;
245
- // }
246
330
  }
247
331
 
248
332
  Object.assign(shim, {
package/src/index.js CHANGED
@@ -2,12 +2,28 @@
2
2
 
3
3
  import Type from "./type";
4
4
  import Term from "./term";
5
+ import Rule from "./rule";
6
+ import Label from "./label";
7
+ import Axiom from "./axiom";
8
+ import Lemma from "./lemma";
9
+ import Premise from "./premise";
10
+ import Theorem from "./theorem";
5
11
  import MetaType from "./metaType";
12
+ import Variable from "./variable";
6
13
  import Statement from "./statement";
7
14
  import ProofStep from "./proofStep";
15
+ import Consequent from "./consequent";
16
+ import Conjecture from "./conjecture";
17
+ import Combinator from "./combinator";
18
+ import Conclusion from "./conclusion";
19
+ import Constructor from "./constructor";
20
+ import Supposition from "./supposition";
21
+ import Metatheorem from "./metatheorem";
22
+ import Metavariable from "./metavariable";
23
+ import UnqualifiedStatement from "./statement/unqualified";
8
24
 
9
25
  export { default as Log } from "./log";
10
- export { default as verifyRelease } from "./verify/release";
11
26
  export { default as ReleaseContext } from "./context/release";
27
+ export { default as releaseUtilities } from "./utilities/release";
12
28
  export { default as customGrammarUtilities } from "./utilities/customGrammar";
13
29
  export { default as releaseContextUtilities } from "./utilities/releaseContext";
package/src/judgement.js CHANGED
@@ -1,11 +1,25 @@
1
1
  "use strict";
2
2
 
3
+ import Frame from "./frame";
4
+ import Declaration from "./declaration";
5
+ import JudgementAssignment from "./assignment/judgement";
6
+
7
+ import { nodeQuery } from "./utilities/query";
8
+
9
+ const frameNodeQuery = nodeQuery("/judgement/frame"),
10
+ declarationNodeQuery = nodeQuery("/judgement/declaration");
11
+
3
12
  export default class Judgement {
4
- constructor(frame, declaration) {
13
+ constructor(string, frame, declaration) {
14
+ this.string = string;
5
15
  this.frame = frame;
6
16
  this.declaration = declaration;
7
17
  }
8
18
 
19
+ getString() {
20
+ return this.string;
21
+ }
22
+
9
23
  getFrame() {
10
24
  return this.frame;
11
25
  }
@@ -18,8 +32,100 @@ export default class Judgement {
18
32
 
19
33
  matchMetavariableName(metavariableName) { return this.frame.matchMetavariableName(metavariableName); }
20
34
 
21
- static fromJudgementNodeFrameAndDeclaration(judgementNode, frame, declaration) {
22
- const judgement = new Judgement(frame, declaration);
35
+ verify(assignments, stated, localContext) {
36
+ let verified;
37
+
38
+ const judgementString = this.string; ///
39
+
40
+ localContext.trace(`Verifying the '${judgementString}' judgement...`);
41
+
42
+ const frameVerified = this.frame.verify(assignments, stated, localContext),
43
+ declarationVerified = this.declaration.verify(assignments, stated, localContext);
44
+
45
+ if (frameVerified && declarationVerified) {
46
+ let verifiedWhenStated = false,
47
+ verifiedWhenDerived = false;
48
+
49
+ if (stated) {
50
+ verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
51
+ } else {
52
+ verifiedWhenDerived = this.verifyWhenDerived(assignments, localContext);
53
+ }
54
+
55
+ if (verifiedWhenStated || verifiedWhenDerived) {
56
+ verified = true;
57
+ }
58
+ }
59
+
60
+ if (verified) {
61
+ localContext.debug(`...verified the '${judgementString}' judgement.`);
62
+ }
63
+
64
+ return verified;
65
+ }
66
+
67
+ verifyWhenStated(assignments, localContext) {
68
+ let verifiedWhenStated;
69
+
70
+ const judgementString = this.string; ///
71
+
72
+ localContext.trace(`Verifying the '${judgementString}' judgement when stated...`);
73
+
74
+ if (assignments !== null) {
75
+ const judgement = this, ///
76
+ judgementAssignment = JudgementAssignment.fromJudgement(judgement),
77
+ assignment = judgementAssignment;
78
+
79
+ assignments.push(assignment);
80
+ }
81
+
82
+ verifiedWhenStated = true;
83
+
84
+ if (verifiedWhenStated) {
85
+ localContext.debug(`...verified the '${judgementString}' judgement when stated.`);
86
+ }
87
+
88
+ return verifiedWhenStated;
89
+ }
90
+
91
+ verifyWhenDerived(assignments, localContext) {
92
+ let verifiedWhenDerived;
93
+
94
+ const judgementString = this.string; ///
95
+
96
+ localContext.trace(`Verifying the '${judgementString}' judgement when derived...`);
97
+
98
+ const reference = this.declaration.getReference(),
99
+ metaLemma = localContext.findMetaLemmaByReference(reference),
100
+ metatheorem = localContext.findMetatheoremByReference(reference),
101
+ metaLemmaMetatheorem = (metaLemma || metatheorem); ///
102
+
103
+ if (metaLemmaMetatheorem !== null) {
104
+ const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, localContext);
105
+
106
+ verifiedWhenDerived = metaLemmaMetatheoremUnified; ///
107
+ }
108
+
109
+ if (verifiedWhenDerived) {
110
+ localContext.debug(`...verified the '${judgementString}' judgement when derived.`);
111
+ }
112
+
113
+ return verifiedWhenDerived;
114
+ }
115
+
116
+ static fromJudgementNode(judgementNode, localContext) {
117
+ let judgement = null;
118
+
119
+ if (judgementNode !== null) {
120
+ const frameNode = frameNodeQuery(judgementNode),
121
+ declarationNode = declarationNodeQuery(judgementNode),
122
+ node = judgementNode, ///
123
+ string = localContext.nodeAsString(node),
124
+ frame = Frame.fromFrameNode(frameNode, localContext),
125
+ declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
126
+
127
+ judgement = new Judgement(string, frame, declaration);
128
+ }
23
129
 
24
130
  return judgement;
25
131
  }
package/src/label.js CHANGED
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ import shim from "./shim";
4
+ import LocalContext from "./context/local";
3
5
  import Metavariable from "./metavariable";
4
6
 
5
7
  import { nodeQuery } from "./utilities/query";
8
+ import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
6
9
 
7
10
  const metavariableNodeQuery = nodeQuery("//label/metavariable");
8
11
 
9
- export default class Label {
12
+ class Label {
10
13
  constructor(metavariable) {
11
14
  this.metavariable = metavariable;
12
15
  }
@@ -43,7 +46,7 @@ export default class Label {
43
46
  }
44
47
 
45
48
  toJSON() {
46
- const metavariableJSON = this.metavariable.toJSON(),
49
+ const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
47
50
  metavariable = metavariableJSON, ///
48
51
  json = {
49
52
  metavariable
@@ -53,22 +56,24 @@ export default class Label {
53
56
  }
54
57
 
55
58
  static fromJSON(json, fileContext) {
56
- let { metavariable } = json;
57
-
58
- json = metavariable; ///
59
-
60
- metavariable = Metavariable.fromJSON(json, fileContext);
61
-
62
- const label = new Label(metavariable);
59
+ const metavariable = metavariableFromJSON(json, fileContext),
60
+ label = new Label(metavariable);
63
61
 
64
62
  return label;
65
63
  }
66
64
 
67
65
  static fromLabelNode(labelNode, fileContext) {
68
66
  const metavariableNode = metavariableNodeQuery(labelNode),
69
- metavariable = Metavariable.fromMetavariableNode(metavariableNode, fileContext),
67
+ localContext = LocalContext.fromFileContext(fileContext),
68
+ metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
70
69
  label = new Label(metavariable);
71
70
 
72
71
  return label;
73
72
  }
74
73
  }
74
+
75
+ Object.assign(shim, {
76
+ Label
77
+ });
78
+
79
+ export default Label;