occam-verify-cli 0.0.1067 → 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/contained.js +2 -2
- package/lib/assertion/defined.js +2 -2
- package/lib/assertion/subproof.js +3 -3
- package/lib/assignment/judgement.js +3 -3
- package/lib/axiom.js +11 -6
- package/lib/combinator.js +9 -9
- package/lib/conclusion.js +13 -10
- package/lib/conjecture.js +11 -6
- package/lib/consequent.js +13 -10
- 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 +96 -2
- package/lib/equivalence.js +2 -2
- package/lib/frame.js +179 -98
- package/lib/index.js +22 -6
- package/lib/judgement.js +84 -5
- package/lib/label.js +12 -8
- package/lib/lemma.js +12 -12
- package/lib/metaLemma.js +120 -8
- package/lib/metaType.js +24 -3
- package/lib/metatheorem.js +145 -9
- package/lib/metavariable.js +128 -43
- package/lib/mixins/statement/qualified/unify.js +6 -10
- package/lib/mixins/statement/unify.js +4 -19
- package/lib/mixins/statement/verify.js +13 -13
- package/lib/mixins/term/unify.js +2 -2
- package/lib/premise.js +21 -13
- package/lib/reference.js +17 -17
- package/lib/rule.js +28 -40
- package/lib/statement/unqualified.js +34 -9
- package/lib/statement.js +7 -5
- package/lib/substitution/frameForMetavariable.js +75 -70
- package/lib/substitution/statementForMetavariable.js +83 -42
- package/lib/substitution/termForVariable.js +65 -68
- package/lib/substitution.js +46 -43
- package/lib/substitutions.js +52 -40
- package/lib/supposition.js +15 -11
- 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/intrinsicLevel.js +4 -4
- package/lib/unifier/metaLevel.js +11 -7
- 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 +26 -19
- package/lib/utilities/release.js +53 -0
- package/lib/utilities/releaseContext.js +4 -15
- package/lib/utilities/tokens.js +8 -1
- package/lib/variable.js +14 -15
- package/lib/verifier/topLevel.js +5 -5
- package/package.json +1 -1
- package/src/assertion/contained.js +1 -1
- package/src/assertion/defined.js +1 -1
- package/src/assertion/subproof.js +2 -3
- package/src/assignment/judgement.js +3 -4
- package/src/axiom.js +14 -6
- package/src/combinator.js +12 -13
- package/src/conclusion.js +16 -13
- package/src/conjecture.js +14 -6
- package/src/consequent.js +16 -13
- 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 +126 -45
- package/src/equivalence.js +2 -2
- package/src/frame.js +225 -141
- package/src/index.js +17 -1
- package/src/judgement.js +109 -3
- package/src/label.js +15 -10
- package/src/lemma.js +17 -10
- package/src/metaLemma.js +102 -1
- package/src/metaType.js +29 -3
- package/src/metatheorem.js +143 -2
- package/src/metavariable.js +189 -66
- package/src/mixins/statement/qualified/unify.js +7 -19
- package/src/mixins/statement/unify.js +3 -25
- package/src/mixins/statement/verify.js +15 -13
- package/src/mixins/term/unify.js +1 -1
- package/src/premise.js +31 -16
- package/src/reference.js +18 -18
- package/src/rule.js +40 -58
- package/src/statement/unqualified.js +41 -11
- package/src/statement.js +6 -3
- package/src/substitution/frameForMetavariable.js +85 -98
- package/src/substitution/statementForMetavariable.js +109 -45
- package/src/substitution/termForVariable.js +83 -94
- package/src/substitution.js +36 -34
- package/src/substitutions.js +53 -46
- package/src/supposition.js +22 -14
- 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/intrinsicLevel.js +4 -3
- package/src/unifier/metaLevel.js +19 -7
- package/src/unifier/metavariable.js +5 -5
- package/src/unifier/statementWithCombinator.js +19 -19
- 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 +28 -23
- package/src/{verify → utilities}/release.js +5 -1
- package/src/utilities/releaseContext.js +2 -2
- package/src/utilities/tokens.js +10 -0
- package/src/variable.js +18 -19
- package/src/verifier/topLevel.js +6 -4
- package/lib/argument.js +0 -106
- package/lib/metaTypes.js +0 -19
- package/lib/unify/metavariableWithFrame.js +0 -40
- package/lib/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -31
- package/lib/unify/statementWithSttaemetnGivenEquivalences.js +0 -45
- package/lib/verify/declaration.js +0 -83
- package/lib/verify/frame.js +0 -120
- package/lib/verify/judgement.js +0 -88
- package/lib/verify/metaLemma.js +0 -49
- package/lib/verify/metatheorem.js +0 -48
- package/lib/verify/metavariableGivenMetaType.js +0 -44
- package/lib/verify/release.js +0 -50
- package/src/argument.js +0 -79
- package/src/metaTypes.js +0 -11
- package/src/unify/metavariableWithFrame.js +0 -40
- package/src/unify/simpleSubstitutionStatementWithComplexSubstitutionStatement.js +0 -27
- package/src/unify/statementWithSttaemetnGivenEquivalences.js +0 -51
- package/src/verify/declaration.js +0 -113
- package/src/verify/frame.js +0 -157
- package/src/verify/judgement.js +0 -127
- package/src/verify/metaLemma.js +0 -72
- package/src/verify/metatheorem.js +0 -67
- package/src/verify/metavariableGivenMetaType.js +0 -45
package/src/frame.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { arrayUtilities } from "necessary";
|
|
4
|
+
|
|
3
5
|
import shim from "./shim";
|
|
4
6
|
import Declaration from "./declaration";
|
|
5
7
|
import Metavariable from "./metavariable";
|
|
@@ -7,13 +9,17 @@ import Metavariable from "./metavariable";
|
|
|
7
9
|
import { FRAME_META_TYPE_NAME } from "./metaTypeNames";
|
|
8
10
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
9
11
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
const frameNodeQuery = nodeQuery("/*/frame"),
|
|
13
|
+
declarationNodesQuery = nodesQuery("/frame/declaration"),
|
|
14
|
+
metavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
15
|
+
metavariableNodesQuery = nodesQuery("/frame/metavariable");
|
|
16
|
+
|
|
17
|
+
const { first } = arrayUtilities;
|
|
13
18
|
|
|
14
19
|
class Frame {
|
|
15
|
-
constructor(string, declarations, metavariables) {
|
|
20
|
+
constructor(string, node, declarations, metavariables) {
|
|
16
21
|
this.string = string;
|
|
22
|
+
this.node = node;
|
|
17
23
|
this.declarations = declarations;
|
|
18
24
|
this.metavariables = metavariables;
|
|
19
25
|
}
|
|
@@ -22,6 +28,10 @@ class Frame {
|
|
|
22
28
|
return this.string;
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
getNode() {
|
|
32
|
+
return this.node;
|
|
33
|
+
}
|
|
34
|
+
|
|
25
35
|
getDeclarations() {
|
|
26
36
|
return this.declarations;
|
|
27
37
|
}
|
|
@@ -31,82 +41,113 @@ class Frame {
|
|
|
31
41
|
}
|
|
32
42
|
|
|
33
43
|
getMetavariable() {
|
|
34
|
-
let metavariable;
|
|
44
|
+
let metavariable = null;
|
|
45
|
+
|
|
46
|
+
const declarationsLength = this.declarations.length;
|
|
35
47
|
|
|
36
|
-
|
|
48
|
+
if (declarationsLength === 0) {
|
|
49
|
+
const metavariablesLength = this.metavariables.length;
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
|
|
51
|
+
if (metavariablesLength === 1) {
|
|
52
|
+
const firstMetavariable = first(this.metavariables);
|
|
40
53
|
|
|
41
|
-
|
|
54
|
+
metavariable = firstMetavariable; ///
|
|
55
|
+
}
|
|
42
56
|
}
|
|
43
57
|
|
|
44
58
|
return metavariable;
|
|
45
59
|
}
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
61
|
+
getMetavariableNode() {
|
|
62
|
+
let metavariableNode = null;
|
|
63
|
+
|
|
64
|
+
const metavariable = this.getMetavariable();
|
|
65
|
+
|
|
66
|
+
if (metavariable !== null) {
|
|
67
|
+
metavariableNode = metavariable.getNode();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return metavariableNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
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);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return metavariableNameMatches;
|
|
89
|
+
}
|
|
90
|
+
|
|
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
|
+
}
|
|
149
|
+
|
|
150
|
+
verify(assignments, stated, localContext) {
|
|
110
151
|
let verified;
|
|
111
152
|
|
|
112
153
|
const frameString = this.string; ///
|
|
@@ -114,19 +155,29 @@ class Frame {
|
|
|
114
155
|
localContext.trace(`Verifying the '${frameString}' frame...`);
|
|
115
156
|
|
|
116
157
|
const declarationsVerified = this.declarations.every((declaration) => {
|
|
117
|
-
|
|
158
|
+
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
118
159
|
|
|
119
|
-
|
|
120
|
-
|
|
160
|
+
return declarationVerified;
|
|
161
|
+
}),
|
|
162
|
+
metavariablesVerified = this.metavariables.every((metavariable) => {
|
|
163
|
+
const metavariableVerified = metavariable.verify(localContext);
|
|
121
164
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const metavariableVerified = metavariable.verify(localContext);
|
|
165
|
+
return metavariableVerified;
|
|
166
|
+
});
|
|
125
167
|
|
|
126
|
-
|
|
127
|
-
|
|
168
|
+
if (declarationsVerified && metavariablesVerified) {
|
|
169
|
+
let verifiedWhenStated = false,
|
|
170
|
+
verifiedWhenDerived = false;
|
|
128
171
|
|
|
129
|
-
|
|
172
|
+
if (stated) {
|
|
173
|
+
verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
|
|
174
|
+
} else {
|
|
175
|
+
verifiedWhenDerived = this.verifyWhenDerived(assignments, localContext);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (verifiedWhenStated || verifiedWhenDerived) {
|
|
179
|
+
verified = true;
|
|
180
|
+
}
|
|
130
181
|
}
|
|
131
182
|
|
|
132
183
|
if (verified) {
|
|
@@ -136,7 +187,52 @@ class Frame {
|
|
|
136
187
|
return verified;
|
|
137
188
|
}
|
|
138
189
|
|
|
139
|
-
|
|
190
|
+
verifyWhenStated(assignments, localContext) {
|
|
191
|
+
let verifiedWhenStated = false;
|
|
192
|
+
|
|
193
|
+
const frameString = this.string; ///
|
|
194
|
+
|
|
195
|
+
localContext.trace(`Verifying the '${frameString}' frame when stated...`);
|
|
196
|
+
|
|
197
|
+
const declarationsLength = this.declarations.length;
|
|
198
|
+
|
|
199
|
+
if (declarationsLength === 0) {
|
|
200
|
+
const metavariablesLength = this.metavariables.length;
|
|
201
|
+
|
|
202
|
+
if (metavariablesLength === 1) {
|
|
203
|
+
verifiedWhenStated = true;
|
|
204
|
+
} else {
|
|
205
|
+
localContext.trace(`The '${frameString}' stated frame cannot have more than one metavariable.`);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
localContext.trace(`The '${frameString}' stated frame cannot have declarations.`);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
if (verifiedWhenStated) {
|
|
213
|
+
localContext.debug(`...verified the '${frameString}' frame when stated.`);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return verifiedWhenStated;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
verifyWhenDerived(assignments, localContext) {
|
|
220
|
+
let verifiedWhenDerived;
|
|
221
|
+
|
|
222
|
+
const frameString = this.string; ///
|
|
223
|
+
|
|
224
|
+
localContext.trace(`Verifying the '${frameString}' frame when derived...`);
|
|
225
|
+
|
|
226
|
+
verifiedWhenDerived = true;
|
|
227
|
+
|
|
228
|
+
if (verifiedWhenDerived) {
|
|
229
|
+
localContext.debug(`...verified the '${frameString}' frame when derived.`);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return verifiedWhenDerived;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
verifyGivenMetaType(metaType, assignments, stated, localContext) {
|
|
140
236
|
let verifiedGivenMetaType = false;
|
|
141
237
|
|
|
142
238
|
const frameString = this.string, ///
|
|
@@ -147,7 +243,7 @@ class Frame {
|
|
|
147
243
|
const metaTypeName = metaType.getName();
|
|
148
244
|
|
|
149
245
|
if (metaTypeName === FRAME_META_TYPE_NAME) {
|
|
150
|
-
const verified = this.verify(localContext)
|
|
246
|
+
const verified = this.verify(assignments, stated, localContext)
|
|
151
247
|
|
|
152
248
|
verifiedGivenMetaType = verified; ///
|
|
153
249
|
}
|
|
@@ -160,21 +256,26 @@ class Frame {
|
|
|
160
256
|
}
|
|
161
257
|
|
|
162
258
|
static fromFrameNode(frameNode, localContext) {
|
|
163
|
-
|
|
164
|
-
metavariableNodes = metavariableNodesQuery(frameNode),
|
|
165
|
-
declarations = declarationNodes.map((declarationNode) => {
|
|
166
|
-
const declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
259
|
+
let frame = null;
|
|
167
260
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
261
|
+
if (frameNode !== null) {
|
|
262
|
+
const declarationNodes = declarationNodesQuery(frameNode),
|
|
263
|
+
metavariableNodes = metavariableNodesQuery(frameNode),
|
|
264
|
+
declarations = declarationNodes.map((declarationNode) => {
|
|
265
|
+
const declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
172
266
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
267
|
+
return declaration;
|
|
268
|
+
}),
|
|
269
|
+
metavariables = metavariableNodes.map((metavariableNode) => {
|
|
270
|
+
const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext);
|
|
271
|
+
|
|
272
|
+
return metavariable;
|
|
273
|
+
}),
|
|
274
|
+
node = frameNode, ///
|
|
275
|
+
string = localContext.nodeAsString(node);
|
|
276
|
+
|
|
277
|
+
frame = new Frame(string, node, declarations, metavariables);
|
|
278
|
+
}
|
|
178
279
|
|
|
179
280
|
return frame;
|
|
180
281
|
}
|
|
@@ -182,19 +283,22 @@ class Frame {
|
|
|
182
283
|
static fromDefinedAssertionNode(definedAssertionNode, localContext) {
|
|
183
284
|
let frame = null;
|
|
184
285
|
|
|
185
|
-
const
|
|
286
|
+
const frameNode = frameNodeQuery(definedAssertionNode);
|
|
186
287
|
|
|
187
|
-
if (
|
|
188
|
-
const metavariableNode =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
288
|
+
if (frameNode !== null) {
|
|
289
|
+
const metavariableNode = metavariableNodeQuery(frameNode);
|
|
290
|
+
|
|
291
|
+
if (metavariableNode !== null) {
|
|
292
|
+
const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
|
|
293
|
+
declarations = [],
|
|
294
|
+
metavariables = [
|
|
295
|
+
metavariable
|
|
296
|
+
],
|
|
297
|
+
node = frameNode, ///
|
|
298
|
+
string = localContext.nodeAsString(node);
|
|
196
299
|
|
|
197
|
-
|
|
300
|
+
frame = new Frame(string, node, declarations, metavariables);
|
|
301
|
+
}
|
|
198
302
|
}
|
|
199
303
|
|
|
200
304
|
return frame;
|
|
@@ -203,46 +307,26 @@ class Frame {
|
|
|
203
307
|
static fromContainedAssertionNode(containedAssertionNode, localContext) {
|
|
204
308
|
let frame = null;
|
|
205
309
|
|
|
206
|
-
const
|
|
310
|
+
const frameNode = frameNodeQuery(containedAssertionNode);
|
|
207
311
|
|
|
208
|
-
if (
|
|
209
|
-
const metavariableNode =
|
|
210
|
-
metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
|
|
211
|
-
declarations = [],
|
|
212
|
-
metavariables = [
|
|
213
|
-
metavariable
|
|
214
|
-
],
|
|
215
|
-
node = metavariableNode, ///
|
|
216
|
-
string = localContext.nodeAsString(node);
|
|
312
|
+
if (frameNode !== null) {
|
|
313
|
+
const metavariableNode = metavariableNodeQuery(frameNode);
|
|
217
314
|
|
|
218
|
-
|
|
315
|
+
if (metavariableNode !== null) {
|
|
316
|
+
const metavariable = Metavariable.fromMetavariableNode(metavariableNode, localContext),
|
|
317
|
+
declarations = [],
|
|
318
|
+
metavariables = [
|
|
319
|
+
metavariable
|
|
320
|
+
],
|
|
321
|
+
node = frameNode, ///
|
|
322
|
+
string = localContext.nodeAsString(node);
|
|
323
|
+
|
|
324
|
+
frame = new Frame(string, node, declarations, metavariables);
|
|
325
|
+
}
|
|
219
326
|
}
|
|
220
327
|
|
|
221
328
|
return frame;
|
|
222
329
|
}
|
|
223
|
-
|
|
224
|
-
// static fromDeclarations(declarations) {
|
|
225
|
-
// const metavariableNodes = [],
|
|
226
|
-
// frame = new Frame(declarations, metavariableNodes);
|
|
227
|
-
//
|
|
228
|
-
// return frame;
|
|
229
|
-
// }
|
|
230
|
-
//
|
|
231
|
-
// static fromMetavariableNode(metavariableNode) {
|
|
232
|
-
// const declarations = [],
|
|
233
|
-
// metavariableNodes = [
|
|
234
|
-
// metavariableNode
|
|
235
|
-
// ],
|
|
236
|
-
// frame = new Frame(declarations, metavariableNodes);
|
|
237
|
-
//
|
|
238
|
-
// return frame;
|
|
239
|
-
// }
|
|
240
|
-
//
|
|
241
|
-
// static fromDeclarationsAndMetavariableNodes(declarations, metavariableNodes) {
|
|
242
|
-
// const frame = new Frame(declarations, metavariableNodes);
|
|
243
|
-
//
|
|
244
|
-
// return frame;
|
|
245
|
-
// }
|
|
246
330
|
}
|
|
247
331
|
|
|
248
332
|
Object.assign(shim, {
|
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
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Frame from "./frame";
|
|
4
|
+
import Declaration from "./declaration";
|
|
5
|
+
import JudgementAssignment from "./assignment/judgement";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "./utilities/query";
|
|
8
|
+
|
|
9
|
+
const frameNodeQuery = nodeQuery("/judgement/frame"),
|
|
10
|
+
declarationNodeQuery = nodeQuery("/judgement/declaration");
|
|
11
|
+
|
|
3
12
|
export default class Judgement {
|
|
4
|
-
constructor(frame, declaration) {
|
|
13
|
+
constructor(string, frame, declaration) {
|
|
14
|
+
this.string = string;
|
|
5
15
|
this.frame = frame;
|
|
6
16
|
this.declaration = declaration;
|
|
7
17
|
}
|
|
8
18
|
|
|
19
|
+
getString() {
|
|
20
|
+
return this.string;
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
getFrame() {
|
|
10
24
|
return this.frame;
|
|
11
25
|
}
|
|
@@ -18,8 +32,100 @@ export default class Judgement {
|
|
|
18
32
|
|
|
19
33
|
matchMetavariableName(metavariableName) { return this.frame.matchMetavariableName(metavariableName); }
|
|
20
34
|
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
verify(assignments, stated, localContext) {
|
|
36
|
+
let verified;
|
|
37
|
+
|
|
38
|
+
const judgementString = this.string; ///
|
|
39
|
+
|
|
40
|
+
localContext.trace(`Verifying the '${judgementString}' judgement...`);
|
|
41
|
+
|
|
42
|
+
const frameVerified = this.frame.verify(assignments, stated, localContext),
|
|
43
|
+
declarationVerified = this.declaration.verify(assignments, stated, localContext);
|
|
44
|
+
|
|
45
|
+
if (frameVerified && declarationVerified) {
|
|
46
|
+
let verifiedWhenStated = false,
|
|
47
|
+
verifiedWhenDerived = false;
|
|
48
|
+
|
|
49
|
+
if (stated) {
|
|
50
|
+
verifiedWhenStated = this.verifyWhenStated(assignments, localContext);
|
|
51
|
+
} else {
|
|
52
|
+
verifiedWhenDerived = this.verifyWhenDerived(assignments, localContext);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (verifiedWhenStated || verifiedWhenDerived) {
|
|
56
|
+
verified = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (verified) {
|
|
61
|
+
localContext.debug(`...verified the '${judgementString}' judgement.`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return verified;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
verifyWhenStated(assignments, localContext) {
|
|
68
|
+
let verifiedWhenStated;
|
|
69
|
+
|
|
70
|
+
const judgementString = this.string; ///
|
|
71
|
+
|
|
72
|
+
localContext.trace(`Verifying the '${judgementString}' judgement when stated...`);
|
|
73
|
+
|
|
74
|
+
if (assignments !== null) {
|
|
75
|
+
const judgement = this, ///
|
|
76
|
+
judgementAssignment = JudgementAssignment.fromJudgement(judgement),
|
|
77
|
+
assignment = judgementAssignment;
|
|
78
|
+
|
|
79
|
+
assignments.push(assignment);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
verifiedWhenStated = true;
|
|
83
|
+
|
|
84
|
+
if (verifiedWhenStated) {
|
|
85
|
+
localContext.debug(`...verified the '${judgementString}' judgement when stated.`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return verifiedWhenStated;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
verifyWhenDerived(assignments, localContext) {
|
|
92
|
+
let verifiedWhenDerived;
|
|
93
|
+
|
|
94
|
+
const judgementString = this.string; ///
|
|
95
|
+
|
|
96
|
+
localContext.trace(`Verifying the '${judgementString}' judgement when derived...`);
|
|
97
|
+
|
|
98
|
+
const reference = this.declaration.getReference(),
|
|
99
|
+
metaLemma = localContext.findMetaLemmaByReference(reference),
|
|
100
|
+
metatheorem = localContext.findMetatheoremByReference(reference),
|
|
101
|
+
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
102
|
+
|
|
103
|
+
if (metaLemmaMetatheorem !== null) {
|
|
104
|
+
const metaLemmaMetatheoremUnified = this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem, localContext);
|
|
105
|
+
|
|
106
|
+
verifiedWhenDerived = metaLemmaMetatheoremUnified; ///
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (verifiedWhenDerived) {
|
|
110
|
+
localContext.debug(`...verified the '${judgementString}' judgement when derived.`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return verifiedWhenDerived;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static fromJudgementNode(judgementNode, localContext) {
|
|
117
|
+
let judgement = null;
|
|
118
|
+
|
|
119
|
+
if (judgementNode !== null) {
|
|
120
|
+
const frameNode = frameNodeQuery(judgementNode),
|
|
121
|
+
declarationNode = declarationNodeQuery(judgementNode),
|
|
122
|
+
node = judgementNode, ///
|
|
123
|
+
string = localContext.nodeAsString(node),
|
|
124
|
+
frame = Frame.fromFrameNode(frameNode, localContext),
|
|
125
|
+
declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
126
|
+
|
|
127
|
+
judgement = new Judgement(string, frame, declaration);
|
|
128
|
+
}
|
|
23
129
|
|
|
24
130
|
return judgement;
|
|
25
131
|
}
|
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;
|