occam-verify-cli 0.0.977 → 0.0.979
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/context/local.js +11 -15
- package/lib/declaration.js +25 -19
- package/lib/frame.js +44 -19
- package/lib/judgement.js +15 -22
- package/lib/metaTypeNames.js +4 -4
- package/lib/reference.js +69 -0
- package/lib/rule.js +1 -11
- package/lib/topLevelAssertion.js +1 -11
- package/lib/unify/qualifiedStatement.js +16 -16
- package/lib/unify/termWithType.js +1 -1
- package/lib/verify/declaration.js +8 -7
- package/lib/verify/frame.js +43 -35
- package/lib/verify/judgement.js +21 -28
- package/lib/verify/metavariableGivenMetaType.js +6 -3
- package/lib/verify/statement.js +2 -2
- package/lib/verify/statementGivenMetaType.js +8 -8
- package/package.json +3 -3
- package/src/context/local.js +13 -16
- package/src/declaration.js +19 -17
- package/src/frame.js +47 -17
- package/src/judgement.js +9 -15
- package/src/metaTypeNames.js +1 -1
- package/src/reference.js +31 -0
- package/src/rule.js +0 -10
- package/src/topLevelAssertion.js +0 -10
- package/src/unify/qualifiedStatement.js +20 -25
- package/src/unify/termWithType.js +0 -1
- package/src/verify/declaration.js +16 -11
- package/src/verify/frame.js +63 -45
- package/src/verify/judgement.js +43 -46
- package/src/verify/metavariableGivenMetaType.js +6 -2
- package/src/verify/statement.js +1 -1
- package/src/verify/statementGivenMetaType.js +12 -12
package/src/judgement.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
export default class Judgement {
|
|
4
|
-
constructor(node, frame,
|
|
4
|
+
constructor(node, frame, declaration) {
|
|
5
5
|
this.node = node;
|
|
6
6
|
this.frame = frame;
|
|
7
|
-
this.
|
|
7
|
+
this.declaration = declaration;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
getNode() {
|
|
@@ -15,23 +15,17 @@ export default class Judgement {
|
|
|
15
15
|
return this.frame;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
return this.
|
|
18
|
+
getDeclaration() {
|
|
19
|
+
return this.declaration;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
getMetavariable() { return this.frame.getMetavariable(); }
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
const metavariableNodeMatches = this.metavariableNode.match(metavariableNode);
|
|
24
|
+
matchMetavariableName(metavariableName) { return this.frame.matchMetavariableName(metavariableName); }
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem) { return this.frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem); }
|
|
31
|
-
|
|
32
|
-
static fromJudgementNodeFrameAndMetavariableNode(judgementNode, frame, metavariableNode) {
|
|
33
|
-
const node = judgementNode,
|
|
34
|
-
judgement = new Judgement(node, frame, metavariableNode);
|
|
26
|
+
static fromJudgementNodeFrameAndDeclaration(judgementNode, frame, declaration) {
|
|
27
|
+
const node = judgementNode, ///
|
|
28
|
+
judgement = new Judgement(node, frame, declaration);
|
|
35
29
|
|
|
36
30
|
return judgement;
|
|
37
31
|
}
|
package/src/metaTypeNames.js
CHANGED
package/src/reference.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeAsString } from "./utilities/string";
|
|
4
|
+
|
|
5
|
+
export default class Reference {
|
|
6
|
+
constructor(metavariableNode) {
|
|
7
|
+
this.metavariableNode = metavariableNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
getMetavariableNode() {
|
|
11
|
+
return this.metavariableNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
matchMetavariableNode(metavariableNode) {
|
|
15
|
+
const metavariableNodeMatches = this.metavariableNode.match(metavariableNode);
|
|
16
|
+
|
|
17
|
+
return metavariableNodeMatches;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
asString(tokens) {
|
|
21
|
+
const string = nodeAsString(this.metavariableNode, tokens);
|
|
22
|
+
|
|
23
|
+
return string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static fromMetavariableNode(metavariableNode) {
|
|
27
|
+
const reference = new Reference(metavariableNode);
|
|
28
|
+
|
|
29
|
+
return reference;
|
|
30
|
+
}
|
|
31
|
+
}
|
package/src/rule.js
CHANGED
|
@@ -29,16 +29,6 @@ export default class Rule {
|
|
|
29
29
|
return this.fileContext;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
getLabelMetavariableNodes() {
|
|
33
|
-
const labelMetavariableNodes = this.labels.map((label) => {
|
|
34
|
-
const labelMetavariableNode = label.getMetavariableNode();
|
|
35
|
-
|
|
36
|
-
return labelMetavariableNode;
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return labelMetavariableNodes;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
32
|
unifyStatement(statementNode, localContext) {
|
|
43
33
|
let statementUnified = false;
|
|
44
34
|
|
package/src/topLevelAssertion.js
CHANGED
|
@@ -34,16 +34,6 @@ export default class TopLevelAssertion {
|
|
|
34
34
|
return this.fileContext;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
getLabelMetavariableNodes() {
|
|
38
|
-
const labelMetavariableNodes = this.labels.map((label) => {
|
|
39
|
-
const labelMetavariableNode = label.getMetavariableNode();
|
|
40
|
-
|
|
41
|
-
return labelMetavariableNode;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return labelMetavariableNodes;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
37
|
unifyStatement(statementNode, localContext) {
|
|
48
38
|
let statementUnified = false;
|
|
49
39
|
|
|
@@ -46,18 +46,17 @@ function unifyQualifiedStatementAWithRule(qualifiedStatementNode, substitutions,
|
|
|
46
46
|
|
|
47
47
|
if (rule !== null) {
|
|
48
48
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
49
|
-
|
|
50
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
51
|
-
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
49
|
+
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
50
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
52
51
|
|
|
53
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
52
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' rule...`, qualifiedStatementNode);
|
|
54
53
|
|
|
55
54
|
const statementUnified = rule.unifyStatement(statementNode, localContext);
|
|
56
55
|
|
|
57
56
|
qualifiedStatementUnifiedWithRule = statementUnified; ///
|
|
58
57
|
|
|
59
58
|
if (qualifiedStatementUnifiedWithRule) {
|
|
60
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
59
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' rule.`, qualifiedStatementNode);
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -72,18 +71,17 @@ function unifyQualifiedStatementAWithAxiom(qualifiedStatementNode, substitutions
|
|
|
72
71
|
|
|
73
72
|
if (axiom !== null) {
|
|
74
73
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
75
|
-
|
|
76
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
77
|
-
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
74
|
+
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
75
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
78
76
|
|
|
79
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
77
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' axiom...`, qualifiedStatementNode);
|
|
80
78
|
|
|
81
79
|
const statementUnified = axiom.unifyStatement(statementNode, localContext);
|
|
82
80
|
|
|
83
81
|
qualifiedStatementUnifiedWithAxiom = statementUnified; ///
|
|
84
82
|
|
|
85
83
|
if (qualifiedStatementUnifiedWithAxiom) {
|
|
86
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
84
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' axiom.`, qualifiedStatementNode);
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
87
|
|
|
@@ -98,18 +96,17 @@ function unifyQualifiedStatementAWithLemma(qualifiedStatementNode, substitutions
|
|
|
98
96
|
|
|
99
97
|
if (lemma !== null) {
|
|
100
98
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
101
|
-
|
|
102
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
103
|
-
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
99
|
+
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
100
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
104
101
|
|
|
105
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
102
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' lemma...`, qualifiedStatementNode);
|
|
106
103
|
|
|
107
104
|
const statementUnified = lemma.unifyStatement(statementNode, localContext);
|
|
108
105
|
|
|
109
106
|
qualifiedStatementUnifiedWithLemma = statementUnified; ///
|
|
110
107
|
|
|
111
108
|
if (qualifiedStatementUnifiedWithLemma) {
|
|
112
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
109
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' lemma.`, qualifiedStatementNode);
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
|
|
@@ -124,18 +121,17 @@ function unifyQualifiedStatementAWithTheorem(qualifiedStatementNode, substitutio
|
|
|
124
121
|
|
|
125
122
|
if (theorem !== null) {
|
|
126
123
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
127
|
-
|
|
128
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
129
|
-
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
124
|
+
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
125
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
130
126
|
|
|
131
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
127
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' theorem...`, qualifiedStatementNode);
|
|
132
128
|
|
|
133
129
|
const statementUnified = theorem.unifyStatement(statementNode, localContext);
|
|
134
130
|
|
|
135
131
|
qualifiedStatementUnifiedWithTheorem = statementUnified; ///
|
|
136
132
|
|
|
137
133
|
if (qualifiedStatementUnifiedWithTheorem) {
|
|
138
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
134
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' theorem.`, qualifiedStatementNode);
|
|
139
135
|
}
|
|
140
136
|
}
|
|
141
137
|
|
|
@@ -150,18 +146,17 @@ function unifyQualifiedStatementAWithConjecture(qualifiedStatementNode, substitu
|
|
|
150
146
|
|
|
151
147
|
if (conjecture !== null) {
|
|
152
148
|
const statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
153
|
-
|
|
154
|
-
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode)
|
|
155
|
-
labelMetavariableNodesString = localContext.nodesAsString(labelMetavariableNodes);
|
|
149
|
+
metavariableString = localContext.nodeAsString(metavariableNode),
|
|
150
|
+
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
156
151
|
|
|
157
|
-
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${
|
|
152
|
+
localContext.trace(`Unifying the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' conjecture...`, qualifiedStatementNode);
|
|
158
153
|
|
|
159
154
|
const statementUnified = conjecture.unifyStatement(statementNode, localContext);
|
|
160
155
|
|
|
161
156
|
qualifiedStatementUnifiedWithConjecture = statementUnified; ///
|
|
162
157
|
|
|
163
158
|
if (qualifiedStatementUnifiedWithConjecture) {
|
|
164
|
-
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${
|
|
159
|
+
localContext.debug(`...unified the '${qualifiedStatementString}' qualified statement with the '${metavariableString}' conjecture.`, qualifiedStatementNode);
|
|
165
160
|
}
|
|
166
161
|
}
|
|
167
162
|
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import shim from "../shim";
|
|
4
|
+
import Reference from "../reference";
|
|
4
5
|
import Declaration from "../declaration"
|
|
5
6
|
import referenceMetaType from "../metaType/reference";
|
|
6
7
|
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
7
8
|
|
|
8
9
|
import { nodeQuery } from "../utilities/query";
|
|
9
10
|
|
|
10
|
-
const statementNodeQuery = nodeQuery("/declaration/statement
|
|
11
|
-
metavariableNodeQuery = nodeQuery("/declaration/
|
|
11
|
+
const statementNodeQuery = nodeQuery("/declaration/statement"),
|
|
12
|
+
metavariableNodeQuery = nodeQuery("/declaration/reference/metavariable"); ///
|
|
12
13
|
|
|
13
14
|
const verifyDeclarationFunctions = [
|
|
14
15
|
verifyDerivedDeclaration,
|
|
@@ -46,8 +47,9 @@ function verifyDerivedDeclaration(declarationNode, declarations, stated, localCo
|
|
|
46
47
|
localContext.trace(`Verifying the '${declarationString}' derived declaration...`, declarationNode);
|
|
47
48
|
|
|
48
49
|
const metaType = referenceMetaType, ///
|
|
50
|
+
metavariables = [],
|
|
49
51
|
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
50
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
52
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
|
|
51
53
|
|
|
52
54
|
if (metavariableVerifiedGivenMetaType) {
|
|
53
55
|
const { verifyStatement } = shim,
|
|
@@ -57,7 +59,8 @@ function verifyDerivedDeclaration(declarationNode, declarations, stated, localCo
|
|
|
57
59
|
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
58
60
|
|
|
59
61
|
if (statementVerified) {
|
|
60
|
-
const
|
|
62
|
+
const reference = Reference.fromMetavariableNode(metavariableNode),
|
|
63
|
+
declaration = Declaration.fromReferenceAndStatementNode(reference, statementNode);
|
|
61
64
|
|
|
62
65
|
declarations.push(declaration);
|
|
63
66
|
|
|
@@ -82,18 +85,20 @@ function verifyStatedDeclaration(declarationNode, declarations, stated, localCon
|
|
|
82
85
|
localContext.trace(`Verifying the '${declarationString}' stated declaration...`, declarationNode);
|
|
83
86
|
|
|
84
87
|
const metaType = referenceMetaType, ///
|
|
88
|
+
metavariables = [],
|
|
85
89
|
metavariableNode = metavariableNodeQuery(declarationNode),
|
|
86
|
-
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext);
|
|
90
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
|
|
87
91
|
|
|
88
92
|
if (metavariableVerifiedGivenMetaType) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
const { verifyStatement } = shim,
|
|
94
|
+
stated = true,
|
|
95
|
+
assignments = null,
|
|
96
|
+
statementNode = statementNodeQuery(declarationNode),
|
|
97
|
+
statementVerified = verifyStatement(statementNode, assignments, stated, localContext);
|
|
94
98
|
|
|
95
99
|
if (statementVerified) {
|
|
96
|
-
const
|
|
100
|
+
const reference = Reference.fromMetavariableNode(metavariableNode),
|
|
101
|
+
declaration = Declaration.fromReferenceAndStatementNode(reference, statementNode);
|
|
97
102
|
|
|
98
103
|
declarations.push(declaration);
|
|
99
104
|
|
package/src/verify/frame.js
CHANGED
|
@@ -3,10 +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 "
|
|
6
|
+
import verifyMetavariableGivenMetaType from "./metavariableGivenMetaType";
|
|
7
7
|
|
|
8
|
+
import { first } from "../utilities/array";
|
|
8
9
|
import { nodesQuery } from "../utilities/query";
|
|
9
|
-
import { first, push } from "../utilities/array";
|
|
10
10
|
|
|
11
11
|
const declarationNodesQuery = nodesQuery("/frame/declaration"),
|
|
12
12
|
metavariableNodesQuery = nodesQuery("/frame/metavariable");
|
|
@@ -46,31 +46,33 @@ function verifyDerivedFrame(frameNode, frames, stated, localContext) {
|
|
|
46
46
|
|
|
47
47
|
localContext.trace(`Verifying the '${frameString}' derived frame...`, frameNode);
|
|
48
48
|
|
|
49
|
-
const
|
|
50
|
-
|
|
49
|
+
const declarations = [],
|
|
50
|
+
declarationNodes = declarationNodesQuery(frameNode),
|
|
51
|
+
declarationsVerified = declarationNodes.every((declarationNode) => {
|
|
52
|
+
const declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
53
|
+
|
|
54
|
+
if (declarationVerified) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
51
58
|
|
|
52
|
-
if (
|
|
59
|
+
if (declarationsVerified) {
|
|
53
60
|
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
54
|
-
|
|
61
|
+
metavariablesVerified = metavariableNodes.every((metavariableNode) => {
|
|
62
|
+
const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localContext);
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
64
|
+
if (metavariableVerified) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
61
68
|
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
if (metavariablesVerified) {
|
|
70
|
+
const frame = Frame.fromDeclarations(declarations);
|
|
64
71
|
|
|
65
|
-
|
|
72
|
+
frames.push(frame);
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
} else {
|
|
70
|
-
localContext.debug(`The '${frameString}' derived frame must no spread metavariables.`, frameNode);
|
|
74
|
+
derivedFrameVerified = true; ///
|
|
71
75
|
}
|
|
72
|
-
} else {
|
|
73
|
-
localContext.debug(`The '${frameString}' derived frame must have one and only one declaration.`, frameNode);
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
if (derivedFrameVerified) {
|
|
@@ -89,30 +91,36 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
|
|
|
89
91
|
|
|
90
92
|
localContext.trace(`Verifying the '${frameString}' stated frame...`, frameNode);
|
|
91
93
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
declarationsVerified = declarationNodes.every((declarationNode) => {
|
|
95
|
-
const declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
94
|
+
const declarationNodes = declarationNodesQuery(frameNode),
|
|
95
|
+
declarationNodesLength = declarationNodes.length;
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
if (declarationNodesLength === 0) {
|
|
98
|
+
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
99
|
+
metavariableNodesLength = metavariableNodes.length;
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
if (metavariableNodesLength === 1) {
|
|
102
|
+
const firstMetavariableNode = first(metavariableNodes),
|
|
103
|
+
metavariableNode = firstMetavariableNode,
|
|
104
|
+
metaType = frameMetaType, ///
|
|
105
|
+
metavariables = [],
|
|
106
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
|
|
104
107
|
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
if (metavariableVerifiedGivenMetaType) {
|
|
109
|
+
const firstMetavariable = first(metavariables),
|
|
110
|
+
metavariable = firstMetavariable,
|
|
107
111
|
|
|
108
|
-
|
|
109
|
-
const frame = Frame.fromDeclarations(declarations);
|
|
112
|
+
frame = Frame.fromMetavariable(metavariable);
|
|
110
113
|
|
|
111
|
-
|
|
114
|
+
frames.push(frame);
|
|
112
115
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
statedFrameVerified = true;
|
|
117
|
+
}
|
|
118
|
+
} else {
|
|
119
|
+
localContext.trace(`The '${frameString}' stated frame cannot have more than one metavariable.`, frameNode);
|
|
120
|
+
}
|
|
121
|
+
} else {
|
|
122
|
+
localContext.trace(`The '${frameString}' stated frame cannot have declarations.`, frameNode);
|
|
123
|
+
}
|
|
116
124
|
|
|
117
125
|
if (statedFrameVerified) {
|
|
118
126
|
localContext.debug(`...verified the '${frameString}' stated frame.`, frameNode);
|
|
@@ -125,24 +133,34 @@ function verifyStatedFrame(frameNode, frames, stated, localContext) {
|
|
|
125
133
|
function verifyMetavariable(metavariableNode, declarations, localContext) {
|
|
126
134
|
let metavariableVerified = false;
|
|
127
135
|
|
|
136
|
+
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
137
|
+
|
|
138
|
+
localContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
139
|
+
|
|
128
140
|
const metaType = frameMetaType, ///
|
|
129
|
-
|
|
141
|
+
metavariables = [],
|
|
142
|
+
metavariableVerifiedGivenMetaType = verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext);
|
|
130
143
|
|
|
131
144
|
if (metavariableVerifiedGivenMetaType) {
|
|
132
|
-
const
|
|
145
|
+
const firstMetavariable = first(metavariables),
|
|
146
|
+
metavariable = firstMetavariable, ///
|
|
147
|
+
metavariableName = metavariable.getName(),
|
|
148
|
+
judgement = localContext.findJudgementByMetavariableName(metavariableName);
|
|
133
149
|
|
|
134
150
|
if (judgement !== null) {
|
|
135
|
-
const
|
|
151
|
+
const declaration = judgement.getDeclaration();
|
|
136
152
|
|
|
137
|
-
push(
|
|
153
|
+
declarations.push(declaration);
|
|
138
154
|
|
|
139
155
|
metavariableVerified = true;
|
|
140
156
|
} else {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
localContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode)
|
|
157
|
+
localContext.trace(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode);
|
|
144
158
|
}
|
|
145
159
|
}
|
|
146
160
|
|
|
161
|
+
if (metavariableVerified) {
|
|
162
|
+
localContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
163
|
+
}
|
|
164
|
+
|
|
147
165
|
return metavariableVerified;
|
|
148
166
|
}
|
package/src/verify/judgement.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import Judgement from "../judgement";
|
|
4
4
|
import verifyFrame from "../verify/frame";
|
|
5
|
-
import
|
|
5
|
+
import verifyDeclaration from "./declaration";
|
|
6
6
|
import JudgementAssignment from "../assignment/judgement";
|
|
7
|
-
import verifyMetavariableGivenMetaType from "../verify/metavariableGivenMetaType";
|
|
8
7
|
|
|
9
8
|
import { first } from "../utilities/array";
|
|
10
9
|
import { nodeQuery } from "../utilities/query";
|
|
10
|
+
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
11
11
|
|
|
12
|
-
const frameNodeQuery = nodeQuery("/judgement/frame
|
|
13
|
-
|
|
12
|
+
const frameNodeQuery = nodeQuery("/judgement/frame"),
|
|
13
|
+
declarationNodeQuery = nodeQuery("/judgement/declaration");
|
|
14
14
|
|
|
15
15
|
const verifyJudgementFunctions = [
|
|
16
16
|
verifyDerivedJudgement,
|
|
@@ -47,40 +47,29 @@ function verifyDerivedJudgement(judgementNode, assignments, stated, localContext
|
|
|
47
47
|
|
|
48
48
|
localContext.trace(`Verifying the '${judgementString}' derived judgement...`, judgementNode);
|
|
49
49
|
|
|
50
|
-
const
|
|
50
|
+
const declarations = [],
|
|
51
|
+
declarationNode = declarationNodeQuery(judgementNode),
|
|
52
|
+
declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
51
53
|
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
54
|
-
|
|
54
|
+
if (declarationVerified) {
|
|
55
|
+
const firstDeclaration = first(declarations),
|
|
56
|
+
declaration = firstDeclaration, ///
|
|
57
|
+
metavariableNode = declaration.getMetavariableNode(),
|
|
58
|
+
metatheorem = localContext.findMetatheoremByMetavariableNode(metavariableNode),
|
|
59
|
+
metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
|
|
60
|
+
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
55
61
|
|
|
56
|
-
if (
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const frames = [],
|
|
61
|
-
frameNode = frameNodeQuery(judgementNode),
|
|
62
|
-
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
63
|
-
|
|
64
|
-
if (frameVerified) {
|
|
65
|
-
const firstFrame = first(frames),
|
|
66
|
-
frame = firstFrame, ///
|
|
67
|
-
declaration = frame.getDeclaration(),
|
|
68
|
-
metavariableNode = declaration.getMetavariableNode(),
|
|
69
|
-
metatheorem = localContext.findMetatheoremByMetavariableNode(metavariableNode),
|
|
70
|
-
metaLemma = localContext.findMetaLemmaByMetavariableNode(metavariableNode),
|
|
71
|
-
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
72
|
-
|
|
73
|
-
if (metaLemmaMetatheorem !== null) {
|
|
74
|
-
const metaLemmaMetatheoremUnifiedWithJudgement = judgement.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem),
|
|
75
|
-
metaLemmaMetatheoremUnifiedWithDeclaration = declaration.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem);
|
|
62
|
+
if (metaLemmaMetatheorem !== null) {
|
|
63
|
+
const frames = [],
|
|
64
|
+
frameNode = frameNodeQuery(judgementNode),
|
|
65
|
+
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
76
66
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const metavariableString = localContext.nodeAsString(metavariableNode);
|
|
67
|
+
if (frameVerified) {
|
|
68
|
+
const firstFrame = first(frames),
|
|
69
|
+
frame = firstFrame, ///
|
|
70
|
+
metaLemmaMetatheoremUnified = frame.unifyMetaLemmaOrMetatheorem(metaLemmaMetatheorem);
|
|
82
71
|
|
|
83
|
-
|
|
72
|
+
derivedJudgementVerified = metaLemmaMetatheoremUnified; ///
|
|
84
73
|
}
|
|
85
74
|
}
|
|
86
75
|
}
|
|
@@ -101,22 +90,28 @@ function verifyStatedJudgement(judgementNode, assignments, stated, localContext)
|
|
|
101
90
|
|
|
102
91
|
localContext.trace(`Verifying the '${judgementString}' stated judgement...`, judgementNode);
|
|
103
92
|
|
|
104
|
-
const
|
|
93
|
+
const frames = [],
|
|
94
|
+
frameNode = frameNodeQuery(judgementNode),
|
|
95
|
+
frameVerified = verifyFrame(frameNode, frames, stated, localContext);
|
|
105
96
|
|
|
106
|
-
if (
|
|
107
|
-
const
|
|
108
|
-
|
|
97
|
+
if (frameVerified) {
|
|
98
|
+
const firstFrame = first(frames),
|
|
99
|
+
frame = firstFrame, ///
|
|
100
|
+
metavariable = frame.getMetavariable(),
|
|
101
|
+
metavariableNode = metavariable.getNode(),
|
|
102
|
+
metavariableName = metavariableNameFromMetavariableNode(metavariableNode),
|
|
103
|
+
judgementPresent = localContext.isJudgementPresentByMetavariableName(metavariableName);
|
|
109
104
|
|
|
110
|
-
if (
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
if (!judgementPresent) {
|
|
106
|
+
const declarations = [],
|
|
107
|
+
declarationNode = declarationNodeQuery(judgementNode),
|
|
108
|
+
declarationVerified = verifyDeclaration(declarationNode, declarations, stated, localContext);
|
|
114
109
|
|
|
115
|
-
if (
|
|
110
|
+
if (declarationVerified) {
|
|
116
111
|
if (assignments !== null) {
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
judgement = Judgement.
|
|
112
|
+
const firstDeclaration = first(declarations),
|
|
113
|
+
declaration = firstDeclaration, ///
|
|
114
|
+
judgement = Judgement.fromJudgementNodeFrameAndDeclaration(judgementNode, frame, declaration),
|
|
120
115
|
judgementAssignment = JudgementAssignment.fromJudgement(judgement),
|
|
121
116
|
assignment = judgementAssignment;
|
|
122
117
|
|
|
@@ -125,6 +120,8 @@ function verifyStatedJudgement(judgementNode, assignments, stated, localContext)
|
|
|
125
120
|
|
|
126
121
|
statedJudgementVerified = true;
|
|
127
122
|
}
|
|
123
|
+
} else {
|
|
124
|
+
localContext.trace(`There is already a judgement for the '${metavariableName}' metavariable.`, judgementNode);
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
|
|
@@ -4,7 +4,7 @@ import metavariableUnifier from "../unifier/metavariable";
|
|
|
4
4
|
|
|
5
5
|
import { metavariableNameFromMetavariableNode } from "../utilities/name";
|
|
6
6
|
|
|
7
|
-
export default function verifyMetavariableGivenMetaType(metavariableNode, metaType, localContext) {
|
|
7
|
+
export default function verifyMetavariableGivenMetaType(metavariableNode, metaType, metavariables, localContext) {
|
|
8
8
|
let metavariableVerifiedGivenMetaType = false;
|
|
9
9
|
|
|
10
10
|
const metaTypeName = metaType.getName(),
|
|
@@ -27,7 +27,11 @@ export default function verifyMetavariableGivenMetaType(metavariableNode, metaTy
|
|
|
27
27
|
|
|
28
28
|
const unified = metavariableUnifier.unify(metavariableNodeA, metavariableNodeB, localContext);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
if (unified) {
|
|
31
|
+
metavariables.push(metavariable);
|
|
32
|
+
|
|
33
|
+
metavariableVerifiedGivenMetaType = true;
|
|
34
|
+
}
|
|
31
35
|
} else {
|
|
32
36
|
const metavariableMetaTypeName = metavariableMetaType.getName();
|
|
33
37
|
|
package/src/verify/statement.js
CHANGED
|
@@ -96,7 +96,7 @@ function verifyStatementAsMetavariable(statementNode, assignments, stated, local
|
|
|
96
96
|
|
|
97
97
|
const metavariableUnified = unifyMetavariable(metavariableNode, localContext);
|
|
98
98
|
|
|
99
|
-
statementVerifiedAsMetavariable = metavariableUnified;
|
|
99
|
+
statementVerifiedAsMetavariable = metavariableUnified; ///
|
|
100
100
|
|
|
101
101
|
if (statementVerifiedAsMetavariable) {
|
|
102
102
|
localContext.debug(`...verified the '${statementString}' statement as a metavariable.`, statementNode);
|