occam-verify-cli 1.0.792 → 1.0.799

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 (69) hide show
  1. package/lib/context/ephemeral.js +41 -11
  2. package/lib/context/file/nominal.js +5 -1
  3. package/lib/context/liminal.js +39 -16
  4. package/lib/context/proof.js +35 -40
  5. package/lib/context.js +23 -3
  6. package/lib/element/assertion/contained.js +10 -14
  7. package/lib/element/assertion/defined.js +6 -8
  8. package/lib/element/assumption/metaLevel.js +181 -0
  9. package/lib/element/assumption.js +24 -44
  10. package/lib/element/frame.js +12 -18
  11. package/lib/element/hypothesis.js +1 -1
  12. package/lib/element/judgement.js +19 -15
  13. package/lib/element/metavariable.js +73 -48
  14. package/lib/element/proofAssertion/step.js +5 -7
  15. package/lib/element/reference.js +21 -19
  16. package/lib/element/substitution/frame.js +12 -16
  17. package/lib/element/substitution/reference.js +20 -1
  18. package/lib/element/substitution/statement.js +22 -2
  19. package/lib/element/topLevelMetaAssertion.js +9 -9
  20. package/lib/node/assumption/metaLevel.js +27 -0
  21. package/lib/node/assumption.js +5 -5
  22. package/lib/node/declaration/metavariable.js +4 -4
  23. package/lib/node/frame.js +5 -2
  24. package/lib/nonTerminalNodeMap.js +3 -1
  25. package/lib/preamble.js +2 -1
  26. package/lib/process/instantiate.js +8 -2
  27. package/lib/process/unify.js +22 -35
  28. package/lib/ruleNames.js +5 -1
  29. package/lib/utilities/context.js +5 -5
  30. package/lib/utilities/element.js +34 -26
  31. package/lib/utilities/json.js +23 -1
  32. package/lib/utilities/string.js +25 -14
  33. package/lib/utilities/unification.js +3 -3
  34. package/lib/utilities/validation.js +9 -14
  35. package/package.json +4 -4
  36. package/src/context/ephemeral.js +63 -12
  37. package/src/context/file/nominal.js +6 -0
  38. package/src/context/liminal.js +54 -16
  39. package/src/context/proof.js +41 -47
  40. package/src/context.js +35 -2
  41. package/src/element/assertion/contained.js +10 -14
  42. package/src/element/assertion/defined.js +6 -8
  43. package/src/element/assumption/metaLevel.js +263 -0
  44. package/src/element/assumption.js +35 -63
  45. package/src/element/frame.js +11 -17
  46. package/src/element/hypothesis.js +1 -1
  47. package/src/element/judgement.js +18 -19
  48. package/src/element/metavariable.js +98 -58
  49. package/src/element/proofAssertion/step.js +5 -7
  50. package/src/element/reference.js +30 -23
  51. package/src/element/substitution/frame.js +11 -15
  52. package/src/element/substitution/reference.js +33 -0
  53. package/src/element/substitution/statement.js +33 -1
  54. package/src/element/topLevelMetaAssertion.js +15 -15
  55. package/src/node/assumption/metaLevel.js +23 -0
  56. package/src/node/assumption.js +8 -8
  57. package/src/node/declaration/metavariable.js +4 -4
  58. package/src/node/frame.js +6 -1
  59. package/src/nonTerminalNodeMap.js +3 -0
  60. package/src/preamble.js +1 -0
  61. package/src/process/instantiate.js +4 -0
  62. package/src/process/unify.js +25 -50
  63. package/src/ruleNames.js +1 -0
  64. package/src/utilities/context.js +4 -4
  65. package/src/utilities/element.js +47 -35
  66. package/src/utilities/json.js +27 -1
  67. package/src/utilities/string.js +34 -19
  68. package/src/utilities/unification.js +3 -3
  69. package/src/utilities/validation.js +10 -16
@@ -224,20 +224,30 @@ export default define(class Reference extends Element {
224
224
  unifyLabel(label) {
225
225
  let labelUnifies = false;
226
226
 
227
- const context = label.getContext(),
228
- labelString = label.getString(),
227
+ let context;
228
+
229
+ const labelString = label.getString(),
230
+ labelContext = label.getContext(),
229
231
  referenceString = this.getString(); ///
230
232
 
233
+ context = labelContext; ///
234
+
231
235
  context.trace(`Unifying the '${labelString}' label with the '${referenceString}' reference...`);
232
236
 
233
- reconcile((context) => {
237
+ const specificContext = labelContext; ///
238
+
239
+ context = this.getContext();
240
+
241
+ const generalContext = context; ///
242
+
243
+ reconcile((specificContext) => {
234
244
  const metavariable = label.getMetavariable(),
235
- metavariableUnifies = this.unifyMetavariable(metavariable, context);
245
+ metavariableUnifies = this.unifyMetavariable(metavariable, generalContext, specificContext);
236
246
 
237
247
  if (metavariableUnifies) {
238
248
  labelUnifies = true;
239
249
  }
240
- }, context);
250
+ }, specificContext);
241
251
 
242
252
  if (labelUnifies) {
243
253
  context.debug(`...unified the '${labelString}' label with the '${referenceString}' reference.`);
@@ -246,22 +256,15 @@ export default define(class Reference extends Element {
246
256
  return labelUnifies;
247
257
  }
248
258
 
249
- unifyMetavariable(metavariable, context) {
259
+ unifyMetavariable(metavariable, generalContext, specificContext) {
250
260
  let metavariableUnifies = false;
251
261
 
252
- const referenceString = this.getString(), ///
262
+ const context = specificContext, ///
263
+ referenceString = this.getString(), ///
253
264
  metavariableString = metavariable.getString();
254
265
 
255
266
  context.trace(`Unifying the '${metavariableString}' metavariable with the '${referenceString}' reference...`);
256
267
 
257
- const specificContext = context; ///
258
-
259
- context = this.getContext();
260
-
261
- const generalContext = context; ///
262
-
263
- context = specificContext; ///
264
-
265
268
  const metavariableUnifiesIntrinsically = this.metavariable.unifyMetavariableIntrinsically(metavariable, generalContext, specificContext);
266
269
 
267
270
  if (metavariableUnifiesIntrinsically) {
@@ -279,29 +282,33 @@ export default define(class Reference extends Element {
279
282
  let topLevelMetaAssertionUUnifies = false;
280
283
 
281
284
  const label = topLevelMetaAssertion.getLabel(),
285
+ labelContext = label.getContext(),
282
286
  referenceString = this.getString(), ///
287
+ temporaryContext = context, ///
283
288
  topLevelMetaAssertionString = topLevelMetaAssertion.getString();
284
289
 
285
290
  context.trace(`Unifying the '${topLevelMetaAssertionString}' top level meta-assertion with the '${referenceString}' reference...`);
286
291
 
287
- const specificContext = context; ///
292
+ const specificContext = labelContext; ///
288
293
 
289
- context = label.getContext();
294
+ context = this.getContext();
290
295
 
291
- reconcile((context) => {
296
+ const generalContext = context; ///
297
+
298
+ context = temporaryContext; ///
299
+
300
+ reconcile((specificContext) => {
292
301
  const metavariable = label.getMetavariable(),
293
- metavariableUnifies = this.unifyMetavariable(metavariable, context);
302
+ metavariableUnifies = this.unifyMetavariable(metavariable, generalContext, specificContext);
294
303
 
295
304
  if (metavariableUnifies) {
296
305
  this.topLevelMetaAssertion = topLevelMetaAssertion;
297
306
 
298
- context.commit(specificContext);
307
+ specificContext.commit(context);
299
308
 
300
309
  topLevelMetaAssertionUUnifies = true;
301
310
  }
302
- }, context);
303
-
304
- context = specificContext; ///
311
+ }, specificContext);
305
312
 
306
313
  if (topLevelMetaAssertionUUnifies) {
307
314
  context.debug(`...unified the '${topLevelMetaAssertionString}' top level meta-assertion with the '${referenceString}' reference.`);
@@ -3,8 +3,8 @@
3
3
  import Substitution from "../substitution";
4
4
 
5
5
  import { define } from "../../elements";
6
+ import { attempt, instantiate } from "../../utilities/context";
6
7
  import { instantiateFrameSubstitution } from "../../process/instantiate";
7
- import { attempt, descend, instantiate } from "../../utilities/context";
8
8
  import { frameSubstitutionStringFromFrameAndMetavariable } from "../../utilities/string";
9
9
  import { frameSubstitutionFromStatementNode, frameSubstitutionFromFrameSubstitutionNode } from "../../utilities/element";
10
10
 
@@ -132,15 +132,13 @@ export default define(class FrameSubstitution extends Substitution {
132
132
  const targetFrameSingular = this.targetFrame.isSingular();
133
133
 
134
134
  if (targetFrameSingular) {
135
- descend((context) => {
136
- const tragetFrame = this.targetFrame.validate(context);
135
+ const tragetFrame = this.targetFrame.validate(context);
137
136
 
138
- if (tragetFrame !== null) {
139
- this.targetFrame = tragetFrame;
137
+ if (tragetFrame !== null) {
138
+ this.targetFrame = tragetFrame;
140
139
 
141
- targetFrameValidates = true;
142
- }
143
- }, context);
140
+ targetFrameValidates = true;
141
+ }
144
142
  } else {
145
143
  context.debug(`The '${frameSubstitutionString}' frame substitution's '${targetFrameString}' target frame is not singular.`);
146
144
  }
@@ -161,15 +159,13 @@ export default define(class FrameSubstitution extends Substitution {
161
159
 
162
160
  context.trace(`Validating the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame...`);
163
161
 
164
- descend((context) => {
165
- const replacementFrame = this.replacementFrame.validate(context);
162
+ const replacementFrame = this.replacementFrame.validate(context);
166
163
 
167
- if (replacementFrame !== null) {
168
- this.replacementFrame = replacementFrame;
164
+ if (replacementFrame !== null) {
165
+ this.replacementFrame = replacementFrame;
169
166
 
170
- replacementFrameValidates = true;
171
- }
172
- }, context);
167
+ replacementFrameValidates = true;
168
+ }
173
169
 
174
170
  if (replacementFrameValidates) {
175
171
  context.debug(`...validated the '${frameSubstitutionString}' frame substitution's '${replacementFrameString}' replacement frame.`);
@@ -70,6 +70,23 @@ export default define(class ReferenceSubstitution extends Substitution {
70
70
  return comparesToParameter;
71
71
  }
72
72
 
73
+ compareSubstitution(substitution) {
74
+ let substitutionCompares = false;
75
+
76
+ const substitutionReferenceSubstitution = (substitution instanceof ReferenceSubstitution);
77
+
78
+ if (substitutionReferenceSubstitution) {
79
+ const substitutionNode = substitution.getNode(),
80
+ substitutionNodeMatches = this.matchNode(substitutionNode);
81
+
82
+ if (substitutionNodeMatches) {
83
+ substitutionCompares = true;
84
+ }
85
+ }
86
+
87
+ return substitutionCompares;
88
+ }
89
+
73
90
  validate(generalContext, specificContext) {
74
91
  let referenceSubstitution = null;
75
92
 
@@ -199,6 +216,22 @@ export default define(class ReferenceSubstitution extends Substitution {
199
216
 
200
217
  return referenceSubstitution;
201
218
  }
219
+
220
+ static fromAssumptionAndMetaLevelAssumption(assumption, metaLevelAssumption, context) {
221
+ let referenceSubstitution;
222
+
223
+ instantiate((context) => {
224
+ const reference = metaLevelAssumption.getReference(),
225
+ metavariable = assumption.getMetavariable(),
226
+ referenceSubstitutionString = referenceSubstitutionStringFromReferenceAndMetavariable(reference, metavariable),
227
+ string = referenceSubstitutionString, ///
228
+ referenceSubstitutionNode = instantiateReferenceSubstitution(string, context);
229
+
230
+ referenceSubstitution = referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
231
+ }, context);
232
+
233
+ return referenceSubstitution;
234
+ }
202
235
  });
203
236
 
204
237
  function targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
@@ -132,7 +132,11 @@ export default define(class StatementSubstitution extends Substitution {
132
132
  const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
133
133
 
134
134
  if (replacementStatementValidates) {
135
- validates = true;
135
+ const substitutionValidates = this.validateSubstitution(generalContext, specificContext);
136
+
137
+ if (substitutionValidates) {
138
+ validates = true;
139
+ }
136
140
  }
137
141
  }
138
142
 
@@ -155,6 +159,34 @@ export default define(class StatementSubstitution extends Substitution {
155
159
  return statementSubstitution;
156
160
  }
157
161
 
162
+ validateSubstitution(generalContext, specificContext) {
163
+ let substitutionValidates = true;
164
+
165
+ if (this.substitution !== null) {
166
+ const context = specificContext, ///
167
+ substitutionString = this.substitution.getString(),
168
+ statementSubstitutionString = this.getString();
169
+
170
+ context.trace(`Validating the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution...`);
171
+
172
+ specificContext = generalContext; ///
173
+
174
+ const substitution = this.substitution.validate(generalContext, specificContext);
175
+
176
+ if (substitution !== null) {
177
+ this.substitution = substitution;
178
+
179
+ substitutionValidates = true;
180
+ }
181
+
182
+ if (substitutionValidates) {
183
+ context.debug(`...validatewd the '${statementSubstitutionString}' statement substitution's '${substitutionString}' substitution.`);
184
+ }
185
+ }
186
+
187
+ return substitutionValidates;
188
+ }
189
+
158
190
  validateTargetStatement(generalContext, specificContext) {
159
191
  let targetStatementValidates = false;
160
192
 
@@ -3,27 +3,27 @@
3
3
  import { Element, asynchronousUtilities } from "occam-languages";
4
4
 
5
5
  import { asyncRestrict } from "../utilities/context";
6
- import { topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction } from "../utilities/string";
6
+ import { topLevelMetaAssertionStringFromLabelSuppositionsDeductionAndMetaLevelAssumptions } from "../utilities/string";
7
7
  import { labelFromJSON,
8
8
  labelToLabelJSON,
9
9
  deductionFromJSON,
10
- assumptionsFromJSON,
11
10
  suppositionsFromJSON,
12
11
  deductionToDeductionJSON,
13
- assumptionsToAssumptionsJSON,
14
- suppositionsToSuppositionsJSON } from "../utilities/json";
12
+ metaLevelAssumptionsFromJSON,
13
+ suppositionsToSuppositionsJSON,
14
+ metaLevelAssumptionsToMetaLevelAssumptionsJSON } from "../utilities/json";
15
15
 
16
16
  const { asyncForwardsEvery } = asynchronousUtilities;
17
17
 
18
18
  export default class TopLevelMetaAssertion extends Element {
19
- constructor(context, string, node, label, suppositions, deduction, proof, assumptions) {
19
+ constructor(context, string, node, label, suppositions, deduction, proof, metaLevelAssumptions) {
20
20
  super(context, string, node);
21
21
 
22
22
  this.label = label;
23
23
  this.suppositions = suppositions;
24
24
  this.deduction = deduction;
25
25
  this.proof = proof;
26
- this.assumptions = assumptions;
26
+ this.metaLevelAssumptions = metaLevelAssumptions;
27
27
  }
28
28
 
29
29
  getLabel() {
@@ -42,8 +42,8 @@ export default class TopLevelMetaAssertion extends Element {
42
42
  return this.proof;
43
43
  }
44
44
 
45
- getAssumptions() {
46
- return this.assumptions;
45
+ getMetaLevelAssumptions() {
46
+ return this.metaLevelAssumptions;
47
47
  }
48
48
 
49
49
  getStatement() {
@@ -121,7 +121,7 @@ export default class TopLevelMetaAssertion extends Element {
121
121
  }
122
122
  }
123
123
  }
124
- }, this.assumptions, context);
124
+ }, this.metaLevelAssumptions, context);
125
125
 
126
126
  if (verifies) {
127
127
  context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta assertion.`);
@@ -234,16 +234,16 @@ export default class TopLevelMetaAssertion extends Element {
234
234
  const labelJSON = labelToLabelJSON(this.label),
235
235
  deductionJSON = deductionToDeductionJSON(this.deduction),
236
236
  suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
237
- assumptionsJSON = assumptionsToAssumptionsJSON(this.assumptions),
237
+ metaLevelAssumptionsJSON = metaLevelAssumptionsToMetaLevelAssumptionsJSON(this.metaLevelAssumptions),
238
238
  label = labelJSON, ///
239
239
  deduction = deductionJSON, ///
240
240
  suppositions = suppositionsJSON, ///
241
- assumptions = assumptionsJSON, ///
241
+ metaLevelAssumptions = metaLevelAssumptionsJSON, ///
242
242
  json = {
243
243
  label,
244
244
  deduction,
245
245
  suppositions,
246
- assumptions
246
+ metaLevelAssumptions
247
247
  };
248
248
 
249
249
  return json;
@@ -253,11 +253,11 @@ export default class TopLevelMetaAssertion extends Element {
253
253
  const label = labelFromJSON(json, context),
254
254
  deduction = deductionFromJSON(json, context),
255
255
  suppositions = suppositionsFromJSON(json, context),
256
- assumptions = assumptionsFromJSON(json, context),
256
+ metaLevelAssumptions = metaLevelAssumptionsFromJSON(json, context),
257
257
  node = null,
258
258
  proof = null,
259
- string = topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction(label, suppositions, deduction),
260
- topLevelMetaAssertion = new Class(context, string, node, label, suppositions, deduction, proof, assumptions);
259
+ string = topLevelMetaAssertionStringFromLabelSuppositionsDeductionAndMetaLevelAssumptions(label, suppositions, deduction, metaLevelAssumptions),
260
+ topLevelMetaAssertion = new Class(context, string, node, label, suppositions, deduction, proof, metaLevelAssumptions);
261
261
 
262
262
  return topLevelMetaAssertion;
263
263
  }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ import { NonTerminalNode } from "occam-languages";
4
+
5
+ import { REFERENCE_RULE_NAME, STATEMENT_RULE_NAME } from "../../ruleNames";
6
+
7
+ export default class MetaLevelAssumptionpNode extends NonTerminalNode {
8
+ getReferenceNode() {
9
+ const ruleName = REFERENCE_RULE_NAME,
10
+ referenceNode = this.getNodeByRuleName(ruleName);
11
+
12
+ return referenceNode;
13
+ }
14
+
15
+ getStatementNode() {
16
+ const ruleName = STATEMENT_RULE_NAME,
17
+ statementNode = this.getNodeByRuleName(ruleName);
18
+
19
+ return statementNode;
20
+ }
21
+
22
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(MetaLevelAssumptionpNode, ruleName, childNodes, opacity, precedence); }
23
+ }
@@ -2,16 +2,9 @@
2
2
 
3
3
  import { NonTerminalNode } from "occam-languages";
4
4
 
5
- import { STATEMENT_RULE_NAME, METAVARIABLE_RULE_NAME } from "../ruleNames";
5
+ import { METAVARIABLE_RULE_NAME, STATEMENT_RULE_NAME } from "../ruleNames";
6
6
 
7
7
  export default class AssumptionpNode extends NonTerminalNode {
8
- getStatementNode() {
9
- const ruleName = STATEMENT_RULE_NAME,
10
- statementNode = this.getNodeByRuleName(ruleName);
11
-
12
- return statementNode;
13
- }
14
-
15
8
  getMetavariableNode() {
16
9
  const ruleName = METAVARIABLE_RULE_NAME,
17
10
  metavariableNode = this.getNodeByRuleName(ruleName);
@@ -19,5 +12,12 @@ export default class AssumptionpNode extends NonTerminalNode {
19
12
  return metavariableNode;
20
13
  }
21
14
 
15
+ getStatementNode() {
16
+ const ruleName = STATEMENT_RULE_NAME,
17
+ statementNode = this.getNodeByRuleName(ruleName);
18
+
19
+ return statementNode;
20
+ }
21
+
22
22
  static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return NonTerminalNode.fromRuleNameChildNodesOpacityAndPrecedence(AssumptionpNode, ruleName, childNodes, opacity, precedence); }
23
23
  }
@@ -5,11 +5,11 @@ import DeclarationNode from "../../node/declaration";
5
5
  import { META_TYPE_RULE_NAME, METAVARIABLE_RULE_NAME } from "../../ruleNames";
6
6
 
7
7
  export default class MetavariableDeclarationNode extends DeclarationNode {
8
- getTypeNode() {
9
- const metavariableNode = this.getMetavariableNode(),
10
- typeNode = metavariableNode.getTypeNode();
8
+ getMetaTypeName() {
9
+ const metaTypeNode = this.getMetaTypeNode(),
10
+ metaTypeName = metaTypeNode.getMetaTypeName();
11
11
 
12
- return typeNode;
12
+ return metaTypeName;
13
13
  }
14
14
 
15
15
  getMetaTypeNode() {
package/src/node/frame.js CHANGED
@@ -11,7 +11,12 @@ export default class FrameNode extends NonTerminalNode {
11
11
  const metavariableNode = this.getMetavariableNode();
12
12
 
13
13
  if (metavariableNode !== null) {
14
- singular = true;
14
+ const assumptionNodes = this.getAssumptionNodes(),
15
+ assumptionNodesLength = assumptionNodes.length;
16
+
17
+ if (assumptionNodesLength === 0) {
18
+ singular = true;
19
+ }
15
20
  }
16
21
 
17
22
  return singular;
@@ -75,6 +75,7 @@ import SatisfiesAssertionNode from "./node/assertion/satisfies";
75
75
  import ParenthesisedLabelsNode from "./node/parenthesisedLabels"
76
76
  import PropertyDeclarationNode from "./node/declaration/property";
77
77
  import VariableDeclarationNode from "./node/declaration/variable";
78
+ import MetaLevelAssumptionpNode from "./node/assumption/metaLevel";
78
79
  import SimpleTypeDeclarationNode from "./node/declaration/simpleType";
79
80
  import CombinatorDeclarationNode from "./node/declaration/combinator";
80
81
  import ReferenceSubstitutionNode from "./node/substitution/reference";
@@ -160,6 +161,7 @@ import {
160
161
  PARENTHESISED_LABELS_RULE_NAME,
161
162
  PROPERTY_DECLARATION_RULE_NAME,
162
163
  VARIABLE_DECLARATION_RULE_NAME,
164
+ META_LEVEL_ASSUMPTION_RULE_NAME,
163
165
  COMBINATOR_DECLARATION_RULE_NAME,
164
166
  REFERENCE_SUBSTITUTION_RULE_NAME,
165
167
  STATEMENT_SUBSTITUTION_RULE_NAME,
@@ -245,6 +247,7 @@ const NonTerminalNodeMap = {
245
247
  [PARENTHESISED_LABELS_RULE_NAME]: ParenthesisedLabelsNode,
246
248
  [VARIABLE_DECLARATION_RULE_NAME]: VariableDeclarationNode,
247
249
  [PROPERTY_DECLARATION_RULE_NAME]: PropertyDeclarationNode,
250
+ [META_LEVEL_ASSUMPTION_RULE_NAME]: MetaLevelAssumptionpNode,
248
251
  [COMBINATOR_DECLARATION_RULE_NAME]: CombinatorDeclarationNode,
249
252
  [STATEMENT_SUBSTITUTION_RULE_NAME]: StatementSubstitutionNode,
250
253
  [REFERENCE_SUBSTITUTION_RULE_NAME]: ReferenceSubstitutionNode,
package/src/preamble.js CHANGED
@@ -50,6 +50,7 @@ import PropertyAssertion from "./element/assertion/property";
50
50
  import ProcedureReference from "./element/procedureReference";
51
51
  import ContainedAssertion from "./element/assertion/contained";
52
52
  import SatisfiesAssertion from "./element/assertion/satisfies";
53
+ import MetaLevelAssumption from "./element/assumption/metaLevel";
53
54
  import VariableDeclaration from "./element/declaration/variable";
54
55
  import BracketedCombinator from "./element/combinator/bracketed";
55
56
  import BracketedConstructor from "./element/constructor/bracketed";
@@ -33,6 +33,7 @@ import { TERM_RULE_NAME,
33
33
  PROCEDURE_REFERENCE_RULE_NAME,
34
34
  CONTAINED_ASSERTION_RULE_NAME,
35
35
  SATISFIES_ASSERTION_RULE_NAME,
36
+ META_LEVEL_ASSUMPTION_RULE_NAME,
36
37
  STATEMENT_SUBSTITUTION_RULE_NAME,
37
38
  REFERENCE_SUBSTITUTION_RULE_NAME } from "../ruleNames";
38
39
 
@@ -68,6 +69,7 @@ const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
68
69
  procedureReferencelaceholderRule = ruleFromRuleName(PROCEDURE_REFERENCE_RULE_NAME),
69
70
  containedAssertionPlaceholderRule = ruleFromRuleName(CONTAINED_ASSERTION_RULE_NAME),
70
71
  satisfiesAssertionPlaceholderRule = ruleFromRuleName(SATISFIES_ASSERTION_RULE_NAME),
72
+ metaLevelAssumptionPlaceholderRule = ruleFromRuleName(META_LEVEL_ASSUMPTION_RULE_NAME),
71
73
  statementSubstitutionPlaceholderRule = ruleFromRuleName(STATEMENT_SUBSTITUTION_RULE_NAME),
72
74
  referenceSubstitutionPlaceholderRule = ruleFromRuleName(REFERENCE_SUBSTITUTION_RULE_NAME);
73
75
 
@@ -155,6 +157,8 @@ export function instantiateContainedAssertion(string, context) { return instanti
155
157
 
156
158
  export function instantiateSatisfiesAssertion(string, context) { return instantiate(satisfiesAssertionPlaceholderRule, string, context); }
157
159
 
160
+ export function instantiateMetaLevelAssumption(string, context) { return instantiate(metaLevelAssumptionPlaceholderRule, string, context); }
161
+
158
162
  export function instantiateStatementSubstitution(string, context) { return instantiate(statementSubstitutionPlaceholderRule, string, context); }
159
163
 
160
164
  export function instantiateReferenceSubstitution(string, context) { return instantiate(referenceSubstitutionPlaceholderRule, string, context); }
@@ -17,6 +17,7 @@ const typeNodeQuery = nodeQuery("/type"),
17
17
  metavariableNodeQuery = nodeQuery("/metavariable"),
18
18
  termVariableNodeQuery = nodeQuery("/term/variable!"),
19
19
  frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
20
+ referenceMetavariableNodeQuery = nodeQuery("/reference/metavariable!"),
20
21
  statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
21
22
  assumptionMetavariableNodeQuery = nodeQuery("/assumption/metavariable!");
22
23
 
@@ -29,21 +30,24 @@ class MetaLevelPass extends ZipPassBase {
29
30
  let success = false;
30
31
 
31
32
  let context,
33
+ reference,
32
34
  metavariableNode;
33
35
 
34
36
  context = generalContext; ///
35
37
 
36
38
  metavariableNode = generalAssumptionMetavariableNode; ///
37
39
 
38
- const metavariableName = metavariableNode.getMetavariableName(),
39
- metavariable = context.findMetavariableByMetavariableName(metavariableName);
40
+ reference = context.findReferenceByMetavariableNode(metavariableNode);
41
+
42
+ const metavariable = reference.getMetavariable();
40
43
 
41
44
  context = specificContext; ///
42
45
 
43
46
  metavariableNode = specificAssumptionMetavariableNode; ///
44
47
 
45
- const reference = context.findReferenceByMetavariableNode(metavariableNode),
46
- referenceUnifies = metavariable.unifyReference(reference, generalContext, specificContext);
48
+ reference = context.findReferenceByMetavariableNode(metavariableNode);
49
+
50
+ const referenceUnifies = metavariable.unifyReference(reference, generalContext, specificContext);
47
51
 
48
52
  if (referenceUnifies) {
49
53
  success = true;
@@ -64,8 +68,7 @@ class MetaLevelPass extends ZipPassBase {
64
68
  context = generalContext; ///
65
69
 
66
70
  const metavariableNode = generalStatementMetavariableNode, ///
67
- metavariableName = metavariableNode.getMetavariableName(),
68
- metavariable = context.findMetavariableByMetavariableName(metavariableName),
71
+ metavariable = context.findMetavariableByMetavariableNode(metavariableNode),
69
72
  metavariableNodeParentNode = metavariableNode.getParentNode();
70
73
 
71
74
  statementNode = metavariableNodeParentNode; ///
@@ -96,14 +99,13 @@ class MetaLevelPass extends ZipPassBase {
96
99
  let success = false;
97
100
 
98
101
  const frameNode = specificFrameNode, ///
99
- metavariableNode = generalFrameMetavariableNode, ///
100
- metavariableName = metavariableNode.getMetavariableName();
102
+ metavariableNode = generalFrameMetavariableNode;
101
103
 
102
104
  let context;
103
105
 
104
106
  context = generalContext; ///
105
107
 
106
- const metavariable = context.findMetavariableByMetavariableName(metavariableName);
108
+ const metavariable = context.findMetavariableByMetavariableNode(metavariableNode);
107
109
 
108
110
  context = specificContext; ///
109
111
 
@@ -157,14 +159,13 @@ class AssumptionPass extends ZipPass {
157
159
  let success = false;
158
160
 
159
161
  const statementNode = specificStatementNode, ///
160
- metavariableNode = generalStatementMetavariableNode, ///
161
- metavariableName = metavariableNode.getMetavariableName();
162
+ metavariableNode = generalStatementMetavariableNode; ///
162
163
 
163
164
  let context;
164
165
 
165
166
  context = generalContext; ///
166
167
 
167
- const metavariable = context.findMetavariableByMetavariableName(metavariableName);
168
+ const metavariable = context.findMetavariableByMetavariableNode(metavariableNode);
168
169
 
169
170
  context = specificContext; ///
170
171
 
@@ -181,56 +182,31 @@ class AssumptionPass extends ZipPass {
181
182
  },
182
183
  {
183
184
  generalNodeQuery: metavariableNodeQuery,
184
- specificNodeQuery: metavariableNodeQuery,
185
- run: (generalMetavariableNode, specificMetavariableNode, generalContext, specificContext) => {
185
+ specificNodeQuery: referenceMetavariableNodeQuery,
186
+ run: (generalMetavariableNode, specificReferenceMetavariableNode, generalContext, specificContext) => {
186
187
  let success = false;
187
188
 
188
189
  let context,
190
+ reference,
189
191
  metavariableNode;
190
192
 
191
193
  context = generalContext; ///
192
194
 
193
195
  metavariableNode = generalMetavariableNode; ///
194
196
 
195
- const metavariableName = metavariableNode.getMetavariableName(),
196
- metavariable = context.findMetavariableByMetavariableName(metavariableName);
197
-
198
- context = specificContext; ///
199
-
200
- metavariableNode = specificMetavariableNode; ///
201
-
202
- const reference = context.findReferenceByMetavariableNode(metavariableNode),
203
- referenceUnifies = metavariable.unifyReference(reference, generalContext, specificContext);
204
-
205
- if (referenceUnifies) {
206
- success = true;
207
- }
208
-
209
- return success;
210
- }
211
- },
212
- {
213
- generalNodeQuery: termVariableNodeQuery,
214
- specificNodeQuery: termNodeQuery,
215
- run: (generalTermVariableNode, specificTermNode, generalContext, specificContext) => {
216
- let success = false;
217
-
218
- const termNode = specificTermNode, ///
219
- variableNode = generalTermVariableNode, ///
220
- variableIdentifier = variableNode.getVariableIdentifier();
197
+ reference = context.findReferenceByMetavariableNode(metavariableNode);
221
198
 
222
- let context;
199
+ const metavariable = reference.getMetavariable();
223
200
 
224
- context = generalContext; ///
201
+ context = specificContext; ///
225
202
 
226
- const variable = context.findVariableByVariableIdentifier(variableIdentifier);
203
+ metavariableNode = specificReferenceMetavariableNode; ///
227
204
 
228
- context = specificContext; ///
205
+ reference = context.findReferenceByMetavariableNode(metavariableNode);
229
206
 
230
- const term = context.findTermByTermNode(termNode),
231
- termUnifies = variable.unifyTerm(term, generalContext, specificContext);
207
+ const referenceUnifies = metavariable.unifyReference(reference, generalContext, specificContext);
232
208
 
233
- if (termUnifies) {
209
+ if (referenceUnifies) {
234
210
  success = true;
235
211
  }
236
212
 
@@ -406,14 +382,13 @@ class SubstitutionPass extends ZipPass {
406
382
  let success = false;
407
383
 
408
384
  const frameNode = specificFrameNode, ///
409
- metavariableNode = generalFrameMetavariableNode, ///
410
- metavariableName = metavariableNode.getMetavariableName();
385
+ metavariableNode = generalFrameMetavariableNode; ///
411
386
 
412
387
  let context;
413
388
 
414
389
  context = generalContext; ///
415
390
 
416
- const metavariable = context.findMetavariableByMetavariableName(metavariableName);
391
+ const metavariable = context.findMetavariableByMetavariableNode(metavariableNode);
417
392
 
418
393
  context = specificContext; ///
419
394
 
package/src/ruleNames.js CHANGED
@@ -75,6 +75,7 @@ export const SATISFIES_ASSERTION_RULE_NAME = "satisfiesAssertion";
75
75
  export const PARENTHESISED_LABELS_RULE_NAME = "parenthesisedLabels";
76
76
  export const PROPERTY_DECLARATION_RULE_NAME = "propertyDeclaration";
77
77
  export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
78
+ export const META_LEVEL_ASSUMPTION_RULE_NAME = "metaLevelAssumption";
78
79
  export const COMBINATOR_DECLARATION_RULE_NAME = "combinatorDeclaration";
79
80
  export const STATEMENT_SUBSTITUTION_RULE_NAME = "statementSubstitution";
80
81
  export const REFERENCE_SUBSTITUTION_RULE_NAME = "referenceSubstitution";