occam-verify-cli 1.0.806 → 1.0.814
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/bounded.js +242 -0
- package/lib/context/branching.js +3 -3
- package/lib/context/ephemeral.js +3 -3
- package/lib/context/file/nominal.js +16 -16
- package/lib/context/liminal.js +26 -30
- package/lib/context/synoptic.js +272 -0
- package/lib/context.js +66 -54
- package/lib/element/assertion/defined.js +8 -8
- package/lib/element/assertion/satisfies.js +15 -11
- package/lib/element/assertion.js +5 -5
- package/lib/element/assumption/metaLevel.js +3 -3
- package/lib/element/conclusion.js +11 -8
- package/lib/element/deduction.js +11 -8
- package/lib/element/derivation.js +1 -7
- package/lib/element/frame.js +6 -14
- package/lib/element/label.js +5 -8
- package/lib/element/metavariable.js +17 -17
- package/lib/element/procedureCall.js +10 -6
- package/lib/element/proof.js +2 -2
- package/lib/element/proofAssertion/premise.js +27 -27
- package/lib/element/proofAssertion/step.js +26 -6
- package/lib/element/proofAssertion/supposition.js +27 -27
- package/lib/element/proofAssertion.js +10 -10
- package/lib/element/reference.js +9 -13
- package/lib/element/rule.js +42 -44
- package/lib/element/signature.js +4 -4
- package/lib/element/statement.js +35 -45
- package/lib/element/subproof.js +5 -5
- package/lib/element/substitution/frame.js +16 -11
- package/lib/element/substitution/reference.js +15 -10
- package/lib/element/substitution/statement.js +62 -56
- package/lib/element/substitution/term.js +15 -10
- package/lib/element/substitution.js +29 -31
- package/lib/element/term.js +1 -16
- package/lib/element/topLevelAssertion/axiom.js +5 -3
- package/lib/element/topLevelAssertion.js +37 -39
- package/lib/element/topLevelMetaAssertion.js +2 -2
- package/lib/element/variable.js +6 -6
- package/lib/node/frame.js +1 -9
- package/lib/node/statement.js +1 -9
- package/lib/node/term.js +1 -19
- package/lib/process/assign.js +23 -31
- package/lib/utilities/context.js +41 -42
- package/lib/utilities/element.js +33 -5
- package/lib/utilities/equivalence.js +4 -4
- package/lib/utilities/equivalences.js +28 -13
- package/lib/utilities/instance.js +3 -3
- package/lib/utilities/string.js +2 -2
- package/lib/utilities/substitutions.js +16 -15
- package/lib/utilities/unification.js +133 -124
- package/package.json +4 -4
- package/src/context/{proof.js → bounded.js} +9 -9
- package/src/context/branching.js +2 -2
- package/src/context/ephemeral.js +2 -2
- package/src/context/file/nominal.js +15 -15
- package/src/context/liminal.js +29 -35
- package/src/context/{synthetic.js → synoptic.js} +84 -4
- package/src/context.js +88 -69
- package/src/element/assertion/defined.js +8 -8
- package/src/element/assertion/satisfies.js +17 -10
- package/src/element/assertion.js +8 -8
- package/src/element/assumption/metaLevel.js +4 -2
- package/src/element/conclusion.js +12 -7
- package/src/element/deduction.js +12 -7
- package/src/element/derivation.js +0 -2
- package/src/element/frame.js +7 -20
- package/src/element/label.js +3 -5
- package/src/element/metavariable.js +27 -27
- package/src/element/procedureCall.js +15 -10
- package/src/element/proof.js +2 -2
- package/src/element/proofAssertion/premise.js +41 -41
- package/src/element/proofAssertion/step.js +39 -9
- package/src/element/proofAssertion/supposition.js +41 -41
- package/src/element/proofAssertion.js +10 -9
- package/src/element/reference.js +9 -13
- package/src/element/rule.js +59 -63
- package/src/element/signature.js +3 -3
- package/src/element/statement.js +54 -68
- package/src/element/subproof.js +5 -5
- package/src/element/substitution/frame.js +18 -8
- package/src/element/substitution/reference.js +16 -7
- package/src/element/substitution/statement.js +87 -74
- package/src/element/substitution/term.js +15 -6
- package/src/element/substitution.js +38 -41
- package/src/element/term.js +0 -26
- package/src/element/topLevelAssertion/axiom.js +5 -2
- package/src/element/topLevelAssertion.js +51 -55
- package/src/element/topLevelMetaAssertion.js +2 -2
- package/src/element/variable.js +5 -5
- package/src/node/frame.js +0 -12
- package/src/node/statement.js +0 -12
- package/src/node/term.js +0 -28
- package/src/process/assign.js +35 -46
- package/src/utilities/context.js +41 -43
- package/src/utilities/element.js +32 -4
- package/src/utilities/equivalence.js +3 -4
- package/src/utilities/equivalences.js +29 -17
- package/src/utilities/instance.js +3 -3
- package/src/utilities/string.js +2 -2
- package/src/utilities/substitutions.js +17 -15
- package/src/utilities/unification.js +145 -119
- package/lib/context/proof.js +0 -242
- package/lib/context/synthetic.js +0 -212
|
@@ -38,9 +38,12 @@ export default define(class Axiom extends TopLevelAssertion {
|
|
|
38
38
|
|
|
39
39
|
context = this.getContext();
|
|
40
40
|
|
|
41
|
-
const generalContext = context
|
|
41
|
+
const generalContext = context, ///
|
|
42
|
+
signatureAComparesToSignatureB = signatureA.compareSignature(signatureB, generalContext, specificContext);
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
if (signatureAComparesToSignatureB) {
|
|
45
|
+
comparesToSignature = true;
|
|
46
|
+
}
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
return comparesToSignature;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { enclose } from "../utilities/context";
|
|
7
7
|
import { topLevelAssertionStringFromLabelsSuppositionsAndDeduction } from "../utilities/string";
|
|
8
8
|
import { labelsFromJSON,
|
|
9
9
|
deductionFromJSON,
|
|
@@ -16,8 +16,8 @@ import { labelsFromJSON,
|
|
|
16
16
|
hypothesesToHypothesesJSON,
|
|
17
17
|
suppositionsToSuppositionsJSON } from "../utilities/json";
|
|
18
18
|
|
|
19
|
-
const {
|
|
20
|
-
{ asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
|
|
19
|
+
const { reverse, correlate } = arrayUtilities,
|
|
20
|
+
{ asyncExtract, asyncForwardsEvery, asyncBackwardsEvery } = asynchronousUtilities;
|
|
21
21
|
|
|
22
22
|
export default class TopLevelAssertion extends Element {
|
|
23
23
|
constructor(context, string, node, labels, suppositions, deduction, proof, signature, hypotheses) {
|
|
@@ -59,6 +59,12 @@ export default class TopLevelAssertion extends Element {
|
|
|
59
59
|
this.hypotheses = hypotheses;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
getSupposition(index) {
|
|
63
|
+
const supposition = this.suppositions[index] || null;
|
|
64
|
+
|
|
65
|
+
return supposition;
|
|
66
|
+
}
|
|
67
|
+
|
|
62
68
|
isHypothetical() {
|
|
63
69
|
const hypothesesLength = this.hypotheses.length,
|
|
64
70
|
hypothetical = (hypothesesLength > 0);
|
|
@@ -73,22 +79,16 @@ export default class TopLevelAssertion extends Element {
|
|
|
73
79
|
return unconditional;
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
return supposition;
|
|
80
|
-
}
|
|
82
|
+
matchMetavariableNode(metavariableNode) {
|
|
83
|
+
const metavariableNodeMatches = this.labels.some((label) => {
|
|
84
|
+
const metavariableNodeMatches = label.matchMetavariableNode(metavariableNode);
|
|
81
85
|
|
|
82
|
-
|
|
83
|
-
const comparesToMetavariableName = this.labels.some((label) => {
|
|
84
|
-
const labelComparesToMetavariableName = label.compareMetavariableName(metavariableName);
|
|
85
|
-
|
|
86
|
-
if (labelComparesToMetavariableName) {
|
|
86
|
+
if (metavariableNodeMatches) {
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
return
|
|
91
|
+
return metavariableNodeMatches;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
correlateHypotheses(context) {
|
|
@@ -120,28 +120,6 @@ export default class TopLevelAssertion extends Element {
|
|
|
120
120
|
return correlatesToHypotheses;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
unifyStatementWithDeduction(statement, context) {
|
|
124
|
-
let statementUnifiesWithDeduction = false;
|
|
125
|
-
|
|
126
|
-
const statementString = statement.getString(),
|
|
127
|
-
deductionString = this.deduction.getString(),
|
|
128
|
-
topLevelAssertionString = this.getString(); ///
|
|
129
|
-
|
|
130
|
-
context.trace(`Unifying the '${statementString}' statement with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction...`);
|
|
131
|
-
|
|
132
|
-
const statementUnifies = this.deduction.unifyStatement(statement, context);
|
|
133
|
-
|
|
134
|
-
if (statementUnifies) {
|
|
135
|
-
statementUnifiesWithDeduction = true;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (statementUnifiesWithDeduction) {
|
|
139
|
-
context.debug(`...unified the '${statementString}' statement with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction.`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return statementUnifiesWithDeduction;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
123
|
async verify() {
|
|
146
124
|
let verifies = false;
|
|
147
125
|
|
|
@@ -150,7 +128,7 @@ export default class TopLevelAssertion extends Element {
|
|
|
150
128
|
|
|
151
129
|
context.trace(`Verifying the '${topLevelAssertionString}' top level assertion...`);
|
|
152
130
|
|
|
153
|
-
await
|
|
131
|
+
await enclose(async (context) => {
|
|
154
132
|
const labelsVerify = this.verifyLabels();
|
|
155
133
|
|
|
156
134
|
if (labelsVerify) {
|
|
@@ -304,47 +282,65 @@ export default class TopLevelAssertion extends Element {
|
|
|
304
282
|
return suppositionsVerify;
|
|
305
283
|
}
|
|
306
284
|
|
|
307
|
-
async
|
|
308
|
-
let
|
|
285
|
+
async unifyStepWithDeduction(step, context) {
|
|
286
|
+
let stepUnifiesWithDeduction = false;
|
|
287
|
+
|
|
288
|
+
await this.break(context);
|
|
289
|
+
|
|
290
|
+
const stepString = step.getString(),
|
|
291
|
+
deductionString = this.deduction.getString(),
|
|
292
|
+
topLevelAssertionString = this.getString(); ///
|
|
293
|
+
|
|
294
|
+
context.trace(`Unifying the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction...`);
|
|
295
|
+
|
|
296
|
+
const stepUnifies = await this.deduction.unifyStep(step, context);
|
|
297
|
+
|
|
298
|
+
if (stepUnifies) {
|
|
299
|
+
stepUnifiesWithDeduction = true;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (stepUnifiesWithDeduction) {
|
|
303
|
+
context.debug(`...unified the '${stepString}' step with the '${topLevelAssertionString}' top level assertion's '${deductionString}' deduction.`);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
return stepUnifiesWithDeduction;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async unifyStepAndSubproofOrProofAssertions(step, subproofOrProofAssertions, context) {
|
|
310
|
+
let stepAndSubproofOrProofAssertionsUnify = false;
|
|
309
311
|
|
|
310
312
|
const correlatesToHypotheses = this.correlateHypotheses(context);
|
|
311
313
|
|
|
312
314
|
if (correlatesToHypotheses) {
|
|
313
|
-
const
|
|
315
|
+
const stepUnifiesWithDeduction = await this.unifyStepWithDeduction(step, context);
|
|
314
316
|
|
|
315
|
-
if (
|
|
317
|
+
if (stepUnifiesWithDeduction) {
|
|
316
318
|
const subproofOrProofAssertionsUnifiesWithSuppositions = await this.unifySubproofOrProofAssertionsWithSuppositions(subproofOrProofAssertions, context);
|
|
317
319
|
|
|
318
320
|
if (subproofOrProofAssertionsUnifiesWithSuppositions) {
|
|
319
321
|
const substitutionsResolved = context.areSubstitutionsResolved();
|
|
320
322
|
|
|
321
323
|
if (substitutionsResolved) {
|
|
322
|
-
|
|
324
|
+
stepAndSubproofOrProofAssertionsUnify = true;
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
329
|
|
|
328
|
-
return
|
|
330
|
+
return stepAndSubproofOrProofAssertionsUnify;
|
|
329
331
|
}
|
|
330
332
|
|
|
331
333
|
async unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, context) {
|
|
332
334
|
let subproofOrProofAssertionsUnifiesWithSupposition = false;
|
|
333
335
|
|
|
336
|
+
await this.break(context);
|
|
337
|
+
|
|
334
338
|
if (!subproofOrProofAssertionsUnifiesWithSupposition) {
|
|
335
|
-
const subproofOrProofAssertion =
|
|
336
|
-
const subproofOrProofAssertionUnifies = supposition.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
|
|
339
|
+
const subproofOrProofAssertion = await asyncExtract(subproofOrProofAssertions, async (subproofOrProofAssertion) => {
|
|
340
|
+
const subproofOrProofAssertionUnifies = await supposition.unifySubproofOrProofAssertion(subproofOrProofAssertion, context);
|
|
337
341
|
|
|
338
342
|
if (subproofOrProofAssertionUnifies) {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
context = this.getContext();
|
|
342
|
-
|
|
343
|
-
const generalContext = context; ///
|
|
344
|
-
|
|
345
|
-
context = specificContext; ///
|
|
346
|
-
|
|
347
|
-
context.resolveSubstitutions(generalContext, specificContext);
|
|
343
|
+
context.resolveSubstitutions();
|
|
348
344
|
|
|
349
345
|
return true;
|
|
350
346
|
}
|
|
@@ -371,7 +367,7 @@ export default class TopLevelAssertion extends Element {
|
|
|
371
367
|
|
|
372
368
|
subproofOrProofAssertions = reverse(subproofOrProofAssertions); ///
|
|
373
369
|
|
|
374
|
-
subproofOrProofAssertionsUnifiesWithSuppositions = asyncBackwardsEvery(this.suppositions, async (supposition) => {
|
|
370
|
+
subproofOrProofAssertionsUnifiesWithSuppositions = await asyncBackwardsEvery(this.suppositions, async (supposition) => {
|
|
375
371
|
const stepUnifiesWithSupposition = await this.unifySubproofOrProofAssertionsWithSupposition(subproofOrProofAssertions, supposition, context);
|
|
376
372
|
|
|
377
373
|
if (stepUnifiesWithSupposition) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { Element, asynchronousUtilities } from "occam-languages";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { enclose } from "../utilities/context";
|
|
6
6
|
import { topLevelMetaAssertionStringFromLabelSuppositionsDeductionAndMetaLevelAssumptions } from "../utilities/string";
|
|
7
7
|
import { labelFromJSON,
|
|
8
8
|
labelToLabelJSON,
|
|
@@ -103,7 +103,7 @@ export default class TopLevelMetaAssertion extends Element {
|
|
|
103
103
|
|
|
104
104
|
context.trace(`Verifying the '${topLevelMetaAssertionString}' top level meta assertion...`);
|
|
105
105
|
|
|
106
|
-
await
|
|
106
|
+
await enclose(async (context) => {
|
|
107
107
|
const labelVerifies = this.verifyLabel();
|
|
108
108
|
|
|
109
109
|
if (labelVerifies) {
|
package/src/element/variable.js
CHANGED
|
@@ -45,11 +45,11 @@ export default define(class Variable extends Element {
|
|
|
45
45
|
return identifierEqualTo;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
compareVariable(variable) {
|
|
49
49
|
const variableIdentifier = variable.getIdentifier(),
|
|
50
|
-
|
|
50
|
+
comparesToVariable = (this.identifier === variableIdentifier);
|
|
51
51
|
|
|
52
|
-
return
|
|
52
|
+
return comparesToVariable;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
compareParamter(parameter) {
|
|
@@ -117,9 +117,9 @@ export default define(class Variable extends Element {
|
|
|
117
117
|
|
|
118
118
|
variable = this; ///
|
|
119
119
|
|
|
120
|
-
const
|
|
120
|
+
const variableNode = variable.getNode();
|
|
121
121
|
|
|
122
|
-
substitution = context.
|
|
122
|
+
substitution = context.findSubstitutionByVariableNode(variableNode);
|
|
123
123
|
|
|
124
124
|
if (substitution !== null) {
|
|
125
125
|
const substitutionComparesToTerm = substitution.compareTerm(term, context);
|
package/src/node/frame.js
CHANGED
|
@@ -22,18 +22,6 @@ export default class FrameNode extends NonTerminalNode {
|
|
|
22
22
|
return singular;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
getMetavariableName() {
|
|
26
|
-
let metavariableName = null;
|
|
27
|
-
|
|
28
|
-
const metavariableNode = this.getMetavariableNode();
|
|
29
|
-
|
|
30
|
-
if (metavariableNode !== null) {
|
|
31
|
-
metavariableName = metavariableNode.getMetavariableName();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return metavariableName;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
25
|
getAssumptionNodes() {
|
|
38
26
|
const ruleName = ASSUMPTION_RULE_NAME,
|
|
39
27
|
declarationNodes = this.getNodesByRuleName(ruleName);
|
package/src/node/statement.js
CHANGED
|
@@ -31,18 +31,6 @@ export default class StatementNode extends NonTerminalNode {
|
|
|
31
31
|
return singular;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
getMetavariableName() {
|
|
35
|
-
let metavariableName = null;
|
|
36
|
-
|
|
37
|
-
const metavariableNode = this.getMetavariableNode();
|
|
38
|
-
|
|
39
|
-
if (metavariableNode !== null) {
|
|
40
|
-
metavariableName = metavariableNode.getMetavariableName();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return metavariableName;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
34
|
getMetavariableNode() {
|
|
47
35
|
const singularMetavariableNode = this.getSingularMetavariableNode(),
|
|
48
36
|
metavariableNode = singularMetavariableNode; ///
|
package/src/node/term.js
CHANGED
|
@@ -36,34 +36,6 @@ export default class TermNode extends NonTerminalNode {
|
|
|
36
36
|
return singularTermNode;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
getVariableIdentifier() {
|
|
40
|
-
let variableIdentifier = null;
|
|
41
|
-
|
|
42
|
-
const singular = this.isSingular();
|
|
43
|
-
|
|
44
|
-
if (singular) {
|
|
45
|
-
const singularVariableNode = this.getSingularVariableNode();
|
|
46
|
-
|
|
47
|
-
variableIdentifier = singularVariableNode.getVariableIdentifier();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return variableIdentifier;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getSingularVariableIdentifier() {
|
|
54
|
-
let singularVariableIdentifier = null;
|
|
55
|
-
|
|
56
|
-
const singularVariableNode = this.getSingularVariableNode();
|
|
57
|
-
|
|
58
|
-
if (singularVariableNode !== null) {
|
|
59
|
-
const variableIdentifier = singularVariableNode.getVariableIdentifier();
|
|
60
|
-
|
|
61
|
-
singularVariableIdentifier = variableIdentifier; ///
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return singularVariableIdentifier;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
39
|
getVariableNodes() {
|
|
68
40
|
const ruleName = VARIABLE_RULE_NAME,
|
|
69
41
|
variableNodes = this.getNodesByRuleName(ruleName);
|
package/src/process/assign.js
CHANGED
|
@@ -24,37 +24,17 @@ export function judgementAssignmentFromJudgement(judgement, context) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export function leftVariableAssignmentFromEquality(equality, context) {
|
|
27
|
-
let leftVariableAssignment = (contxt) => {
|
|
28
|
-
///
|
|
29
|
-
};
|
|
30
|
-
|
|
31
27
|
const type = equality.getType(),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (singularVariableNode !== null) {
|
|
36
|
-
const leftVariableNode = singularVariableNode; ///
|
|
37
|
-
|
|
38
|
-
leftVariableAssignment = variableAssignmentFromVariableNodeAndType(leftVariableNode, type, context);
|
|
39
|
-
}
|
|
28
|
+
leftTerm = equality.getLeftTerm(),
|
|
29
|
+
leftVariableAssignment = variableAssignmentFromTermAndType(leftTerm, type, context);
|
|
40
30
|
|
|
41
31
|
return leftVariableAssignment;
|
|
42
32
|
}
|
|
43
33
|
|
|
44
34
|
export function rightVariableAssignmentFromEquality(equality, context) {
|
|
45
|
-
let rightVariableAssignment = (context) => {
|
|
46
|
-
///
|
|
47
|
-
};
|
|
48
|
-
|
|
49
35
|
const type = equality.getType(),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (singularVariableNode !== null) {
|
|
54
|
-
const rightVariableNode = singularVariableNode; ///
|
|
55
|
-
|
|
56
|
-
rightVariableAssignment = variableAssignmentFromVariableNodeAndType(rightVariableNode, type, context);
|
|
57
|
-
}
|
|
36
|
+
rightTerm = equality.getRightTerm(),
|
|
37
|
+
rightVariableAssignment = variableAssignmentFromTermAndType(rightTerm, type, context);
|
|
58
38
|
|
|
59
39
|
return rightVariableAssignment;
|
|
60
40
|
}
|
|
@@ -68,15 +48,10 @@ export function variableAssignmentFromTypeAssertion(typeAssertion, context) {
|
|
|
68
48
|
termSingular = term.isSingular();
|
|
69
49
|
|
|
70
50
|
if (termSingular) {
|
|
71
|
-
const
|
|
72
|
-
|
|
51
|
+
const type = typeAssertion.getType(),
|
|
52
|
+
variableNode = term.getVariableNode();
|
|
73
53
|
|
|
74
|
-
|
|
75
|
-
const type = typeAssertion.getType(),
|
|
76
|
-
variableNode = variable.getNode();
|
|
77
|
-
|
|
78
|
-
variableAssignment = variableAssignmentFromVariableNodeAndType(variableNode, type, context);
|
|
79
|
-
}
|
|
54
|
+
variableAssignment = variableAssignmentFromTermAndType(variableNode, type, context);
|
|
80
55
|
}
|
|
81
56
|
|
|
82
57
|
return variableAssignment;
|
|
@@ -104,26 +79,40 @@ export function variableAssignmentFromPrepertyAssertion(propertyAssertion, conte
|
|
|
104
79
|
|
|
105
80
|
}
|
|
106
81
|
|
|
107
|
-
function
|
|
108
|
-
|
|
82
|
+
function variableAssignmentFromTermAndType(term, type, context) {
|
|
83
|
+
let variableAssignment = (context) => {
|
|
84
|
+
///
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const termSingular = term.isSingular();
|
|
109
88
|
|
|
110
|
-
|
|
89
|
+
if (termSingular) {
|
|
90
|
+
const termType = term.getType(),
|
|
91
|
+
termTypeEqualToType = termType.isEqualTo(type);
|
|
111
92
|
|
|
112
|
-
|
|
113
|
-
|
|
93
|
+
if (!termTypeEqualToType) {
|
|
94
|
+
const variableNode = term.getVariableNode(),
|
|
95
|
+
variable = variableFromVariableNode(variableNode, context);
|
|
114
96
|
|
|
115
|
-
|
|
97
|
+
variable.setType(type);
|
|
116
98
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
assigned = true; ///
|
|
99
|
+
variableAssignment = (context) => {
|
|
100
|
+
const declaredVariable = variable; ///
|
|
120
101
|
|
|
121
|
-
|
|
122
|
-
context.trace(`Assigned the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`) :
|
|
123
|
-
context.debug(`Unable to assign the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`);
|
|
102
|
+
context.addDeclaredVariable(declaredVariable);
|
|
124
103
|
|
|
125
|
-
|
|
126
|
-
|
|
104
|
+
const declaredVariableTypeString = declaredVariable.getTypeString(),
|
|
105
|
+
declaredVariableString = declaredVariable.getString(),
|
|
106
|
+
assigned = true; ///
|
|
107
|
+
|
|
108
|
+
assigned ?
|
|
109
|
+
context.trace(`Assigned the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`) :
|
|
110
|
+
context.debug(`Unable to assign the '${declaredVariableString}' declared variable with type '${declaredVariableTypeString}'.`);
|
|
111
|
+
|
|
112
|
+
return assigned;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
127
116
|
|
|
128
117
|
return variableAssignment;
|
|
129
118
|
}
|
package/src/utilities/context.js
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import ProofContext from "../context/proof";
|
|
4
3
|
import NestedContext from "../context/nested";
|
|
5
4
|
import TheticContext from "../context/thetic";
|
|
5
|
+
import BoundedContext from "../context/bounded";
|
|
6
6
|
import NominalContext from "../context/nominal";
|
|
7
7
|
import LiteralContext from "../context/literal";
|
|
8
8
|
import LiminalContext from "../context/liminal";
|
|
9
|
+
import SynopticContext from "../context/synoptic";
|
|
9
10
|
import IllativeContext from "../context/illative";
|
|
10
11
|
import EphemeralContext from "../context/ephemeral";
|
|
11
12
|
import BranchingContext from "../context/branching";
|
|
12
|
-
import SyntheticContext from "../context/synthetic";
|
|
13
13
|
import NominalFileContext from "../context/file/nominal";
|
|
14
14
|
|
|
15
15
|
import { ephemeralContextFromJSON, ephemeralContextToEphemeralContextJSON } from "../utilities/json";
|
|
16
16
|
|
|
17
17
|
export function join(innerFunction, ...contexts) {
|
|
18
|
-
const
|
|
19
|
-
context =
|
|
18
|
+
const synopticContext = SynopticContext.fromContexts(...contexts),
|
|
19
|
+
context = synopticContext; ///
|
|
20
|
+
|
|
21
|
+
return innerFunction(context);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function ground(innerFunction) {
|
|
25
|
+
let context;
|
|
26
|
+
|
|
27
|
+
const nominalContext = NominalContext.fromNothing();
|
|
28
|
+
|
|
29
|
+
context = nominalContext; ///
|
|
30
|
+
|
|
31
|
+
const literalContext = LiteralContext.fromNothing(context);
|
|
32
|
+
|
|
33
|
+
context = literalContext; ///
|
|
20
34
|
|
|
21
35
|
return innerFunction(context);
|
|
22
36
|
}
|
|
@@ -57,14 +71,6 @@ export function declare(innerFunction, context) {
|
|
|
57
71
|
return innerFunction(context);
|
|
58
72
|
}
|
|
59
73
|
|
|
60
|
-
export function descend(innerFunction, context) {
|
|
61
|
-
const nestedContext = NestedContext.fromNothing(context);
|
|
62
|
-
|
|
63
|
-
context = nestedContext; ///
|
|
64
|
-
|
|
65
|
-
return innerFunction(context);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
74
|
export function attempt(innerFunction, context) {
|
|
69
75
|
const ephemeralContext = EphemeralContext.fromNothing(context);
|
|
70
76
|
|
|
@@ -73,32 +79,38 @@ export function attempt(innerFunction, context) {
|
|
|
73
79
|
return innerFunction(context);
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
export function
|
|
77
|
-
const
|
|
82
|
+
export function descend(innerFunction, context) {
|
|
83
|
+
const nestedContext = NestedContext.fromNothing(context);
|
|
78
84
|
|
|
79
|
-
context =
|
|
85
|
+
context = nestedContext; ///
|
|
80
86
|
|
|
81
87
|
return innerFunction(context);
|
|
82
88
|
}
|
|
83
89
|
|
|
84
|
-
export function
|
|
85
|
-
|
|
90
|
+
export function enclose(innerFunction, metaLevelAssumptions, context) {
|
|
91
|
+
if (context === undefined) {
|
|
92
|
+
context = metaLevelAssumptions; ///
|
|
86
93
|
|
|
87
|
-
|
|
94
|
+
metaLevelAssumptions = null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const boundedContext = BoundedContext.fromMetaLevelAssumptions(metaLevelAssumptions, context);
|
|
98
|
+
|
|
99
|
+
context = boundedContext; ///
|
|
88
100
|
|
|
89
101
|
return innerFunction(context);
|
|
90
102
|
}
|
|
91
103
|
|
|
92
|
-
export function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const nominalContext = NominalContext.fromNothing();
|
|
104
|
+
export function evaluate(procedure, terms) {
|
|
105
|
+
const context = procedure.getContext();
|
|
96
106
|
|
|
97
|
-
|
|
107
|
+
return procedure.call(terms, context);
|
|
108
|
+
}
|
|
98
109
|
|
|
99
|
-
|
|
110
|
+
export function reconcile(innerFunction, context) {
|
|
111
|
+
const liminalContext = LiminalContext.fromNothing(context);
|
|
100
112
|
|
|
101
|
-
context =
|
|
113
|
+
context = liminalContext; ///
|
|
102
114
|
|
|
103
115
|
return innerFunction(context);
|
|
104
116
|
}
|
|
@@ -121,24 +133,10 @@ export function unserialise(innerFunction, json, context) {
|
|
|
121
133
|
return innerFunction(json, context);
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
context = metaLevelAssumptions; ///
|
|
127
|
-
|
|
128
|
-
metaLevelAssumptions = null;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const proofContext = ProofContext.fromMetaLevelAssumptions(metaLevelAssumptions, context);
|
|
132
|
-
|
|
133
|
-
context = proofContext; ///
|
|
134
|
-
|
|
135
|
-
return await innerFunction(context);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export async function asyncReconcile(innerFunction, context) {
|
|
139
|
-
const liminalContext = LiminalContext.fromNothing(context);
|
|
136
|
+
export function instantiate(innerFunction, context) {
|
|
137
|
+
const literalContext = LiteralContext.fromNothing(context);
|
|
140
138
|
|
|
141
|
-
context =
|
|
139
|
+
context = literalContext; ///
|
|
142
140
|
|
|
143
|
-
return
|
|
141
|
+
return innerFunction(context);
|
|
144
142
|
}
|
package/src/utilities/element.js
CHANGED
|
@@ -618,9 +618,10 @@ export function termSubstitutionFromTermSubstitutionNode(termSubstitutionNode, c
|
|
|
618
618
|
const { TermSubstitution } = elements,
|
|
619
619
|
node = termSubstitutionNode, ///
|
|
620
620
|
string = context.nodeAsString(node),
|
|
621
|
+
generalContext = generalContextFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
621
622
|
targetTerm = targetTermFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
622
623
|
replacementTerm = replacementTermFromTermSubstitutionNode(termSubstitutionNode, context),
|
|
623
|
-
termSubstitution = new TermSubstitution(context, string, node, targetTerm, replacementTerm);
|
|
624
|
+
termSubstitution = new TermSubstitution(context, string, node, generalContext, targetTerm, replacementTerm);
|
|
624
625
|
|
|
625
626
|
return termSubstitution;
|
|
626
627
|
}
|
|
@@ -629,9 +630,10 @@ export function frameSubstitutionFromFrameSubstitutionNode(frameSubstitutionNode
|
|
|
629
630
|
const { FrameSubstitution } = elements,
|
|
630
631
|
node = frameSubstitutionNode, ///
|
|
631
632
|
string = context.nodeAsString(node),
|
|
633
|
+
generalContext = generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
632
634
|
targetFrame = targetFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
633
635
|
replacementFrame = replacementFrameFromFrameSubstitutionNode(frameSubstitutionNode, context),
|
|
634
|
-
frameSubstitution = new FrameSubstitution(context, string, node, targetFrame, replacementFrame);
|
|
636
|
+
frameSubstitution = new FrameSubstitution(context, string, node, generalContext, targetFrame, replacementFrame);
|
|
635
637
|
|
|
636
638
|
return frameSubstitution;
|
|
637
639
|
}
|
|
@@ -767,9 +769,10 @@ export function referenceSubstitutionFromReferenceSubstitutionNode(referenceSubs
|
|
|
767
769
|
const { ReferenceSubstitution } = elements,
|
|
768
770
|
node = referenceSubstitutionNode, ///
|
|
769
771
|
string = context.nodeAsString(node),
|
|
772
|
+
generalContext = generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
770
773
|
targetReference = targetReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
771
774
|
replacementReference = replacementReferenceFromReferenceSubstitutionNode(referenceSubstitutionNode, context),
|
|
772
|
-
referenceSubstitution = new ReferenceSubstitution(context, string, node, targetReference, replacementReference);
|
|
775
|
+
referenceSubstitution = new ReferenceSubstitution(context, string, node, generalContext, targetReference, replacementReference);
|
|
773
776
|
|
|
774
777
|
return referenceSubstitution;
|
|
775
778
|
}
|
|
@@ -779,11 +782,12 @@ export function statementSubstitutionFromStatementSubstitutionNode(statementSubs
|
|
|
779
782
|
const { StatementSubstitution } = elements,
|
|
780
783
|
node = statementSubstitutionNode, ///
|
|
781
784
|
string = context.nodeAsString(node),
|
|
785
|
+
generalContext = generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
782
786
|
resolved = resolvedFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
783
787
|
substitution = substitutionFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
784
788
|
targetStatement = targetStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
785
789
|
replacementStatement = replacementStatementFromStatementSubstitutionNode(statementSubstitutionNode, context),
|
|
786
|
-
statementSubstitution = new StatementSubstitution(context, string, node, resolved, substitution, targetStatement, replacementStatement);
|
|
790
|
+
statementSubstitution = new StatementSubstitution(context, string, node, generalContext, resolved, substitution, targetStatement, replacementStatement);
|
|
787
791
|
|
|
788
792
|
return statementSubstitution;
|
|
789
793
|
}
|
|
@@ -1757,6 +1761,12 @@ export function topLevelMetaAssertionFromReferenceNode(referenceNode, context) {
|
|
|
1757
1761
|
return topLevelMetaAssertion;
|
|
1758
1762
|
}
|
|
1759
1763
|
|
|
1764
|
+
export function generalContextFromTermSubstitutionNode(termSubstitutionNode, context) {
|
|
1765
|
+
const generalContext = null;
|
|
1766
|
+
|
|
1767
|
+
return generalContext;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1760
1770
|
export function deductionFromTopLevelMetaAssertionNode(metaLemmaMetathoremNode, context) {
|
|
1761
1771
|
const deductionNode = metaLemmaMetathoremNode.getDeductionNode(),
|
|
1762
1772
|
deduction = deductionFromDeductionNode(deductionNode, context);
|
|
@@ -1778,6 +1788,12 @@ export function replacementTermFromTermSubstitutionNode(termSubstitutionNode, co
|
|
|
1778
1788
|
return replacementTerm;
|
|
1779
1789
|
}
|
|
1780
1790
|
|
|
1791
|
+
export function generalContextFromFrameSubstitutionNode(frameSubstitutionNode, context) {
|
|
1792
|
+
const generalContext = null;
|
|
1793
|
+
|
|
1794
|
+
return generalContext;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1781
1797
|
export function superTypesFromSimpleTypeDeclarationNode(simpleTypeDeclarationNode, context) {
|
|
1782
1798
|
let superTypes = [];
|
|
1783
1799
|
|
|
@@ -1881,6 +1897,18 @@ export function provisionalFromComplexTypeDeclarationNode(complexTypeDeclaration
|
|
|
1881
1897
|
return provisional;
|
|
1882
1898
|
}
|
|
1883
1899
|
|
|
1900
|
+
export function generalContextFromStatementSubstitutionNode(statementSubstitutionNode, context) {
|
|
1901
|
+
const generalContext = null;
|
|
1902
|
+
|
|
1903
|
+
return generalContext;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
export function generalContextFromReferenceSubstitutionNode(referenceSubstitutionNode, context) {
|
|
1907
|
+
const generalContext = null;
|
|
1908
|
+
|
|
1909
|
+
return generalContext;
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1884
1912
|
export function metavariableFromMetavariableDeclarationNode(metavariableDeclarationNode, context) {
|
|
1885
1913
|
const metavariableNode = metavariableDeclarationNode.getMetavariableNode(),
|
|
1886
1914
|
metavariable = metavariableFromMetavariableNode(metavariableNode, context);
|