occam-verify-cli 0.0.1068 → 0.0.1069
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/bin/action/verify.js +3 -2
- package/lib/assertion/subproof.js +3 -3
- package/lib/axiom.js +11 -6
- package/lib/combinator.js +9 -9
- package/lib/conclusion.js +10 -7
- package/lib/conjecture.js +11 -6
- package/lib/consequent.js +10 -7
- package/lib/constructor.js +9 -9
- package/lib/context/file.js +34 -126
- package/lib/context/local.js +16 -5
- package/lib/context/release.js +2 -3
- package/lib/declaration.js +50 -43
- package/lib/equivalence.js +2 -2
- package/lib/frame.js +100 -80
- package/lib/index.js +22 -6
- package/lib/judgement.js +3 -3
- package/lib/label.js +12 -8
- package/lib/lemma.js +12 -12
- package/lib/metaLemma.js +120 -8
- package/lib/metatheorem.js +145 -9
- package/lib/metavariable.js +39 -22
- package/lib/mixins/statement/qualified/unify.js +6 -10
- package/lib/mixins/statement/unify.js +3 -3
- package/lib/mixins/term/unify.js +2 -2
- package/lib/premise.js +12 -8
- package/lib/reference.js +7 -9
- package/lib/rule.js +24 -39
- package/lib/ruleNames.js +1 -5
- package/lib/statement/unqualified.js +9 -8
- package/lib/statement.js +4 -4
- package/lib/substitution/frameForMetavariable.js +30 -26
- package/lib/substitution/statementForMetavariable.js +44 -26
- package/lib/substitution/termForVariable.js +33 -37
- package/lib/substitution.js +24 -21
- package/lib/substitutions.js +7 -1
- package/lib/supposition.js +12 -8
- package/lib/term.js +6 -11
- package/lib/theorem.js +11 -6
- package/lib/topLevelAssertion.js +24 -42
- package/lib/type.js +5 -12
- package/lib/unifier/metaLevel.js +3 -3
- package/lib/unifier/metavariable.js +6 -6
- package/lib/unifier/statementWithCombinator.js +16 -16
- package/lib/unifier/termWithConstructor.js +7 -7
- package/lib/utilities/brackets.js +10 -10
- package/lib/utilities/json.js +493 -0
- package/lib/utilities/node.js +15 -22
- package/lib/utilities/release.js +53 -0
- package/lib/utilities/releaseContext.js +4 -15
- package/lib/utilities/tokens.js +7 -7
- package/lib/variable.js +6 -11
- package/lib/verifier/topLevel.js +5 -5
- package/package.json +1 -1
- package/src/assertion/subproof.js +2 -3
- package/src/axiom.js +14 -6
- package/src/combinator.js +12 -13
- package/src/conclusion.js +12 -9
- package/src/conjecture.js +14 -6
- package/src/consequent.js +12 -9
- package/src/constructor.js +11 -13
- package/src/context/file.js +94 -202
- package/src/context/local.js +8 -6
- package/src/context/release.js +2 -3
- package/src/declaration.js +72 -44
- package/src/equivalence.js +2 -2
- package/src/frame.js +111 -86
- package/src/index.js +17 -1
- package/src/judgement.js +2 -2
- package/src/label.js +15 -10
- package/src/lemma.js +17 -10
- package/src/metaLemma.js +102 -1
- package/src/metatheorem.js +143 -2
- package/src/metavariable.js +50 -30
- package/src/mixins/statement/qualified/unify.js +7 -19
- package/src/mixins/statement/unify.js +2 -2
- package/src/mixins/term/unify.js +1 -1
- package/src/premise.js +18 -10
- package/src/reference.js +7 -11
- package/src/rule.js +33 -57
- package/src/ruleNames.js +0 -1
- package/src/statement/unqualified.js +10 -10
- package/src/statement.js +3 -2
- package/src/substitution/frameForMetavariable.js +39 -33
- package/src/substitution/statementForMetavariable.js +64 -31
- package/src/substitution/termForVariable.js +47 -37
- package/src/substitution.js +18 -16
- package/src/substitutions.js +2 -0
- package/src/supposition.js +18 -10
- package/src/term.js +5 -15
- package/src/theorem.js +14 -6
- package/src/topLevelAssertion.js +38 -64
- package/src/type.js +5 -20
- package/src/unifier/metaLevel.js +2 -2
- package/src/unifier/metavariable.js +5 -5
- package/src/unifier/statementWithCombinator.js +18 -18
- package/src/unifier/termWithConstructor.js +7 -7
- package/src/utilities/brackets.js +5 -5
- package/src/utilities/json.js +551 -0
- package/src/utilities/node.js +15 -26
- package/src/{verify → utilities}/release.js +5 -1
- package/src/utilities/releaseContext.js +2 -2
- package/src/utilities/tokens.js +10 -7
- package/src/variable.js +4 -14
- package/src/verifier/topLevel.js +6 -4
- package/lib/argument.js +0 -106
- package/lib/metaTypes.js +0 -19
- package/lib/unify/statementWithSttaemetnGivenEquivalences.js +0 -45
- package/lib/verify/metaLemma.js +0 -49
- package/lib/verify/metatheorem.js +0 -48
- package/lib/verify/release.js +0 -50
- package/src/argument.js +0 -79
- package/src/metaTypes.js +0 -11
- package/src/unify/statementWithSttaemetnGivenEquivalences.js +0 -51
- package/src/verify/metaLemma.js +0 -72
- package/src/verify/metatheorem.js +0 -67
package/src/frame.js
CHANGED
|
@@ -41,14 +41,18 @@ class Frame {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
getMetavariable() {
|
|
44
|
-
let metavariable;
|
|
44
|
+
let metavariable = null;
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const declarationsLength = this.declarations.length;
|
|
47
|
+
|
|
48
|
+
if (declarationsLength === 0) {
|
|
49
|
+
const metavariablesLength = this.metavariables.length;
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
if (metavariablesLength === 1) {
|
|
52
|
+
const firstMetavariable = first(this.metavariables);
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
metavariable = firstMetavariable; ///
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
return metavariable;
|
|
@@ -57,65 +61,91 @@ class Frame {
|
|
|
57
61
|
getMetavariableNode() {
|
|
58
62
|
let metavariableNode = null;
|
|
59
63
|
|
|
60
|
-
const
|
|
64
|
+
const metavariable = this.getMetavariable();
|
|
61
65
|
|
|
62
|
-
if (
|
|
63
|
-
|
|
66
|
+
if (metavariable !== null) {
|
|
67
|
+
metavariableNode = metavariable.getNode();
|
|
68
|
+
}
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
metavariable = firstMetavariable; ///
|
|
70
|
+
return metavariableNode;
|
|
71
|
+
}
|
|
68
72
|
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
matchFrameNode(frameNode) {
|
|
74
|
+
const frameNodeMatches = this.node.match(frameNode);
|
|
75
|
+
|
|
76
|
+
return frameNodeMatches;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
matchMetavariableName(metavariableName) {
|
|
80
|
+
let metavariableNameMatches = false;
|
|
81
|
+
|
|
82
|
+
const metavariable = this.getMetavariable();
|
|
83
|
+
|
|
84
|
+
if (metavariable !== null) {
|
|
85
|
+
metavariableNameMatches = metavariable.matchMetavariableName(metavariableName);
|
|
71
86
|
}
|
|
72
87
|
|
|
73
|
-
return
|
|
88
|
+
return metavariableNameMatches;
|
|
74
89
|
}
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
91
|
+
unifySubstitution(substitution, localContext) {
|
|
92
|
+
let substitutionUnified = false;
|
|
93
|
+
|
|
94
|
+
const substitutionString = substitution.getString();
|
|
95
|
+
|
|
96
|
+
localContext.trace(`Unifying the '${substitutionString}' substitution...`)
|
|
97
|
+
|
|
98
|
+
if (!substitutionUnified) {
|
|
99
|
+
substitutionUnified = this.declarations.some((declaration) => {
|
|
100
|
+
const substitutionUnified = declaration.unifySubstitution(substitution, localContext);
|
|
101
|
+
|
|
102
|
+
if (substitutionUnified) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!substitutionUnified) {
|
|
109
|
+
substitutionUnified = this.metavariables.some((metavariable) => {
|
|
110
|
+
const substitutionUnified = metavariable.unifySubstitution(substitution, localContext);
|
|
111
|
+
|
|
112
|
+
if (substitutionUnified) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (substitutionUnified) {
|
|
119
|
+
localContext.debug(`...unified the '${substitutionString}' substitution...`)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return substitutionUnified;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, localContext) {
|
|
126
|
+
let metaLemmaOrMetaTheoremUnified;
|
|
127
|
+
|
|
128
|
+
const metaLemmaMetatheoremString = metaLemmaMetatheorem.getString();
|
|
129
|
+
|
|
130
|
+
localContext.trace(`Unifying the '${metaLemmaMetatheoremString}' metatheorem or meta-lemma...`);
|
|
131
|
+
|
|
132
|
+
const substitutions = metaLemmaMetatheorem.getSubstitutions(),
|
|
133
|
+
substitutionsUnified = substitutions.everySubstitution((substitution) => {
|
|
134
|
+
const substitutionUnified = this.unifySubstitution(substitution, localContext);
|
|
135
|
+
|
|
136
|
+
if (substitutionUnified) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
metaLemmaOrMetaTheoremUnified = substitutionsUnified; ///
|
|
142
|
+
|
|
143
|
+
if (metaLemmaOrMetaTheoremUnified) {
|
|
144
|
+
localContext.debug(`...unified the '${metaLemmaMetatheoremString}' metatheorem or meta-lemma.`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return metaLemmaOrMetaTheoremUnified;
|
|
148
|
+
}
|
|
119
149
|
|
|
120
150
|
verify(assignments, stated, localContext) {
|
|
121
151
|
let verified;
|
|
@@ -124,17 +154,30 @@ class Frame {
|
|
|
124
154
|
|
|
125
155
|
localContext.trace(`Verifying the '${frameString}' frame...`);
|
|
126
156
|
|
|
127
|
-
|
|
128
|
-
|
|
157
|
+
const declarationsVerified = this.declarations.every((declaration) => {
|
|
158
|
+
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
129
159
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
160
|
+
return declarationVerified;
|
|
161
|
+
}),
|
|
162
|
+
metavariablesVerified = this.metavariables.every((metavariable) => {
|
|
163
|
+
const metavariableVerified = metavariable.verify(localContext);
|
|
164
|
+
|
|
165
|
+
return metavariableVerified;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
if (declarationsVerified && metavariablesVerified) {
|
|
169
|
+
let verifiedWhenStated = false,
|
|
170
|
+
verifiedWhenDerived = false;
|
|
171
|
+
|
|
172
|
+
if (stated) {
|
|
173
|
+
verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
|
|
174
|
+
} else {
|
|
175
|
+
verifiedWhenDerived = this.verifyWhenDerived(assignments, localContext);
|
|
176
|
+
}
|
|
135
177
|
|
|
136
|
-
|
|
137
|
-
|
|
178
|
+
if (verifiedWhenStated || verifiedWhenDerived) {
|
|
179
|
+
verified = true;
|
|
180
|
+
}
|
|
138
181
|
}
|
|
139
182
|
|
|
140
183
|
if (verified) {
|
|
@@ -157,11 +200,7 @@ class Frame {
|
|
|
157
200
|
const metavariablesLength = this.metavariables.length;
|
|
158
201
|
|
|
159
202
|
if (metavariablesLength === 1) {
|
|
160
|
-
|
|
161
|
-
metavariable = firstMetavariable, ///
|
|
162
|
-
metavariableVerified = metavariable.verify(localContext);
|
|
163
|
-
|
|
164
|
-
verifiedWhenStated = metavariableVerified; ///
|
|
203
|
+
verifiedWhenStated = true;
|
|
165
204
|
} else {
|
|
166
205
|
localContext.trace(`The '${frameString}' stated frame cannot have more than one metavariable.`);
|
|
167
206
|
}
|
|
@@ -184,21 +223,7 @@ class Frame {
|
|
|
184
223
|
|
|
185
224
|
localContext.trace(`Verifying the '${frameString}' frame when derived...`);
|
|
186
225
|
|
|
187
|
-
|
|
188
|
-
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
189
|
-
|
|
190
|
-
return declarationVerified;
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
if (declarationsVerified) {
|
|
194
|
-
const metavariablesVerified = this.metavariables.every((metavariable) => {
|
|
195
|
-
const metavariableVerified = metavariable.verify(localContext);
|
|
196
|
-
|
|
197
|
-
return metavariableVerified;
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
verifiedWhenDerived = metavariablesVerified; ///
|
|
201
|
-
}
|
|
226
|
+
verifiedWhenDerived = true;
|
|
202
227
|
|
|
203
228
|
if (verifiedWhenDerived) {
|
|
204
229
|
localContext.debug(`...verified the '${frameString}' frame when derived.`);
|
package/src/index.js
CHANGED
|
@@ -2,12 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
import Type from "./type";
|
|
4
4
|
import Term from "./term";
|
|
5
|
+
import Rule from "./rule";
|
|
6
|
+
import Label from "./label";
|
|
7
|
+
import Axiom from "./axiom";
|
|
8
|
+
import Lemma from "./lemma";
|
|
9
|
+
import Premise from "./premise";
|
|
10
|
+
import Theorem from "./theorem";
|
|
5
11
|
import MetaType from "./metaType";
|
|
12
|
+
import Variable from "./variable";
|
|
6
13
|
import Statement from "./statement";
|
|
7
14
|
import ProofStep from "./proofStep";
|
|
15
|
+
import Consequent from "./consequent";
|
|
16
|
+
import Conjecture from "./conjecture";
|
|
17
|
+
import Combinator from "./combinator";
|
|
18
|
+
import Conclusion from "./conclusion";
|
|
19
|
+
import Constructor from "./constructor";
|
|
20
|
+
import Supposition from "./supposition";
|
|
21
|
+
import Metatheorem from "./metatheorem";
|
|
22
|
+
import Metavariable from "./metavariable";
|
|
23
|
+
import UnqualifiedStatement from "./statement/unqualified";
|
|
8
24
|
|
|
9
25
|
export { default as Log } from "./log";
|
|
10
|
-
export { default as verifyRelease } from "./verify/release";
|
|
11
26
|
export { default as ReleaseContext } from "./context/release";
|
|
27
|
+
export { default as releaseUtilities } from "./utilities/release";
|
|
12
28
|
export { default as customGrammarUtilities } from "./utilities/customGrammar";
|
|
13
29
|
export { default as releaseContextUtilities } from "./utilities/releaseContext";
|
package/src/judgement.js
CHANGED
|
@@ -96,12 +96,12 @@ export default class Judgement {
|
|
|
96
96
|
localContext.trace(`Verifying the '${judgementString}' judgement when derived...`);
|
|
97
97
|
|
|
98
98
|
const reference = this.declaration.getReference(),
|
|
99
|
-
metatheorem = localContext.findMetatheoremByReference(reference),
|
|
100
99
|
metaLemma = localContext.findMetaLemmaByReference(reference),
|
|
100
|
+
metatheorem = localContext.findMetatheoremByReference(reference),
|
|
101
101
|
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
102
102
|
|
|
103
103
|
if (metaLemmaMetatheorem !== null) {
|
|
104
|
-
const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem);
|
|
104
|
+
const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, localContext);
|
|
105
105
|
|
|
106
106
|
verifiedWhenDerived = metaLemmaMetatheoremUnified; ///
|
|
107
107
|
}
|
package/src/label.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
import LocalContext from "./context/local";
|
|
3
5
|
import Metavariable from "./metavariable";
|
|
4
6
|
|
|
5
7
|
import { nodeQuery } from "./utilities/query";
|
|
8
|
+
import { metavariableFromJSON, metavariableToMetavariableJSON } from "./utilities/json";
|
|
6
9
|
|
|
7
10
|
const metavariableNodeQuery = nodeQuery("//label/metavariable");
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
class Label {
|
|
10
13
|
constructor(metavariable) {
|
|
11
14
|
this.metavariable = metavariable;
|
|
12
15
|
}
|
|
@@ -43,7 +46,7 @@ export default class Label {
|
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
toJSON() {
|
|
46
|
-
const metavariableJSON = this.metavariable
|
|
49
|
+
const metavariableJSON = metavariableToMetavariableJSON(this.metavariable),
|
|
47
50
|
metavariable = metavariableJSON, ///
|
|
48
51
|
json = {
|
|
49
52
|
metavariable
|
|
@@ -53,22 +56,24 @@ export default class Label {
|
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
static fromJSON(json, fileContext) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
json = metavariable; ///
|
|
59
|
-
|
|
60
|
-
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
61
|
-
|
|
62
|
-
const label = new Label(metavariable);
|
|
59
|
+
const metavariable = metavariableFromJSON(json, fileContext),
|
|
60
|
+
label = new Label(metavariable);
|
|
63
61
|
|
|
64
62
|
return label;
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
static fromLabelNode(labelNode, fileContext) {
|
|
68
66
|
const metavariableNode = metavariableNodeQuery(labelNode),
|
|
69
|
-
|
|
67
|
+
localContext = LocalContext.fromFileContext(fileContext),
|
|
68
|
+
metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
|
|
70
69
|
label = new Label(metavariable);
|
|
71
70
|
|
|
72
71
|
return label;
|
|
73
72
|
}
|
|
74
73
|
}
|
|
74
|
+
|
|
75
|
+
Object.assign(shim, {
|
|
76
|
+
Label
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export default Label;
|
package/src/lemma.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
3
4
|
import Label from "./label";
|
|
4
5
|
import Proof from "./proof";
|
|
5
6
|
import Consequent from "./consequent";
|
|
@@ -8,23 +9,24 @@ import LocalContext from "./context/local";
|
|
|
8
9
|
import Substitutions from "./substitutions";
|
|
9
10
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
10
11
|
|
|
12
|
+
import { EMPTY_STRING } from "./constants";
|
|
13
|
+
import { stringFromLabels } from "./topLevelAssertion";
|
|
11
14
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
12
|
-
import { labelsStringFromLabels } from "./topLevelAssertion";
|
|
13
15
|
|
|
14
16
|
const proofNodeQuery = nodeQuery("/lemma/proof"),
|
|
15
17
|
labelNodesQuery = nodesQuery("/lemma/label"),
|
|
16
18
|
consequentNodeQuery = nodeQuery("/lemma/consequent"),
|
|
17
19
|
suppositionNodesQuery = nodesQuery("/lemma/supposition");
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
class Lemma extends TopLevelAssertion {
|
|
20
22
|
verify() {
|
|
21
23
|
let verified = false;
|
|
22
24
|
|
|
23
|
-
const
|
|
25
|
+
const lemmaString = this.string; ///
|
|
24
26
|
|
|
25
|
-
(
|
|
27
|
+
(lemmaString === EMPTY_STRING) ?
|
|
26
28
|
this.fileContext.trace(`Verifying a lemma...`) :
|
|
27
|
-
this.fileContext.trace(`Verifying the '${
|
|
29
|
+
this.fileContext.trace(`Verifying the '${lemmaString}' lemma...`);
|
|
28
30
|
|
|
29
31
|
const labelsVerifiedAtTopLevel = this.labels.every((label) => {
|
|
30
32
|
const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
|
|
@@ -63,16 +65,14 @@ export default class Lemma extends TopLevelAssertion {
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
if (verified) {
|
|
66
|
-
(
|
|
68
|
+
(lemmaString === EMPTY_STRING) ?
|
|
67
69
|
this.fileContext.debug(`...verified a lemma.`) :
|
|
68
|
-
this.fileContext.debug(`...verified the '${
|
|
70
|
+
this.fileContext.debug(`...verified the '${lemmaString}' lemma.`);
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
return verified;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
static fromJSON(json, fileContext) { return TopLevelAssertion.fromJSON(Lemma, json, fileContext); }
|
|
75
|
-
|
|
76
76
|
static fromLemmaNode(lemmaNode, fileContext) {
|
|
77
77
|
const proofNode = proofNodeQuery(lemmaNode),
|
|
78
78
|
labelNodes = labelNodesQuery(lemmaNode),
|
|
@@ -89,9 +89,16 @@ export default class Lemma extends TopLevelAssertion {
|
|
|
89
89
|
return supposition;
|
|
90
90
|
}),
|
|
91
91
|
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
92
|
+
string = stringFromLabels(labels),
|
|
92
93
|
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
93
|
-
lemma = new Lemma(fileContext, labels, suppositions, consequent, proof);
|
|
94
|
+
lemma = new Lemma(fileContext, string, labels, suppositions, consequent, proof);
|
|
94
95
|
|
|
95
96
|
return lemma;
|
|
96
97
|
}
|
|
97
98
|
}
|
|
99
|
+
|
|
100
|
+
Object.assign(shim, {
|
|
101
|
+
Lemma
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export default Lemma;
|
package/src/metaLemma.js
CHANGED
|
@@ -1,7 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Label from "./label";
|
|
4
|
+
import Proof from "./proof";
|
|
5
|
+
import Consequent from "./consequent";
|
|
6
|
+
import Supposition from "./supposition";
|
|
7
|
+
import LocalContext from "./context/local";
|
|
8
|
+
import Substitutions from "./substitutions";
|
|
3
9
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
4
10
|
|
|
11
|
+
import { EMPTY_STRING } from "./constants";
|
|
12
|
+
import { stringFromLabels } from "./topLevelAssertion";
|
|
13
|
+
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
14
|
+
|
|
15
|
+
const proofNodeQuery = nodeQuery("/metaLemma/proof"),
|
|
16
|
+
labelNodesQuery = nodesQuery("/metaLemma/label"),
|
|
17
|
+
consequentNodeQuery = nodeQuery("/metaLemma/consequent"),
|
|
18
|
+
suppositionNodesQuery = nodesQuery("/metaLemma/supposition");
|
|
19
|
+
|
|
5
20
|
export default class MetaLemma extends TopLevelAssertion {
|
|
6
|
-
|
|
21
|
+
constructor(fileContext, string, labels, suppositions, consequent, proof, substitutions) {
|
|
22
|
+
super(fileContext, string, labels, suppositions, consequent, proof);
|
|
23
|
+
|
|
24
|
+
this.substitutions = substitutions;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getSubstitutions() {
|
|
28
|
+
return this.substitutions;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
verify() {
|
|
32
|
+
let verified = false;
|
|
33
|
+
|
|
34
|
+
const metaLemmaString = this.string; ///
|
|
35
|
+
|
|
36
|
+
(metaLemmaString === EMPTY_STRING) ?
|
|
37
|
+
this.fileContext.trace(`Verifying a meta-lemma...`) :
|
|
38
|
+
this.fileContext.trace(`Verifying the '${metaLemmaString}' meta-lemma...`);
|
|
39
|
+
|
|
40
|
+
const labelsVerifiedAtTopLevel = this.labels.every((label) => {
|
|
41
|
+
const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
|
|
42
|
+
|
|
43
|
+
if (labelVVerifiedAtTopLevel) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (labelsVerifiedAtTopLevel) {
|
|
49
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
50
|
+
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
51
|
+
const suppositionVerified = supposition.verify(localContext);
|
|
52
|
+
|
|
53
|
+
if (suppositionVerified) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (suppositionsVerified) {
|
|
59
|
+
const consequentVerified = this.consequent.verify(localContext);
|
|
60
|
+
|
|
61
|
+
if (consequentVerified) {
|
|
62
|
+
const proofVerified = this.proof.verify(this.substitutions, this.consequent, localContext);
|
|
63
|
+
|
|
64
|
+
if (proofVerified) {
|
|
65
|
+
const metaLemma = this; ///
|
|
66
|
+
|
|
67
|
+
this.fileContext.addMetaLemma(metaLemma);
|
|
68
|
+
|
|
69
|
+
verified = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (verified) {
|
|
76
|
+
(metaLemmaString === EMPTY_STRING) ?
|
|
77
|
+
this.fileContext.debug(`...verified a meta-lemma.`) :
|
|
78
|
+
this.fileContext.debug(`...verified the '${metaLemmaString}' meta-lemma.`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return verified;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static fromMetaLemmaNode(metaLemmaNode, fileContext) {
|
|
85
|
+
const proofNode = proofNodeQuery(metaLemmaNode),
|
|
86
|
+
labelNodes = labelNodesQuery(metaLemmaNode),
|
|
87
|
+
consequentNode = consequentNodeQuery(metaLemmaNode),
|
|
88
|
+
suppositionNodes = suppositionNodesQuery(metaLemmaNode),
|
|
89
|
+
labels = labelNodes.map((labelNode) => {
|
|
90
|
+
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
91
|
+
|
|
92
|
+
return label;
|
|
93
|
+
}),
|
|
94
|
+
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
95
|
+
const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
|
|
96
|
+
|
|
97
|
+
return supposition;
|
|
98
|
+
}),
|
|
99
|
+
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
100
|
+
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
101
|
+
string = stringFromLabels(labels),
|
|
102
|
+
substitutions = Substitutions.fromNothing(),
|
|
103
|
+
metaLemma = new MetaLemma(fileContext, string, labels, suppositions, consequent, proof, substitutions);
|
|
104
|
+
|
|
105
|
+
return metaLemma;
|
|
106
|
+
}
|
|
7
107
|
}
|
|
108
|
+
|
package/src/metatheorem.js
CHANGED
|
@@ -1,7 +1,148 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
import Label from "./label";
|
|
5
|
+
import Proof from "./proof";
|
|
6
|
+
import Consequent from "./consequent";
|
|
7
|
+
import Supposition from "./supposition";
|
|
8
|
+
import LocalContext from "./context/local";
|
|
9
|
+
import Substitutions from "./substitutions";
|
|
3
10
|
import TopLevelAssertion from "./topLevelAssertion";
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
|
|
12
|
+
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
13
|
+
import { stringFromLabels } from "./topLevelAssertion";
|
|
14
|
+
import { labelsFromJSON,
|
|
15
|
+
labelsToLabelsJSON,
|
|
16
|
+
consequentFromJSON,
|
|
17
|
+
suppositionsFromJSON,
|
|
18
|
+
substitutionsFromJSON,
|
|
19
|
+
consequentToConsequentJSON,
|
|
20
|
+
suppositionsToSuppositionsJSON,
|
|
21
|
+
substitutionsToSubstitutionsJSON } from "./utilities/json";
|
|
22
|
+
|
|
23
|
+
const proofNodeQuery = nodeQuery("/metatheorem/proof"),
|
|
24
|
+
labelNodesQuery = nodesQuery("/metatheorem/label"),
|
|
25
|
+
consequentNodeQuery = nodeQuery("/metatheorem/consequent"),
|
|
26
|
+
suppositionNodesQuery = nodesQuery("/metatheorem/supposition");
|
|
27
|
+
|
|
28
|
+
class Metatheorem extends TopLevelAssertion {
|
|
29
|
+
constructor(fileContext, string, labels, suppositions, consequent, proof, substitutions) {
|
|
30
|
+
super(fileContext, string, labels, suppositions, consequent, proof);
|
|
31
|
+
|
|
32
|
+
this.substitutions = substitutions;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getSubstitutions() {
|
|
36
|
+
return this.substitutions;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
verify() {
|
|
40
|
+
let verified = false;
|
|
41
|
+
|
|
42
|
+
const metatheoremString = this.string; ///
|
|
43
|
+
|
|
44
|
+
this.fileContext.trace(`Verifying the '${metatheoremString}' metatheorem...`);
|
|
45
|
+
|
|
46
|
+
const labelsVerifiedAtTopLevel = this.labels.every((label) => {
|
|
47
|
+
const labelVVerifiedAtTopLevel = label.verifyAtTopLevel(this.fileContext);
|
|
48
|
+
|
|
49
|
+
if (labelVVerifiedAtTopLevel) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (labelsVerifiedAtTopLevel) {
|
|
55
|
+
const localContext = LocalContext.fromFileContext(this.fileContext),
|
|
56
|
+
suppositionsVerified = this.suppositions.every((supposition) => {
|
|
57
|
+
const suppositionVerified = supposition.verify(localContext);
|
|
58
|
+
|
|
59
|
+
if (suppositionVerified) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (suppositionsVerified) {
|
|
65
|
+
const consequentVerified = this.consequent.verify(localContext);
|
|
66
|
+
|
|
67
|
+
if (consequentVerified) {
|
|
68
|
+
const proofVerified = this.proof.verify(this.substitutions, this.consequent, localContext);
|
|
69
|
+
|
|
70
|
+
if (proofVerified) {
|
|
71
|
+
const metatheorem = this; ///
|
|
72
|
+
|
|
73
|
+
this.fileContext.addMetatheorem(metatheorem);
|
|
74
|
+
|
|
75
|
+
verified = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (verified) {
|
|
82
|
+
this.fileContext.debug(`...verified the '${metatheoremString}' metatheorem.`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return verified;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
toJSON() {
|
|
89
|
+
const labelsJSON = labelsToLabelsJSON(this.labels),
|
|
90
|
+
consequentJSON = consequentToConsequentJSON(this.consequent),
|
|
91
|
+
suppositionsJSON = suppositionsToSuppositionsJSON(this.suppositions),
|
|
92
|
+
substitutionsJSON = substitutionsToSubstitutionsJSON(this.substitutions),
|
|
93
|
+
labels = labelsJSON, ///
|
|
94
|
+
consequent = consequentJSON, ///
|
|
95
|
+
suppositions = suppositionsJSON, ///
|
|
96
|
+
substitutions = substitutionsJSON, ///
|
|
97
|
+
json = {
|
|
98
|
+
labels,
|
|
99
|
+
consequent,
|
|
100
|
+
suppositions,
|
|
101
|
+
substitutions
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return json;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static fromJSON(json, fileContext) {
|
|
108
|
+
const labels = labelsFromJSON(json, fileContext),
|
|
109
|
+
consequent = consequentFromJSON(json, fileContext),
|
|
110
|
+
suppositions = suppositionsFromJSON(json, fileContext),
|
|
111
|
+
substitutions = substitutionsFromJSON(json, fileContext),
|
|
112
|
+
string = stringFromLabels(labels),
|
|
113
|
+
proof = null,
|
|
114
|
+
topLevelAssertion = new Metatheorem(fileContext, string, labels, suppositions, consequent, proof, substitutions);
|
|
115
|
+
|
|
116
|
+
return topLevelAssertion;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static fromMetatheoremNode(metatheoremNode, fileContext) {
|
|
120
|
+
const proofNode = proofNodeQuery(metatheoremNode),
|
|
121
|
+
labelNodes = labelNodesQuery(metatheoremNode),
|
|
122
|
+
consequentNode = consequentNodeQuery(metatheoremNode),
|
|
123
|
+
suppositionNodes = suppositionNodesQuery(metatheoremNode),
|
|
124
|
+
labels = labelNodes.map((labelNode) => {
|
|
125
|
+
const label = Label.fromLabelNode(labelNode, fileContext);
|
|
126
|
+
|
|
127
|
+
return label;
|
|
128
|
+
}),
|
|
129
|
+
suppositions = suppositionNodes.map((suppositionNode) => {
|
|
130
|
+
const supposition = Supposition.fromSuppositionNode(suppositionNode, fileContext);
|
|
131
|
+
|
|
132
|
+
return supposition;
|
|
133
|
+
}),
|
|
134
|
+
consequent = Consequent.fromConsequentNode(consequentNode, fileContext),
|
|
135
|
+
proof = Proof.fromProofNode(proofNode, fileContext),
|
|
136
|
+
string = stringFromLabels(labels),
|
|
137
|
+
substitutions = Substitutions.fromNothing(),
|
|
138
|
+
metatheorem = new Metatheorem(fileContext, string, labels, suppositions, consequent, proof, substitutions);
|
|
139
|
+
|
|
140
|
+
return metatheorem;
|
|
141
|
+
}
|
|
7
142
|
}
|
|
143
|
+
|
|
144
|
+
Object.assign(shim, {
|
|
145
|
+
Metatheorem
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
export default Metatheorem;
|