occam-verify-cli 1.0.862 → 1.0.866
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.
- package/lib/context/liminal.js +16 -24
- package/lib/context/literal.js +1 -9
- package/lib/context/mnemic.js +5 -51
- package/lib/context/synoptic.js +26 -12
- package/lib/context.js +1 -37
- package/lib/element/assumption/metaLevel.js +3 -3
- package/lib/element/combinator.js +2 -2
- package/lib/element/conclusion.js +2 -2
- package/lib/element/constructor.js +2 -2
- package/lib/element/deduction.js +2 -2
- package/lib/element/label.js +2 -2
- package/lib/element/metavariable.js +10 -10
- package/lib/element/proofAssertion/premise.js +2 -2
- package/lib/element/proofAssertion/step.js +2 -2
- package/lib/element/proofAssertion/supposition.js +2 -2
- package/lib/element/reference.js +2 -2
- package/lib/element/substitution/frame.js +34 -34
- package/lib/element/substitution/reference.js +37 -36
- package/lib/element/substitution/statement.js +41 -38
- package/lib/element/substitution/term.js +35 -34
- package/lib/element/substitution.js +66 -29
- package/lib/element/variable.js +4 -4
- package/lib/process/unify.js +5 -5
- package/lib/utilities/context.js +52 -17
- package/lib/utilities/element.js +27 -66
- package/lib/utilities/json.js +27 -8
- package/lib/utilities/validation.js +7 -7
- package/package.json +4 -4
- package/src/context/liminal.js +15 -26
- package/src/context/literal.js +0 -14
- package/src/context/mnemic.js +8 -64
- package/src/context/synoptic.js +37 -11
- package/src/context.js +0 -54
- package/src/element/assumption/metaLevel.js +2 -2
- package/src/element/combinator.js +1 -1
- package/src/element/conclusion.js +1 -1
- package/src/element/constructor.js +1 -1
- package/src/element/deduction.js +1 -1
- package/src/element/label.js +1 -1
- package/src/element/metavariable.js +10 -10
- package/src/element/proofAssertion/premise.js +1 -1
- package/src/element/proofAssertion/step.js +1 -1
- package/src/element/proofAssertion/supposition.js +1 -1
- package/src/element/reference.js +1 -1
- package/src/element/substitution/frame.js +42 -38
- package/src/element/substitution/reference.js +46 -39
- package/src/element/substitution/statement.js +51 -41
- package/src/element/substitution/term.js +44 -38
- package/src/element/substitution.js +84 -35
- package/src/element/variable.js +3 -3
- package/src/process/unify.js +3 -5
- package/src/utilities/context.js +61 -23
- package/src/utilities/element.js +36 -70
- package/src/utilities/json.js +31 -12
- package/src/utilities/validation.js +9 -9
|
@@ -1,20 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import { serialises } from "../utilities/context";
|
|
5
6
|
import { primitiveUtilities } from "occam-furtle";
|
|
6
7
|
|
|
7
|
-
const {
|
|
8
|
+
const { first, second } = arrayUtilities,
|
|
9
|
+
{ primitiveFromNode } =primitiveUtilities;
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
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
|
-
|
|
19
|
+
getContexts() {
|
|
20
|
+
return this.contexts;
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
return this.
|
|
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
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
80
|
+
getGeneralContext() {
|
|
81
|
+
const contexts = this.getContexts(),
|
|
82
|
+
firstContext = first(contexts),
|
|
83
|
+
generalContext = firstContext; ///
|
|
38
84
|
|
|
39
|
-
return
|
|
85
|
+
return generalContext;
|
|
40
86
|
}
|
|
41
87
|
|
|
42
|
-
|
|
43
|
-
const
|
|
88
|
+
getSpecificContext() {
|
|
89
|
+
const contexts = this.getContexts(),
|
|
90
|
+
secondContext = second(contexts),
|
|
91
|
+
specificContext = secondContext; ///
|
|
44
92
|
|
|
45
|
-
return
|
|
93
|
+
return specificContext;
|
|
46
94
|
}
|
|
47
95
|
|
|
48
|
-
|
|
49
|
-
const
|
|
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
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
setGeneralContext(generalContext) {
|
|
60
|
-
this.generalContext = generalContext;
|
|
103
|
+
this.setContexts(contexts);
|
|
61
104
|
}
|
|
62
105
|
|
|
63
|
-
setSpecificContext(
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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.
|
|
73
|
-
this.setSpecificContext(specificContext);
|
|
113
|
+
this.setContexts(contexts);
|
|
74
114
|
}
|
|
75
115
|
|
|
76
116
|
isEqualTo(substitution) {
|
|
@@ -165,10 +205,19 @@ export default class Substitution extends Element {
|
|
|
165
205
|
return resolved;
|
|
166
206
|
}
|
|
167
207
|
|
|
208
|
+
commit(generalContext, specificContext) {
|
|
209
|
+
const contexts = [
|
|
210
|
+
generalContext,
|
|
211
|
+
specificContext
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
this.setContexts(contexts);
|
|
215
|
+
}
|
|
216
|
+
|
|
168
217
|
toJSON() {
|
|
169
218
|
const contexts = this.getContexts();
|
|
170
219
|
|
|
171
|
-
return
|
|
220
|
+
return serialises((...contexts) => {
|
|
172
221
|
const name = this.getName(),
|
|
173
222
|
string = this.getString(),
|
|
174
223
|
lineIndex = this.getLineIndex(),
|
package/src/element/variable.js
CHANGED
|
@@ -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,
|
|
155
|
+
termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, generalContext, specificContext);
|
|
156
156
|
|
|
157
|
-
termSubstitution.validate(
|
|
157
|
+
termSubstitution.validate(context);
|
|
158
158
|
|
|
159
159
|
const derivedSubstitution = termSubstitution; ///
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
context.addDerivedSubstitution(derivedSubstitution);
|
|
162
162
|
|
|
163
163
|
termUnifies = true;
|
|
164
164
|
}
|
package/src/process/unify.js
CHANGED
|
@@ -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
|
|
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
|
|
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 =
|
|
419
|
+
success = statementPass.run(generalNode, specificNode, generalContext, specificContext);
|
|
422
420
|
|
|
423
421
|
if (success) {
|
|
424
422
|
statementUnifies = true;
|
package/src/utilities/context.js
CHANGED
|
@@ -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,
|
|
83
|
-
|
|
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
|
-
|
|
89
|
-
})
|
|
85
|
+
context = mnemicContext; ///
|
|
90
86
|
|
|
91
|
-
return innerFunction(
|
|
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,
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
146
|
+
let contextNominalFileContext = (context instanceof NominalFileContext);
|
|
147
|
+
|
|
148
|
+
while (!contextNominalFileContext) {
|
|
149
|
+
context = context.getContext();
|
|
127
150
|
|
|
128
|
-
|
|
151
|
+
contextNominalFileContext = (context instanceof NominalFileContext);
|
|
152
|
+
}
|
|
129
153
|
|
|
130
154
|
return context;
|
|
131
155
|
});
|
|
@@ -133,17 +157,31 @@ export function serialise(innerFunction, ...contexts) {
|
|
|
133
157
|
return innerFunction(...contexts);
|
|
134
158
|
}
|
|
135
159
|
|
|
136
|
-
export function
|
|
137
|
-
|
|
138
|
-
|
|
160
|
+
export function attempts(innerFunction, ...contexts) {
|
|
161
|
+
contexts = contexts.map((context) => {
|
|
162
|
+
const mnemicContext = MenmicContext.fromNothing(context);
|
|
139
163
|
|
|
140
|
-
|
|
164
|
+
context = mnemicContext; ///
|
|
165
|
+
|
|
166
|
+
return context;
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
return innerFunction(...contexts);
|
|
141
170
|
}
|
|
142
171
|
|
|
143
|
-
export function
|
|
144
|
-
const
|
|
172
|
+
export function serialises(innerFunction, ...contexts) {
|
|
173
|
+
const mnemicContexts = contexts, ///
|
|
174
|
+
mnemicContextsJSON = mnemicContextsToMnemicContextsJSON(mnemicContexts),
|
|
175
|
+
contextsJSON = mnemicContextsJSON; ///
|
|
145
176
|
|
|
146
|
-
|
|
177
|
+
contexts = contextsJSON; ///
|
|
147
178
|
|
|
148
|
-
return innerFunction(
|
|
179
|
+
return innerFunction(...contexts);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function unserialises(innerFunction, json, context) {
|
|
183
|
+
const mnemicContexts = mnemicContextsFromJSON(json, context),
|
|
184
|
+
contexts = mnemicContexts; ///
|
|
185
|
+
|
|
186
|
+
return innerFunction(json, ...contexts);
|
|
149
187
|
}
|
package/src/utilities/element.js
CHANGED
|
@@ -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,
|
|
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(
|
|
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,
|
|
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(
|
|
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,
|
|
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(
|
|
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,
|
|
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,
|
|
891
|
+
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, generalContext, specificContext),
|
|
878
892
|
targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
879
893
|
replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
880
|
-
statementSubstitution = new StatementSubstitution(
|
|
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,
|
|
1976
|
-
const frameSubstitution = frameSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
1977
|
-
termSubstitution = termSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
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,
|
|
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,
|
|
2009
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, generalContext, specificContext);
|
|
2044
2010
|
}
|
|
2045
2011
|
|
|
2046
2012
|
return termSubstitution;
|
|
2047
2013
|
}
|
|
2048
2014
|
|
|
2049
|
-
export function frameSubstitutionFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
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,
|
|
2021
|
+
frameSubstitution = frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode, generalContext, specificContext);
|
|
2056
2022
|
}
|
|
2057
2023
|
|
|
2058
2024
|
return frameSubstitution;
|
package/src/utilities/json.js
CHANGED
|
@@ -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
|
|
679
|
+
const { contexts } = json;
|
|
666
680
|
|
|
667
|
-
|
|
681
|
+
const mnemicContexts = contexts.map((context) => {
|
|
682
|
+
json = context; ///
|
|
668
683
|
|
|
669
|
-
|
|
670
|
-
contexts.push(context);
|
|
671
|
-
}
|
|
684
|
+
context = releaseContext; ///
|
|
672
685
|
|
|
673
|
-
|
|
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
|
-
|
|
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
|
|
109
|
-
|
|
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
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
if (substitution === null) {
|
|
115
|
+
statementValidatesAsMetavariable = true;
|
|
116
|
+
} else {
|
|
117
117
|
substitution = substitution.validate(generalContext, specificContext); ///
|
|
118
118
|
|
|
119
|
-
if (substitution
|
|
120
|
-
statementValidatesAsMetavariable =
|
|
119
|
+
if (substitution !== null) {
|
|
120
|
+
statementValidatesAsMetavariable = true;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|