occam-verify-cli 1.0.913 → 1.0.919

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.
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
 
3
- import { arrayUtilities } from "necessary";
4
-
5
3
  import TopLevelAssertion from "../topLevelAssertion";
6
4
 
7
5
  import { define } from "../../elements";
8
-
9
- const { backwardsEvery } = arrayUtilities;
6
+ import supposition from "../proofAssertion/supposition";
10
7
 
11
8
  export default define(class Axiom extends TopLevelAssertion {
12
9
  getAxiomNode() {
@@ -73,149 +70,6 @@ export default define(class Axiom extends TopLevelAssertion {
73
70
  return signatureVerifies;
74
71
  }
75
72
 
76
- unifyStep(step, context) {
77
- let stepUnifies = false;
78
-
79
- context = step.getContext();
80
-
81
- const stepString = step.getString(),
82
- axiomString = this.getString();
83
-
84
- context.trace(`Unifying the '${stepString}' step with the '${axiomString}' axiom...`);
85
-
86
- const unconditional = this.isUnconditional();
87
-
88
- if (!unconditional) {
89
- context.trace(`Unable to unify the '${stepString}' step with the '${axiomString}' axiom because the axiom is not unconditional.`);
90
- } else {
91
- const statement = step.getStatement(),
92
- statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, context);
93
-
94
- if (statementUnifiesWithDeduction) {
95
- stepUnifies = true;
96
- }
97
- }
98
-
99
- if (stepUnifies) {
100
- context.debug(`...unified the '${stepString}' step with the '${axiomString}' axiom.`);
101
- }
102
-
103
- return stepUnifies;
104
- }
105
-
106
- unifySubproof(subproof, context) {
107
- let subproofUnifies = false;
108
-
109
- const axiomString = this.getString(), ///
110
- subproofString = subproof.getString();
111
-
112
- context.trace(`Unifying the '${subproofString}' subproof with the '${axiomString}' axiom...`);
113
-
114
- const unconditional = this.isUnconditional();
115
-
116
- if (unconditional) {
117
- context.trace(`Unable to unify the '${subproofString}' subproof with the '${axiomString}' axiom because the axiom is unconditional.`);
118
- } else {
119
- const lastStep = subproof.getLastStep(),
120
- lastStepUnifies = this.unifyLastStep(lastStep, context);
121
-
122
- if (lastStepUnifies) {
123
- const suppositions = subproof.getSuppositions(),
124
- suppositionsUnify = this.unifySuppositions(suppositions, context);
125
-
126
- if (suppositionsUnify) {
127
- subproofUnifies = true;
128
- }
129
- }
130
- }
131
-
132
- if (subproofUnifies) {
133
- context.debug(`...unified the '${subproofString}' subproof with the '${axiomString}' axiom.`);
134
- }
135
-
136
- return subproofUnifies;
137
- }
138
-
139
- unifyDeduction(deduction, generalContext, specificContext) {
140
- let deductionUnifies;
141
-
142
- const specificDeduction = deduction; ///
143
-
144
- deduction = this.getDeduction();
145
-
146
- const generalDeduction = deduction; ///
147
-
148
- deduction = specificDeduction; ///
149
-
150
- deductionUnifies = generalDeduction.unifyDeduction(deduction, generalContext, specificContext);
151
-
152
- return deductionUnifies;
153
- }
154
-
155
- unifySupposition(supposition, index, generalContext, specificContext) {
156
- let suppositionUnifies;
157
-
158
- const specificSupposition = supposition; ///
159
-
160
- supposition = this.getSupposition(index);
161
-
162
- const generalSupposition = supposition; ///
163
-
164
- supposition = specificSupposition; ///
165
-
166
- suppositionUnifies = generalSupposition.unifySupposition(supposition, generalContext, specificContext);
167
-
168
- return suppositionUnifies;
169
- }
170
-
171
- unifySuppositions(suppositions, generalContext, specificContext) {
172
- let suppositionsUnify = false;
173
-
174
- const specificSuppositions = suppositions; ///
175
-
176
- suppositions = this.getSuppositions();
177
-
178
- const generalSuppositions = suppositions, ///
179
- generalSuppositionsLength = generalSuppositions.length,
180
- specificSuppositionsLength = specificSuppositions.length;
181
-
182
- if (generalSuppositionsLength === specificSuppositionsLength) {
183
- suppositions = specificSuppositions; ///
184
-
185
- suppositionsUnify = backwardsEvery(suppositions, (supposition, index) => {
186
- const suppositionUnifies = this.unifySupposition(supposition, index, generalContext, specificContext);
187
-
188
- if (suppositionUnifies) {
189
- return true;
190
- }
191
- });
192
- }
193
-
194
- return suppositionsUnify;
195
- }
196
-
197
- unifyLastStep(lastStep, context) {
198
- let lastStepUnifies = false;
199
-
200
- const axiomString = this.getString(), ///
201
- lastStepString = lastStep.getString();
202
-
203
- context.trace(`Unifying the '${lastStepString}' last step with the '${axiomString}' axiom...`);
204
-
205
- const statement = lastStep.getStatement(),
206
- statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, context);
207
-
208
- if (statementUnifiesWithDeduction) {
209
- lastStepUnifies = true;
210
- }
211
-
212
- if (lastStepUnifies) {
213
- context.debug(`...unified the '${lastStepString}' last step with the '${axiomString}' axiom.`);
214
- }
215
-
216
- return lastStepUnifies;
217
- }
218
-
219
73
  unifySignature(signature, context) {
220
74
  let signatureUnifies;
221
75
 
@@ -228,9 +82,11 @@ export default define(class Axiom extends TopLevelAssertion {
228
82
 
229
83
  signature = this.getSignature();
230
84
 
231
- const generalSignature = signature; ///
85
+ const generalSignature = signature, ///
86
+ specificContext = context, ///
87
+ generalContext = null;
232
88
 
233
- signatureUnifies = generalSignature.unifySignature(specificSignature, context);
89
+ signatureUnifies = generalSignature.unifySignature(specificSignature, generalContext, specificContext);
234
90
 
235
91
  if (signatureUnifies) {
236
92
  context.debug(`...unified the '${signatureString}' signature with the '${axiomString}' axiom.`);
@@ -239,40 +95,40 @@ export default define(class Axiom extends TopLevelAssertion {
239
95
  return signatureUnifies;
240
96
  }
241
97
 
242
- unifyTopLevelAssertion(topLevelAssertion, context) {
243
- let topLevelAssertionUnifies = false;
98
+ async unifyDeduction(deduction, context) {
99
+ let deductionUnifies;
244
100
 
245
- const axiomString = this.getString(), ///
246
- topLevelAssertionString = topLevelAssertion.getString();
101
+ await this.break(context);
247
102
 
248
- context.trace(`Unifying the '${topLevelAssertionString}' top level assertion with the '${axiomString}' axiom...`);
103
+ const asiomString = this.getString(), ///,
104
+ deductionString = deduction.getString();
249
105
 
250
- const hypothesesCorrelate = topLevelAssertion.correlateHypotheses(context);
106
+ context.trace(`Unifying the '${deductionString}' deduction with the '${asiomString}' axiom's deduction...`);
251
107
 
252
- if (hypothesesCorrelate) {
253
- const specificContext = context; ///
108
+ deductionUnifies = this.deduction.unifyDeduction(deduction, context);
254
109
 
255
- context = this.getContext();
110
+ if (deductionUnifies) {
111
+ context.debug(`...unified the '${deductionString}' deduction with the '${asiomString}' axiom's deduction.`);
112
+ }
256
113
 
257
- const generalContext = context; ///
114
+ return deductionUnifies;
115
+ }
258
116
 
259
- context = specificContext; ///
117
+ async unifyTopLevelAssertion(topLevelAssertion, context) {
118
+ let topLevelAssertionUnifies = false;
260
119
 
261
- const deduction = topLevelAssertion.getDeduction(),
262
- deductionUnifies = this.unifyDeduction(deduction, generalContext, specificContext);
120
+ const deduction = topLevelAssertion.getDeduction(),
121
+ deductionUnifies = await this.unifyDeduction(deduction, context);
263
122
 
264
- if (deductionUnifies) {
265
- const suppositions = topLevelAssertion.getSuppositions(),
266
- suppositionsUnify = this.unifySuppositions(suppositions, generalContext, specificContext);
123
+ if (deductionUnifies) {
124
+ const suppositions = topLevelAssertion.getSuppositions(),
125
+ suppositionsUnify = await this.unifySuppositions(suppositions, context);
267
126
 
268
- topLevelAssertionUnifies = suppositionsUnify; ///
127
+ if (suppositionsUnify) {
128
+ topLevelAssertionUnifies = true;
269
129
  }
270
130
  }
271
131
 
272
- if (topLevelAssertionUnifies) {
273
- context.debug(`...unified the '${topLevelAssertionString}' top level assertion with the '${axiomString}' axiom.`);
274
- }
275
-
276
132
  return topLevelAssertionUnifies;
277
133
  }
278
134
 
@@ -16,7 +16,7 @@ import { labelsFromJSON,
16
16
  hypothesesToHypothesesJSON,
17
17
  suppositionsToSuppositionsJSON } from "../utilities/json";
18
18
 
19
- const { reverse, correlate } = arrayUtilities,
19
+ const { reverse } = arrayUtilities,
20
20
  { asyncExtract, asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
21
21
 
22
22
  export default class TopLevelAssertion extends Element {
@@ -91,35 +91,6 @@ export default class TopLevelAssertion extends Element {
91
91
  return metavariableNodeMatches;
92
92
  }
93
93
 
94
- correlateHypotheses(context) {
95
- let correlatesToHypotheses;
96
-
97
- const hypothetical = this.isHypothetical();
98
-
99
- if (hypothetical) {
100
- const proofAssertions = context.getProofAssertions(),
101
- topLevelAssertionString = this.getString(); ///
102
-
103
- context.trace(`Correlating the hypotheses of the '${topLevelAssertionString}' top level assertion...`);
104
-
105
- correlatesToHypotheses = correlate(this.hypotheses, proofAssertions, (hypothesis, proofAssertion) => {
106
- const hypothesesComparesToStep = hypothesis.compareProofAssertion(proofAssertion, context);
107
-
108
- if (hypothesesComparesToStep) {
109
- return true;
110
- }
111
- });
112
-
113
- if (correlatesToHypotheses) {
114
- context.debug(`...correlated the hypotheses of the '${topLevelAssertionString}' top level assertion.`);
115
- }
116
- } else {
117
- correlatesToHypotheses = true
118
- }
119
-
120
- return correlatesToHypotheses;
121
- }
122
-
123
94
  async verify(context) {
124
95
  let verifies = false;
125
96
 
@@ -285,19 +256,18 @@ export default class TopLevelAssertion extends Element {
285
256
  await this.break(context);
286
257
 
287
258
  const stepString = step.getString(),
288
- deductionString = this.deduction.getString(),
289
259
  topLevelAssertionString = this.getString(); ///
290
260
 
291
- context.trace(`Unifying the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction...`);
261
+ context.trace(`Unifying the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's deduction...`);
292
262
 
293
- const stepUnifies = await this.deduction.unifyStep(step, context);
263
+ const stepUnifies = this.deduction.unifyStep(step, context);
294
264
 
295
265
  if (stepUnifies) {
296
266
  stepUnifiesWithDeduction = true;
297
267
  }
298
268
 
299
269
  if (stepUnifiesWithDeduction) {
300
- context.debug(`...unified the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction.`);
270
+ context.debug(`...unified the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's deduction.`);
301
271
  }
302
272
 
303
273
  return stepUnifiesWithDeduction;
@@ -306,20 +276,16 @@ export default class TopLevelAssertion extends Element {
306
276
  async unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context) {
307
277
  let stepAndSubproofOrProofAssertionsUnify = false;
308
278
 
309
- const correlatesToHypotheses = this.correlateHypotheses(context);
310
-
311
- if (correlatesToHypotheses) {
312
- const stepUnifiesWithDeduction = await this.unifyStepWithDeduction(step, context);
279
+ const stepUnifiesWithDeduction = await this.unifyStepWithDeduction(step, context);
313
280
 
314
- if (stepUnifiesWithDeduction) {
315
- const subproofOrProofAssertionsUnifiesWithSuppositions = await this.unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, context);
281
+ if (stepUnifiesWithDeduction) {
282
+ const subproofOrProofAssertionsUnifiesWithSuppositions = await this.unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, context);
316
283
 
317
- if (subproofOrProofAssertionsUnifiesWithSuppositions) {
318
- const derivedSubstitutionsResolved = context.areDerivedSubstitutionsResolved();
284
+ if (subproofOrProofAssertionsUnifiesWithSuppositions) {
285
+ const derivedSubstitutionsResolved = context.areDerivedSubstitutionsResolved();
319
286
 
320
- if (derivedSubstitutionsResolved) {
321
- stepAndSubproofOrProofAssertionsUnify = true;
322
- }
287
+ if (derivedSubstitutionsResolved) {
288
+ stepAndSubproofOrProofAssertionsUnify = true;
323
289
  }
324
290
  }
325
291
  }
@@ -29,16 +29,16 @@ export default class StepNode extends ProofAssertionNode {
29
29
  return referenceNode;
30
30
  }
31
31
 
32
- getSatisfiedAssertionNode() {
33
- let satisfiedAssertionNode = null;
32
+ getSignatureAssertionNode() {
33
+ let signatureAssertionNode = null;
34
34
 
35
35
  const qualificationNode = this.getQualificationNode();
36
36
 
37
37
  if (qualificationNode !== null) {
38
- satisfiedAssertionNode = qualificationNode.getSatisfiedAssertionNode();
38
+ signatureAssertionNode = qualificationNode.getSignatureAssertionNode();
39
39
  }
40
40
 
41
- return satisfiedAssertionNode;
41
+ return signatureAssertionNode;
42
42
  }
43
43
 
44
44
  getQualificationNode() {
@@ -12,11 +12,11 @@ export default class QualificationNode extends NonTerminalNode {
12
12
  return referenceNode;
13
13
  }
14
14
 
15
- getSatisfiedAssertionNode() {
15
+ getSignatureAssertionNode() {
16
16
  const ruleName = SIGNATURE_ASSERTION_RULE_NAME,
17
- satisfiedAssertionNode = this.getNodeByRuleName(ruleName);
17
+ signatureAssertionNode = this.getNodeByRuleName(ruleName);
18
18
 
19
- return satisfiedAssertionNode;
19
+ return signatureAssertionNode;
20
20
  }
21
21
 
22
22
  static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(QualificationNode, ruleName, childNodes, opacity, precedence); }
@@ -135,11 +135,11 @@ export default class StatementNode extends NonTerminalNode {
135
135
  return containedAssertionNode;
136
136
  }
137
137
 
138
- getSatisfiedAssertionNode() {
138
+ getSignatureAssertionNode() {
139
139
  const ruleName = SIGNATURE_ASSERTION_RULE_NAME,
140
- satisfiedAssertionNode = this.getNodeByRuleName(ruleName);
140
+ signatureAssertionNode = this.getNodeByRuleName(ruleName);
141
141
 
142
- return satisfiedAssertionNode;
142
+ return signatureAssertionNode;
143
143
  }
144
144
 
145
145
  getSingularMetavariableNode() {
@@ -13,13 +13,14 @@ const typeNodeQuery = nodeQuery("/type"),
13
13
  termNodeQuery = nodeQuery("/term"),
14
14
  frameNodeQuery = nodeQuery("/frame"),
15
15
  metaTypeNodeQuery = nodeQuery("/metaType"),
16
+ signatureNodeQuery = nodeQuery("/signature"),
16
17
  statementNodeQuery = nodeQuery("/statement"),
17
18
  termVariableNodeQuery = nodeQuery("/term/variable!"),
18
19
  frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
19
20
  statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
20
21
  assumptionMetavariableNodeQuery = nodeQuery("/assumption/metavariable!");
21
22
 
22
- class StatementPass extends ZipPassBase {
23
+ class MetaLevelPass extends ZipPassBase {
23
24
  static maps = [
24
25
  {
25
26
  generalNodeQuery: assumptionMetavariableNodeQuery,
@@ -141,6 +142,30 @@ class StatementPass extends ZipPassBase {
141
142
  success = true;
142
143
  }
143
144
 
145
+ return success;
146
+ }
147
+ },
148
+ {
149
+ generalNodeQuery: signatureNodeQuery,
150
+ specificNodeQuery: signatureNodeQuery,
151
+ run: (generalSignatureNode, specificSignatureNode, generalContext, specificContext) => {
152
+ let success = false;
153
+
154
+ let context;
155
+
156
+ context = generalContext; ///
157
+
158
+ const generalSignature = context.findSignatureBySignatureNode(generalSignatureNode);
159
+
160
+ context = specificContext; ///
161
+
162
+ const specificSignature = context.findSignatureBySignatureNode(specificSignatureNode),
163
+ signatureUnifies = generalSignature.unifySignature(specificSignature, generalContext, specificContext);
164
+
165
+ if (signatureUnifies) {
166
+ success = true;
167
+ }
168
+
144
169
  return success;
145
170
  }
146
171
  }
@@ -434,7 +459,7 @@ class IntrinsicMetavariablePass extends ZipPass {
434
459
  ];
435
460
  }
436
461
 
437
- const statementPass = new StatementPass(),
462
+ const metaLevelPass = new MetaLevelPass(),
438
463
  combinatorPass = new CombinatorPass(),
439
464
  constructorPass = new ConstructorPass(),
440
465
  metavariablePass = new MetavariablePass(),
@@ -449,7 +474,7 @@ export function unifyStatement(generalStatement, specificStatement, generalConte
449
474
  specificStatementNode = specificStatement.getNode(),
450
475
  generalNode = generalStatementNode, ///
451
476
  specificNode = specificStatementNode, ///
452
- success = statementPass.run(generalNode, specificNode, generalContext, specificContext);
477
+ success = metaLevelPass.run(generalNode, specificNode, generalContext, specificContext);
453
478
 
454
479
  if (success) {
455
480
  statementUnifies = true;
@@ -16,6 +16,12 @@ import NominalFileContext from "../context/file/nominal";
16
16
  import { mnemicContextFromJSON, mnemicContextsFromJSON, mnemicContextToMnemicContextJSON, mnemicContextsToMnemicContextsJSON } from "../utilities/json";
17
17
 
18
18
  export function join(innerFunction, ...contexts) {
19
+ contexts = contexts.filter((context) => {
20
+ if (context !== null) {
21
+ return true;
22
+ }
23
+ });
24
+
19
25
  const synopticContext = SynopticContext.fromContexts(contexts),
20
26
  context = synopticContext; ///
21
27
 
@@ -1556,7 +1556,7 @@ export function termFromPropertyAssertionNode(propertyAssertionNode, context) {
1556
1556
  export function signatureAssertionFromStepNode(stepNode, context) {
1557
1557
  let signatureAssertion = null;
1558
1558
 
1559
- const signatureAssertionNode = stepNode.getSatisfiedAssertionNode();
1559
+ const signatureAssertionNode = stepNode.getSignatureAssertionNode();
1560
1560
 
1561
1561
  if (signatureAssertionNode !== null) {
1562
1562
  signatureAssertion = signatureAssertionFromSignatureAssertionNode(signatureAssertionNode, context);
@@ -1841,7 +1841,7 @@ export function containedAssertionFromStatementNode(statementNode, context) {0
1841
1841
  export function signatureAssertionFromStatementNode(statementNode, context) {
1842
1842
  let signatureAssertion = null;
1843
1843
 
1844
- const signatureAssertionNode = statementNode.getSatisfiedAssertionNode();
1844
+ const signatureAssertionNode = statementNode.getSignatureAssertionNode();
1845
1845
 
1846
1846
  if (signatureAssertionNode !== null) {
1847
1847
  signatureAssertion = signatureAssertionFromSignatureAssertionNode(signatureAssertionNode, context);
@@ -20,18 +20,6 @@ export function mergeEquivalences(equivalencesA, equivalencesB, context) {
20
20
  return equivalencesA;
21
21
  }
22
22
 
23
- export function findEquivalenceByTerm(equivalences, term) {
24
- const equivalence = equivalences.find((equivalence) => {
25
- const equivalenceEqualToTerm = equivalence.isEqualTo(term);
26
-
27
- if (equivalenceEqualToTerm) {
28
- return true;
29
- }
30
- }) || null;
31
-
32
- return equivalence;
33
- }
34
-
35
23
  export function equivalencesFromEquality(equality, context) {
36
24
  const { Equivalence } = elements,
37
25
  eaulivalence = Equivalence.fromEquality(equality, context),