occam-verify-cli 0.0.1089 → 0.0.1091

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 (126) hide show
  1. package/bin/action/verify.js +2 -2
  2. package/lib/assertion/contained.js +35 -41
  3. package/lib/assertion/defined.js +24 -24
  4. package/lib/assertion/subproof.js +24 -24
  5. package/lib/assertion/type.js +23 -23
  6. package/lib/assignment/equality.js +4 -10
  7. package/lib/assignment/judgement.js +4 -4
  8. package/lib/assignment/variable.js +4 -4
  9. package/lib/combinator/bracketed.js +3 -3
  10. package/lib/conclusion.js +11 -13
  11. package/lib/consequent.js +11 -13
  12. package/lib/constructor/bracketed.js +3 -3
  13. package/lib/constructor.js +2 -2
  14. package/lib/context/file.js +28 -27
  15. package/lib/context/local.js +31 -32
  16. package/lib/context/release.js +6 -3
  17. package/lib/declaration.js +18 -18
  18. package/lib/derivation.js +3 -3
  19. package/lib/equality.js +24 -24
  20. package/lib/equivalence.js +13 -13
  21. package/lib/frame.js +43 -43
  22. package/lib/index.js +2 -1
  23. package/lib/judgement.js +20 -20
  24. package/lib/label.js +9 -1
  25. package/lib/metaType.js +2 -2
  26. package/lib/metavariable.js +40 -39
  27. package/lib/mixins/statement/qualified/unify.js +19 -19
  28. package/lib/mixins/statement/resolve.js +11 -11
  29. package/lib/mixins/statement/unify.js +12 -12
  30. package/lib/mixins/statement/verify.js +36 -36
  31. package/lib/mixins/term/verify.js +2 -2
  32. package/lib/premise.js +31 -40
  33. package/lib/proof.js +6 -5
  34. package/lib/proofStep.js +17 -17
  35. package/lib/reference.js +8 -8
  36. package/lib/rule.js +21 -21
  37. package/lib/statement/qualified.js +17 -17
  38. package/lib/statement/unqualified.js +19 -19
  39. package/lib/statement.js +52 -54
  40. package/lib/subDerivation.js +3 -3
  41. package/lib/subproof.js +6 -5
  42. package/lib/substitution/frameForMetavariable.js +16 -39
  43. package/lib/substitution/statementForMetavariable.js +88 -74
  44. package/lib/substitution/termForVariable.js +15 -41
  45. package/lib/substitution.js +20 -6
  46. package/lib/substitutions.js +13 -13
  47. package/lib/supposition.js +31 -40
  48. package/lib/term.js +28 -28
  49. package/lib/topLevelAssertion.js +33 -21
  50. package/lib/unifier/equality.js +8 -8
  51. package/lib/unifier/intrinsicLevel.js +149 -0
  52. package/lib/unifier/metaLevel.js +41 -31
  53. package/lib/unifier/metavariable.js +14 -8
  54. package/lib/unifier/statementWithCombinator.js +16 -16
  55. package/lib/unifier/termWithConstructor.js +6 -6
  56. package/lib/unifier.js +47 -47
  57. package/lib/utilities/assignments.js +3 -3
  58. package/lib/utilities/equivalences.js +14 -14
  59. package/lib/utilities/json.js +22 -21
  60. package/lib/utilities/unifier.js +7 -8
  61. package/lib/variable.js +33 -33
  62. package/lib/verifier/statementAsCombinator.js +2 -2
  63. package/lib/verifier/termAsConstructor.js +2 -2
  64. package/package.json +2 -2
  65. package/src/assertion/contained.js +37 -45
  66. package/src/assertion/defined.js +25 -25
  67. package/src/assertion/subproof.js +25 -28
  68. package/src/assertion/type.js +23 -23
  69. package/src/assignment/equality.js +4 -6
  70. package/src/assignment/judgement.js +4 -4
  71. package/src/assignment/variable.js +4 -4
  72. package/src/combinator/bracketed.js +2 -2
  73. package/src/conclusion.js +14 -15
  74. package/src/consequent.js +14 -15
  75. package/src/constructor/bracketed.js +2 -2
  76. package/src/constructor.js +3 -2
  77. package/src/context/file.js +26 -25
  78. package/src/context/local.js +21 -23
  79. package/src/context/release.js +5 -3
  80. package/src/declaration.js +20 -20
  81. package/src/derivation.js +2 -2
  82. package/src/equality.js +26 -26
  83. package/src/equivalence.js +12 -12
  84. package/src/frame.js +42 -42
  85. package/src/index.js +1 -0
  86. package/src/judgement.js +25 -25
  87. package/src/label.js +14 -0
  88. package/src/metaType.js +1 -1
  89. package/src/metavariable.js +51 -43
  90. package/src/mixins/statement/qualified/unify.js +21 -21
  91. package/src/mixins/statement/resolve.js +12 -12
  92. package/src/mixins/statement/unify.js +11 -11
  93. package/src/mixins/statement/verify.js +35 -35
  94. package/src/mixins/term/verify.js +1 -1
  95. package/src/premise.js +42 -53
  96. package/src/proof.js +6 -4
  97. package/src/proofStep.js +21 -21
  98. package/src/reference.js +12 -11
  99. package/src/rule.js +20 -20
  100. package/src/statement/qualified.js +18 -17
  101. package/src/statement/unqualified.js +19 -18
  102. package/src/statement.js +63 -66
  103. package/src/subDerivation.js +2 -3
  104. package/src/subproof.js +6 -4
  105. package/src/substitution/frameForMetavariable.js +29 -45
  106. package/src/substitution/statementForMetavariable.js +136 -86
  107. package/src/substitution/termForVariable.js +28 -49
  108. package/src/substitution.js +15 -5
  109. package/src/substitutions.js +12 -12
  110. package/src/supposition.js +41 -53
  111. package/src/term.js +27 -27
  112. package/src/topLevelAssertion.js +32 -19
  113. package/src/unifier/equality.js +7 -7
  114. package/src/unifier/intrinsicLevel.js +61 -0
  115. package/src/unifier/metaLevel.js +60 -46
  116. package/src/unifier/metavariable.js +22 -13
  117. package/src/unifier/statementWithCombinator.js +28 -28
  118. package/src/unifier/termWithConstructor.js +8 -8
  119. package/src/unifier.js +55 -55
  120. package/src/utilities/assignments.js +2 -2
  121. package/src/utilities/equivalences.js +13 -13
  122. package/src/utilities/json.js +76 -66
  123. package/src/utilities/unifier.js +10 -12
  124. package/src/variable.js +43 -40
  125. package/src/verifier/statementAsCombinator.js +2 -1
  126. package/src/verifier/termAsConstructor.js +2 -1
@@ -28,33 +28,36 @@ class Supposition {
28
28
 
29
29
  getStatement() { return this.unqualifiedStatement.getStatement(); }
30
30
 
31
- resolveIndependently(substitutions, localContext) {
31
+ resolveIndependently(substitutions, context) {
32
32
  let resolvedIndependently;
33
33
 
34
- const suppositionString = this.getString();
34
+ const localContext = LocalContext.fromFileContext(this.fileContext),
35
+ generalContext = localContext, ///
36
+ specificContext = context; ///
35
37
 
36
- const localContextB = localContext; ///
37
-
38
- localContext = LocalContext.fromFileContext(this.fileContext);
39
-
40
- const localContextA = localContext; ///
38
+ const supposition = this, ///
39
+ suppositionString = supposition.getString();
41
40
 
42
- localContextB.trace(`Resolving the '${suppositionString}' supposition independently...`);
41
+ specificContext.trace(`Resolving the '${suppositionString}' supposition independently...`);
43
42
 
44
- const unqualifiedStatementResolvedIndependently = this.unqualifiedStatement.resolveIndependently(substitutions, localContextA, localContextB);
43
+ const unqualifiedStatementResolvedIndependently = this.unqualifiedStatement.resolveIndependently(substitutions, generalContext, specificContext);
45
44
 
46
45
  resolvedIndependently = unqualifiedStatementResolvedIndependently; ///
47
46
 
48
47
  if (resolvedIndependently) {
49
- localContextB.trace(`...resolved the '${suppositionString}' supposition independently.`);
48
+ specificContext.trace(`...resolved the '${suppositionString}' supposition independently.`);
50
49
  }
51
50
 
52
51
  return resolvedIndependently;
53
52
  }
54
53
 
55
- unifyProofStep(proofStep, substitutions, localContext) {
54
+ unifyProofStep(proofStep, substitutions, context) {
56
55
  let proofStepUnified = false;
57
56
 
57
+ const localContext = LocalContext.fromFileContext(this.fileContext),
58
+ generalContext = localContext, ///
59
+ specificContext = context; ///
60
+
58
61
  const subproof = proofStep.getSubproof(),
59
62
  statement = proofStep.getStatement();
60
63
 
@@ -66,54 +69,47 @@ class Supposition {
66
69
  if (false) {
67
70
  ///
68
71
  } else if (subproof !== null) {
69
- subproofUnified = this.unifySubproof(subproof, substitutions, localContext);
72
+ subproofUnified = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
70
73
  } else if (statement !== null) {
71
- statementUnified = this.unifyStatement(statement, substitutions, localContext);
74
+ statementUnified = this.unifyStatement(statement, substitutions, generalContext, specificContext);
72
75
  }
73
76
 
74
77
  if (subproofUnified || statementUnified) {
75
- const localContextB = localContext; ///
78
+ const localContext = LocalContext.fromFileContext(this.fileContext),
79
+ generalContext = localContext, ///
80
+ specificContext = context; ///
76
81
 
77
- localContext = LocalContext.fromFileContext(this.fileContext);
78
-
79
- const localContextA = localContext; ///
80
-
81
- substitutions.resolve(localContextA, localContextB);
82
+ substitutions.resolve(generalContext, specificContext);
82
83
 
83
84
  proofStepUnified = true;
84
85
  }
85
86
 
86
87
  proofStepUnified ?
87
88
  substitutions.continue() :
88
- substitutions.rollback(localContext);
89
+ substitutions.rollback(context);
89
90
 
90
91
  return proofStepUnified;
91
92
  }
92
93
 
93
- unifyStatement(statement, substitutions, localContext) {
94
+ unifyStatement(statement, substitutions, generalContext, specificContext) {
94
95
  let statementUnified;
95
96
 
96
- const statementString = statement.getString(),
97
- suppositionString = this.getString();
98
-
99
- const localContextB = localContext; ///
100
-
101
- localContext = LocalContext.fromFileContext(this.fileContext);
102
-
103
- const localContextA = localContext; ///
97
+ const supposition = this, ///
98
+ suppositionString = supposition.getString(),
99
+ statementString = statement.getString();
104
100
 
105
- localContextB.trace(`Unifying the '${statementString}' statement with the '${suppositionString}' supposition...`);
101
+ specificContext.trace(`Unifying the '${statementString}' statement with the '${suppositionString}' supposition...`);
106
102
 
107
- statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
103
+ statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, generalContext, specificContext);
108
104
 
109
105
  if (statementUnified) {
110
- localContextB.debug(`...unified the '${statementString}' statement with the '${suppositionString}' supposition.`);
106
+ specificContext.debug(`...unified the '${statementString}' statement with the '${suppositionString}' supposition.`);
111
107
  }
112
108
 
113
109
  return statementUnified;
114
110
  }
115
111
 
116
- unifySubproof(subproof, substitutions, localContext) {
112
+ unifySubproof(subproof, substitutions, generalContext, specificContext) {
117
113
  let subproofUnified = false;
118
114
 
119
115
  const supposition = this, ///
@@ -121,59 +117,51 @@ class Supposition {
121
117
  suppositionStatement = supposition.getStatement(),
122
118
  suppositionStatementString = suppositionStatement.getString();
123
119
 
124
- const localContextB = localContext; ///
125
-
126
120
  const statement = this.unqualifiedStatement.getStatement(),
127
- statementTokens = statement.getTokens(),
128
- context = this.fileContext, ///
129
- tokens = statementTokens; ///
130
-
131
- localContext = LocalContext.fromContextAndTokens(context, tokens); ///
132
-
133
- const localContextA = localContext; ///
121
+ statementNode = statement.getNode();
134
122
 
135
- localContextB.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
123
+ specificContext.trace(`Unifying the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement...`);
136
124
 
137
- const statementNode = statement.getNode(),
138
- subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, localContext);
125
+ const context = specificContext, ///
126
+ subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, context);
139
127
 
140
128
  if (subproofAssertion !== null) {
141
- subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, localContextA, localContextB);
129
+ subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, generalContext, specificContext);
142
130
  }
143
131
 
144
132
  if (subproofUnified) {
145
- localContextB.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
133
+ specificContext.debug(`...unified the '${subproofString}' subproof with the supposition's '${suppositionStatementString}' statement.`);
146
134
  }
147
135
 
148
136
  return subproofUnified;
149
137
  }
150
138
 
151
- verify(localContext) {
139
+ verify(context) {
152
140
  let verified = false;
153
141
 
154
142
  const suppositionString = this.getString(); ///
155
143
 
156
- localContext.trace(`Verifying the '${suppositionString}' supposition...`);
144
+ context.trace(`Verifying the '${suppositionString}' supposition...`);
157
145
 
158
146
  const stated = true,
159
147
  assignments = [],
160
- unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
148
+ unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, context);
161
149
 
162
150
  if (unqualifiedStatementVerified) {
163
- const assignmentsAssigned = assignAssignments(assignments, localContext);
151
+ const assignmentsAssigned = assignAssignments(assignments, context);
164
152
 
165
153
  if (assignmentsAssigned) {
166
154
  const { ProofStep } = shim,
167
155
  proofStep = ProofStep.fromUnqualifiedStatement(this.unqualifiedStatement);
168
156
 
169
- localContext.addProofStep(proofStep);
157
+ context.addProofStep(proofStep);
170
158
 
171
159
  verified = true;
172
160
  }
173
161
  }
174
162
 
175
163
  if (verified) {
176
- localContext.debug(`...verified the '${suppositionString}' supposition.`);
164
+ context.debug(`...verified the '${suppositionString}' supposition.`);
177
165
  }
178
166
 
179
167
  return verified;
package/src/term.js CHANGED
@@ -42,7 +42,7 @@ class Term {
42
42
  this.type = type;
43
43
  }
44
44
 
45
- getVariable(localContext) {
45
+ getVariable(context) {
46
46
  let variable = null;
47
47
 
48
48
  const variableNode = variableNodeQuery(this.node);
@@ -50,19 +50,19 @@ class Term {
50
50
  if (variableNode !== null) {
51
51
  const variableName = variableNameFromVariableNode(variableNode);
52
52
 
53
- variable = localContext.findVariableByVariableName(variableName);
53
+ variable = context.findVariableByVariableName(variableName);
54
54
  }
55
55
 
56
56
  return variable;
57
57
  }
58
58
 
59
- getVariables(localContext) {
59
+ getVariables(context) {
60
60
  const variables = [],
61
61
  variableNodes = variableNodesQuery(this.node);
62
62
 
63
63
  variableNodes.forEach((variableNode) => {
64
64
  const variableName = variableNameFromVariableNode(variableNode),
65
- variable = localContext.findVariableByVariableName(variableName),
65
+ variable = context.findVariableByVariableName(variableName),
66
66
  variablesIncludesVariable = variables.includes(variable);
67
67
 
68
68
  if (!variablesIncludesVariable) {
@@ -73,8 +73,8 @@ class Term {
73
73
  return variables;
74
74
  }
75
75
 
76
- isGrounded(definedVariables, localContext) {
77
- const variables = this.getVariables(localContext);
76
+ isGrounded(definedVariables, context) {
77
+ const variables = this.getVariables(context);
78
78
 
79
79
  filter(variables, (variable) => {
80
80
  const definedVariablesIncludesVariable = definedVariables.includes(variable);
@@ -114,32 +114,32 @@ class Term {
114
114
  return termNodeMatches;
115
115
  }
116
116
 
117
- isInitiallyGrounded(localContext) {
118
- const variables = this.getVariables(localContext),
117
+ isInitiallyGrounded(context) {
118
+ const variables = this.getVariables(context),
119
119
  variablesLength = variables.length,
120
120
  initiallyGrounded = (variablesLength === 0);
121
121
 
122
122
  return initiallyGrounded;
123
123
  }
124
124
 
125
- isImplicitlyGrounded(definedVariables, localContext) {
126
- const grounded = this.isGrounded(definedVariables, localContext),
125
+ isImplicitlyGrounded(definedVariables, context) {
126
+ const grounded = this.isGrounded(definedVariables, context),
127
127
  implicitlyGrounded = grounded; ///
128
128
 
129
129
  return implicitlyGrounded;
130
130
  }
131
131
 
132
- verify(localContext, verifyAhead) {
132
+ verify(context, verifyAhead) {
133
133
  let verified = false;
134
134
 
135
135
  const term = this, ///
136
136
  termString = this.string; ///
137
137
 
138
- localContext.trace(`Verifying the '${termString}' term...`);
138
+ context.trace(`Verifying the '${termString}' term...`);
139
139
 
140
140
  if (!verified) {
141
141
  verified = verifyMixins.some((verifyMixin) => {
142
- const verified = verifyMixin(term, localContext, verifyAhead);
142
+ const verified = verifyMixin(term, context, verifyAhead);
143
143
 
144
144
  if (verified) {
145
145
  return true;
@@ -149,7 +149,7 @@ class Term {
149
149
 
150
150
  if (!verified) {
151
151
  const unified = unifyMixins.some((unifyMixin) => { ///
152
- const unified = unifyMixin(term, localContext, verifyAhead);
152
+ const unified = unifyMixin(term, context, verifyAhead);
153
153
 
154
154
  if (unified) {
155
155
  return true;
@@ -160,7 +160,7 @@ class Term {
160
160
  }
161
161
 
162
162
  if (verified) {
163
- localContext.debug(`...verified the '${termString}' term.`);
163
+ context.debug(`...verified the '${termString}' term.`);
164
164
  }
165
165
 
166
166
  return verified;
@@ -194,15 +194,15 @@ class Term {
194
194
  return typeVerified;
195
195
  }
196
196
 
197
- verifyGivenType(type, localContext) {
197
+ verifyGivenType(type, context) {
198
198
  let verifiedGivenType;
199
199
 
200
200
  const typeName = type.getName(),
201
201
  termString = this.getString();
202
202
 
203
- localContext.trace(`Verifying the '${termString}' term given the '${typeName}' type...`);
203
+ context.trace(`Verifying the '${termString}' term given the '${typeName}' type...`);
204
204
 
205
- const verified = this.verify(localContext, () => {
205
+ const verified = this.verify(context, () => {
206
206
  let verifiedAhead;
207
207
 
208
208
  const typeEqualToOrSubTypeOfGivenTypeType = this.type.isEqualToOrSubTypeOf(type);
@@ -217,7 +217,7 @@ class Term {
217
217
  verifiedGivenType = verified; ///
218
218
 
219
219
  if (verifiedGivenType) {
220
- localContext.debug(`...verified the '${termString}' term given the '${typeName}' type.`);
220
+ context.debug(`...verified the '${termString}' term given the '${typeName}' type.`);
221
221
  }
222
222
 
223
223
  return verifiedGivenType;
@@ -271,12 +271,12 @@ class Term {
271
271
  return term;
272
272
  }
273
273
 
274
- static fromTermNode(termNode, localContext) {
274
+ static fromTermNode(termNode, context) {
275
275
  let term = null;
276
276
 
277
277
  if (termNode !== null) {
278
278
  const node = termNode, ///
279
- string = localContext.nodeAsString(node),
279
+ string = context.nodeAsString(node),
280
280
  type = null;
281
281
 
282
282
  term = new Term(string, node, type);
@@ -285,15 +285,15 @@ class Term {
285
285
  return term;
286
286
  }
287
287
 
288
- static fromTermNodeAndType(termNode, type, localContext) {
288
+ static fromTermNodeAndType(termNode, type, context) {
289
289
  const node = termNode, ///
290
- string = localContext.nodeAsString(node),
290
+ string = context.nodeAsString(node),
291
291
  term = new Term(string, node, type);
292
292
 
293
293
  return term;
294
294
  }
295
295
 
296
- static fromDefinedAssertionNode(definedAssertionNode, localContext) {
296
+ static fromDefinedAssertionNode(definedAssertionNode, context) {
297
297
  let term = null;
298
298
 
299
299
  const termNode = termNodeQuery(definedAssertionNode);
@@ -303,7 +303,7 @@ class Term {
303
303
 
304
304
  if (variableNode !== null) {
305
305
  const node = termNode, ///
306
- string = localContext.nodeAsString(node),
306
+ string = context.nodeAsString(node),
307
307
  type = null;
308
308
 
309
309
  term = new Term(string, node, type);
@@ -313,7 +313,7 @@ class Term {
313
313
  return term;
314
314
  }
315
315
 
316
- static fromContainedAssertionNode(containedAssertionNode, localContext) {
316
+ static fromContainedAssertionNode(containedAssertionNode, context) {
317
317
  let term = null;
318
318
 
319
319
  const termNode = termNodeQuery(containedAssertionNode);
@@ -323,7 +323,7 @@ class Term {
323
323
 
324
324
  if (variableNode !== null) {
325
325
  const node = termNode, ///
326
- string = localContext.nodeAsString(node),
326
+ string = context.nodeAsString(node),
327
327
  type = null;
328
328
 
329
329
  term = new Term(string, node, type);
@@ -76,15 +76,27 @@ export default class TopLevelAssertion {
76
76
  return metavariableNodeMatches;
77
77
  }
78
78
 
79
- unifyStatement(statement, localContext) {
79
+ unifyReference(reference, generalContext, specificContext) {
80
+ const referenceUnified = this.labels.some((label) => {
81
+ const referenceUnified = label.unifyReference(reference, generalContext, specificContext);
82
+
83
+ if (referenceUnified) {
84
+ return true;
85
+ }
86
+ });
87
+
88
+ return referenceUnified;
89
+ }
90
+
91
+ unifyStatement(statement, context) {
80
92
  let statementUnified;
81
93
 
82
94
  const { Substitutions } = shim,
83
95
  substitutions = Substitutions.fromNothing(),
84
- consequentUnified = this.unifyConsequent(statement, substitutions, localContext);
96
+ consequentUnified = this.unifyConsequent(statement, substitutions, context);
85
97
 
86
98
  if (consequentUnified) {
87
- const suppositionsUnified = this.unifySupposition(substitutions, localContext);
99
+ const suppositionsUnified = this.unifySupposition(substitutions, context);
88
100
 
89
101
  if (suppositionsUnified) {
90
102
  const substitutionsResolved = substitutions.areResolved();
@@ -96,31 +108,31 @@ export default class TopLevelAssertion {
96
108
  return statementUnified;
97
109
  }
98
110
 
99
- unifyConsequent(statement, substitutions, localContext) {
111
+ unifyConsequent(statement, substitutions, context) {
100
112
  let consequentUnified;
101
113
 
102
114
  const consequentString = this.consequent.getString();
103
115
 
104
- localContext.trace(`Unifying the '${consequentString}' consequent...`);
116
+ context.trace(`Unifying the '${consequentString}' consequent...`);
105
117
 
106
- const statementUnified = this.consequent.unifyStatement(statement, substitutions, localContext); ///
118
+ const statementUnified = this.consequent.unifyStatement(statement, substitutions, context); ///
107
119
 
108
120
  consequentUnified = statementUnified; ///
109
121
 
110
122
  if (consequentUnified) {
111
- localContext.debug(`...unified the '${consequentString}' consequent`);
123
+ context.debug(`...unified the '${consequentString}' consequent`);
112
124
  }
113
125
 
114
126
  return consequentUnified;
115
127
  }
116
128
 
117
- unifySupposition(substitutions, localContext) {
118
- let proofSteps = localContext.getProofSteps();
129
+ unifySupposition(substitutions, context) {
130
+ let proofSteps = context.getProofSteps();
119
131
 
120
132
  proofSteps = reverse(proofSteps); ///
121
133
 
122
134
  const suppositionsUnified = backwardsEvery(this.suppositions, (supposition) => {
123
- const suppositionUnified = this.unifyPremise(supposition, proofSteps, substitutions, localContext);
135
+ const suppositionUnified = this.unifyPremise(supposition, proofSteps, substitutions, context);
124
136
 
125
137
  if (suppositionUnified) {
126
138
  return true;
@@ -130,25 +142,25 @@ export default class TopLevelAssertion {
130
142
  return suppositionsUnified;
131
143
  }
132
144
 
133
- unifyPremise(supposition, proofSteps, substitutions, localContext) {
145
+ unifyPremise(supposition, proofSteps, substitutions, context) {
134
146
  let suppositionUnified =false;
135
147
 
136
148
  const suppositionString = supposition.getString();
137
149
 
138
- localContext.trace(`Unifying the '${suppositionString}' supposition...`);
150
+ context.trace(`Unifying the '${suppositionString}' supposition...`);
139
151
 
140
- const suppositionResolvedIndependently = supposition.resolveIndependently(substitutions, localContext);
152
+ const suppositionResolvedIndependently = supposition.resolveIndependently(substitutions, context);
141
153
 
142
154
  if (suppositionResolvedIndependently) {
143
155
  suppositionUnified = true;
144
156
  } else {
145
157
  const proofStep = extract(proofSteps, (proofStep) => {
146
- const proofStepUnified = supposition.unifyProofStep(proofStep, substitutions, localContext);
158
+ const proofStepUnified = supposition.unifyProofStep(proofStep, substitutions, context);
147
159
 
148
160
  if (proofStepUnified) {
149
161
  return true;
150
162
  }
151
- });
163
+ }) || null;
152
164
 
153
165
  if (proofStep !== null) {
154
166
  suppositionUnified = true;
@@ -156,7 +168,7 @@ export default class TopLevelAssertion {
156
168
  }
157
169
 
158
170
  if (suppositionUnified) {
159
- localContext.debug(`...unified the '${suppositionString}' supposition.`);
171
+ context.debug(`...unified the '${suppositionString}' supposition.`);
160
172
  }
161
173
 
162
174
  return suppositionUnified;
@@ -175,8 +187,9 @@ export default class TopLevelAssertion {
175
187
 
176
188
  if (labelsVerifiedWhenDeclared) {
177
189
  const localContext = LocalContext.fromFileContext(this.fileContext),
190
+ context = localContext, ///
178
191
  suppositionsVerified = this.suppositions.every((supposition) => {
179
- const suppositionVerified = supposition.verify(localContext);
192
+ const suppositionVerified = supposition.verify(context);
180
193
 
181
194
  if (suppositionVerified) {
182
195
  return true;
@@ -184,13 +197,13 @@ export default class TopLevelAssertion {
184
197
  });
185
198
 
186
199
  if (suppositionsVerified) {
187
- const consequentVerified = this.consequent.verify(localContext);
200
+ const consequentVerified = this.consequent.verify(context);
188
201
 
189
202
  if (consequentVerified) {
190
203
  if (this.proof === null) {
191
204
  verified = true;
192
205
  } else {
193
- const proofVerified = this.proof.verify(this.substitutions, this.consequent, localContext);
206
+ const proofVerified = this.proof.verify(this.substitutions, this.consequent, context);
194
207
 
195
208
  verified = proofVerified; ///
196
209
  }
@@ -8,12 +8,12 @@ import { findEquivalenceByTermNodes } from "../utilities/equivalences";
8
8
  const termNodeQuery = nodeQuery("/term");
9
9
 
10
10
  class EqualityUnifier extends Unifier {
11
- unify(leftTermNode, rightTermNode, localContext) {
11
+ unify(leftTermNode, rightTermNode, context) {
12
12
  let equalityUnified;
13
13
 
14
14
  const nonTerminalNodeA = leftTermNode, ///
15
15
  nonTerminalNodeB = rightTermNode, ///
16
- nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, localContext);
16
+ nonTerminalNodeUnified = this.unifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, context);
17
17
 
18
18
  equalityUnified = nonTerminalNodeUnified; ///
19
19
 
@@ -22,9 +22,9 @@ class EqualityUnifier extends Unifier {
22
22
 
23
23
  static maps = [
24
24
  {
25
- nodeQueryA: termNodeQuery,
26
- nodeQueryB: termNodeQuery,
27
- unify: (termNodeA, termNodeB, localContext) => {
25
+ generalNodeQuery: termNodeQuery,
26
+ specificNodeQuery: termNodeQuery,
27
+ unify: (termNodeA, termNodeB, context) => {
28
28
  let termUnifiedWithTerm;
29
29
 
30
30
  const leftTermNode = termNodeA, ///
@@ -34,7 +34,7 @@ class EqualityUnifier extends Unifier {
34
34
  if (leftTermNodeMatchesRightTermNode) {
35
35
  termUnifiedWithTerm = true;
36
36
  } else {
37
- const equivalences = localContext.getEquivalences(),
37
+ const equivalences = context.getEquivalences(),
38
38
  termNodes = [
39
39
  leftTermNode,
40
40
  rightTermNode
@@ -51,7 +51,7 @@ class EqualityUnifier extends Unifier {
51
51
  nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
52
52
  childNodesA = nonTerminalNodeAChildNodes, ///
53
53
  childNodesB = nonTerminalNodeBChildNodes, ///
54
- childNodesVerified = equalityUnifier.unifyChildNodes(childNodesA, childNodesB, localContext);
54
+ childNodesVerified = equalityUnifier.unifyChildNodes(childNodesA, childNodesB, context);
55
55
 
56
56
  termUnifiedWithTerm = childNodesVerified; ///
57
57
  }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ import shim from "../shim";
4
+ import Unifier from "../unifier";
5
+
6
+ import { nodeQuery } from "../utilities/query";
7
+ import { variableNameFromVariableNode } from "../utilities/name";
8
+
9
+ const termNodeQuery = nodeQuery("/term"),
10
+ termVariableNodeQuery = nodeQuery("/term/variable!");
11
+
12
+ class IntrinsicLevelUnifier extends Unifier {
13
+ unify(generalNode, specificNode, substitutions, generalContext, specificContext) {
14
+ let unifiedAtMetaLevel;
15
+
16
+ const generalNonTerminalNode = generalNode, ///
17
+ specificNonTerminalNode = specificNode, ///
18
+ nonTerminalNodeUnified = this.unifyNonTerminalNode(generalNonTerminalNode, specificNonTerminalNode, substitutions, generalContext, specificContext);
19
+
20
+ unifiedAtMetaLevel = nonTerminalNodeUnified; ///
21
+
22
+ return unifiedAtMetaLevel;
23
+ }
24
+
25
+ static maps = [
26
+ {
27
+ generalNodeQuery: termVariableNodeQuery,
28
+ specificNodeQuery: termNodeQuery,
29
+ unify: (generalVermVariableNode, specificTermNode, substitutions, generalContext, specificContext) => {
30
+ let termUnified = false;
31
+
32
+ const variableNode = generalVermVariableNode, ///
33
+ variableName = variableNameFromVariableNode(variableNode),
34
+ variablePresent = generalContext.isVariablePresentByVariableName(variableName);
35
+
36
+ if (variablePresent) {
37
+ let context;
38
+
39
+ const { Term, Variable } = shim,
40
+ termNode = specificTermNode; ///
41
+
42
+ context = generalContext; ///
43
+
44
+ const variable = Variable.fromVariableNode(variableNode, context);
45
+
46
+ context = specificContext; ///
47
+
48
+ const term = Term.fromTermNode(termNode, context);
49
+
50
+ termUnified = variable.unifyTerm(term, substitutions, generalContext, specificContext);
51
+ }
52
+
53
+ return termUnified;
54
+ }
55
+ }
56
+ ];
57
+ }
58
+
59
+ const intrinsicLevelUnifier = new IntrinsicLevelUnifier();
60
+
61
+ export default intrinsicLevelUnifier;