occam-verify-cli 1.0.587 → 1.0.603
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 +74 -2
- package/lib/context/file/nominal.js +11 -9
- package/lib/context/liminal.js +161 -24
- package/lib/context/literal.js +8 -2
- package/lib/context/scoped.js +4 -28
- package/lib/context/synthetic.js +146 -0
- package/lib/context.js +170 -1
- package/lib/element/assertion/contained.js +21 -15
- package/lib/element/assertion/defined.js +45 -65
- package/lib/element/assertion/property.js +25 -19
- package/lib/element/assertion/satisfies.js +14 -8
- package/lib/element/assertion/subproof.js +12 -6
- package/lib/element/assertion.js +47 -1
- package/lib/element/assumption.js +12 -12
- package/lib/element/conclusion.js +2 -2
- package/lib/element/deduction.js +2 -2
- package/lib/element/frame.js +61 -29
- package/lib/element/judgement.js +7 -1
- package/lib/element/label.js +8 -8
- package/lib/element/metavariable.js +71 -59
- package/lib/element/procedureCall.js +24 -8
- package/lib/element/proof.js +43 -35
- package/lib/element/proofAssertion/premise.js +122 -97
- package/lib/element/proofAssertion/step.js +161 -115
- package/lib/element/proofAssertion/supposition.js +157 -118
- package/lib/element/proofAssertion.js +3 -3
- package/lib/element/reference.js +40 -7
- package/lib/element/rule.js +227 -95
- package/lib/element/signature.js +2 -1
- package/lib/element/statement.js +67 -34
- package/lib/element/substitution/frame.js +36 -16
- package/lib/element/substitution/reference.js +36 -16
- package/lib/element/substitution/statement.js +94 -55
- package/lib/element/substitution/term.js +36 -16
- package/lib/element/substitution.js +54 -17
- package/lib/element/substitutions.js +4 -276
- package/lib/element/term.js +60 -31
- package/lib/element/topLevelAssertion/axiom.js +13 -4
- package/lib/element/topLevelAssertion/conjecture.js +7 -2
- package/lib/element/topLevelAssertion/theorem.js +7 -2
- package/lib/element/topLevelAssertion.js +201 -134
- package/lib/element/topLevelMetaAssertion.js +310 -51
- package/lib/element/variable.js +15 -6
- package/lib/node/substitution/statement.js +33 -1
- package/lib/process/unify.js +6 -6
- package/lib/utilities/context.js +10 -25
- package/lib/utilities/element.js +34 -9
- package/lib/utilities/statement.js +1 -8
- package/lib/utilities/string.js +12 -1
- package/lib/utilities/substitutions.js +42 -16
- package/lib/utilities/unification.js +3 -1
- package/lib/utilities/validation.js +2 -2
- package/package.json +4 -4
- package/src/context/ephemeral.js +73 -1
- package/src/context/file/nominal.js +14 -11
- package/src/context/liminal.js +180 -25
- package/src/context/literal.js +3 -1
- package/src/context/scoped.js +3 -35
- package/src/context/synthetic.js +49 -0
- package/src/context.js +163 -1
- package/src/element/assertion/contained.js +28 -20
- package/src/element/assertion/defined.js +62 -34
- package/src/element/assertion/property.js +27 -19
- package/src/element/assertion/satisfies.js +15 -7
- package/src/element/assertion/subproof.js +13 -5
- package/src/element/assertion.js +35 -0
- package/src/element/assumption.js +5 -5
- package/src/element/conclusion.js +2 -4
- package/src/element/deduction.js +2 -4
- package/src/element/frame.js +71 -39
- package/src/element/judgement.js +2 -0
- package/src/element/label.js +4 -4
- package/src/element/metavariable.js +94 -75
- package/src/element/procedureCall.js +6 -6
- package/src/element/proof.js +6 -6
- package/src/element/proofAssertion/premise.js +101 -69
- package/src/element/proofAssertion/step.js +78 -39
- package/src/element/proofAssertion/supposition.js +141 -115
- package/src/element/proofAssertion.js +3 -2
- package/src/element/reference.js +52 -10
- package/src/element/rule.js +138 -76
- package/src/element/signature.js +2 -0
- package/src/element/statement.js +76 -45
- package/src/element/substitution/frame.js +44 -15
- package/src/element/substitution/reference.js +44 -15
- package/src/element/substitution/statement.js +124 -72
- package/src/element/substitution/term.js +43 -15
- package/src/element/substitution.js +55 -18
- package/src/element/substitutions.js +1 -258
- package/src/element/term.js +65 -34
- package/src/element/topLevelAssertion/axiom.js +1 -1
- package/src/element/topLevelAssertion/conjecture.js +1 -1
- package/src/element/topLevelAssertion/theorem.js +1 -1
- package/src/element/topLevelAssertion.js +128 -48
- package/src/element/topLevelMetaAssertion.js +86 -32
- package/src/element/variable.js +15 -5
- package/src/node/substitution/statement.js +33 -0
- package/src/process/unify.js +6 -8
- package/src/utilities/context.js +9 -8
- package/src/utilities/element.js +37 -10
- package/src/utilities/statement.js +0 -7
- package/src/utilities/string.js +14 -0
- package/src/utilities/substitutions.js +59 -17
- package/src/utilities/unification.js +4 -0
- package/src/utilities/validation.js +3 -1
package/src/element/rule.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import assignAssignments from "../process/assign";
|
|
7
|
+
|
|
7
8
|
import { define } from "../elements";
|
|
9
|
+
import { asyncScope } from "../utilities/context";
|
|
8
10
|
import { labelsFromJSON,
|
|
9
11
|
premisesFromJSON,
|
|
10
12
|
conclusionFromJSON,
|
|
@@ -13,7 +15,7 @@ import { labelsFromJSON,
|
|
|
13
15
|
conclusionToConclusionJSON } from "../utilities/json";
|
|
14
16
|
|
|
15
17
|
const { reverse, extract } = arrayUtilities,
|
|
16
|
-
{ asyncBackwardsEvery } = asynchronousUtilities;
|
|
18
|
+
{ asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
|
|
17
19
|
|
|
18
20
|
export default define(class Rule extends Element {
|
|
19
21
|
constructor(context, string, node, proof, labels, premises, conclusion) {
|
|
@@ -54,7 +56,14 @@ export default define(class Rule extends Element {
|
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
verifyLabels() {
|
|
57
|
-
|
|
59
|
+
let labelsVerify;
|
|
60
|
+
|
|
61
|
+
const context = this.getContext(),
|
|
62
|
+
ruleString = this.getString(); ///
|
|
63
|
+
|
|
64
|
+
context.trace(`Verifying the '${ruleString}' rule's labels...`);
|
|
65
|
+
|
|
66
|
+
labelsVerify = this.labels.every((label) => {
|
|
58
67
|
const nameOnly = true,
|
|
59
68
|
labelVerifies = label.verify(nameOnly);
|
|
60
69
|
|
|
@@ -63,67 +72,144 @@ export default define(class Rule extends Element {
|
|
|
63
72
|
}
|
|
64
73
|
});
|
|
65
74
|
|
|
75
|
+
if (labelsVerify) {
|
|
76
|
+
context.trace(`...verified the '${ruleString}' rule's labels.`);
|
|
77
|
+
}
|
|
78
|
+
|
|
66
79
|
return labelsVerify;
|
|
67
80
|
}
|
|
68
81
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const premiseVerifies = this.verifyPremise(premise, context);
|
|
82
|
+
unifyStatementWithConclusion(statement, context) {
|
|
83
|
+
let statementUnifiesWithConclusion = false;
|
|
72
84
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
85
|
+
const ruleString = this.getString(),
|
|
86
|
+
statementString = statement.getString(),
|
|
87
|
+
conclusionString = this.conclusion.getString();
|
|
77
88
|
|
|
78
|
-
|
|
79
|
-
}
|
|
89
|
+
context.trace(`Unifying the '${statementString}' statement with the '${ruleString}' rule's '${conclusionString}' conclusion...`);
|
|
80
90
|
|
|
81
|
-
|
|
82
|
-
|
|
91
|
+
const statementUnifies = this.conclusion.unifyStatement(statement, context);
|
|
92
|
+
|
|
93
|
+
if (statementUnifies) {
|
|
94
|
+
statementUnifiesWithConclusion = true;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (statementUnifiesWithConclusion) {
|
|
98
|
+
context.debug(`...unified the '${statementString}' statement with the '${ruleString}' rule's '${conclusionString}' conclusion.`);
|
|
99
|
+
}
|
|
83
100
|
|
|
84
|
-
return
|
|
101
|
+
return statementUnifiesWithConclusion;
|
|
85
102
|
}
|
|
86
103
|
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
async verify() {
|
|
105
|
+
let verifies = false;
|
|
89
106
|
|
|
90
|
-
|
|
107
|
+
const context = this.getContext();
|
|
108
|
+
|
|
109
|
+
await this.break(context);
|
|
110
|
+
|
|
111
|
+
const ruleString = this.getString(); ///
|
|
112
|
+
|
|
113
|
+
context.trace(`Verifying the '${ruleString}' rule...`);
|
|
114
|
+
|
|
115
|
+
await asyncScope(async (context) => {
|
|
116
|
+
const labelsVerify = this.verifyLabels();
|
|
117
|
+
|
|
118
|
+
if (labelsVerify) {
|
|
119
|
+
const premisesVerify = await this.verifyPremises(context);
|
|
120
|
+
|
|
121
|
+
if (premisesVerify) {
|
|
122
|
+
const conclusionVerifies = await this.verifyConclusion(context);
|
|
123
|
+
|
|
124
|
+
if (conclusionVerifies) {
|
|
125
|
+
const proofVerifies = await this.verifyProof(context);
|
|
126
|
+
|
|
127
|
+
if (proofVerifies) {
|
|
128
|
+
const rule = this; ///
|
|
129
|
+
|
|
130
|
+
context.addRule(rule);
|
|
131
|
+
|
|
132
|
+
verifies = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}, context);
|
|
138
|
+
|
|
139
|
+
if (verifies) {
|
|
140
|
+
context.debug(`...verified the '${ruleString}' rule.`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return verifies;
|
|
91
144
|
}
|
|
92
145
|
|
|
93
|
-
verifyProof(context) {
|
|
146
|
+
async verifyProof(context) {
|
|
94
147
|
let proofVerifies;
|
|
95
148
|
|
|
96
149
|
if (this.proof === null) {
|
|
97
150
|
proofVerifies = true;
|
|
98
151
|
} else {
|
|
99
|
-
const
|
|
152
|
+
const ruleString = this.getString(); ///
|
|
100
153
|
|
|
101
|
-
|
|
154
|
+
context.trace(`Verifying the '${ruleString}' rule's proof...`);
|
|
155
|
+
|
|
156
|
+
const statement = this.conclusion.getStatement();
|
|
157
|
+
|
|
158
|
+
proofVerifies = this.proof.verify(statement, context);
|
|
159
|
+
|
|
160
|
+
if (proofVerifies) {
|
|
161
|
+
context.debug(`...verified the '${ruleString}' rule's proof.`);
|
|
162
|
+
}
|
|
102
163
|
}
|
|
103
164
|
|
|
104
165
|
return proofVerifies;
|
|
105
166
|
}
|
|
106
167
|
|
|
107
|
-
|
|
108
|
-
let
|
|
168
|
+
async verifyPremises(context) {
|
|
169
|
+
let premisesVerify;
|
|
109
170
|
|
|
110
|
-
const ruleString = this.getString()
|
|
111
|
-
statementString = statement.getString(),
|
|
112
|
-
conclusionString = this.conclusion.getString();
|
|
171
|
+
const ruleString = this.getString(); ///
|
|
113
172
|
|
|
114
|
-
context.trace(`
|
|
173
|
+
context.trace(`Verifying the '${ruleString}' rule's premises...`);
|
|
115
174
|
|
|
116
|
-
|
|
175
|
+
premisesVerify = await asyncForwardsEvery(this.premises, async (premise) => {
|
|
176
|
+
const assignments = [],
|
|
177
|
+
premiseVerifies = await premise.verify(assignments, context)
|
|
117
178
|
|
|
118
|
-
|
|
119
|
-
|
|
179
|
+
if (premiseVerifies) {
|
|
180
|
+
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
181
|
+
|
|
182
|
+
if (assignmentsAssigned) {
|
|
183
|
+
const subproofOrProofAssertion = premise; ////
|
|
184
|
+
|
|
185
|
+
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
186
|
+
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
if (premisesVerify) {
|
|
193
|
+
context.debug(`...verified the '${ruleString}' rule's premises.`);
|
|
120
194
|
}
|
|
121
195
|
|
|
122
|
-
|
|
123
|
-
|
|
196
|
+
return premisesVerify;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async verifyConclusion(context) {
|
|
200
|
+
let conclusionVerifies;
|
|
201
|
+
|
|
202
|
+
const ruleString = this.getString(); ///
|
|
203
|
+
|
|
204
|
+
context.trace(`Verifying the '${ruleString}' rule's conclusion...`);
|
|
205
|
+
|
|
206
|
+
conclusionVerifies = await this.conclusion.verify(context);
|
|
207
|
+
|
|
208
|
+
if (conclusionVerifies) {
|
|
209
|
+
context.debug(`...verified the '${ruleString}' rule's conclusion.`);
|
|
124
210
|
}
|
|
125
211
|
|
|
126
|
-
return
|
|
212
|
+
return conclusionVerifies;
|
|
127
213
|
}
|
|
128
214
|
|
|
129
215
|
async unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions, context) {
|
|
@@ -135,7 +221,15 @@ export default define(class Rule extends Element {
|
|
|
135
221
|
const subproofOrProofAssertionsUnifiesWithPremises = await this.unifySubproofOrProofAssertionsWithPremises(subproofOrProofAssertions, context);
|
|
136
222
|
|
|
137
223
|
if (subproofOrProofAssertionsUnifiesWithPremises) {
|
|
138
|
-
const
|
|
224
|
+
const specificContext = context; ///
|
|
225
|
+
|
|
226
|
+
context = this.getContext();
|
|
227
|
+
|
|
228
|
+
const generalContext = context; ///
|
|
229
|
+
|
|
230
|
+
context = specificContext; ///
|
|
231
|
+
|
|
232
|
+
const substitutionsResolved = context.areSubstitutionsResolved(generalContext, specificContext);
|
|
139
233
|
|
|
140
234
|
if (substitutionsResolved) {
|
|
141
235
|
statementAndSubproofOrProofAssertionsUnify = true;
|
|
@@ -170,6 +264,16 @@ export default define(class Rule extends Element {
|
|
|
170
264
|
const subproofOrProofAssertionUnifies = premise.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
|
|
171
265
|
|
|
172
266
|
if (subproofOrProofAssertionUnifies) {
|
|
267
|
+
const specificContext = context; ///
|
|
268
|
+
|
|
269
|
+
context = this.getContext();
|
|
270
|
+
|
|
271
|
+
const generalContext = context; ///
|
|
272
|
+
|
|
273
|
+
context = specificContext; ///
|
|
274
|
+
|
|
275
|
+
context.resolveSubstitutions(generalContext, specificContext);
|
|
276
|
+
|
|
173
277
|
return true;
|
|
174
278
|
}
|
|
175
279
|
}) || null;
|
|
@@ -190,48 +294,6 @@ export default define(class Rule extends Element {
|
|
|
190
294
|
return subproofOrProofAssertionsUnifiesWithPremise;
|
|
191
295
|
}
|
|
192
296
|
|
|
193
|
-
async verify() {
|
|
194
|
-
let verifies = false;
|
|
195
|
-
|
|
196
|
-
const context = this.getContext();
|
|
197
|
-
|
|
198
|
-
await this.break(context);
|
|
199
|
-
|
|
200
|
-
const ruleString = this.getString(); ///
|
|
201
|
-
|
|
202
|
-
context.trace(`Verifying the '${ruleString}' rule...`);
|
|
203
|
-
|
|
204
|
-
scope((context) => {
|
|
205
|
-
const labelsVerify = this.verifyLabels();
|
|
206
|
-
|
|
207
|
-
if (labelsVerify) {
|
|
208
|
-
const premisesVerify = this.verifyPremises(context);
|
|
209
|
-
|
|
210
|
-
if (premisesVerify) {
|
|
211
|
-
const conclusionVerifies = this.verifyConclusion(context);
|
|
212
|
-
|
|
213
|
-
if (conclusionVerifies) {
|
|
214
|
-
const proofVerifies = this.verifyProof(context);
|
|
215
|
-
|
|
216
|
-
if (proofVerifies) {
|
|
217
|
-
verifies = true;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}, context);
|
|
223
|
-
|
|
224
|
-
if (verifies) {
|
|
225
|
-
const rule = this; ///
|
|
226
|
-
|
|
227
|
-
context.addRule(rule);
|
|
228
|
-
|
|
229
|
-
context.debug(`...verified the '${ruleString}' rule.`);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return verifies;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
297
|
toJSON() {
|
|
236
298
|
const labelsJSON = labelsToLabelsJSON(this.labels),
|
|
237
299
|
premisesJSON = premisesToPremisesJSON(this.premises),
|
package/src/element/signature.js
CHANGED
package/src/element/statement.js
CHANGED
|
@@ -30,16 +30,50 @@ export default define(class Statement extends Element {
|
|
|
30
30
|
return metavariableName;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
getStatementNode() {
|
|
34
|
+
const node = this.getNode(),
|
|
35
|
+
statementNode = node; ///
|
|
36
|
+
|
|
37
|
+
return statementNode;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
matchStatementNode(statementNode) {
|
|
41
|
+
const statementNodeA = statementNode; ///
|
|
42
|
+
|
|
43
|
+
statementNode = this.getStatementNode();
|
|
44
|
+
|
|
45
|
+
const statementNodeB = statementNode, ///
|
|
46
|
+
statementNodeAAMatchesStatementBNodeB = statementNodeA.match(statementNodeB),
|
|
47
|
+
equalTo = statementNodeAAMatchesStatementBNodeB; ///
|
|
48
|
+
|
|
49
|
+
return equalTo;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
isValid(context) {
|
|
53
|
+
const statementNode = this.getStatementNode(),
|
|
54
|
+
statementPresent = context.isStatementPresentByStatementNode(statementNode),
|
|
55
|
+
valid = statementPresent; ///
|
|
56
|
+
|
|
57
|
+
return valid;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
isEqualTo(statement) {
|
|
61
|
+
const statementNode = statement.getNode(),
|
|
62
|
+
statementNodeMatches = this.matchStatementNode(statementNode),
|
|
63
|
+
equalTo = statementNodeMatches; ///
|
|
64
|
+
|
|
65
|
+
return equalTo;
|
|
66
|
+
}
|
|
67
|
+
|
|
33
68
|
isTermContained(term, context) {
|
|
34
69
|
let termContained;
|
|
35
70
|
|
|
36
|
-
const
|
|
37
|
-
termString = term.getString(),
|
|
71
|
+
const termString = term.getString(),
|
|
38
72
|
statementString = this.getString(); ///
|
|
39
73
|
|
|
40
74
|
context.trace(`Is the '${termString}' term contained in the '${statementString}' statement...`);
|
|
41
75
|
|
|
42
|
-
const statementNode =
|
|
76
|
+
const statementNode = this.getStatementNode(),
|
|
43
77
|
statementNodeTermNodes = statementNode.getTermNodes();
|
|
44
78
|
|
|
45
79
|
termContained = statementNodeTermNodes.some((statementNodeTermNode) => { ///
|
|
@@ -65,8 +99,7 @@ export default define(class Statement extends Element {
|
|
|
65
99
|
|
|
66
100
|
context.trace(`Is the '${frameString}' frame contained in the '${statementString}' statement...`);
|
|
67
101
|
|
|
68
|
-
const
|
|
69
|
-
statementNode = node, ///
|
|
102
|
+
const statementNode = this.getStatementNode(),
|
|
70
103
|
statementNodeFrameNodes = statementNode.getFrameNodes();
|
|
71
104
|
|
|
72
105
|
frameContained = statementNodeFrameNodes.some((statementNodeFrameNode) => { ///
|
|
@@ -84,37 +117,29 @@ export default define(class Statement extends Element {
|
|
|
84
117
|
return frameContained;
|
|
85
118
|
}
|
|
86
119
|
|
|
87
|
-
|
|
88
|
-
let
|
|
120
|
+
compareMetavariable(metavariable) {
|
|
121
|
+
let metavaraibleComparseTo;
|
|
89
122
|
|
|
90
123
|
const singular = this.isSingular();
|
|
91
124
|
|
|
92
125
|
if (singular) {
|
|
93
|
-
|
|
94
|
-
metavariableA = metavariable, ///
|
|
95
|
-
singularMetavariableNode = node.getSingularMetavariableNode(),
|
|
96
|
-
metavariableName = singularMetavariableNode.getMetavariableName();
|
|
126
|
+
let metavariableName;
|
|
97
127
|
|
|
98
|
-
|
|
128
|
+
const statementNode = this.getStatementNode(),
|
|
129
|
+
singularMetavariableNode = statementNode.getSingularMetavariableNode();
|
|
99
130
|
|
|
100
|
-
|
|
101
|
-
equalTo = metavariableA.isEqualTo(metavariableB);
|
|
131
|
+
metavariableName = singularMetavariableNode.getMetavariableName();
|
|
102
132
|
|
|
103
|
-
|
|
104
|
-
}
|
|
133
|
+
const metavariableNameA = metavariableName ///
|
|
105
134
|
|
|
106
|
-
|
|
107
|
-
}
|
|
135
|
+
metavariableName = metavariable.getName();
|
|
108
136
|
|
|
109
|
-
|
|
110
|
-
const statementA = this, ///
|
|
111
|
-
statementB = statement, ///
|
|
112
|
-
statementANode = statementA.getNode(),
|
|
113
|
-
statementBNode = statementB.getNode(),
|
|
114
|
-
statementANodeMatchesStatementBNode = statementANode.match(statementBNode),
|
|
115
|
-
equalTo = statementANodeMatchesStatementBNode; ///
|
|
137
|
+
const metavariableNameB = metavariableName; ///
|
|
116
138
|
|
|
117
|
-
|
|
139
|
+
metavaraibleComparseTo = (metavariableNameA === metavariableNameB);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return metavaraibleComparseTo;
|
|
118
143
|
}
|
|
119
144
|
|
|
120
145
|
compareParameter(parameter) {
|
|
@@ -144,21 +169,29 @@ export default define(class Statement extends Element {
|
|
|
144
169
|
|
|
145
170
|
context.trace(`Validating the '${statementString}' statement...`);
|
|
146
171
|
|
|
147
|
-
|
|
148
|
-
const statement = this, ///
|
|
149
|
-
statementValidates = validateStatement(statement, assignments, stated, context);
|
|
172
|
+
const valid = this.isValid(context);
|
|
150
173
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
});
|
|
174
|
+
if (valid) {
|
|
175
|
+
validates = true;
|
|
155
176
|
|
|
156
|
-
|
|
157
|
-
|
|
177
|
+
context.debug(`...the '${statementString}' statement is alrady valid.`);
|
|
178
|
+
} else {
|
|
179
|
+
validates = validateStatements.some((validateStatement) => {
|
|
180
|
+
const statement = this, ///
|
|
181
|
+
statementValidates = validateStatement(statement, assignments, stated, context);
|
|
158
182
|
|
|
159
|
-
|
|
183
|
+
if (statementValidates) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
if (validates) {
|
|
189
|
+
const statement = this; ///
|
|
190
|
+
|
|
191
|
+
context.addStatement(statement);
|
|
160
192
|
|
|
161
|
-
|
|
193
|
+
context.debug(`...validated the '${statementString}' statement.`);
|
|
194
|
+
}
|
|
162
195
|
}
|
|
163
196
|
|
|
164
197
|
return validates;
|
|
@@ -187,11 +220,10 @@ export default define(class Statement extends Element {
|
|
|
187
220
|
return validatesGivenMetaType;
|
|
188
221
|
}
|
|
189
222
|
|
|
190
|
-
unifySubproof(subproof,
|
|
223
|
+
unifySubproof(subproof, generalContext, specificContext) {
|
|
191
224
|
let subproofUnifies = false;
|
|
192
225
|
|
|
193
|
-
const
|
|
194
|
-
statementNode = node, ///
|
|
226
|
+
const statementNode = this.getStatementNode(),
|
|
195
227
|
subproofAssertionNode = statementNode.getSubproofAssertionNode(),
|
|
196
228
|
assertionNode = subproofAssertionNode; ///
|
|
197
229
|
|
|
@@ -211,7 +243,7 @@ export default define(class Statement extends Element {
|
|
|
211
243
|
subproofUnifies = match(subproofAssertionStatements, subproofStatements, (subproofAssertionStatement, subproofStatement) => {
|
|
212
244
|
const generalStatement = subproofAssertionStatement, ///
|
|
213
245
|
specificStatement = subproofStatement, ///
|
|
214
|
-
statementUnifies = unifyStatement(generalStatement, specificStatement,
|
|
246
|
+
statementUnifies = unifyStatement(generalStatement, specificStatement, generalContext, specificContext);
|
|
215
247
|
|
|
216
248
|
if (statementUnifies) {
|
|
217
249
|
return true;
|
|
@@ -246,7 +278,7 @@ export default define(class Statement extends Element {
|
|
|
246
278
|
return statementUnifies;
|
|
247
279
|
}
|
|
248
280
|
|
|
249
|
-
unifyIndependently(
|
|
281
|
+
unifyIndependently(generalContext, specificContext) {
|
|
250
282
|
let unifiesIndependently = false;
|
|
251
283
|
|
|
252
284
|
const context = specificContext, ///
|
|
@@ -254,8 +286,7 @@ export default define(class Statement extends Element {
|
|
|
254
286
|
|
|
255
287
|
context.trace(`Unifying the '${statementString}' statement independently...`);
|
|
256
288
|
|
|
257
|
-
const
|
|
258
|
-
statementNode = node, ///
|
|
289
|
+
const statementNode = this.getStatementNode(),
|
|
259
290
|
definedAssertionNode = statementNode.getDefinedAssertionNode(),
|
|
260
291
|
containedAssertionNode = statementNode.getContainedAssertionNode();
|
|
261
292
|
|
|
@@ -263,7 +294,7 @@ export default define(class Statement extends Element {
|
|
|
263
294
|
const context = generalContext, ///
|
|
264
295
|
assertionNode = (definedAssertionNode || containedAssertionNode),
|
|
265
296
|
assertion = context.findAssertionByAssertionNode(assertionNode),
|
|
266
|
-
assertionUnifiesIndependently = assertion.unifyIndependently(
|
|
297
|
+
assertionUnifiesIndependently = assertion.unifyIndependently(generalContext, specificContext);
|
|
267
298
|
|
|
268
299
|
if (assertionUnifiesIndependently) {
|
|
269
300
|
unifiesIndependently = true;
|
|
@@ -38,6 +38,21 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
38
38
|
return replacementNode;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
getMetavariable(generalContext, specificContext) {
|
|
42
|
+
let metavariable = null;
|
|
43
|
+
|
|
44
|
+
const targetFrameNode = this.targetFrame.getNode(),
|
|
45
|
+
metavariableName = targetFrameNode.getMetavariableName();
|
|
46
|
+
|
|
47
|
+
if (metavariableName !== null) {
|
|
48
|
+
const context = generalContext; ///
|
|
49
|
+
|
|
50
|
+
metavariable = context.findMetavariableByMetavariableName(metavariableName);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return metavariable;
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
isTrivial() {
|
|
42
57
|
const targetFrameEqualToReplacementFrame = this.targetFrame.isEqualTo(this.replacementFrame),
|
|
43
58
|
trivial = targetFrameEqualToReplacementFrame; ///
|
|
@@ -59,38 +74,51 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
59
74
|
return comparesToParameter;
|
|
60
75
|
}
|
|
61
76
|
|
|
62
|
-
validate(
|
|
77
|
+
validate(generalContext, specificContext) {
|
|
63
78
|
let validates = false;
|
|
64
79
|
|
|
80
|
+
const context = this.getContext();
|
|
81
|
+
|
|
82
|
+
specificContext = context; ///
|
|
83
|
+
|
|
65
84
|
const frameSubstitutionString = this.getString(); ///
|
|
66
85
|
|
|
67
86
|
context.trace(`Validating the '${frameSubstitutionString}' frame substitution...`);
|
|
68
87
|
|
|
69
|
-
const
|
|
88
|
+
const valid = this.isValid(context);
|
|
70
89
|
|
|
71
|
-
if (
|
|
72
|
-
|
|
90
|
+
if (valid) {
|
|
91
|
+
validates = true;
|
|
92
|
+
|
|
93
|
+
context.debug(`...the '${frameSubstitutionString}' frame substitution is already valid.`);
|
|
94
|
+
} else {
|
|
95
|
+
const targetFrameValidates = this.validateTargetFrame(generalContext, specificContext);
|
|
96
|
+
|
|
97
|
+
if (targetFrameValidates) {
|
|
98
|
+
const replacementFrameValidates = this.validateReplacementFrame(generalContext, specificContext);
|
|
73
99
|
|
|
74
|
-
|
|
75
|
-
|
|
100
|
+
if (replacementFrameValidates) {
|
|
101
|
+
validates = true;
|
|
102
|
+
}
|
|
76
103
|
}
|
|
77
|
-
}
|
|
78
104
|
|
|
79
|
-
|
|
80
|
-
|
|
105
|
+
if (validates) {
|
|
106
|
+
const substititoin = this; ///
|
|
81
107
|
|
|
82
|
-
|
|
108
|
+
context.addSubstitution(substititoin);
|
|
83
109
|
|
|
84
|
-
|
|
110
|
+
context.debug(`...validated the '${frameSubstitutionString}' frame substitution.`);
|
|
111
|
+
}
|
|
85
112
|
}
|
|
86
113
|
|
|
87
114
|
return validates;
|
|
88
115
|
}
|
|
89
116
|
|
|
90
|
-
validateTargetFrame(
|
|
117
|
+
validateTargetFrame(generalContext, specificContext) {
|
|
91
118
|
let targetFrameValidates = false;
|
|
92
119
|
|
|
93
|
-
const
|
|
120
|
+
const context = generalContext, ///
|
|
121
|
+
targetFrameString = this.targetFrame.getString(),
|
|
94
122
|
frameSubstitutionString = this.getString(); ///
|
|
95
123
|
|
|
96
124
|
context.trace(`Validating the '${frameSubstitutionString}' frame subtitution's '${targetFrameString}' target frame...`);
|
|
@@ -113,10 +141,11 @@ export default define(class FrameSubstitution extends Substitution {
|
|
|
113
141
|
return targetFrameValidates;
|
|
114
142
|
}
|
|
115
143
|
|
|
116
|
-
validateReplacementFrame(
|
|
144
|
+
validateReplacementFrame(generalContext, specificContext) {
|
|
117
145
|
let replacementFrameValidates;
|
|
118
146
|
|
|
119
|
-
const
|
|
147
|
+
const context = specificContext, ///
|
|
148
|
+
replacementFrameString = this.replacementFrame.getString(),
|
|
120
149
|
frameSubstitutionString = this.getString(); ///
|
|
121
150
|
|
|
122
151
|
context.trace(`Validating the '${frameSubstitutionString}' frame subtitution's '${replacementFrameString}' replacement frame...`);
|