occam-verify-cli 0.0.1087 → 0.0.1089
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/assertion/contained.js +3 -3
- package/lib/assertion/defined.js +4 -4
- package/lib/axiom.js +33 -81
- package/lib/conjecture.js +33 -85
- package/lib/context/file.js +43 -1
- package/lib/context/local.js +38 -2
- package/lib/declaration.js +7 -41
- package/lib/frame.js +49 -26
- package/lib/judgement.js +28 -16
- package/lib/lemma.js +34 -85
- package/lib/metaLemma.js +35 -102
- package/lib/metatheorem.js +34 -60
- package/lib/mixins/statement/qualified/unify.js +21 -63
- package/lib/mixins/statement/verify.js +2 -17
- package/lib/proofStep.js +6 -6
- package/lib/reference.js +14 -4
- package/lib/statement.js +8 -8
- package/lib/term.js +8 -8
- package/lib/theorem.js +34 -85
- package/lib/topLevelAssertion.js +62 -5
- package/lib/utilities/json.js +2 -2
- package/lib/variable.js +2 -2
- package/package.json +1 -1
- package/src/assertion/contained.js +4 -4
- package/src/assertion/defined.js +4 -4
- package/src/axiom.js +10 -63
- package/src/conjecture.js +10 -72
- package/src/context/file.js +42 -0
- package/src/context/local.js +13 -2
- package/src/declaration.js +7 -55
- package/src/frame.js +58 -31
- package/src/judgement.js +40 -20
- package/src/lemma.js +12 -72
- package/src/metaLemma.js +12 -81
- package/src/metatheorem.js +10 -78
- package/src/mixins/statement/qualified/unify.js +37 -104
- package/src/mixins/statement/verify.js +0 -27
- package/src/proofStep.js +7 -5
- package/src/reference.js +25 -4
- package/src/statement.js +8 -8
- package/src/term.js +8 -8
- package/src/theorem.js +10 -71
- package/src/topLevelAssertion.js +86 -4
- package/src/utilities/json.js +1 -1
- package/src/variable.js +1 -1
package/src/declaration.js
CHANGED
|
@@ -100,71 +100,23 @@ class Declaration {
|
|
|
100
100
|
|
|
101
101
|
localContext.trace(`Verifying the '${declarationString}' declaration...`);
|
|
102
102
|
|
|
103
|
-
if (!verified) {
|
|
104
|
-
const verifiedAtMetaLevel = this.verifyAtMetaLevel(assignments, stated, localContext);
|
|
105
|
-
|
|
106
|
-
verified = verifiedAtMetaLevel; ///
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (!verified) {
|
|
110
|
-
const verifiedAtIntrinsicLevel = this.verifyAtIntrinsicLevel(assignments, stated, localContext);
|
|
111
|
-
|
|
112
|
-
verified = verifiedAtIntrinsicLevel; ///
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (verified) {
|
|
116
|
-
localContext.debug(`...verified the '${declarationString}' declaration.`);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return verified;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
verifyAtMetaLevel(assignments, stated, localContext) {
|
|
123
|
-
let verifiedAtMetaLevel;
|
|
124
|
-
|
|
125
|
-
const declarationString = this.string; ///
|
|
126
|
-
|
|
127
|
-
localContext.trace(`Verifying the '${declarationString}' declaration at meta level...`);
|
|
128
|
-
|
|
129
103
|
stated = true; ///
|
|
130
104
|
|
|
131
105
|
assignments = null; ///
|
|
132
106
|
|
|
133
|
-
const referenceVerified = this.reference.verify(localContext)
|
|
134
|
-
statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
107
|
+
const referenceVerified = this.reference.verify(localContext);
|
|
135
108
|
|
|
136
|
-
|
|
109
|
+
if (referenceVerified) {
|
|
110
|
+
const statementVerified = this.statement.verify(assignments, stated, localContext);
|
|
137
111
|
|
|
138
|
-
|
|
139
|
-
localContext.debug(`...verified the '${declarationString}' declaration at meta level.`);
|
|
112
|
+
verified = statementVerified; ///
|
|
140
113
|
}
|
|
141
114
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
verifyAtIntrinsicLevel(assignments, stated, localContext) {
|
|
146
|
-
let verifiedAtIntrinsicLevel = false;
|
|
147
|
-
|
|
148
|
-
const declarationString = this.string; ///
|
|
149
|
-
|
|
150
|
-
localContext.trace(`Verifying the '${declarationString}' declaration at intrinsic level...`);
|
|
151
|
-
|
|
152
|
-
const lemma = localContext.findLemmaByReference(this.reference),
|
|
153
|
-
theorem = localContext.findTheoremByReference(this.reference),
|
|
154
|
-
lemmaOrTheorem = (lemma || theorem);
|
|
155
|
-
|
|
156
|
-
if (lemmaOrTheorem !== null) {
|
|
157
|
-
const lemmaOrTheoremStatement = lemmaOrTheorem.getStatement(),
|
|
158
|
-
lemmaOrTheoremStatementEqualToStatement = lemmaOrTheoremStatement.isEqualTo(this.statement);
|
|
159
|
-
|
|
160
|
-
verifiedAtIntrinsicLevel = lemmaOrTheoremStatementEqualToStatement; ///
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
if (verifiedAtIntrinsicLevel) {
|
|
164
|
-
localContext.debug(`...verified the '${declarationString}' declaration at intrinsic level.`);
|
|
115
|
+
if (verified) {
|
|
116
|
+
localContext.debug(`...verified the '${declarationString}' declaration.`);
|
|
165
117
|
}
|
|
166
118
|
|
|
167
|
-
return
|
|
119
|
+
return verified;
|
|
168
120
|
}
|
|
169
121
|
|
|
170
122
|
static fromDeclarationNode(declarationNode, localContext) {
|
package/src/frame.js
CHANGED
|
@@ -121,11 +121,11 @@ class Frame {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, localContext) {
|
|
124
|
-
let
|
|
124
|
+
let metaLemmaMetatheoremUnified;
|
|
125
125
|
|
|
126
126
|
const metaLemmaMetatheoremString = metaLemmaMetatheorem.getString();
|
|
127
127
|
|
|
128
|
-
localContext.trace(`Unifying the '${metaLemmaMetatheoremString}'
|
|
128
|
+
localContext.trace(`Unifying the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem...`);
|
|
129
129
|
|
|
130
130
|
const substitutions = metaLemmaMetatheorem.getSubstitutions(),
|
|
131
131
|
substitutionsUnified = substitutions.everySubstitution((substitution) => {
|
|
@@ -136,45 +136,73 @@ class Frame {
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
metaLemmaMetatheoremUnified = substitutionsUnified; ///
|
|
140
140
|
|
|
141
|
-
if (
|
|
142
|
-
localContext.debug(`...unified the '${metaLemmaMetatheoremString}'
|
|
141
|
+
if (metaLemmaMetatheoremUnified) {
|
|
142
|
+
localContext.debug(`...unified the '${metaLemmaMetatheoremString}' meta-lemma or metatheorem.`);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
return
|
|
145
|
+
return metaLemmaMetatheoremUnified;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
unifyAxiomLemmaTheoremOrConjecture(axiomLemmaTheoremOrConjecture, localContext) {
|
|
149
|
+
let axiomLemmaTheoremOrConjectureUnified;
|
|
150
|
+
|
|
151
|
+
const axiomLemmaTheoremStringOrConjecture = axiomLemmaTheoremOrConjecture.getString();
|
|
152
|
+
|
|
153
|
+
localContext.trace(`Unifying the '${axiomLemmaTheoremStringOrConjecture}' axiom, lemma, theorem or conjecture...`);
|
|
154
|
+
|
|
155
|
+
const substitutions = axiomLemmaTheoremOrConjecture.getSubstitutions(),
|
|
156
|
+
substitutionsUnified = substitutions.everySubstitution((substitution) => {
|
|
157
|
+
const substitutionUnified = this.unifySubstitution(substitution, localContext);
|
|
158
|
+
|
|
159
|
+
if (substitutionUnified) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
axiomLemmaTheoremOrConjectureUnified = substitutionsUnified; ///
|
|
165
|
+
|
|
166
|
+
if (axiomLemmaTheoremOrConjectureUnified) {
|
|
167
|
+
localContext.debug(`...unified the '${axiomLemmaTheoremStringOrConjecture}' axiom, lemma, theorem or conjecture.`);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return axiomLemmaTheoremOrConjectureUnified;
|
|
146
171
|
}
|
|
147
172
|
|
|
148
173
|
verify(assignments, stated, localContext) {
|
|
149
|
-
let verified;
|
|
174
|
+
let verified = false;
|
|
150
175
|
|
|
151
176
|
const frameString = this.string; ///
|
|
152
177
|
|
|
153
178
|
localContext.trace(`Verifying the '${frameString}' frame...`);
|
|
154
179
|
|
|
155
180
|
const declarationsVerified = this.declarations.every((declaration) => {
|
|
156
|
-
|
|
181
|
+
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
157
182
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
metavariablesVerified = this.metavariables.every((metavariable) => {
|
|
161
|
-
const metavariableVerified = metavariable.verify(localContext);
|
|
183
|
+
return declarationVerified;
|
|
184
|
+
});
|
|
162
185
|
|
|
163
|
-
|
|
164
|
-
|
|
186
|
+
if (declarationsVerified) {
|
|
187
|
+
const metavariablesVerified = this.metavariables.every((metavariable) => {
|
|
188
|
+
const metavariableVerified = metavariable.verify(localContext);
|
|
165
189
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
verifiedWhenDerived = false;
|
|
190
|
+
return metavariableVerified;
|
|
191
|
+
});
|
|
169
192
|
|
|
170
|
-
if (
|
|
171
|
-
verifiedWhenStated =
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
193
|
+
if (metavariablesVerified) {
|
|
194
|
+
let verifiedWhenStated = false,
|
|
195
|
+
verifiedWhenDerived = false;
|
|
196
|
+
|
|
197
|
+
if (stated) {
|
|
198
|
+
verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
|
|
199
|
+
} else {
|
|
200
|
+
verifiedWhenDerived = this.verifyWhenDerived(assignments, localContext);
|
|
201
|
+
}
|
|
175
202
|
|
|
176
|
-
|
|
177
|
-
|
|
203
|
+
if (verifiedWhenStated || verifiedWhenDerived) {
|
|
204
|
+
verified = true;
|
|
205
|
+
}
|
|
178
206
|
}
|
|
179
207
|
}
|
|
180
208
|
|
|
@@ -194,19 +222,18 @@ class Frame {
|
|
|
194
222
|
|
|
195
223
|
const declarationsLength = this.declarations.length;
|
|
196
224
|
|
|
197
|
-
if (declarationsLength
|
|
225
|
+
if (declarationsLength > 0) {
|
|
226
|
+
localContext.trace(`The '${frameString}' stated frame cannot have declarations.`);
|
|
227
|
+
} else {
|
|
198
228
|
const metavariablesLength = this.metavariables.length;
|
|
199
229
|
|
|
200
|
-
if (metavariablesLength
|
|
201
|
-
verifiedWhenStated = true;
|
|
202
|
-
} else {
|
|
230
|
+
if (metavariablesLength > 1) {
|
|
203
231
|
localContext.trace(`The '${frameString}' stated frame cannot have more than one metavariable.`);
|
|
232
|
+
} else {
|
|
233
|
+
verifiedWhenStated = true;
|
|
204
234
|
}
|
|
205
|
-
} else {
|
|
206
|
-
localContext.trace(`The '${frameString}' stated frame cannot have declarations.`);
|
|
207
235
|
}
|
|
208
236
|
|
|
209
|
-
|
|
210
237
|
if (verifiedWhenStated) {
|
|
211
238
|
localContext.debug(`...verified the '${frameString}' frame when stated.`);
|
|
212
239
|
}
|
package/src/judgement.js
CHANGED
|
@@ -38,21 +38,24 @@ class Judgement {
|
|
|
38
38
|
|
|
39
39
|
localContext.trace(`Verifying the '${judgementString}' judgement...`);
|
|
40
40
|
|
|
41
|
-
const frameVerified = this.frame.verify(assignments, stated, localContext)
|
|
42
|
-
declarationVerified = this.declaration.verify(assignments, stated, localContext);
|
|
41
|
+
const frameVerified = this.frame.verify(assignments, stated, localContext);
|
|
43
42
|
|
|
44
|
-
if (frameVerified
|
|
45
|
-
|
|
46
|
-
verifiedWhenDerived = false;
|
|
43
|
+
if (frameVerified) {
|
|
44
|
+
const declarationVerified = this.declaration.verify(assignments, stated, localContext);
|
|
47
45
|
|
|
48
|
-
if (
|
|
49
|
-
verifiedWhenStated =
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
if (declarationVerified) {
|
|
47
|
+
let verifiedWhenStated = false,
|
|
48
|
+
verifiedWhenDerived = false;
|
|
49
|
+
|
|
50
|
+
if (stated) {
|
|
51
|
+
verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
|
|
52
|
+
} else {
|
|
53
|
+
verifiedWhenDerived = this.verifyWhenDerived(assignments, localContext);
|
|
54
|
+
}
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
if (verifiedWhenStated || verifiedWhenDerived) {
|
|
57
|
+
verified = true;
|
|
58
|
+
}
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
|
|
@@ -88,21 +91,38 @@ class Judgement {
|
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
verifyWhenDerived(assignments, localContext) {
|
|
91
|
-
let verifiedWhenDerived;
|
|
94
|
+
let verifiedWhenDerived = false;
|
|
92
95
|
|
|
93
96
|
const judgementString = this.string; ///
|
|
94
97
|
|
|
95
98
|
localContext.trace(`Verifying the '${judgementString}' judgement when derived...`);
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
if (!verifiedWhenDerived) {
|
|
101
|
+
const reference = this.declaration.getReference(),
|
|
102
|
+
metaLemma = localContext.findMetaLemmaByReference(reference),
|
|
103
|
+
metatheorem = localContext.findMetatheoremByReference(reference),
|
|
104
|
+
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
105
|
+
|
|
106
|
+
if (metaLemmaMetatheorem !== null) {
|
|
107
|
+
const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, localContext);
|
|
108
|
+
|
|
109
|
+
verifiedWhenDerived = metaLemmaMetatheoremUnified; ///
|
|
110
|
+
}
|
|
111
|
+
}
|
|
101
112
|
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
113
|
+
if (!verifiedWhenDerived) {
|
|
114
|
+
const reference = this.declaration.getReference(),
|
|
115
|
+
axiom = localContext.findAxiomByReference(reference),
|
|
116
|
+
lemma = localContext.findLemmaByReference(reference),
|
|
117
|
+
theorem = localContext.findTheoremByReference(reference),
|
|
118
|
+
conjecture = localContext.findConjectureByReference(reference),
|
|
119
|
+
axiomLemmaTheoremOrConjecture = (axiom || lemma || theorem || conjecture);
|
|
104
120
|
|
|
105
|
-
|
|
121
|
+
if (axiomLemmaTheoremOrConjecture !== null) {
|
|
122
|
+
const axiomLemmaTheoremOrConjectureUnified = this.frame.unifyAxiomLemmaTheoremOrConjecture(axiomLemmaTheoremOrConjecture, localContext);
|
|
123
|
+
|
|
124
|
+
verifiedWhenDerived = axiomLemmaTheoremOrConjectureUnified; ///
|
|
125
|
+
}
|
|
106
126
|
}
|
|
107
127
|
|
|
108
128
|
if (verifiedWhenDerived) {
|
package/src/lemma.js
CHANGED
|
@@ -1,97 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import LocalContext from "./context/local";
|
|
5
4
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
6
5
|
|
|
7
6
|
import { EMPTY_STRING } from "./constants";
|
|
8
|
-
import { stringFromLabels } from "./topLevelAssertion";
|
|
9
|
-
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
10
|
-
|
|
11
|
-
const proofNodeQuery = nodeQuery("/lemma/proof"),
|
|
12
|
-
labelNodesQuery = nodesQuery("/lemma/label"),
|
|
13
|
-
consequentNodeQuery = nodeQuery("/lemma/consequent"),
|
|
14
|
-
suppositionNodesQuery = nodesQuery("/lemma/supposition");
|
|
15
7
|
|
|
16
8
|
class Lemma extends TopLevelAssertion {
|
|
17
9
|
verify() {
|
|
18
|
-
let verified
|
|
10
|
+
let verified;
|
|
19
11
|
|
|
20
|
-
const
|
|
12
|
+
const fileContext = this.getFileContext(),
|
|
13
|
+
lemmaString = this.string; ///
|
|
21
14
|
|
|
22
15
|
(lemmaString === EMPTY_STRING) ?
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
27
|
-
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
28
|
-
|
|
29
|
-
if (labelVVerifiedWhenDeclared) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
if (labelsVerifiedWhenDeclared) {
|
|
35
|
-
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
36
|
-
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
37
|
-
const suppositionVerified = supposition.verify(localContext);
|
|
38
|
-
|
|
39
|
-
if (suppositionVerified) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
if (suppositionsVerified) {
|
|
45
|
-
const consequentVerified = this.consequent.verify(localContext);
|
|
46
|
-
|
|
47
|
-
if (consequentVerified) {
|
|
48
|
-
const { Substitutions } = shim,
|
|
49
|
-
substitutions = Substitutions.fromNothing(),
|
|
50
|
-
proofVerified = this.proof.verify(substitutions, this.consequent, localContext);
|
|
16
|
+
fileContext.trace(`Verifying a lemma...`) :
|
|
17
|
+
fileContext.trace(`Verifying the '${lemmaString}' lemma...`);
|
|
51
18
|
|
|
52
|
-
|
|
53
|
-
const lemma = this; ///
|
|
19
|
+
verified = super.verify();
|
|
54
20
|
|
|
55
|
-
|
|
21
|
+
if (verified) {
|
|
22
|
+
const lemma = this; ///
|
|
56
23
|
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
24
|
+
fileContext.addLemma(lemma);
|
|
62
25
|
|
|
63
|
-
if (verified) {
|
|
64
26
|
(lemmaString === EMPTY_STRING) ?
|
|
65
|
-
|
|
66
|
-
|
|
27
|
+
fileContext.debug(`...verified a lemma.`) :
|
|
28
|
+
fileContext.debug(`...verified the '${lemmaString}' lemma.`);
|
|
67
29
|
}
|
|
68
30
|
|
|
69
31
|
return verified;
|
|
70
32
|
}
|
|
71
33
|
|
|
72
|
-
static fromLemmaNode(
|
|
73
|
-
const { Label, Proof, Supposition, Consequent } = shim,
|
|
74
|
-
proofNode = proofNodeQuery(lemmaNode),
|
|
75
|
-
labelNodes = labelNodesQuery(lemmaNode),
|
|
76
|
-
consequentNode = consequentNodeQuery(lemmaNode),
|
|
77
|
-
suppositionNodes = suppositionNodesQuery(lemmaNode),
|
|
78
|
-
labels = labelNodes.map((labelNode) => {
|
|
79
|
-
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
80
|
-
|
|
81
|
-
return label;
|
|
82
|
-
}),
|
|
83
|
-
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
84
|
-
const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
|
|
85
|
-
|
|
86
|
-
return supposition;
|
|
87
|
-
}),
|
|
88
|
-
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
89
|
-
string = stringFromLabels(labels),
|
|
90
|
-
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
91
|
-
lemma = new Lemma(fileContext, string, labels, suppositions, consequent, proof);
|
|
92
|
-
|
|
93
|
-
return lemma;
|
|
94
|
-
}
|
|
34
|
+
static fromLemmaNode(metaLemmaNode, fileContext) { return TopLevelAssertion.fromNode(Lemma, metaLemmaNode, fileContext); }
|
|
95
35
|
}
|
|
96
36
|
|
|
97
37
|
Object.assign(shim, {
|
package/src/metaLemma.js
CHANGED
|
@@ -1,106 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import LocalContext from "./context/local";
|
|
5
4
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
6
5
|
|
|
7
6
|
import { EMPTY_STRING } from "./constants";
|
|
8
|
-
import { stringFromLabels } from "./topLevelAssertion";
|
|
9
|
-
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
10
|
-
|
|
11
|
-
const proofNodeQuery = nodeQuery("/metaLemma/proof"),
|
|
12
|
-
labelNodesQuery = nodesQuery("/metaLemma/label"),
|
|
13
|
-
consequentNodeQuery = nodeQuery("/metaLemma/consequent"),
|
|
14
|
-
suppositionNodesQuery = nodesQuery("/metaLemma/supposition");
|
|
15
7
|
|
|
16
8
|
class MetaLemma extends TopLevelAssertion {
|
|
17
|
-
constructor(fileContext, string, labels, suppositions, consequent, proof, substitutions) {
|
|
18
|
-
super(fileContext, string, labels, suppositions, consequent, proof);
|
|
19
|
-
|
|
20
|
-
this.substitutions = substitutions;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
getSubstitutions() {
|
|
24
|
-
return this.substitutions;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
9
|
verify() {
|
|
28
|
-
let verified
|
|
10
|
+
let verified;
|
|
29
11
|
|
|
30
|
-
const
|
|
12
|
+
const fileContext = this.getFileContext(),
|
|
13
|
+
metaLemmaString = this.string; ///
|
|
31
14
|
|
|
32
15
|
(metaLemmaString === EMPTY_STRING) ?
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
37
|
-
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
38
|
-
|
|
39
|
-
if (labelVVerifiedWhenDeclared) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
if (labelsVerifiedWhenDeclared) {
|
|
45
|
-
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
46
|
-
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
47
|
-
const suppositionVerified = supposition.verify(localContext);
|
|
48
|
-
|
|
49
|
-
if (suppositionVerified) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
16
|
+
fileContext.trace(`Verifying a meta-lemma...`) :
|
|
17
|
+
fileContext.trace(`Verifying the '${metaLemmaString}' meta-lemma...`);
|
|
53
18
|
|
|
54
|
-
|
|
55
|
-
const consequentVerified = this.consequent.verify(localContext);
|
|
19
|
+
verified = super.verify();
|
|
56
20
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (proofVerified) {
|
|
61
|
-
const metaLemma = this; ///
|
|
21
|
+
if (verified) {
|
|
22
|
+
const metaLemma = this; ///
|
|
62
23
|
|
|
63
|
-
|
|
24
|
+
fileContext.addMetaLemma(metaLemma);
|
|
64
25
|
|
|
65
|
-
verified = true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (verified) {
|
|
72
26
|
(metaLemmaString === EMPTY_STRING) ?
|
|
73
|
-
|
|
74
|
-
|
|
27
|
+
fileContext.debug(`...verified a meta-lemma.`) :
|
|
28
|
+
fileContext.debug(`...verified the '${metaLemmaString}' meta-lemma.`);
|
|
75
29
|
}
|
|
76
30
|
|
|
77
31
|
return verified;
|
|
78
32
|
}
|
|
79
33
|
|
|
80
|
-
static fromMetaLemmaNode(metaLemmaNode, fileContext) {
|
|
81
|
-
const { Label, Proof, Consequent, Supposition, Substitutions } = shim,
|
|
82
|
-
proofNode = proofNodeQuery(metaLemmaNode),
|
|
83
|
-
labelNodes = labelNodesQuery(metaLemmaNode),
|
|
84
|
-
consequentNode = consequentNodeQuery(metaLemmaNode),
|
|
85
|
-
suppositionNodes = suppositionNodesQuery(metaLemmaNode),
|
|
86
|
-
labels = labelNodes.map((labelNode) => {
|
|
87
|
-
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
88
|
-
|
|
89
|
-
return label;
|
|
90
|
-
}),
|
|
91
|
-
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
92
|
-
const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
|
|
93
|
-
|
|
94
|
-
return supposition;
|
|
95
|
-
}),
|
|
96
|
-
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
97
|
-
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
98
|
-
string = stringFromLabels(labels),
|
|
99
|
-
substitutions = Substitutions.fromNothing(),
|
|
100
|
-
metaLemma = new MetaLemma(fileContext, string, labels, suppositions, consequent, proof, substitutions);
|
|
101
|
-
|
|
102
|
-
return metaLemma;
|
|
103
|
-
}
|
|
34
|
+
static fromMetaLemmaNode(metaLemmaNode, fileContext) { return TopLevelAssertion.fromNode(MetaLemma, metaLemmaNode, fileContext); }
|
|
104
35
|
}
|
|
105
36
|
|
|
106
37
|
Object.assign(shim, {
|
package/src/metatheorem.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import LocalContext from "./context/local";
|
|
5
4
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
6
5
|
|
|
7
|
-
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
6
|
import { stringFromLabels } from "./topLevelAssertion";
|
|
9
7
|
import { labelsFromJSON,
|
|
10
8
|
labelsToLabelsJSON,
|
|
@@ -15,66 +13,23 @@ import { labelsFromJSON,
|
|
|
15
13
|
suppositionsToSuppositionsJSON,
|
|
16
14
|
substitutionsToSubstitutionsJSON } from "./utilities/json";
|
|
17
15
|
|
|
18
|
-
const proofNodeQuery = nodeQuery("/metatheorem/proof"),
|
|
19
|
-
labelNodesQuery = nodesQuery("/metatheorem/label"),
|
|
20
|
-
consequentNodeQuery = nodeQuery("/metatheorem/consequent"),
|
|
21
|
-
suppositionNodesQuery = nodesQuery("/metatheorem/supposition");
|
|
22
|
-
|
|
23
16
|
class Metatheorem extends TopLevelAssertion {
|
|
24
|
-
constructor(fileContext, string, labels, suppositions, consequent, proof, substitutions) {
|
|
25
|
-
super(fileContext, string, labels, suppositions, consequent, proof);
|
|
26
|
-
|
|
27
|
-
this.substitutions = substitutions;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
getSubstitutions() {
|
|
31
|
-
return this.substitutions;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
17
|
verify() {
|
|
35
|
-
let verified
|
|
36
|
-
|
|
37
|
-
const metatheoremString = this.string; ///
|
|
38
|
-
|
|
39
|
-
this.fileContext.trace(`Verifying the '${metatheoremString}' metatheorem...`);
|
|
40
|
-
|
|
41
|
-
const labelsVerifiedWhenDeclared = this.labels.every((label) => {
|
|
42
|
-
const labelVVerifiedWhenDeclared = label.verifyWhenDeclared(this.fileContext);
|
|
18
|
+
let verified;
|
|
43
19
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
});
|
|
20
|
+
const fileContext = this.getFileContext(),
|
|
21
|
+
metatheoremString = this.string; ///
|
|
48
22
|
|
|
49
|
-
|
|
50
|
-
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
51
|
-
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
52
|
-
const suppositionVerified = supposition.verify(localContext);
|
|
23
|
+
fileContext.trace(`Verifying the '${metatheoremString}' metatheorem...`);
|
|
53
24
|
|
|
54
|
-
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
25
|
+
verified = super.verify();
|
|
58
26
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (consequentVerified) {
|
|
63
|
-
const proofVerified = this.proof.verify(this.substitutions, this.consequent, localContext);
|
|
64
|
-
|
|
65
|
-
if (proofVerified) {
|
|
66
|
-
const metatheorem = this; ///
|
|
27
|
+
if (verified) {
|
|
28
|
+
const metaTheorem = this; ///
|
|
67
29
|
|
|
68
|
-
|
|
30
|
+
fileContext.addMetatheorem(metaTheorem);
|
|
69
31
|
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (verified) {
|
|
77
|
-
this.fileContext.debug(`...verified the '${metatheoremString}' metatheorem.`);
|
|
32
|
+
fileContext.debug(`...verified the '${metatheoremString}' metatheorem.`);
|
|
78
33
|
}
|
|
79
34
|
|
|
80
35
|
return verified;
|
|
@@ -111,30 +66,7 @@ class Metatheorem extends TopLevelAssertion {
|
|
|
111
66
|
return topLevelAssertion;
|
|
112
67
|
}
|
|
113
68
|
|
|
114
|
-
static fromMetatheoremNode(metatheoremNode, fileContext) {
|
|
115
|
-
const { Label, Proof, Consequent, Supposition, Substitutions } = shim,
|
|
116
|
-
proofNode = proofNodeQuery(metatheoremNode),
|
|
117
|
-
labelNodes = labelNodesQuery(metatheoremNode),
|
|
118
|
-
consequentNode = consequentNodeQuery(metatheoremNode),
|
|
119
|
-
suppositionNodes = suppositionNodesQuery(metatheoremNode),
|
|
120
|
-
labels = labelNodes.map((labelNode) => {
|
|
121
|
-
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
122
|
-
|
|
123
|
-
return label;
|
|
124
|
-
}),
|
|
125
|
-
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
126
|
-
const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
|
|
127
|
-
|
|
128
|
-
return supposition;
|
|
129
|
-
}),
|
|
130
|
-
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
131
|
-
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
132
|
-
string = stringFromLabels(labels),
|
|
133
|
-
substitutions = Substitutions.fromNothing(),
|
|
134
|
-
metatheorem = new Metatheorem(fileContext, string, labels, suppositions, consequent, proof, substitutions);
|
|
135
|
-
|
|
136
|
-
return metatheorem;
|
|
137
|
-
}
|
|
69
|
+
static fromMetatheoremNode(metatheoremNode, fileContext) { return TopLevelAssertion.fromNode(Metatheorem, metatheoremNode, fileContext); }
|
|
138
70
|
}
|
|
139
71
|
|
|
140
72
|
Object.assign(shim, {
|