occam-verify-cli 0.0.1111 → 0.0.1112

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 (197) hide show
  1. package/lib/combinator/bracketed.js +15 -65
  2. package/lib/combinator.js +4 -8
  3. package/lib/constructor/bracketed.js +24 -101
  4. package/lib/constructor.js +4 -8
  5. package/lib/context/file.js +41 -12
  6. package/lib/context/local.js +45 -25
  7. package/lib/context/release.js +2 -2
  8. package/lib/dom/assertion/contained.js +246 -0
  9. package/lib/dom/assertion/defined.js +266 -0
  10. package/lib/dom/assertion/subproof.js +210 -0
  11. package/lib/dom/assertion/type.js +240 -0
  12. package/lib/{axiom.js → dom/axiom.js} +18 -8
  13. package/lib/dom/conclusion.js +171 -0
  14. package/lib/{conjecture.js → dom/conjecture.js} +18 -8
  15. package/lib/dom/consequent.js +171 -0
  16. package/lib/dom/declaration/combinator.js +105 -0
  17. package/lib/dom/declaration/constructor.js +140 -0
  18. package/lib/dom/declaration/metavariable.js +154 -0
  19. package/lib/dom/declaration/type.js +140 -0
  20. package/lib/dom/declaration/variable.js +155 -0
  21. package/lib/{declaration.js → dom/declaration.js} +62 -18
  22. package/lib/dom/derivation.js +137 -0
  23. package/lib/dom/equality.js +260 -0
  24. package/lib/dom/error.js +85 -0
  25. package/lib/dom/frame.js +372 -0
  26. package/lib/dom/judgement.js +198 -0
  27. package/lib/dom/label.js +190 -0
  28. package/lib/{lemma.js → dom/lemma.js} +19 -9
  29. package/lib/{metaLemma.js → dom/metaLemma.js} +19 -9
  30. package/lib/dom/metaType.js +261 -0
  31. package/lib/dom/metatheorem.js +273 -0
  32. package/lib/dom/metavariable.js +463 -0
  33. package/lib/dom/premise.js +221 -0
  34. package/lib/dom/proof.js +154 -0
  35. package/lib/dom/proofStep.js +239 -0
  36. package/lib/dom/reference.js +218 -0
  37. package/lib/dom/rule.js +311 -0
  38. package/lib/dom/statement.js +379 -0
  39. package/lib/dom/subDerivation.js +137 -0
  40. package/lib/dom/subproof.js +211 -0
  41. package/lib/dom/supposition.js +221 -0
  42. package/lib/dom/term.js +354 -0
  43. package/lib/{theorem.js → dom/theorem.js} +18 -8
  44. package/lib/dom/topLevelAssertion.js +306 -0
  45. package/lib/dom/type.js +327 -0
  46. package/lib/dom/variable.js +328 -0
  47. package/lib/dom.js +27 -0
  48. package/lib/equivalences.js +307 -0
  49. package/lib/index.js +40 -35
  50. package/lib/mixins/proofStep/unify.js +86 -0
  51. package/lib/mixins/statement/verify.js +27 -2
  52. package/lib/mixins/term/verify.js +24 -4
  53. package/lib/substitution/frame.js +3 -3
  54. package/lib/substitution/statement.js +17 -16
  55. package/lib/substitution/term.js +10 -7
  56. package/lib/substitution.js +4 -31
  57. package/lib/substitutions.js +24 -56
  58. package/lib/unifier/equality.js +2 -3
  59. package/lib/unifier/label.js +3 -3
  60. package/lib/unifier/metaLevel.js +9 -8
  61. package/lib/unifier/metavariable.js +3 -3
  62. package/lib/unifier/statementWithCombinator.js +5 -5
  63. package/lib/unifier/termWithConstructor.js +3 -3
  64. package/lib/utilities/json.js +26 -40
  65. package/lib/utilities/string.js +6 -8
  66. package/lib/utilities/subproof.js +2 -2
  67. package/lib/utilities/substitutions.js +7 -6
  68. package/lib/utilities/verification.js +22 -14
  69. package/lib/verifier/combinator.js +4 -4
  70. package/lib/verifier/constructor.js +3 -3
  71. package/lib/verifier/topLevel.js +15 -21
  72. package/package.json +1 -1
  73. package/src/combinator/bracketed.js +11 -4
  74. package/src/combinator.js +3 -10
  75. package/src/constructor/bracketed.js +17 -5
  76. package/src/constructor.js +3 -9
  77. package/src/context/file.js +42 -11
  78. package/src/context/local.js +26 -34
  79. package/src/context/release.js +1 -1
  80. package/src/{assertion → dom/assertion}/contained.js +10 -8
  81. package/src/{assertion → dom/assertion}/defined.js +14 -11
  82. package/src/{assertion → dom/assertion}/subproof.js +11 -62
  83. package/src/{assertion → dom/assertion}/type.js +11 -8
  84. package/src/{axiom.js → dom/axiom.js} +6 -9
  85. package/src/dom/conclusion.js +95 -0
  86. package/src/{conjecture.js → dom/conjecture.js} +5 -8
  87. package/src/dom/consequent.js +95 -0
  88. package/src/{declaration → dom/declaration}/combinator.js +8 -5
  89. package/src/{declaration → dom/declaration}/constructor.js +8 -4
  90. package/src/{declaration → dom/declaration}/metavariable.js +8 -5
  91. package/src/{declaration → dom/declaration}/type.js +8 -4
  92. package/src/{declaration → dom/declaration}/variable.js +9 -6
  93. package/src/{declaration.js → dom/declaration.js} +11 -16
  94. package/src/{derivation.js → dom/derivation.js} +9 -12
  95. package/src/{equality.js → dom/equality.js} +11 -14
  96. package/src/{error.js → dom/error.js} +6 -3
  97. package/src/{frame.js → dom/frame.js} +14 -23
  98. package/src/{judgement.js → dom/judgement.js} +8 -11
  99. package/src/{label.js → dom/label.js} +9 -16
  100. package/src/{lemma.js → dom/lemma.js} +5 -9
  101. package/src/{metaLemma.js → dom/metaLemma.js} +6 -9
  102. package/src/{metaType.js → dom/metaType.js} +7 -10
  103. package/src/{metatheorem.js → dom/metatheorem.js} +6 -10
  104. package/src/{metavariable.js → dom/metavariable.js} +79 -77
  105. package/src/dom/premise.js +173 -0
  106. package/src/{proof.js → dom/proof.js} +8 -11
  107. package/src/dom/proofStep.js +173 -0
  108. package/src/{reference.js → dom/reference.js} +48 -20
  109. package/src/{rule.js → dom/rule.js} +13 -17
  110. package/src/{statement.js → dom/statement.js} +142 -71
  111. package/src/{subDerivation.js → dom/subDerivation.js} +9 -12
  112. package/src/{subproof.js → dom/subproof.js} +14 -47
  113. package/src/dom/supposition.js +173 -0
  114. package/src/{term.js → dom/term.js} +24 -45
  115. package/src/{theorem.js → dom/theorem.js} +5 -8
  116. package/src/{topLevelAssertion.js → dom/topLevelAssertion.js} +12 -14
  117. package/src/{type.js → dom/type.js} +9 -12
  118. package/src/{variable.js → dom/variable.js} +20 -28
  119. package/src/dom.js +13 -0
  120. package/src/equivalences.js +278 -0
  121. package/src/index.js +39 -34
  122. package/src/mixins/proofStep/unify.js +115 -0
  123. package/src/mixins/statement/verify.js +33 -1
  124. package/src/mixins/term/verify.js +33 -3
  125. package/src/substitution/frame.js +2 -2
  126. package/src/substitution/statement.js +20 -18
  127. package/src/substitution/term.js +12 -5
  128. package/src/substitution.js +4 -29
  129. package/src/substitutions.js +35 -73
  130. package/src/unifier/equality.js +1 -2
  131. package/src/unifier/label.js +2 -2
  132. package/src/unifier/metaLevel.js +9 -7
  133. package/src/unifier/metavariable.js +2 -2
  134. package/src/unifier/statementWithCombinator.js +4 -4
  135. package/src/unifier/termWithConstructor.js +2 -2
  136. package/src/utilities/json.js +23 -42
  137. package/src/utilities/string.js +8 -6
  138. package/src/utilities/subproof.js +2 -2
  139. package/src/utilities/substitutions.js +7 -5
  140. package/src/utilities/verification.js +29 -13
  141. package/src/verifier/combinator.js +3 -3
  142. package/src/verifier/constructor.js +3 -3
  143. package/src/verifier/topLevel.js +20 -21
  144. package/lib/assertion/contained.js +0 -232
  145. package/lib/assertion/defined.js +0 -211
  146. package/lib/assertion/subproof.js +0 -203
  147. package/lib/assertion/type.js +0 -185
  148. package/lib/conclusion.js +0 -130
  149. package/lib/consequent.js +0 -130
  150. package/lib/declaration/combinator.js +0 -90
  151. package/lib/declaration/constructor.js +0 -90
  152. package/lib/declaration/metavariable.js +0 -104
  153. package/lib/declaration/type.js +0 -90
  154. package/lib/declaration/variable.js +0 -105
  155. package/lib/derivation.js +0 -91
  156. package/lib/equality.js +0 -209
  157. package/lib/error.js +0 -70
  158. package/lib/frame.js +0 -331
  159. package/lib/judgement.js +0 -147
  160. package/lib/label.js +0 -141
  161. package/lib/metaType.js +0 -255
  162. package/lib/metatheorem.js +0 -263
  163. package/lib/metavariable.js +0 -399
  164. package/lib/mixins/statement/qualified/unify.js +0 -69
  165. package/lib/mixins/statement/unify.js +0 -42
  166. package/lib/mixins/statement/unifyIndependenntly.js +0 -46
  167. package/lib/mixins/term/unify.js +0 -40
  168. package/lib/premise.js +0 -184
  169. package/lib/proof.js +0 -103
  170. package/lib/proofStep.js +0 -179
  171. package/lib/reference.js +0 -145
  172. package/lib/rule.js +0 -259
  173. package/lib/shim.js +0 -14
  174. package/lib/statement/qualified.js +0 -152
  175. package/lib/statement/unqualified.js +0 -175
  176. package/lib/statement.js +0 -270
  177. package/lib/subDerivation.js +0 -91
  178. package/lib/subproof.js +0 -181
  179. package/lib/supposition.js +0 -184
  180. package/lib/term.js +0 -318
  181. package/lib/topLevelAssertion.js +0 -305
  182. package/lib/type.js +0 -321
  183. package/lib/utilities/equivalences.js +0 -178
  184. package/lib/variable.js +0 -281
  185. package/src/conclusion.js +0 -96
  186. package/src/consequent.js +0 -96
  187. package/src/mixins/statement/qualified/unify.js +0 -103
  188. package/src/mixins/statement/unify.js +0 -41
  189. package/src/mixins/statement/unifyIndependenntly.js +0 -58
  190. package/src/mixins/term/unify.js +0 -36
  191. package/src/premise.js +0 -183
  192. package/src/proofStep.js +0 -181
  193. package/src/shim.js +0 -5
  194. package/src/statement/qualified.js +0 -133
  195. package/src/statement/unqualified.js +0 -166
  196. package/src/supposition.js +0 -183
  197. package/src/utilities/equivalences.js +0 -183
@@ -1,21 +1,25 @@
1
1
  "use strict";
2
2
 
3
- import shim from "./shim";
4
- import unifyMixins from "./mixins/statement/unify";
5
- import verifyMixins from "./mixins/statement/verify";
6
- import combinatorVerifier from "./verifier/combinator";
7
- import StatementNodeAndTokens from "./nodeAndTokens/statement";
8
- import unifyIndependentlyMixins from "./mixins/statement/unifyIndependenntly";
9
-
10
- import { unifyStatement } from "./utilities/unification";
11
- import { nodeQuery, nodesQuery } from "./utilities/query";
12
- import { STATEMENT_META_TYPE_NAME } from "./metaTypeNames";
13
-
14
- const statementNodeQuery = nodeQuery("/*//statement"),
3
+ import { arrayUtilities } from "necessary";
4
+
5
+ import dom from "../dom";
6
+ import verifyMixins from "../mixins/statement/verify";
7
+ import combinatorVerifier from "../verifier/combinator";
8
+ import StatementNodeAndTokens from "../nodeAndTokens/statement";
9
+
10
+ import { domAssigned } from "../dom";
11
+ import { unifyStatement } from "../utilities/unification";
12
+ import { nodeQuery, nodesQuery } from "../utilities/query";
13
+ import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
14
+ import { definedAssertionFromStatement, subproofAssertionFromStatement, containedAssertionFromStatement } from "../utilities/verification";
15
+
16
+ const { match, backwardsSome } = arrayUtilities;
17
+
18
+ const statementNodeQuery = nodeQuery("/*/statement"),
15
19
  statementTermNodesQuery = nodesQuery("/statement//term"),
16
20
  statementFrameNodesQuery = nodesQuery("/statement//frame");
17
21
 
18
- class Statement {
22
+ export default domAssigned(class Statement {
19
23
  constructor(string, node, tokens) {
20
24
  this.string = string;
21
25
  this.node = node;
@@ -35,13 +39,8 @@ class Statement {
35
39
  }
36
40
 
37
41
  isEqualTo(statement) {
38
- let equalTo = false;
39
-
40
- if (statement !== null) {
41
- const statementString = statement.getString();
42
-
43
- equalTo = (statementString === this.string);
44
- }
42
+ const statementString = statement.getString(),
43
+ equalTo = (statementString === this.string);
45
44
 
46
45
  return equalTo;
47
46
  }
@@ -106,27 +105,38 @@ class Statement {
106
105
  return statementNodeMatches;
107
106
  }
108
107
 
109
- unifyIndependently(substitutions, generalContext, specificContext) {
110
- let unifiedIndependently;
108
+ unifySubproof(subproof, substitutions, generalContext, specificContext) {
109
+ let subproofUnified = false;
111
110
 
112
- const statementString = this.string; ///
111
+ const context = specificContext, ///
112
+ statement = this, ///
113
+ subproofAssertion = subproofAssertionFromStatement(statement, context);
113
114
 
114
- specificContext.trace(`Unifying the '${statementString}' statement independently...`);
115
+ if (subproofAssertion !== null) {
116
+ const subproofString = subproof.getString(),
117
+ subproofAssertionString = subproofAssertion.getString();
115
118
 
116
- unifiedIndependently = unifyIndependentlyMixins.some((resolveMixin) => {
117
- const statement = this, ///
118
- unifiedIndependently = resolveMixin(statement, substitutions, generalContext, specificContext);
119
+ specificContext.trace(`Unifying the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion...`);
119
120
 
120
- if (unifiedIndependently) {
121
- return true;
122
- }
123
- });
121
+ const subproofStatements = subproof.getStatements(),
122
+ subproofAssertionStatements = subproofAssertion.getStatements();
123
+
124
+ subproofUnified = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
125
+ const generalStatement = subproofAssertionStatement, ///
126
+ specificStatement = subproofStatement, ///
127
+ statementUnified = unifyStatement(generalStatement, specificStatement, substitutions, generalContext, specificContext);
128
+
129
+ if (statementUnified) {
130
+ return true;
131
+ }
132
+ });
124
133
 
125
- if (unifiedIndependently) {
126
- specificContext.debug(`...unified the '${statementString}' statement independently.`);
134
+ if (subproofUnified) {
135
+ specificContext.debug(`...unified the '${subproofString}' subproof with the '${subproofAssertionString}' subproof assertion.`);
136
+ }
127
137
  }
128
138
 
129
- return unifiedIndependently;
139
+ return subproofUnified;
130
140
  }
131
141
 
132
142
  unifyStatement(statement, substitutions, generalContext, specificContext) {
@@ -148,41 +158,67 @@ class Statement {
148
158
  return statementUnified;
149
159
  }
150
160
 
151
- verify(assignments, stated, context) {
152
- let verified = false;
161
+ unifyIndependently(substitutions, generalContext, specificContext) {
162
+ let unifiedIndependently = false;
153
163
 
154
- const statementString = this.string; ///
164
+ const context = specificContext, ///
165
+ statement = this; ///
155
166
 
156
- context.trace(`Verifying the '${statementString}' statement...`);
167
+ const definedAssertion = definedAssertionFromStatement(statement, context),
168
+ containedAssertion = containedAssertionFromStatement(statement, context);
157
169
 
158
- if (!verified) {
159
- verified = verifyMixins.some((verifyMixin) => {
160
- const statement = this, ///
161
- verified = verifyMixin(statement, assignments, stated, context);
170
+ if ((definedAssertion !== null) || (containedAssertion !== null)) {
171
+ const statementString = this.string;
162
172
 
163
- if (verified) {
164
- return true;
165
- }
166
- });
167
- }
173
+ specificContext.trace(`Unifying the '${statementString}' statement independently...`);
168
174
 
169
- if (!verified) {
170
- const unified = unifyMixins.some((unifyMixin) => {
171
- const statement = this, ///
172
- unified = unifyMixin(statement, assignments, stated, context);
175
+ if (definedAssertion !== null) {
176
+ const definedAssertionUnifiedIndependently = definedAssertion.unifyIndependently(substitutions, context);
173
177
 
174
- if (unified) {
175
- return true;
176
- }
177
- });
178
+ unifiedIndependently = definedAssertionUnifiedIndependently; ///
179
+ }
178
180
 
179
- verified = unified; ///
180
- }
181
+ if (containedAssertion !== null) {
182
+ const containedAssertionUnifiedIndependently = containedAssertion.unifyIndependently(substitutions, context);
181
183
 
182
- if (verified) {
183
- context.debug(`...verified the '${statementString}' statement.`);
184
+ unifiedIndependently = containedAssertionUnifiedIndependently; ///
185
+ }
186
+
187
+ if (unifiedIndependently) {
188
+ specificContext.debug(`...unified the '${statementString}' statement independently.`);
189
+ }
184
190
  }
185
191
 
192
+ return unifiedIndependently;
193
+ }
194
+
195
+ unifyWithProofSteps(proofSteps, context) {
196
+ let unifiedWithProofSteps;
197
+
198
+ unifiedWithProofSteps = backwardsSome(proofSteps, (proofStep) => {
199
+ const statement = this, ///
200
+ statementUnified =proofStep.unifyStatement(statement, context);
201
+
202
+ if (statementUnified) {
203
+ return true;
204
+ }
205
+ });
206
+
207
+ return unifiedWithProofSteps;
208
+ }
209
+
210
+ verify(assignments, stated, context) {
211
+ let verified;
212
+
213
+ verified = verifyMixins.some((verifyMixin) => {
214
+ const statement = this, ///
215
+ verified = verifyMixin(statement, assignments, stated, context);
216
+
217
+ if (verified) {
218
+ return true;
219
+ }
220
+ });
221
+
186
222
  return verified;
187
223
  }
188
224
 
@@ -235,6 +271,8 @@ class Statement {
235
271
  return json;
236
272
  }
237
273
 
274
+ static name = "Statement";
275
+
238
276
  static fromJSON(json, fileContext) {
239
277
  const { string } = json,
240
278
  context = fileContext, ///
@@ -246,6 +284,20 @@ class Statement {
246
284
  return statement;
247
285
  }
248
286
 
287
+ static fromPremiseNode(premiseNode, fileContext) {
288
+ const node = premiseNode, ///
289
+ statement = statementFromNode(node, fileContext);
290
+
291
+ return statement;
292
+ }
293
+
294
+ static fromProofStepNode(proofStepNode, fileContext) {
295
+ const node = proofStepNode, ///
296
+ statement = statementFromNode(node, fileContext);
297
+
298
+ return statement;
299
+ }
300
+
249
301
  static fromStatementNode(statementNode, context) {
250
302
  let statement = null;
251
303
 
@@ -260,12 +312,23 @@ class Statement {
260
312
  return statement;
261
313
  }
262
314
 
263
- static fromDefinedAssertionNode(definedAssertionNode, context) {
264
- const statementNode = statementNodeQuery(definedAssertionNode),
265
- node = statementNode, ///
266
- tokens = context.nodeAsTokens(node),
267
- string = context.tokensAsString(tokens),
268
- statement = new Statement(string, node, tokens);
315
+ static fromConclusionNode(conclusionNode, fileContext) {
316
+ const node = conclusionNode, ///
317
+ statement = statementFromNode(node, fileContext);
318
+
319
+ return statement;
320
+ }
321
+
322
+ static fromConsequentNode(consequentNode, fileContext) {
323
+ const node = consequentNode, ///
324
+ statement = statementFromNode(node, fileContext);
325
+
326
+ return statement;
327
+ }
328
+
329
+ static fromSuppositionNode(suppositionNode, fileContext) {
330
+ const node = suppositionNode, ///
331
+ statement = statementFromNode(node, fileContext);
269
332
 
270
333
  return statement;
271
334
  }
@@ -279,13 +342,21 @@ class Statement {
279
342
 
280
343
  return statement;
281
344
  }
282
- }
345
+ });
283
346
 
284
- Object.assign(Statement.prototype, unifyMixins);
347
+ function statementFromNode(node, fileContext) {
348
+ let statement = null;
285
349
 
286
- Object.assign(shim, {
287
- Statement
288
- });
350
+ const statementNode = statementNodeQuery(node);
289
351
 
290
- export default Statement;
352
+ if (statementNode !== null) {
353
+ const { Statement } = dom,
354
+ node = statementNode, ///
355
+ tokens = fileContext.nodeAsTokens(node),
356
+ string = fileContext.tokensAsString(tokens);
357
+
358
+ statement = new Statement(string, node, tokens);
359
+ }
291
360
 
361
+ return statement;
362
+ }
@@ -2,15 +2,16 @@
2
2
 
3
3
  import { arrayUtilities } from "necessary";
4
4
 
5
- import shim from "./shim";
5
+ import dom from "../dom";
6
6
 
7
- import { nodesQuery } from "./utilities/query";
7
+ import { nodesQuery } from "../utilities/query";
8
+ import { domAssigned } from "../dom";
8
9
 
9
10
  const { last } = arrayUtilities;
10
11
 
11
12
  const proofStepNodesQuery = nodesQuery("/subDerivation/proofStep|lastProofStep");
12
13
 
13
- class SubDerivation {
14
+ export default domAssigned(class SubDerivation {
14
15
  constructor(proofSteps) {
15
16
  this.proofSteps = proofSteps;
16
17
  }
@@ -29,9 +30,9 @@ class SubDerivation {
29
30
  let verified;
30
31
 
31
32
  verified = this.proofSteps.every((proofStep) => { ///
32
- const proofStepVerified = proofStep.verify(substitutions, context);
33
+ const proofStepVerifiedAndUnified = proofStep.verifyAndUnify(substitutions, context);
33
34
 
34
- if (proofStepVerified) {
35
+ if (proofStepVerifiedAndUnified) {
35
36
  return true;
36
37
  }
37
38
  });
@@ -39,8 +40,10 @@ class SubDerivation {
39
40
  return verified;
40
41
  }
41
42
 
43
+ static name = "SubDerivation";
44
+
42
45
  static fromSubDerivationNode(subDerivationNode, fileContext) {
43
- const { ProofStep } = shim,
46
+ const { ProofStep } = dom,
44
47
  proofStepNodes = proofStepNodesQuery(subDerivationNode),
45
48
  proofSteps = proofStepNodes.map((proofStepNode) => {
46
49
  const proofStep = ProofStep.fromProofStepNode(proofStepNode, fileContext);
@@ -51,10 +54,4 @@ class SubDerivation {
51
54
 
52
55
  return subDerivation;
53
56
  }
54
- }
55
-
56
- Object.assign(shim, {
57
- SubDerivation
58
57
  });
59
-
60
- export default SubDerivation;
@@ -1,20 +1,17 @@
1
1
  "use strict";
2
2
 
3
- import { arrayUtilities } from "necessary";
3
+ import dom from "../dom";
4
+ import LocalContext from "../context/local";
4
5
 
5
- import shim from "./shim";
6
- import LocalContext from "./context/local";
6
+ import { domAssigned } from "../dom";
7
+ import { nodeQuery, nodesQuery } from "../utilities/query";
8
+ import { subproofStringFromSubproofNode } from "../utilities/subproof";
7
9
 
8
- import { unifyStatement } from "./utilities/unification";
9
- import { nodeQuery, nodesQuery } from "./utilities/query";
10
- import { subproofStringFromSubproofNode } from "./utilities/subproof";
11
-
12
- const { match } = arrayUtilities;
13
-
14
- const suppositionNodesQuery = nodesQuery("/subproof/supposition"),
10
+ const subproofNodeQuery = nodeQuery("/proofStep/subproof"),
11
+ suppositionNodesQuery = nodesQuery("/subproof/supposition"),
15
12
  subDerivationNodeQuery = nodeQuery("/subproof/subDerivation");
16
13
 
17
- class Subproof {
14
+ export default domAssigned(class Subproof {
18
15
  constructor(string, suppositions, subDerivation) {
19
16
  this.string = string;
20
17
  this.suppositions = suppositions;
@@ -55,34 +52,6 @@ class Subproof {
55
52
  return statements;
56
53
  }
57
54
 
58
- unifySubproofAssertion(subproofAssertion, substitutions, generalContext, specificContext) {
59
- let subproofAssertionUnified;
60
-
61
- const subproofString = this.string,
62
- subproofAssertionString = subproofAssertion.getString();
63
-
64
- specificContext.trace(`Unifying the '${subproofAssertionString}' subproof assertion with the '${subproofString}' subproof...`);
65
-
66
- const subproofStatements = this.getStatements(),
67
- subproofAssertionStatements = subproofAssertion.getStatements();
68
-
69
- subproofAssertionUnified = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
70
- const generalStatement = subproofAssertionStatement, ///
71
- specificStatement = subproofStatement, ///
72
- statementUnified = unifyStatement(generalStatement, specificStatement, substitutions, generalContext, specificContext);
73
-
74
- if (statementUnified) {
75
- return true;
76
- }
77
- });
78
-
79
- if (subproofAssertionUnified) {
80
- specificContext.trace(`...unified the '${subproofAssertionString}' subproof assertion with the '${subproofString}' subproof.`);
81
- }
82
-
83
- return subproofAssertionUnified;
84
- }
85
-
86
55
  verify(substitutions, context) {
87
56
  let subproofVerified = false;
88
57
 
@@ -109,11 +78,15 @@ class Subproof {
109
78
  return subproofVerified;
110
79
  }
111
80
 
112
- static fromSubproofNode(subproofNode, fileContext) {
81
+ static name = "Subproof";
82
+
83
+ static fromProofStepNode(proofStepNode, fileContext) {
113
84
  let subproof = null;
114
85
 
86
+ const subproofNode = subproofNodeQuery(proofStepNode);
87
+
115
88
  if (subproofNode !== null) {
116
- const { Supposition, SubDerivation } = shim,
89
+ const { Supposition, SubDerivation } = dom,
117
90
  subproofString = subproofStringFromSubproofNode(subproofNode, fileContext),
118
91
  suppositionNodes = suppositionNodesQuery(subproofNode),
119
92
  subDerivationNode = subDerivationNodeQuery(subproofNode),
@@ -130,10 +103,4 @@ class Subproof {
130
103
 
131
104
  return subproof;
132
105
  }
133
- }
134
-
135
- Object.assign(shim, {
136
- Subproof
137
106
  });
138
-
139
- export default Subproof;
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+
3
+ import dom from "../dom";
4
+
5
+ import { domAssigned } from "../dom";
6
+ import { assignAssignments } from "../utilities/assignments";
7
+ import { subproofAssertionFromStatement } from "../utilities/verification";
8
+ import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
9
+
10
+ export default domAssigned(class Supposition {
11
+ constructor(string, statement) {
12
+ this.string = string;
13
+ this.statement = statement;
14
+ }
15
+
16
+ getString() {
17
+ return this.string;
18
+ }
19
+
20
+ getStatement() {
21
+ return this.statement;
22
+ }
23
+
24
+ unifyIndependently(substitutions, generalContext, specificContext) {
25
+ let unifiedIndependently;
26
+
27
+ const statementResolvedIndependently = this.statement.unifyIndependently(substitutions, generalContext, specificContext);
28
+
29
+ unifiedIndependently = statementResolvedIndependently; ///
30
+
31
+ return unifiedIndependently;
32
+ }
33
+
34
+ unifyProofStep(proofStep, substitutions, generalContext, specificContext) {
35
+ let proofStepUnified = false;
36
+
37
+ const subproof = proofStep.getSubproof(),
38
+ statement = proofStep.getStatement();
39
+
40
+ substitutions.snapshot();
41
+
42
+ if (subproof !== null) {
43
+ const subproofUnified = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
44
+
45
+ proofStepUnified = subproofUnified; ///
46
+ }
47
+
48
+ if (statement !== null) {
49
+ const statementUnified = this.unifyStatement(statement, substitutions, generalContext, specificContext);
50
+
51
+ proofStepUnified = statementUnified; ///
52
+ }
53
+
54
+ if (proofStepUnified) {
55
+ substitutions.resolve(generalContext, specificContext);
56
+ }
57
+
58
+ const context = specificContext; ///
59
+
60
+ proofStepUnified ?
61
+ substitutions.continue() :
62
+ substitutions.rollback(context);
63
+
64
+ return proofStepUnified;
65
+ }
66
+
67
+ unifyStatement(statement, substitutions, generalContext, specificContext) {
68
+ let statementUnified;
69
+
70
+ const supposition = this, ///
71
+ suppositionString = supposition.getString(),
72
+ statementString = statement.getString();
73
+
74
+ specificContext.trace(`Unifying the '${statementString}' statement with the '${suppositionString}' supposition...`);
75
+
76
+ statementUnified = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
77
+
78
+ if (statementUnified) {
79
+ specificContext.debug(`...unified the '${statementString}' statement with the '${suppositionString}' supposition.`);
80
+ }
81
+
82
+ return statementUnified;
83
+ }
84
+
85
+ unifySubproof(subproof, substitutions, generalContext, specificContext) {
86
+ let subproofUnified = false;
87
+
88
+ const supposition = this, ///
89
+ subproofString = subproof.getString(),
90
+ suppositionStatement = supposition.getStatement(),
91
+ suppositionStatementString = suppositionStatement.getString();
92
+
93
+ specificContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
94
+
95
+ const context = generalContext,
96
+ subproofAssertion = subproofAssertionFromStatement(this.statement, context);
97
+
98
+ if (subproofAssertion !== null) {
99
+ subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
100
+ }
101
+
102
+ if (subproofUnified) {
103
+ specificContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
104
+ }
105
+
106
+ return subproofUnified;
107
+ }
108
+
109
+ verify(context) {
110
+ let verified = false;
111
+
112
+ const suppositionString = this.string; ///
113
+
114
+ if (this.statement !== null) {
115
+ context.trace(`Verifying the '${suppositionString}' supposition...`);
116
+
117
+ const stated = true,
118
+ assignments = [],
119
+ statementVerified = this.statement.verify(assignments, stated, context);
120
+
121
+ if (statementVerified) {
122
+ const assignmentsAssigned = assignAssignments(assignments, context);
123
+
124
+ if (assignmentsAssigned) {
125
+ const { ProofStep } = dom,
126
+ proofStep = ProofStep.fromStatement(this.statement, context);
127
+
128
+ context.addProofStep(proofStep);
129
+
130
+ verified = true;
131
+ }
132
+ }
133
+
134
+ if (verified) {
135
+ context.debug(`...verified the '${suppositionString}' supposition.`);
136
+ }
137
+ } else {
138
+ context.debug(`Unable to verify the '${suppositionString}' supposition because it is nonsense.`);
139
+ }
140
+
141
+ return verified;
142
+ }
143
+
144
+ toJSON() {
145
+ const statementJSON = statementToStatementJSON(this.statement),
146
+ statement = statementJSON, ///
147
+ json = {
148
+ statement
149
+ };
150
+
151
+ return json;
152
+ }
153
+
154
+ static name = "Supposition";
155
+
156
+ static fromJSON(json, fileContext) {
157
+ const statement = statementFromJSON(json, fileContext),
158
+ string = statement.getString(),
159
+ supposition = new Supposition(string, statement);
160
+
161
+ return supposition;
162
+ }
163
+
164
+ static fromSuppositionNode(suppositionNode, fileContext) {
165
+ const { Statement } = dom,
166
+ statement = Statement.fromSuppositionNode(suppositionNode, fileContext),
167
+ statementString = statement.getString(),
168
+ string = statementString, ///
169
+ supposition = new Supposition(string, statement);
170
+
171
+ return supposition
172
+ }
173
+ });