occam-verify-cli 0.0.974 → 0.0.975
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 +30 -0
- package/bin/main.js +0 -27
- package/lib/frame.js +3 -3
- package/lib/judgement.js +4 -4
- package/lib/metavariable.js +4 -28
- package/lib/rule.js +11 -1
- package/lib/topLevelAssertion.js +11 -1
- package/lib/unifier/metavariable.js +142 -0
- package/lib/unify/qualifiedStatement.js +42 -23
- package/lib/unify/statementWithCombinators.js +2 -1
- package/lib/verify/assertion/defined.js +3 -2
- package/lib/verify/declaration.js +13 -25
- package/lib/verify/frame.js +39 -32
- package/lib/verify/judgement.js +12 -41
- package/lib/verify/metavariableGivenMetaType.js +44 -0
- package/lib/verify/statement.js +18 -14
- package/lib/verify/statementGivenMetaType.js +3 -2
- package/package.json +4 -4
- package/src/frame.js +1 -1
- package/src/judgement.js +1 -1
- package/src/metavariable.js +3 -32
- package/src/rule.js +10 -0
- package/src/topLevelAssertion.js +10 -0
- package/src/unifier/metavariable.js +46 -0
- package/src/unify/qualifiedStatement.js +60 -30
- package/src/unify/statementWithCombinators.js +2 -0
- package/src/verify/assertion/defined.js +3 -1
- package/src/verify/declaration.js +24 -35
- package/src/verify/frame.js +52 -39
- package/src/verify/judgement.js +17 -57
- package/src/verify/metavariableGivenMetaType.js +45 -0
- package/src/verify/statement.js +22 -13
- package/src/verify/statementGivenMetaType.js +3 -1
- package/lib/verify/metavariable.js +0 -51
- package/src/verify/metavariable.js +0 -58
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import metavariableUnifier from "../unifier/metavariable";
|
|
4
|
+
import StatementForMetavariableSubstitution from "../substitution/statementForMetavariable";
|
|
5
|
+
|
|
3
6
|
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
4
8
|
|
|
5
9
|
const statementNodeQuery = nodeQuery("/qualifiedStatement/statement!"),
|
|
6
10
|
metavariableNodeQuery = nodeQuery("/qualifiedStatement/reference/metavariable!");
|
|
@@ -42,17 +46,18 @@ function unifyQualifiedStatementAWithRule(qualifiedStatementNode, substitutions,
|
|
|
42
46
|
|
|
43
47
|
if (rule !== null) {
|
|
44
48
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
45
|
-
|
|
46
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
49
|
+
labelMetavariableNodes = rule.getLabelMetavariableNodes(),
|
|
50
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
|
|
51
|
+
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
47
52
|
|
|
48
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
53
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' rule...`, qualifiedStatementNode);
|
|
49
54
|
|
|
50
55
|
const statementUnified = rule.unifyStatement(statementNode, localContext);
|
|
51
56
|
|
|
52
57
|
qualifiedStatementUnifiedWithRule = statementUnified; ///
|
|
53
58
|
|
|
54
59
|
if (qualifiedStatementUnifiedWithRule) {
|
|
55
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
60
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' rule.`, qualifiedStatementNode);
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
|
|
@@ -67,17 +72,18 @@ function unifyQualifiedStatementAWithAxiom(qualifiedStatementNode, substitutions
|
|
|
67
72
|
|
|
68
73
|
if (axiom !== null) {
|
|
69
74
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
70
|
-
|
|
71
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
75
|
+
labelMetavariableNodes = axiom.getLabelMetavariableNodes(),
|
|
76
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
|
|
77
|
+
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
72
78
|
|
|
73
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
79
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' axiom...`, qualifiedStatementNode);
|
|
74
80
|
|
|
75
81
|
const statementUnified = axiom.unifyStatement(statementNode, localContext);
|
|
76
82
|
|
|
77
83
|
qualifiedStatementUnifiedWithAxiom = statementUnified; ///
|
|
78
84
|
|
|
79
85
|
if (qualifiedStatementUnifiedWithAxiom) {
|
|
80
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
86
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' axiom.`, qualifiedStatementNode);
|
|
81
87
|
}
|
|
82
88
|
}
|
|
83
89
|
|
|
@@ -92,17 +98,18 @@ function unifyQualifiedStatementAWithLemma(qualifiedStatementNode, substitutions
|
|
|
92
98
|
|
|
93
99
|
if (lemma !== null) {
|
|
94
100
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
95
|
-
|
|
96
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
101
|
+
labelMetavariableNodes = lemma.getLabelMetavariableNodes(),
|
|
102
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
|
|
103
|
+
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
97
104
|
|
|
98
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
105
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' lemma...`, qualifiedStatementNode);
|
|
99
106
|
|
|
100
107
|
const statementUnified = lemma.unifyStatement(statementNode, localContext);
|
|
101
108
|
|
|
102
109
|
qualifiedStatementUnifiedWithLemma = statementUnified; ///
|
|
103
110
|
|
|
104
111
|
if (qualifiedStatementUnifiedWithLemma) {
|
|
105
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
112
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' lemma.`, qualifiedStatementNode);
|
|
106
113
|
}
|
|
107
114
|
}
|
|
108
115
|
|
|
@@ -117,17 +124,18 @@ function unifyQualifiedStatementAWithTheorem(qualifiedStatementNode, substitutio
|
|
|
117
124
|
|
|
118
125
|
if (theorem !== null) {
|
|
119
126
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
120
|
-
|
|
121
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
127
|
+
labelMetavariableNodes = theorem.getLabelMetavariableNodes(),
|
|
128
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
|
|
129
|
+
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
122
130
|
|
|
123
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
131
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' theorem...`, qualifiedStatementNode);
|
|
124
132
|
|
|
125
133
|
const statementUnified = theorem.unifyStatement(statementNode, localContext);
|
|
126
134
|
|
|
127
135
|
qualifiedStatementUnifiedWithTheorem = statementUnified; ///
|
|
128
136
|
|
|
129
137
|
if (qualifiedStatementUnifiedWithTheorem) {
|
|
130
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
138
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' theorem.`, qualifiedStatementNode);
|
|
131
139
|
}
|
|
132
140
|
}
|
|
133
141
|
|
|
@@ -142,17 +150,18 @@ function unifyQualifiedStatementAWithConjecture(qualifiedStatementNode, substitu
|
|
|
142
150
|
|
|
143
151
|
if (conjecture !== null) {
|
|
144
152
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
145
|
-
|
|
146
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
153
|
+
labelMetavariableNodes = conjecture.getLabelMetavariableNodes(),
|
|
154
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode),
|
|
155
|
+
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
147
156
|
|
|
148
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
157
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' conjecture...`, qualifiedStatementNode);
|
|
149
158
|
|
|
150
159
|
const statementUnified = conjecture.unifyStatement(statementNode, localContext);
|
|
151
160
|
|
|
152
161
|
qualifiedStatementUnifiedWithConjecture = statementUnified; ///
|
|
153
162
|
|
|
154
163
|
if (qualifiedStatementUnifiedWithConjecture) {
|
|
155
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
164
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${labelMetavariableNodesString}' conjecture.`, qualifiedStatementNode);
|
|
156
165
|
}
|
|
157
166
|
}
|
|
158
167
|
|
|
@@ -162,21 +171,42 @@ function unifyQualifiedStatementAWithConjecture(qualifiedStatementNode, substitu
|
|
|
162
171
|
function unifyQualifiedStatementAWithReference(qualifiedStatementNode, substitutions, localContext) {
|
|
163
172
|
let qualifiedStatementUnifiedWithReference = false;
|
|
164
173
|
|
|
165
|
-
|
|
166
|
-
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
167
|
-
metavariablePresent = localContext.isMetavariablePresentByMetavariableNode(metavariableNode),
|
|
168
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
174
|
+
let metavariableNode = metavariableNodeQuery(qualifiedStatementNode);
|
|
169
175
|
|
|
170
|
-
|
|
176
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
177
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
171
178
|
|
|
172
|
-
if (
|
|
179
|
+
if (metavariable !== null) {
|
|
180
|
+
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
181
|
+
statementString = localContext.nodeAsString(statementNode),
|
|
182
|
+
metavariableString = localContext.nodeAsString(metavariableNode);
|
|
173
183
|
|
|
174
|
-
|
|
184
|
+
localContext.trace(`Unifying the '${statementString}' qualified statement with the '${metavariableString}' reference...`, qualifiedStatementNode);
|
|
175
185
|
|
|
176
|
-
|
|
186
|
+
const metavariableNodeA = metavariableNode; ///
|
|
187
|
+
|
|
188
|
+
metavariableNode = metavariable.getNode();
|
|
189
|
+
|
|
190
|
+
const metavariableNodeB = metavariableNode; ///
|
|
191
|
+
|
|
192
|
+
const unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
177
193
|
|
|
178
|
-
|
|
179
|
-
|
|
194
|
+
if (unified) {
|
|
195
|
+
metavariableNode = metavariableNodeA; ///
|
|
196
|
+
|
|
197
|
+
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeAndMetavariableNode(statementNode, metavariableNode),
|
|
198
|
+
substitution = statementForMetavariableSubstitution, ///
|
|
199
|
+
localContextA = localContext, ///
|
|
200
|
+
localContextB = localContext; ///
|
|
201
|
+
|
|
202
|
+
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
203
|
+
|
|
204
|
+
qualifiedStatementUnifiedWithReference = true;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (qualifiedStatementUnifiedWithReference) {
|
|
208
|
+
localContext.debug(`...unified the '${statementString}' qualified statement with the '${metavariableString}' reference.`, qualifiedStatementNode);
|
|
209
|
+
}
|
|
180
210
|
}
|
|
181
211
|
|
|
182
212
|
return qualifiedStatementUnifiedWithReference;
|
|
@@ -9,6 +9,8 @@ export default function unifyStatementWithCombinators(statementNode, assignments
|
|
|
9
9
|
|
|
10
10
|
assignments = null; ///
|
|
11
11
|
|
|
12
|
+
stated = true; ///
|
|
13
|
+
|
|
12
14
|
statementUnifiedWithCombinators = combinators.some((combinator) => {
|
|
13
15
|
const statementUnifiedWithCombinator = unifyStatementWithCombinator(statementNode, combinator, assignments, stated, localContext);
|
|
14
16
|
|
|
@@ -6,6 +6,7 @@ import metaLevelVerifier from "../../verifier/metaLevel";
|
|
|
6
6
|
import { first } from "../../utilities/array";
|
|
7
7
|
import { nodeQuery } from "../../utilities/query";
|
|
8
8
|
import { isAssertionNegated } from "../../utilities/assertion";
|
|
9
|
+
import { metavariableNameFromMetavariableNode } from "../../utilities/name";
|
|
9
10
|
|
|
10
11
|
const variableNodeQuery = nodeQuery("/definedAssertion/term/variable!"),
|
|
11
12
|
metavariableNodeQuery = nodeQuery("/definedAssertion/statement[-1]/metavariable!");
|
|
@@ -63,7 +64,8 @@ function verifyDerivedDefinedAssertion(definedAssertionNode, assignments, stated
|
|
|
63
64
|
if (false) {
|
|
64
65
|
///
|
|
65
66
|
} else if (metavariableNode !== null) {
|
|
66
|
-
const
|
|
67
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
68
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName),
|
|
67
69
|
metavariableDefined = localContext.isMetavariableDefined(metavariable);
|
|
68
70
|
|
|
69
71
|
if (!assertionNegated) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import shim from "../shim";
|
|
4
4
|
import Declaration from "../declaration"
|
|
5
5
|
import referenceMetaType from "../metaType/reference";
|
|
6
|
+
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
6
7
|
|
|
7
8
|
import { nodeQuery } from "../utilities/query";
|
|
8
9
|
|
|
@@ -44,7 +45,25 @@ function verifyDerivedDeclaration(declarationNode, declarations, stated, localCo
|
|
|
44
45
|
|
|
45
46
|
localContext.trace(`Verifying the '${declarationString}' derived declaration...`, declarationNode);
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
const metaType = referenceMetaType, ///
|
|
49
|
+
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
50
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
51
|
+
|
|
52
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
53
|
+
const { verifyStatement } = shim,
|
|
54
|
+
stated = true,
|
|
55
|
+
assignments = null,
|
|
56
|
+
statementNode = statementNodeQuery(declarationNode),
|
|
57
|
+
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
58
|
+
|
|
59
|
+
if (statementVerified) {
|
|
60
|
+
const declaration = Declaration.fromMetavariableNodeAndStatementNode(metavariableNode, statementNode);
|
|
61
|
+
|
|
62
|
+
declarations.push(declaration);
|
|
63
|
+
|
|
64
|
+
derivedDeclarationVerified = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
48
67
|
|
|
49
68
|
if (derivedDeclarationVerified) {
|
|
50
69
|
localContext.debug(`...verified the '${declarationString}' derived declaration.`, declarationNode);
|
|
@@ -62,10 +81,11 @@ function verifyStatedDeclaration(declarationNode, declarations, stated, localCon
|
|
|
62
81
|
|
|
63
82
|
localContext.trace(`Verifying the '${declarationString}' stated declaration...`, declarationNode);
|
|
64
83
|
|
|
65
|
-
const
|
|
66
|
-
|
|
84
|
+
const metaType = referenceMetaType, ///
|
|
85
|
+
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
86
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
67
87
|
|
|
68
|
-
if (
|
|
88
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
69
89
|
const { verifyStatement } = shim,
|
|
70
90
|
stated = true,
|
|
71
91
|
assignments = null,
|
|
@@ -88,34 +108,3 @@ function verifyStatedDeclaration(declarationNode, declarations, stated, localCon
|
|
|
88
108
|
|
|
89
109
|
return statedDeclarationVerified;
|
|
90
110
|
}
|
|
91
|
-
|
|
92
|
-
function verifyMetavariable(metavariableNode, localContext) {
|
|
93
|
-
let metavariableVerified = false;
|
|
94
|
-
|
|
95
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
96
|
-
|
|
97
|
-
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
98
|
-
|
|
99
|
-
const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
100
|
-
|
|
101
|
-
if (metavariable !== null) {
|
|
102
|
-
const metaType = metavariable.getMetaType();
|
|
103
|
-
|
|
104
|
-
if (metaType === referenceMetaType) {
|
|
105
|
-
metavariableVerified = true;
|
|
106
|
-
} else {
|
|
107
|
-
const referenceMetaTypeName = referenceMetaType.getName(),
|
|
108
|
-
metaTypeString = metaType.asString();
|
|
109
|
-
|
|
110
|
-
localContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${referenceMetaTypeName}'.`, metavariableNode);
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (metavariableVerified) {
|
|
117
|
-
localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return metavariableVerified;
|
|
121
|
-
}
|
package/src/verify/frame.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
import Frame from "../frame";
|
|
4
4
|
import frameMetaType from "../metaType/frame";
|
|
5
5
|
import verifyDeclaration from "../verify/declaration";
|
|
6
|
+
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
6
7
|
|
|
7
|
-
import { push } from "../utilities/array";
|
|
8
8
|
import { nodesQuery } from "../utilities/query";
|
|
9
|
+
import { first, push } from "../utilities/array";
|
|
9
10
|
|
|
10
11
|
const declarationNodesQuery = nodesQuery("/frame/declaration"),
|
|
11
12
|
metavariableNodesQuery = nodesQuery("/frame/metavariable");
|
|
@@ -45,7 +46,32 @@ function verifyDerivedFrame(frameNode, frames, stated, localContext) {
|
|
|
45
46
|
|
|
46
47
|
localContext.trace(`Verifying the '${frameString}' derived frame...`, frameNode);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
const declarationNodes = declarationNodesQuery(frameNode),
|
|
50
|
+
declarationNodesLength = declarationNodes.length;
|
|
51
|
+
|
|
52
|
+
if (declarationNodesLength === 1) {
|
|
53
|
+
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
54
|
+
metavariableNodesLength = metavariableNodes.length;
|
|
55
|
+
|
|
56
|
+
if (metavariableNodesLength === 0) {
|
|
57
|
+
const firstDeclarationNode = first(declarationNodes),
|
|
58
|
+
declarationNode = firstDeclarationNode, ///
|
|
59
|
+
declarations = [],
|
|
60
|
+
declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
61
|
+
|
|
62
|
+
if (declarationVerified) {
|
|
63
|
+
const frame = Frame.fromDeclarations(declarations);
|
|
64
|
+
|
|
65
|
+
frames.push(frame);
|
|
66
|
+
|
|
67
|
+
derivedFrameVerified = true; ///
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
localContext.debug(`The '${frameString}' derived frame must no spread metavariables.`, frameNode);
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
localContext.debug(`The '${frameString}' derived frame must have one and only one declaration.`, frameNode);
|
|
74
|
+
}
|
|
49
75
|
|
|
50
76
|
if (derivedFrameVerified) {
|
|
51
77
|
localContext.debug(`...verified the '${frameString}' derived frame.`, frameNode);
|
|
@@ -65,25 +91,28 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
|
|
|
65
91
|
|
|
66
92
|
const declarations = [],
|
|
67
93
|
declarationNodes = declarationNodesQuery(frameNode),
|
|
68
|
-
metavariableNodes = metavariableNodesQuery(frameNode),
|
|
69
94
|
declarationsVerified = declarationNodes.every((declarationNode) => {
|
|
70
95
|
const declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
71
96
|
|
|
72
97
|
return declarationVerified;
|
|
73
|
-
}),
|
|
74
|
-
metavariablesVerified = metavariableNodes.every((metavariableNode) => {
|
|
75
|
-
const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localContext);
|
|
76
|
-
|
|
77
|
-
return metavariableVerified;
|
|
78
98
|
});
|
|
79
99
|
|
|
80
|
-
|
|
81
|
-
|
|
100
|
+
if (declarationsVerified) {
|
|
101
|
+
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
102
|
+
metavariablesVerified = metavariableNodes.every((metavariableNode) => {
|
|
103
|
+
const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localContext);
|
|
82
104
|
|
|
83
|
-
|
|
105
|
+
return metavariableVerified;
|
|
106
|
+
});
|
|
84
107
|
|
|
85
|
-
|
|
86
|
-
|
|
108
|
+
if (metavariablesVerified) {
|
|
109
|
+
const frame = Frame.fromDeclarations(declarations);
|
|
110
|
+
|
|
111
|
+
frames.push(frame);
|
|
112
|
+
|
|
113
|
+
statedFrameVerified = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
87
116
|
|
|
88
117
|
if (statedFrameVerified) {
|
|
89
118
|
localContext.debug(`...verified the '${frameString}' stated frame.`, frameNode);
|
|
@@ -96,39 +125,23 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
|
|
|
96
125
|
function verifyMetavariable(metavariableNode, declarations, localContext) {
|
|
97
126
|
let metavariableVerified = false;
|
|
98
127
|
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
102
|
-
|
|
103
|
-
const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
128
|
+
const metaType = frameMetaType, ///
|
|
129
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
104
130
|
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
131
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
132
|
+
const judgement = localContext.findJudgementByMetavariableNode(metavariableNode);
|
|
107
133
|
|
|
108
|
-
if (
|
|
109
|
-
const
|
|
134
|
+
if (judgement !== null) {
|
|
135
|
+
const judgementDeclarations = judgement.getDeclarations();
|
|
110
136
|
|
|
111
|
-
|
|
112
|
-
const judgementDeclarations = judgement.getDeclarations();
|
|
137
|
+
push(declarations, judgementDeclarations);
|
|
113
138
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
metavariableVerified = true;
|
|
117
|
-
} else {
|
|
118
|
-
localContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode);
|
|
119
|
-
}
|
|
139
|
+
metavariableVerified = true;
|
|
120
140
|
} else {
|
|
121
|
-
const
|
|
122
|
-
metaTypeString = metaType.asString();
|
|
141
|
+
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
123
142
|
|
|
124
|
-
localContext.debug(`
|
|
143
|
+
localContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode)
|
|
125
144
|
}
|
|
126
|
-
} else {
|
|
127
|
-
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
if (metavariableVerified) {
|
|
131
|
-
localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
132
145
|
}
|
|
133
146
|
|
|
134
147
|
return metavariableVerified;
|
package/src/verify/judgement.js
CHANGED
|
@@ -4,6 +4,7 @@ import Judgement from "../judgement";
|
|
|
4
4
|
import verifyFrame from "../verify/frame";
|
|
5
5
|
import frameMetaType from "../metaType/frame";
|
|
6
6
|
import JudgementAssignment from "../assignment/judgement";
|
|
7
|
+
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
7
8
|
|
|
8
9
|
import { first } from "../utilities/array";
|
|
9
10
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -49,9 +50,10 @@ function verifyDerivedJudgement(judgementNode, assignments, stated, localContext
|
|
|
49
50
|
const metavariableNode = metavariableNodeQuery(judgementNode);
|
|
50
51
|
|
|
51
52
|
if (metavariableNode !== null) {
|
|
52
|
-
const
|
|
53
|
+
const metaType = frameMetaType, ///
|
|
54
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
53
55
|
|
|
54
|
-
if (
|
|
56
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
55
57
|
const judgement = localContext.findJudgementByMetavariableNode(metavariableNode);
|
|
56
58
|
|
|
57
59
|
if (judgement !== null) {
|
|
@@ -62,35 +64,23 @@ function verifyDerivedJudgement(judgementNode, assignments, stated, localContext
|
|
|
62
64
|
if (frameVerified) {
|
|
63
65
|
const firstFrame = first(frames),
|
|
64
66
|
frame = firstFrame, ///
|
|
65
|
-
|
|
67
|
+
declaration = frame.getDeclaration(),
|
|
68
|
+
metavariableNode = declaration.getMetavariableNode(),
|
|
69
|
+
metatheorem = localContext.findMetatheoremByMetavariableNode(metavariableNode),
|
|
70
|
+
metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
|
|
71
|
+
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
66
72
|
|
|
67
|
-
if (
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
|
|
71
|
-
metatheorem = localContext.findMetatheoremByMetavariableNode(metavariableNode),
|
|
72
|
-
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
73
|
+
if (metaLemmaMetatheorem !== null) {
|
|
74
|
+
const metaLemmaMetatheoremUnifiedWithJudgement = judgement.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem),
|
|
75
|
+
metaLemmaMetatheoremUnifiedWithDeclaration = declaration.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem);
|
|
73
76
|
|
|
74
|
-
|
|
75
|
-
const metaLemmaMetatheoremUnifiedWithDeclaration = declaration.unifyMetaLemmaOrMetaTheorem(metaLemmaMetatheorem),
|
|
76
|
-
metaLemmaMetatheoremUnifiedWithJudgement = judgement.unifyMetaLemmaOrMetaTheorem(metaLemmaMetatheorem);
|
|
77
|
-
|
|
78
|
-
derivedJudgementVerified = (metaLemmaMetatheoremUnifiedWithDeclaration && metaLemmaMetatheoremUnifiedWithJudgement);
|
|
79
|
-
} else {
|
|
80
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
81
|
-
|
|
82
|
-
localContext.debug(`There are no meta-lemmas or metatheorems corresponding to the '${metavariableString}' metavariable.`, judgementNode);
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
const frameString = localContext.nodeAsString(frameNode);
|
|
86
|
-
|
|
87
|
-
localContext.debug(`The '${frameString}' is not singular.`, judgementNode);
|
|
77
|
+
derivedJudgementVerified = (metaLemmaMetatheoremUnifiedWithJudgement && metaLemmaMetatheoremUnifiedWithDeclaration);
|
|
88
78
|
}
|
|
89
79
|
}
|
|
90
80
|
} else {
|
|
91
81
|
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
92
82
|
|
|
93
|
-
localContext.debug(`There is no judgement
|
|
83
|
+
localContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode)
|
|
94
84
|
}
|
|
95
85
|
}
|
|
96
86
|
}
|
|
@@ -114,9 +104,10 @@ function verifyStatedJudgement(judgementNode, assignments, stated, localContext)
|
|
|
114
104
|
const metavariableNode = metavariableNodeQuery(judgementNode);
|
|
115
105
|
|
|
116
106
|
if (metavariableNode !== null) {
|
|
117
|
-
const
|
|
107
|
+
const metaType = frameMetaType, ///
|
|
108
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
118
109
|
|
|
119
|
-
if (
|
|
110
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
120
111
|
const frames = [],
|
|
121
112
|
frameNode = frameNodeQuery(judgementNode),
|
|
122
113
|
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
@@ -144,34 +135,3 @@ function verifyStatedJudgement(judgementNode, assignments, stated, localContext)
|
|
|
144
135
|
|
|
145
136
|
return statedJudgementVerified;
|
|
146
137
|
}
|
|
147
|
-
|
|
148
|
-
function verifyMetavariable(metavariableNode, localContext) {
|
|
149
|
-
let metavariableVerified = false;
|
|
150
|
-
|
|
151
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
152
|
-
|
|
153
|
-
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
154
|
-
|
|
155
|
-
const metavariable = localContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
156
|
-
|
|
157
|
-
if (metavariable !== null) {
|
|
158
|
-
const metaType = metavariable.getMetaType();
|
|
159
|
-
|
|
160
|
-
if (metaType === frameMetaType) {
|
|
161
|
-
metavariableVerified = true;
|
|
162
|
-
} else {
|
|
163
|
-
const frameMetaTypeName = frameMetaType.getName(),
|
|
164
|
-
metaTypeString = metaType.asString();
|
|
165
|
-
|
|
166
|
-
localContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${frameMetaTypeName}'.`, metavariableNode);
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
if (metavariableVerified) {
|
|
173
|
-
localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return metavariableVerified;
|
|
177
|
-
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import metavariableUnifier from "../unifier/metavariable";
|
|
4
|
+
|
|
5
|
+
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
6
|
+
|
|
7
|
+
export default function verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext) {
|
|
8
|
+
let metavariableVerifiedGivenMetaType = false;
|
|
9
|
+
|
|
10
|
+
const metaTypeName = metaType.getName(),
|
|
11
|
+
metavariableString = localContext.nodeAsString(metavariableNode);
|
|
12
|
+
|
|
13
|
+
localContext.trace(`Verifying the '${metavariableString}' metavariable given the '${metaTypeName}' meta-type...`, metavariableNode);
|
|
14
|
+
|
|
15
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
16
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
17
|
+
|
|
18
|
+
if (metavariable !== null) {
|
|
19
|
+
const metavariableMetaType = metavariable.getMetaType();
|
|
20
|
+
|
|
21
|
+
if (metavariableMetaType === metaType) {
|
|
22
|
+
const metavariableNodeA = metavariableNode; ///
|
|
23
|
+
|
|
24
|
+
metavariableNode = metavariable.getNode();
|
|
25
|
+
|
|
26
|
+
const metavariableNodeB = metavariableNode; ///
|
|
27
|
+
|
|
28
|
+
const unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
29
|
+
|
|
30
|
+
metavariableVerifiedGivenMetaType = unified; ///
|
|
31
|
+
} else {
|
|
32
|
+
const metavariableMetaTypeName = metavariableMetaType.getName();
|
|
33
|
+
|
|
34
|
+
localContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metavariableMetaTypeName}' when it should be '${metaTypeName}'.`, metavariableNode);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
localContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
41
|
+
localContext.debug(`...verified the '${metavariableString}' metavariable given the '${metaTypeName}' meta-type.`, metavariableNode);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return metavariableVerifiedGivenMetaType;
|
|
45
|
+
}
|
package/src/verify/statement.js
CHANGED
|
@@ -6,6 +6,7 @@ import verifyEquality from "../verify/equality";
|
|
|
6
6
|
import verifyJudgement from "../verify/judgement";
|
|
7
7
|
import verifyDeclaration from "../verify/declaration";
|
|
8
8
|
import verifyTypeAssertion from "../verify/assertion/type";
|
|
9
|
+
import metavariableUnifier from "../unifier/metavariable";
|
|
9
10
|
import verifyDefinedAssertion from "../verify/assertion/defined";
|
|
10
11
|
import verifySubproofAssertion from "../verify/assertion/subproof";
|
|
11
12
|
import verifyContainedAssertion from "../verify/assertion/contained";
|
|
@@ -13,6 +14,7 @@ import unifyStatementWithCombinators from "../unify/statementWithCombinators";
|
|
|
13
14
|
import unifyStatementWithBracketedCombinator from "../unify/statementWithBracketedCombinator";
|
|
14
15
|
|
|
15
16
|
import { nodeQuery } from "../utilities/query";
|
|
17
|
+
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
16
18
|
|
|
17
19
|
const frameNodeQuery = nodeQuery("/statement/frame!"),
|
|
18
20
|
equalityNodeQuery = nodeQuery("/statement/equality!"),
|
|
@@ -92,9 +94,9 @@ function verifyStatementAsMetavariable(statementNode, assignments, stated, local
|
|
|
92
94
|
|
|
93
95
|
localContext.trace(`Verifying the '${statementString}' statement as a metavariable...`, statementNode);
|
|
94
96
|
|
|
95
|
-
const
|
|
97
|
+
const metavariableUnified = unifyMetavariable(metavariableNode, localContext);
|
|
96
98
|
|
|
97
|
-
statementVerifiedAsMetavariable =
|
|
99
|
+
statementVerifiedAsMetavariable = metavariableUnified;
|
|
98
100
|
|
|
99
101
|
if (statementVerifiedAsMetavariable) {
|
|
100
102
|
localContext.debug(`...verified the '${statementString}' statement as a metavariable.`, statementNode);
|
|
@@ -280,24 +282,31 @@ function verifyStatementAsContainedAssertion(statementNode, assignments, stated,
|
|
|
280
282
|
return statementVerifiedAsContainedAssertion;
|
|
281
283
|
}
|
|
282
284
|
|
|
283
|
-
function
|
|
284
|
-
let
|
|
285
|
+
function unifyMetavariable(metavariableNode, localContext) {
|
|
286
|
+
let metavariableUnified;
|
|
285
287
|
|
|
286
288
|
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
287
289
|
|
|
288
|
-
localContext.trace(`
|
|
290
|
+
localContext.trace(`Unifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
289
291
|
|
|
290
|
-
const
|
|
292
|
+
const metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
293
|
+
metavariable = localContext.findMetavariableByMetavariableName(metavariableName);
|
|
291
294
|
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
295
|
+
if (metavariable !== null) {
|
|
296
|
+
const metavariableNodeA = metavariableNode; ///
|
|
297
|
+
|
|
298
|
+
metavariableNode = metavariable.getNode();
|
|
299
|
+
|
|
300
|
+
const metavariableNodeB = metavariableNode; ///
|
|
301
|
+
|
|
302
|
+
const unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
303
|
+
|
|
304
|
+
metavariableUnified = unified; ///
|
|
296
305
|
}
|
|
297
306
|
|
|
298
|
-
if (
|
|
299
|
-
localContext.debug(`...
|
|
307
|
+
if (metavariableUnified) {
|
|
308
|
+
localContext.debug(`...unified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
300
309
|
}
|
|
301
310
|
|
|
302
|
-
return
|
|
311
|
+
return metavariableUnified;
|
|
303
312
|
}
|