occam-verify-cli 1.0.956 → 1.0.973

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 (81) hide show
  1. package/lib/context/bounded.js +11 -7
  2. package/lib/context.js +17 -5
  3. package/lib/element/assertion/signature.js +17 -19
  4. package/lib/element/assertion/subproof.js +36 -39
  5. package/lib/element/assertion/type.js +20 -1
  6. package/lib/element/assumption/metaLevel.js +18 -17
  7. package/lib/element/assumption.js +52 -3
  8. package/lib/element/combinator.js +10 -12
  9. package/lib/element/conclusion.js +33 -33
  10. package/lib/element/constructor.js +7 -11
  11. package/lib/element/deduction.js +33 -33
  12. package/lib/element/equivalence.js +11 -7
  13. package/lib/element/hypothesis.js +45 -19
  14. package/lib/element/judgement.js +1 -1
  15. package/lib/element/label.js +9 -11
  16. package/lib/element/proofAssertion/premise.js +98 -87
  17. package/lib/element/proofAssertion/step.js +27 -27
  18. package/lib/element/proofAssertion/supposition.js +99 -88
  19. package/lib/element/proofAssertion.js +3 -3
  20. package/lib/element/reference.js +30 -38
  21. package/lib/element/signature.js +38 -47
  22. package/lib/element/statement.js +18 -58
  23. package/lib/element/substitution/frame.js +34 -42
  24. package/lib/element/substitution/reference.js +12 -13
  25. package/lib/element/substitution/statement.js +26 -31
  26. package/lib/element/substitution/term.js +32 -37
  27. package/lib/element/term.js +2 -2
  28. package/lib/element/topLevelAssertion/axiom.js +33 -34
  29. package/lib/element/topLevelAssertion.js +30 -7
  30. package/lib/element/topLevelMetaAssertion.js +2 -2
  31. package/lib/process/discharge.js +38 -0
  32. package/lib/process/unification.js +228 -0
  33. package/lib/process/unify.js +9 -5
  34. package/lib/process/validation.js +291 -0
  35. package/lib/utilities/context.js +69 -105
  36. package/lib/utilities/element.js +2 -4
  37. package/lib/utilities/string.js +4 -4
  38. package/package.json +1 -1
  39. package/src/context/bounded.js +19 -7
  40. package/src/context.js +26 -6
  41. package/src/element/assertion/signature.js +21 -26
  42. package/src/element/assertion/subproof.js +43 -45
  43. package/src/element/assertion/type.js +30 -1
  44. package/src/element/assumption/metaLevel.js +26 -22
  45. package/src/element/assumption.js +80 -2
  46. package/src/element/combinator.js +11 -14
  47. package/src/element/conclusion.js +38 -37
  48. package/src/element/constructor.js +8 -13
  49. package/src/element/deduction.js +38 -37
  50. package/src/element/equivalence.js +17 -13
  51. package/src/element/hypothesis.js +59 -19
  52. package/src/element/judgement.js +1 -1
  53. package/src/element/label.js +10 -12
  54. package/src/element/proofAssertion/premise.js +123 -107
  55. package/src/element/proofAssertion/step.js +29 -29
  56. package/src/element/proofAssertion/supposition.js +124 -108
  57. package/src/element/proofAssertion.js +2 -2
  58. package/src/element/reference.js +36 -47
  59. package/src/element/signature.js +42 -53
  60. package/src/element/statement.js +18 -89
  61. package/src/element/substitution/frame.js +45 -58
  62. package/src/element/substitution/reference.js +13 -16
  63. package/src/element/substitution/statement.js +27 -34
  64. package/src/element/substitution/term.js +37 -46
  65. package/src/element/term.js +1 -1
  66. package/src/element/topLevelAssertion/axiom.js +43 -45
  67. package/src/element/topLevelAssertion.js +42 -6
  68. package/src/element/topLevelMetaAssertion.js +2 -2
  69. package/src/process/discharge.js +33 -0
  70. package/src/{utilities → process}/unification.js +21 -27
  71. package/src/process/unify.js +9 -5
  72. package/src/{utilities → process}/validation.js +2 -2
  73. package/src/utilities/context.js +77 -128
  74. package/src/utilities/element.js +2 -5
  75. package/src/utilities/string.js +6 -6
  76. package/lib/context/ephemeral.js +0 -28
  77. package/lib/context/synoptic.js +0 -255
  78. package/lib/utilities/unification.js +0 -233
  79. package/lib/utilities/validation.js +0 -291
  80. package/src/context/ephemeral.js +0 -17
  81. package/src/context/synoptic.js +0 -361
@@ -6,7 +6,7 @@ import { define } from "../elements";
6
6
  import { instantiateLabel } from "../process/instantiate";
7
7
  import { labelFromLabelNode, metavariableFromLabelNode } from "../utilities/element";
8
8
  import { breakPointFromJSON, breakPointToBreakPointJSON } from "../utilities/breakPoint";
9
- import { posit, ablate, attempt, serialise, unserialise, instantiate } from "../utilities/context";
9
+ import { attempt, ablate, serialise, unserialise, instantiate } from "../utilities/context";
10
10
 
11
11
  export default define(class Label extends Element {
12
12
  constructor(context, string, node, breakPoint, metavariable) {
@@ -154,8 +154,8 @@ export default define(class Label extends Element {
154
154
  static fromJSON(json, context) {
155
155
  let label;
156
156
 
157
- unserialise((json, context) => {
158
- instantiate((context) => {
157
+ instantiate((context) => {
158
+ unserialise((json, context) => {
159
159
  const { string } = json,
160
160
  labelNode = instantiateLabel(string, context),
161
161
  node = labelNode, ///
@@ -163,8 +163,8 @@ export default define(class Label extends Element {
163
163
  metavariable = metavariableFromLabelNode(labelNode, context);
164
164
 
165
165
  label = new Label(context, string, node, breakPoint, metavariable);
166
- }, context);
167
- }, json, context);
166
+ }, json, context);
167
+ }, context);
168
168
 
169
169
  return label;
170
170
  }
@@ -172,14 +172,12 @@ export default define(class Label extends Element {
172
172
  static fromLabelString(labelString, context) {
173
173
  let label;
174
174
 
175
- posit((context) => {
176
- ablate((context) => {
177
- instantiate((context) => {
178
- const string = labelString, ///
179
- labelNode = instantiateLabel(string, context);
175
+ ablate((context) => {
176
+ instantiate((context) => {
177
+ const string = labelString, ///
178
+ labelNode = instantiateLabel(string, context);
180
179
 
181
- label = labelFromLabelNode(labelNode, context);
182
- }, context);
180
+ label = labelFromLabelNode(labelNode, context);
183
181
  }, context);
184
182
  }, context);
185
183
 
@@ -6,7 +6,7 @@ import { define } from "../../elements";
6
6
  import { instantiatePremise } from "../../process/instantiate";
7
7
  import { procedureCallFromPremiseNode } from "../../utilities/element";
8
8
  import { breakPointFromJSON, breakPointToBreakPointJSON } from "../../utilities/breakPoint";
9
- import { join, declare, attempt, reconcile, serialise, unserialise, instantiate } from "../../utilities/context";
9
+ import { declare, attempt, reconcile, serialise, unserialise, instantiate } from "../../utilities/context";
10
10
 
11
11
  export default define(class Premise extends ProofAssertion {
12
12
  constructor(context, string, node, breakPoint, statement, procedureCall) {
@@ -26,6 +26,31 @@ export default define(class Premise extends ProofAssertion {
26
26
  return premiseNode;
27
27
  }
28
28
 
29
+ getStatementNode() {
30
+ const premiseNode = this.getPremiseNode(),
31
+ statementNode = premiseNode.getStatementNode();
32
+
33
+ return statementNode;
34
+ }
35
+
36
+ findSubproofAssertion() {
37
+ let subproofAssertion = null;
38
+
39
+ const statementNode = this.getStatementNode();
40
+
41
+ if (statementNode !== null) {
42
+ const subproofAssertionNode = statementNode.getSubproofAssertionNode();
43
+
44
+ if (subproofAssertionNode !== null) {
45
+ const context = this.getContext();
46
+
47
+ subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
48
+ }
49
+ }
50
+
51
+ return subproofAssertion;
52
+ }
53
+
29
54
  async verify(context) {
30
55
  let verifies = false;
31
56
 
@@ -39,11 +64,13 @@ export default define(class Premise extends ProofAssertion {
39
64
  procedureCall = this.getProcedureCall();
40
65
 
41
66
  if ((statement !== null) || (procedureCall !== null)) {
42
- const validates = this.validate(context);
67
+ declare((context) => {
68
+ const validates = this.validate(context);
43
69
 
44
- if (validates) {
45
- verifies = true;
46
- }
70
+ if (validates) {
71
+ verifies = true;
72
+ }
73
+ }, context);
47
74
  } else {
48
75
  context.debug(`Unable to validate the '${premiseString}' premise because it is nonsense.`);
49
76
  }
@@ -58,31 +85,29 @@ export default define(class Premise extends ProofAssertion {
58
85
 
59
86
  context.trace(`Validatting the '${premiseString}' premise...`);
60
87
 
61
- declare((context) => {
62
- attempt((context) => {
63
- const statement = this.getStatement(),
64
- procedureCall = this.getProcedureCall();
88
+ attempt((context) => {
89
+ const statement = this.getStatement(),
90
+ procedureCall = this.getProcedureCall();
65
91
 
66
- if (statement !== null) {
67
- const statementValidates = this.validateStatement(context);
92
+ if (statement !== null) {
93
+ const statementValidates = this.validateStatement(context);
68
94
 
69
- if (statementValidates) {
70
- validates = true;
71
- }
95
+ if (statementValidates) {
96
+ validates = true;
72
97
  }
98
+ }
73
99
 
74
- if (procedureCall !== null) {
75
- const procedureCallValidates = this.validateProcedureCall(context);
100
+ if (procedureCall !== null) {
101
+ const procedureCallValidates = this.validateProcedureCall(context);
76
102
 
77
- if (procedureCallValidates) {
78
- validates = true;
79
- }
103
+ if (procedureCallValidates) {
104
+ validates = true;
80
105
  }
106
+ }
81
107
 
82
- if (validates) {
83
- this.commit(context);
84
- }
85
- }, context);
108
+ if (validates) {
109
+ this.commit(context);
110
+ }
86
111
  }, context);
87
112
 
88
113
  if (validates) {
@@ -143,77 +168,60 @@ export default define(class Premise extends ProofAssertion {
143
168
 
144
169
  context.trace(`Unifying the '${premiseString}' premise independently...`);
145
170
 
146
- const statement = this.getStatement(),
147
- procedureCall = this.getProcedureCall();
171
+ await reconcile(async (context) => {
172
+ const statement = this.getStatement(),
173
+ procedureCall = this.getProcedureCall();
148
174
 
149
- if (statement !== null) {
150
- const specificContext = context; ///
175
+ if (statement !== null) {
176
+ const premiseContext = this.getContext(),
177
+ generalContext = premiseContext, ///
178
+ specificContext = context, ///
179
+ statementUnifiesIndependently = statement.unifyIndependently(generalContext, specificContext);
151
180
 
152
- context = this.getContext();
153
-
154
- const generalContext = context; ///
155
-
156
- context = specificContext; ///
157
-
158
- const statementUnifiesIndependently = statement.unifyIndependently(generalContext, specificContext);
159
-
160
- if (statementUnifiesIndependently) {
161
- unifiesIndependently = true;
181
+ if (statementUnifiesIndependently) {
182
+ unifiesIndependently = true;
183
+ }
162
184
  }
163
- }
164
185
 
165
- if (procedureCall !== null) {
166
- const procedureCallResolvedIndependently = await procedureCall.unifyIndependently(context);
186
+ if (procedureCall !== null) {
187
+ const procedureCallResolvedIndependently = await procedureCall.unifyIndependently(context);
167
188
 
168
- if (procedureCallResolvedIndependently) {
169
- unifiesIndependently = true;
189
+ if (procedureCallResolvedIndependently) {
190
+ unifiesIndependently = true;
191
+ }
170
192
  }
171
- }
193
+ }, context);
172
194
 
173
195
  if (unifiesIndependently) {
174
- context.debug(`...unified the '${premiseString}' premise independenly.`);
196
+ context.debug(`...unified the '${premiseString}' premise independently.`);
175
197
  }
176
198
 
177
199
  return unifiesIndependently;
178
200
  }
179
201
 
180
- unifySubproofOrProofAssertion(subproofOrProofAssertion, context) {
181
- let subproofOrProofAssertionUnifies;
202
+ unifySubproof(subproof, context) {
203
+ let subproofUnifies = false;
182
204
 
183
205
  const premiseString = this.getString(), ///
184
- subproofOrProofAssertionString = subproofOrProofAssertion.getString();
206
+ subproofString = subproof.getString();
185
207
 
186
- context.trace(`Unifying the '${subproofOrProofAssertionString}' subproof or proof assertion with the '${premiseString}' premise...`);
208
+ context.trace(`Unifying the '${subproofString}' subproof with the '${premiseString}' premise...`);
187
209
 
188
- const subproofOrProofAssertionProofAssertion = subproofOrProofAssertion.isProofAssertion(),
189
- proofAssertion = subproofOrProofAssertionProofAssertion ?
190
- subproofOrProofAssertion :
191
- null,
192
- subproof = subproofOrProofAssertionProofAssertion ?
193
- null :
194
- subproofOrProofAssertion;
195
-
196
- if (proofAssertion !== null) {
197
- const proofAssertionUnifies = this.unifyProofAssertion(proofAssertion, context);
198
-
199
- if (proofAssertionUnifies) {
200
- subproofOrProofAssertionUnifies = true;
201
- }
202
- }
210
+ const subproofAssertion = this.findSubproofAssertion();
203
211
 
204
- if (subproof !== null) {
205
- const subproofUnifies = this.unifySubproof(subproof, context);
212
+ if (subproofAssertion !== null) {
213
+ const premiseContext = this.getContext(),
214
+ generalContext = premiseContext, ///
215
+ spsecfiicContext = context; ///
206
216
 
207
- if (subproofUnifies) {
208
- subproofOrProofAssertionUnifies = true;
209
- }
217
+ subproofUnifies = subproofAssertion.unifySubproof(subproof, generalContext, spsecfiicContext);
210
218
  }
211
219
 
212
- if (subproofOrProofAssertionUnifies) {
213
- context.debug(`...unified the '${subproofOrProofAssertionString}' subproof or proof assertion with the '${premiseString}' premise.`);
220
+ if (subproofUnifies) {
221
+ context.debug(`...unified the '${subproofString}' subproof with the '${premiseString}' premise.`);
214
222
  }
215
223
 
216
- return subproofOrProofAssertionUnifies;
224
+ return subproofUnifies;
217
225
  }
218
226
 
219
227
  unifyProofAssertion(proofAssertion, context) {
@@ -229,18 +237,16 @@ export default define(class Premise extends ProofAssertion {
229
237
  generalContext = premiseContext, ///
230
238
  specificContext = proofAssertionContext; ///
231
239
 
232
- join((specificContext) => {
233
- reconcile((specificContext) => {
234
- const statement = proofAssertion.getStatement(),
235
- statementUnifies = this.unifyStatement(statement, generalContext, specificContext);
240
+ reconcile((specificContext) => {
241
+ const statement = proofAssertion.getStatement(),
242
+ statementUnifies = this.unifyStatement(statement, generalContext, specificContext);
236
243
 
237
- if (statementUnifies) {
238
- specificContext.commit(context);
244
+ if (statementUnifies) {
245
+ specificContext.commit(context);
239
246
 
240
- proofAssertionUnifies = true;
241
- }
242
- }, specificContext);
243
- }, specificContext, context);
247
+ proofAssertionUnifies = true;
248
+ }
249
+ }, specificContext);
244
250
 
245
251
  if (proofAssertionUnifies) {
246
252
  context.debug(`...unified the '${proofAssertionString}' proof assertion with the '${premiseString}' premise.`);
@@ -249,39 +255,49 @@ export default define(class Premise extends ProofAssertion {
249
255
  return proofAssertionUnifies;
250
256
  }
251
257
 
252
- unifySubproof(subproof, context) {
253
- let subproofUnifies = false;
258
+ unifySubproofOrProofAssertion(subproofOrProofAssertion, context) {
259
+ let subproofOrProofAssertionUnifies;
254
260
 
255
261
  const premiseString = this.getString(), ///
256
- subproofString = subproof.getString();
257
-
258
- context.trace(`Unifying the '${subproofString}' subproof with the '${premiseString}' premise...`);
259
-
260
- const statement = this.getStatement();
261
-
262
- if (statement !== null) {
263
- const statementNode = statement.getNode(),
264
- subproofAssertionNode = statementNode.getSubproofAssertionNode();
262
+ subproofOrProofAssertionString = subproofOrProofAssertion.getString();
265
263
 
266
- if (subproofAssertionNode !== null) {
267
- const specificContext = context; ///
264
+ context.trace(`Unifying the '${subproofOrProofAssertionString}' subproof or proof assertion with the '${premiseString}' premise...`);
268
265
 
269
- context = this.getContext();
266
+ const subproofOrProofAssertionProofAssertion = subproofOrProofAssertion.isProofAssertion(),
267
+ proofAssertion = subproofOrProofAssertionProofAssertion ?
268
+ subproofOrProofAssertion :
269
+ null,
270
+ subproof = subproofOrProofAssertionProofAssertion ?
271
+ null :
272
+ subproofOrProofAssertion;
273
+
274
+ reconcile((context) => {
275
+ if (proofAssertion !== null) {
276
+ const proofAssertionUnifies = this.unifyProofAssertion(proofAssertion, context);
277
+
278
+ if (proofAssertionUnifies) {
279
+ subproofOrProofAssertionUnifies = true;
280
+ }
281
+ }
270
282
 
271
- const generalContext = context, ///
272
- subproofAssertion = context.findAssertionByAssertionNode(subproofAssertionNode);
283
+ if (subproof !== null) {
284
+ const subproofUnifies = this.unifySubproof(subproof, context);
273
285
 
274
- context = specificContext; ///
286
+ if (subproofUnifies) {
287
+ subproofOrProofAssertionUnifies = true;
288
+ }
289
+ }
275
290
 
276
- subproofUnifies = subproofAssertion.unifySubproof(subproof, generalContext, specificContext);
291
+ if (subproofOrProofAssertionUnifies) {
292
+ context.commit();
277
293
  }
278
- }
294
+ }, context);
279
295
 
280
- if (subproofUnifies) {
281
- context.debug(`...unified the '${subproofString}' subproof with the '${premiseString}' premise.`);
296
+ if (subproofOrProofAssertionUnifies) {
297
+ context.debug(`...unified the '${subproofOrProofAssertionString}' subproof or proof assertion with the '${premiseString}' premise.`);
282
298
  }
283
299
 
284
- return subproofUnifies;
300
+ return subproofOrProofAssertionUnifies;
285
301
  }
286
302
 
287
303
  toJSON() {
@@ -313,8 +329,8 @@ export default define(class Premise extends ProofAssertion {
313
329
  static fromJSON(json, context) {
314
330
  let premise;
315
331
 
316
- unserialise((json, context) => {
317
- instantiate((context) => {
332
+ instantiate((context) => {
333
+ unserialise((json, context) => {
318
334
  const { string } = json,
319
335
  premiseNode = instantiatePremise(string, context),
320
336
  node = premiseNode, ///
@@ -323,8 +339,8 @@ export default define(class Premise extends ProofAssertion {
323
339
  procedureCall = procedureCallFromPremiseNode(premiseNode, context);
324
340
 
325
341
  premise = new Premise(context, string, node, breakPoint, statement, procedureCall);
326
- }, context);
327
- }, json, context);
342
+ }, json, context);
343
+ }, context);
328
344
 
329
345
  return premise;
330
346
  }
@@ -7,7 +7,7 @@ import elements from "../../elements";
7
7
  import ProofAssertion from "../proofAssertion";
8
8
 
9
9
  import { define } from "../../elements";
10
- import { unifySteps } from "../../utilities/unification";
10
+ import { unifySteps } from "../../process/unification";
11
11
  import { derive, declare, attempt, reconcile } from "../../utilities/context";
12
12
 
13
13
  const { asyncSome } = asynchronousUtilities,
@@ -98,17 +98,22 @@ export default define(class Step extends ProofAssertion {
98
98
  const statement = this.getStatement();
99
99
 
100
100
  if (statement !== null) {
101
- const validates = this.validate(context);
101
+ const qualified = this.isQualified(),
102
+ stated = qualified; ///
102
103
 
103
- if (validates) {
104
- context = this.getContext();
104
+ await (stated ? declare : derive)(async (context) => {
105
+ const validates = this.validate(context);
106
+
107
+ if (validates) {
108
+ context = this.getContext();
105
109
 
106
- const unifiies = await this.unify(context);
110
+ const unifiies = await this.unify(context);
107
111
 
108
- if (unifiies) {
109
- verifies = true;
112
+ if (unifiies) {
113
+ verifies = true;
114
+ }
110
115
  }
111
- }
116
+ }, context)
112
117
  } else {
113
118
  context.debug(`Unable to verify the '${stepString}' step because it is nonsense.`);
114
119
  }
@@ -127,30 +132,25 @@ export default define(class Step extends ProofAssertion {
127
132
 
128
133
  context.trace(`Validating the '${stepString}' step...`);
129
134
 
130
- const qualified = this.isQualified(),
131
- stated = qualified; ///
132
-
133
- (stated ? declare : derive)((context) => {
134
- attempt((context) => {
135
- const statementValidates = this.validateStatement(context);
135
+ attempt((context) => {
136
+ const statementValidates = this.validateStatement(context);
136
137
 
137
- if (statementValidates) {
138
- const referenceValidates = this.validateReference(context);
138
+ if (statementValidates) {
139
+ const referenceValidates = this.validateReference(context);
139
140
 
140
- if (referenceValidates) {
141
- const signatureAssertionValidates = this.validateSignatureAssertion(context);
141
+ if (referenceValidates) {
142
+ const signatureAssertionValidates = this.validateSignatureAssertion(context);
142
143
 
143
- if (signatureAssertionValidates) {
144
- validates = true;
145
- }
144
+ if (signatureAssertionValidates) {
145
+ validates = true;
146
146
  }
147
147
  }
148
+ }
148
149
 
149
- if (validates) {
150
- this.commit(context);
151
- }
152
- }, context);
153
- }, context)
150
+ if (validates) {
151
+ this.commit(context);
152
+ }
153
+ }, context);
154
154
 
155
155
  if (validates) {
156
156
  context.debug(`...validated the '${stepString}' step.`);
@@ -247,13 +247,13 @@ export default define(class Step extends ProofAssertion {
247
247
  const step = this; ///
248
248
 
249
249
  await asyncSome(unifySteps, async (unifyStep) => {
250
- let statementUnifies;
250
+ let stepUnifies;
251
251
 
252
252
  await reconcile(async (context) => {
253
- statementUnifies = await unifyStep(step, context);
253
+ stepUnifies = await unifyStep(step, context);
254
254
  }, context);
255
255
 
256
- if (statementUnifies) {
256
+ if (stepUnifies) {
257
257
  unifies = true;
258
258
 
259
259
  return true;