occam-verify-cli 1.0.768 → 1.0.781
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/file/nominal.js +11 -11
- package/lib/context/illative.js +28 -0
- package/lib/context/nested.js +31 -0
- package/lib/context/proof.js +242 -0
- package/lib/context/thetic.js +28 -0
- package/lib/context.js +19 -21
- package/lib/element/assertion/contained.js +32 -24
- package/lib/element/assertion/defined.js +47 -40
- package/lib/element/assertion/property.js +18 -13
- package/lib/element/assertion/satisfies.js +12 -9
- package/lib/element/assertion/subproof.js +28 -26
- package/lib/element/assertion/type.js +14 -12
- package/lib/element/assumption.js +40 -50
- package/lib/element/combinator/bracketed.js +3 -3
- package/lib/element/combinator.js +20 -20
- package/lib/element/conclusion.js +33 -29
- package/lib/element/constructor.js +19 -18
- package/lib/element/deduction.js +33 -29
- package/lib/element/equality.js +13 -15
- package/lib/element/equivalence.js +59 -52
- package/lib/element/equivalences.js +4 -2
- package/lib/element/frame.js +74 -53
- package/lib/element/hypothesis.js +7 -5
- package/lib/element/judgement.js +41 -74
- package/lib/element/label.js +22 -22
- package/lib/element/metavariable.js +31 -11
- package/lib/element/proofAssertion/premise.js +48 -35
- package/lib/element/proofAssertion/step.js +77 -22
- package/lib/element/proofAssertion/supposition.js +48 -34
- package/lib/element/proofAssertion.js +1 -14
- package/lib/element/reference.js +80 -53
- package/lib/element/signature.js +44 -3
- package/lib/element/statement.js +28 -29
- package/lib/element/subproof.js +2 -2
- package/lib/element/substitution/frame.js +24 -19
- package/lib/element/substitution/metaLevel.js +31 -27
- package/lib/element/substitution/reference.js +11 -10
- package/lib/element/substitution/statement.js +30 -23
- package/lib/element/substitution/term.js +11 -10
- package/lib/element/term.js +24 -20
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/variable.js +6 -2
- package/lib/process/assign.js +10 -4
- package/lib/process/unify.js +8 -8
- package/lib/process/validate.js +10 -8
- package/lib/utilities/context.js +68 -23
- package/lib/utilities/element.js +55 -27
- package/lib/utilities/json.js +8 -8
- package/lib/utilities/string.js +12 -1
- package/lib/utilities/unification.js +14 -12
- package/lib/utilities/validation.js +55 -40
- package/package.json +4 -4
- package/src/context/file/nominal.js +14 -16
- package/src/context/illative.js +17 -0
- package/src/context/nested.js +21 -0
- package/src/context/{scoped.js → proof.js} +65 -51
- package/src/context/thetic.js +17 -0
- package/src/context.js +30 -36
- package/src/element/assertion/contained.js +44 -31
- package/src/element/assertion/defined.js +55 -46
- package/src/element/assertion/property.js +23 -15
- package/src/element/assertion/satisfies.js +15 -10
- package/src/element/assertion/subproof.js +34 -31
- package/src/element/assertion/type.js +18 -13
- package/src/element/assumption.js +40 -69
- package/src/element/combinator/bracketed.js +2 -2
- package/src/element/combinator.js +23 -29
- package/src/element/conclusion.js +37 -40
- package/src/element/constructor.js +29 -34
- package/src/element/deduction.js +36 -39
- package/src/element/equality.js +16 -18
- package/src/element/equivalence.js +76 -67
- package/src/element/equivalences.js +5 -2
- package/src/element/frame.js +96 -65
- package/src/element/hypothesis.js +7 -6
- package/src/element/judgement.js +45 -45
- package/src/element/label.js +25 -31
- package/src/element/metavariable.js +48 -21
- package/src/element/proofAssertion/premise.js +63 -49
- package/src/element/proofAssertion/step.js +47 -26
- package/src/element/proofAssertion/supposition.js +64 -50
- package/src/element/proofAssertion.js +0 -22
- package/src/element/reference.js +119 -80
- package/src/element/signature.js +5 -2
- package/src/element/statement.js +30 -35
- package/src/element/subproof.js +1 -1
- package/src/element/substitution/frame.js +27 -26
- package/src/element/substitution/metaLevel.js +38 -42
- package/src/element/substitution/reference.js +13 -14
- package/src/element/substitution/statement.js +35 -33
- package/src/element/substitution/term.js +13 -14
- package/src/element/term.js +42 -34
- package/src/element/topLevelMetaAssertion.js +1 -1
- package/src/element/variable.js +8 -1
- package/src/process/assign.js +9 -3
- package/src/process/unify.js +7 -7
- package/src/process/validate.js +9 -8
- package/src/utilities/context.js +82 -31
- package/src/utilities/element.js +68 -31
- package/src/utilities/json.js +13 -13
- package/src/utilities/string.js +16 -2
- package/src/utilities/unification.js +18 -16
- package/src/utilities/validation.js +73 -53
- package/lib/context/scoped.js +0 -232
- package/lib/utilities/statement.js +0 -78
- package/lib/utilities/term.js +0 -17
- package/src/utilities/statement.js +0 -74
- package/src/utilities/term.js +0 -10
package/src/element/term.js
CHANGED
|
@@ -41,40 +41,6 @@ export default define(class Term extends Element {
|
|
|
41
41
|
return variableIdentifier;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
matchTermNode(termNode) {
|
|
45
|
-
const node = termNode, ///
|
|
46
|
-
nodeMatches = this.matchNode(node),
|
|
47
|
-
termNodeMatches = nodeMatches; ///
|
|
48
|
-
|
|
49
|
-
return termNodeMatches;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
compareVariableIdentifier(variableIdentifier) {
|
|
53
|
-
let comparesToVariableIdentifier = false;
|
|
54
|
-
|
|
55
|
-
const singular = this.isSingular();
|
|
56
|
-
|
|
57
|
-
if (singular) {
|
|
58
|
-
const variableIdentifierA = variableIdentifier; ///
|
|
59
|
-
|
|
60
|
-
variableIdentifier = this.getVariableIdentifier();
|
|
61
|
-
|
|
62
|
-
const variableIdentifierB = variableIdentifier;
|
|
63
|
-
|
|
64
|
-
comparesToVariableIdentifier = (variableIdentifierA === variableIdentifierB);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return comparesToVariableIdentifier;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
findValidTerm(context) {
|
|
71
|
-
const termNode = this.getTermNode(),
|
|
72
|
-
term = context.findTermByTermNode(termNode),
|
|
73
|
-
validTerm = term; ///
|
|
74
|
-
|
|
75
|
-
return validTerm;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
44
|
isEqualTo(term) {
|
|
79
45
|
const termNode = term.getNode(),
|
|
80
46
|
termNodeMatches = this.matchTermNode(termNode),
|
|
@@ -127,6 +93,22 @@ export default define(class Term extends Element {
|
|
|
127
93
|
return implicitlyGrounded;
|
|
128
94
|
}
|
|
129
95
|
|
|
96
|
+
matchTermNode(termNode) {
|
|
97
|
+
const node = termNode, ///
|
|
98
|
+
nodeMatches = this.matchNode(node),
|
|
99
|
+
termNodeMatches = nodeMatches; ///
|
|
100
|
+
|
|
101
|
+
return termNodeMatches;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
compareTerm(term) {
|
|
105
|
+
const termNode = term.getNode(),
|
|
106
|
+
termNodeMatches = this.matchNode(termNode),
|
|
107
|
+
comparesTo = termNodeMatches; ///
|
|
108
|
+
|
|
109
|
+
return comparesTo;
|
|
110
|
+
}
|
|
111
|
+
|
|
130
112
|
compareParameter(parameter) {
|
|
131
113
|
let comparesToParamter = false;
|
|
132
114
|
|
|
@@ -147,6 +129,32 @@ export default define(class Term extends Element {
|
|
|
147
129
|
return comparesToParamter;
|
|
148
130
|
}
|
|
149
131
|
|
|
132
|
+
compareVariableIdentifier(variableIdentifier) {
|
|
133
|
+
let comparesToVariableIdentifier = false;
|
|
134
|
+
|
|
135
|
+
const singular = this.isSingular();
|
|
136
|
+
|
|
137
|
+
if (singular) {
|
|
138
|
+
const variableIdentifierA = variableIdentifier; ///
|
|
139
|
+
|
|
140
|
+
variableIdentifier = this.getVariableIdentifier();
|
|
141
|
+
|
|
142
|
+
const variableIdentifierB = variableIdentifier;
|
|
143
|
+
|
|
144
|
+
comparesToVariableIdentifier = (variableIdentifierA === variableIdentifierB);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return comparesToVariableIdentifier;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
findValidTerm(context) {
|
|
151
|
+
const termNode = this.getTermNode(),
|
|
152
|
+
term = context.findTermByTermNode(termNode),
|
|
153
|
+
validTerm = term; ///
|
|
154
|
+
|
|
155
|
+
return validTerm;
|
|
156
|
+
}
|
|
157
|
+
|
|
150
158
|
validate(context, validateForwards) {
|
|
151
159
|
let term = null;
|
|
152
160
|
|
package/src/element/variable.js
CHANGED
|
@@ -7,8 +7,8 @@ import elements from "../elements";
|
|
|
7
7
|
import { define } from "../elements";
|
|
8
8
|
import { instantiate } from "../utilities/context";
|
|
9
9
|
import { instantiateVariable } from "../process/instantiate";
|
|
10
|
-
import {identifierFromVarialbeNode, variableFromVariableNode} from "../utilities/element";
|
|
11
10
|
import { typeFromJSON, typeToTypeJSON } from "../utilities/json";
|
|
11
|
+
import { variableFromTermNode, identifierFromVarialbeNode } from "../utilities/element";
|
|
12
12
|
|
|
13
13
|
export default define(class Variable extends Element {
|
|
14
14
|
constructor(context, string, node, type, identifier) {
|
|
@@ -198,4 +198,11 @@ export default define(class Variable extends Element {
|
|
|
198
198
|
return variable;
|
|
199
199
|
}, context);
|
|
200
200
|
}
|
|
201
|
+
|
|
202
|
+
static fromTerm(term, context) {
|
|
203
|
+
const termNode = term.getNode(),
|
|
204
|
+
variable = variableFromTermNode(termNode, context);
|
|
205
|
+
|
|
206
|
+
return variable;
|
|
207
|
+
}
|
|
201
208
|
});
|
package/src/process/assign.js
CHANGED
|
@@ -23,7 +23,9 @@ export function judgementAssignmentFromJudgement(judgement, context) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function leftVariableAssignmentFromEquality(equality, context) {
|
|
26
|
-
let leftVariableAssignment =
|
|
26
|
+
let leftVariableAssignment = (contxt) => {
|
|
27
|
+
///
|
|
28
|
+
};
|
|
27
29
|
|
|
28
30
|
const leftTermNode = equality.getLeftTermNode(),
|
|
29
31
|
singularVariableNode = leftTermNode.getSingularVariableNode();
|
|
@@ -39,7 +41,9 @@ export function leftVariableAssignmentFromEquality(equality, context) {
|
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export function rightVariableAssignmentFromEquality(equality, context) {
|
|
42
|
-
let rightVariableAssignment =
|
|
44
|
+
let rightVariableAssignment = (context) => {
|
|
45
|
+
///
|
|
46
|
+
};
|
|
43
47
|
|
|
44
48
|
const rightTermNode = equality.getRightTermNode(),
|
|
45
49
|
singularVariableNode = rightTermNode.getSingularVariableNode();
|
|
@@ -55,7 +59,9 @@ export function rightVariableAssignmentFromEquality(equality, context) {
|
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
export function variableAssignmentFromTypeAssertion(typeAssertion, context) {
|
|
58
|
-
let variableAssignment =
|
|
62
|
+
let variableAssignment = (context) => {
|
|
63
|
+
///
|
|
64
|
+
};
|
|
59
65
|
|
|
60
66
|
const term = typeAssertion.getTerm(),
|
|
61
67
|
termSingular = term.isSingular();
|
package/src/process/unify.js
CHANGED
|
@@ -152,7 +152,7 @@ class CombinatorPass extends ZipPass {
|
|
|
152
152
|
{
|
|
153
153
|
generalNodeQuery: metaTypeNodeQuery,
|
|
154
154
|
specificNodeQuery: statementNodeQuery,
|
|
155
|
-
run: (generalMetaTypeNode, specificStatementNode,
|
|
155
|
+
run: (generalMetaTypeNode, specificStatementNode, generalContext, specificContext) => {
|
|
156
156
|
let success = false;
|
|
157
157
|
|
|
158
158
|
const metaTypeNode = generalMetaTypeNode, ///
|
|
@@ -167,7 +167,7 @@ class CombinatorPass extends ZipPass {
|
|
|
167
167
|
|
|
168
168
|
statement = statementFromStatementNode(statementNode, context);
|
|
169
169
|
|
|
170
|
-
statement = statement.validate(
|
|
170
|
+
statement = statement.validate(context); ///
|
|
171
171
|
|
|
172
172
|
if (statement !== null) {
|
|
173
173
|
success = true;
|
|
@@ -180,7 +180,7 @@ class CombinatorPass extends ZipPass {
|
|
|
180
180
|
{
|
|
181
181
|
generalNodeQuery: metaTypeNodeQuery,
|
|
182
182
|
specificNodeQuery: frameNodeQuery,
|
|
183
|
-
run: (generalMetaTypeNode, specificFrameNode,
|
|
183
|
+
run: (generalMetaTypeNode, specificFrameNode, generalContext, specificContext) => {
|
|
184
184
|
let success = false;
|
|
185
185
|
|
|
186
186
|
const metaTypeNode = generalMetaTypeNode, ///
|
|
@@ -195,7 +195,7 @@ class CombinatorPass extends ZipPass {
|
|
|
195
195
|
|
|
196
196
|
frame = frameFromFrameNode(frameNode, context);
|
|
197
197
|
|
|
198
|
-
frame = frame.validate(
|
|
198
|
+
frame = frame.validate(context); ///
|
|
199
199
|
|
|
200
200
|
if (frame !== null) {
|
|
201
201
|
success = true;
|
|
@@ -208,7 +208,7 @@ class CombinatorPass extends ZipPass {
|
|
|
208
208
|
{
|
|
209
209
|
generalNodeQuery: typeNodeQuery,
|
|
210
210
|
specificNodeQuery: termNodeQuery,
|
|
211
|
-
run: (generalTypeNode, specificTermNode,
|
|
211
|
+
run: (generalTypeNode, specificTermNode, generalContext, specificContext) => {
|
|
212
212
|
let success = false;
|
|
213
213
|
|
|
214
214
|
const typeNode = generalTypeNode, ///
|
|
@@ -466,13 +466,13 @@ export function unifyTermWithConstructor(term, constructor, generalContext, spec
|
|
|
466
466
|
return termUnifiesWithConstructor;
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
-
export function unifyStatementWithCombinator(statement, combinator,
|
|
469
|
+
export function unifyStatementWithCombinator(statement, combinator, generalContext, specificContext) {
|
|
470
470
|
let statementUnifiesWithCombinator = false;
|
|
471
471
|
|
|
472
472
|
const statementNode = statement.getNode(),
|
|
473
473
|
combinatorStatement = combinator.getStatement(),
|
|
474
474
|
combinatorStatementNode = combinatorStatement.getNode(),
|
|
475
|
-
success = combinatorPass.run(combinatorStatementNode, statementNode,
|
|
475
|
+
success = combinatorPass.run(combinatorStatementNode, statementNode, generalContext, specificContext);
|
|
476
476
|
|
|
477
477
|
if (success) {
|
|
478
478
|
statementUnifiesWithCombinator = true;
|
package/src/process/validate.js
CHANGED
|
@@ -4,6 +4,7 @@ import { SimplePass } from "occam-languages";
|
|
|
4
4
|
import { queryUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
6
|
import { termFromTermNode, statementFromStatementNode } from "../utilities/element";
|
|
7
|
+
import {descend} from "../utilities/context";
|
|
7
8
|
|
|
8
9
|
const { nodeQuery } = queryUtilities;
|
|
9
10
|
|
|
@@ -32,17 +33,17 @@ class CombinatorPass extends SimplePass {
|
|
|
32
33
|
run: (statementNode, context) => {
|
|
33
34
|
let success = false;
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
descend((context) => {
|
|
37
|
+
let statement;
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
statement = statementFromStatementNode(statementNode, context);
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
statement = statement.validate(context); ///
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
43
|
+
if (statement !== null) {
|
|
44
|
+
success = true;
|
|
45
|
+
}
|
|
46
|
+
}, context);
|
|
46
47
|
|
|
47
48
|
return success;
|
|
48
49
|
}
|
package/src/utilities/context.js
CHANGED
|
@@ -1,38 +1,53 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import ProofContext from "../context/proof";
|
|
4
|
+
import NestedContext from "../context/nested";
|
|
5
|
+
import TheticContext from "../context/thetic";
|
|
4
6
|
import NominalContext from "../context/nominal";
|
|
5
7
|
import LiteralContext from "../context/literal";
|
|
6
8
|
import LiminalContext from "../context/liminal";
|
|
9
|
+
import IllativeContext from "../context/illative";
|
|
7
10
|
import EphemeralContext from "../context/ephemeral";
|
|
8
11
|
import BranchingContext from "../context/branching";
|
|
9
12
|
import SyntheticContext from "../context/synthetic";
|
|
10
13
|
|
|
11
|
-
|
|
12
|
-
let context;
|
|
14
|
+
import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
export function join(innerFunction, ...contexts) {
|
|
17
|
+
const syntheticContext = SyntheticContext.fromContexts(...contexts),
|
|
18
|
+
context = syntheticContext; ///
|
|
15
19
|
|
|
16
|
-
context
|
|
20
|
+
return innerFunction(context);
|
|
21
|
+
}
|
|
17
22
|
|
|
18
|
-
|
|
23
|
+
export function choose(innerFunction, context) {
|
|
24
|
+
const branchingContext = BranchingContext.fromNothing(context);
|
|
19
25
|
|
|
20
|
-
context =
|
|
26
|
+
context = branchingContext; ///
|
|
21
27
|
|
|
22
28
|
return innerFunction(context);
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
export function
|
|
26
|
-
const
|
|
27
|
-
|
|
31
|
+
export function derive(innerFunction, context) {
|
|
32
|
+
const illativeContext = IllativeContext.fromNothing(context);
|
|
33
|
+
|
|
34
|
+
context = illativeContext; ///
|
|
28
35
|
|
|
29
36
|
return innerFunction(context);
|
|
30
37
|
}
|
|
31
38
|
|
|
32
|
-
export function
|
|
33
|
-
const
|
|
39
|
+
export function declare(innerFunction, context) {
|
|
40
|
+
const theticContext = TheticContext.fromNothing(context);
|
|
34
41
|
|
|
35
|
-
context =
|
|
42
|
+
context = theticContext; ///
|
|
43
|
+
|
|
44
|
+
return innerFunction(context);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function descend(innerFunction, context) {
|
|
48
|
+
const nestedContext = NestedContext.fromNothing(context);
|
|
49
|
+
|
|
50
|
+
context = nestedContext; ///
|
|
36
51
|
|
|
37
52
|
return innerFunction(context);
|
|
38
53
|
}
|
|
@@ -61,6 +76,54 @@ export function instantiate(innerFunction, context) {
|
|
|
61
76
|
return innerFunction(context);
|
|
62
77
|
}
|
|
63
78
|
|
|
79
|
+
export function nominally(innerFunction) {
|
|
80
|
+
let context;
|
|
81
|
+
|
|
82
|
+
const nominalContext = NominalContext.fromNothing();
|
|
83
|
+
|
|
84
|
+
context = nominalContext; ///
|
|
85
|
+
|
|
86
|
+
const literalContext = LiteralContext.fromNothing(context);
|
|
87
|
+
|
|
88
|
+
context = literalContext; ///
|
|
89
|
+
|
|
90
|
+
return innerFunction(context);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function simplify(innerFunction, context) {
|
|
94
|
+
let contextExtraneousContext = isContextExtraneousContext(context);
|
|
95
|
+
|
|
96
|
+
while (contextExtraneousContext) {
|
|
97
|
+
context = context.getContext();
|
|
98
|
+
|
|
99
|
+
contextExtraneousContext = isContextExtraneousContext(context);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const ephemeralContext = EphemeralContext.fromNothing(context);
|
|
103
|
+
|
|
104
|
+
context = ephemeralContext; ///
|
|
105
|
+
|
|
106
|
+
return innerFunction(context);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function serialise(innerFunction, context) {
|
|
110
|
+
const ephemeralContext = context, ///
|
|
111
|
+
ephemeralContextJSON = ephemeralContextToEphemeralContextJSON(ephemeralContext),
|
|
112
|
+
contextJSON = ephemeralContextJSON; ///
|
|
113
|
+
|
|
114
|
+
context = contextJSON; ///
|
|
115
|
+
|
|
116
|
+
return innerFunction(context);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function unserialise(innerFunction, json, context) {
|
|
120
|
+
const ephemeralContext = ephemeralContextFromJSON(json, context);
|
|
121
|
+
|
|
122
|
+
context = ephemeralContext; ///
|
|
123
|
+
|
|
124
|
+
return innerFunction(json, context);
|
|
125
|
+
}
|
|
126
|
+
|
|
64
127
|
export async function asyncRestrict(innerFunction, metaLevelSubstitutions, context) {
|
|
65
128
|
if (context === undefined) {
|
|
66
129
|
context = metaLevelSubstitutions; ///
|
|
@@ -68,9 +131,9 @@ export async function asyncRestrict(innerFunction, metaLevelSubstitutions, conte
|
|
|
68
131
|
metaLevelSubstitutions = null;
|
|
69
132
|
}
|
|
70
133
|
|
|
71
|
-
const
|
|
134
|
+
const proofContext = ProofContext.fromMetaLevelSubstitutions(metaLevelSubstitutions, context);
|
|
72
135
|
|
|
73
|
-
context =
|
|
136
|
+
context = proofContext; ///
|
|
74
137
|
|
|
75
138
|
return await innerFunction(context);
|
|
76
139
|
}
|
|
@@ -83,27 +146,15 @@ export async function asyncReconcile(innerFunction, context) {
|
|
|
83
146
|
return await innerFunction(context);
|
|
84
147
|
}
|
|
85
148
|
|
|
86
|
-
export function sanitisedContextFromContext(context) {
|
|
87
|
-
let contextExtraneousContext = isContextExtraneousContext(context);
|
|
88
|
-
|
|
89
|
-
while (contextExtraneousContext) {
|
|
90
|
-
context = context.getContext();
|
|
91
|
-
|
|
92
|
-
contextExtraneousContext = isContextExtraneousContext(context);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const ephemeralContext = EphemeralContext.fromNothing(context),
|
|
96
|
-
sanitisedContext = ephemeralContext; ///
|
|
97
|
-
|
|
98
|
-
return sanitisedContext;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
149
|
function isContextExtraneousContext(context) {
|
|
102
150
|
const contextLiminalContext = (context instanceof LiminalContext),
|
|
103
151
|
contextEphemeralContext = (context instanceof EphemeralContext),
|
|
104
152
|
contextBranchingContext = (context instanceof BranchingContext),
|
|
105
153
|
contextSyntheticContext = (context instanceof SyntheticContext),
|
|
106
|
-
contextExtraneousContext = (contextLiminalContext
|
|
154
|
+
contextExtraneousContext = ( contextLiminalContext
|
|
155
|
+
|| contextEphemeralContext
|
|
156
|
+
|| contextBranchingContext
|
|
157
|
+
|| contextSyntheticContext );
|
|
107
158
|
|
|
108
159
|
return contextExtraneousContext;
|
|
109
160
|
}
|
package/src/utilities/element.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import elements from "../elements";
|
|
4
4
|
|
|
5
|
-
import { instantiate } from "../utilities/context";
|
|
6
5
|
import { baseTypeFromNothing } from "../utilities/type";
|
|
7
|
-
import {
|
|
6
|
+
import { simplify, instantiate,} from "../utilities/context";
|
|
7
|
+
import { instantiateLabel, instantiateReference } from "../process/instantiate";
|
|
8
8
|
import { equivalenceStringFromTerms,
|
|
9
9
|
typeStringFromNominalTypeName,
|
|
10
10
|
rulsStringFromLabelsPremisesAndConclusion,
|
|
@@ -13,7 +13,6 @@ import { equivalenceStringFromTerms,
|
|
|
13
13
|
procedureCallStringFromProcedureReferenceAndParameters,
|
|
14
14
|
topLevelAssertionStringFromLabelsSuppositionsAndDeduction,
|
|
15
15
|
topLevelMetaAssertionStringFromLabelSuppositionsAndDeduction } from "../utilities/string";
|
|
16
|
-
import EphemeralContext from "../context/ephemeral";
|
|
17
16
|
|
|
18
17
|
export function typeFromTypeNode(typeNode, context) {
|
|
19
18
|
let type;
|
|
@@ -321,11 +320,9 @@ export function referenceFromReferenceNode(referenceNode, context) {
|
|
|
321
320
|
const { Reference } = elements,
|
|
322
321
|
node = referenceNode, ///
|
|
323
322
|
string = context.nodeAsString(node),
|
|
324
|
-
metavariable = metavariableFromReferenceNode(referenceNode, context)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const reference = new Reference(context, string, node, metavariable);
|
|
323
|
+
metavariable = metavariableFromReferenceNode(referenceNode, context),
|
|
324
|
+
topLevelMetaAssertion = topLevelMetaAssertionFromReferenceNode(referenceNode, context),
|
|
325
|
+
reference = new Reference(context, string, node, metavariable, topLevelMetaAssertion);
|
|
329
326
|
|
|
330
327
|
return reference;
|
|
331
328
|
}
|
|
@@ -509,13 +506,14 @@ export function suppositionFromSuppositionNode(suppositionNode, context) {
|
|
|
509
506
|
export function equivalenceFromEquivalenceNode(equivalenceNode, context) {
|
|
510
507
|
const { Equivalence } = elements,
|
|
511
508
|
node = equivalenceNode, ///
|
|
509
|
+
type = typeFromEquivalenceNode(equivalenceNode, context),
|
|
512
510
|
terms = termsFromEquivalenceNode(equivalenceNode, context),
|
|
513
511
|
equivalenceString = equivalenceStringFromTerms(terms),
|
|
514
512
|
string = equivalenceString; ///
|
|
515
513
|
|
|
516
514
|
context = null;
|
|
517
515
|
|
|
518
|
-
const equivalence = new Equivalence(context, string, node, terms);
|
|
516
|
+
const equivalence = new Equivalence(context, string, node, type, terms);
|
|
519
517
|
|
|
520
518
|
return equivalence;
|
|
521
519
|
}
|
|
@@ -677,12 +675,6 @@ export function subproofAssertionFromSubproofAssertionNode(subproofAssertionNode
|
|
|
677
675
|
return subproofAssertion;
|
|
678
676
|
}
|
|
679
677
|
|
|
680
|
-
export function substitutionsFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, context) {
|
|
681
|
-
const substitutions = [];
|
|
682
|
-
|
|
683
|
-
return substitutions;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
678
|
export function containedAssertionFromContainedAssertionNode(containedAssertionNode, context) {
|
|
687
679
|
const { ContainedAssertion } = elements,
|
|
688
680
|
node = containedAssertionNode, ///
|
|
@@ -945,7 +937,9 @@ export function referenceFromStepNode(stepNode, context) {
|
|
|
945
937
|
const referenceNode = stepNode.getReferenceNode();
|
|
946
938
|
|
|
947
939
|
if (referenceNode !== null) {
|
|
948
|
-
|
|
940
|
+
const referenceString = context.nodeAsString(referenceNode);
|
|
941
|
+
|
|
942
|
+
reference = referenceFromReferenceString(referenceString, context);
|
|
949
943
|
}
|
|
950
944
|
|
|
951
945
|
return reference;
|
|
@@ -1042,6 +1036,12 @@ export function typeFromConstructorNode(ocnstructorNode, context) {
|
|
|
1042
1036
|
return type;
|
|
1043
1037
|
}
|
|
1044
1038
|
|
|
1039
|
+
export function typeFromEquivalenceNode(equivalenceNode, context) {
|
|
1040
|
+
const type = null;
|
|
1041
|
+
|
|
1042
|
+
return type;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
1045
|
export function assumptionsFromFrameNode(frameNode, context) {
|
|
1046
1046
|
const assumptionNodes = frameNode.getAssumptionNodes(),
|
|
1047
1047
|
assumptions = assumptionsFromAssumptionNodes(assumptionNodes, context);
|
|
@@ -1361,16 +1361,11 @@ export function metavariableFromReferenceNode(referenceNode, context) {
|
|
|
1361
1361
|
}
|
|
1362
1362
|
|
|
1363
1363
|
export function referenceFromMetavariableNode(metavariableNode, context) {
|
|
1364
|
-
const metavariableString = context.nodeAsString(metavariableNode)
|
|
1364
|
+
const metavariableString = context.nodeAsString(metavariableNode),
|
|
1365
|
+
referenceString = metavariableString, ///
|
|
1366
|
+
reference = referenceFromReferenceString(referenceString, context);
|
|
1365
1367
|
|
|
1366
|
-
return
|
|
1367
|
-
const referenceString = metavariableString, ///
|
|
1368
|
-
string = referenceString, ///
|
|
1369
|
-
referenceNode = instantiateReference(string, context),
|
|
1370
|
-
reference = referenceFromReferenceNode(referenceNode, context);
|
|
1371
|
-
|
|
1372
|
-
return reference;
|
|
1373
|
-
}, context);
|
|
1368
|
+
return reference;
|
|
1374
1369
|
}
|
|
1375
1370
|
|
|
1376
1371
|
export function termFromJDefinedAssertionNode(definedAssertionNode, context) {
|
|
@@ -1607,7 +1602,8 @@ export function proofFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, cont
|
|
|
1607
1602
|
|
|
1608
1603
|
export function labelFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, context) {
|
|
1609
1604
|
const labelNode = metaLemmaMetathoremNode.getLabelNode(),
|
|
1610
|
-
|
|
1605
|
+
labelString = context.nodeAsString(labelNode),
|
|
1606
|
+
label = labelFromLabelString(labelString, context);
|
|
1611
1607
|
|
|
1612
1608
|
return label;
|
|
1613
1609
|
}
|
|
@@ -1729,7 +1725,8 @@ export function signatureFromJSatisfiesAssertionNode(sasisfiesAssertionNode, con
|
|
|
1729
1725
|
|
|
1730
1726
|
export function referenceFromJSatisfiesAssertionNode(sasisfiesAssertionNode, context) {
|
|
1731
1727
|
const referenceNode = sasisfiesAssertionNode.getReferenceNode(),
|
|
1732
|
-
|
|
1728
|
+
referenceString = context.nodeAsString(referenceNode),
|
|
1729
|
+
reference = referenceFromReferenceString(referenceString, context);
|
|
1733
1730
|
|
|
1734
1731
|
return reference;
|
|
1735
1732
|
}
|
|
@@ -1754,6 +1751,12 @@ export function resolvedFromStatementSubstitutionNode(statementSubstitutionNode,
|
|
|
1754
1751
|
return resolved;
|
|
1755
1752
|
}
|
|
1756
1753
|
|
|
1754
|
+
export function topLevelMetaAssertionFromReferenceNode(referenceNode, context) {
|
|
1755
|
+
const topLevelMetaAssertion = null;
|
|
1756
|
+
|
|
1757
|
+
return topLevelMetaAssertion;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1757
1760
|
export function deductionFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, context) {
|
|
1758
1761
|
const deductionNode = metaLemmaMetathoremNode.getDeductionNode(),
|
|
1759
1762
|
deduction = deductionFromDeductionNode(deductionNode, context);
|
|
@@ -1887,14 +1890,16 @@ export function metavariableFromMetavariableDeclarationNode(metavariableDeclarat
|
|
|
1887
1890
|
|
|
1888
1891
|
export function targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
|
|
1889
1892
|
const targetReferenceNode = referenceSubstitutionNode.getTargetReferenceNode(),
|
|
1890
|
-
|
|
1893
|
+
targetReferenceString = context.nodeAsString(targetReferenceNode),
|
|
1894
|
+
targetRefernece = referenceFromReferenceString(targetReferenceString, context);
|
|
1891
1895
|
|
|
1892
1896
|
return targetRefernece;
|
|
1893
1897
|
}
|
|
1894
1898
|
|
|
1895
1899
|
export function targetReferenceFromMetaLevelSubstitutionNode(metaLevelSubstitutionNode, context) {
|
|
1896
1900
|
const targetReferenceNode = metaLevelSubstitutionNode.getTargetReferenceNode(),
|
|
1897
|
-
|
|
1901
|
+
targetReferenceString = context.nodeAsString(targetReferenceNode),
|
|
1902
|
+
targetRefernece = referenceFromReferenceString(targetReferenceString, context);
|
|
1898
1903
|
|
|
1899
1904
|
return targetRefernece;
|
|
1900
1905
|
}
|
|
@@ -1932,7 +1937,8 @@ export function frameSubstitutionFromStatementSubstitutionNode(statementSubstitu
|
|
|
1932
1937
|
|
|
1933
1938
|
export function replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
|
|
1934
1939
|
const replacementReferenceNode = referenceSubstitutionNode.getReplacementReferenceNode(),
|
|
1935
|
-
|
|
1940
|
+
replacementReferenceString = context.nodeAsString(replacementReferenceNode),
|
|
1941
|
+
replacementReference = referenceFromReferenceString(replacementReferenceString, context);
|
|
1936
1942
|
|
|
1937
1943
|
return replacementReference;
|
|
1938
1944
|
}
|
|
@@ -1980,7 +1986,8 @@ export function typesFromTypesNode(typesNode, context) {
|
|
|
1980
1986
|
|
|
1981
1987
|
export function labelsFromLabelNodes(labelNodes, context) {
|
|
1982
1988
|
const labels = labelNodes.map((labelNode) => {
|
|
1983
|
-
const
|
|
1989
|
+
const labelString = context.nodeAsString(labelNode),
|
|
1990
|
+
label = labelFromLabelString(labelString, context);
|
|
1984
1991
|
|
|
1985
1992
|
return label;
|
|
1986
1993
|
});
|
|
@@ -2069,3 +2076,33 @@ export function stepsOrSubproofsFromSubDerivationNode(subDerivationNode, context
|
|
|
2069
2076
|
|
|
2070
2077
|
return stepsOrSubproofs;
|
|
2071
2078
|
}
|
|
2079
|
+
|
|
2080
|
+
export function labelFromLabelString(labelString, context) {
|
|
2081
|
+
let label;
|
|
2082
|
+
|
|
2083
|
+
simplify((context) => {
|
|
2084
|
+
instantiate((context) => {
|
|
2085
|
+
const string = labelString, ///
|
|
2086
|
+
labelNode = instantiateLabel(string, context);
|
|
2087
|
+
|
|
2088
|
+
label = labelFromLabelNode(labelNode, context);
|
|
2089
|
+
}, context);
|
|
2090
|
+
}, context);
|
|
2091
|
+
|
|
2092
|
+
return label;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
export function referenceFromReferenceString(referenceString, context) {
|
|
2096
|
+
let reference;
|
|
2097
|
+
|
|
2098
|
+
simplify((context) => {
|
|
2099
|
+
instantiate((context) => {
|
|
2100
|
+
const string = referenceString, ///
|
|
2101
|
+
referenceNode = instantiateReference(string, context);
|
|
2102
|
+
|
|
2103
|
+
reference = referenceFromReferenceNode(referenceNode, context);
|
|
2104
|
+
}, context);
|
|
2105
|
+
}, context);
|
|
2106
|
+
|
|
2107
|
+
return reference;
|
|
2108
|
+
}
|
package/src/utilities/json.js
CHANGED
|
@@ -56,6 +56,19 @@ export function typeFromJSON(json, context) {
|
|
|
56
56
|
return type;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
export function labelFromJSON(json, context) {
|
|
60
|
+
let { label } = json;
|
|
61
|
+
|
|
62
|
+
const { Label } = elements,
|
|
63
|
+
labelJSON = label; ///
|
|
64
|
+
|
|
65
|
+
json = labelJSON; ///
|
|
66
|
+
|
|
67
|
+
label = Label.fromJSON(json, context);
|
|
68
|
+
|
|
69
|
+
return label;
|
|
70
|
+
}
|
|
71
|
+
|
|
59
72
|
export function frameFromJSON(json, context) {
|
|
60
73
|
let { frame } = json;
|
|
61
74
|
|
|
@@ -270,19 +283,6 @@ export function rulesFromJSON(json, context) {
|
|
|
270
283
|
return rules;
|
|
271
284
|
}
|
|
272
285
|
|
|
273
|
-
export function labelFromJSON(json, context) {
|
|
274
|
-
let { label } = json;
|
|
275
|
-
|
|
276
|
-
const { Label } = elements,
|
|
277
|
-
labelJSON = label; ///
|
|
278
|
-
|
|
279
|
-
json = labelJSON; ///
|
|
280
|
-
|
|
281
|
-
label = Label.fromJSON(json, context);
|
|
282
|
-
|
|
283
|
-
return label;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
286
|
export function framesFromJSON(json, context) {
|
|
287
287
|
let { frames } = json;
|
|
288
288
|
|