occam-verify-cli 1.0.457 → 1.0.473
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/constants.js +13 -1
- package/lib/context/ephemeral.js +270 -0
- package/lib/context/file.js +102 -66
- package/lib/context/liminal.js +120 -0
- package/lib/context/literal.js +92 -0
- package/lib/context/nominal.js +15 -1
- package/lib/context/release.js +66 -7
- package/lib/context/scoped.js +48 -40
- package/lib/context/synthetic.js +133 -0
- package/lib/element/assertion/contained.js +66 -66
- package/lib/element/assertion/defined.js +32 -32
- package/lib/element/assertion/property.js +39 -39
- package/lib/element/assertion/satisfies.js +22 -22
- package/lib/element/assumption.js +5 -8
- package/lib/element/conclusion.js +14 -13
- package/lib/element/constructor.js +2 -2
- package/lib/element/deduction.js +14 -13
- package/lib/element/derivation.js +3 -3
- package/lib/element/equality.js +5 -5
- package/lib/element/equivalence.js +112 -107
- package/lib/element/equivalences.js +24 -10
- package/lib/element/error.js +3 -3
- package/lib/element/frame.js +38 -21
- package/lib/element/hypothesis.js +2 -2
- package/lib/element/judgement.js +6 -5
- package/lib/element/metaType.js +1 -2
- package/lib/element/metavariable.js +46 -35
- package/lib/element/parameter.js +13 -5
- package/lib/element/procedureCall.js +16 -16
- package/lib/element/proof.js +14 -13
- package/lib/element/proofAssertion/premise.js +41 -30
- package/lib/element/proofAssertion/step.js +39 -35
- package/lib/element/proofAssertion/supposition.js +43 -32
- package/lib/element/proofAssertion.js +19 -5
- package/lib/element/propertyRelation.js +2 -2
- package/lib/element/reference.js +50 -9
- package/lib/element/rule.js +26 -28
- package/lib/element/section.js +2 -2
- package/lib/element/signature.js +9 -6
- package/lib/element/statement.js +44 -31
- package/lib/element/subproof.js +18 -17
- package/lib/element/substitution/frame.js +83 -46
- package/lib/element/substitution/reference.js +101 -19
- package/lib/element/substitution/statement.js +122 -75
- package/lib/element/substitution/term.js +93 -57
- package/lib/element/substitution.js +20 -69
- package/lib/element/substitutions.js +49 -34
- package/lib/element/term.js +30 -21
- package/lib/element/topLevelAssertion/axiom.js +8 -6
- package/lib/element/topLevelAssertion/conjecture.js +4 -4
- package/lib/element/topLevelAssertion/lemma.js +4 -4
- package/lib/element/topLevelAssertion/theorem.js +2 -2
- package/lib/element/topLevelAssertion.js +30 -23
- package/lib/element/topLevelMetaAssertion/metaLemma.js +2 -2
- package/lib/element/topLevelMetaAssertion/metatheorem.js +2 -2
- package/lib/element/topLevelMetaAssertion.js +16 -12
- package/lib/element/variable.js +30 -22
- package/lib/index.js +3 -3
- package/lib/main.js +3 -3
- package/lib/node/frame.js +2 -2
- package/lib/node/metavariable.js +4 -4
- package/lib/node/parameter.js +28 -7
- package/lib/node/substitution/frame.js +9 -31
- package/lib/node/substitution/reference.js +137 -0
- package/lib/node/substitution/statement.js +9 -31
- package/lib/node/substitution/term.js +9 -23
- package/lib/nonTerminalNodeMap.js +3 -2
- package/lib/process/instantiate.js +2 -14
- package/lib/process/unify.js +5 -5
- package/lib/tokenTypes.js +22 -0
- package/lib/utilities/context.js +54 -19
- package/lib/utilities/element.js +161 -336
- package/lib/utilities/instance.js +4 -4
- package/lib/utilities/string.js +18 -4
- package/lib/utilities/unification.js +24 -18
- package/lib/utilities/validation.js +31 -31
- package/package.json +2 -2
- package/src/constants.js +12 -0
- package/src/context/{transient.js → ephemeral.js} +15 -112
- package/src/context/file.js +66 -67
- package/src/context/liminal.js +67 -0
- package/src/context/{fragment.js → literal.js} +17 -4
- package/src/context/nominal.js +12 -0
- package/src/context/release.js +44 -6
- package/src/context/scoped.js +41 -31
- package/src/context/synthetic.js +60 -0
- package/src/element/assertion/contained.js +49 -47
- package/src/element/assertion/defined.js +29 -27
- package/src/element/assertion/property.js +35 -35
- package/src/element/assertion/satisfies.js +19 -18
- package/src/element/assumption.js +4 -10
- package/src/element/conclusion.js +16 -19
- package/src/element/constructor.js +1 -1
- package/src/element/deduction.js +16 -21
- package/src/element/derivation.js +2 -2
- package/src/element/equality.js +4 -4
- package/src/element/equivalence.js +115 -135
- package/src/element/equivalences.js +9 -7
- package/src/element/error.js +4 -2
- package/src/element/frame.js +50 -23
- package/src/element/hypothesis.js +1 -1
- package/src/element/judgement.js +9 -4
- package/src/element/metaType.js +0 -1
- package/src/element/metavariable.js +54 -53
- package/src/element/parameter.js +10 -5
- package/src/element/procedureCall.js +20 -18
- package/src/element/proof.js +14 -16
- package/src/element/proofAssertion/premise.js +46 -42
- package/src/element/proofAssertion/step.js +45 -40
- package/src/element/proofAssertion/supposition.js +56 -45
- package/src/element/proofAssertion.js +23 -5
- package/src/element/propertyRelation.js +1 -1
- package/src/element/reference.js +64 -16
- package/src/element/rule.js +31 -37
- package/src/element/section.js +1 -1
- package/src/element/signature.js +8 -8
- package/src/element/statement.js +51 -40
- package/src/element/subproof.js +16 -18
- package/src/element/substitution/frame.js +99 -42
- package/src/element/substitution/reference.js +120 -20
- package/src/element/substitution/statement.js +160 -89
- package/src/element/substitution/term.js +104 -63
- package/src/element/substitution.js +16 -58
- package/src/element/substitutions.js +43 -41
- package/src/element/term.js +37 -32
- package/src/element/topLevelAssertion/axiom.js +8 -6
- package/src/element/topLevelAssertion/conjecture.js +1 -2
- package/src/element/topLevelAssertion/lemma.js +2 -3
- package/src/element/topLevelAssertion/theorem.js +1 -1
- package/src/element/topLevelAssertion.js +31 -27
- package/src/element/topLevelMetaAssertion/metaLemma.js +1 -2
- package/src/element/topLevelMetaAssertion/metatheorem.js +1 -2
- package/src/element/topLevelMetaAssertion.js +15 -13
- package/src/element/variable.js +30 -31
- package/src/index.js +2 -1
- package/src/main.js +2 -1
- package/src/node/frame.js +1 -1
- package/src/node/metavariable.js +3 -3
- package/src/node/parameter.js +32 -5
- package/src/node/substitution/frame.js +6 -32
- package/src/node/substitution/reference.js +38 -0
- package/src/node/substitution/statement.js +6 -32
- package/src/node/substitution/term.js +6 -22
- package/src/nonTerminalNodeMap.js +3 -0
- package/src/process/instantiate.js +0 -8
- package/src/process/unify.js +4 -4
- package/src/tokenTypes.js +4 -0
- package/src/utilities/context.js +43 -17
- package/src/utilities/element.js +187 -401
- package/src/utilities/instance.js +3 -3
- package/src/utilities/string.js +21 -5
- package/src/utilities/unification.js +26 -23
- package/src/utilities/validation.js +47 -47
- package/lib/context/fragment.js +0 -77
- package/lib/context/transient.js +0 -371
- package/lib/log.js +0 -150
- package/lib/utilities/fragment.js +0 -23
- package/lib/utilities/node.js +0 -71
- package/src/log.js +0 -118
- package/src/utilities/fragment.js +0 -11
- package/src/utilities/node.js +0 -85
package/src/element/frame.js
CHANGED
|
@@ -7,6 +7,7 @@ import elements from "../elements";
|
|
|
7
7
|
|
|
8
8
|
import { define } from "../elements";
|
|
9
9
|
import { FRAME_META_TYPE_NAME } from "../metaTypeNames";
|
|
10
|
+
import { assumptionsStringFromAssumptions } from "../utilities/string";
|
|
10
11
|
|
|
11
12
|
const { first } = arrayUtilities;
|
|
12
13
|
|
|
@@ -52,18 +53,18 @@ export default define(class Frame extends Element {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
getMetavariableName() {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const singular = this.isSingular();
|
|
58
|
-
|
|
59
|
-
if (singular) {
|
|
60
|
-
metavariableName = this.node.getMetavariableName();
|
|
61
|
-
}
|
|
56
|
+
const node = this.getNode(),
|
|
57
|
+
metavariableName = node.getMetavariableName();
|
|
62
58
|
|
|
63
59
|
return metavariableName;
|
|
64
60
|
}
|
|
65
61
|
|
|
66
|
-
isSingular() {
|
|
62
|
+
isSingular() {
|
|
63
|
+
const node = this.getNode(),
|
|
64
|
+
singular = node.isSingular();
|
|
65
|
+
|
|
66
|
+
return singular;
|
|
67
|
+
}
|
|
67
68
|
|
|
68
69
|
isMetavariableEqualToMetavariable(metavariable, context) {
|
|
69
70
|
let metavariableEqualToMetavariable;
|
|
@@ -71,8 +72,9 @@ export default define(class Frame extends Element {
|
|
|
71
72
|
const singular = this.isSingular();
|
|
72
73
|
|
|
73
74
|
if (singular) {
|
|
74
|
-
const
|
|
75
|
-
|
|
75
|
+
const node = this.getNode(),
|
|
76
|
+
metavariableA = metavariable, ///
|
|
77
|
+
singularMetavariableNode = node.getSingularMetavariableNode(),
|
|
76
78
|
metavariableName = singularMetavariableNode.getMetavariableName();
|
|
77
79
|
|
|
78
80
|
metavariable = context.findMetavariableByMetavariableName(metavariableName)
|
|
@@ -86,6 +88,26 @@ export default define(class Frame extends Element {
|
|
|
86
88
|
return metavariableEqualToMetavariable;
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
compareParameter(parameter) {
|
|
92
|
+
let comparesToParamter = false;
|
|
93
|
+
|
|
94
|
+
const singular = this.isSingular();
|
|
95
|
+
|
|
96
|
+
if (singular) {
|
|
97
|
+
const parameterName = parameter.getName();
|
|
98
|
+
|
|
99
|
+
if (parameterName !== null) {
|
|
100
|
+
const metavariableName = this.getMetavariableName();
|
|
101
|
+
|
|
102
|
+
if (parameterName === metavariableName) {
|
|
103
|
+
comparesToParamter = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return comparesToParamter;
|
|
109
|
+
}
|
|
110
|
+
|
|
89
111
|
compareSubstitution(substitution, context) {
|
|
90
112
|
let comparesToSubstitution = false;
|
|
91
113
|
|
|
@@ -178,10 +200,10 @@ export default define(class Frame extends Element {
|
|
|
178
200
|
|
|
179
201
|
const singular = this.isSingular();
|
|
180
202
|
|
|
181
|
-
if (
|
|
182
|
-
context.trace(`The '${frameString}' stated frame must be singular.`);
|
|
183
|
-
} else {
|
|
203
|
+
if (singular) {
|
|
184
204
|
validatesWhenStated = true;
|
|
205
|
+
} else {
|
|
206
|
+
context.trace(`The '${frameString}' stated frame must be singular.`);
|
|
185
207
|
}
|
|
186
208
|
|
|
187
209
|
if (validatesWhenStated) {
|
|
@@ -208,20 +230,25 @@ export default define(class Frame extends Element {
|
|
|
208
230
|
}
|
|
209
231
|
|
|
210
232
|
validateAssumptions(assignments, stated, context) {
|
|
211
|
-
let assumptionsValidate
|
|
233
|
+
let assumptionsValidate;
|
|
212
234
|
|
|
213
|
-
const
|
|
235
|
+
const frameString = this.getString(), ///
|
|
236
|
+
assumptionsString = assumptionsStringFromAssumptions(this.assumptions);
|
|
214
237
|
|
|
215
|
-
|
|
216
|
-
stated = true; ///
|
|
238
|
+
context.trace(`Validating the '${assumptionsString}' assumptions of the '${frameString}' frame...`);
|
|
217
239
|
|
|
218
|
-
|
|
240
|
+
stated = true; ///
|
|
219
241
|
|
|
220
|
-
|
|
221
|
-
const assumptionVerifies = assumption.validate(assignments, stated, context);
|
|
242
|
+
assignments = null; ///
|
|
222
243
|
|
|
223
|
-
|
|
224
|
-
|
|
244
|
+
assumptionsValidate = this.assumptions.every((assumption) => {
|
|
245
|
+
const assumptionVerifies = assumption.validate(assignments, stated, context);
|
|
246
|
+
|
|
247
|
+
return assumptionVerifies;
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
if (assumptionsValidate) {
|
|
251
|
+
context.debug(`...validated the '${assumptionsString}' assumptions of the '${frameString}' frame.`);
|
|
225
252
|
}
|
|
226
253
|
|
|
227
254
|
return assumptionsValidate;
|
|
@@ -233,7 +260,7 @@ export default define(class Frame extends Element {
|
|
|
233
260
|
const frameString = this.getString(), ///
|
|
234
261
|
metaTypeString = metaType.getString();
|
|
235
262
|
|
|
236
|
-
context.trace(`
|
|
263
|
+
context.trace(`Validating the '${frameString}' frame given the '${metaTypeString}' meta-type...`);
|
|
237
264
|
|
|
238
265
|
const metaTypeName = metaType.getName();
|
|
239
266
|
|
|
@@ -20,7 +20,7 @@ export default define(class Hypothesis extends Element {
|
|
|
20
20
|
verify(context) {
|
|
21
21
|
let verifies = false;
|
|
22
22
|
|
|
23
|
-
const hypothesisString = this.
|
|
23
|
+
const hypothesisString = this.getString(); ///
|
|
24
24
|
|
|
25
25
|
context.trace(`Verifying the '${hypothesisString}' hypothesis...`, this.node);
|
|
26
26
|
|
package/src/element/judgement.js
CHANGED
|
@@ -22,14 +22,19 @@ export default define(class Judgement extends Element {
|
|
|
22
22
|
return this.assumption;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
isSingular() {
|
|
25
|
+
isSingular() {
|
|
26
|
+
const node = this.getNode(),
|
|
27
|
+
singular = node.isSingular();
|
|
28
|
+
|
|
29
|
+
return singular;
|
|
30
|
+
}
|
|
26
31
|
|
|
27
32
|
getMetavariable() { return this.frame.getMetavariable(); }
|
|
28
33
|
|
|
29
34
|
validate(assignments, stated, context) {
|
|
30
35
|
let validates = false;
|
|
31
36
|
|
|
32
|
-
const judgementString = this.
|
|
37
|
+
const judgementString = this.getString(); ///
|
|
33
38
|
|
|
34
39
|
context.trace(`Validating the '${judgementString}' judgement...`);
|
|
35
40
|
|
|
@@ -70,7 +75,7 @@ export default define(class Judgement extends Element {
|
|
|
70
75
|
validateWhenStated(assignments, context) {
|
|
71
76
|
let validatesWhenStated;
|
|
72
77
|
|
|
73
|
-
const judgementString = this.
|
|
78
|
+
const judgementString = this.getString(); ///
|
|
74
79
|
|
|
75
80
|
context.trace(`Validating the '${judgementString}' stated judgement...`);
|
|
76
81
|
|
|
@@ -86,7 +91,7 @@ export default define(class Judgement extends Element {
|
|
|
86
91
|
validateWhenDerived(context) {
|
|
87
92
|
let validatesWhenDerived = false;
|
|
88
93
|
|
|
89
|
-
const judgementString = this.
|
|
94
|
+
const judgementString = this.getString(); ///
|
|
90
95
|
|
|
91
96
|
context.trace(`Validating the '${judgementString}' derived judgement...`);
|
|
92
97
|
|
package/src/element/metaType.js
CHANGED
|
@@ -5,9 +5,9 @@ import elements from "../elements";
|
|
|
5
5
|
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
import { EMPTY_STRING } from "../constants";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { synthetically } from "../utilities/context";
|
|
9
|
+
import { typeToTypeJSON } from "../utilities/json";
|
|
10
|
+
import { metaTypeToMetaTypeJSON } from "../utilities/json";
|
|
11
11
|
import { unifyMetavariable, unifyMetavariableIntrinsically } from "../process/unify";
|
|
12
12
|
|
|
13
13
|
export default define(class Metavariable extends Element {
|
|
@@ -45,6 +45,8 @@ export default define(class Metavariable extends Element {
|
|
|
45
45
|
return nameEqualTo;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
49
|
+
|
|
48
50
|
compareMetavariableName(metavariableName) {
|
|
49
51
|
const nameMetavariableName = (this.name === metavariableName),
|
|
50
52
|
comparesToMetavariableName = nameMetavariableName; ///
|
|
@@ -52,8 +54,6 @@ export default define(class Metavariable extends Element {
|
|
|
52
54
|
return comparesToMetavariableName;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
isMetaTypeEqualTo(metaType) { return this.metaType.isEqualTo(metaType); }
|
|
56
|
-
|
|
57
57
|
validate(context) {
|
|
58
58
|
let validates = false;
|
|
59
59
|
|
|
@@ -105,10 +105,11 @@ export default define(class Metavariable extends Element {
|
|
|
105
105
|
unifyFrame(frame, substitutions, generalContext, specificContext) {
|
|
106
106
|
let frameUnifies = false;
|
|
107
107
|
|
|
108
|
-
const
|
|
108
|
+
const context = specificContext, ///
|
|
109
|
+
frameString = frame.getString(),
|
|
109
110
|
metavariableString = this.getString(); ///
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
context.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
112
113
|
|
|
113
114
|
const frameMetavariableUnifies = this.unifyFrameMetavariable(frame, substitutions, generalContext, specificContext);
|
|
114
115
|
|
|
@@ -127,20 +128,20 @@ export default define(class Metavariable extends Element {
|
|
|
127
128
|
frameUnifies = true;
|
|
128
129
|
}
|
|
129
130
|
} else {
|
|
130
|
-
const
|
|
131
|
-
context = specificContext, ///
|
|
132
|
-
metavariable = this, ///
|
|
133
|
-
frameSubstitution = FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, context),
|
|
134
|
-
substitution = frameSubstitution; ///
|
|
131
|
+
const metavariable = this; ///
|
|
135
132
|
|
|
136
|
-
|
|
133
|
+
synthetically((context) => {
|
|
134
|
+
const { FrameSubstitution } = elements;
|
|
135
|
+
|
|
136
|
+
FrameSubstitution.fromFrameAndMetavariable(frame, metavariable, context);
|
|
137
|
+
}, generalContext, specificContext);
|
|
137
138
|
|
|
138
139
|
frameUnifies = true;
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
if (frameUnifies) {
|
|
143
|
-
|
|
144
|
+
context.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
return frameUnifies;
|
|
@@ -149,13 +150,14 @@ export default define(class Metavariable extends Element {
|
|
|
149
150
|
unifyStatement(statement, substitution, substitutions, generalContext, specificContext) {
|
|
150
151
|
let statementUnifies = false;
|
|
151
152
|
|
|
152
|
-
const
|
|
153
|
+
const context = specificContext, ///
|
|
154
|
+
statementString = statement.getString(),
|
|
153
155
|
metavariableString = this.getString(), ///
|
|
154
156
|
substitutionString = (substitution !== null) ?
|
|
155
157
|
substitution.getString() :
|
|
156
158
|
EMPTY_STRING;
|
|
157
159
|
|
|
158
|
-
|
|
160
|
+
context.trace(`Unifying the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable...`);
|
|
159
161
|
|
|
160
162
|
const statementMetavariableUnifies = this.unifyStatementMetavariable(statement, substitutions, generalContext, specificContext);
|
|
161
163
|
|
|
@@ -175,22 +177,23 @@ export default define(class Metavariable extends Element {
|
|
|
175
177
|
statementUnifies = true;
|
|
176
178
|
}
|
|
177
179
|
} else {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, context);
|
|
180
|
+
const metavariable = this; ///
|
|
181
|
+
|
|
182
|
+
synthetically((context) => {
|
|
183
|
+
const { StatementSubstitution } = elements;
|
|
183
184
|
|
|
184
|
-
|
|
185
|
+
(substitution !== null) ?
|
|
186
|
+
StatementSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, context) :
|
|
187
|
+
StatementSubstitution.fromStatementAndMetavariable(statement, metavariable, context);
|
|
185
188
|
|
|
186
|
-
|
|
189
|
+
}, generalContext, specificContext);
|
|
187
190
|
|
|
188
191
|
statementUnifies = true;
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
if (statementUnifies) {
|
|
193
|
-
|
|
196
|
+
context.debug(`...unified the '${statementString}' statement with the '${metavariableString}${substitutionString}' metavariable.`);
|
|
194
197
|
}
|
|
195
198
|
|
|
196
199
|
return statementUnifies;
|
|
@@ -199,42 +202,43 @@ export default define(class Metavariable extends Element {
|
|
|
199
202
|
unifyReference(reference, substitutions, generalContext, specificContext) {
|
|
200
203
|
let referenceUnifies = false;
|
|
201
204
|
|
|
202
|
-
const
|
|
205
|
+
const context = specificContext, ///
|
|
206
|
+
referenceString = reference.getString(),
|
|
203
207
|
metavariableString = this.getString(); ///
|
|
204
208
|
|
|
205
|
-
|
|
209
|
+
context.trace(`Unifying the '${referenceString}' reference with the '${metavariableString}' metavariable...`);
|
|
206
210
|
|
|
207
211
|
const referenceMetavariableUnifies = this.unifyReferenceMetavariable(reference, substitutions, generalContext, specificContext);
|
|
208
212
|
|
|
209
213
|
if (referenceMetavariableUnifies) {
|
|
210
214
|
referenceUnifies = true;
|
|
211
215
|
} else {
|
|
212
|
-
const
|
|
213
|
-
metavariable = this, ///
|
|
216
|
+
const metavariable = this, ///
|
|
214
217
|
simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariable(metavariable);
|
|
215
218
|
|
|
216
219
|
if (simpleSubstitutionPresent) {
|
|
217
220
|
const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariable(metavariable), ///
|
|
218
221
|
substitution = simpleSubstitution, ///
|
|
219
|
-
substitutionReferenceEqualToReference = substitution.isReferenceEqualToReference(reference
|
|
222
|
+
substitutionReferenceEqualToReference = substitution.isReferenceEqualToReference(reference);
|
|
220
223
|
|
|
221
224
|
if (substitutionReferenceEqualToReference) {
|
|
222
225
|
referenceUnifies = true;
|
|
223
226
|
}
|
|
224
227
|
} else {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
228
|
+
const metavariable = this; ///
|
|
229
|
+
|
|
230
|
+
synthetically((context) => {
|
|
231
|
+
const { ReferenceSubstitution } = elements;
|
|
229
232
|
|
|
230
|
-
|
|
233
|
+
ReferenceSubstitution.fromReferenceAndMetavariable(reference, metavariable, context);
|
|
234
|
+
}, generalContext, specificContext);
|
|
231
235
|
|
|
232
236
|
referenceUnifies = true;
|
|
233
237
|
}
|
|
234
238
|
}
|
|
235
239
|
|
|
236
240
|
if (referenceUnifies) {
|
|
237
|
-
|
|
241
|
+
context.debug(`...unified the '${referenceString}' reference with the '${metavariableString}' metavariable.`);
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
return referenceUnifies;
|
|
@@ -243,19 +247,25 @@ export default define(class Metavariable extends Element {
|
|
|
243
247
|
unifyMetavariable(metavariable, context) {
|
|
244
248
|
let metavariableUnifies;
|
|
245
249
|
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
250
|
+
const specificContext = context; ///
|
|
251
|
+
|
|
252
|
+
context = this.getContext();
|
|
253
|
+
|
|
254
|
+
const generalContext = context; ///
|
|
255
|
+
|
|
256
|
+
context = specificContext; ///
|
|
257
|
+
|
|
258
|
+
const generalMetavariable = this, ///
|
|
249
259
|
specificMetavariable = metavariable, ///
|
|
250
260
|
generalMetavariableString = generalMetavariable.getString(),
|
|
251
261
|
specificMetavariableString = specificMetavariable.getString();
|
|
252
262
|
|
|
253
|
-
|
|
263
|
+
context.trace(`Unifying the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable...`);
|
|
254
264
|
|
|
255
265
|
metavariableUnifies = unifyMetavariable(generalMetavariable, specificMetavariable, generalContext, specificContext);
|
|
256
266
|
|
|
257
267
|
if (metavariableUnifies) {
|
|
258
|
-
|
|
268
|
+
context.debug(`...unified the '${specificMetavariableString}' metavariable with the '${generalMetavariableString}' metavariable.`);
|
|
259
269
|
}
|
|
260
270
|
|
|
261
271
|
return metavariableUnifies;
|
|
@@ -269,8 +279,8 @@ export default define(class Metavariable extends Element {
|
|
|
269
279
|
specificContextFilePath = specificContext.getFilePath();
|
|
270
280
|
|
|
271
281
|
if (generalContextFilePath === specificContextFilePath) {
|
|
272
|
-
const metavariable = this,
|
|
273
|
-
metavariableString =
|
|
282
|
+
const metavariable = this, ///
|
|
283
|
+
metavariableString = metavariable.getString(),
|
|
274
284
|
frameMetavariableEqualToMetvariable = frame.isMetavariableEqualToMetavariable(metavariable, context);
|
|
275
285
|
|
|
276
286
|
if (frameMetavariableEqualToMetvariable) {
|
|
@@ -350,7 +360,7 @@ export default define(class Metavariable extends Element {
|
|
|
350
360
|
|
|
351
361
|
if (generalContextFilePath === specificContextFilePath) {
|
|
352
362
|
const metavariable = this, ///
|
|
353
|
-
metavariableString =
|
|
363
|
+
metavariableString = metavariable.getString(),
|
|
354
364
|
referenceMetavariableEqualToMetvariable = reference.isMetavariableEqualToMetavariable(metavariable);
|
|
355
365
|
|
|
356
366
|
if (referenceMetavariableEqualToMetvariable) {
|
|
@@ -394,15 +404,6 @@ export default define(class Metavariable extends Element {
|
|
|
394
404
|
static name = "Metavariable";
|
|
395
405
|
|
|
396
406
|
static fromJSON(json, context) {
|
|
397
|
-
|
|
398
|
-
metavariableNode = instantiateMetavariable(string, context),
|
|
399
|
-
metavariableName = metavariableNode.getMetavariableName(),
|
|
400
|
-
name = metavariableName, ///
|
|
401
|
-
node = metavariableNode, ///
|
|
402
|
-
type = typeFromJSON(json, context),
|
|
403
|
-
metaType = metaTypeFromJSON(json, context),
|
|
404
|
-
metavariable = new Metavariable(context, string, node, name, type, metaType);
|
|
405
|
-
|
|
406
|
-
return metavariable;
|
|
407
|
+
///
|
|
407
408
|
}
|
|
408
409
|
});
|
package/src/element/parameter.js
CHANGED
|
@@ -5,16 +5,21 @@ import Element from "../element";
|
|
|
5
5
|
import { define } from "../elements";
|
|
6
6
|
|
|
7
7
|
export default define(class Parameter extends Element {
|
|
8
|
-
constructor(context, string, node, name) {
|
|
9
|
-
super(context, string, node);
|
|
8
|
+
constructor(context, string, node, name, identifier) {
|
|
9
|
+
super(context, string, node, identifier);
|
|
10
10
|
|
|
11
11
|
this.name = name;
|
|
12
|
+
this.identifier = identifier;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
getName() {
|
|
15
16
|
return this.name;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
getIdentifier() {
|
|
20
|
+
return this.identifier;
|
|
21
|
+
}
|
|
22
|
+
|
|
18
23
|
findReplacementNode(substitutions) {
|
|
19
24
|
let replacementNode = null;
|
|
20
25
|
|
|
@@ -25,7 +30,7 @@ export default define(class Parameter extends Element {
|
|
|
25
30
|
if (substitutionComparesToParamter) {
|
|
26
31
|
return true;
|
|
27
32
|
}
|
|
28
|
-
});
|
|
33
|
+
}) || null;
|
|
29
34
|
|
|
30
35
|
if (substitution !== null) {
|
|
31
36
|
replacementNode = substitution.getReplacementNode();
|
|
@@ -46,10 +51,10 @@ export default define(class Parameter extends Element {
|
|
|
46
51
|
static name = "Parameter";
|
|
47
52
|
|
|
48
53
|
static fromJSON(json, context) {
|
|
49
|
-
const { name } = json,
|
|
54
|
+
const { name, identifier } = json,
|
|
50
55
|
string = null,
|
|
51
56
|
node = null,
|
|
52
|
-
parameter = new Parameter(context, string, node, name);
|
|
57
|
+
parameter = new Parameter(context, string, node, name, identifier);
|
|
53
58
|
|
|
54
59
|
return parameter;
|
|
55
60
|
}
|
|
@@ -10,6 +10,7 @@ import { parametersFromJSON, procedureReferenceFromJSON, parametersToParametersJ
|
|
|
10
10
|
export default define(class ProcedureCall extends Element {
|
|
11
11
|
constructor(context, string, node, parameters, procedureReference) {
|
|
12
12
|
super(context, string, node);
|
|
13
|
+
|
|
13
14
|
this.parameters = parameters;
|
|
14
15
|
this.procedureReference = procedureReference;
|
|
15
16
|
}
|
|
@@ -24,23 +25,24 @@ export default define(class ProcedureCall extends Element {
|
|
|
24
25
|
|
|
25
26
|
getName() { return this.procedureReference.getName(); }
|
|
26
27
|
|
|
27
|
-
findNodes(
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
findNodes(context) {
|
|
29
|
+
const substitutions = context.getSubstitutions(),
|
|
30
|
+
nodes = this.parameters.map((parameter) => {
|
|
31
|
+
const replacementNode = parameter.findReplacementNode(substitutions),
|
|
32
|
+
node = replacementNode; ///
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
return node;
|
|
35
|
+
});
|
|
34
36
|
|
|
35
37
|
return nodes;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
let
|
|
40
|
+
validate(context) {
|
|
41
|
+
let validates = false;
|
|
40
42
|
|
|
41
|
-
const procedureCallString = this.
|
|
43
|
+
const procedureCallString = this.getString(); ///
|
|
42
44
|
|
|
43
|
-
context.trace(`
|
|
45
|
+
context.trace(`Validating the '${procedureCallString}' procedure call...`);
|
|
44
46
|
|
|
45
47
|
const name = this.getName(),
|
|
46
48
|
procedure = context.findProcedureByName(name);
|
|
@@ -49,30 +51,30 @@ export default define(class ProcedureCall extends Element {
|
|
|
49
51
|
const procedureBoolean = procedure.isBoolean();
|
|
50
52
|
|
|
51
53
|
if (procedureBoolean) {
|
|
52
|
-
|
|
54
|
+
validates = true;
|
|
53
55
|
} else {
|
|
54
|
-
context.trace(`The '${procedureCallString}' procedure is not boolean
|
|
56
|
+
context.trace(`The '${procedureCallString}' procedure is not boolean.`);
|
|
55
57
|
}
|
|
56
58
|
} else {
|
|
57
|
-
context.trace(`The '${procedureCallString}' procedure is not present
|
|
59
|
+
context.trace(`The '${procedureCallString}' procedure is not present.`);
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
if (
|
|
61
|
-
context.debug(`...
|
|
62
|
+
if (validates) {
|
|
63
|
+
context.debug(`...validated the '${procedureCallString}' procedure call.`);
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
return
|
|
66
|
+
return validates;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
unifyIndependently(substitutions, context) {
|
|
68
70
|
let unifiesIndependently = false;
|
|
69
71
|
|
|
70
|
-
const procedureCallString = this.
|
|
72
|
+
const procedureCallString = this.getString(); ///
|
|
71
73
|
|
|
72
74
|
context.trace(`Unifying the '${procedureCallString}' procedure call independently...`);
|
|
73
75
|
|
|
74
76
|
const name = this.getName(),
|
|
75
|
-
nodes = this.findNodes(
|
|
77
|
+
nodes = this.findNodes(context),
|
|
76
78
|
procedure = context.findProcedureByName(name),
|
|
77
79
|
expressions = Expressions.fromNodes(nodes, context);
|
|
78
80
|
|
package/src/element/proof.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Element from "../element";
|
|
4
|
-
import ScopedContext from "../context/scoped";
|
|
5
4
|
|
|
5
|
+
import { scope } from "../utilities/context";
|
|
6
6
|
import { define } from "../elements";
|
|
7
7
|
|
|
8
8
|
export default define(class Proof extends Element {
|
|
@@ -26,28 +26,26 @@ export default define(class Proof extends Element {
|
|
|
26
26
|
return statement;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
verify(
|
|
29
|
+
verify(conclusion, context) {
|
|
30
30
|
let verifies = false;
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
scope((context) => {
|
|
33
|
+
const derivationVerifies = this.derivation.verify(context);
|
|
33
34
|
|
|
34
|
-
|
|
35
|
+
if (derivationVerifies) {
|
|
36
|
+
const lastProofAssertion = context.getLastProofAssertion();
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
if (lastProofAssertion !== null) {
|
|
39
|
+
const statement = this.getStatement(),
|
|
40
|
+
conclusionStatement = conclusion.getStatement(),
|
|
41
|
+
conclusionStatementEqualToStatement = conclusionStatement.isEqualTo(statement);
|
|
37
42
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (lastProofAssertion !== null) {
|
|
42
|
-
const statement = this.getStatement(),
|
|
43
|
-
conclusionStatement = conclusion.getStatement(),
|
|
44
|
-
conclusionStatementEqualToStatement = conclusionStatement.isEqualTo(statement);
|
|
45
|
-
|
|
46
|
-
if (conclusionStatementEqualToStatement) {
|
|
47
|
-
verifies = true;
|
|
43
|
+
if (conclusionStatementEqualToStatement) {
|
|
44
|
+
verifies = true;
|
|
45
|
+
}
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
|
-
}
|
|
48
|
+
}, context);
|
|
51
49
|
|
|
52
50
|
return verifies;
|
|
53
51
|
}
|