occam-verify-cli 0.0.1246 → 0.0.1248
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/file.js +170 -209
- package/lib/context/local.js +95 -125
- package/lib/dom/assertion/contained.js +44 -22
- package/lib/dom/assertion/defined.js +34 -17
- package/lib/dom/combinator/bracketed.js +167 -0
- package/lib/dom/combinator.js +163 -0
- package/lib/{constructor → dom/constructor}/bracketed.js +7 -7
- package/lib/dom/constructor.js +190 -0
- package/lib/dom/declaration/combinator.js +2 -8
- package/lib/dom/declaration/constructor.js +42 -7
- package/lib/dom/declaration.js +141 -149
- package/lib/dom/equality.js +3 -3
- package/lib/dom/frame.js +111 -76
- package/lib/dom/judgement.js +29 -3
- package/lib/dom/label.js +22 -15
- package/lib/dom/metaLemma.js +13 -58
- package/lib/dom/metatheorem.js +11 -117
- package/lib/dom/metavariable.js +7 -7
- package/lib/dom/reference.js +60 -18
- package/lib/dom/rule.js +6 -7
- package/lib/dom/statement.js +2 -2
- package/lib/dom/term.js +2 -2
- package/lib/dom/topLevelAssertion.js +78 -99
- package/lib/dom/topLevelMetaAssertion.js +253 -0
- package/lib/dom/type.js +3 -3
- package/lib/dom/variable.js +5 -5
- package/lib/equivalence.js +2 -2
- package/lib/index.js +7 -3
- package/lib/mixins/statement/verify.js +3 -3
- package/lib/mixins/term/verify.js +2 -3
- package/lib/substitution/statement.js +2 -2
- package/lib/unifier/{label.js → reference.js} +14 -14
- package/lib/utilities/json.js +5 -7
- package/lib/utilities/string.js +3 -3
- package/lib/utilities/unification.js +25 -6
- package/lib/verifier/combinator.js +3 -3
- package/lib/verifier/constructor.js +3 -3
- package/package.json +5 -5
- package/src/context/file.js +161 -205
- package/src/context/local.js +73 -83
- package/src/dom/assertion/contained.js +60 -27
- package/src/dom/assertion/defined.js +44 -20
- package/src/{combinator → dom/combinator}/bracketed.js +6 -5
- package/src/{combinator.js → dom/combinator.js} +8 -7
- package/src/{constructor → dom/constructor}/bracketed.js +6 -5
- package/src/{constructor.js → dom/constructor.js} +28 -27
- package/src/dom/declaration/combinator.js +2 -3
- package/src/dom/declaration/constructor.js +3 -2
- package/src/dom/declaration.js +163 -199
- package/src/dom/equality.js +2 -2
- package/src/dom/frame.js +151 -95
- package/src/dom/judgement.js +36 -2
- package/src/dom/label.js +18 -13
- package/src/dom/metaLemma.js +5 -78
- package/src/dom/metatheorem.js +8 -121
- package/src/dom/metavariable.js +6 -6
- package/src/dom/reference.js +85 -25
- package/src/dom/rule.js +7 -5
- package/src/dom/statement.js +1 -1
- package/src/dom/term.js +1 -1
- package/src/dom/topLevelAssertion.js +86 -128
- package/src/dom/topLevelMetaAssertion.js +154 -0
- package/src/dom/type.js +2 -2
- package/src/dom/variable.js +4 -4
- package/src/equivalence.js +1 -1
- package/src/index.js +4 -0
- package/src/mixins/statement/verify.js +3 -2
- package/src/mixins/term/verify.js +2 -3
- package/src/substitution/statement.js +1 -1
- package/src/unifier/{label.js → reference.js} +6 -6
- package/src/utilities/json.js +4 -4
- package/src/utilities/string.js +2 -2
- package/src/utilities/unification.js +44 -5
- package/src/verifier/combinator.js +2 -2
- package/src/verifier/constructor.js +2 -2
- package/lib/combinator/bracketed.js +0 -126
- package/lib/combinator.js +0 -122
- package/lib/constructor.js +0 -149
package/src/dom/metavariable.js
CHANGED
|
@@ -380,9 +380,9 @@ export default domAssigned(class Metavariable {
|
|
|
380
380
|
const metavariable = this, ///
|
|
381
381
|
generalContext = context, ///
|
|
382
382
|
specificContext = context, ///
|
|
383
|
-
|
|
383
|
+
metavariablePresent = generalContext.isMetavariablePresent(metavariable, generalContext, specificContext);
|
|
384
384
|
|
|
385
|
-
verified =
|
|
385
|
+
verified = metavariablePresent; ///
|
|
386
386
|
|
|
387
387
|
if (verified) {
|
|
388
388
|
context.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
@@ -437,15 +437,15 @@ export default domAssigned(class Metavariable {
|
|
|
437
437
|
fileContext.debug(`A term was found in the '${metavariableString}' metavariable when a type should have been present.`);
|
|
438
438
|
} else {
|
|
439
439
|
const metavariableName = this.name, ///
|
|
440
|
-
|
|
440
|
+
metavariablePresent = fileContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
441
441
|
|
|
442
|
-
if (
|
|
442
|
+
if (metavariablePresent) {
|
|
443
443
|
fileContext.debug(`The '${metavariableName}' metavariable has already been declared.`);
|
|
444
444
|
} else {
|
|
445
445
|
const variableName = this.name, ///
|
|
446
|
-
|
|
446
|
+
variablePresent = fileContext.isVariablePresentByVariableName(variableName);
|
|
447
447
|
|
|
448
|
-
if (
|
|
448
|
+
if (variablePresent) {
|
|
449
449
|
fileContext.debug(`A '${metavariableName}' variable has already been declared.`);
|
|
450
450
|
} else {
|
|
451
451
|
const typeVerified = this.verifyType(fileContext);
|
package/src/dom/reference.js
CHANGED
|
@@ -6,8 +6,8 @@ import LocalContext from "../context/local";
|
|
|
6
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
7
|
import { domAssigned } from "../dom";
|
|
8
8
|
import { referenceMetaType } from "../dom/metaType";
|
|
9
|
-
import { unifyLabelWithReference } from "../utilities/unification";
|
|
10
9
|
import { metavariableFromJSON, metavariableToMetavariableJSON } from "../utilities/json";
|
|
10
|
+
import { unifyLabelWithReference, unifyMetavariableWithReference } from "../utilities/unification";
|
|
11
11
|
|
|
12
12
|
const proofStepReferenceNodeQuery = nodeQuery("/proofStep/reference"),
|
|
13
13
|
procedureCallReferenceNodeQuery = nodeQuery("/procedureCall/reference"),
|
|
@@ -42,26 +42,6 @@ export default domAssigned(class Reference {
|
|
|
42
42
|
|
|
43
43
|
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
44
44
|
|
|
45
|
-
unifyLabel(label, substitutions, generalContext, specificContext) {
|
|
46
|
-
let labelUnified;
|
|
47
|
-
|
|
48
|
-
const reference = this, ///
|
|
49
|
-
labelString = label.getString(),
|
|
50
|
-
referenceString = reference.getString();
|
|
51
|
-
|
|
52
|
-
specificContext.trace(`Unifying the '${labelString}' label with the '${referenceString}' reference...`);
|
|
53
|
-
|
|
54
|
-
const labelUnifiedWithReference = unifyLabelWithReference(label, reference, substitutions, generalContext, specificContext);
|
|
55
|
-
|
|
56
|
-
labelUnified = labelUnifiedWithReference; ///
|
|
57
|
-
|
|
58
|
-
if (labelUnified) {
|
|
59
|
-
specificContext.debug(`...unified the '${labelString}' label with the '${referenceString}' reference.`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return labelUnified;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
45
|
verify(context) {
|
|
66
46
|
let verified = false;
|
|
67
47
|
|
|
@@ -77,11 +57,9 @@ export default domAssigned(class Reference {
|
|
|
77
57
|
|
|
78
58
|
if (!verified) {
|
|
79
59
|
const reference = this, ///
|
|
80
|
-
|
|
81
|
-
metaLemmasMetaTheoremsPresent = context.areMetaLemmasMetaTheoremsPresentByReference(reference),
|
|
82
|
-
axiomLemmaTheoremConjecturePresent = context.isAxiomLemmaTheoremConjecturePresentByReference(reference);
|
|
60
|
+
labelPresent = context.isLabelPresentByReference(reference);
|
|
83
61
|
|
|
84
|
-
verified =
|
|
62
|
+
verified = labelPresent; ///
|
|
85
63
|
}
|
|
86
64
|
|
|
87
65
|
if (verified) {
|
|
@@ -102,6 +80,88 @@ export default domAssigned(class Reference {
|
|
|
102
80
|
return metavariableVerified;
|
|
103
81
|
}
|
|
104
82
|
|
|
83
|
+
unifyLabel(label, context) {
|
|
84
|
+
let labelUnified;
|
|
85
|
+
|
|
86
|
+
const reference = this, ///
|
|
87
|
+
labelString = label.getString(),
|
|
88
|
+
referenceString = reference.getString();
|
|
89
|
+
|
|
90
|
+
context.trace(`Unifying the '${labelString}' label with the '${referenceString}' reference...`);
|
|
91
|
+
|
|
92
|
+
const labelUnifiedWithReference = unifyLabelWithReference(label, reference, context);
|
|
93
|
+
|
|
94
|
+
labelUnified = labelUnifiedWithReference; ///
|
|
95
|
+
|
|
96
|
+
if (labelUnified) {
|
|
97
|
+
context.debug(`...unified the '${labelString}' label with the '${referenceString}' reference.`);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return labelUnified;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
unifyMetaLemma(metaLemma, context) {
|
|
104
|
+
let metaLemmaUnified;
|
|
105
|
+
|
|
106
|
+
const reference = this, ///
|
|
107
|
+
referenceString = reference.getString(),
|
|
108
|
+
metaLemmaString = metaLemma.getString();
|
|
109
|
+
|
|
110
|
+
context.trace(`Unifying the '${metaLemmaString}' meta-lemma with the '${referenceString}' reference...`);
|
|
111
|
+
|
|
112
|
+
const label = metaLemma.getLabel(),
|
|
113
|
+
labelUnified = this.unifyLabel(label, context);
|
|
114
|
+
|
|
115
|
+
metaLemmaUnified = labelUnified; ///
|
|
116
|
+
|
|
117
|
+
if (metaLemmaUnified) {
|
|
118
|
+
context.trace(`...unified the '${metaLemmaString}' meta-lemma with the '${referenceString}' reference.`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return metaLemmaUnified;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
unifyMetatheorem(metatheorem, context) {
|
|
125
|
+
let metatheoremUnified;
|
|
126
|
+
|
|
127
|
+
const reference = this, ///
|
|
128
|
+
referenceString = reference.getString(),
|
|
129
|
+
metatheoremString = metatheorem.getString();
|
|
130
|
+
|
|
131
|
+
context.trace(`Unifying the '${metatheoremString}' metatheorem with the '${referenceString}' reference...`);
|
|
132
|
+
|
|
133
|
+
const label = metatheorem.getLabel(),
|
|
134
|
+
labelUnified = this.unifyLabel(label, context);
|
|
135
|
+
|
|
136
|
+
metatheoremUnified = labelUnified; ///
|
|
137
|
+
|
|
138
|
+
if (metatheoremUnified) {
|
|
139
|
+
context.trace(`...unified the '${metatheoremString}' metatheorem with the '${referenceString}' reference.`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return metatheoremUnified;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
unifyMetavariable(metavariable, context) {
|
|
146
|
+
let metavariableUnified;
|
|
147
|
+
|
|
148
|
+
const reference = this, ///
|
|
149
|
+
metavariableString = metavariable.getString(),
|
|
150
|
+
referenceString = reference.getString();
|
|
151
|
+
|
|
152
|
+
context.trace(`Unifying the '${metavariableString}' metavariable with the '${referenceString}' reference...`);
|
|
153
|
+
|
|
154
|
+
const metavariableUnifiedWithReference = unifyMetavariableWithReference(metavariable, reference, context);
|
|
155
|
+
|
|
156
|
+
metavariableUnified = metavariableUnifiedWithReference; ///
|
|
157
|
+
|
|
158
|
+
if (metavariableUnified) {
|
|
159
|
+
context.debug(`...unified the '${metavariableString}' metavariable with the '${referenceString}' reference.`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return metavariableUnified;
|
|
163
|
+
}
|
|
164
|
+
|
|
105
165
|
toJSON() {
|
|
106
166
|
const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
|
|
107
167
|
metavariable = metavariableJSON, ///
|
package/src/dom/rule.js
CHANGED
|
@@ -7,8 +7,8 @@ import LocalContext from "../context/local";
|
|
|
7
7
|
import Substitutions from "../substitutions";
|
|
8
8
|
|
|
9
9
|
import { domAssigned } from "../dom";
|
|
10
|
-
import { stringFromLabels } from "./topLevelAssertion";
|
|
11
10
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
|
+
import { labelsStringFromLabels } from "./topLevelAssertion";
|
|
12
12
|
import { labelsFromJSON,
|
|
13
13
|
premisesFromJSON,
|
|
14
14
|
conclusionFromJSON,
|
|
@@ -195,9 +195,9 @@ export default domAssigned(class Rule {
|
|
|
195
195
|
verifyLabels() {
|
|
196
196
|
const labelsVerified = this.labels.every((label) => {
|
|
197
197
|
const nameOnly = true,
|
|
198
|
-
|
|
198
|
+
labelVerified = label.verify(nameOnly);
|
|
199
199
|
|
|
200
|
-
if (
|
|
200
|
+
if (labelVerified) {
|
|
201
201
|
return true;
|
|
202
202
|
}
|
|
203
203
|
});
|
|
@@ -230,7 +230,8 @@ export default domAssigned(class Rule {
|
|
|
230
230
|
labels = labelsFromJSON(json, fileContext),
|
|
231
231
|
premises = premisesFromJSON(json, fileContext),
|
|
232
232
|
conclusion = conclusionFromJSON(json, fileContext),
|
|
233
|
-
|
|
233
|
+
labelsString = labelsStringFromLabels(labels),
|
|
234
|
+
string = labelsString; ///
|
|
234
235
|
|
|
235
236
|
rule = new Rule(fileContext, string, labels, premises, conclusion, proof);
|
|
236
237
|
|
|
@@ -242,7 +243,8 @@ export default domAssigned(class Rule {
|
|
|
242
243
|
premises = premisesFromRuleNode(ruleNode, fileContext),
|
|
243
244
|
conclusion = conclusionFromRuleNode(ruleNode, fileContext),
|
|
244
245
|
proof = proofFromRuleNode(ruleNode, fileContext),
|
|
245
|
-
|
|
246
|
+
labelsString = labelsStringFromLabels(labels),
|
|
247
|
+
string = labelsString, ///
|
|
246
248
|
rule = new Rule(fileContext, string, labels, premises, conclusion, proof);
|
|
247
249
|
|
|
248
250
|
return rule;
|
package/src/dom/statement.js
CHANGED
|
@@ -168,7 +168,7 @@ export default domAssigned(class Statement {
|
|
|
168
168
|
let unifiedIndependently = false;
|
|
169
169
|
|
|
170
170
|
const statement = this, ///
|
|
171
|
-
statementString = this.string;
|
|
171
|
+
statementString = this.string; ///
|
|
172
172
|
|
|
173
173
|
context.trace(`Unifying the '${statementString}' statement independently...`);
|
|
174
174
|
|
package/src/dom/term.js
CHANGED
|
@@ -181,7 +181,7 @@ export default domAssigned(class Term {
|
|
|
181
181
|
let verifiedGivenType;
|
|
182
182
|
|
|
183
183
|
const typeName = type.getName(),
|
|
184
|
-
termString = this.getString();
|
|
184
|
+
termString = this.getString(); ///
|
|
185
185
|
|
|
186
186
|
specificContext.trace(`Verifying the '${termString}' term given the '${typeName}' type...`);
|
|
187
187
|
|
|
@@ -6,7 +6,6 @@ import dom from "../dom";
|
|
|
6
6
|
import LocalContext from "../context/local";
|
|
7
7
|
import Substitutions from "../substitutions";
|
|
8
8
|
|
|
9
|
-
import { EMPTY_STRING } from "../constants";
|
|
10
9
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
10
|
import { labelsFromJSON,
|
|
12
11
|
labelsToLabelsJSON,
|
|
@@ -25,11 +24,10 @@ const proofNodeQuery = nodeQuery("/*/proof"),
|
|
|
25
24
|
suppositionNodesQuery = nodesQuery("/*/supposition");
|
|
26
25
|
|
|
27
26
|
export default class TopLevelAssertion {
|
|
28
|
-
constructor(fileContext, string, labels,
|
|
27
|
+
constructor(fileContext, string, labels, suppositions, consequent, proof) {
|
|
29
28
|
this.fileContext = fileContext;
|
|
30
29
|
this.string = string;
|
|
31
30
|
this.labels = labels;
|
|
32
|
-
this.substitutions = substitutions;
|
|
33
31
|
this.suppositions = suppositions;
|
|
34
32
|
this.consequent = consequent;
|
|
35
33
|
this.proof = proof;
|
|
@@ -47,10 +45,6 @@ export default class TopLevelAssertion {
|
|
|
47
45
|
return this.labels;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
getSubstitutions() {
|
|
51
|
-
return this.substitutions;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
48
|
getSuppositions() {
|
|
55
49
|
return this.suppositions;
|
|
56
50
|
}
|
|
@@ -77,37 +71,52 @@ export default class TopLevelAssertion {
|
|
|
77
71
|
return metavariableNameMatches;
|
|
78
72
|
}
|
|
79
73
|
|
|
80
|
-
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
const referenceString = reference.getString(),
|
|
84
|
-
axiomLemmaTheoremConjecture = this, ///
|
|
85
|
-
axiomLemmaTheoremConjectureString = axiomLemmaTheoremConjecture.getString();
|
|
74
|
+
verify() {
|
|
75
|
+
let verified = false;
|
|
86
76
|
|
|
87
|
-
|
|
77
|
+
const labelsVerified = this.verifyLabels();
|
|
88
78
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
labelUnified = this.labels.some((label) => {
|
|
95
|
-
substitutions.clear();
|
|
79
|
+
if (labelsVerified) {
|
|
80
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
81
|
+
context = localContext, ///
|
|
82
|
+
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
83
|
+
const suppositionVerified = supposition.verify(context);
|
|
96
84
|
|
|
97
|
-
|
|
85
|
+
if (suppositionVerified) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
98
89
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
});
|
|
90
|
+
if (suppositionsVerified) {
|
|
91
|
+
const consequentVerified = this.consequent.verify(context);
|
|
103
92
|
|
|
104
|
-
|
|
93
|
+
if (consequentVerified) {
|
|
94
|
+
if (this.proof === null) {
|
|
95
|
+
verified = true;
|
|
96
|
+
} else {
|
|
97
|
+
const substitutions = Substitutions.fromNothing(),
|
|
98
|
+
proofVerified = this.proof.verify(substitutions, this.consequent, context);
|
|
105
99
|
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
verified = proofVerified; ///
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
108
104
|
}
|
|
109
105
|
|
|
110
|
-
return
|
|
106
|
+
return verified;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
verifyLabels() {
|
|
110
|
+
const labelsVerified = this.labels.every((label) => {
|
|
111
|
+
const nameOnly = true,
|
|
112
|
+
labelVerified = label.verify(nameOnly);
|
|
113
|
+
|
|
114
|
+
if (labelVerified) {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return labelsVerified;
|
|
111
120
|
}
|
|
112
121
|
|
|
113
122
|
unifyStatement(statement, context) {
|
|
@@ -139,6 +148,16 @@ export default class TopLevelAssertion {
|
|
|
139
148
|
return statementUnified;
|
|
140
149
|
}
|
|
141
150
|
|
|
151
|
+
unifyStatementWithConsequent(statement, substitutions, generalContext, specificContext) {
|
|
152
|
+
let consequentUnified;
|
|
153
|
+
|
|
154
|
+
const statementUnified = this.consequent.unifyStatement(statement, substitutions, generalContext, specificContext); ///
|
|
155
|
+
|
|
156
|
+
consequentUnified = statementUnified; ///
|
|
157
|
+
|
|
158
|
+
return consequentUnified;
|
|
159
|
+
}
|
|
160
|
+
|
|
142
161
|
unifyStatementAndProofStepSubproofs(statement, proofStepSubproofs, context) {
|
|
143
162
|
let statementAndProofStepSubproofsUnified = false;
|
|
144
163
|
|
|
@@ -162,30 +181,6 @@ export default class TopLevelAssertion {
|
|
|
162
181
|
return statementAndProofStepSubproofsUnified;
|
|
163
182
|
}
|
|
164
183
|
|
|
165
|
-
unifyStatementWithConsequent(statement, substitutions, generalContext, specificContext) {
|
|
166
|
-
let consequentUnified;
|
|
167
|
-
|
|
168
|
-
const statementUnified = this.consequent.unifyStatement(statement, substitutions, generalContext, specificContext); ///
|
|
169
|
-
|
|
170
|
-
consequentUnified = statementUnified; ///
|
|
171
|
-
|
|
172
|
-
return consequentUnified;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
unifyProofStepSubproofsWithSuppositions(proofStepSubproofs, substitutions, generalContext, specificContext) {
|
|
176
|
-
proofStepSubproofs = reverse(proofStepSubproofs); ///
|
|
177
|
-
|
|
178
|
-
const proofStepSubproofsUnifiedWithSuppositions = backwardsEvery(this.suppositions, (supposition) => {
|
|
179
|
-
const proofStepSubproofsUnifiedWithSupposition = this.unifyProofStepSubproofsWithSupposition(proofStepSubproofs, supposition, substitutions, generalContext, specificContext);
|
|
180
|
-
|
|
181
|
-
if (proofStepSubproofsUnifiedWithSupposition) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
return proofStepSubproofsUnifiedWithSuppositions;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
184
|
unifyProofStepSubproofsWithSupposition(proofStepSubproofs, supposition, substitutions, generalContext, specificContext) {
|
|
190
185
|
let proofStepSubproofsUnifiedWithSupposition =false;
|
|
191
186
|
|
|
@@ -211,67 +206,31 @@ export default class TopLevelAssertion {
|
|
|
211
206
|
return proofStepSubproofsUnifiedWithSupposition;
|
|
212
207
|
}
|
|
213
208
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const labelsVerified = this.verifyLabels();
|
|
218
|
-
|
|
219
|
-
if (labelsVerified) {
|
|
220
|
-
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
221
|
-
context = localContext, ///
|
|
222
|
-
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
223
|
-
const suppositionVerified = supposition.verify(context);
|
|
224
|
-
|
|
225
|
-
if (suppositionVerified) {
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
if (suppositionsVerified) {
|
|
231
|
-
const consequentVerified = this.consequent.verify(context);
|
|
232
|
-
|
|
233
|
-
if (consequentVerified) {
|
|
234
|
-
if (this.proof === null) {
|
|
235
|
-
verified = true;
|
|
236
|
-
} else {
|
|
237
|
-
const proofVerified = this.proof.verify(this.substitutions, this.consequent, context);
|
|
238
|
-
|
|
239
|
-
verified = proofVerified; ///
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return verified;
|
|
246
|
-
}
|
|
209
|
+
unifyProofStepSubproofsWithSuppositions(proofStepSubproofs, substitutions, generalContext, specificContext) {
|
|
210
|
+
proofStepSubproofs = reverse(proofStepSubproofs); ///
|
|
247
211
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
const nameOnly = true,
|
|
251
|
-
labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext, nameOnly);
|
|
212
|
+
const proofStepSubproofsUnifiedWithSuppositions = backwardsEvery(this.suppositions, (supposition) => {
|
|
213
|
+
const proofStepSubproofsUnifiedWithSupposition = this.unifyProofStepSubproofsWithSupposition(proofStepSubproofs, supposition, substitutions, generalContext, specificContext);
|
|
252
214
|
|
|
253
|
-
if (
|
|
215
|
+
if (proofStepSubproofsUnifiedWithSupposition) {
|
|
254
216
|
return true;
|
|
255
217
|
}
|
|
256
218
|
});
|
|
257
219
|
|
|
258
|
-
return
|
|
220
|
+
return proofStepSubproofsUnifiedWithSuppositions;
|
|
259
221
|
}
|
|
260
222
|
|
|
261
223
|
toJSON() {
|
|
262
224
|
const labelsJSON = labelsToLabelsJSON(this.labels),
|
|
263
225
|
consequentJSON = consequentToConsequentJSON(this.consequent),
|
|
264
226
|
suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
|
|
265
|
-
substitutionsJSON = substitutionsToSubstitutionsJSON(this.substitutions),
|
|
266
227
|
labels = labelsJSON, ///
|
|
267
228
|
consequent = consequentJSON, ///
|
|
268
229
|
suppositions = suppositionsJSON, ///
|
|
269
|
-
substitutions = substitutionsJSON, ///
|
|
270
230
|
json = {
|
|
271
231
|
labels,
|
|
272
232
|
consequent,
|
|
273
|
-
suppositions
|
|
274
|
-
substitutions
|
|
233
|
+
suppositions
|
|
275
234
|
};
|
|
276
235
|
|
|
277
236
|
return json;
|
|
@@ -279,51 +238,29 @@ export default class TopLevelAssertion {
|
|
|
279
238
|
|
|
280
239
|
static fromJSON(Class, json, fileContext) {
|
|
281
240
|
const labels = labelsFromJSON(json, fileContext),
|
|
282
|
-
|
|
241
|
+
labelsString = labelsStringFromLabels(labels),
|
|
283
242
|
suppositions = suppositionsFromJSON(json, fileContext),
|
|
284
|
-
|
|
285
|
-
string = stringFromLabels(labels),
|
|
243
|
+
consequent = consequentFromJSON(json, fileContext),
|
|
286
244
|
proof = null,
|
|
287
|
-
|
|
245
|
+
string = labelsString, ///
|
|
246
|
+
topLevelAssertion = new Class(fileContext, string, labels, suppositions, consequent, proof);
|
|
288
247
|
|
|
289
248
|
return topLevelAssertion;
|
|
290
249
|
}
|
|
291
250
|
|
|
292
251
|
static fromNode(Class, node, fileContext) {
|
|
293
252
|
const labels = labelsFromNode(node, fileContext),
|
|
294
|
-
|
|
253
|
+
labelsString = labelsStringFromLabels(labels),
|
|
295
254
|
suppositions = suppositionsFromNode(node, fileContext),
|
|
296
255
|
consequent = consequentFromNode(node, fileContext),
|
|
297
256
|
proof = proofFromNode(node, fileContext),
|
|
298
|
-
string =
|
|
299
|
-
metaLemma = new Class(fileContext, string, labels,
|
|
257
|
+
string = labelsString, ///
|
|
258
|
+
metaLemma = new Class(fileContext, string, labels, suppositions, consequent, proof);
|
|
300
259
|
|
|
301
260
|
return metaLemma;
|
|
302
261
|
}
|
|
303
262
|
}
|
|
304
263
|
|
|
305
|
-
export function stringFromLabels(labels) {
|
|
306
|
-
const string = labels.reduce((string, label) => {
|
|
307
|
-
const labelString = label.getString();
|
|
308
|
-
|
|
309
|
-
string = (string === EMPTY_STRING) ?
|
|
310
|
-
labelString: ///
|
|
311
|
-
`${string},${labelString}`;
|
|
312
|
-
|
|
313
|
-
return string;
|
|
314
|
-
}, EMPTY_STRING);
|
|
315
|
-
|
|
316
|
-
return string;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function proofFromNode(node, fileContext) {
|
|
320
|
-
const { Proof } = dom,
|
|
321
|
-
proofNode = proofNodeQuery(node),
|
|
322
|
-
proof = Proof.fromProofNode(proofNode, fileContext);
|
|
323
|
-
|
|
324
|
-
return proof;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
264
|
function labelsFromNode(node, fileContext) {
|
|
328
265
|
const { Label } = dom,
|
|
329
266
|
labelNodes = labelNodesQuery(node),
|
|
@@ -336,7 +273,15 @@ function labelsFromNode(node, fileContext) {
|
|
|
336
273
|
return labels;
|
|
337
274
|
}
|
|
338
275
|
|
|
339
|
-
function
|
|
276
|
+
export function proofFromNode(node, fileContext) {
|
|
277
|
+
const { Proof } = dom,
|
|
278
|
+
proofNode = proofNodeQuery(node),
|
|
279
|
+
proof = Proof.fromProofNode(proofNode, fileContext);
|
|
280
|
+
|
|
281
|
+
return proof;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function consequentFromNode(node, fileContext) {
|
|
340
285
|
const { Consequent } = dom,
|
|
341
286
|
consequentNode = consequentNodeQuery(node),
|
|
342
287
|
consequent = Consequent.fromConsequentNode(consequentNode, fileContext);
|
|
@@ -344,7 +289,7 @@ function consequentFromNode(node, fileContext) {
|
|
|
344
289
|
return consequent;
|
|
345
290
|
}
|
|
346
291
|
|
|
347
|
-
function suppositionsFromNode(node, fileContext) {
|
|
292
|
+
export function suppositionsFromNode(node, fileContext) {
|
|
348
293
|
const { Supposition } = dom,
|
|
349
294
|
suppositionNodes = suppositionNodesQuery(node),
|
|
350
295
|
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
@@ -356,3 +301,16 @@ function suppositionsFromNode(node, fileContext) {
|
|
|
356
301
|
return suppositions;
|
|
357
302
|
}
|
|
358
303
|
|
|
304
|
+
export function labelsStringFromLabels(labels) {
|
|
305
|
+
const labelsString = labels.reduce((labelsString, label) => {
|
|
306
|
+
const labelString = label.getString();
|
|
307
|
+
|
|
308
|
+
labelsString = (labelsString === null) ?
|
|
309
|
+
labelString: ///
|
|
310
|
+
`${labelsString},${labelString}`;
|
|
311
|
+
|
|
312
|
+
return labelsString;
|
|
313
|
+
}, null);
|
|
314
|
+
|
|
315
|
+
return labelsString;
|
|
316
|
+
}
|