occam-verify-cli 1.0.781 → 1.0.785

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 (45) hide show
  1. package/lib/context/branching.js +1 -1
  2. package/lib/context/ephemeral.js +22 -11
  3. package/lib/context/file/nominal.js +4 -4
  4. package/lib/context/proof.js +45 -40
  5. package/lib/context.js +16 -20
  6. package/lib/element/assumption.js +47 -17
  7. package/lib/element/frame.js +1 -39
  8. package/lib/element/judgement.js +33 -5
  9. package/lib/element/metavariable.js +7 -7
  10. package/lib/element/topLevelMetaAssertion.js +9 -9
  11. package/lib/nonTerminalNodeMap.js +1 -3
  12. package/lib/preamble.js +1 -2
  13. package/lib/process/instantiate.js +2 -8
  14. package/lib/process/unify.js +72 -5
  15. package/lib/ruleNames.js +1 -5
  16. package/lib/utilities/context.js +30 -10
  17. package/lib/utilities/element.js +18 -41
  18. package/lib/utilities/json.js +1 -23
  19. package/lib/utilities/string.js +8 -19
  20. package/lib/utilities/unification.js +8 -6
  21. package/package.json +4 -4
  22. package/src/context/branching.js +1 -1
  23. package/src/context/ephemeral.js +26 -10
  24. package/src/context/file/nominal.js +3 -3
  25. package/src/context/proof.js +52 -46
  26. package/src/context.js +21 -27
  27. package/src/element/assumption.js +72 -23
  28. package/src/element/frame.js +1 -61
  29. package/src/element/judgement.js +45 -5
  30. package/src/element/metavariable.js +6 -9
  31. package/src/element/topLevelMetaAssertion.js +13 -13
  32. package/src/nonTerminalNodeMap.js +0 -3
  33. package/src/preamble.js +0 -1
  34. package/src/process/instantiate.js +2 -6
  35. package/src/process/unify.js +117 -7
  36. package/src/ruleNames.js +0 -1
  37. package/src/utilities/context.js +43 -11
  38. package/src/utilities/element.js +26 -56
  39. package/src/utilities/json.js +0 -26
  40. package/src/utilities/string.js +8 -22
  41. package/src/utilities/unification.js +8 -8
  42. package/lib/element/substitution/metaLevel.js +0 -148
  43. package/lib/node/substitution/metaLevel.js +0 -40
  44. package/src/element/substitution/metaLevel.js +0 -212
  45. package/src/node/substitution/metaLevel.js +0 -37
@@ -1,212 +0,0 @@
1
- "use strict";
2
-
3
- import Substitution from "../substitution";
4
-
5
- import { define } from "../../elements";
6
- import { instantiateMetaLevelSubstitution } from "../../process/instantiate";
7
- import { metaLevelSubstitutionFromMetaLevelSubstitutionNode } from "../../utilities/element";
8
- import { metaLevelSubstitutionStringFromStatementAndReference } from "../../utilities/string";
9
- import { descend, simplify, serialise, unserialise, instantiate } from "../../utilities/context";
10
-
11
- export default define(class MetaLevelSubstitution extends Substitution {
12
- constructor(context, string, node, targetReference, replacementStatement) {
13
- super(context, string, node);
14
-
15
- this.targetReference = targetReference;
16
- this.replacementStatement = replacementStatement;
17
- }
18
-
19
- getTargetReference() {
20
- return this.targetReference;
21
- }
22
-
23
- getReplacementStatement() {
24
- return this.replacementStatement;
25
- }
26
-
27
- getMetaLevelSubstitutionNode() {
28
- const node = this.getNode(),
29
- metaLevelSubstitutionNode = node; ///
30
-
31
- return metaLevelSubstitutionNode;
32
- }
33
-
34
- getTargetNode() {
35
- const targetReferenceNode = this.targetReference.getNode(),
36
- tergetNode = targetReferenceNode; ///
37
-
38
- return tergetNode;
39
- }
40
-
41
- getReplacementNode() {
42
- const replacementStatementNode = this.replacementStatement.getNode(),
43
- replacementNode = replacementStatementNode; ///
44
-
45
- return replacementNode;
46
- }
47
-
48
- matchMetaLevelSubstitutionNode(metaLevelSubstitutionNode) {
49
- const node = metaLevelSubstitutionNode, ///
50
- nodeMatches = this.matchNode(node),
51
- metaLevelSubstitutionNodeMatches = nodeMatches; ///
52
-
53
- return metaLevelSubstitutionNodeMatches;
54
- }
55
-
56
- findValidMetaLevelSubstiution(context) {
57
- const metaLevelSubstitutionNode = this.getMetaLevelSubstitutionNode(),
58
- metaLevelSubstitution = context.findMetaLevelSubstitutionByMetaLevelSubstitutionNode(metaLevelSubstitutionNode),
59
- validMetaLevelSubstitution = metaLevelSubstitution; ///
60
-
61
- return validMetaLevelSubstitution;
62
- }
63
-
64
- validate(generalContext, specificContext) {
65
- let metaLevelSubstitution = null;
66
-
67
- const context = specificContext, ///
68
- metaLevelSubstitutionString = this.getString(); ///
69
-
70
- context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level substitution...`);
71
-
72
- const validMetaLevelSubstitution = this.findValidMetaLevelSubstiution(context);
73
-
74
- if (validMetaLevelSubstitution) {
75
- metaLevelSubstitution = validMetaLevelSubstitution; ///
76
-
77
- context.debug(`...the '${metaLevelSubstitutionString}' meta-level substitution is already valid.`);
78
- } else {
79
- let validates = false;
80
-
81
- const targetReferenceValidates = this.validateTargetReference(generalContext, specificContext);
82
-
83
- if (targetReferenceValidates) {
84
- const replacementStatementValidates = this.validateReplacementStatement(generalContext, specificContext);
85
-
86
- if (replacementStatementValidates) {
87
- validates = true;
88
- }
89
- }
90
-
91
- if (validates) {
92
- metaLevelSubstitution = this; ///
93
-
94
- context.addMetaLevelSubstitution(metaLevelSubstitution);
95
-
96
- context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level substitution.`);
97
- }
98
- }
99
-
100
- return metaLevelSubstitution;
101
- }
102
-
103
- validateTargetReference(generalContext, specificContext) {
104
- let targetReferenceValidates = false;
105
-
106
- const context = generalContext, ///
107
- targetReferenceString = this.targetReference.getString(),
108
- metaLevelSubstitutionString = this.getString(); ///
109
-
110
- context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level substitution's '${targetReferenceString}' target reference...`);
111
-
112
- const targetReference = this.targetReference.validate(context);
113
-
114
- if (targetReference !== null) {
115
- targetReferenceValidates = true;
116
- }
117
-
118
- if (targetReferenceValidates) {
119
- context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level substitution's '${targetReferenceString}' target reference...`);
120
- }
121
-
122
- return targetReferenceValidates;
123
- }
124
-
125
- validateReplacementStatement(generalContext, specificContext) {
126
- let replacementStatementValidates = false;
127
-
128
- const context = this.getContext(),
129
- replacementStatementString = this.replacementStatement.getString(),
130
- metaLevelSubstitutionString = this.getString(); ///
131
-
132
- context.trace(`Validating the '${metaLevelSubstitutionString}' meta-level substitution's '${replacementStatementString}' replacement statement...`);
133
-
134
- descend((context) => {
135
- const replacementStatement = this.replacementStatement.validate(context);
136
-
137
- if (replacementStatement !== null) {
138
- replacementStatementValidates = true;
139
- }
140
- }, context);
141
-
142
- if (replacementStatementValidates) {
143
- context.debug(`...validated the '${metaLevelSubstitutionString}' meta-level substitution's '${replacementStatementString}' replacement statement.`);
144
- }
145
-
146
- return replacementStatementValidates;
147
- }
148
-
149
- toJSON() {
150
- const context = this.getContext();
151
-
152
- return serialise((context) => {
153
- const string = this.getString(),
154
- json = {
155
- context,
156
- string
157
- };
158
-
159
- return json;
160
- }, context);
161
- }
162
-
163
- static name = "MetaLevelSubstitution";
164
-
165
- static fromJSON(json, context) {
166
- let metaLevelSubstitution;
167
-
168
- unserialise((json, context) => {
169
- instantiate((context) => {
170
- const { string } = json,
171
- metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context),
172
- node = metaLevelSubstitutionNode, ///
173
- targetReference = targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context),
174
- replacementStatement = replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
175
-
176
- metaLevelSubstitution = new MetaLevelSubstitution(context, string, node, targetReference, replacementStatement);
177
- }, context);
178
- }, json, context);
179
-
180
- return metaLevelSubstitution;
181
- }
182
-
183
- static fromStatementAndReference(statement, reference, context) {
184
- let metaLevelSubstitution;
185
-
186
- simplify((context) => {
187
- instantiate((context) => {
188
- const metaLevelSubstitutionString = metaLevelSubstitutionStringFromStatementAndReference(statement, reference),
189
- string = metaLevelSubstitutionString, ///
190
- metaLevelSubstitutionNode = instantiateMetaLevelSubstitution(string, context);
191
-
192
- metaLevelSubstitution = metaLevelSubstitutionFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context);
193
- }, context);
194
- }, context);
195
-
196
- return metaLevelSubstitution;
197
- }
198
- });
199
-
200
- function targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context) {
201
- const targetReferenceNode = metaLevelSubstitutionNode.getTargetReferenceNode(),
202
- targetReference = context.findReferenceByReferenceNode(targetReferenceNode);
203
-
204
- return targetReference;
205
- }
206
-
207
- function replacementStatementFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context) {
208
- const replacementStatementNode = metaLevelSubstitutionNode.getReplacementStatementNode(),
209
- replacementStatement = context.findStatementByStatementNode(replacementStatementNode);
210
-
211
- return replacementStatement;
212
- }
@@ -1,37 +0,0 @@
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
- }