occam-verify-cli 1.0.862 → 1.0.865

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 (53) hide show
  1. package/lib/context/liminal.js +16 -24
  2. package/lib/context/mnemic.js +5 -51
  3. package/lib/context/synoptic.js +26 -12
  4. package/lib/context.js +1 -37
  5. package/lib/element/assumption/metaLevel.js +3 -3
  6. package/lib/element/combinator.js +2 -2
  7. package/lib/element/conclusion.js +2 -2
  8. package/lib/element/constructor.js +2 -2
  9. package/lib/element/deduction.js +2 -2
  10. package/lib/element/label.js +2 -2
  11. package/lib/element/metavariable.js +10 -10
  12. package/lib/element/proofAssertion/premise.js +2 -2
  13. package/lib/element/proofAssertion/step.js +2 -2
  14. package/lib/element/proofAssertion/supposition.js +2 -2
  15. package/lib/element/reference.js +2 -2
  16. package/lib/element/substitution/frame.js +35 -33
  17. package/lib/element/substitution/reference.js +34 -32
  18. package/lib/element/substitution/statement.js +36 -34
  19. package/lib/element/substitution/term.js +33 -31
  20. package/lib/element/substitution.js +63 -29
  21. package/lib/element/variable.js +4 -4
  22. package/lib/process/unify.js +5 -5
  23. package/lib/utilities/context.js +42 -18
  24. package/lib/utilities/element.js +27 -66
  25. package/lib/utilities/json.js +27 -8
  26. package/lib/utilities/validation.js +7 -7
  27. package/package.json +4 -4
  28. package/src/context/liminal.js +15 -26
  29. package/src/context/mnemic.js +8 -64
  30. package/src/context/synoptic.js +37 -11
  31. package/src/context.js +0 -54
  32. package/src/element/assumption/metaLevel.js +2 -2
  33. package/src/element/combinator.js +1 -1
  34. package/src/element/conclusion.js +1 -1
  35. package/src/element/constructor.js +1 -1
  36. package/src/element/deduction.js +1 -1
  37. package/src/element/label.js +1 -1
  38. package/src/element/metavariable.js +10 -10
  39. package/src/element/proofAssertion/premise.js +1 -1
  40. package/src/element/proofAssertion/step.js +1 -1
  41. package/src/element/proofAssertion/supposition.js +1 -1
  42. package/src/element/reference.js +1 -1
  43. package/src/element/substitution/frame.js +39 -33
  44. package/src/element/substitution/reference.js +44 -35
  45. package/src/element/substitution/statement.js +45 -37
  46. package/src/element/substitution/term.js +44 -35
  47. package/src/element/substitution.js +80 -35
  48. package/src/element/variable.js +3 -3
  49. package/src/process/unify.js +3 -5
  50. package/src/utilities/context.js +50 -24
  51. package/src/utilities/element.js +36 -70
  52. package/src/utilities/json.js +31 -12
  53. package/src/utilities/validation.js +9 -9
@@ -1,20 +1,65 @@
1
1
  "use strict";
2
2
 
3
- import { Element } from "occam-languages";
4
- import { serialise } from "../utilities/context";
3
+ import { arrayUtilities } from "necessary";
4
+
5
+ import { serialises } from "../utilities/context";
5
6
  import { primitiveUtilities } from "occam-furtle";
6
7
 
7
- const { primitiveFromNode } =primitiveUtilities;
8
+ const { first, second } = arrayUtilities,
9
+ { primitiveFromNode } =primitiveUtilities;
8
10
 
9
- export default class Substitution extends Element {
10
- constructor(context, string, node, lineIndex, generalContext) {
11
- super(context, string, node, lineIndex);
11
+ class Element {
12
+ constructor(contexts, string, node, lineIndex) {
13
+ this.contexts = contexts;
14
+ this.string = string;
15
+ this.node = node;
16
+ this.lineIndex = lineIndex;
17
+ }
12
18
 
13
- this.generalContext = generalContext;
19
+ getContexts() {
20
+ return this.contexts;
14
21
  }
15
22
 
16
- getGeneralContext() {
17
- return this.generalContext;
23
+ getString() {
24
+ return this.string;
25
+ }
26
+
27
+ getNode() {
28
+ return this.node;
29
+ }
30
+
31
+ getLineIndex() {
32
+ return this.lineIndex;
33
+ }
34
+
35
+ setContexts(contexts) {
36
+ this.contexts = contexts;
37
+ }
38
+
39
+ setString(string) {
40
+ this.string = string;
41
+ }
42
+
43
+ setNode(node) {
44
+ this.node = node;
45
+ }
46
+
47
+ setLineIndex(lineIndex) {
48
+ this.lineIndex = lineIndex;
49
+ }
50
+
51
+ async break(context) {
52
+ this.lineIndex = await context.break(this.node, this.lineIndex);
53
+ }
54
+
55
+ matchNode(node) { return this.node.match(node); }
56
+ }
57
+
58
+ export default class Substitution extends Element {
59
+ getName() {
60
+ const { name } = this.constructor;
61
+
62
+ return name;
18
63
  }
19
64
 
20
65
  getPrimitive(context) {
@@ -32,45 +77,40 @@ export default class Substitution extends Element {
32
77
  return substitutionNode;
33
78
  }
34
79
 
35
- getSpecificContext() {
36
- const context = this.getContext(),
37
- specificContext = context; ///
80
+ getGeneralContext() {
81
+ const contexts = this.getContexts(),
82
+ firstContext = first(contexts),
83
+ generalContext = firstContext; ///
38
84
 
39
- return specificContext;
85
+ return generalContext;
40
86
  }
41
87
 
42
- getName() {
43
- const { name } = this.constructor;
88
+ getSpecificContext() {
89
+ const contexts = this.getContexts(),
90
+ secondContext = second(contexts),
91
+ specificContext = secondContext; ///
44
92
 
45
- return name;
93
+ return specificContext;
46
94
  }
47
95
 
48
- getContexts() {
49
- const generalContext = this.getGeneralContext(),
50
- specificContext = this.getSpecificContext(),
96
+ setGeneralContext(generalContext) {
97
+ const specificContext = this.getSpecificContext(),
51
98
  contexts = [
52
99
  generalContext,
53
100
  specificContext
54
101
  ];
55
102
 
56
- return contexts;
57
- }
58
-
59
- setGeneralContext(generalContext) {
60
- this.generalContext = generalContext;
61
- }
62
-
63
- setSpecificContext(specifiContext) {
64
- const context = specifiContext; ///
65
-
66
- this.setContext(context);
103
+ this.setContexts(contexts);
67
104
  }
68
105
 
69
- setContexts(...contexts) {
70
- const [ generalContext, specificContext ] = contexts;
106
+ setSpecificContext(specificContext) {
107
+ const generalContext = this.getGeneralContext(),
108
+ contexts = [
109
+ generalContext,
110
+ specificContext
111
+ ];
71
112
 
72
- this.setGeneralContext(generalContext);
73
- this.setSpecificContext(specificContext);
113
+ this.setContexts(contexts);
74
114
  }
75
115
 
76
116
  isEqualTo(substitution) {
@@ -165,10 +205,15 @@ export default class Substitution extends Element {
165
205
  return resolved;
166
206
  }
167
207
 
208
+ commit(generalContext, specificContext) {
209
+ this.setGeneralContext(generalContext);
210
+ this.setSpecificContext(specificContext);
211
+ }
212
+
168
213
  toJSON() {
169
214
  const contexts = this.getContexts();
170
215
 
171
- return serialise((...contexts) => {
216
+ return serialises((...contexts) => {
172
217
  const name = this.getName(),
173
218
  string = this.getString(),
174
219
  lineIndex = this.getLineIndex(),
@@ -152,13 +152,13 @@ export default define(class Variable extends Element {
152
152
 
153
153
  if (termTypeEqualToOrSubTypeOfVariableType) {
154
154
  const { TermSubstitution } = elements,
155
- termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, context);
155
+ termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, generalContext, specificContext);
156
156
 
157
- termSubstitution.validate(generalContext, specificContext);
157
+ termSubstitution.validate(context);
158
158
 
159
159
  const derivedSubstitution = termSubstitution; ///
160
160
 
161
- specificContext.addDerivedSubstitution(derivedSubstitution);
161
+ context.addDerivedSubstitution(derivedSubstitution);
162
162
 
163
163
  termUnifies = true;
164
164
  }
@@ -14,14 +14,12 @@ const typeNodeQuery = nodeQuery("/type"),
14
14
  frameNodeQuery = nodeQuery("/frame"),
15
15
  metaTypeNodeQuery = nodeQuery("/metaType"),
16
16
  statementNodeQuery = nodeQuery("/statement"),
17
- metavariableNodeQuery = nodeQuery("/metavariable"),
18
17
  termVariableNodeQuery = nodeQuery("/term/variable!"),
19
18
  frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
20
- referenceMetavariableNodeQuery = nodeQuery("/reference/metavariable!"),
21
19
  statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!"),
22
20
  assumptionMetavariableNodeQuery = nodeQuery("/assumption/metavariable!");
23
21
 
24
- class MetaLevelPass extends ZipPassBase {
22
+ class StatementPass extends ZipPassBase {
25
23
  static maps = [
26
24
  {
27
25
  generalNodeQuery: assumptionMetavariableNodeQuery,
@@ -404,7 +402,7 @@ class IntrinsicLevelPass extends ZipPass {
404
402
  ];
405
403
  }
406
404
 
407
- const metaLevelPass = new MetaLevelPass(),
405
+ const statementPass = new StatementPass(),
408
406
  combinatorPass = new CombinatorPass(),
409
407
  constructorPass = new ConstructorPass(),
410
408
  metavariablePass = new MetavariablePass(),
@@ -418,7 +416,7 @@ export function unifyStatement(generalStatement, specificStatement, generalConte
418
416
  specificStatementNode = specificStatement.getNode(),
419
417
  generalNode = generalStatementNode, ///
420
418
  specificNode = specificStatementNode, ///
421
- success = metaLevelPass.run(generalNode, specificNode, generalContext, specificContext);
419
+ success = statementPass.run(generalNode, specificNode, generalContext, specificContext);
422
420
 
423
421
  if (success) {
424
422
  statementUnifies = true;
@@ -12,7 +12,7 @@ import IllativeContext from "../context/illative";
12
12
  import BranchingContext from "../context/branching";
13
13
  import NominalFileContext from "../context/file/nominal";
14
14
 
15
- import { mnemicContextsFromJSON, mnemicContextToMnemicContextJSON } from "../utilities/json";
15
+ import { mnemicContextFromJSON, mnemicContextsFromJSON, mnemicContextToMnemicContextJSON, mnemicContextsToMnemicContextsJSON } from "../utilities/json";
16
16
 
17
17
  export function join(innerFunction, ...contexts) {
18
18
  const synopticContext = SynopticContext.fromContexts(...contexts),
@@ -41,7 +41,7 @@ export function ablate(innerFunction, context) {
41
41
  while (!contextNominalFileContext) {
42
42
  context = context.getContext();
43
43
 
44
- contextNominalFileContext = (context instanceof NominalFileContext)
44
+ contextNominalFileContext = (context instanceof NominalFileContext);
45
45
  }
46
46
 
47
47
  return innerFunction(context);
@@ -79,16 +79,12 @@ export function descend(innerFunction, context) {
79
79
  return innerFunction(context);
80
80
  }
81
81
 
82
- export function attempt(innerFunction, ...contexts) {
83
- contexts = contexts.map((context) => { ///
84
- const mnemicContext = MenmicContext.fromNothing(context);
85
-
86
- context = mnemicContext; ///
82
+ export function attempt(innerFunction, context) {
83
+ const mnemicContext = MenmicContext.fromNothing(context);
87
84
 
88
- return context;
89
- })
85
+ context = mnemicContext; ///
90
86
 
91
- return innerFunction(...contexts);
87
+ return innerFunction(context);
92
88
  }
93
89
 
94
90
  export function enclose(innerFunction, metaLevelAssumptions, context) {
@@ -119,13 +115,41 @@ export function reconcile(innerFunction, context) {
119
115
  return innerFunction(context);
120
116
  }
121
117
 
122
- export function serialise(innerFunction, ...contexts) {
118
+ export function serialise(innerFunction, context) {
119
+ const mnemicContext = context, ///
120
+ mnemicContextJSON = mnemicContextToMnemicContextJSON(mnemicContext),
121
+ contextJSON = mnemicContextJSON; ///
122
+
123
+ context = contextJSON; ///
124
+
125
+ return innerFunction(context);
126
+ }
127
+
128
+ export function instantiate(innerFunction, context) {
129
+ const literalContext = LiteralContext.fromNothing(context);
130
+
131
+ context = literalContext; ///
132
+
133
+ return innerFunction(context);
134
+ }
135
+
136
+ export function unserialise(innerFunction, json, context) {
137
+ const mnemicContext = mnemicContextFromJSON(json, context);
138
+
139
+ context = mnemicContext; ///
140
+
141
+ return innerFunction(json, context);
142
+ }
143
+
144
+ export function ablates(innerFunction, ...contexts) {
123
145
  contexts = contexts.map((context) => { ///
124
- const mnemicContext = context, ///
125
- mnemicContextJSON = mnemicContextToMnemicContextJSON(mnemicContext),
126
- contextJSON = mnemicContextJSON; ///
146
+ let contextNominalFileContext = (context instanceof NominalFileContext);
127
147
 
128
- context = contextJSON; ///
148
+ while (!contextNominalFileContext) {
149
+ context = context.getContext();
150
+
151
+ contextNominalFileContext = (context instanceof NominalFileContext);
152
+ }
129
153
 
130
154
  return context;
131
155
  });
@@ -133,17 +157,19 @@ export function serialise(innerFunction, ...contexts) {
133
157
  return innerFunction(...contexts);
134
158
  }
135
159
 
136
- export function unserialise(innerFunction, json, context) {
137
- const mnemicContexts = mnemicContextsFromJSON(json, context),
138
- contexts = mnemicContexts; ///
160
+ export function serialises(innerFunction, ...contexts) {
161
+ const mnemicContexts = contexts, ///
162
+ mnemicContextsJSON = mnemicContextsToMnemicContextsJSON(mnemicContexts),
163
+ contextsJSON = mnemicContextsJSON; ///
139
164
 
140
- return innerFunction(json, ...contexts);
141
- }
165
+ contexts = contextsJSON; ///
142
166
 
143
- export function instantiate(innerFunction, context) {
144
- const literalContext = LiteralContext.fromNothing(context);
167
+ return innerFunction(...contexts);
168
+ }
145
169
 
146
- context = literalContext; ///
170
+ export function unserialises(innerFunction, json, context) {
171
+ const mnemicContexts = mnemicContextsFromJSON(json, context),
172
+ contexts = mnemicContexts; ///
147
173
 
148
- return innerFunction(context);
174
+ return innerFunction(json, contexts);
149
175
  }
@@ -11,7 +11,6 @@ import { equivalenceStringFromTerms,
11
11
  procedureCallStringFromProcedureReferenceAndParameters,
12
12
  topLevelAssertionStringFromLabelsSuppositionsAndDeduction,
13
13
  topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction } from "../utilities/string";
14
- import statement from "../element/statement";
15
14
 
16
15
  export function typeFromTypeNode(typeNode, context) {
17
16
  let type;
@@ -675,28 +674,36 @@ export function propertyRelationFromPropertyRelationNode(propertyRelationNode, c
675
674
  return propertyRelation;
676
675
  }
677
676
 
678
- export function termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context) {
677
+ export function termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext) {
679
678
  const { TermSubstitution } = elements,
680
679
  node = termSubstitutionNode, ///
680
+ context = specificContext, ///
681
+ contexts = [
682
+ generalContext,
683
+ specificContext
684
+ ],
681
685
  string = context.nodeAsString(node),
682
686
  lineIndex = null,
683
- generalContext = generalContextFromTermSubstitutionNode(termSubstitutionNode, context),
684
687
  targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
685
688
  replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context),
686
- termSubstitution = new TermSubstitution(context, string, node, lineIndex, generalContext, targetTerm, replacementTerm);
689
+ termSubstitution = new TermSubstitution(contexts, string, node, lineIndex, targetTerm, replacementTerm);
687
690
 
688
691
  return termSubstitution;
689
692
  }
690
693
 
691
- export function frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context) {
694
+ export function frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext) {
692
695
  const { FrameSubstitution } = elements,
693
696
  node = frameSubstitutionNode, ///
697
+ context = specificContext, ///
698
+ contexts = [
699
+ generalContext,
700
+ specificContext
701
+ ],
694
702
  string = context.nodeAsString(node),
695
703
  lineIndex = null,
696
- generalContext = generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context),
697
704
  targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
698
705
  replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
699
- frameSubstitution = new FrameSubstitution(context, string, node, lineIndex, generalContext, targetFrame, replacementFrame);
706
+ frameSubstitution = new FrameSubstitution(contexts, string, node, lineIndex, targetFrame, replacementFrame);
700
707
 
701
708
  return frameSubstitution;
702
709
  }
@@ -853,31 +860,38 @@ export function simpleTypeDeclarationFromSimpleTypeDeclarationNode(simpleTypeDec
853
860
  return simpleTypeDeclaration;
854
861
  }
855
862
 
856
- export function referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
863
+ export function referenceSubstitutionFromReferenceSubstitutionNode(referenceSubstitutionNode, generalContext, specificContext) {
857
864
  const { ReferenceSubstitution } = elements,
858
865
  node = referenceSubstitutionNode, ///
866
+ context = specificContext, ///
867
+ contexts = [
868
+ generalContext,
869
+ specificContext
870
+ ],
859
871
  string = context.nodeAsString(node),
860
872
  lineIndex = null,
861
- generalContext = generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
862
873
  targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
863
874
  replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
864
- referenceSubstitution = new ReferenceSubstitution(context, string, node, lineIndex, generalContext, targetReference, replacementReference);
875
+ referenceSubstitution = new ReferenceSubstitution(contexts, string, node, lineIndex, targetReference, replacementReference);
865
876
 
866
877
  return referenceSubstitution;
867
878
  }
868
879
 
869
- export function statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context) {
870
-
880
+ export function statementSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext) {
871
881
  const { StatementSubstitution } = elements,
872
882
  node = statementSubstitutionNode, ///
883
+ context = specificContext, ///
884
+ contexts = [
885
+ generalContext,
886
+ specificContext
887
+ ],
873
888
  string = context.nodeAsString(node),
874
889
  lineIndex = null,
875
- generalContext = generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context),
876
890
  resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
877
- substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
891
+ substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext),
878
892
  targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
879
893
  replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
880
- statementSubstitution = new StatementSubstitution(context, string, node, lineIndex, generalContext, resolved, substitution, targetStatement, replacementStatement);
894
+ statementSubstitution = new StatementSubstitution(contexts, string, node, lineIndex, resolved, substitution, targetStatement, replacementStatement);
881
895
 
882
896
  return statementSubstitution;
883
897
  }
@@ -1630,18 +1644,6 @@ export function definedAssertionFromStatementNode(statementNode, context) {
1630
1644
  return definedAssertion;
1631
1645
  }
1632
1646
 
1633
- export function termSubstitutionFromStatementNode(statementNode, context) {
1634
- let termSubstitution = null;
1635
-
1636
- const termSubstitutionNode = statementNode.getTermSubstitutionNode();
1637
-
1638
- if (termSubstitutionNode !== null) {
1639
- termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
1640
- }
1641
-
1642
- return termSubstitution;
1643
- }
1644
-
1645
1647
  export function negatedFromContainedAssertionNode(containedAssertionNode, context) {
1646
1648
  const negated = containedAssertionNode.isNegated();
1647
1649
 
@@ -1697,18 +1699,6 @@ export function labelFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, cont
1697
1699
  return label;
1698
1700
  }
1699
1701
 
1700
- export function frameSubstitutionFromStatementNode(statementNode, context) {
1701
- let frameSubstitution = null;
1702
-
1703
- const frameSubstitutionNode = statementNode.getFrameSubstitutionNode();
1704
-
1705
- if (frameSubstitutionNode !== null) {
1706
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
1707
- }
1708
-
1709
- return frameSubstitution;
1710
- }
1711
-
1712
1702
  export function propertyAssertionFromStatementNode(statementNode, context) {
1713
1703
  let propertyAssertion = null;
1714
1704
 
@@ -1863,12 +1853,6 @@ export function topLevelMetaAssertionFromReferenceNode(referenceNode, context) {
1863
1853
  return topLevelMetaAssertion;
1864
1854
  }
1865
1855
 
1866
- export function generalContextFromTermSubstitutionNode(termSubstitutionNode, context) {
1867
- const generalContext = null;
1868
-
1869
- return generalContext;
1870
- }
1871
-
1872
1856
  export function deductionFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, context) {
1873
1857
  const deductionNode = metaLemmaMetathoremNode.getDeductionNode(),
1874
1858
  deduction = deductionFromDeductionNode(deductionNode, context);
@@ -1890,12 +1874,6 @@ export function replacementTermFromTermSubstitutionNode(termSubstitutionNode, co
1890
1874
  return replacementTerm;
1891
1875
  }
1892
1876
 
1893
- export function generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context) {
1894
- const generalContext = null;
1895
-
1896
- return generalContext;
1897
- }
1898
-
1899
1877
  export function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
1900
1878
  let superTypes = [];
1901
1879
 
@@ -1972,9 +1950,9 @@ export function suppositionsFromTopLevelMetaAssertionNode(metaLemmaMetathoremNod
1972
1950
  return suppositions;
1973
1951
  }
1974
1952
 
1975
- export function substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context) {
1976
- const frameSubstitution = frameSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
1977
- termSubstitution = termSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
1953
+ export function substitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContxt, specificContext) {
1954
+ const frameSubstitution = frameSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContxt, specificContext),
1955
+ termSubstitution = termSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContxt, specificContext),
1978
1956
  substitution = (frameSubstitution || termSubstitution);
1979
1957
 
1980
1958
  return substitution;
@@ -1999,18 +1977,6 @@ export function provisionalFromComplexTypeDeclarationNode(complexTypeDeclaration
1999
1977
  return provisional;
2000
1978
  }
2001
1979
 
2002
- export function generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context) {
2003
- const generalContext = null;
2004
-
2005
- return generalContext;
2006
- }
2007
-
2008
- export function generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
2009
- const generalContext = null;
2010
-
2011
- return generalContext;
2012
- }
2013
-
2014
1980
  export function metavariableFromMetavariableDeclarationNode(metavariableDeclarationNode, context) {
2015
1981
  const metavariableNode = metavariableDeclarationNode.getMetavariableNode(),
2016
1982
  metavariable = metavariableFromMetavariableNode(metavariableNode, context);
@@ -2034,25 +2000,25 @@ export function targetStatementFromStatementSubstitutionNode(statementSubstituti
2034
2000
  return targetStatement;
2035
2001
  }
2036
2002
 
2037
- export function termSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context) {
2003
+ export function termSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext) {
2038
2004
  let termSubstitution = null;
2039
2005
 
2040
2006
  const termSubstitutionNode = statementSubstitutionNode.getTermSubstitutionNode();
2041
2007
 
2042
2008
  if (termSubstitutionNode !== null) {
2043
- termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
2009
+ termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext);
2044
2010
  }
2045
2011
 
2046
2012
  return termSubstitution;
2047
2013
  }
2048
2014
 
2049
- export function frameSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, context) {
2015
+ export function frameSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext) {
2050
2016
  let frameSubstitution = null;
2051
2017
 
2052
2018
  const frameSubstitutionNode = statementSubstitutionNode.getFrameSubstitutionNode();
2053
2019
 
2054
2020
  if (frameSubstitutionNode !== null) {
2055
- frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, context);
2021
+ frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
2056
2022
  }
2057
2023
 
2058
2024
  return frameSubstitution;
@@ -192,6 +192,20 @@ export function metavariableFromJSON(json, context) {
192
192
  return metavariable;
193
193
  }
194
194
 
195
+ export function mnemicContextFromJSON(json, context) {
196
+ const releaseContext = context; ///
197
+
198
+ ({ context } = json);
199
+
200
+ json = context; ///
201
+
202
+ context = releaseContext; ///
203
+
204
+ const mnemicContext = MnemicContext.fromJSON(json, context);
205
+
206
+ return mnemicContext;
207
+ }
208
+
195
209
  export function procedureCallFromJSON(json, context) {
196
210
  let { procedureCall = null } = json;
197
211
 
@@ -662,22 +676,17 @@ export function metavariablesFromJSON(json, context) {
662
676
  export function mnemicContextsFromJSON(json, context) {
663
677
  const releaseContext = context; ///
664
678
 
665
- const { contexts = [] } = json;
679
+ const { contexts } = json;
666
680
 
667
- ({ context = null } = json);
681
+ const mnemicContexts = contexts.map((context) => {
682
+ json = context; ///
668
683
 
669
- if (context !== null) {
670
- contexts.push(context);
671
- }
684
+ context = releaseContext; ///
672
685
 
673
- const contextsJSON = contexts, ///
674
- mnemicContexts = contextsJSON.map((contextJSON) => {
675
- const json = contextJSON, ///
676
- context = releaseContext, ///
677
- mnemicContext = MnemicContext.fromJSON(json, context);
686
+ const mnemicContext = MnemicContext.fromJSON(json, context);
678
687
 
679
- return mnemicContext; ///
680
- });
688
+ return mnemicContext; ///
689
+ });
681
690
 
682
691
  return mnemicContexts;
683
692
  }
@@ -1168,6 +1177,16 @@ export function metavariablesToMetavariablesJSON(metavariables) {
1168
1177
  return metavariablesJSON;
1169
1178
  }
1170
1179
 
1180
+ export function mnemicContextsToMnemicContextsJSON(mnemicContexts) {
1181
+ const mnemicContextsJSON = mnemicContexts.map((mnemicContext) => {
1182
+ const mnemicContextJSON = mnemicContext.toJSON();
1183
+
1184
+ return mnemicContextJSON;
1185
+ });
1186
+
1187
+ return mnemicContextsJSON;
1188
+ }
1189
+
1171
1190
  export function propertyRelationsToPropertyRelationsJSON(propertyRelations) {
1172
1191
  const propertyRelationsJSON = propertyRelations.map((propertyRelation) => {
1173
1192
  const propertyRelationJSON = propertyRelation.toJSON();
@@ -99,25 +99,25 @@ function validateStatementAsMetavariable(statement, context) {
99
99
  metavariable = metavariable.validate(strict, context);
100
100
 
101
101
  if (metavariable !== null) {
102
- statementValidatesAsMetavariable = true;
103
102
 
104
103
  const { TermSubstitution, FrameSubstitution } = elements;
105
104
 
106
105
  let substitution;
107
106
 
108
- const termSubstitution = TermSubstitution.fromStatement(statement, context),
109
- frameSubstitution = FrameSubstitution.fromStatement(statement, context);
107
+ const generalContext = context, ///
108
+ specificContext = context, ///
109
+ termSubstitution = TermSubstitution.fromStatement(statement, generalContext, specificContext),
110
+ frameSubstitution = FrameSubstitution.fromStatement(statement, generalContext, specificContext);
110
111
 
111
112
  substitution = (termSubstitution || frameSubstitution);
112
113
 
113
- if (substitution !== null) {
114
- const generalContext = context, ///
115
- specificContext = context; ///
116
-
114
+ if (substitution === null) {
115
+ statementValidatesAsMetavariable = true;
116
+ } else {
117
117
  substitution = substitution.validate(generalContext, specificContext); ///
118
118
 
119
- if (substitution === null) {
120
- statementValidatesAsMetavariable = false;
119
+ if (substitution !== null) {
120
+ statementValidatesAsMetavariable = true;
121
121
  }
122
122
  }
123
123
  }