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/metavariable.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "./shim";
|
|
4
|
-
import Argument from "./argument";
|
|
5
4
|
import LocalContext from "./context/local";
|
|
6
5
|
import metavariableUnifier from "./unifier/metavariable";
|
|
6
|
+
import FrameForMetavariableSubstitution from "./substitution/frameForMetavariable";
|
|
7
7
|
import StatementForMetavariableSubstitution from "./substitution/statementForMetavariable";
|
|
8
8
|
|
|
9
9
|
import { nodeQuery } from "./utilities/query";
|
|
10
|
-
import { metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
11
10
|
import { metavariableNodeFromMetavariableString } from "./utilities/node";
|
|
11
|
+
import { metaTypeFromJSON, metaTypeToMetaTypeJSON } from "./utilities/json";
|
|
12
|
+
import { typeNameFromTypeNode, metavariableNameFromMetavariableNode } from "./utilities/name";
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
+
const termNodeQuery = nodeQuery("/metavariable/argument/term"),
|
|
15
|
+
typeNodeQuery = nodeQuery("/metavariable/argument/type"),
|
|
14
16
|
metaTypeNodeQuery = nodeQuery("/metavariableDeclaration/metaType"),
|
|
15
17
|
metavariableNodeQuery = nodeQuery("/metavariableDeclaration/metavariable"),
|
|
18
|
+
frameMetavariableNodeQuery = nodeQuery("/frame/metavariable!"),
|
|
16
19
|
statementMetavariableNodeQuery = nodeQuery("/statement/metavariable!");
|
|
17
20
|
|
|
18
21
|
class Metavariable {
|
|
@@ -50,6 +53,12 @@ class Metavariable {
|
|
|
50
53
|
return metaTypeName;
|
|
51
54
|
}
|
|
52
55
|
|
|
56
|
+
matchMetaType(metaType) {
|
|
57
|
+
const metaTypeMatches = (this.metaType === metaType);
|
|
58
|
+
|
|
59
|
+
return metaTypeMatches;
|
|
60
|
+
}
|
|
61
|
+
|
|
53
62
|
matchMetavariableName(metavariableName) {
|
|
54
63
|
const metavariableNameMatches = (this.name === metavariableName);
|
|
55
64
|
|
|
@@ -62,6 +71,131 @@ class Metavariable {
|
|
|
62
71
|
return metavariableNodeMatches;
|
|
63
72
|
}
|
|
64
73
|
|
|
74
|
+
unifyFrame(frame, substitutions, localContext) {
|
|
75
|
+
let frameUnified = false;
|
|
76
|
+
|
|
77
|
+
const frameNode = frame.getNode(),
|
|
78
|
+
frameString = frame.getString(),
|
|
79
|
+
metavariableString = this.string; ///
|
|
80
|
+
|
|
81
|
+
localContext.trace(`Unifying the '${frameString}' frame with the '${metavariableString}' metavariable...`);
|
|
82
|
+
|
|
83
|
+
const metavariableName = this.name, ///
|
|
84
|
+
simpleSubstitutionPresent = substitutions.isSimpleSubstitutionPresentByMetavariableName(metavariableName);
|
|
85
|
+
|
|
86
|
+
if (simpleSubstitutionPresent) {
|
|
87
|
+
const simpleSubstitution = substitutions.findSimpleSubstitutionByMetavariableName(metavariableName),
|
|
88
|
+
substitution = simpleSubstitution, ///
|
|
89
|
+
frameNodeMatches = substitution.matchFrameNode(frameNode);
|
|
90
|
+
|
|
91
|
+
if (frameNodeMatches) {
|
|
92
|
+
frameUnified = true;
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
const metavariableNode = this.node, ///
|
|
96
|
+
metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
|
|
97
|
+
frameMetavariable = frameMetavariableFromStatementNode(frameNode, localContext);
|
|
98
|
+
|
|
99
|
+
if (metavariable === frameMetavariable) {
|
|
100
|
+
frameUnified = true;
|
|
101
|
+
} else {
|
|
102
|
+
const metavariable = this, ///
|
|
103
|
+
frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameAndMetavariable(frame, metavariable, localContext),
|
|
104
|
+
substitution = frameForMetavariableSubstitution; ///
|
|
105
|
+
|
|
106
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
107
|
+
|
|
108
|
+
frameUnified = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (frameUnified) {
|
|
113
|
+
localContext.debug(`...unified the '${frameString}' frame with the '${metavariableString}' metavariable.`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return frameUnified;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
unifyStatement(statement, substitution, substitutions, localContext) {
|
|
120
|
+
let statementUnified = false;
|
|
121
|
+
|
|
122
|
+
const statementString = statement.getString(),
|
|
123
|
+
metavariableString = this.string, ///
|
|
124
|
+
substitutionString = (substitution !== null) ?
|
|
125
|
+
substitution.getString() :
|
|
126
|
+
null;
|
|
127
|
+
|
|
128
|
+
(substitutionString !== null) ?
|
|
129
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution...`) :
|
|
130
|
+
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
131
|
+
|
|
132
|
+
const statementNode = statement.getNode(),
|
|
133
|
+
metavariableNode = this.node, ///
|
|
134
|
+
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
135
|
+
substitutionNode = (substitution !== null) ?
|
|
136
|
+
substitution.getSubstitutionNode() :
|
|
137
|
+
null,
|
|
138
|
+
substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode);
|
|
139
|
+
|
|
140
|
+
if (substitutionPresent) {
|
|
141
|
+
const substitution = substitutions.findSubstitutionByMetavariableNameAndSubstitutionNode(metavariableName, substitutionNode),
|
|
142
|
+
statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
143
|
+
|
|
144
|
+
if (statementNodeMatches) {
|
|
145
|
+
statementUnified = true;
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
const metavariableNode = this.node, ///
|
|
149
|
+
metavariable = metavariableFromMetavariableNode(metavariableNode, localContext),
|
|
150
|
+
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
151
|
+
|
|
152
|
+
if (metavariable === statementMetavariable) {
|
|
153
|
+
statementUnified = true;
|
|
154
|
+
} else {
|
|
155
|
+
const metavariable = this, ///
|
|
156
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
|
|
157
|
+
|
|
158
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
159
|
+
|
|
160
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
161
|
+
|
|
162
|
+
statementUnified = true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (statementUnified) {
|
|
167
|
+
(substitutionString !== null) ?
|
|
168
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution.`) :
|
|
169
|
+
localContext.debug(`...unified the '${statementString}' statement with the '${metavariableString}' metavariable.`);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return statementUnified;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
unifySubstitution(substitution, localContext) {
|
|
176
|
+
let substitutionUnified = false;
|
|
177
|
+
|
|
178
|
+
const metavariableString = this.string, ///
|
|
179
|
+
substitutionString = substitution.getString();
|
|
180
|
+
|
|
181
|
+
localContext.trace(`Unifying the '${substitutionString}' substitution with the '${metavariableString}' metavariable...`);
|
|
182
|
+
|
|
183
|
+
const metavariableName = this.name, ///
|
|
184
|
+
judgement = localContext.findJudgementByMetavariableName(metavariableName);
|
|
185
|
+
|
|
186
|
+
if (judgement !== null){
|
|
187
|
+
const declaration = judgement.getDeclaration();
|
|
188
|
+
|
|
189
|
+
substitutionUnified = declaration.unifySubstitution(substitution, localContext);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (substitutionUnified) {
|
|
193
|
+
localContext.debug(`...unified the '${substitutionString}' substitution with the '${metavariableString}' metavariable.`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return substitutionUnified;
|
|
197
|
+
}
|
|
198
|
+
|
|
65
199
|
verify(localContext) {
|
|
66
200
|
let verified;
|
|
67
201
|
|
|
@@ -80,7 +214,6 @@ class Metavariable {
|
|
|
80
214
|
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
81
215
|
|
|
82
216
|
verified = metavariableUnified; ///
|
|
83
|
-
|
|
84
217
|
}
|
|
85
218
|
|
|
86
219
|
if (verified) {
|
|
@@ -104,15 +237,25 @@ class Metavariable {
|
|
|
104
237
|
if (metavariablePresent) {
|
|
105
238
|
fileContext.debug(`The metavariable '${metavariableString}' is already present.`);
|
|
106
239
|
} else {
|
|
107
|
-
const
|
|
108
|
-
argument = Argument.fromArgumentNode(argumentNode, fileContext);
|
|
240
|
+
const termNode = termNodeQuery(this.node);
|
|
109
241
|
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
} else {
|
|
113
|
-
const argumentVerified = argument.verify(fileContext);
|
|
242
|
+
if (termNode !== null) {
|
|
243
|
+
const termString = this.fileContext.nodeAsString(termNode);
|
|
114
244
|
|
|
115
|
-
|
|
245
|
+
this.fileContext.debug(`The '${termString}' term was found when a type should have been present.`);
|
|
246
|
+
} else {
|
|
247
|
+
const typeNode = typeNodeQuery(this.node);
|
|
248
|
+
|
|
249
|
+
if (typeNode !== null) {
|
|
250
|
+
const typeName = typeNameFromTypeNode(typeNode),
|
|
251
|
+
typePresent = this.fileContext.isTypePresentByTypeName(typeName);
|
|
252
|
+
|
|
253
|
+
if (typePresent) {
|
|
254
|
+
verifiedAtTopLevel = true;
|
|
255
|
+
} else {
|
|
256
|
+
this.fileContext.debug(`The '${typeName}' type is not present.`);
|
|
257
|
+
}
|
|
258
|
+
} else {
|
|
116
259
|
verifiedAtTopLevel = true;
|
|
117
260
|
}
|
|
118
261
|
}
|
|
@@ -125,63 +268,35 @@ class Metavariable {
|
|
|
125
268
|
return verifiedAtTopLevel;
|
|
126
269
|
}
|
|
127
270
|
|
|
128
|
-
|
|
129
|
-
let
|
|
271
|
+
verifyGivenMetaType(metaType, localContext) {
|
|
272
|
+
let verifiedGivenMetaType = false;
|
|
130
273
|
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
substitutionString = (substitution !== null) ?
|
|
134
|
-
substitution.getString() :
|
|
135
|
-
null;
|
|
274
|
+
const metavariableString = this.string, ///
|
|
275
|
+
metaTypeString = metaType.getString();
|
|
136
276
|
|
|
137
|
-
(
|
|
138
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable given the ${substitutionString} substitution...`) :
|
|
139
|
-
localContext.trace(`Unifying the '${statementString}' statement with the '${metavariableString}' metavariable...`);
|
|
277
|
+
localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type...`);
|
|
140
278
|
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
substitution.getSubstitutionNode() :
|
|
145
|
-
null,
|
|
146
|
-
substitutionPresent = substitutions.isSubstitutionPresentByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode);
|
|
147
|
-
|
|
148
|
-
if (substitutionPresent) {
|
|
149
|
-
const substitution = substitutions.findSubstitutionByMetavariableNodeAndSubstitutionNode(metavariableNode, substitutionNode),
|
|
150
|
-
statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
151
|
-
|
|
152
|
-
if (statementNodeMatches) {
|
|
153
|
-
statementUnified = true;
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
const metavariable = this, ///
|
|
157
|
-
statementMetavariable = statementMetavariableFromStatementNode(statementNode, localContext);
|
|
158
|
-
|
|
159
|
-
if (metavariable === statementMetavariable) {
|
|
160
|
-
statementUnified = true;
|
|
161
|
-
} else {
|
|
162
|
-
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementMetavariableAndSubstitution(statement, metavariable, substitution, localContext);
|
|
163
|
-
|
|
164
|
-
substitution = statementForMetavariableSubstitution; ///
|
|
279
|
+
const name = this.getName(),
|
|
280
|
+
metavariableName = name, ///
|
|
281
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
165
282
|
|
|
166
|
-
|
|
283
|
+
if (metavariable !== null) {
|
|
284
|
+
const metaTypeMatches = metavariable.matchMetaType(metaType);
|
|
167
285
|
|
|
168
|
-
|
|
169
|
-
}
|
|
286
|
+
verifiedGivenMetaType = metaTypeMatches; ///
|
|
170
287
|
}
|
|
171
288
|
|
|
172
|
-
(
|
|
173
|
-
localContext.debug(`...
|
|
174
|
-
|
|
289
|
+
if (verifiedGivenMetaType) {
|
|
290
|
+
localContext.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeString}' meta-type.`);
|
|
291
|
+
}
|
|
175
292
|
|
|
176
|
-
return
|
|
293
|
+
return verifiedGivenMetaType;
|
|
177
294
|
}
|
|
178
295
|
|
|
179
296
|
toJSON() {
|
|
180
|
-
const metaTypeJSON = (this.metaType
|
|
181
|
-
this.metaType.toJSON() :
|
|
182
|
-
null,
|
|
183
|
-
string = this.string,
|
|
297
|
+
const metaTypeJSON = metaTypeToMetaTypeJSON(this.metaType),
|
|
184
298
|
metaType = metaTypeJSON, ///
|
|
299
|
+
string = this.string,
|
|
185
300
|
json = {
|
|
186
301
|
string,
|
|
187
302
|
metaType
|
|
@@ -205,17 +320,17 @@ class Metavariable {
|
|
|
205
320
|
return metavariable;
|
|
206
321
|
}
|
|
207
322
|
|
|
208
|
-
static fromMetavariableNode(metavariableNode,
|
|
323
|
+
static fromMetavariableNode(metavariableNode, localContext) {
|
|
209
324
|
let metavariable = null;
|
|
210
325
|
|
|
211
326
|
if (metavariableNode !== null) {
|
|
212
327
|
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
213
328
|
node = metavariableNode, ///
|
|
214
329
|
name = metavariableName, ///
|
|
215
|
-
string =
|
|
330
|
+
string = localContext.nodeAsString(node),
|
|
216
331
|
metaType = null;
|
|
217
332
|
|
|
218
|
-
metavariable = new Metavariable(
|
|
333
|
+
metavariable = new Metavariable(localContext, string, node, name, metaType);
|
|
219
334
|
}
|
|
220
335
|
|
|
221
336
|
return metavariable;
|
|
@@ -244,17 +359,25 @@ Object.assign(shim, {
|
|
|
244
359
|
|
|
245
360
|
export default Metavariable;
|
|
246
361
|
|
|
247
|
-
function
|
|
248
|
-
|
|
362
|
+
function metavariableFromMetavariableNode(metavariableNode, localContext) {
|
|
363
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
364
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
365
|
+
|
|
366
|
+
return metavariable;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function frameMetavariableFromStatementNode(frameNode, localContext) {
|
|
370
|
+
let frameMetavariable = null;
|
|
371
|
+
|
|
372
|
+
const frameMetavariableNode = frameMetavariableNodeQuery(frameNode);
|
|
249
373
|
|
|
250
|
-
if (
|
|
251
|
-
const
|
|
252
|
-
metaTypeName = name; ///
|
|
374
|
+
if (frameMetavariableNode !== null) {
|
|
375
|
+
const frameMetavariableName = metavariableNameFromMetavariableNode(frameMetavariableNode);
|
|
253
376
|
|
|
254
|
-
|
|
377
|
+
frameMetavariable = localContext.findMetavariableByMetavariableName(frameMetavariableName);
|
|
255
378
|
}
|
|
256
379
|
|
|
257
|
-
return
|
|
380
|
+
return frameMetavariable;
|
|
258
381
|
}
|
|
259
382
|
|
|
260
383
|
function statementMetavariableFromStatementNode(statementNode, localContext) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import metavariableUnifier from "../../../unifier/metavariable";
|
|
4
3
|
import StatementForMetavariableSubstitution from "../../../substitution/statementForMetavariable";
|
|
5
4
|
|
|
6
5
|
import { trim } from "../../../utilities/string";
|
|
@@ -137,33 +136,22 @@ function unifyAWithReference(qualifiedStatement, substitutions, localContext) {
|
|
|
137
136
|
const reference = qualifiedStatement.getReference(),
|
|
138
137
|
metavariableNode = reference.getMetavariableNode(),
|
|
139
138
|
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
140
|
-
|
|
139
|
+
metavariablePresent = localContext.isMetavariablePresentByMetavariableName(metavariableName);
|
|
141
140
|
|
|
142
|
-
if (
|
|
141
|
+
if (metavariablePresent) {
|
|
143
142
|
const statement = qualifiedStatement.getStatement(),
|
|
144
143
|
statementString = statement.getString(),
|
|
145
144
|
referenceString = reference.getString();
|
|
146
145
|
|
|
147
146
|
localContext.trace(`Unifying the '${statementString}' qualified statement with the '${referenceString}' reference...`);
|
|
148
147
|
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
metavariableNodeB = metavariableNode, ///
|
|
153
|
-
metavariableUnified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
148
|
+
const metavariable = reference.getMetavariable(),
|
|
149
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementAndMetavariable(statement, metavariable, localContext),
|
|
150
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
154
151
|
|
|
155
|
-
|
|
156
|
-
const statementNode = statement.getNode(),
|
|
157
|
-
metavariableNode = metavariableNodeA, ///
|
|
158
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeAndMetavariableNode(statementNode, metavariableNode, localContextA, localContextB),
|
|
159
|
-
substitution = statementForMetavariableSubstitution, ///
|
|
160
|
-
localContextA = localContext, ///
|
|
161
|
-
localContextB = localContext; ///
|
|
152
|
+
substitutions.addSubstitution(substitution, localContext);
|
|
162
153
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
unifiedWithReference = true;
|
|
166
|
-
}
|
|
154
|
+
unifiedWithReference = true;
|
|
167
155
|
|
|
168
156
|
if (unifiedWithReference) {
|
|
169
157
|
localContext.debug(`...unified the '${statementString}' qualified statement with the '${referenceString}' reference.`);
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { arrayUtilities } from "necessary";
|
|
4
|
-
|
|
5
3
|
import BracketedCombinator from "../../combinator/bracketed";
|
|
6
4
|
import statementWithCombinatorUnifier from "../../unifier/statementWithCombinator";
|
|
7
5
|
|
|
8
|
-
const { reverse } = arrayUtilities;
|
|
9
|
-
|
|
10
6
|
function unifyWithBracketedCombinator(statement, assignments, stated, localContext) {
|
|
11
7
|
let unifiedWithBracketedCombinator;
|
|
12
8
|
|
|
@@ -18,7 +14,7 @@ function unifyWithBracketedCombinator(statement, assignments, stated, localConte
|
|
|
18
14
|
|
|
19
15
|
localContext.trace(`Unifying the '${statementString}' statement with the bracketed combinator...`);
|
|
20
16
|
|
|
21
|
-
unifiedWithBracketedCombinator = statementWithCombinatorUnifier.unify(
|
|
17
|
+
unifiedWithBracketedCombinator = statementWithCombinatorUnifier.unify(combinatorStatementNode, statementNode, assignments, stated, localContext);
|
|
22
18
|
|
|
23
19
|
if (unifiedWithBracketedCombinator) {
|
|
24
20
|
localContext.debug(`...unified the '${statementString}' statement with the bracketed combinator.`);
|
|
@@ -47,28 +43,10 @@ function unifyWithCombinators(statement, assignments, stated, localContext) {
|
|
|
47
43
|
return unifiedWithCombinators;
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
function unifyWithProofSteps(statement, assignments, stated, localContext) {
|
|
51
|
-
let unifiedWithProofSteps;
|
|
52
|
-
|
|
53
|
-
let proofSteps = localContext.getProofSteps();
|
|
54
|
-
|
|
55
|
-
proofSteps = reverse(proofSteps); ///
|
|
56
|
-
|
|
57
|
-
unifiedWithProofSteps = proofSteps.some((proofStep) => {
|
|
58
|
-
const statementUnified = proofStep.unifyStatement(statement, localContext);
|
|
59
|
-
|
|
60
|
-
if (statementUnified) {
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
return unifiedWithProofSteps;
|
|
66
|
-
}
|
|
67
46
|
|
|
68
47
|
const unifyMixins = [
|
|
69
48
|
unifyWithBracketedCombinator,
|
|
70
|
-
unifyWithCombinators
|
|
71
|
-
unifyWithProofSteps
|
|
49
|
+
unifyWithCombinators
|
|
72
50
|
];
|
|
73
51
|
|
|
74
52
|
export default unifyMixins;
|
|
@@ -83,7 +61,7 @@ function unifyStatementWithCombinator(statement, combinator, assignments, stated
|
|
|
83
61
|
|
|
84
62
|
localContext.trace(`Unifying the '${statementString}' statement with the '${combinatorString}' combinator...`);
|
|
85
63
|
|
|
86
|
-
unifiedWithCombinator = statementWithCombinatorUnifier.unify(
|
|
64
|
+
unifiedWithCombinator = statementWithCombinatorUnifier.unify(combinatorStatementNode, statementNode, assignments, stated, localContext);
|
|
87
65
|
|
|
88
66
|
if (unifiedWithCombinator) {
|
|
89
67
|
localContext.debug(`...unified the '${statementString}' statement with the '${combinatorString}' combinator.`);
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Frame from "../../frame";
|
|
3
4
|
import Equality from "../../equality";
|
|
5
|
+
import Judgement from "../../judgement";
|
|
6
|
+
import Declaration from "../../declaration";
|
|
4
7
|
import Metavariable from "../../metavariable";
|
|
5
8
|
import TypeAssertion from "../../assertion/type";
|
|
6
9
|
import DefinedAssertion from "../../assertion/defined";
|
|
7
10
|
import SubproofAssertion from "../../assertion/subproof";
|
|
8
11
|
import ContainedAssertion from "../../assertion/contained";
|
|
9
12
|
|
|
10
|
-
import verifyFrame from "../../verify/frame";
|
|
11
|
-
import verifyJudgement from "../../verify/judgement";
|
|
12
|
-
import verifyDeclaration from "../../verify/declaration";
|
|
13
|
-
|
|
14
13
|
import { nodeQuery } from "../../utilities/query";
|
|
15
14
|
|
|
16
15
|
const frameNodeQuery = nodeQuery("/statement/frame!"),
|
|
@@ -75,14 +74,15 @@ function verifyAsFrame(statement, assignments, stated, localContext) {
|
|
|
75
74
|
let verifiedAsFrame = false;
|
|
76
75
|
|
|
77
76
|
const statementNode = statement.getNode(),
|
|
78
|
-
frameNode = frameNodeQuery(statementNode)
|
|
77
|
+
frameNode = frameNodeQuery(statementNode),
|
|
78
|
+
frame = Frame.fromFrameNode(frameNode, localContext);
|
|
79
79
|
|
|
80
|
-
if (
|
|
80
|
+
if (frame !== null) {
|
|
81
81
|
const statementString = statement.getString();
|
|
82
82
|
|
|
83
83
|
localContext.trace(`Verifying the '${statementString}' statement as a frame...`);
|
|
84
84
|
|
|
85
|
-
const frameVerified =
|
|
85
|
+
const frameVerified = frame.verify(assignments, stated, localContext);
|
|
86
86
|
|
|
87
87
|
verifiedAsFrame = frameVerified; ///
|
|
88
88
|
|
|
@@ -98,14 +98,15 @@ function verifyAsJudgement(statement, assignments, stated, localContext) {
|
|
|
98
98
|
let verifiedAsJudgement = false;
|
|
99
99
|
|
|
100
100
|
const statementNode = statement.getNode(),
|
|
101
|
-
judgementNode = judgementNodeQuery(statementNode)
|
|
101
|
+
judgementNode = judgementNodeQuery(statementNode),
|
|
102
|
+
judgement = Judgement.fromJudgementNode(judgementNode, localContext);
|
|
102
103
|
|
|
103
|
-
if (
|
|
104
|
+
if (judgement !== null) {
|
|
104
105
|
const statementString = statement.getString();
|
|
105
106
|
|
|
106
107
|
localContext.trace(`Verifying the '${statementString}' statement as a judgement...`);
|
|
107
108
|
|
|
108
|
-
const judgementVerified =
|
|
109
|
+
const judgementVerified = judgement.verify(assignments, stated, localContext);
|
|
109
110
|
|
|
110
111
|
verifiedAsJudgement = judgementVerified; ///
|
|
111
112
|
|
|
@@ -121,14 +122,15 @@ function verifyAsDeclaration(statement, assignments, stated, localContext) {
|
|
|
121
122
|
let verifiedAsDeclaration = false;
|
|
122
123
|
|
|
123
124
|
const statementNode = statement.getNode(),
|
|
124
|
-
declarationNode = declarationNodeQuery(statementNode)
|
|
125
|
+
declarationNode = declarationNodeQuery(statementNode),
|
|
126
|
+
declaration = Declaration.fromDeclarationNode(declarationNode, localContext);
|
|
125
127
|
|
|
126
|
-
if (
|
|
128
|
+
if (declaration !== null) {
|
|
127
129
|
const statementString = statement.getString();
|
|
128
130
|
|
|
129
131
|
localContext.trace(`Verifying the '${statementString}' statement as a declaration...`);
|
|
130
132
|
|
|
131
|
-
const declarationVerified =
|
|
133
|
+
const declarationVerified = declaration.verify(assignments, stated, localContext);
|
|
132
134
|
|
|
133
135
|
verifiedAsDeclaration = declarationVerified; ///
|
|
134
136
|
|
package/src/mixins/term/unify.js
CHANGED
|
@@ -87,7 +87,7 @@ function unifyTermWithConstructor(term, constructor, localContext, verifyAhead)
|
|
|
87
87
|
const termNode = term.getNode(),
|
|
88
88
|
constructorTerm = constructor.getTerm(),
|
|
89
89
|
constructorTermNode = constructorTerm.getNode(),
|
|
90
|
-
unified = termWithConstructorUnifier.unify(
|
|
90
|
+
unified = termWithConstructorUnifier.unify(constructorTermNode, termNode, localContext);
|
|
91
91
|
|
|
92
92
|
if (unified) {
|
|
93
93
|
let verifiedAhead;
|
package/src/premise.js
CHANGED
|
@@ -7,10 +7,11 @@ import UnqualifiedStatement from "./statement/unqualified";
|
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "./utilities/query";
|
|
9
9
|
import { assignAssignments } from "./utilities/assignments";
|
|
10
|
+
import { unqualifiedStatementFromJSON, unqualifiedStatementToUnqualifiedStatementJSON } from "./utilities/json";
|
|
10
11
|
|
|
11
12
|
const unqualifiedStatementNodeQuery = nodeQuery("/premise/unqualifiedStatement");
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
class Premise {
|
|
14
15
|
constructor(fileContext, unqualifiedStatement) {
|
|
15
16
|
this.fileContext = fileContext;
|
|
16
17
|
this.unqualifiedStatement = unqualifiedStatement;
|
|
@@ -40,7 +41,13 @@ export default class Premise {
|
|
|
40
41
|
|
|
41
42
|
const statement = this.unqualifiedStatement.getStatement(),
|
|
42
43
|
statementNode = statement.getNode(),
|
|
43
|
-
|
|
44
|
+
statementTokens = statement.getTokens(),
|
|
45
|
+
context = this.fileContext, ///
|
|
46
|
+
tokens = statementTokens; ///
|
|
47
|
+
|
|
48
|
+
localContext = LocalContext.fromContextAndTokens(context, tokens); ///
|
|
49
|
+
|
|
50
|
+
const subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, localContext);
|
|
44
51
|
|
|
45
52
|
if (subproofAssertion !== null) {
|
|
46
53
|
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, this.fileContext, localContext);
|
|
@@ -61,12 +68,19 @@ export default class Premise {
|
|
|
61
68
|
|
|
62
69
|
substitutions.snapshot();
|
|
63
70
|
|
|
71
|
+
let subproofUnified = false,
|
|
72
|
+
statementUnified = false;
|
|
73
|
+
|
|
64
74
|
if (false) {
|
|
65
75
|
///
|
|
66
76
|
} else if (subproof !== null) {
|
|
67
|
-
|
|
77
|
+
subproofUnified = this.unifySubproof(subproof, substitutions, localContext);
|
|
68
78
|
} else if (statement !== null) {
|
|
69
|
-
|
|
79
|
+
statementUnified = this.unifyStatement(statement, substitutions, localContext);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (subproofUnified || statementUnified) {
|
|
83
|
+
proofStepUnified = true;
|
|
70
84
|
}
|
|
71
85
|
|
|
72
86
|
proofStepUnified ?
|
|
@@ -82,18 +96,18 @@ export default class Premise {
|
|
|
82
96
|
const statementString = statement.getString(),
|
|
83
97
|
premiseString = this.getString();
|
|
84
98
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const localContextB = localContext;
|
|
99
|
+
const localContextB = localContext; ///
|
|
88
100
|
|
|
89
101
|
localContext = LocalContext.fromFileContext(this.fileContext);
|
|
90
102
|
|
|
91
103
|
const localContextA = localContext; ///
|
|
92
104
|
|
|
105
|
+
localContextB.trace(`Unifying the '${statementString}' statement with the '${premiseString}' premise...`);
|
|
106
|
+
|
|
93
107
|
statementUnified = this.unqualifiedStatement.unifyStatement(statement, substitutions, localContextA, localContextB);
|
|
94
108
|
|
|
95
109
|
if (statementUnified) {
|
|
96
|
-
|
|
110
|
+
localContextB.debug(`...unified the '${statementString}' statement with the '${premiseString}' premise.`);
|
|
97
111
|
}
|
|
98
112
|
|
|
99
113
|
return statementUnified;
|
|
@@ -131,7 +145,7 @@ export default class Premise {
|
|
|
131
145
|
}
|
|
132
146
|
|
|
133
147
|
toJSON() {
|
|
134
|
-
const unqualifiedStatementJSON = this.unqualifiedStatement
|
|
148
|
+
const unqualifiedStatementJSON = unqualifiedStatementToUnqualifiedStatementJSON(this.unqualifiedStatement),
|
|
135
149
|
unqualifiedStatement = unqualifiedStatementJSON, ///
|
|
136
150
|
json = {
|
|
137
151
|
unqualifiedStatement
|
|
@@ -141,13 +155,8 @@ export default class Premise {
|
|
|
141
155
|
}
|
|
142
156
|
|
|
143
157
|
static fromJSON(json, fileContext) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
json = unqualifiedStatement; ///
|
|
147
|
-
|
|
148
|
-
unqualifiedStatement = UnqualifiedStatement.fromJSON(json, fileContext);
|
|
149
|
-
|
|
150
|
-
const premise = new Premise(fileContext, unqualifiedStatement);
|
|
158
|
+
const unqualifiedStatement = unqualifiedStatementFromJSON(json, fileContext),
|
|
159
|
+
premise = new Premise(fileContext, unqualifiedStatement);
|
|
151
160
|
|
|
152
161
|
return premise;
|
|
153
162
|
}
|
|
@@ -160,3 +169,9 @@ export default class Premise {
|
|
|
160
169
|
return premise
|
|
161
170
|
}
|
|
162
171
|
}
|
|
172
|
+
|
|
173
|
+
Object.assign(shim, {
|
|
174
|
+
Premise
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export default Premise;
|