occam-verify-cli 0.0.1250 → 0.0.1252

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.
@@ -19,24 +19,6 @@ export default domAssigned(class Consequent {
19
19
  return this.statement;
20
20
  }
21
21
 
22
- unifyStatement(statement, substitutions, generalContext, specificContext) {
23
- let statementUnified;
24
-
25
- const consequent = this, ///
26
- statementString = statement.getString(),
27
- consequentString = consequent.getString();
28
-
29
- specificContext.trace(`Unifying the '${statementString}' statement with the '${consequentString}' consequent...`);
30
-
31
- statementUnified = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
32
-
33
- if (statementUnified) {
34
- specificContext.debug(`...unified the '${statementString}' statement with the '${consequentString}' consequent.`);
35
- }
36
-
37
- return statementUnified;
38
- }
39
-
40
22
  verify(context) {
41
23
  let verified = false;
42
24
 
@@ -61,6 +43,24 @@ export default domAssigned(class Consequent {
61
43
  return verified;
62
44
  }
63
45
 
46
+ unifyStatement(statement, substitutions, generalContext, specificContext) {
47
+ let statementUnified;
48
+
49
+ const consequent = this, ///
50
+ statementString = statement.getString(),
51
+ consequentString = consequent.getString();
52
+
53
+ specificContext.trace(`Unifying the '${statementString}' statement with the '${consequentString}' consequent...`);
54
+
55
+ statementUnified = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
56
+
57
+ if (statementUnified) {
58
+ specificContext.debug(`...unified the '${statementString}' statement with the '${consequentString}' consequent.`);
59
+ }
60
+
61
+ return statementUnified;
62
+ }
63
+
64
64
  toJSON() {
65
65
  const statementJSON = statementToStatementJSON(this.statement),
66
66
  statement = statementJSON, ///
@@ -113,6 +113,126 @@ export default domAssigned(class Metavariable {
113
113
  return substitutionMatched;
114
114
  }
115
115
 
116
+ verify(context) {
117
+ let verified;
118
+
119
+ const metavariableString = this.string; ///
120
+
121
+ context.trace(`Verifying the '${metavariableString}' metavariable...`);
122
+
123
+ const metavariable = this, ///
124
+ generalContext = context, ///
125
+ specificContext = context, ///
126
+ metavariablePresent = generalContext.isMetavariablePresent(metavariable, generalContext, specificContext);
127
+
128
+ verified = metavariablePresent; ///
129
+
130
+ if (verified) {
131
+ context.debug(`...verified the '${metavariableString}' metavariable.`);
132
+ }
133
+
134
+ return verified;
135
+ }
136
+
137
+ verifyType(fileContext) {
138
+ let typeVerified;
139
+
140
+ if (this.type === null) {
141
+ typeVerified = true;
142
+ } else {
143
+ if (this.type === objectType) {
144
+ typeVerified = true;
145
+ } else {
146
+ const typeName = this.type.getName();
147
+
148
+ fileContext.trace(`Verifying the '${typeName}' type...`);
149
+
150
+ const type = fileContext.findTypeByTypeName(typeName);
151
+
152
+ if (type === null) {
153
+ fileContext.debug(`The '${typeName}' type is missing.`);
154
+ } else {
155
+ this.type = type; ///
156
+
157
+ typeVerified = true;
158
+ }
159
+
160
+ if (typeVerified) {
161
+ fileContext.debug(`...verified the '${typeName}' type.`);
162
+ }
163
+ }
164
+ }
165
+
166
+ return typeVerified;
167
+ }
168
+
169
+ verifyWhenDeclared(fileContext) {
170
+ let verifiedWhenDeclared = false;
171
+
172
+ const metavariableString = this.string; ///
173
+
174
+ fileContext.trace(`Verifying the '${metavariableString}' metavariable when declared...`);
175
+
176
+ const metavariableNode = this.node, ///
177
+ termNode = termNodeQuery(metavariableNode);
178
+
179
+ if (termNode !== null) {
180
+ fileContext.debug(`A term was found in the '${metavariableString}' metavariable when a type should have been present.`);
181
+ } else {
182
+ const metavariableName = this.name, ///
183
+ metavariablePresent = fileContext.isMetavariablePresentByMetavariableName(metavariableName);
184
+
185
+ if (metavariablePresent) {
186
+ fileContext.debug(`The '${metavariableName}' metavariable has already been declared.`);
187
+ } else {
188
+ const variableName = this.name, ///
189
+ variablePresent = fileContext.isVariablePresentByVariableName(variableName);
190
+
191
+ if (variablePresent) {
192
+ fileContext.debug(`A '${metavariableName}' variable has already been declared.`);
193
+ } else {
194
+ const typeVerified = this.verifyType(fileContext);
195
+
196
+ verifiedWhenDeclared = typeVerified;
197
+ }
198
+ }
199
+ }
200
+
201
+ if (verifiedWhenDeclared) {
202
+ fileContext.debug(`...verified the '${metavariableString}' metavariable when declared.`);
203
+ }
204
+
205
+ return verifiedWhenDeclared;
206
+ }
207
+
208
+ verifyGivenMetaType(metaType, context) {
209
+ let verifiedGivenMetaType = false;
210
+
211
+ const metavariableString = this.string, ///
212
+ metaTypeString = metaType.getString();
213
+
214
+ context.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
215
+
216
+ let metavariable = this; ///
217
+
218
+ const specificContext = context, ///
219
+ generalContext = context; ///
220
+
221
+ metavariable = generalContext.findMetavariable(metavariable, generalContext, specificContext);
222
+
223
+ if (metavariable !== null) {
224
+ const metavariableMetaTypeEqualToMetaType = metavariable.isMetaTypeEqualTo(metaType);
225
+
226
+ verifiedGivenMetaType = metavariableMetaTypeEqualToMetaType; ///
227
+ }
228
+
229
+ if (verifiedGivenMetaType) {
230
+ context.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type.`);
231
+ }
232
+
233
+ return verifiedGivenMetaType;
234
+ }
235
+
116
236
  unifyFrame(frame, substitutions, generalContext, specificContext) {
117
237
  let frameUnified = false;
118
238
 
@@ -374,126 +494,6 @@ export default domAssigned(class Metavariable {
374
494
  return statementMetavariableUnified;
375
495
  }
376
496
 
377
- verify(context) {
378
- let verified;
379
-
380
- const metavariableString = this.string; ///
381
-
382
- context.trace(`Verifying the '${metavariableString}' metavariable...`);
383
-
384
- const metavariable = this, ///
385
- generalContext = context, ///
386
- specificContext = context, ///
387
- metavariablePresent = generalContext.isMetavariablePresent(metavariable, generalContext, specificContext);
388
-
389
- verified = metavariablePresent; ///
390
-
391
- if (verified) {
392
- context.debug(`...verified the '${metavariableString}' metavariable.`);
393
- }
394
-
395
- return verified;
396
- }
397
-
398
- verifyType(fileContext) {
399
- let typeVerified;
400
-
401
- if (this.type === null) {
402
- typeVerified = true;
403
- } else {
404
- if (this.type === objectType) {
405
- typeVerified = true;
406
- } else {
407
- const typeName = this.type.getName();
408
-
409
- fileContext.trace(`Verifying the '${typeName}' type...`);
410
-
411
- const type = fileContext.findTypeByTypeName(typeName);
412
-
413
- if (type === null) {
414
- fileContext.debug(`The '${typeName}' type is missing.`);
415
- } else {
416
- this.type = type; ///
417
-
418
- typeVerified = true;
419
- }
420
-
421
- if (typeVerified) {
422
- fileContext.debug(`...verified the '${typeName}' type.`);
423
- }
424
- }
425
- }
426
-
427
- return typeVerified;
428
- }
429
-
430
- verifyWhenDeclared(fileContext) {
431
- let verifiedWhenDeclared = false;
432
-
433
- const metavariableString = this.string; ///
434
-
435
- fileContext.trace(`Verifying the '${metavariableString}' metavariable when declared...`);
436
-
437
- const metavariableNode = this.node, ///
438
- termNode = termNodeQuery(metavariableNode);
439
-
440
- if (termNode !== null) {
441
- fileContext.debug(`A term was found in the '${metavariableString}' metavariable when a type should have been present.`);
442
- } else {
443
- const metavariableName = this.name, ///
444
- metavariablePresent = fileContext.isMetavariablePresentByMetavariableName(metavariableName);
445
-
446
- if (metavariablePresent) {
447
- fileContext.debug(`The '${metavariableName}' metavariable has already been declared.`);
448
- } else {
449
- const variableName = this.name, ///
450
- variablePresent = fileContext.isVariablePresentByVariableName(variableName);
451
-
452
- if (variablePresent) {
453
- fileContext.debug(`A '${metavariableName}' variable has already been declared.`);
454
- } else {
455
- const typeVerified = this.verifyType(fileContext);
456
-
457
- verifiedWhenDeclared = typeVerified;
458
- }
459
- }
460
- }
461
-
462
- if (verifiedWhenDeclared) {
463
- fileContext.debug(`...verified the '${metavariableString}' metavariable when declared.`);
464
- }
465
-
466
- return verifiedWhenDeclared;
467
- }
468
-
469
- verifyGivenMetaType(metaType, context) {
470
- let verifiedGivenMetaType = false;
471
-
472
- const metavariableString = this.string, ///
473
- metaTypeString = metaType.getString();
474
-
475
- context.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
476
-
477
- let metavariable = this; ///
478
-
479
- const specificContext = context, ///
480
- generalContext = context; ///
481
-
482
- metavariable = generalContext.findMetavariable(metavariable, generalContext, specificContext);
483
-
484
- if (metavariable !== null) {
485
- const metavariableMetaTypeEqualToMetaType = metavariable.isMetaTypeEqualTo(metaType);
486
-
487
- verifiedGivenMetaType = metavariableMetaTypeEqualToMetaType; ///
488
- }
489
-
490
- if (verifiedGivenMetaType) {
491
- context.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type.`);
492
- }
493
-
494
- return verifiedGivenMetaType;
495
- }
496
-
497
497
  toJSON() {
498
498
  const metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
499
499
  typeJSON = typeToTypeJSON(this.type),
@@ -26,6 +26,52 @@ export default domAssigned(class Premise {
26
26
  return this.procedureCall;
27
27
  }
28
28
 
29
+ verify(context) {
30
+ let verified = false;
31
+
32
+ const premiseString = this.string; ///
33
+
34
+ context.trace(`Verifying the '${premiseString}' premise...`);
35
+
36
+ if (false) {
37
+ ///
38
+ } else if (this.statement !== null) {
39
+ const stated = true,
40
+ assignments = [],
41
+ statementVerified = this.statement.verify(assignments, stated, context);
42
+
43
+ if (statementVerified) {
44
+ const assignmentsAssigned = assignAssignments(assignments, context);
45
+
46
+ if (assignmentsAssigned) {
47
+ const { ProofStep } = dom,
48
+ proofStep = ProofStep.fromStatement(this.statement, context),
49
+ proofStepSubproof = proofStep; ///
50
+
51
+ context.addProofStepSubproof(proofStepSubproof);
52
+
53
+ verified = true;
54
+ }
55
+ }
56
+ } else if (this.procedureCall !== null) {
57
+ const stated = true,
58
+ assignments = null,
59
+ procedureCallVerified = this.procedureCall.verify(assignments, stated, context);
60
+
61
+ if (procedureCallVerified) {
62
+ verified = true;
63
+ }
64
+ } else {
65
+ context.debug(`Unable to verify the '${premiseString}' premise because it is nonsense.`);
66
+ }
67
+
68
+ if (verified) {
69
+ context.debug(`...verified the '${premiseString}' premise.`);
70
+ }
71
+
72
+ return verified;
73
+ }
74
+
29
75
  unifyIndependently(substitutions, context) {
30
76
  let unifiedIndependently;
31
77
 
@@ -139,52 +185,6 @@ export default domAssigned(class Premise {
139
185
  return statementUnified;
140
186
  }
141
187
 
142
- verify(context) {
143
- let verified = false;
144
-
145
- const premiseString = this.string; ///
146
-
147
- context.trace(`Verifying the '${premiseString}' premise...`);
148
-
149
- if (false) {
150
- ///
151
- } else if (this.statement !== null) {
152
- const stated = true,
153
- assignments = [],
154
- statementVerified = this.statement.verify(assignments, stated, context);
155
-
156
- if (statementVerified) {
157
- const assignmentsAssigned = assignAssignments(assignments, context);
158
-
159
- if (assignmentsAssigned) {
160
- const { ProofStep } = dom,
161
- proofStep = ProofStep.fromStatement(this.statement, context),
162
- proofStepSubproof = proofStep; ///
163
-
164
- context.addProofStepSubproof(proofStepSubproof);
165
-
166
- verified = true;
167
- }
168
- }
169
- } else if (this.procedureCall !== null) {
170
- const stated = true,
171
- assignments = null,
172
- procedureCallVerified = this.procedureCall.verify(assignments, stated, context);
173
-
174
- if (procedureCallVerified) {
175
- verified = true;
176
- }
177
- } else {
178
- context.debug(`Unable to verify the '${premiseString}' premise because it is nonsense.`);
179
- }
180
-
181
- if (verified) {
182
- context.debug(`...verified the '${premiseString}' premise.`);
183
- }
184
-
185
- return verified;
186
- }
187
-
188
188
  toJSON() {
189
189
  const statementJSON = statementToStatementJSON(this.statement),
190
190
  procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
@@ -219,6 +219,16 @@ export default domAssigned(class Reference {
219
219
  return reference;
220
220
  }
221
221
 
222
+ static fromMetavariableNode(metavariableNode, fileContext) {
223
+ const { Metavariable } = dom,
224
+ localContext = LocalContext.fromFileContext(fileContext),
225
+ context = localContext, ///
226
+ metavariable = Metavariable.fromMetavariableNode(metavariableNode, context),
227
+ reference = new Reference(metavariable);
228
+
229
+ return reference;
230
+ }
231
+
222
232
  static fromProcedureCallNode(procedureCallNode, fileContext) {
223
233
  let reference = null;
224
234
 
@@ -26,6 +26,52 @@ export default domAssigned(class Supposition {
26
26
  return this.procedureCall;
27
27
  }
28
28
 
29
+ verify(context) {
30
+ let verified = false;
31
+
32
+ const suppositionString = this.string; ///
33
+
34
+ context.trace(`Verifying the '${suppositionString}' supposition...`);
35
+
36
+ if (false) {
37
+ ///
38
+ } else if (this.statement !== null) {
39
+ const stated = true,
40
+ assignments = [],
41
+ statementVerified = this.statement.verify(assignments, stated, context);
42
+
43
+ if (statementVerified) {
44
+ const assignmentsAssigned = assignAssignments(assignments, context);
45
+
46
+ if (assignmentsAssigned) {
47
+ const { ProofStep } = dom,
48
+ proofStep = ProofStep.fromStatement(this.statement, context),
49
+ proofStepSubproof = proofStep; ///
50
+
51
+ context.addProofStepSubproof(proofStepSubproof);
52
+
53
+ verified = true;
54
+ }
55
+ }
56
+ } else if (this.procedureCall !== null) {
57
+ const stated = true,
58
+ assignments = null,
59
+ procedureCallVerified = this.procedureCall.verify(assignments, stated, context);
60
+
61
+ if (procedureCallVerified) {
62
+ verified = true;
63
+ }
64
+ } else {
65
+ context.debug(`Unable to verify the '${suppositionString}' supposition because it is nonsense.`);
66
+ }
67
+
68
+ if (verified) {
69
+ context.debug(`...verified the '${suppositionString}' supposition.`);
70
+ }
71
+
72
+ return verified;
73
+ }
74
+
29
75
  unifyIndependently(substitutions, context) {
30
76
  let unifiedIndependently;
31
77
 
@@ -139,52 +185,6 @@ export default domAssigned(class Supposition {
139
185
  return statementUnified;
140
186
  }
141
187
 
142
- verify(context) {
143
- let verified = false;
144
-
145
- const suppositionString = this.string; ///
146
-
147
- context.trace(`Verifying the '${suppositionString}' supposition...`);
148
-
149
- if (false) {
150
- ///
151
- } else if (this.statement !== null) {
152
- const stated = true,
153
- assignments = [],
154
- statementVerified = this.statement.verify(assignments, stated, context);
155
-
156
- if (statementVerified) {
157
- const assignmentsAssigned = assignAssignments(assignments, context);
158
-
159
- if (assignmentsAssigned) {
160
- const { ProofStep } = dom,
161
- proofStep = ProofStep.fromStatement(this.statement, context),
162
- proofStepSubproof = proofStep; ///
163
-
164
- context.addProofStepSubproof(proofStepSubproof);
165
-
166
- verified = true;
167
- }
168
- }
169
- } else if (this.procedureCall !== null) {
170
- const stated = true,
171
- assignments = null,
172
- procedureCallVerified = this.procedureCall.verify(assignments, stated, context);
173
-
174
- if (procedureCallVerified) {
175
- verified = true;
176
- }
177
- } else {
178
- context.debug(`Unable to verify the '${suppositionString}' supposition because it is nonsense.`);
179
- }
180
-
181
- if (verified) {
182
- context.debug(`...verified the '${suppositionString}' supposition.`);
183
- }
184
-
185
- return verified;
186
- }
187
-
188
188
  toJSON() {
189
189
  const statementJSON = statementToStatementJSON(this.statement),
190
190
  procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
@@ -9,12 +9,11 @@ import { nodeQuery } from "../utilities/query";
9
9
 
10
10
  const termNodeQuery = nodeQuery("/term"),
11
11
  frameNodeQuery = nodeQuery("/frame"),
12
- referenceNodeQuery = nodeQuery("/reference"),
13
12
  statementNodeQuery = nodeQuery("/statement"),
14
13
  termVariableNodeQuery = nodeQuery("/term/variable!"),
15
14
  frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
16
- referenceMetavariableNodeQuery = nodeQuery("/reference/metavariable!"),
17
- statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
15
+ statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
16
+ declarationMetavariableNodeQuery = nodeQuery("/declaration/metavariable!");
18
17
 
19
18
  class MetaLevelUnifier extends Unifier {
20
19
  unify(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext) {
@@ -69,24 +68,27 @@ class MetaLevelUnifier extends Unifier {
69
68
  }
70
69
  },
71
70
  {
72
- generalNodeQuery: referenceMetavariableNodeQuery,
73
- specificNodeQuery: referenceNodeQuery,
74
- unify: (generalReferenceMetavariableNode, specificReferenceNode, substitutions, generalContext, specificContext) => {
71
+ generalNodeQuery: declarationMetavariableNodeQuery,
72
+ specificNodeQuery: declarationMetavariableNodeQuery,
73
+ unify: (generalDeclarationMetavariableNode, specificDeclarationMetavariableNode, substitutions, generalContext, specificContext) => {
75
74
  let referenceUnified;
76
75
 
77
- const { Reference, Metavariable } = dom,
78
- referenceNode = specificReferenceNode, ///
79
- metavariableNode = generalReferenceMetavariableNode; ///
76
+ const { Reference, Metavariable } = dom;
80
77
 
81
- let context;
78
+ let context,
79
+ metavariableNode;
82
80
 
83
81
  context = generalContext; ///
84
82
 
83
+ metavariableNode = generalDeclarationMetavariableNode; ///
84
+
85
85
  const metavariable = Metavariable.fromMetavariableNode(metavariableNode, context);
86
86
 
87
87
  context = specificContext; ///
88
88
 
89
- const reference = Reference.fromReferenceNode(referenceNode, context);
89
+ metavariableNode = specificDeclarationMetavariableNode; ///
90
+
91
+ const reference = Reference.fromMetavariableNode(metavariableNode, context);
90
92
 
91
93
  referenceUnified = metavariable.unifyReference(reference, substitutions, generalContext, specificContext);
92
94