occam-verify-cli 1.0.587 → 1.0.602

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 (105) hide show
  1. package/lib/context/ephemeral.js +74 -2
  2. package/lib/context/file/nominal.js +11 -9
  3. package/lib/context/liminal.js +161 -24
  4. package/lib/context/literal.js +8 -2
  5. package/lib/context/scoped.js +4 -28
  6. package/lib/context/synthetic.js +146 -0
  7. package/lib/context.js +170 -1
  8. package/lib/element/assertion/contained.js +21 -15
  9. package/lib/element/assertion/defined.js +45 -65
  10. package/lib/element/assertion/property.js +25 -19
  11. package/lib/element/assertion/satisfies.js +14 -8
  12. package/lib/element/assertion/subproof.js +12 -6
  13. package/lib/element/assertion.js +47 -1
  14. package/lib/element/assumption.js +12 -12
  15. package/lib/element/conclusion.js +2 -2
  16. package/lib/element/deduction.js +2 -2
  17. package/lib/element/frame.js +61 -29
  18. package/lib/element/judgement.js +7 -1
  19. package/lib/element/label.js +8 -8
  20. package/lib/element/metavariable.js +71 -59
  21. package/lib/element/procedureCall.js +24 -8
  22. package/lib/element/proof.js +43 -35
  23. package/lib/element/proofAssertion/premise.js +122 -97
  24. package/lib/element/proofAssertion/step.js +161 -115
  25. package/lib/element/proofAssertion/supposition.js +157 -118
  26. package/lib/element/proofAssertion.js +3 -3
  27. package/lib/element/reference.js +40 -7
  28. package/lib/element/rule.js +227 -95
  29. package/lib/element/signature.js +2 -1
  30. package/lib/element/statement.js +67 -34
  31. package/lib/element/substitution/frame.js +36 -16
  32. package/lib/element/substitution/reference.js +36 -16
  33. package/lib/element/substitution/statement.js +94 -55
  34. package/lib/element/substitution/term.js +36 -16
  35. package/lib/element/substitution.js +54 -17
  36. package/lib/element/substitutions.js +4 -276
  37. package/lib/element/term.js +60 -31
  38. package/lib/element/topLevelAssertion/axiom.js +13 -4
  39. package/lib/element/topLevelAssertion/conjecture.js +7 -2
  40. package/lib/element/topLevelAssertion/theorem.js +7 -2
  41. package/lib/element/topLevelAssertion.js +201 -134
  42. package/lib/element/topLevelMetaAssertion.js +310 -51
  43. package/lib/element/variable.js +15 -6
  44. package/lib/node/substitution/statement.js +33 -1
  45. package/lib/process/unify.js +6 -6
  46. package/lib/utilities/context.js +10 -25
  47. package/lib/utilities/element.js +34 -9
  48. package/lib/utilities/statement.js +1 -8
  49. package/lib/utilities/string.js +12 -1
  50. package/lib/utilities/substitutions.js +42 -16
  51. package/lib/utilities/unification.js +3 -1
  52. package/lib/utilities/validation.js +2 -2
  53. package/package.json +4 -4
  54. package/src/context/ephemeral.js +73 -1
  55. package/src/context/file/nominal.js +14 -11
  56. package/src/context/liminal.js +180 -25
  57. package/src/context/literal.js +3 -1
  58. package/src/context/scoped.js +3 -35
  59. package/src/context/synthetic.js +49 -0
  60. package/src/context.js +163 -1
  61. package/src/element/assertion/contained.js +28 -20
  62. package/src/element/assertion/defined.js +62 -34
  63. package/src/element/assertion/property.js +27 -19
  64. package/src/element/assertion/satisfies.js +15 -7
  65. package/src/element/assertion/subproof.js +13 -5
  66. package/src/element/assertion.js +35 -0
  67. package/src/element/assumption.js +5 -5
  68. package/src/element/conclusion.js +2 -4
  69. package/src/element/deduction.js +2 -4
  70. package/src/element/frame.js +71 -39
  71. package/src/element/judgement.js +2 -0
  72. package/src/element/label.js +4 -4
  73. package/src/element/metavariable.js +94 -75
  74. package/src/element/procedureCall.js +6 -6
  75. package/src/element/proof.js +6 -6
  76. package/src/element/proofAssertion/premise.js +101 -69
  77. package/src/element/proofAssertion/step.js +78 -39
  78. package/src/element/proofAssertion/supposition.js +141 -115
  79. package/src/element/proofAssertion.js +3 -2
  80. package/src/element/reference.js +52 -10
  81. package/src/element/rule.js +138 -76
  82. package/src/element/signature.js +2 -0
  83. package/src/element/statement.js +76 -45
  84. package/src/element/substitution/frame.js +44 -15
  85. package/src/element/substitution/reference.js +44 -15
  86. package/src/element/substitution/statement.js +124 -72
  87. package/src/element/substitution/term.js +43 -15
  88. package/src/element/substitution.js +55 -18
  89. package/src/element/substitutions.js +1 -258
  90. package/src/element/term.js +65 -34
  91. package/src/element/topLevelAssertion/axiom.js +1 -1
  92. package/src/element/topLevelAssertion/conjecture.js +1 -1
  93. package/src/element/topLevelAssertion/theorem.js +1 -1
  94. package/src/element/topLevelAssertion.js +128 -48
  95. package/src/element/topLevelMetaAssertion.js +86 -32
  96. package/src/element/variable.js +15 -5
  97. package/src/node/substitution/statement.js +33 -0
  98. package/src/process/unify.js +6 -8
  99. package/src/utilities/context.js +9 -8
  100. package/src/utilities/element.js +37 -10
  101. package/src/utilities/statement.js +0 -7
  102. package/src/utilities/string.js +14 -0
  103. package/src/utilities/substitutions.js +59 -17
  104. package/src/utilities/unification.js +4 -0
  105. package/src/utilities/validation.js +3 -1
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  import ProofAssertion from "../proofAssertion";
4
- import assignAssignments from "../../process/assign";
5
4
 
6
5
  import { define } from "../../elements";
7
- import { attempt } from "../../utilities/context";
6
+ import { attempt, liminally } from "../../utilities/context";
8
7
  import { statementFromJSON, procedureCallFromJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../../utilities/json";
9
8
 
10
9
  export default define(class Supposition extends ProofAssertion {
@@ -24,161 +23,142 @@ export default define(class Supposition extends ProofAssertion {
24
23
  return stated;
25
24
  }
26
25
 
27
- async verify(context) {
28
- let verifies = false;
29
-
30
- await this.break(context);
26
+ validate(assignments, context) {
27
+ let validates = false;
31
28
 
32
29
  const suppositionString = this.getString(); ///
33
30
 
34
- context.trace(`Verifying the '${suppositionString}' supposition...`);
31
+ context.trace(`Validatting the '${suppositionString}' supposition...`);
35
32
 
36
33
  const statement = this.getStatement(),
37
34
  procedureCall = this.getProcedureCall();
38
35
 
39
- if ((statement !== null) || (procedureCall !== null)) {
40
- attempt((context) => {
41
- if (statement !== null) {
42
- const assignments = [],
43
- statementValidates = this.validateStatement(assignments, context);
36
+ if (false) {
37
+ ///
38
+ } else if (statement !== null) {
39
+ const statementValidates = this.validateStatement(assignments, context);
44
40
 
45
- if (statementValidates) {
46
- const assignmentsAssigned = assignAssignments(assignments, context);
41
+ if (statementValidates) {
42
+ validates = true;
43
+ }
44
+ } else if (procedureCall !== null) {
45
+ const procedureCallValidates = this.validateProcedureCall(assignments, context);
47
46
 
48
- if (assignmentsAssigned) {
49
- const subproofOrProofAssertion = this; ///
47
+ if (procedureCallValidates) {
48
+ validates = true;
49
+ }
50
+ } else {
51
+ context.debug(`Unable to validate the '${suppositionString}' supposition because it is nonsense.`);
52
+ }
50
53
 
51
- context.addSubproofOrProofAssertion(subproofOrProofAssertion);
54
+ if (validates) {
55
+ context.debug(`...validated the '${suppositionString}' supposition.`);
56
+ }
52
57
 
53
- this.setContext(context);
58
+ return validates;
59
+ }
54
60
 
55
- verifies = true;
56
- }
57
- }
58
- }
61
+ validateProcedureCall(assignments, context) {
62
+ let procedureCallValidates = false;
59
63
 
60
- if (procedureCall !== null) {
61
- const procedureCallValidates = procedureCall.validate(context);
64
+ const suppositionString = this.getString(), ///
65
+ procedureCallString = this.procedureCall.getString();
62
66
 
63
- if (procedureCallValidates) {
64
- this.setContext(context);
67
+ context.trace(`Validatting the '${suppositionString}' supposition's '${procedureCallString}' procedure call...`);
65
68
 
66
- verifies = true;
67
- }
68
- }
69
- }, context);
70
- } else {
71
- context.debug(`Unable to verify the '${suppositionString}' supposition because it is nonsense.`);
72
- }
69
+ procedureCallValidates = this.procedureCall.validate(context);
73
70
 
74
- if (verifies) {
75
- context.debug(`...verified the '${suppositionString}' supposition.`);
71
+ if (procedureCallValidates) {
72
+ context.debug(`...validated the '${suppositionString}' supposition's '${procedureCallString}' procedure call.`);
76
73
  }
77
74
 
78
- return verifies;
75
+ return procedureCallValidates;
79
76
  }
80
77
 
81
- unifyIndependently(substitutions, context) {
82
- let unifiesIndependently = false;
78
+ unifySupposition(supposition, generalContext, specificContext) {
79
+ let suppositionUnifies;
83
80
 
84
- const suppositionString = this.getString(); ///
81
+ const context = specificContext, ///
82
+ specificSupposition = supposition, ///
83
+ generalSuppositionString = this.getString(), ///
84
+ specificSuppositionString = specificSupposition.getString();
85
85
 
86
- context.trace(`Unifying the '${suppositionString}' supposition independently...`);
86
+ context.trace(`Unifying the '${specificSuppositionString}' supposition with the '${generalSuppositionString}' supposition...`);
87
87
 
88
- const statement = this.getStatement();
88
+ const statement = specificSupposition.getStatement(),
89
+ statementUnifies = this.unifyStatement(statement, generalContext, specificContext);
89
90
 
90
- if (statement !== null) {
91
- const statementUnifiesIndependently = statement.unifyIndependently(context);
91
+ suppositionUnifies = statementUnifies; ///
92
92
 
93
- if (statementUnifiesIndependently) {
94
- unifiesIndependently = true;
95
- }
93
+ if (suppositionUnifies) {
94
+ context.debug(`...unified the '${specificSuppositionString}' supposition with the '${generalSuppositionString}' supposition.`);
96
95
  }
97
96
 
98
- if (this.procedureCall !== null) {
99
- const procedureCallResolvedIndependently = this.procedureCall.unifyIndependently(context);
100
-
101
- if (procedureCallResolvedIndependently) {
102
- unifiesIndependently = true;
103
- }
104
- }
97
+ return suppositionUnifies;
98
+ }
105
99
 
106
- if (unifiesIndependently) {
107
- context.debug(`...unified the '${suppositionString}' supposition independenly.`);
108
- }
100
+ unifySubproofOrProofAssertion(subproofOrProofAssertion, context) {
101
+ let subproofOrProofAssertionUnifies;
109
102
 
110
- return unifiesIndependently;
111
- }
103
+ const suppositionString = this.getString(), ///
104
+ subproofOrProofAssertionString = subproofOrProofAssertion.getString();
112
105
 
113
- unifySubproofOrProosAssertion(subproofOrProofAssertion, substitutions, context) {
114
- let subproofOrProofAssertionUnifies = false;
106
+ context.trace(`Unifying the '${subproofOrProofAssertionString}' subproof or proof assertion with the '${suppositionString}' supposition...`);
115
107
 
116
108
  const subproofOrProofAssertionProofAssertion = subproofOrProofAssertion.isProofAssertion(),
117
- subproof = subproofOrProofAssertionProofAssertion ?
118
- null :
119
- subproofOrProofAssertion,
120
- proofAssertion = subproofOrProofAssertionProofAssertion ?
121
- subproofOrProofAssertion :
122
- null;
123
-
124
- substitutions.snapshot(context);
109
+ proofAssertion = subproofOrProofAssertionProofAssertion ?
110
+ subproofOrProofAssertion :
111
+ null,
112
+ subproof = subproofOrProofAssertionProofAssertion ?
113
+ null :
114
+ subproofOrProofAssertion;
125
115
 
126
- if (subproof !== null) {
127
- const subproofUnifies = this.unifySubproof(subproof, substitutions, context);
116
+ if (proofAssertion !== null) {
117
+ const proofAssertionUnifies = this.unifyProofAssertion(proofAssertion, context);
128
118
 
129
- if (subproofUnifies) {
119
+ if (proofAssertionUnifies) {
130
120
  subproofOrProofAssertionUnifies = true;
131
121
  }
132
122
  }
133
123
 
134
- if (proofAssertion !== null) {
135
- const proofAssertionUnifies = this.unifyProofAssertion(proofAssertion, substitutions, context);
124
+ if (subproof !== null) {
125
+ const subproofUnifies = this.unifySubproof(subproof, context);
136
126
 
137
- if (proofAssertionUnifies) {
127
+ if (subproofUnifies) {
138
128
  subproofOrProofAssertionUnifies = true;
139
129
  }
140
130
  }
141
131
 
142
132
  if (subproofOrProofAssertionUnifies) {
143
- substitutions.resolve(context);
133
+ context.debug(`...unified the '${subproofOrProofAssertionString}' subproof or proof assertion with the '${suppositionString}' supposition.`);
144
134
  }
145
135
 
146
- subproofOrProofAssertionUnifies ?
147
- substitutions.continue(context) :
148
- substitutions.rollback(context);
149
-
150
136
  return subproofOrProofAssertionUnifies;
151
137
  }
152
138
 
153
- unifyProofAssertion(proofAssertion, substitutions, context) {
154
- let proofAssertionUnifies = false;
139
+ unifyProofAssertion(proofAssertion, context) {
140
+ let proofAssertionUnifies;
155
141
 
156
142
  const suppositionString = this.getString(), ///
157
143
  proofAssertionString = proofAssertion.getString();
158
144
 
159
145
  context.trace(`Unifying the '${proofAssertionString}' proof assertion with the '${suppositionString}' supposition...`);
160
146
 
161
- const specificContext = context; ///
162
-
163
- context = this.getContext();
164
-
165
- const generalContext = context; ///
166
-
167
- context = specificContext; ///
147
+ const proofAssertionContext = proofAssertion.getContext(),
148
+ suppositionContext = this.getContext(),
149
+ generalContext = suppositionContext, ///
150
+ specificContext = proofAssertionContext; ///
168
151
 
169
- debugger
152
+ proofAssertionUnifies = liminally((specificContext) => {
153
+ const statement = proofAssertion.getStatement(),
154
+ statementUnifies = this.unifyStatement(statement, generalContext, specificContext);
170
155
 
171
- // const proofAssertionContext = proofAssertion.getContext(),
172
- // statementUnifies = synthetically((specificContext) => {
173
- // const statement = proofAssertion.getStatement(),
174
- // statementUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
175
- //
176
- // return statementUnifies;
177
- // }, specificContext, proofAssertionContext);
156
+ if (statementUnifies) {
157
+ specificContext.commit(context);
178
158
 
179
- if (statementUnifies) {
180
- proofAssertionUnifies = true;
181
- }
159
+ return true;
160
+ }
161
+ }, specificContext);
182
162
 
183
163
  if (proofAssertionUnifies) {
184
164
  context.debug(`...unified the '${proofAssertionString}' proof assertion with the '${suppositionString}' supposition.`);
@@ -187,11 +167,11 @@ export default define(class Supposition extends ProofAssertion {
187
167
  return proofAssertionUnifies;
188
168
  }
189
169
 
190
- unifySubproof(subproof, substitutions, context) {
170
+ unifySubproof(subproof, context) {
191
171
  let subproofUnifies = false;
192
172
 
193
- const subproofString = subproof.getString(),
194
- suppositionString = this.getString(); ///
173
+ const suppositionString = this.getString(),
174
+ subproofString = subproof.getString();
195
175
 
196
176
  context.trace(`Unifying the '${subproofString}' subproof with the '${suppositionString}' supposition...`);
197
177
 
@@ -229,26 +209,71 @@ export default define(class Supposition extends ProofAssertion {
229
209
  return subproofUnifies;
230
210
  }
231
211
 
232
- unifySupposition(supposition, substitutions, generalContext, specificContext) {
233
- let suppositionUnifies;
212
+ async verify(assignments, context) {
213
+ let verifies = false;
234
214
 
235
- const context = specificContext, ///
236
- specificSupposition = supposition, ///
237
- generalSuppositionString = this.getString(), ///
238
- specificSuppositionString = specificSupposition.getString();
215
+ await this.break(context);
239
216
 
240
- context.trace(`Unifying the '${specificSuppositionString}' supposition with the '${generalSuppositionString}' supposition...`);
217
+ const suppositionString = this.getString(); ///
241
218
 
242
- const statement = specificSupposition.getStatement(),
243
- statementUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
219
+ context.trace(`Verifying the '${suppositionString}' supposition...`);
244
220
 
245
- suppositionUnifies = statementUnifies; ///
221
+ attempt((context) => {
222
+ const validates = this.validate(assignments, context);
246
223
 
247
- if (suppositionUnifies) {
248
- context.debug(`...unified the '${specificSuppositionString}' supposition with the '${generalSuppositionString}' supposition.`);
224
+ if (validates) {
225
+ this.setContext(context);
226
+
227
+ verifies = true;
228
+ }
229
+ }, context);
230
+
231
+ if (verifies) {
232
+ context.debug(`...verified the '${suppositionString}' supposition.`);
249
233
  }
250
234
 
251
- return suppositionUnifies;
235
+ return verifies;
236
+ }
237
+
238
+ async unifyIndependently(context) {
239
+ let unifiesIndependently = false;
240
+
241
+ const suppositionString = this.getString(); ///
242
+
243
+ context.trace(`Unifying the '${suppositionString}' supposition independently...`);
244
+
245
+ const statement = this.getStatement(),
246
+ procedureCall = this.getProcedureCall();
247
+
248
+ if (statement !== null) {
249
+ const specificContext = context; ///
250
+
251
+ context = this.getContext();
252
+
253
+ const generalContext = context; ///
254
+
255
+ context = specificContext; ///
256
+
257
+ const statementUnifiesIndependently = statement.unifyIndependently(generalContext, specificContext);
258
+
259
+ if (statementUnifiesIndependently) {
260
+ unifiesIndependently = true;
261
+ }
262
+ }
263
+
264
+ if (procedureCall !== null) {
265
+ const procedureCallResolvedIndependently = await procedureCall.unifyIndependently(context);
266
+
267
+ if (procedureCallResolvedIndependently) {
268
+ unifiesIndependently = true;
269
+ }
270
+ }
271
+
272
+ if (unifiesIndependently) {
273
+ context.debug(`...unified the '${suppositionString}' supposition independenly.`);
274
+ }
275
+
276
+ return unifiesIndependently;
252
277
  }
253
278
 
254
279
  toJSON() {
@@ -287,3 +312,4 @@ export default define(class Supposition extends ProofAssertion {
287
312
  return supposition;
288
313
  }
289
314
  });
315
+
@@ -65,7 +65,7 @@ export default class ProofAssertion extends Element {
65
65
  return statementValidates;
66
66
  }
67
67
 
68
- unifyStatement(statement, substitutions, generalContext, specificContext) {
68
+ unifyStatement(statement, generalContext, specificContext) {
69
69
  let statementUnifies = false;
70
70
 
71
71
  if (this.statement !== null) {
@@ -74,7 +74,8 @@ export default class ProofAssertion extends Element {
74
74
  proofAssertionString = this.getString(); ///
75
75
 
76
76
  context.trace(`Unifying the '${statementString}' statement with the '${proofAssertionString}' proof assertion...`);
77
- statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
77
+
78
+ statementUnifies = this.statement.unifyStatement(statement, generalContext, specificContext);
78
79
 
79
80
  if (statementUnifies) {
80
81
  context.debug(`...unified the '${statementString}' statement with the '${proofAssertionString}' proof assertion.`);
@@ -34,15 +34,37 @@ export default define(class Reference extends Element {
34
34
  return metavariableNode;
35
35
  }
36
36
 
37
- isMetavariableEqualToMetavariable(metavariable) { return this.metavariable.isEqualTo(metavariable); }
37
+ getReferenceNode() {
38
+ const node = this.getNode(),
39
+ assertionNode = node; ///
38
40
 
39
- isEqualTo(reference) {
40
- const referenceA = this, ///
41
- referenceB = reference, ///
42
- referenceANode = referenceA.getNode(),
43
- referenceBNode = referenceB.getNode(),
44
- referenceANodeMatchesReferenceBNode = referenceANode.match(referenceBNode),
45
- equalTo = referenceANodeMatchesReferenceBNode; ///
41
+ return assertionNode;
42
+ }
43
+
44
+ matchReferenceNode(assertionNode) {
45
+ const assertionNodeA = assertionNode; ///
46
+
47
+ assertionNode = this.getReferenceNode();
48
+
49
+ const assertionNodeB = assertionNode, ///
50
+ assertionNodeAAMatchesReferenceBNodeB = assertionNodeA.match(assertionNodeB),
51
+ equalTo = assertionNodeAAMatchesReferenceBNodeB; ///
52
+
53
+ return equalTo;
54
+ }
55
+
56
+ isValid(context) {
57
+ const assertionNode = this.getReferenceNode(),
58
+ assertionPresent = context.isReferencePresentByReferenceNode(assertionNode),
59
+ valid = assertionPresent; ///
60
+
61
+ return valid;
62
+ }
63
+
64
+ isEqualTo(assertion) {
65
+ const assertionNode = assertion.getNode(),
66
+ assertionNodeMatches = this.matchReferenceNode(assertionNode),
67
+ equalTo = assertionNodeMatches; ///
46
68
 
47
69
  return equalTo;
48
70
  }
@@ -63,6 +85,26 @@ export default define(class Reference extends Element {
63
85
  return comparesToParamter;
64
86
  }
65
87
 
88
+ compareMetavariable(metavariable) {
89
+ let metavaraibleComparseTo = false;
90
+
91
+ let metavariableName;
92
+
93
+ metavariableName = this.metavariable.getName();
94
+
95
+ const metavariableNameA = metavariableName ///
96
+
97
+ metavariableName = metavariable.getName();
98
+
99
+ const metavariableNameB = metavariableName; ///
100
+
101
+ if (metavariableNameA === metavariableNameB) {
102
+ metavaraibleComparseTo = true;
103
+ }
104
+
105
+ return metavaraibleComparseTo;
106
+ }
107
+
66
108
  compareMetavariableName(metavariableName) { return this.metavariable.compareMetavariableName(metavariableName); }
67
109
 
68
110
  matchMetavariableNode(metavariableNode) { return this.metavariable.matchNode(metavariableNode); }
@@ -105,7 +147,7 @@ export default define(class Reference extends Element {
105
147
  validateMetavariable(context) {
106
148
  let metavariableValidates = false;
107
149
 
108
- const referenceString = this.getString(),
150
+ const referenceString = this.getString(), ///
109
151
  metavariableString = this.metavariable.getString();
110
152
 
111
153
  context.trace(`Validating the '${referenceString}' reference's '${metavariableString}' metavariable....'`);
@@ -131,7 +173,7 @@ export default define(class Reference extends Element {
131
173
  validateAsMetavariable(context) {
132
174
  let validatesAsMetavariable = false;
133
175
 
134
- const referenceString = this.getString();
176
+ const referenceString = this.getString(); ///
135
177
 
136
178
  context.trace(`Validating the '${referenceString}' reference as a metavaraible...`);
137
179