occam-verify-cli 1.0.587 → 1.0.602
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
|
@@ -4,7 +4,9 @@ import { Element } from "occam-languages";
|
|
|
4
4
|
import { arrayUtilities } from "necessary";
|
|
5
5
|
import { asynchronousUtilities } from "occam-languages";
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import assignAssignments from "../process/assign";
|
|
8
|
+
|
|
9
|
+
import { asyncScope } from "../utilities/context";
|
|
8
10
|
import { labelsFromJSON,
|
|
9
11
|
deductionFromJSON,
|
|
10
12
|
signatureFromJSON,
|
|
@@ -16,8 +18,8 @@ import { labelsFromJSON,
|
|
|
16
18
|
hypothesesToHypothesesJSON,
|
|
17
19
|
suppositionsToSuppositionsJSON } from "../utilities/json";
|
|
18
20
|
|
|
19
|
-
const {
|
|
20
|
-
{
|
|
21
|
+
const { extract, reverse, correlate } = arrayUtilities,
|
|
22
|
+
{ asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
|
|
21
23
|
|
|
22
24
|
export default class TopLevelAssertion extends Element {
|
|
23
25
|
constructor(context, string, node, labels, suppositions, deduction, proof, signature, hypotheses) {
|
|
@@ -123,7 +125,14 @@ export default class TopLevelAssertion extends Element {
|
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
verifyLabels() {
|
|
126
|
-
|
|
128
|
+
let labelsVerify;
|
|
129
|
+
|
|
130
|
+
const context = this.getContext(),
|
|
131
|
+
topLevelAssertionString = this.getString();
|
|
132
|
+
|
|
133
|
+
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion's labels...`);
|
|
134
|
+
|
|
135
|
+
labelsVerify = this.labels.every((label) => {
|
|
127
136
|
const nameOnly = true,
|
|
128
137
|
labelVerifies = label.verify(nameOnly);
|
|
129
138
|
|
|
@@ -132,13 +141,42 @@ export default class TopLevelAssertion extends Element {
|
|
|
132
141
|
}
|
|
133
142
|
});
|
|
134
143
|
|
|
144
|
+
if (labelsVerify) {
|
|
145
|
+
context.trace(`...verified the '${topLevelAssertionString}' top level assertion's labels.`);
|
|
146
|
+
}
|
|
147
|
+
|
|
135
148
|
return labelsVerify;
|
|
136
149
|
}
|
|
137
150
|
|
|
151
|
+
unifyStatementWithDeduction(statement, context) {
|
|
152
|
+
let statementUnifiesWithDeduction = false;
|
|
153
|
+
|
|
154
|
+
const statementString = statement.getString(),
|
|
155
|
+
deductionString = this.deduction.getString(),
|
|
156
|
+
topLevelAssertionString = this.getString(); ///
|
|
157
|
+
|
|
158
|
+
context.trace(`Unifying the '${statementString}' statement with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction...`);
|
|
159
|
+
|
|
160
|
+
const statementUnifies = this.deduction.unifyStatement(statement, context);
|
|
161
|
+
|
|
162
|
+
if (statementUnifies) {
|
|
163
|
+
statementUnifiesWithDeduction = true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (statementUnifiesWithDeduction) {
|
|
167
|
+
context.debug(`...unified the '${statementString}' statement with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction.`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return statementUnifiesWithDeduction;
|
|
171
|
+
}
|
|
172
|
+
|
|
138
173
|
async verify() {
|
|
139
174
|
let verifies = false;
|
|
140
175
|
|
|
141
|
-
const context = this.getContext()
|
|
176
|
+
const context = this.getContext(),
|
|
177
|
+
topLevelAssertionString = this.getString(); ///
|
|
178
|
+
|
|
179
|
+
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion...`);
|
|
142
180
|
|
|
143
181
|
await asyncScope(async (context) => {
|
|
144
182
|
const labelsVerify = this.verifyLabels();
|
|
@@ -160,72 +198,103 @@ export default class TopLevelAssertion extends Element {
|
|
|
160
198
|
}
|
|
161
199
|
}, context);
|
|
162
200
|
|
|
201
|
+
if (verifies) {
|
|
202
|
+
context.debug(`...verified the '${topLevelAssertionString}' top level assertion.`);
|
|
203
|
+
}
|
|
204
|
+
|
|
163
205
|
return verifies;
|
|
164
206
|
}
|
|
165
207
|
|
|
166
|
-
async
|
|
167
|
-
|
|
168
|
-
const suppositionVerifies = await this.verifySupposition(supposition, context);
|
|
208
|
+
async verifyProof(context) {
|
|
209
|
+
let proofVerifies;
|
|
169
210
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
211
|
+
if (this.proof === null) {
|
|
212
|
+
proofVerifies = true;
|
|
213
|
+
} else {
|
|
214
|
+
const topLevelAssertionString = this.getString(); ///
|
|
174
215
|
|
|
175
|
-
|
|
176
|
-
|
|
216
|
+
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion's proof...`);
|
|
217
|
+
|
|
218
|
+
const statement = this.deduction.getStatement();
|
|
177
219
|
|
|
178
|
-
|
|
179
|
-
const suppositionVerifies = await supposition.verify(context);
|
|
220
|
+
proofVerifies = this.proof.verify(statement, context);
|
|
180
221
|
|
|
181
|
-
|
|
222
|
+
if (proofVerifies) {
|
|
223
|
+
context.debug(`...verified the '${topLevelAssertionString}' top level assertion's proof.`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return proofVerifies;
|
|
182
228
|
}
|
|
183
229
|
|
|
184
230
|
async verifyDeduction(context) {
|
|
185
|
-
|
|
231
|
+
let deductionVerifies;
|
|
186
232
|
|
|
187
|
-
|
|
188
|
-
}
|
|
233
|
+
const topLevelAssertionString = this.getString(); ///
|
|
189
234
|
|
|
190
|
-
|
|
191
|
-
let proofVerifies = true; ///
|
|
235
|
+
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion's deduction...`);
|
|
192
236
|
|
|
193
|
-
|
|
194
|
-
proofVerifies = await asyncAttempt(async (context) => {
|
|
195
|
-
const proofVerifies = await this.proof.verify(this.deduction, context);
|
|
237
|
+
deductionVerifies = await this.deduction.verify(context);
|
|
196
238
|
|
|
197
|
-
|
|
198
|
-
}
|
|
239
|
+
if (deductionVerifies) {
|
|
240
|
+
context.debug(`...verified the '${topLevelAssertionString}' top level assertion's deduction.`);
|
|
199
241
|
}
|
|
200
242
|
|
|
201
|
-
return
|
|
243
|
+
return deductionVerifies;
|
|
202
244
|
}
|
|
203
245
|
|
|
204
|
-
|
|
205
|
-
let
|
|
246
|
+
async verifySuppositions(context) {
|
|
247
|
+
let suppositionsVerify;
|
|
206
248
|
|
|
207
|
-
const
|
|
249
|
+
const topLevelAssertionString = this.getString(); ///
|
|
208
250
|
|
|
209
|
-
|
|
210
|
-
|
|
251
|
+
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion's suppositions...`);
|
|
252
|
+
|
|
253
|
+
suppositionsVerify = await asyncForwardsEvery(this.suppositions, async (supposition) => {
|
|
254
|
+
const assignments = [],
|
|
255
|
+
suppositionVerifies = await supposition.verify(assignments, context)
|
|
256
|
+
|
|
257
|
+
if (suppositionVerifies) {
|
|
258
|
+
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
259
|
+
|
|
260
|
+
if (assignmentsAssigned) {
|
|
261
|
+
const subproofOrProofAssertion = supposition; ////
|
|
262
|
+
|
|
263
|
+
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
264
|
+
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
if (suppositionsVerify) {
|
|
271
|
+
context.debug(`...verified the '${topLevelAssertionString}' top level assertion's suppositions.`);
|
|
211
272
|
}
|
|
212
273
|
|
|
213
|
-
return
|
|
274
|
+
return suppositionsVerify;
|
|
214
275
|
}
|
|
215
276
|
|
|
216
|
-
unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions,
|
|
277
|
+
async unifyStatementAndSubproofOrProofAssertions(statement, subproofOrProofAssertions, context) {
|
|
217
278
|
let statementAndSubproofOrProofAssertionsUnify = false;
|
|
218
279
|
|
|
219
280
|
const correlatesToHypotheses = this.correlateHypotheses(context);
|
|
220
281
|
|
|
221
282
|
if (correlatesToHypotheses) {
|
|
222
|
-
const statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement,
|
|
283
|
+
const statementUnifiesWithDeduction = this.unifyStatementWithDeduction(statement, context);
|
|
223
284
|
|
|
224
285
|
if (statementUnifiesWithDeduction) {
|
|
225
|
-
const
|
|
286
|
+
const subproofOrProofAssertionsUnifiesWithSuppositions = await this.unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, context);
|
|
287
|
+
|
|
288
|
+
if (subproofOrProofAssertionsUnifiesWithSuppositions) {
|
|
289
|
+
const specificContext = context; ///
|
|
290
|
+
|
|
291
|
+
context = this.getContext();
|
|
226
292
|
|
|
227
|
-
|
|
228
|
-
|
|
293
|
+
const generalContext = context; ///
|
|
294
|
+
|
|
295
|
+
context = specificContext; ///
|
|
296
|
+
|
|
297
|
+
const substitutionsResolved = context.areSubstitutionsResolved(generalContext, specificContext);
|
|
229
298
|
|
|
230
299
|
if (substitutionsResolved) {
|
|
231
300
|
statementAndSubproofOrProofAssertionsUnify = true;
|
|
@@ -237,14 +306,24 @@ export default class TopLevelAssertion extends Element {
|
|
|
237
306
|
return statementAndSubproofOrProofAssertionsUnify;
|
|
238
307
|
}
|
|
239
308
|
|
|
240
|
-
unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition,
|
|
309
|
+
async unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, context) {
|
|
241
310
|
let subproofOrProofAssertionsUnifiesWithSupposition = false;
|
|
242
311
|
|
|
243
312
|
if (!subproofOrProofAssertionsUnifiesWithSupposition) {
|
|
244
313
|
const subproofOrProofAssertion = extract(subproofOrProofAssertions, (subproofOrProofAssertion) => {
|
|
245
|
-
const subproofOrProofAssertionUnifies = supposition.unifySubproofOrProofAssertion(subproofOrProofAssertion,
|
|
314
|
+
const subproofOrProofAssertionUnifies = supposition.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
|
|
246
315
|
|
|
247
316
|
if (subproofOrProofAssertionUnifies) {
|
|
317
|
+
const specificContext = context; ///
|
|
318
|
+
|
|
319
|
+
context = this.getContext();
|
|
320
|
+
|
|
321
|
+
const generalContext = context; ///
|
|
322
|
+
|
|
323
|
+
context = specificContext; ///
|
|
324
|
+
|
|
325
|
+
context.resolveSubstitutions(generalContext, specificContext);
|
|
326
|
+
|
|
248
327
|
return true;
|
|
249
328
|
}
|
|
250
329
|
}) || null;
|
|
@@ -255,8 +334,7 @@ export default class TopLevelAssertion extends Element {
|
|
|
255
334
|
}
|
|
256
335
|
|
|
257
336
|
if (!subproofOrProofAssertionsUnifiesWithSupposition) {
|
|
258
|
-
const
|
|
259
|
-
suppositionUnifiesIndependently = supposition.unifyIndependently(substitutions, context);
|
|
337
|
+
const suppositionUnifiesIndependently = await supposition.unifyIndependently(context);
|
|
260
338
|
|
|
261
339
|
if (suppositionUnifiesIndependently) {
|
|
262
340
|
subproofOrProofAssertionsUnifiesWithSupposition = true;
|
|
@@ -266,18 +344,20 @@ export default class TopLevelAssertion extends Element {
|
|
|
266
344
|
return subproofOrProofAssertionsUnifiesWithSupposition;
|
|
267
345
|
}
|
|
268
346
|
|
|
269
|
-
unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions,
|
|
347
|
+
async unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, context) {
|
|
348
|
+
let subproofOrProofAssertionsUnifiesWithSuppositions;
|
|
349
|
+
|
|
270
350
|
subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
|
|
271
351
|
|
|
272
|
-
|
|
273
|
-
const
|
|
352
|
+
subproofOrProofAssertionsUnifiesWithSuppositions = asyncBackwardsEvery(this.suppositions, async (supposition) => {
|
|
353
|
+
const stepUnifiesWithSupposition = await this.unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, context);
|
|
274
354
|
|
|
275
|
-
if (
|
|
355
|
+
if (stepUnifiesWithSupposition) {
|
|
276
356
|
return true;
|
|
277
357
|
}
|
|
278
358
|
});
|
|
279
359
|
|
|
280
|
-
return
|
|
360
|
+
return subproofOrProofAssertionsUnifiesWithSuppositions;
|
|
281
361
|
}
|
|
282
362
|
|
|
283
363
|
toJSON() {
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import assignAssignments from "../process/assign";
|
|
6
|
+
|
|
7
|
+
import { asyncScope } from "../utilities/context";
|
|
6
8
|
import { labelFromJSON,
|
|
7
9
|
labelToLabelJSON,
|
|
8
10
|
deductionFromJSON,
|
|
@@ -53,22 +55,44 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
53
55
|
return comparesToReference;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
verifyLabel() {
|
|
59
|
+
let labelVerifies;
|
|
60
|
+
|
|
61
|
+
const context = this.getContext(),
|
|
62
|
+
topLevelMetaAssertionString = this.getString(); ///
|
|
63
|
+
|
|
64
|
+
context.trace(`Verifiesing the '${topLevelMetaAssertionString}' top level meta assertion's label...`);
|
|
65
|
+
|
|
66
|
+
const nameOnly = true;
|
|
67
|
+
|
|
68
|
+
labelVerifies = this.label.verify(nameOnly);
|
|
69
|
+
|
|
70
|
+
if (labelVerifies) {
|
|
71
|
+
context.trace(`...verified the '${topLevelMetaAssertionString}' top level meta assertion's label.`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return labelVerifies;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async verify() {
|
|
57
78
|
let verifies = false;
|
|
58
79
|
|
|
59
|
-
const context = this.getContext()
|
|
80
|
+
const context = this.getContext(),
|
|
81
|
+
topLevelMetaAssertionString = this.getString(); ///
|
|
82
|
+
|
|
83
|
+
context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta assertion...`);
|
|
60
84
|
|
|
61
|
-
|
|
85
|
+
await asyncScope(async (context) => {
|
|
62
86
|
const labelVerifies = this.verifyLabel();
|
|
63
87
|
|
|
64
88
|
if (labelVerifies) {
|
|
65
|
-
const suppositionsVerify = this.verifySuppositions(context);
|
|
89
|
+
const suppositionsVerify = await this.verifySuppositions(context);
|
|
66
90
|
|
|
67
91
|
if (suppositionsVerify) {
|
|
68
|
-
const deductionVerifies = this.verifyDeduction(context);
|
|
92
|
+
const deductionVerifies = await this.verifyDeduction(context);
|
|
69
93
|
|
|
70
94
|
if (deductionVerifies) {
|
|
71
|
-
const proofVerifies = this.verifyProof(context);
|
|
95
|
+
const proofVerifies = await this.verifyProof(context);
|
|
72
96
|
|
|
73
97
|
if (proofVerifies) {
|
|
74
98
|
verifies = true;
|
|
@@ -78,50 +102,80 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
78
102
|
}
|
|
79
103
|
}, context);
|
|
80
104
|
|
|
105
|
+
if (verifies) {
|
|
106
|
+
context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta assertion.`);
|
|
107
|
+
}
|
|
108
|
+
|
|
81
109
|
return verifies;
|
|
82
110
|
}
|
|
83
111
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
labelVerifies = this.label.verify(nameOnly);
|
|
112
|
+
async verifyProof(context) {
|
|
113
|
+
let proofVerifies;
|
|
87
114
|
|
|
88
|
-
|
|
89
|
-
|
|
115
|
+
if (this.proof === null) {
|
|
116
|
+
proofVerifies = true;
|
|
117
|
+
} else {
|
|
118
|
+
const topLevelMetaAssertionString = this.getString(); ///
|
|
90
119
|
|
|
91
|
-
|
|
92
|
-
const suppositionsVerify = this.suppositions.every((supposition) => {
|
|
93
|
-
const suppositionVerifies = this.verifySupposition(supposition, context);
|
|
120
|
+
context.trace(`Verifying the '${topLevelMetaAssertionString}' top meta level assertion's proof...`);
|
|
94
121
|
|
|
95
|
-
|
|
96
|
-
|
|
122
|
+
const statement = this.deduction.getStatement();
|
|
123
|
+
|
|
124
|
+
proofVerifies = this.proof.verify(statement, context);
|
|
125
|
+
|
|
126
|
+
if (proofVerifies) {
|
|
127
|
+
context.debug(`...verified the '${topLevelMetaAssertionString}' top meta level assertion's proof.`);
|
|
97
128
|
}
|
|
98
|
-
}
|
|
129
|
+
}
|
|
99
130
|
|
|
100
|
-
return
|
|
131
|
+
return proofVerifies;
|
|
101
132
|
}
|
|
102
133
|
|
|
103
|
-
|
|
104
|
-
|
|
134
|
+
async verifyDeduction(context) {
|
|
135
|
+
let deductionVerifies;
|
|
105
136
|
|
|
106
|
-
|
|
107
|
-
|
|
137
|
+
const topLevelMetaAssertionString = this.getString(); ///
|
|
138
|
+
|
|
139
|
+
context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta assertion's deduction...`);
|
|
108
140
|
|
|
109
|
-
|
|
110
|
-
|
|
141
|
+
deductionVerifies = await this.deduction.verify(context);
|
|
142
|
+
|
|
143
|
+
if (deductionVerifies) {
|
|
144
|
+
context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta assertion's deduction.`);
|
|
145
|
+
}
|
|
111
146
|
|
|
112
147
|
return deductionVerifies;
|
|
113
148
|
}
|
|
114
149
|
|
|
115
|
-
|
|
116
|
-
let
|
|
150
|
+
async verifySuppositions(context) {
|
|
151
|
+
let suppositionsVerify;
|
|
117
152
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
153
|
+
const topLevelMetaAssertionString = this.getString(); ///
|
|
154
|
+
|
|
155
|
+
context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta assertion's suppositions...`);
|
|
156
|
+
|
|
157
|
+
suppositionsVerify = await asyncForwardsEvery(this.suppositions, async (supposition) => {
|
|
158
|
+
const assignments = [],
|
|
159
|
+
suppositionVerifies = await supposition.verify(assignments, context)
|
|
160
|
+
|
|
161
|
+
if (suppositionVerifies) {
|
|
162
|
+
const assignmentsAssigned = assignAssignments(assignments, context);
|
|
163
|
+
|
|
164
|
+
if (assignmentsAssigned) {
|
|
165
|
+
const subproofOrProofAssertion = supposition; ////
|
|
166
|
+
|
|
167
|
+
context.addSubproofOrProofAssertion(subproofOrProofAssertion);
|
|
168
|
+
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
if (suppositionsVerify) {
|
|
175
|
+
context.debug(`...verified the '${topLevelMetaAssertionString}' top level meta assertion's suppositions.`);
|
|
122
176
|
}
|
|
123
177
|
|
|
124
|
-
return
|
|
178
|
+
return suppositionsVerify;
|
|
125
179
|
}
|
|
126
180
|
|
|
127
181
|
toJSON() {
|
package/src/element/variable.js
CHANGED
|
@@ -38,6 +38,13 @@ export default define(class Variable extends Element {
|
|
|
38
38
|
return identifierEqualTo;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
compare(variable) {
|
|
42
|
+
const variableIdentifier = variable.getIdentifier(),
|
|
43
|
+
comparesTo = (this.identifier === variableIdentifier);
|
|
44
|
+
|
|
45
|
+
return comparesTo;
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
compareParamter(parameter) {
|
|
42
49
|
const identifier = parameter.getIdentifier(),
|
|
43
50
|
identifierEqualTo = this.isIdentifierEqualTo(identifier),
|
|
@@ -120,7 +127,7 @@ export default define(class Variable extends Element {
|
|
|
120
127
|
|
|
121
128
|
variable = this; ///
|
|
122
129
|
|
|
123
|
-
substitution = substitutions.findSubstitutionByVariable(variable);
|
|
130
|
+
substitution = substitutions.findSubstitutionByVariable(variable, generalContext, specificContext);
|
|
124
131
|
|
|
125
132
|
if (substitution !== null) {
|
|
126
133
|
const substitutionComparesToTerm = substitution.compareTerm(term, context);
|
|
@@ -149,13 +156,16 @@ export default define(class Variable extends Element {
|
|
|
149
156
|
|
|
150
157
|
if (termTypeEqualToOrSubTypeOfVariableType) {
|
|
151
158
|
const { TermSubstitution } = elements,
|
|
152
|
-
termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, context)
|
|
159
|
+
termSubstitution = TermSubstitution.fromTermAndVariable(term, variable, context),
|
|
160
|
+
termSubstitutionValidates = termSubstitution.validate(generalContext, specificContext);
|
|
153
161
|
|
|
154
|
-
|
|
162
|
+
if (termSubstitutionValidates) {
|
|
163
|
+
substitution = termSubstitution; ///
|
|
155
164
|
|
|
156
|
-
|
|
165
|
+
context.addSubstitution(substitution);
|
|
157
166
|
|
|
158
|
-
|
|
167
|
+
termUnifies = true;
|
|
168
|
+
}
|
|
159
169
|
}
|
|
160
170
|
}
|
|
161
171
|
|
|
@@ -5,6 +5,39 @@ import SubstitutionNode from "../../node/substitution";
|
|
|
5
5
|
import { STATEMENT_RULE_NAME } from "../../ruleNames";
|
|
6
6
|
|
|
7
7
|
export default class StatementSubstitutionNode extends SubstitutionNode {
|
|
8
|
+
isResolved() {
|
|
9
|
+
let resolved = true;
|
|
10
|
+
|
|
11
|
+
const substitutionNode = this.getSubstitutionNode();
|
|
12
|
+
|
|
13
|
+
if (substitutionNode !== null) {
|
|
14
|
+
resolved = false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return resolved;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getSubstitutionNode() {
|
|
21
|
+
const targetStatementNode = this.getTargetStatementNode(),
|
|
22
|
+
substitutionNode = targetStatementNode.getSubstitutionNode();
|
|
23
|
+
|
|
24
|
+
return substitutionNode;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getTermSubstitutionNode() {
|
|
28
|
+
const targetStatementNode = this.getTargetStatementNode(),
|
|
29
|
+
termSubstitutionNode = targetStatementNode.getTermSubstitutionNode();
|
|
30
|
+
|
|
31
|
+
return termSubstitutionNode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getFrameSubstitutionNode() {
|
|
35
|
+
const targetStatementNode = this.getTargetStatementNode(),
|
|
36
|
+
frameSubstitutionNode = targetStatementNode.getFrameSubstitutionNode();
|
|
37
|
+
|
|
38
|
+
return frameSubstitutionNode;
|
|
39
|
+
}
|
|
40
|
+
|
|
8
41
|
getTargetStatementNode() {
|
|
9
42
|
const lastStatementNode = this.getLastStatementNode(),
|
|
10
43
|
targetStatementNode = lastStatementNode; ///
|
package/src/process/unify.js
CHANGED
|
@@ -67,11 +67,9 @@ class MetaLevelPass extends ZipPass {
|
|
|
67
67
|
|
|
68
68
|
statementNode = metavariableNodeParentNode; ///
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
termSubstitutionNode = statementNode.getTermSubstitutionNode(),
|
|
72
|
-
substitutionNode = (frameSubstitutionNode || termSubstitutionNode),
|
|
70
|
+
const substitutionNode = statementNode.getSubstitutionNode(),
|
|
73
71
|
substitution = (substitutionNode !== null) ?
|
|
74
|
-
context.findSubstitutionBySubstitutionNode(substitutionNode) :
|
|
72
|
+
context.findSubstitutionBySubstitutionNode(substitutionNode, generalContext, specificContext) :
|
|
75
73
|
null;
|
|
76
74
|
|
|
77
75
|
context = specificContext; ///
|
|
@@ -354,14 +352,14 @@ export function unifyStatement(generalStatement, specificStatement, generalConte
|
|
|
354
352
|
return statementUnifies;
|
|
355
353
|
}
|
|
356
354
|
|
|
357
|
-
export function unifySubstitution(generalSubstitution, specificSubstitution,
|
|
355
|
+
export function unifySubstitution(generalSubstitution, specificSubstitution, generalContext, specificContext) {
|
|
358
356
|
let substitutionUnifies = false;
|
|
359
357
|
|
|
360
358
|
const generalSubstitutionNode = generalSubstitution.getNode(),
|
|
361
359
|
specificSubstitutionNode = specificSubstitution.getNode(),
|
|
362
360
|
generalNode = generalSubstitutionNode, ///
|
|
363
361
|
specificNode = specificSubstitutionNode, ///
|
|
364
|
-
success = metaLevelPass.run(generalNode, specificNode,
|
|
362
|
+
success = metaLevelPass.run(generalNode, specificNode, generalContext, specificContext);
|
|
365
363
|
|
|
366
364
|
if (success) {
|
|
367
365
|
substitutionUnifies = true;
|
|
@@ -399,14 +397,14 @@ export function unifyTermWithConstructor(term, constructor, generalContext, spec
|
|
|
399
397
|
return termUnifiesWithConstructor;
|
|
400
398
|
}
|
|
401
399
|
|
|
402
|
-
export function unifyStatementIntrinsically(generalStatement, specificStatement,
|
|
400
|
+
export function unifyStatementIntrinsically(generalStatement, specificStatement, generalContext, specificContext) {
|
|
403
401
|
let statementUnifiesIntrinsically = false;
|
|
404
402
|
|
|
405
403
|
const generalStatementNode = generalStatement.getNode(),
|
|
406
404
|
specificStatementNode = specificStatement.getNode(),
|
|
407
405
|
generalNode = generalStatementNode, ///
|
|
408
406
|
specificNode = specificStatementNode, ///
|
|
409
|
-
success = intrinsicLevelPass.run(generalNode, specificNode,
|
|
407
|
+
success = intrinsicLevelPass.run(generalNode, specificNode, generalContext, specificContext);
|
|
410
408
|
|
|
411
409
|
if (success) {
|
|
412
410
|
statementUnifiesIntrinsically = true;
|
package/src/utilities/context.js
CHANGED
|
@@ -4,6 +4,7 @@ import ScopedContext from "../context/scoped";
|
|
|
4
4
|
import LiminalContext from "../context/liminal";
|
|
5
5
|
import LiteralContext from "../context/literal";
|
|
6
6
|
import EphemeralContext from "../context/ephemeral";
|
|
7
|
+
import SyntheticContext from "../context/synthetic";
|
|
7
8
|
|
|
8
9
|
export function scope(innerFunction, context) {
|
|
9
10
|
const scopedContext = ScopedContext.fromNothing(context);
|
|
@@ -37,6 +38,14 @@ export function literally(innerFunction, context) {
|
|
|
37
38
|
return innerFunction(context);
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
export function synthetically(innerFunction, contexts, context) {
|
|
42
|
+
const syntheticContext = SyntheticContext.fromContexts(contexts, context);
|
|
43
|
+
|
|
44
|
+
context = syntheticContext; ///
|
|
45
|
+
|
|
46
|
+
return innerFunction(context);
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
export async function asyncScope(innerFunction, context) {
|
|
41
50
|
const scopedContext = ScopedContext.fromNothing(context);
|
|
42
51
|
|
|
@@ -61,11 +70,3 @@ export async function asyncLiminally(innerFunction, context) {
|
|
|
61
70
|
return await innerFunction(context);
|
|
62
71
|
}
|
|
63
72
|
|
|
64
|
-
export async function asyncLiterally(innerFunction, context) {
|
|
65
|
-
const literalContext = LiteralContext.fromNothing(context);
|
|
66
|
-
|
|
67
|
-
context = literalContext; ///
|
|
68
|
-
|
|
69
|
-
return await innerFunction(context);
|
|
70
|
-
}
|
|
71
|
-
|