occam-verify-cli 1.0.617 → 1.0.632
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/ephemeral.js +152 -47
- package/lib/context/file/nominal.js +136 -140
- package/lib/context/liminal.js +16 -26
- package/lib/context/scoped.js +26 -55
- package/lib/context.js +103 -53
- package/lib/element/assertion/contained.js +3 -1
- package/lib/element/assertion/defined.js +5 -3
- package/lib/element/assertion/property.js +10 -58
- package/lib/element/assertion/satisfies.js +3 -1
- package/lib/element/assertion/subproof.js +3 -1
- package/lib/element/assertion/type.js +65 -109
- package/lib/element/assumption.js +40 -16
- package/lib/element/constructor/bracketed.js +13 -53
- package/lib/element/constructor.js +5 -5
- package/lib/element/declaration/constructor.js +5 -2
- package/lib/element/derivation.js +8 -10
- package/lib/element/equality.js +102 -62
- package/lib/element/equivalence.js +6 -6
- package/lib/element/equivalences.js +4 -4
- package/lib/element/frame.js +21 -21
- package/lib/element/hypothesis.js +5 -7
- package/lib/element/judgement.js +47 -25
- package/lib/element/metaType.js +2 -2
- package/lib/element/metavariable.js +12 -3
- package/lib/element/propertyRelation.js +3 -3
- package/lib/element/reference.js +9 -21
- package/lib/element/rule.js +13 -15
- package/lib/element/signature.js +5 -5
- package/lib/element/statement.js +23 -25
- package/lib/element/subDerivation.js +4 -6
- package/lib/element/substitution/frame.js +4 -4
- package/lib/element/substitution/reference.js +4 -4
- package/lib/element/substitution/statement.js +4 -4
- package/lib/element/substitution/term.js +9 -3
- package/lib/element/substitution.js +71 -43
- package/lib/element/term.js +20 -6
- package/lib/element/topLevelAssertion.js +9 -11
- package/lib/element/topLevelMetaAssertion.js +9 -11
- package/lib/element/variable.js +44 -3
- package/lib/process/assign.js +96 -26
- package/lib/process/unify.js +3 -4
- package/lib/process/validate.js +7 -7
- package/lib/process/verify.js +2 -2
- package/lib/ruleNames.js +5 -1
- package/lib/utilities/element.js +74 -12
- package/lib/utilities/json.js +2 -2
- package/lib/utilities/string.js +9 -24
- package/lib/utilities/substitutions.js +14 -22
- package/lib/utilities/validation.js +3 -3
- package/package.json +4 -4
- package/src/context/ephemeral.js +170 -50
- package/src/context/file/nominal.js +136 -141
- package/src/context/liminal.js +22 -34
- package/src/context/scoped.js +33 -74
- package/src/context.js +97 -46
- package/src/element/assertion/contained.js +4 -0
- package/src/element/assertion/defined.js +6 -2
- package/src/element/assertion/property.js +15 -26
- package/src/element/assertion/satisfies.js +4 -0
- package/src/element/assertion/subproof.js +4 -0
- package/src/element/assertion/type.js +69 -77
- package/src/element/assumption.js +48 -16
- package/src/element/constructor/bracketed.js +11 -12
- package/src/element/constructor.js +4 -4
- package/src/element/declaration/constructor.js +5 -1
- package/src/element/derivation.js +3 -5
- package/src/element/equality.js +109 -74
- package/src/element/equivalence.js +7 -7
- package/src/element/equivalences.js +7 -5
- package/src/element/frame.js +25 -25
- package/src/element/hypothesis.js +4 -6
- package/src/element/judgement.js +54 -24
- package/src/element/metaType.js +1 -1
- package/src/element/metavariable.js +16 -3
- package/src/element/propertyRelation.js +2 -2
- package/src/element/reference.js +12 -26
- package/src/element/rule.js +8 -10
- package/src/element/signature.js +4 -4
- package/src/element/statement.js +27 -30
- package/src/element/subDerivation.js +3 -5
- package/src/element/substitution/frame.js +1 -1
- package/src/element/substitution/reference.js +1 -1
- package/src/element/substitution/statement.js +1 -1
- package/src/element/substitution/term.js +4 -2
- package/src/element/substitution.js +60 -36
- package/src/element/term.js +24 -5
- package/src/element/topLevelAssertion.js +4 -6
- package/src/element/topLevelMetaAssertion.js +4 -6
- package/src/element/variable.js +2 -0
- package/src/process/assign.js +114 -37
- package/src/process/unify.js +2 -3
- package/src/process/validate.js +5 -5
- package/src/process/verify.js +1 -1
- package/src/ruleNames.js +1 -0
- package/src/utilities/element.js +83 -26
- package/src/utilities/json.js +1 -1
- package/src/utilities/string.js +7 -29
- package/src/utilities/substitutions.js +18 -29
- package/src/utilities/validation.js +2 -2
package/src/process/assign.js
CHANGED
|
@@ -1,57 +1,134 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
return function (context) {
|
|
5
|
-
context.addVariable(variable);
|
|
3
|
+
import { variableFromVariableNode } from "../utilities/element";
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export function equalityAssignmentFromEquality(equality, context) {
|
|
6
|
+
const equalityAssignment = (context) => {
|
|
7
|
+
const equalityAdded = context.addEquality(equality);
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
context.debug(`Unable to assign the '${variableString}' variable with type '${variableTypeString}'.`);
|
|
9
|
+
return equalityAdded;
|
|
10
|
+
};
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
return equalityAssignment;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function judgementAssignmentFromJudgement(judgement, context) {
|
|
16
|
+
const judgementAssignment = (context) => {
|
|
17
|
+
const judgementAdded = context.addJudgement(judgement);
|
|
18
|
+
|
|
19
|
+
return judgementAdded;
|
|
16
20
|
};
|
|
21
|
+
|
|
22
|
+
return judgementAssignment;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
export function
|
|
20
|
-
|
|
21
|
-
const equalityString = equality.getString(),
|
|
22
|
-
equalityAdded = context.addEquality(equality),
|
|
23
|
-
assigned = equalityAdded; ///
|
|
25
|
+
export function leftVariableAssignmentFromEquality(equality, context) {
|
|
26
|
+
let leftVariableAssignment = null;
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
context.debug(`Unable to assign the '${equalityString}' equality.`);
|
|
28
|
+
const leftTermNode = equality.getLeftTermNode(),
|
|
29
|
+
singularVariableNode = leftTermNode.getSingularVariableNode();
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
if (singularVariableNode !== null) {
|
|
32
|
+
const type = equality.getType(),
|
|
33
|
+
leftVariableNode = singularVariableNode; ///
|
|
34
|
+
|
|
35
|
+
leftVariableAssignment = variableAssignmentFromVariableNodeAndType(leftVariableNode, type, context);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return leftVariableAssignment;
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
export function
|
|
34
|
-
|
|
35
|
-
const judgementString = judgement.getString(),
|
|
36
|
-
judgementAdded = context.addJudgement(judgement),
|
|
37
|
-
assigned = judgementAdded; ///
|
|
41
|
+
export function rightVariableAssignmentFromEquality(equality, context) {
|
|
42
|
+
let rightVariableAssignment = null;
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
context.debug(`Unable to assign the '${judgementString}' judgement.`);
|
|
44
|
+
const rightTermNode = equality.getRightTermNode(),
|
|
45
|
+
singularVariableNode = rightTermNode.getSingularVariableNode();
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
if (singularVariableNode !== null) {
|
|
48
|
+
const type = equality.getType(),
|
|
49
|
+
rightVariableNode = singularVariableNode; ///
|
|
50
|
+
|
|
51
|
+
rightVariableAssignment = variableAssignmentFromVariableNodeAndType(rightVariableNode, type, context);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return rightVariableAssignment;
|
|
45
55
|
}
|
|
46
56
|
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
export function variableAssignmentFromTypeAssertion(typeAssertion, context) {
|
|
58
|
+
|
|
59
|
+
debugger
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
// const { Type, Variable } = elements,
|
|
62
|
+
// termNode = this.term.getNode();
|
|
63
|
+
//
|
|
64
|
+
// let type,
|
|
65
|
+
// provisional;
|
|
66
|
+
//
|
|
67
|
+
// provisional = this.type.isProvisional();
|
|
68
|
+
//
|
|
69
|
+
// if (!provisional) {
|
|
70
|
+
// type = this.type;
|
|
71
|
+
// } else {
|
|
72
|
+
// provisional = false;
|
|
73
|
+
//
|
|
74
|
+
// type = Type.fromTypeAndProvisional(this.type, provisional);
|
|
75
|
+
// }
|
|
76
|
+
//
|
|
77
|
+
// const singularVariableNode = termNode.getSingularVariableNode();
|
|
78
|
+
//
|
|
79
|
+
// if (singularVariableNode !== null) {
|
|
80
|
+
// const variableNode = singularVariableNode, ///
|
|
81
|
+
// variable = Variable.fromVariableNodeAndType(variableNode, type, context),
|
|
82
|
+
// variableAssignment = variableAssignmentFromVariable(variable),
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function variableAssignmentFromPrepertyAssertion(propertyAssertion, context) {
|
|
87
|
+
|
|
88
|
+
debugger
|
|
89
|
+
|
|
90
|
+
// let variable;
|
|
91
|
+
//
|
|
92
|
+
// const { Variable } = elements,
|
|
93
|
+
// termNode = this.term.getNode();
|
|
94
|
+
//
|
|
95
|
+
// variable = Variable.fromTermNode(termNode, context);
|
|
96
|
+
//
|
|
97
|
+
// if (variable !== null) {
|
|
98
|
+
// const variableIdentifier = variable.getIdentifier();
|
|
99
|
+
//
|
|
100
|
+
// variable = context.findVariableByVariableIdentifier(variableIdentifier);
|
|
101
|
+
//
|
|
102
|
+
// variable = Variable.fromVariableAndPropertyRelation(variable, this.propertyRelation);
|
|
103
|
+
//
|
|
104
|
+
// const variableAssignment = variableAssignmentFromVariable(variable),
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export default function assignAssignments(assignments, context) {
|
|
109
|
+
assignments.forEach((assignment) => {
|
|
110
|
+
assignment(context);
|
|
54
111
|
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function variableAssignmentFromVariableNodeAndType(variableNode, type, context) {
|
|
115
|
+
const variable = variableFromVariableNode(variableNode, context);
|
|
116
|
+
|
|
117
|
+
variable.setType(type);
|
|
118
|
+
|
|
119
|
+
const variableAssignment = (context) => {
|
|
120
|
+
context.addVariable(variable);
|
|
121
|
+
|
|
122
|
+
const variableTypeString = variable.getTypeString(),
|
|
123
|
+
variableString = variable.getString(),
|
|
124
|
+
assigned = true;
|
|
125
|
+
|
|
126
|
+
assigned ?
|
|
127
|
+
context.trace(`Assigned the '${variableString}' variable with type '${variableTypeString}'.`) :
|
|
128
|
+
context.debug(`Unable to assign the '${variableString}' variable with type '${variableTypeString}'.`);
|
|
129
|
+
|
|
130
|
+
return assigned;
|
|
131
|
+
};
|
|
55
132
|
|
|
56
|
-
return
|
|
133
|
+
return variableAssignment;
|
|
57
134
|
}
|
package/src/process/unify.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { ZipPass, queryUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import { findMetaTypeByMetaTypeName } from "../metaTypes";
|
|
6
5
|
import { termFromTermNode, frameFromFrameNode, statementFromStatementNode } from "../utilities/element";
|
|
7
6
|
|
|
8
7
|
const { nodeQuery } = queryUtilities;
|
|
@@ -161,7 +160,7 @@ class CombinatorPass extends ZipPass {
|
|
|
161
160
|
context = generalContext; ///
|
|
162
161
|
|
|
163
162
|
const metaTypeName = metaTypeNode.getMetaTypeName(),
|
|
164
|
-
metaType = findMetaTypeByMetaTypeName(metaTypeName);
|
|
163
|
+
metaType = context.findMetaTypeByMetaTypeName(metaTypeName);
|
|
165
164
|
|
|
166
165
|
context = specificContext; ///
|
|
167
166
|
|
|
@@ -189,7 +188,7 @@ class CombinatorPass extends ZipPass {
|
|
|
189
188
|
context = generalContext; ///
|
|
190
189
|
|
|
191
190
|
const metaTypeName = metaTypeNode.getMetaTypeName(),
|
|
192
|
-
metaType = findMetaTypeByMetaTypeName(metaTypeName);
|
|
191
|
+
metaType = context.findMetaTypeByMetaTypeName(metaTypeName);
|
|
193
192
|
|
|
194
193
|
context = specificContext; ///
|
|
195
194
|
|
package/src/process/validate.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { ForwardPass } from "occam-languages";
|
|
4
3
|
import { queryUtilities } from "occam-languages";
|
|
4
|
+
import { SimplePass, ForwardPass } from "occam-languages";
|
|
5
5
|
|
|
6
6
|
import { termFromTermNode, statementFromStatementNode } from "../utilities/element";
|
|
7
7
|
|
|
@@ -70,7 +70,7 @@ class TermPass extends ForwardPass {
|
|
|
70
70
|
];
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
class StatementPass extends
|
|
73
|
+
class StatementPass extends SimplePass {
|
|
74
74
|
run(statementNode, context) {
|
|
75
75
|
let success = false;
|
|
76
76
|
|
|
@@ -92,8 +92,8 @@ class StatementPass extends ForwardPass {
|
|
|
92
92
|
let success = false;
|
|
93
93
|
|
|
94
94
|
const statement = statementFromStatementNode(statementNode, context),
|
|
95
|
-
assignments = null,
|
|
96
95
|
stated = false,
|
|
96
|
+
assignments = null,
|
|
97
97
|
statementValidates = statement.validate(assignments, stated, context);
|
|
98
98
|
|
|
99
99
|
if (statementValidates) {
|
|
@@ -143,11 +143,11 @@ class StatementPass extends ForwardPass {
|
|
|
143
143
|
const termPass = new TermPass(),
|
|
144
144
|
statementPass = new StatementPass();
|
|
145
145
|
|
|
146
|
-
export function validateTerm(termNode, context) {
|
|
146
|
+
export function validateTerm(termNode, context, validateForwards) {
|
|
147
147
|
let termValidates = false;
|
|
148
148
|
|
|
149
149
|
const node = termNode, ///
|
|
150
|
-
sucess = termPass.run(node, context);
|
|
150
|
+
sucess = termPass.run(node, context, validateForwards);
|
|
151
151
|
|
|
152
152
|
if (sucess) {
|
|
153
153
|
termValidates = true;
|
package/src/process/verify.js
CHANGED
|
@@ -295,8 +295,8 @@ class ConbinatorPass extends SimplePass {
|
|
|
295
295
|
let success = false;
|
|
296
296
|
|
|
297
297
|
const statement = statementFromStatementNode(statementNode, context),
|
|
298
|
-
assignments = null,
|
|
299
298
|
stated = false,
|
|
299
|
+
assignments = null,
|
|
300
300
|
statementValidates = statement.validate(assignments, stated, context);
|
|
301
301
|
|
|
302
302
|
if (statementValidates) {
|
package/src/ruleNames.js
CHANGED
|
@@ -76,6 +76,7 @@ export const PARENTHESISED_LABELS_RULE_NAME = "parenthesisedLabels";
|
|
|
76
76
|
export const PROPERTY_DECLARATION_RULE_NAME = "propertyDeclaration";
|
|
77
77
|
export const VARIABLE_DECLARATION_RULE_NAME = "variableDeclaration";
|
|
78
78
|
export const STATEMENT_SUBSTITUTION_RULE_NAME = "statementSubstitution";
|
|
79
|
+
export const REFERENCE_SUBSTITUTION_RULE_NAME = "referenceSubstitution";
|
|
79
80
|
export const COMBINATOR_DECLARATION_RULE_NAME = "combinatorDeclaration";
|
|
80
81
|
export const TYPE_PREFIX_DECLARATION_RULE_NAME = "typePrefixDeclaration";
|
|
81
82
|
export const SIMPLE_TYPE_DECLARATION_RULE_NAME = "simpleTypeDeclaration";
|
package/src/utilities/element.js
CHANGED
|
@@ -7,6 +7,7 @@ import { baseTypeFromNothing } from "../utilities/type";
|
|
|
7
7
|
import { instantiateReference } from "../process/instantiate";
|
|
8
8
|
import { findMetaTypeByMetaTypeName } from "../metaTypes";
|
|
9
9
|
import { equivalenceStringFromTerms,
|
|
10
|
+
typeStringFromNominalTypeName,
|
|
10
11
|
rulsStringFromLabelsPremisesAndConclusion,
|
|
11
12
|
sectionStringFromHypothesesTopLevelAssertion,
|
|
12
13
|
subproofStringFromSuppositionsAndSubDerivation,
|
|
@@ -23,16 +24,15 @@ export function typeFromTypeNode(typeNode, context) {
|
|
|
23
24
|
type = baseType; ///
|
|
24
25
|
} else {
|
|
25
26
|
const { Type } = elements,
|
|
26
|
-
typeName = typeNode.getTypeName(),
|
|
27
|
-
typePrefixName = typeNode.getTypePrefixName(),
|
|
28
|
-
nominalTypeName = typeNode.getNominalTypeName(),
|
|
29
|
-
string = nominalTypeName, ///
|
|
30
27
|
node = typeNode, ///
|
|
31
|
-
name =
|
|
32
|
-
prefixName =
|
|
33
|
-
superTypes =
|
|
34
|
-
properties =
|
|
35
|
-
provisional =
|
|
28
|
+
name = nameFromTypeNode(typeNode, context),
|
|
29
|
+
prefixName = prefixNameFromTypeNode(typeNode, context),
|
|
30
|
+
superTypes = superTypesFromTypeNode(typeNode, context),
|
|
31
|
+
properties = propertiesFromTypeNode(typeNode, context),
|
|
32
|
+
provisional = provisionalFromTypeNode(typeNode, context),
|
|
33
|
+
nominalTypeName = nominalTypeNameFromTypeNode(typeNode, context),
|
|
34
|
+
typeString = typeStringFromNominalTypeName(nominalTypeName),
|
|
35
|
+
string = typeString; ///
|
|
36
36
|
|
|
37
37
|
type = new Type(context, string, node, name, prefixName, superTypes, properties, provisional);
|
|
38
38
|
}
|
|
@@ -195,7 +195,7 @@ export function theoremFromTheoremNode(theoremNode, context) {
|
|
|
195
195
|
|
|
196
196
|
export function metaTypeFromMetaTypeNode(metaTypeNode, context) {
|
|
197
197
|
const metaTypeName = metaTypeNode.getMetaTypeName(),
|
|
198
|
-
metaType = findMetaTypeByMetaTypeName(metaTypeName);
|
|
198
|
+
metaType = context.findMetaTypeByMetaTypeName(metaTypeName);
|
|
199
199
|
|
|
200
200
|
return metaType;
|
|
201
201
|
}
|
|
@@ -236,21 +236,15 @@ export function subproofFromSubproofNode(subproofNode, context) {
|
|
|
236
236
|
return subproof;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
export function
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
string = context.nodeAsString(node),
|
|
247
|
-
leftTerm = leftTermFromEqualityNode(equalityNode, context),
|
|
248
|
-
rightTerm = rightTermFromEqualityNode(equalityNode, context);
|
|
249
|
-
|
|
250
|
-
equality = new Equality(context, string, node, leftTerm, rightTerm);
|
|
251
|
-
}
|
|
239
|
+
export function equalityFromEqualityNode(equalityNode, context) {
|
|
240
|
+
const { Equality } = elements,
|
|
241
|
+
node = equalityNode, ///
|
|
242
|
+
string = context.nodeAsString(node),
|
|
243
|
+
leftTerm = leftTermFromEqualityNode(equalityNode, context),
|
|
244
|
+
rightTerm = rightTermFromEqualityNode(equalityNode, context),
|
|
245
|
+
subproof = new Equality(context, string, node, leftTerm, rightTerm);
|
|
252
246
|
|
|
253
|
-
return
|
|
247
|
+
return subproof;
|
|
254
248
|
}
|
|
255
249
|
|
|
256
250
|
export function deductionFromDeductionNode(deductionNode, context) {
|
|
@@ -713,6 +707,13 @@ export function metavariableDeclarationFromMetavariableDeclarationNode(metavaria
|
|
|
713
707
|
return metavariableDeclaration;
|
|
714
708
|
}
|
|
715
709
|
|
|
710
|
+
export function nameFromTypeNode(typeNode, context) {
|
|
711
|
+
const typeName = typeNode.getTypeName(),
|
|
712
|
+
name = typeName; ///
|
|
713
|
+
|
|
714
|
+
return name;
|
|
715
|
+
}
|
|
716
|
+
|
|
716
717
|
export function typeFromTermNode(termNode, context) {
|
|
717
718
|
const type = null;
|
|
718
719
|
|
|
@@ -793,6 +794,25 @@ export function referenceFromStepNode(stepNode, context) {
|
|
|
793
794
|
return reference;
|
|
794
795
|
}
|
|
795
796
|
|
|
797
|
+
export function superTypesFromTypeNode(typeNode, context) {
|
|
798
|
+
const superTypes = null;
|
|
799
|
+
|
|
800
|
+
return superTypes;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
export function propertiesFromTypeNode(typeNode, context) {
|
|
804
|
+
const properties = null;
|
|
805
|
+
|
|
806
|
+
return properties;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
export function prefixNameFromTypeNode(typeNode, context) {
|
|
810
|
+
const typePrefixName = typeNode.getTypePrefixName(),
|
|
811
|
+
prefixName = typePrefixName; ///
|
|
812
|
+
|
|
813
|
+
return prefixName;
|
|
814
|
+
}
|
|
815
|
+
|
|
796
816
|
export function conclusionFromRuleNode(ruleNode, context) {
|
|
797
817
|
const conclusionNode = ruleNode.getConclusionNode(),
|
|
798
818
|
conclusion = conclusionFromConclusionNode(conclusionNode, context);
|
|
@@ -833,6 +853,12 @@ export function derivationFromProofNode(proofNode, context) {
|
|
|
833
853
|
return derivation;
|
|
834
854
|
}
|
|
835
855
|
|
|
856
|
+
export function provisionalFromTypeNode(typeNode, context) {
|
|
857
|
+
const provisional = null;
|
|
858
|
+
|
|
859
|
+
return provisional;
|
|
860
|
+
}
|
|
861
|
+
|
|
836
862
|
export function termFromConstructorNode(ocnstructorNode, context) {
|
|
837
863
|
const termNode = ocnstructorNode.getTermNode(),
|
|
838
864
|
term = termFromTermNode(termNode, context);
|
|
@@ -859,6 +885,13 @@ export function statementFromPremiseNode(premiseNode, context) {
|
|
|
859
885
|
return statement;
|
|
860
886
|
}
|
|
861
887
|
|
|
888
|
+
export function leftTermFromEqualityNode(equalityNode, context) {
|
|
889
|
+
const leftTermNode = equalityNode.getLeftTermNode(),
|
|
890
|
+
leftTerm = termFromTermNode(leftTermNode, context);
|
|
891
|
+
|
|
892
|
+
return leftTerm;
|
|
893
|
+
}
|
|
894
|
+
|
|
862
895
|
export function termsFromEquivalenceNode(equivalenceNode, context) {
|
|
863
896
|
const termNodes = equivalenceNode.getTermNodes(),
|
|
864
897
|
terms = termsFromTermNodes(termNodes, context);
|
|
@@ -897,6 +930,25 @@ export function conjectureFromSectionNode(sectionNode, context) {
|
|
|
897
930
|
return conjecture;
|
|
898
931
|
}
|
|
899
932
|
|
|
933
|
+
export function rightTermFromEqualityNode(equalityNode, context) {
|
|
934
|
+
const rightTermNode = equalityNode.getRightTermNode(),
|
|
935
|
+
rightTerm = termFromTermNode(rightTermNode, context);
|
|
936
|
+
|
|
937
|
+
return rightTerm;
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
export function equalityFromStatementNode(statementNode, context) {
|
|
941
|
+
let equality = null;
|
|
942
|
+
|
|
943
|
+
const equalityNode = statementNode.getEqualityNode();
|
|
944
|
+
|
|
945
|
+
if (equalityNode !== null) {
|
|
946
|
+
equality = equalityFromEqualityNode(equalityNode, context);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
return equality;
|
|
950
|
+
}
|
|
951
|
+
|
|
900
952
|
export function termFromTypeAssertionNode(typeAssertionNode, context) {
|
|
901
953
|
const termNode = typeAssertionNode.getTermNode(),
|
|
902
954
|
term = termFromTermNode(termNode, context);
|
|
@@ -956,6 +1008,12 @@ export function stepFromStepOrSubproofNode(stepOrSubproofNode, context) {
|
|
|
956
1008
|
return step;
|
|
957
1009
|
}
|
|
958
1010
|
|
|
1011
|
+
export function nominalTypeNameFromTypeNode(typeNode, context) {
|
|
1012
|
+
const nominalTypeName = typeNode.getNominalTypeName();
|
|
1013
|
+
|
|
1014
|
+
return nominalTypeName;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
959
1017
|
export function assumptionFromJudgementNode(judgementNode, context) {
|
|
960
1018
|
const assumptionNode = judgementNode.getAssumptionNode(),
|
|
961
1019
|
assumption = assumptionFromAssumptionNode(assumptionNode, context);
|
|
@@ -1543,7 +1601,7 @@ export function termSubstitutionFromStatementSubstitutionNode(statementSubstitut
|
|
|
1543
1601
|
const termSubstitutionNode = statementSubstitutionNode.getTermSubstitutionNode();
|
|
1544
1602
|
|
|
1545
1603
|
if (termSubstitutionNode !== null) {
|
|
1546
|
-
termSubstitution =
|
|
1604
|
+
termSubstitution = termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, context);
|
|
1547
1605
|
}
|
|
1548
1606
|
|
|
1549
1607
|
return termSubstitution;
|
|
@@ -1676,4 +1734,3 @@ export function stepsOrSubproofsFromSubDerivationNode(subDerivationNode, context
|
|
|
1676
1734
|
|
|
1677
1735
|
return stepsOrSubproofs;
|
|
1678
1736
|
}
|
|
1679
|
-
|
package/src/utilities/json.js
CHANGED
package/src/utilities/string.js
CHANGED
|
@@ -16,20 +16,6 @@ export function termsStringFromTerms(terms) {
|
|
|
16
16
|
return termsString;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function framesStringFromFrames(frames) {
|
|
20
|
-
const framesString = frames.reduce((framesString, frame) => {
|
|
21
|
-
const frameString = frame.getString();
|
|
22
|
-
|
|
23
|
-
framesString = (framesString !== null) ?
|
|
24
|
-
`${framesString}, ${frameString}` :
|
|
25
|
-
frameString;
|
|
26
|
-
|
|
27
|
-
return framesString;
|
|
28
|
-
}, null);
|
|
29
|
-
|
|
30
|
-
return framesString;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
19
|
export function labelsStringFromLabels(labels) {
|
|
34
20
|
const labelsString = labels.reduce((labelsString, label) => {
|
|
35
21
|
const labelString = label.getString();
|
|
@@ -131,20 +117,6 @@ export function suppositionsStringFromSuppositions(suppositions) {
|
|
|
131
117
|
return suppositionsString;
|
|
132
118
|
}
|
|
133
119
|
|
|
134
|
-
export function substitutionsStringFromSubstitutions(substitutions) {
|
|
135
|
-
const substitutionsString = substitutions.reduce((substitutionsString, substitution) => {
|
|
136
|
-
const substitutionString = substitution.getString();
|
|
137
|
-
|
|
138
|
-
substitutionsString = (substitutionsString === null) ?
|
|
139
|
-
substitutionString : ///
|
|
140
|
-
`${substitutionsString}, ${substitutionString}`;
|
|
141
|
-
|
|
142
|
-
return substitutionsString;
|
|
143
|
-
}, null);
|
|
144
|
-
|
|
145
|
-
return substitutionsString;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
120
|
export function signatureStringFromTerms(terms) {
|
|
149
121
|
const termsString = termsStringFromTerms(terms),
|
|
150
122
|
signatureString = `[${termsString}]`;
|
|
@@ -154,11 +126,17 @@ export function signatureStringFromTerms(terms) {
|
|
|
154
126
|
|
|
155
127
|
export function equivalenceStringFromTerms(terms) {
|
|
156
128
|
const termsString = termsStringFromTerms(terms),
|
|
157
|
-
equivalenceString = termsString
|
|
129
|
+
equivalenceString = `[${termsString}]`;
|
|
158
130
|
|
|
159
131
|
return equivalenceString;
|
|
160
132
|
}
|
|
161
133
|
|
|
134
|
+
export function typeStringFromNominalTypeName(nominalTypeName) {
|
|
135
|
+
const typeString = nominalTypeName; ///
|
|
136
|
+
|
|
137
|
+
return typeString;
|
|
138
|
+
}
|
|
139
|
+
|
|
162
140
|
export function termSubstitutionStringFromTermAndVariable(term, variable) {
|
|
163
141
|
const termString = term.getString(),
|
|
164
142
|
variableString = variable.getString(),
|
|
@@ -13,17 +13,13 @@ export function termFromTermAndSubstitutions(term, generalContext, specificConte
|
|
|
13
13
|
|
|
14
14
|
if (termSingular) {
|
|
15
15
|
const variableIdentifier = termNode.getVariableIdentifier(),
|
|
16
|
-
|
|
16
|
+
substitution = specificContext.findSubstitutionByVariableIdentifier(variableIdentifier);
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
18
|
+
if (substitution !== null) {
|
|
19
|
+
const termSubstitution = substitution, ///
|
|
20
|
+
replacementTerm = termSubstitution.getReplacementTerm();
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
const termSubstitution = substitution, ///
|
|
23
|
-
replacementTerm = termSubstitution.getReplacementTerm();
|
|
24
|
-
|
|
25
|
-
term = replacementTerm; ///
|
|
26
|
-
}
|
|
22
|
+
term = replacementTerm; ///
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
}
|
|
@@ -40,17 +36,13 @@ export function frameFromFrameAndSubstitutions(frame, generalContext, specificCo
|
|
|
40
36
|
|
|
41
37
|
if (frameSingular) {
|
|
42
38
|
const metavariableName = frameNode.getMetavariableName(),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (metavariable !== null) {
|
|
46
|
-
const substitution = specificContext.findSubstitutionByMetavariableName(metavariableName);
|
|
39
|
+
substitution = specificContext.findSubstitutionByMetavariableName(metavariableName);
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
if (substitution !== null) {
|
|
42
|
+
const frameSubstitution = substitution, ///
|
|
43
|
+
replacementFrame = frameSubstitution.getReplacementFrame();
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
}
|
|
45
|
+
frame = replacementFrame; ///
|
|
54
46
|
}
|
|
55
47
|
}
|
|
56
48
|
}
|
|
@@ -86,20 +78,17 @@ export function statementFromStatementAndSubstitutions(statement, generalContext
|
|
|
86
78
|
specificContext = context; ///
|
|
87
79
|
}
|
|
88
80
|
|
|
89
|
-
const metavariableName = statementNode.getMetavariableName()
|
|
90
|
-
metavariable = generalContext.findMetavariableByMetavariableName(metavariableName);
|
|
81
|
+
const metavariableName = statementNode.getMetavariableName();
|
|
91
82
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
specificContext.
|
|
95
|
-
specificContext.findSubstitutionByMetavariableName(metavariableName);
|
|
83
|
+
substitution = (substitution !== null) ?
|
|
84
|
+
specificContext.findSubstitutionByMetavariableNameAndSubstitution(metavariableName, substitution) :
|
|
85
|
+
specificContext.findSubstitutionByMetavariableName(metavariableName);
|
|
96
86
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
if (substitution !== null) {
|
|
88
|
+
const statementSubstitution = substitution, ///
|
|
89
|
+
replacementStatement = statementSubstitution.getReplacementStatement();
|
|
100
90
|
|
|
101
|
-
|
|
102
|
-
}
|
|
91
|
+
statement = replacementStatement; ///
|
|
103
92
|
}
|
|
104
93
|
}
|
|
105
94
|
}
|
|
@@ -31,9 +31,9 @@ function validateTermAsVariable(term, context, validateForwards) {
|
|
|
31
31
|
|
|
32
32
|
term.setType(type);
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const validatesForwards = validateForwards();
|
|
35
35
|
|
|
36
|
-
if (
|
|
36
|
+
if (validatesForwards) {
|
|
37
37
|
termValidatesAsVariable = true;
|
|
38
38
|
}
|
|
39
39
|
}
|