occam-verify-cli 1.0.731 → 1.0.733

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 (41) hide show
  1. package/lib/context/ephemeral.js +2 -7
  2. package/lib/context/liminal.js +2 -7
  3. package/lib/context/scoped.js +27 -27
  4. package/lib/context.js +22 -6
  5. package/lib/element/assertion/satisfies.js +1 -1
  6. package/lib/element/proofAssertion/supposition.js +1 -1
  7. package/lib/element/substitution/metaLevel.js +138 -0
  8. package/lib/element/substitution/reference.js +8 -13
  9. package/lib/element/substitution/statement.js +7 -7
  10. package/lib/element/substitution/term.js +7 -7
  11. package/lib/element/typePrefix.js +1 -1
  12. package/lib/node/substitution/metaLevel.js +40 -0
  13. package/lib/nonTerminalNodeMap.js +6 -4
  14. package/lib/preamble.js +2 -1
  15. package/lib/process/instantiate.js +8 -2
  16. package/lib/ruleNames.js +6 -2
  17. package/lib/utilities/context.js +5 -5
  18. package/lib/utilities/element.js +26 -2
  19. package/lib/utilities/string.js +7 -12
  20. package/lib/utilities/unification.js +10 -4
  21. package/package.json +4 -4
  22. package/src/context/ephemeral.js +1 -9
  23. package/src/context/liminal.js +1 -9
  24. package/src/context/scoped.js +34 -34
  25. package/src/context.js +33 -6
  26. package/src/element/assertion/satisfies.js +1 -2
  27. package/src/element/proofAssertion/supposition.js +1 -2
  28. package/src/element/substitution/metaLevel.js +201 -0
  29. package/src/element/substitution/reference.js +7 -13
  30. package/src/element/substitution/statement.js +11 -11
  31. package/src/element/substitution/term.js +11 -11
  32. package/src/element/typePrefix.js +1 -2
  33. package/src/node/substitution/metaLevel.js +37 -0
  34. package/src/nonTerminalNodeMap.js +7 -4
  35. package/src/preamble.js +1 -0
  36. package/src/process/instantiate.js +6 -2
  37. package/src/ruleNames.js +2 -1
  38. package/src/utilities/context.js +4 -4
  39. package/src/utilities/element.js +31 -1
  40. package/src/utilities/string.js +5 -13
  41. package/src/utilities/unification.js +14 -7
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+
3
+ import Substitution from "../substitution";
4
+
5
+ import { define } from "../../elements";
6
+ import { literally } from "../../utilities/context";
7
+ import { ephemeralContextFromJSON } from "../../utilities/json";
8
+ import { instantiateMetaLevelSubstitution } from "../../process/instantiate";
9
+ import { metaLevelSubstitutionStringFromStatementAndReference } from "../../utilities/string";
10
+ import { targetReferenceFromMetaLevelSubstitutionNode, replacementStatementFromMetaLevelSubstitutionNode, metaLevelSubstitutionFromMetaLevelSubstitutionNode } from "../../utilities/element";
11
+
12
+ export default define(class MetaLevelSubstitution extends Substitution {
13
+ constructor(context, string, node, targetReference, replacementStatement) {
14
+ super(context, string, node);
15
+
16
+ this.targetReference = targetReference;
17
+ this.replacementStatement = replacementStatement;
18
+ }
19
+
20
+ getTargetReference() {
21
+ return this.targetReference;
22
+ }
23
+
24
+ getReplacementStatement() {
25
+ return this.replacementStatement;
26
+ }
27
+
28
+ getMetaLevelSubstitutionNode() {
29
+ const node = this.getNode(),
30
+ metaLevelSubstitutionNode = node; ///
31
+
32
+ return metaLevelSubstitutionNode;
33
+ }
34
+
35
+ getTargetNode() {
36
+ const targetReferenceNode = this.targetReference.getNode(),
37
+ tergetNode = targetReferenceNode; ///
38
+
39
+ return tergetNode;
40
+ }
41
+
42
+ getReplacementNode() {
43
+ const replacementStatementNode = this.replacementStatement.getNode(),
44
+ replacementNode = replacementStatementNode; ///
45
+
46
+ return replacementNode;
47
+ }
48
+
49
+ validate(generalContext, specificContext) {
50
+ let metaLevelSubstitution = null;
51
+
52
+ const context = this.getContext();
53
+
54
+ specificContext = context; ///
55
+
56
+ const metaLevelSubstitutionString = this.getString(); ///
57
+
58
+ context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level substitution...`);
59
+
60
+ const validSubstitution = this.findValidSubstiution(context);
61
+
62
+ if (validSubstitution) {
63
+ metaLevelSubstitution = validSubstitution; ///
64
+
65
+ context.debug(`...the '${metaLevelSubstitutionString}' meta-level substitution is already valid.`);
66
+ } else {
67
+ let validates = false;
68
+
69
+ const targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
70
+
71
+ if (targetReferenceValidates) {
72
+ const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
73
+
74
+ if (replacementStatementValidates) {
75
+ validates = true;
76
+ }
77
+ }
78
+
79
+ if (validates) {
80
+ const substitution = this; ///
81
+
82
+ metaLevelSubstitution = substitution; ///
83
+
84
+ context.addSubstitution(substitution);
85
+
86
+ context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level substitution.`);
87
+ }
88
+ }
89
+
90
+ return metaLevelSubstitution;
91
+ }
92
+
93
+ validateTargetReference(generalContext, specificContext) {
94
+ let targetReferenceValidates = false;
95
+
96
+ const context = generalContext, ///
97
+ targetReferenceString = this.targetReference.getString(),
98
+ metaLevelSubstitutionString = this.getString(); ///
99
+
100
+ context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level subtitution's '${targetReferenceString}' target reference...`);
101
+
102
+ const targetReference = this.targetReference.validate(context);
103
+
104
+ if (targetReference !== null) {
105
+ targetReferenceValidates = true;
106
+ }
107
+
108
+ if (targetReferenceValidates) {
109
+ context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level subtitution's '${targetReferenceString}' target reference...`);
110
+ }
111
+
112
+ return targetReferenceValidates;
113
+ }
114
+
115
+ validateReplacementStatement(generalContext, specificContext) {
116
+ let replacementStatementValidates;
117
+
118
+ const context = specificContext, ///
119
+ replacementStatementString = this.replacementStatement.getString(),
120
+ metaLevelSubstitutionString = this.getString(); ///
121
+
122
+ context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level subtitution's '${replacementStatementString}' replacement statement...`);
123
+
124
+ const stated = true,
125
+ replacementStatement = this.replacementStatement.validate(stated, context);
126
+
127
+ if (replacementStatement !== null) {
128
+ replacementStatementValidates = true;
129
+ }
130
+
131
+ if (replacementStatementValidates) {
132
+ context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level subtitution's '${replacementStatementString}' replacement statement.`);
133
+ }
134
+
135
+ return replacementStatementValidates;
136
+ }
137
+
138
+ toJSON() {
139
+ let context;
140
+
141
+ context = this.getContext();
142
+
143
+ const contextJSON = context.toJSON();
144
+
145
+ context = contextJSON; ///
146
+
147
+ const string = this.getString(),
148
+ json = {
149
+ context,
150
+ string
151
+ };
152
+
153
+ return json;
154
+ }
155
+
156
+ static name = "MetaLevelSubstitution";
157
+
158
+ static fromJSON(json, context) {
159
+ const metaLevelSubstitution = literally((context) => {
160
+ const { string } = json,
161
+ metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
162
+ targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
163
+ replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
164
+ node = metaLevelSubstitutionNode, ///
165
+ ephemeralContext = ephemeralContextFromJSON(json, context);
166
+
167
+ context = ephemeralContext; ///
168
+
169
+ const metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
170
+
171
+ return metaLevelSubstitution;
172
+ }, context);
173
+
174
+ return metaLevelSubstitution;
175
+ }
176
+
177
+ static fromStatementAndReference(statement, reference, context) {
178
+ return literally((context) => {
179
+ const metaLevelSubstitutionString = metaLevelSubstitutionStringFromStatementAndReference(statement, reference),
180
+ string = metaLevelSubstitutionString, ///
181
+ metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
182
+ metaLevelSubstitution = metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
183
+
184
+ return metaLevelSubstitution;
185
+ }, context);
186
+ }
187
+ });
188
+
189
+ function targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context) {
190
+ const targetReferenceNode = metaLevelSubstitutionNode.getTargetReferenceNode(),
191
+ targetReference = context.findReferenceByReferenceNode(targetReferenceNode);
192
+
193
+ return targetReference;
194
+ }
195
+
196
+ function replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context) {
197
+ const replacementStatementNode = metaLevelSubstitutionNode.getReplacementStatementNode(),
198
+ replacementStatement = context.findStatementByStatementNode(replacementStatementNode);
199
+
200
+ return replacementStatement;
201
+ }
@@ -123,16 +123,10 @@ export default define(class ReferenceSubstitution extends Substitution {
123
123
 
124
124
  context.trace(`Validating the '${referenceSubstitutionString}' reference subtitution's '${targetReferenceString}' target reference...`);
125
125
 
126
- const targetReferenceSingular = this.targetReference.isSingular();
126
+ const targetReference = this.targetReference.validate(context);
127
127
 
128
- if (targetReferenceSingular) {
129
- const targetReference = this.targetReference.validate(context);
130
-
131
- if (targetReference !== null) {
132
- targetReferenceValidates = true;
133
- }
134
- } else {
135
- context.debug(`The '${referenceSubstitutionString}' reference subtitution's '${targetReferenceString}' target reference is not singular.`);
128
+ if (targetReference !== null) {
129
+ targetReferenceValidates = true;
136
130
  }
137
131
 
138
132
  if (targetReferenceValidates) {
@@ -200,15 +194,15 @@ export default define(class ReferenceSubstitution extends Substitution {
200
194
  }
201
195
  });
202
196
 
203
- function targetReferenceFromReferenceSubstitutionNode(frameSubstitutionNode, context) {
204
- const targetReferenceNode = frameSubstitutionNode.getTargetReferenceNode(),
197
+ function targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
198
+ const targetReferenceNode = referenceSubstitutionNode.getTargetReferenceNode(),
205
199
  targetReference = context.findReferenceByReferenceNode(targetReferenceNode);
206
200
 
207
201
  return targetReference;
208
202
  }
209
203
 
210
- function replacementReferenceFromReferenceSubstitutionNode(frameSubstitutionNode, context) {
211
- const replacementReferenceNode = frameSubstitutionNode.getReplacementReferenceNode(),
204
+ function replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
205
+ const replacementReferenceNode = referenceSubstitutionNode.getReplacementReferenceNode(),
212
206
  replacementReference = context.findReferenceByReferenceNode(replacementReferenceNode);
213
207
 
214
208
  return replacementReference;
@@ -5,9 +5,9 @@ import Substitution from "../substitution";
5
5
  import { define } from "../../elements";
6
6
  import { unifySubstitution } from "../../process/unify";
7
7
  import { stripBracketsFromStatement } from "../../utilities/brackets";
8
+ import { instantiateStatementSubstitution } from "../../process/instantiate";
8
9
  import { liminally, literally, synthetically } from "../../utilities/context";
9
10
  import { statementSubstitutionFromStatementSubstitutionNode } from "../../utilities/element";
10
- import { instantiateReferenceSubstitution, instantiateStatementSubstitution } from "../../process/instantiate";
11
11
  import { statementSubstitutionStringFromStatementAndMetavariable, statementSubstitutionStringFromStatementMetavariableAndSubstitution } from "../../utilities/string";
12
12
 
13
13
  export default define(class StatementSubstitution extends Substitution {
@@ -331,10 +331,10 @@ export default define(class StatementSubstitution extends Substitution {
331
331
  if (this.name === name) {
332
332
  literally((context) => {
333
333
  const { string } = json,
334
- referenceSubstitutionNode = instantiateReferenceSubstitution(string, context),
335
- node = referenceSubstitutionNode, ///
336
- targetStatement = targetStatementFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
337
- replacementStatement = replacementStatementFromReferenceSubstitutionNode(referenceSubstitutionNode, context);
334
+ statementSubstitutionNode = instantiateStatementSubstitution(string, context),
335
+ node = statementSubstitutionNode, ///
336
+ targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
337
+ replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context);
338
338
 
339
339
  context = null;
340
340
 
@@ -372,16 +372,16 @@ export default define(class StatementSubstitution extends Substitution {
372
372
  }
373
373
  });
374
374
 
375
- function targetStatementFromReferenceSubstitutionNode(frameSubstitutionNode, context) {
376
- const targetStatementNode = frameSubstitutionNode.getTargetReferenceNode(),
377
- targetStatement = context.findReferenceByReferenceNode(targetStatementNode);
375
+ function targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context) {
376
+ const targetStatementNode = statementSubstitutionNode.getTargetStatementNode(),
377
+ targetStatement = context.findStatementByStatementNode(targetStatementNode);
378
378
 
379
379
  return targetStatement;
380
380
  }
381
381
 
382
- function replacementStatementFromReferenceSubstitutionNode(frameSubstitutionNode, context) {
383
- const replacementStatementNode = frameSubstitutionNode.getReplacementReferenceNode(),
384
- replacementStatement = context.findReferenceByReferenceNode(replacementStatementNode);
382
+ function replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context) {
383
+ const replacementStatementNode = statementSubstitutionNode.getReplacementStatementNode(),
384
+ replacementStatement = context.findStatementByStatementNode(replacementStatementNode);
385
385
 
386
386
  return replacementStatement;
387
387
  }
@@ -5,8 +5,8 @@ import Substitution from "../substitution";
5
5
  import { define } from "../../elements";
6
6
  import { literally } from "../../utilities/context";
7
7
  import { stripBracketsFromTerm } from "../../utilities/brackets";
8
+ import { instantiateTermSubstitution } from "../../process/instantiate";
8
9
  import { termSubstitutionStringFromTermAndVariable } from "../../utilities/string";
9
- import { instantiateFrameSubstitution, instantiateTermSubstitution } from "../../process/instantiate";
10
10
  import { termSubstitutionFromStatementNode, termSubstitutionFromTermSubstitutionNode } from "../../utilities/element";
11
11
 
12
12
  export default define(class TermSubstitution extends Substitution {
@@ -189,10 +189,10 @@ export default define(class TermSubstitution extends Substitution {
189
189
  if (this.name === name) {
190
190
  literally((context) => {
191
191
  const { string } = json,
192
- frameSubstitutionNode = instantiateFrameSubstitution(string, context),
193
- node = frameSubstitutionNode, ///
194
- targetTerm = targetTermFromFrameSubstitutionNode(frameSubstitutionNode, context),
195
- replacementTerm = replacementTermFromFrameSubstitutionNode(frameSubstitutionNode, context);
192
+ termSubstitutionNode = instantiateTermSubstitution(string, context),
193
+ node = termSubstitutionNode, ///
194
+ targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
195
+ replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context);
196
196
 
197
197
  context = null;
198
198
 
@@ -224,16 +224,16 @@ export default define(class TermSubstitution extends Substitution {
224
224
  }
225
225
  });
226
226
 
227
- function targetTermFromFrameSubstitutionNode(frameSubstitutionNode, context) {
228
- const targetTermNode = frameSubstitutionNode.getTargetFrameNode(),
229
- targetTerm = context.findFrameByFrameNode(targetTermNode);
227
+ function targetTermFromTermSubstitutionNode(termSubstitutionNode, context) {
228
+ const targetTermNode = termSubstitutionNode.getTargetTermNode(),
229
+ targetTerm = context.findTermByTermNode(targetTermNode);
230
230
 
231
231
  return targetTerm;
232
232
  }
233
233
 
234
- function replacementTermFromFrameSubstitutionNode(frameSubstitutionNode, context) {
235
- const replacementTermNode = frameSubstitutionNode.getReplacementFrameNode(),
236
- replacementTerm = context.findFrameByFrameNode(replacementTermNode);
234
+ function replacementTermFromTermSubstitutionNode(termSubstitutionNode, context) {
235
+ const replacementTermNode = termSubstitutionNode.getReplacementTermNode(),
236
+ replacementTerm = context.findTermByTermNode(replacementTermNode);
237
237
 
238
238
  return replacementTerm;
239
239
  }
@@ -43,8 +43,7 @@ export default define(class TypePrefix extends Element {
43
43
  static name = "TypePrefix";
44
44
 
45
45
  static fromJSON(json, context) {
46
- const typePrefix = literally((context) => {
47
- const { string } = json,
46
+ const typePrefix = literally((context) => {const { string } = json,
48
47
  typePrefixNode = instantiateTypePrefix(string, context),
49
48
  node = typePrefixNode, ///
50
49
  name = nameFromTypePrefixNode(typePrefixNode, context);
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ import SubstitutionNode from "../../node/substitution";
4
+
5
+ import { STATEMENT_RULE_NAME, REFERENCE_RULE_NAME } from "../../ruleNames";
6
+
7
+ export default class MetaLevelSubstitutionNode extends SubstitutionNode {
8
+ getTargetReferenceNode() {
9
+ const referenceNode = this.getReferenceNode(),
10
+ targetReferenceNode = referenceNode; ///
11
+
12
+ return targetReferenceNode;
13
+ }
14
+
15
+ getReplacementStatementNode() {
16
+ const statementNode = this.getStatementNode(),
17
+ replacementStatementNode = statementNode; ///
18
+
19
+ return replacementStatementNode;
20
+ }
21
+
22
+ getReferenceNode() {
23
+ const ruleName = REFERENCE_RULE_NAME,
24
+ referenceNode = this.getNodeByRuleName(ruleName);
25
+
26
+ return referenceNode;
27
+ }
28
+
29
+ getStatementNode() {
30
+ const ruleName = STATEMENT_RULE_NAME,
31
+ statementNode = this.getFirstNodeByRuleName(ruleName);
32
+
33
+ return statementNode;
34
+ }
35
+
36
+ static fromRuleNameChildNodesOpacityAndPrecedence(ruleName, childNodes, opacity, precedence) { return SubstitutionNode.fromRuleNameChildNodesOpacityAndPrecedence(MetaLevelSubstitutionNode, ruleName, childNodes, opacity, precedence); }
37
+ }
@@ -75,10 +75,11 @@ 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 ReferenceSubstitutionNode from "./node/substitution/reference";
79
- import StatementSubstitutionNode from "./node/substitution/statement";
80
78
  import SimpleTypeDeclarationNode from "./node/declaration/simpleType";
81
79
  import CombinatorDeclarationNode from "./node/declaration/combinator";
80
+ import ReferenceSubstitutionNode from "./node/substitution/reference";
81
+ import StatementSubstitutionNode from "./node/substitution/statement";
82
+ import MetaLevelSubstitutionNode from "./node/substitution/metaLevel";
82
83
  import TypePrefixDeclarationNode from "./node/declaration/typePrefix";
83
84
  import ComplexTypeDeclarationNode from "./node/declaration/complexType";
84
85
  import DonstructorDeclarationNode from "./node/declaration/constructor";
@@ -160,9 +161,10 @@ import {
160
161
  PARENTHESISED_LABELS_RULE_NAME,
161
162
  PROPERTY_DECLARATION_RULE_NAME,
162
163
  VARIABLE_DECLARATION_RULE_NAME,
164
+ COMBINATOR_DECLARATION_RULE_NAME,
163
165
  REFERENCE_SUBSTITUTION_RULE_NAME,
164
166
  STATEMENT_SUBSTITUTION_RULE_NAME,
165
- COMBINATOR_DECLARATION_RULE_NAME,
167
+ META_LEVEL_SUBSTITUTION_RULE_NAME,
166
168
  SIMPLE_TYPE_DECLARATION_RULE_NAME,
167
169
  CONSTRUCTOR_DECLARATION_RULE_NAME,
168
170
  TYPE_PREFIX_DECLARATION_RULE_NAME,
@@ -245,9 +247,10 @@ const NonTerminalNodeMap = {
245
247
  [PARENTHESISED_LABELS_RULE_NAME]: ParenthesisedLabelsNode,
246
248
  [VARIABLE_DECLARATION_RULE_NAME]: VariableDeclarationNode,
247
249
  [PROPERTY_DECLARATION_RULE_NAME]: PropertyDeclarationNode,
250
+ [COMBINATOR_DECLARATION_RULE_NAME]: CombinatorDeclarationNode,
248
251
  [STATEMENT_SUBSTITUTION_RULE_NAME]: StatementSubstitutionNode,
249
252
  [REFERENCE_SUBSTITUTION_RULE_NAME]: ReferenceSubstitutionNode,
250
- [COMBINATOR_DECLARATION_RULE_NAME]: CombinatorDeclarationNode,
253
+ [META_LEVEL_SUBSTITUTION_RULE_NAME]: MetaLevelSubstitutionNode,
251
254
  [SIMPLE_TYPE_DECLARATION_RULE_NAME]: SimpleTypeDeclarationNode,
252
255
  [TYPE_PREFIX_DECLARATION_RULE_NAME]: TypePrefixDeclarationNode,
253
256
  [CONSTRUCTOR_DECLARATION_RULE_NAME]: DonstructorDeclarationNode,
package/src/preamble.js CHANGED
@@ -57,6 +57,7 @@ import SimpleTypeDeclaration from "./element/declaration/simpleType";
57
57
  import StatementSubstitution from "./element/substitution/statement";
58
58
  import ReferenceSubstitution from "./element/substitution/reference";
59
59
  import CombinatorDeclaration from "./element/declaration/combinator";
60
+ import MetaLevelSubstitution from "./element/substitution/metaLevel";
60
61
  import TypePrefixDeclaration from "./element/declaration/typePrefix";
61
62
  import ConstructorDeclaration from "./element/declaration/constructor";
62
63
  import ComplexTypeDeclaration from "./element/declaration/complexType";
@@ -34,7 +34,8 @@ import { TERM_RULE_NAME,
34
34
  CONTAINED_ASSERTION_RULE_NAME,
35
35
  SATISFIES_ASSERTION_RULE_NAME,
36
36
  STATEMENT_SUBSTITUTION_RULE_NAME,
37
- REFERENCE_SUBSTITUTION_RULE_NAME } from "../ruleNames";
37
+ REFERENCE_SUBSTITUTION_RULE_NAME,
38
+ META_LEVEL_SUBSTITUTION_RULE_NAME } from "../ruleNames";
38
39
 
39
40
  const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
40
41
  typePlaceholderRule = ruleFromRuleName(TYPE_RULE_NAME),
@@ -69,7 +70,8 @@ const termPlaceholderRule = ruleFromRuleName(TERM_RULE_NAME),
69
70
  containedAssertionPlaceholderRule = ruleFromRuleName(CONTAINED_ASSERTION_RULE_NAME),
70
71
  satisfiesAssertionPlaceholderRule = ruleFromRuleName(SATISFIES_ASSERTION_RULE_NAME),
71
72
  statementSubstitutionPlaceholderRule = ruleFromRuleName(STATEMENT_SUBSTITUTION_RULE_NAME),
72
- referenceSubstitutionPlaceholderRule = ruleFromRuleName(REFERENCE_SUBSTITUTION_RULE_NAME);
73
+ referenceSubstitutionPlaceholderRule = ruleFromRuleName(REFERENCE_SUBSTITUTION_RULE_NAME),
74
+ metaLevelSubstitutionPlaceholderRule = ruleFromRuleName(META_LEVEL_SUBSTITUTION_RULE_NAME);
73
75
 
74
76
  export function instantiatePremise(string, context) {
75
77
  string = `${string}
@@ -159,6 +161,8 @@ export function instantiateStatementSubstitution(string, context) { return insta
159
161
 
160
162
  export function instantiateReferenceSubstitution(string, context) { return instantiate(referenceSubstitutionPlaceholderRule, string, context); }
161
163
 
164
+ export function instantiateMetaLevelSubstitution(string, context) { return instantiate(metaLevelSubstitutionPlaceholderRule, string, context); }
165
+
162
166
  function instantiate(placeholderRule, string, context) {
163
167
  let node;
164
168
 
package/src/ruleNames.js CHANGED
@@ -75,9 +75,10 @@ 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 COMBINATOR_DECLARATION_RULE_NAME = "combinatorDeclaration";
78
79
  export const STATEMENT_SUBSTITUTION_RULE_NAME = "statementSubstitution";
79
80
  export const REFERENCE_SUBSTITUTION_RULE_NAME = "referenceSubstitution";
80
- export const COMBINATOR_DECLARATION_RULE_NAME = "combinatorDeclaration";
81
+ export const META_LEVEL_SUBSTITUTION_RULE_NAME = "metaLevelSubstitution";
81
82
  export const TYPE_PREFIX_DECLARATION_RULE_NAME = "typePrefixDeclaration";
82
83
  export const SIMPLE_TYPE_DECLARATION_RULE_NAME = "simpleTypeDeclaration";
83
84
  export const CONSTRUCTOR_DECLARATION_RULE_NAME = "constructorDeclaration";
@@ -38,14 +38,14 @@ export function synthetically(innerFunction, contexts, context) {
38
38
  return innerFunction(context);
39
39
  }
40
40
 
41
- export async function asyncScope(innerFunction, substitutions, context) {
41
+ export async function asyncScope(innerFunction, metaLevelSubstitutions, context) {
42
42
  if (context === undefined) {
43
- context = substitutions; ///
43
+ context = metaLevelSubstitutions; ///
44
44
 
45
- substitutions = null;
45
+ metaLevelSubstitutions = null;
46
46
  }
47
47
 
48
- const scopedContext = ScopedContext.fromSubstitutions(substitutions, context);
48
+ const scopedContext = ScopedContext.fromMetaLevelSubstitutions(metaLevelSubstitutions, context);
49
49
 
50
50
  context = scopedContext; ///
51
51
 
@@ -13,6 +13,7 @@ import { equivalenceStringFromTerms,
13
13
  procedureCallStringFromProcedureReferenceAndParameters,
14
14
  topLevelAssertionStringFromLabelsSuppositionsAndDeduction,
15
15
  topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction } from "../utilities/string";
16
+ import EphemeralContext from "../context/ephemeral";
16
17
 
17
18
  export function typeFromTypeNode(typeNode, context) {
18
19
  let type;
@@ -795,6 +796,21 @@ export function statementSubstitutionFromStatementSubstitutionNode(statementSubs
795
796
  return statementSubstitution;
796
797
  }
797
798
 
799
+ export function metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context) {
800
+ const { MetaLevelSubstitution } = elements,
801
+ node = metaLevelSubstitutionNode, ///
802
+ string = context.nodeAsString(node),
803
+ targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
804
+ replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
805
+ ephemeralContext = EphemeralContext.fromNothing(context);
806
+
807
+ context = ephemeralContext; ///
808
+
809
+ const metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
810
+
811
+ return metaLevelSubstitution;
812
+ }
813
+
798
814
  export function constructorDeclarationFromConstructorDeclarationNode(constructorDeclarationNode, context) {
799
815
  const { ConstructorDeclaration } = elements,
800
816
  node = constructorDeclarationNode, ///
@@ -1859,7 +1875,14 @@ export function metavariableFromMetavariableDeclarationNode(metavariableDeclarat
1859
1875
 
1860
1876
  export function targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
1861
1877
  const targetReferenceNode = referenceSubstitutionNode.getTargetReferenceNode(),
1862
- targetRefernece = metavariableFromMetavariableNode(targetReferenceNode, context);
1878
+ targetRefernece = referenceFromReferenceNode(targetReferenceNode, context);
1879
+
1880
+ return targetRefernece;
1881
+ }
1882
+
1883
+ export function targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context) {
1884
+ const targetReferenceNode = metaLevelSubstitutionNode.getTargetReferenceNode(),
1885
+ targetRefernece = referenceFromReferenceNode(targetReferenceNode, context);
1863
1886
 
1864
1887
  return targetRefernece;
1865
1888
  }
@@ -1909,6 +1932,13 @@ export function replacementStatementFromStatementSubstitutionNode(statementSubst
1909
1932
  return replacementStatement;
1910
1933
  }
1911
1934
 
1935
+ export function replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context) {
1936
+ const replacementStatementNode = metaLevelSubstitutionNode.getReplacementStatementNode(),
1937
+ replacementStatement = statementFromStatementNode(replacementStatementNode, context);
1938
+
1939
+ return replacementStatement;
1940
+ }
1941
+
1912
1942
  export function termsFromTermNodes(termNodes, context) {
1913
1943
  const terms = termNodes.map((termNode) => {
1914
1944
  const term = termFromTermNode(termNode, context);
@@ -184,20 +184,12 @@ export function frameSubstitutionStringFromFrameAndMetavariable(frame, metavaria
184
184
  return string;
185
185
  }
186
186
 
187
- export function typeStringFromTypeNameTypePrefixNameAndSuperTypes(typeName, typePrefixName, superTypes) {
188
- let typeString;
189
-
190
- typeString = (typePrefixName !== null) ?
191
- `${typePrefixName}${typeName}`:
192
- typeName;
193
-
194
- const superTypesString = superTypesStringFromSuperTypes(superTypes);
195
-
196
- if (superTypesString !== null) {
197
- typeString = `${typeString}:${superTypesString}`;
198
- }
187
+ export function metaLevelSubstitutionStringFromStatementAndReference(statement, reference) {
188
+ const statementString = statement.getString(),
189
+ referenceString = reference.getString(),
190
+ metaLevelSubstitutionString = `[${statementString} for ${referenceString}]`;
199
191
 
200
- return typeString;
192
+ return metaLevelSubstitutionString;
201
193
  }
202
194
 
203
195
  export function procedureCallStringFromProcedureReferenceAndParameters(procedureReference, parameters) {
@@ -62,15 +62,22 @@ async function unifyStatementWithReference(statement, reference, satisfiesAssert
62
62
  const metaLevelSubstitutions = context.hasMetaLevelSubstitutions();
63
63
 
64
64
  if (metaLevelSubstitutions) {
65
- const { StatementSubstitution } = elements,
66
- metavariable = reference.getMetavariable(),
67
- statementSubstitution = StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, context),
68
- substitution = statementSubstitution, ///
69
- metaLevel = true;
65
+ let metaLevelSubstitution;
70
66
 
71
- context.addSubstitution(substitution, metaLevel);
67
+ const { MetaLevelSubstitution } = elements;
72
68
 
73
- statementUnifiesWithReference = true;
69
+ metaLevelSubstitution = MetaLevelSubstitution.fromStatementAndReference(statement, reference, context);
70
+
71
+ const generalContext = context, ///
72
+ specificContext = context; ///
73
+
74
+ metaLevelSubstitution = metaLevelSubstitution.validate(generalContext, specificContext); ///
75
+
76
+ if (metaLevelSubstitution !== null) {
77
+ context.addMetaLevelSubstitution(metaLevelSubstitution);
78
+
79
+ statementUnifiesWithReference = true;
80
+ }
74
81
  }
75
82
  }
76
83