occam-verify-cli 1.0.388 → 1.0.396

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 (119) hide show
  1. package/lib/action/verify.js +3 -3
  2. package/lib/context/file.js +8 -7
  3. package/lib/context/local.js +23 -57
  4. package/lib/context/temporary.js +705 -0
  5. package/lib/mixins/statement/verify.js +38 -16
  6. package/lib/mixins/step/unify.js +3 -3
  7. package/lib/node/substitution/frame.js +23 -1
  8. package/lib/node/substitution/term.js +23 -1
  9. package/lib/ontology/assertion/contained.js +77 -35
  10. package/lib/ontology/assertion/defined.js +76 -34
  11. package/lib/ontology/assertion/property.js +71 -29
  12. package/lib/ontology/assertion/satisfies.js +70 -22
  13. package/lib/ontology/assertion/subproof.js +95 -41
  14. package/lib/ontology/assertion/type.js +74 -18
  15. package/lib/ontology/assertion.js +66 -0
  16. package/lib/ontology/axiom.js +8 -11
  17. package/lib/ontology/combinator/bracketed.js +17 -3
  18. package/lib/ontology/combinator.js +17 -3
  19. package/lib/ontology/conclusion.js +38 -9
  20. package/lib/ontology/constructor/bracketed.js +17 -3
  21. package/lib/ontology/constructor.js +17 -3
  22. package/lib/ontology/declaration.js +27 -2
  23. package/lib/ontology/deduction.js +38 -9
  24. package/lib/ontology/frame.js +50 -13
  25. package/lib/ontology/hypothesis.js +11 -11
  26. package/lib/ontology/judgement.js +1 -1
  27. package/lib/ontology/label.js +5 -6
  28. package/lib/ontology/metavariable.js +11 -12
  29. package/lib/ontology/premise.js +47 -17
  30. package/lib/ontology/procedureCall.js +15 -15
  31. package/lib/ontology/procedureReference.js +1 -1
  32. package/lib/ontology/proof.js +2 -2
  33. package/lib/ontology/reference.js +4 -5
  34. package/lib/ontology/rule.js +68 -69
  35. package/lib/ontology/section.js +2 -2
  36. package/lib/ontology/signature.js +2 -2
  37. package/lib/ontology/statement.js +9 -1
  38. package/lib/ontology/step.js +37 -24
  39. package/lib/ontology/subproof.js +11 -11
  40. package/lib/ontology/substitution/frame.js +69 -21
  41. package/lib/ontology/substitution/reference.js +24 -9
  42. package/lib/ontology/substitution/statement.js +99 -79
  43. package/lib/ontology/substitution/term.js +89 -29
  44. package/lib/ontology/substitution.js +37 -30
  45. package/lib/ontology/supposition.js +56 -25
  46. package/lib/ontology/term.js +4 -3
  47. package/lib/ontology/topLevelAssertion.js +15 -15
  48. package/lib/ontology/topLevelMetaAssertion.js +2 -2
  49. package/lib/ontology/variable.js +42 -14
  50. package/lib/substitutions.js +25 -25
  51. package/lib/unifier/intrinsicLevel.js +14 -7
  52. package/lib/unifier/metaLevel.js +25 -17
  53. package/lib/utilities/brackets.js +4 -21
  54. package/lib/utilities/context.js +6 -6
  55. package/lib/utilities/json.js +24 -1
  56. package/lib/utilities/metavariable.js +18 -0
  57. package/lib/utilities/substitutions.js +3 -3
  58. package/lib/utilities/unification.js +10 -16
  59. package/lib/utilities/variable.js +30 -0
  60. package/package.json +2 -2
  61. package/src/action/verify.js +2 -2
  62. package/src/context/file.js +8 -7
  63. package/src/context/local.js +13 -61
  64. package/src/context/temporary.js +394 -0
  65. package/src/mixins/statement/verify.js +60 -23
  66. package/src/mixins/step/unify.js +2 -2
  67. package/src/node/substitution/frame.js +26 -0
  68. package/src/node/substitution/term.js +26 -0
  69. package/src/ontology/assertion/contained.js +12 -23
  70. package/src/ontology/assertion/defined.js +12 -23
  71. package/src/ontology/assertion/property.js +7 -20
  72. package/src/ontology/assertion/satisfies.js +7 -16
  73. package/src/ontology/assertion/subproof.js +36 -42
  74. package/src/ontology/assertion/type.js +10 -11
  75. package/src/ontology/assertion.js +23 -0
  76. package/src/ontology/axiom.js +7 -16
  77. package/src/ontology/combinator/bracketed.js +2 -0
  78. package/src/ontology/combinator.js +2 -0
  79. package/src/ontology/conclusion.js +51 -10
  80. package/src/ontology/constructor/bracketed.js +2 -0
  81. package/src/ontology/constructor.js +2 -0
  82. package/src/ontology/declaration.js +34 -1
  83. package/src/ontology/deduction.js +51 -10
  84. package/src/ontology/frame.js +58 -21
  85. package/src/ontology/hypothesis.js +8 -8
  86. package/src/ontology/judgement.js +1 -1
  87. package/src/ontology/label.js +2 -7
  88. package/src/ontology/metavariable.js +12 -15
  89. package/src/ontology/premise.js +64 -21
  90. package/src/ontology/procedureCall.js +14 -14
  91. package/src/ontology/procedureReference.js +2 -2
  92. package/src/ontology/proof.js +1 -1
  93. package/src/ontology/reference.js +1 -6
  94. package/src/ontology/rule.js +76 -80
  95. package/src/ontology/section.js +1 -1
  96. package/src/ontology/signature.js +1 -1
  97. package/src/ontology/statement.js +6 -0
  98. package/src/ontology/step.js +43 -26
  99. package/src/ontology/subproof.js +8 -8
  100. package/src/ontology/substitution/frame.js +72 -26
  101. package/src/ontology/substitution/reference.js +8 -6
  102. package/src/ontology/substitution/statement.js +93 -77
  103. package/src/ontology/substitution/term.js +108 -42
  104. package/src/ontology/substitution.js +27 -22
  105. package/src/ontology/supposition.js +70 -24
  106. package/src/ontology/term.js +5 -5
  107. package/src/ontology/topLevelAssertion.js +14 -16
  108. package/src/ontology/topLevelMetaAssertion.js +1 -1
  109. package/src/ontology/variable.js +64 -17
  110. package/src/substitutions.js +25 -25
  111. package/src/unifier/intrinsicLevel.js +18 -8
  112. package/src/unifier/metaLevel.js +35 -21
  113. package/src/utilities/brackets.js +3 -29
  114. package/src/utilities/context.js +5 -5
  115. package/src/utilities/json.js +28 -0
  116. package/src/utilities/metavariable.js +13 -0
  117. package/src/utilities/substitutions.js +2 -4
  118. package/src/utilities/unification.js +8 -24
  119. package/src/utilities/variable.js +22 -0
@@ -7,20 +7,20 @@ import { assignAssignments } from "../utilities/assignments";
7
7
  import { statementFromJSON, statementToStatementJSON } from "../utilities/json";
8
8
 
9
9
  export default define(class Hypothesis {
10
- constructor(node, string, statement) {
11
- this.node = node;
10
+ constructor(string, node, statement) {
12
11
  this.string = string;
12
+ this.node = node;
13
13
  this.statement = statement;
14
14
  }
15
15
 
16
- getNode() {
17
- return this.node;
18
- }
19
-
20
16
  getString() {
21
17
  return this.string;
22
18
  }
23
19
 
20
+ getNode() {
21
+ return this.node;
22
+ }
23
+
24
24
  getStatement() {
25
25
  return this.statement;
26
26
  }
@@ -107,7 +107,7 @@ export default define(class Hypothesis {
107
107
  }
108
108
 
109
109
  const node = null,
110
- hypothesis = new Hypothesis(node, string, statement);
110
+ hypothesis = new Hypothesis(string, node, statement);
111
111
 
112
112
  return hypothesis;
113
113
  }
@@ -117,7 +117,7 @@ export default define(class Hypothesis {
117
117
  node = hypothesisNode, ///
118
118
  string = context.nodeAsString(node),
119
119
  statement = Statement.fromHypothesisNode(hypothesisNode, context),
120
- hypothesis = new Hypothesis(node, string, statement);
120
+ hypothesis = new Hypothesis(string, node, statement);
121
121
 
122
122
  return hypothesis
123
123
  }
@@ -151,7 +151,7 @@ export default define(class Judgement {
151
151
  const judgementNode = statementNode.getJudgementNode();
152
152
 
153
153
  if (judgementNode !== null) {
154
- const { Frame, Declaration} = ontology,
154
+ const { Frame, Declaration } = ontology,
155
155
  node = judgementNode, ///
156
156
  string = context.nodeAsString(node),
157
157
  frame = Frame.fromJudgementNode(judgementNode, context),
@@ -35,18 +35,13 @@ export default define(class Label {
35
35
 
36
36
  matchReference(reference) {
37
37
  const metavariable = reference.getMetavariable(),
38
- metavariableEqualToMetavariable = this.isMetavariableEqualTo(metavariable),
38
+ metavariableEqualToMetavariable = this.isMetavariableEqualToMetavariable(metavariable),
39
39
  referenceMatches = metavariableEqualToMetavariable; ///
40
40
 
41
41
  return referenceMatches;
42
42
  }
43
43
 
44
- isMetavariableEqualTo(metavariable) {
45
- const equalTo = this.metavariable.isEqualTo(metavariable),
46
- metavariableEqualTo = equalTo; ///
47
-
48
- return metavariableEqualTo;
49
- }
44
+ isMetavariableEqualToMetavariable(metavariable) { return this.metavariable.isEqualTo(metavariable); }
50
45
 
51
46
  matchMetavariableName(metavariableName) { return this.metavariable.matchMetavariableName(metavariableName); }
52
47
 
@@ -95,9 +95,7 @@ export default define(class Metavariable {
95
95
  context.trace(`Verifying the '${metavariableString}' metavariable...`);
96
96
 
97
97
  const metavariable = this, ///
98
- generalContext = context, ///
99
- specificContext = context, ///
100
- metavariablePresent = generalContext.isMetavariablePresent(metavariable, generalContext, specificContext);
98
+ metavariablePresent = context.isMetavariablePresent(metavariable);
101
99
 
102
100
  verifies = metavariablePresent; ///
103
101
 
@@ -118,10 +116,7 @@ export default define(class Metavariable {
118
116
 
119
117
  let metavariable = this; ///
120
118
 
121
- const specificContext = context, ///
122
- generalContext = context; ///
123
-
124
- metavariable = generalContext.findMetavariable(metavariable, generalContext, specificContext);
119
+ metavariable = context.findMetavariable(metavariable);
125
120
 
126
121
  if (metavariable !== null) {
127
122
  const metavariableMetaTypeEqualToMetaType = metavariable.isMetaTypeEqualTo(metaType);
@@ -155,7 +150,7 @@ export default define(class Metavariable {
155
150
  if (simpleSubstitutionPresent) {
156
151
  const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariable(metavariable),
157
152
  substitution = simpleSubstitution, ///
158
- substitutionFrameEqualToFrame = substitution.isFrameEqualTo(frame);
153
+ substitutionFrameEqualToFrame = substitution.isFrameEqualToFrame(frame);
159
154
 
160
155
  if (substitutionFrameEqualToFrame) {
161
156
  frameUnifies = true;
@@ -167,7 +162,7 @@ export default define(class Metavariable {
167
162
  frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, context),
168
163
  substitution = frameSubstitution; ///
169
164
 
170
- substitutions.addSubstitution(substitution, specificContext);
165
+ substitutions.addSubstitution(substitution, context);
171
166
 
172
167
  frameUnifies = true;
173
168
  }
@@ -200,7 +195,7 @@ export default define(class Metavariable {
200
195
  if (simpleSubstitutionPresent) {
201
196
  const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariable(metavariable), ///
202
197
  substitution = simpleSubstitution, ///
203
- substitutionReferenceEqualToReference = substitution.isReferenceEqualTo(reference, context);
198
+ substitutionReferenceEqualToReference = substitution.isReferenceEqualToReference(reference, context);
204
199
 
205
200
  if (substitutionReferenceEqualToReference) {
206
201
  referenceUnifies = true;
@@ -211,7 +206,7 @@ export default define(class Metavariable {
211
206
  referenceSubstitution = ReferenceSubstitution.fromReferenceAndMetavariable(reference, metavariable, context),
212
207
  substitution = referenceSubstitution; ///
213
208
 
214
- substitutions.addSubstitution(substitution, specificContext);
209
+ substitutions.addSubstitution(substitution, context);
215
210
 
216
211
  referenceUnifies = true;
217
212
  }
@@ -247,7 +242,7 @@ export default define(class Metavariable {
247
242
  if (substitutionPresent) {
248
243
  substitution = substitutions.findSubstitutionByMetavariableAndSubstitution(metavariable, substitution); ///
249
244
 
250
- const substitutionStatementEqualToStatement = substitution.isStatementEqualTo(statement, context);
245
+ const substitutionStatementEqualToStatement = substitution.isStatementEqualToStatement(statement, context);
251
246
 
252
247
  if (substitutionStatementEqualToStatement) {
253
248
  statementUnifies = true;
@@ -259,7 +254,7 @@ export default define(class Metavariable {
259
254
 
260
255
  substitution = statementSubstitution; ///
261
256
 
262
- substitutions.addSubstitution(substitution, specificContext);
257
+ substitutions.addSubstitution(substitution, context);
263
258
 
264
259
  statementUnifies = true;
265
260
  }
@@ -272,10 +267,12 @@ export default define(class Metavariable {
272
267
  return statementUnifies;
273
268
  }
274
269
 
275
- unifyMetavariable(metavariable, generalContext, specificContext) {
270
+ unifyMetavariable(metavariable, context) {
276
271
  let metavariableUnifies;
277
272
 
278
- const generalMetavariable = this, ///
273
+ const generalContext = context, ///
274
+ specificContext = context, ///
275
+ generalMetavariable = this, ///
279
276
  specificMetavariable = metavariable, ///
280
277
  generalMetavariableString = generalMetavariable.getString(),
281
278
  specificMetavariableString = specificMetavariable.getString();
@@ -1,20 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  import ontology from "../ontology";
4
+ import TemporaryContext from "../context/temporary";
4
5
 
5
6
  import { define } from "../ontology";
6
7
  import { assignAssignments } from "../utilities/assignments";
7
8
  import { subproofAssertionFromStatement } from "../utilities/context";
8
- import { statementFromJSON, procedureCallFromJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../utilities/json";
9
+ import { termsFromJSON, framesFromJSON, statementFromJSON, procedureCallFromJSON, termsToTermsJSON, framesToFramesJSON, statementToStatementJSON, procedureCallToProcedureCallJSON } from "../utilities/json";
9
10
 
10
11
  export default define(class Premise {
11
- constructor(node, string, statement, procedureCall) {
12
+ constructor(context, node, string, statement, procedureCall) {
13
+ this.context = context;
12
14
  this.node = node;
13
15
  this.string = string;
14
16
  this.statement = statement;
15
17
  this.procedureCall = procedureCall;
16
18
  }
17
19
 
20
+ getContext() {
21
+ return this.context;
22
+ }
23
+
18
24
  getNode() {
19
25
  return this.node;
20
26
  }
@@ -34,6 +40,10 @@ export default define(class Premise {
34
40
  verify(context) {
35
41
  let verifies = false;
36
42
 
43
+ const temporaryContext = TemporaryContext.fromNothing(context);
44
+
45
+ context = temporaryContext; ///
46
+
37
47
  const premiseString = this.string; ///
38
48
 
39
49
  context.trace(`Verifying the '${premiseString}' premise...`, this.node);
@@ -71,6 +81,8 @@ export default define(class Premise {
71
81
  }
72
82
 
73
83
  if (verifies) {
84
+ this.context = context;
85
+
74
86
  context.debug(`...verified the '${premiseString}' premise.`, this.node);
75
87
  }
76
88
 
@@ -95,7 +107,7 @@ export default define(class Premise {
95
107
  return unifiesIndependently;
96
108
  }
97
109
 
98
- unifyStepOrSubproof(stepOrSubproof, substitutions, generalContext, specificContext) {
110
+ unifyStepOrSubproof(stepOrSubproof, substitutions, context) {
99
111
  let stepOrSubproofUnifies = false;
100
112
 
101
113
  const stepOrSubProofStep = stepOrSubproof.isStep(),
@@ -109,33 +121,35 @@ export default define(class Premise {
109
121
  substitutions.snapshot();
110
122
 
111
123
  if (subproof !== null) {
112
- const subproofUnifies = this.unifySubproof(subproof, substitutions, generalContext, specificContext);
124
+ const subproofUnifies = this.unifySubproof(subproof, substitutions, context);
113
125
 
114
126
  stepOrSubproofUnifies = subproofUnifies; ///
115
127
  }
116
128
 
117
129
  if (step !== null) {
118
- const statementUnifies = this.unifyStep(step, substitutions, generalContext, specificContext);
130
+ const statementUnifies = this.unifyStep(step, substitutions, context);
119
131
 
120
132
  stepOrSubproofUnifies = statementUnifies; ///
121
133
  }
122
134
 
123
135
  if (stepOrSubproofUnifies) {
124
- substitutions.resolve(generalContext, specificContext);
136
+ substitutions.resolve(context);
125
137
  }
126
138
 
127
139
  stepOrSubproofUnifies ?
128
140
  substitutions.continue() :
129
- substitutions.rollback(specificContext);
141
+ substitutions.rollback(context);
130
142
 
131
143
  return stepOrSubproofUnifies;
132
144
  }
133
145
 
134
- unifyStep(step, substitutions, generalContext, specificContext) {
146
+ unifyStep(step, substitutions, context) {
135
147
  let stepUnifies = false;
136
148
 
149
+ context = step.getContext();
150
+
137
151
  const statement = step.getStatement(),
138
- statementUnifies = this.unifyStatement(statement, substitutions, generalContext, specificContext);
152
+ statementUnifies = this.unifyStatement(statement, substitutions, context);
139
153
 
140
154
  if (statementUnifies) {
141
155
  stepUnifies = true;
@@ -170,34 +184,53 @@ export default define(class Premise {
170
184
  return subproofUnifies;
171
185
  }
172
186
 
173
- unifyStatement(statement, substitutions, generalContext, specificContext) {
187
+ unifyStatement(statement, substitutions, context) {
174
188
  let statementUnifies;
175
189
 
176
190
  const premise = this, ///
177
191
  premiseString = premise.getString(),
178
192
  statementString = statement.getString();
179
193
 
180
- specificContext.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
194
+ context.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
181
195
 
182
196
  if (this.statement !== null) {
197
+ const generalContext = this.context, ///
198
+ specificContext = context; ///
199
+
183
200
  statementUnifies = this.statement.unifyStatement(statement, substitutions, generalContext, specificContext);
184
201
  }
185
202
 
186
203
  if (statementUnifies) {
187
- specificContext.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
204
+ context.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
188
205
  }
189
206
 
190
207
  return statementUnifies;
191
208
  }
192
209
 
193
210
  toJSON() {
194
- const statementJSON = statementToStatementJSON(this.statement),
195
- procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
211
+ let frames,
212
+ terms;
213
+
214
+ frames = this.context.getFrames();
215
+
216
+ terms = this.context.getTerms();
217
+
218
+ const procedureCallJSON = procedureCallToProcedureCallJSON(this.procedureCall),
219
+ statementJSON = statementToStatementJSON(this.statement),
220
+ framesJSON = framesToFramesJSON(frames),
221
+ termsJSON = termsToTermsJSON(terms);
222
+
223
+ frames = framesJSON; ///
224
+
225
+ terms = termsJSON; ///
226
+
227
+ const procedureCall = procedureCallJSON, ///
196
228
  statement = statementJSON, ///
197
- procedureCall = procedureCallJSON, ///
198
229
  json = {
230
+ procedureCall,
199
231
  statement,
200
- procedureCall
232
+ frames,
233
+ terms
201
234
  };
202
235
 
203
236
  return json;
@@ -206,8 +239,11 @@ export default define(class Premise {
206
239
  static name = "Premise";
207
240
 
208
241
  static fromJSON(json, context) {
209
- const statement = statementFromJSON(json, context),
210
- procedureCall = procedureCallFromJSON(json, context);
242
+ const terms = termsFromJSON(json, context),
243
+ frames = framesFromJSON(json, context),
244
+ statement = statementFromJSON(json, context),
245
+ procedureCall = procedureCallFromJSON(json, context),
246
+ temporaryContext = TemporaryContext.fromTermsAndFrames(terms, frames, context);
211
247
 
212
248
  let string;
213
249
 
@@ -219,8 +255,11 @@ export default define(class Premise {
219
255
  string = procedureCall.getString();
220
256
  }
221
257
 
222
- const node = null,
223
- premise = new Premise(node, string, statement, procedureCall);
258
+ const node = null;
259
+
260
+ context = temporaryContext; ///
261
+
262
+ const premise = new Premise(context, node, string, statement, procedureCall);
224
263
 
225
264
  return premise;
226
265
  }
@@ -231,7 +270,11 @@ export default define(class Premise {
231
270
  string = context.nodeAsString(node),
232
271
  statement = Statement.fromPremiseNode(premiseNode, context),
233
272
  procedureCall = ProcedureCall.fromPremiseNode(premiseNode, context),
234
- premise = new Premise(node, string, statement, procedureCall);
273
+ temporaryContext = null;
274
+
275
+ context = temporaryContext; ///
276
+
277
+ const premise = new Premise(context, node, string, statement, procedureCall);
235
278
 
236
279
  return premise
237
280
  }
@@ -8,29 +8,29 @@ import { define } from "../ontology";
8
8
  import { parametersFromJSON, procedureReferenceFromJSON, parametersToParametersJSON, procedureReferenceToProcedureReferenceJSON } from "../utilities/json";
9
9
 
10
10
  export default define(class ProcedureCall {
11
- constructor(node, string, procedureReference, parameters) {
12
- this.node = node;
11
+ constructor(string, node, parameters, procedureReference) {
13
12
  this.string = string;
14
- this.procedureReference = procedureReference;
13
+ this.node = node;
15
14
  this.parameters = parameters;
16
- }
17
-
18
- getNode() {
19
- return this.node;
15
+ this.procedureReference = procedureReference;
20
16
  }
21
17
 
22
18
  getString() {
23
19
  return this.string;
24
20
  }
25
21
 
26
- getProcedureReference() {
27
- return this.procedureReference;
22
+ getNode() {
23
+ return this.node;
28
24
  }
29
25
 
30
26
  getParameters() {
31
27
  return this.parameters;
32
28
  }
33
29
 
30
+ getProcedureReference() {
31
+ return this.procedureReference;
32
+ }
33
+
34
34
  getName() { return this.procedureReference.getName(); }
35
35
 
36
36
  findNodes(substitutions) {
@@ -118,11 +118,11 @@ export default define(class ProcedureCall {
118
118
  static name = "ProcedureCall";
119
119
 
120
120
  static fromJSON(json, context) {
121
- const procedureReference = procedureReferenceFromJSON(json, context),
121
+ const node = null,
122
122
  parameters = parametersFromJSON(json, context),
123
- node = null,
123
+ procedureReference = procedureReferenceFromJSON(json, context),
124
124
  string = stringFromProcedureReferenceAndParameters(procedureReference, parameters),
125
- procedureCall = new ProcedureCall(node, string, procedureReference, parameters);
125
+ procedureCall = new ProcedureCall(string, node, parameters, procedureReference);
126
126
 
127
127
  return procedureCall;
128
128
  }
@@ -155,10 +155,10 @@ export default define(class ProcedureCall {
155
155
  function procedureCallFromProcedureCallNode(procedureCallNode, context) {
156
156
  const { ProcedureCall, ProcedureReference } = ontology,
157
157
  node = procedureCallNode, ///
158
- procedureReference = ProcedureReference.fromProcedureCallNode(procedureCallNode, context),
159
158
  parameters = parametersFromProcedureCallNode(procedureCallNode, context),
159
+ procedureReference = ProcedureReference.fromProcedureCallNode(procedureCallNode, context),
160
160
  string = stringFromProcedureReferenceAndParameters(procedureReference, parameters),
161
- procedureCall = new ProcedureCall(node, string, procedureReference, parameters);
161
+ procedureCall = new ProcedureCall(string, node, parameters, procedureReference);
162
162
 
163
163
  return procedureCall;
164
164
  }
@@ -25,6 +25,8 @@ export default define(class ProcedureReference {
25
25
  return json;
26
26
  }
27
27
 
28
+ static name = "ProcedureReference";
29
+
28
30
  static fromJSON(json, context) {
29
31
  const { name } = json,
30
32
  string = name, ///
@@ -33,8 +35,6 @@ export default define(class ProcedureReference {
33
35
  return procedureReference;
34
36
  }
35
37
 
36
- static name = "ProcedureReference";
37
-
38
38
  static fromProcedureCallNode(procedureCallNode, context) {
39
39
  const procedureName = procedureCallNode.getProcedureName(),
40
40
  name = procedureName, ///
@@ -27,7 +27,7 @@ export default define(class Proof {
27
27
  verify(substitutions, conclusion, context) {
28
28
  let verifies = false;
29
29
 
30
- const localContext = LocalContext.fromContext(context); ///
30
+ const localContext = LocalContext.fromNothing(context); ///
31
31
 
32
32
  context = localContext; ///
33
33
 
@@ -33,12 +33,7 @@ export default define(class Reference {
33
33
  return metavariableNode;
34
34
  }
35
35
 
36
- isMetavariableEqualTo(metavariable) {
37
- const equalTo = this.metavariable.isEqualTo(metavariable),
38
- metavariableEqualTo = equalTo; ///
39
-
40
- return metavariableEqualTo;
41
- }
36
+ isMetavariableEqualToMetavariable(metavariable) { return this.metavariable.isEqualTo(metavariable); }
42
37
 
43
38
  matchMetavariableName(metavariableName) { return this.metavariable.matchMetavariableName(metavariableName); }
44
39
 
@@ -68,85 +68,6 @@ export default define(class Rule {
68
68
  return metavariableNameMatches;
69
69
  }
70
70
 
71
- unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, context) {
72
- let statementAndStepsOrSubproofsUnify = false;
73
-
74
- const generalContext = this.context, ///
75
- specificContext = context; ///
76
-
77
- const substitutions = Substitutions.fromNothing(),
78
- statementUnifiesWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, generalContext, specificContext);
79
-
80
- if (statementUnifiesWithConclusion) {
81
- const stepsOrSubproofsUnifyWithPremises = this.unifyStepsOrSubproofsWithPremises(stepsOrSubproofs, substitutions, generalContext, specificContext);
82
-
83
- if (stepsOrSubproofsUnifyWithPremises) {
84
- const substitutionsResolved = substitutions.areResolved();
85
-
86
- if (substitutionsResolved) {
87
- statementAndStepsOrSubproofsUnify = true;
88
- }
89
- }
90
- }
91
-
92
- return statementAndStepsOrSubproofsUnify;
93
- }
94
-
95
- unifyStatementWithConclusion(statement, substitutions, generalContext, specificContext) {
96
- let statementUnifiesWithConclusion = false;
97
-
98
- const statementUnifies = this.conclusion.unifyStatement(statement, substitutions, generalContext, specificContext);
99
-
100
- if (statementUnifies) {
101
- statementUnifiesWithConclusion = true;
102
- }
103
-
104
- return statementUnifiesWithConclusion;
105
- }
106
-
107
- unifyStepsOrSubproofsWithPremises(stepsOrSubproofs, substitutions, generalContext, specificContext) {
108
- stepsOrSubproofs = reverse(stepsOrSubproofs); ///
109
-
110
- const stepsOrSubproofsUnifyWithPremises = backwardsEvery(this.premises, (premise) => {
111
- const stepUnifiesWithPremise = this.unifyStepsOrSubproofsWithPremise(stepsOrSubproofs, premise, substitutions, generalContext, specificContext);
112
-
113
- if (stepUnifiesWithPremise) {
114
- return true;
115
- }
116
- });
117
-
118
- return stepsOrSubproofsUnifyWithPremises;
119
- }
120
-
121
- unifyStepsOrSubproofsWithPremise(stepsOrSubproofs, premise, substitutions, generalContext, specificContext) {
122
- let stepsOrSubproofsUnifyWithPremise = false;
123
-
124
- if (!stepsOrSubproofsUnifyWithPremise) {
125
- const context = specificContext, ///
126
- premiseUnifiesIndependently = premise.unifyIndependently(substitutions, context);
127
-
128
- if (premiseUnifiesIndependently) {
129
- stepsOrSubproofsUnifyWithPremise = true;
130
- }
131
- }
132
-
133
- if (!stepsOrSubproofsUnifyWithPremise) {
134
- const stepOrSubproof = extract(stepsOrSubproofs, (stepOrSubproof) => {
135
- const stepOrSubproofUnifies = premise.unifyStepOrSubproof(stepOrSubproof, substitutions, generalContext, specificContext);
136
-
137
- if (stepOrSubproofUnifies) {
138
- return true;
139
- }
140
- }) || null;
141
-
142
- if (stepOrSubproof !== null) {
143
- stepsOrSubproofsUnifyWithPremise = true;
144
- }
145
- }
146
-
147
- return stepsOrSubproofsUnifyWithPremise;
148
- }
149
-
150
71
  verify() {
151
72
  let verifies = false;
152
73
 
@@ -157,7 +78,7 @@ export default define(class Rule {
157
78
  const labelsVerify = this.verifyLabels();
158
79
 
159
80
  if (labelsVerify) {
160
- const localContext = LocalContext.fromContext(this.context),
81
+ const localContext = LocalContext.fromNothing(this.context),
161
82
  context = localContext, ///
162
83
  premisesVerify = this.verifyPremises(context);
163
84
 
@@ -236,6 +157,81 @@ export default define(class Rule {
236
157
  return proofVerifies;
237
158
  }
238
159
 
160
+ unifyStatementWithConclusion(statement, substitutions, context) {
161
+ let statementUnifiesWithConclusion = false;
162
+
163
+ const statementUnifies = this.conclusion.unifyStatement(statement, substitutions, context);
164
+
165
+ if (statementUnifies) {
166
+ statementUnifiesWithConclusion = true;
167
+ }
168
+
169
+ return statementUnifiesWithConclusion;
170
+ }
171
+
172
+ unifyStatementAndStepsOrSubproofs(statement, stepsOrSubproofs, context) {
173
+ let statementAndStepsOrSubproofsUnify = false;
174
+
175
+ const substitutions = Substitutions.fromNothing(),
176
+ statementUnifiesWithConclusion = this.unifyStatementWithConclusion(statement, substitutions, context);
177
+
178
+ if (statementUnifiesWithConclusion) {
179
+ const stepsOrSubproofsUnifiesWithPremises = this.unifyStepsOrSubproofsWithPremises(stepsOrSubproofs, substitutions, context);
180
+
181
+ if (stepsOrSubproofsUnifiesWithPremises) {
182
+ const substitutionsResolved = substitutions.areResolved();
183
+
184
+ if (substitutionsResolved) {
185
+ statementAndStepsOrSubproofsUnify = true;
186
+ }
187
+ }
188
+ }
189
+
190
+ return statementAndStepsOrSubproofsUnify;
191
+ }
192
+
193
+ unifyStepsOrSubproofsWithPremise(stepsOrSubproofs, premise, substitutions, context) {
194
+ let stepsOrSubproofsUnifiesWithPremise = false;
195
+
196
+ if (!stepsOrSubproofsUnifiesWithPremise) {
197
+ const premiseUnifiesIndependently = premise.unifyIndependently(substitutions, context);
198
+
199
+ if (premiseUnifiesIndependently) {
200
+ stepsOrSubproofsUnifiesWithPremise = true;
201
+ }
202
+ }
203
+
204
+ if (!stepsOrSubproofsUnifiesWithPremise) {
205
+ const stepOrSubproof = extract(stepsOrSubproofs, (stepOrSubproof) => {
206
+ const stepOrSubproofUnifies = premise.unifyStepOrSubproof(stepOrSubproof, substitutions, context);
207
+
208
+ if (stepOrSubproofUnifies) {
209
+ return true;
210
+ }
211
+ }) || null;
212
+
213
+ if (stepOrSubproof !== null) {
214
+ stepsOrSubproofsUnifiesWithPremise = true;
215
+ }
216
+ }
217
+
218
+ return stepsOrSubproofsUnifiesWithPremise;
219
+ }
220
+
221
+ unifyStepsOrSubproofsWithPremises(stepsOrSubproofs, substitutions, context) {
222
+ stepsOrSubproofs = reverse(stepsOrSubproofs); ///
223
+
224
+ const stepsOrSubproofsUnifiesWithPremises = backwardsEvery(this.premises, (premise) => {
225
+ const stepUnifiesWithPremise = this.unifyStepsOrSubproofsWithPremise(stepsOrSubproofs, premise, substitutions, context);
226
+
227
+ if (stepUnifiesWithPremise) {
228
+ return true;
229
+ }
230
+ });
231
+
232
+ return stepsOrSubproofsUnifiesWithPremises;
233
+ }
234
+
239
235
  toJSON() {
240
236
  const labelsJSON = labelsToLabelsJSON(this.labels),
241
237
  premisesJSON = premisesToPremisesJSON(this.premises),
@@ -91,7 +91,7 @@ export default define(class Section {
91
91
  static name = "Section";
92
92
 
93
93
  static fromSectionNode(sectionNode, context) {
94
- const localContext = LocalContext.fromContext(context);
94
+ const localContext = LocalContext.fromNothing(context);
95
95
 
96
96
  context = localContext; ///
97
97
 
@@ -71,7 +71,7 @@ export default define(class Signature {
71
71
  termSubstitution = TermSubstitution.fromTernAndVariable(term, variable, context),
72
72
  substitution = termSubstitution; ///
73
73
 
74
- substitutions.addSubstitution(substitution, specificContext);
74
+ substitutions.addSubstitution(substitution, context);
75
75
 
76
76
  return true;
77
77
  }