occam-verify-cli 0.0.881 → 0.0.883
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/axiomLemmaTheoremConjecture.js +4 -10
- package/lib/context/file.js +40 -41
- package/lib/context/localMeta.js +27 -2
- package/lib/declaration.js +90 -0
- package/lib/frame.js +52 -13
- package/lib/judgement.js +28 -9
- package/lib/label.js +3 -3
- package/lib/metaLemmaMetatheorem.js +4 -4
- package/lib/mixins/context.js +32 -24
- package/lib/premise.js +8 -32
- package/lib/rule.js +4 -10
- package/lib/step/metaproof.js +2 -2
- package/lib/supposition.js +1 -53
- package/lib/verify/declaration.js +34 -16
- package/lib/verify/frame.js +47 -6
- package/lib/verify/judgement.js +63 -47
- package/lib/verify/label.js +8 -8
- package/lib/verify/labels.js +4 -4
- package/lib/verify/metastatement/qualified.js +12 -8
- package/lib/verify/statement/qualified.js +6 -6
- package/package.json +4 -4
- package/src/axiomLemmaTheoremConjecture.js +3 -12
- package/src/context/file.js +32 -33
- package/src/context/localMeta.js +32 -1
- package/src/declaration.js +58 -0
- package/src/frame.js +52 -10
- package/src/judgement.js +16 -6
- package/src/label.js +2 -2
- package/src/metaLemmaMetatheorem.js +3 -3
- package/src/mixins/context.js +21 -15
- package/src/premise.js +9 -50
- package/src/rule.js +3 -12
- package/src/step/metaproof.js +2 -2
- package/src/supposition.js +0 -45
- package/src/verify/declaration.js +47 -20
- package/src/verify/frame.js +66 -5
- package/src/verify/judgement.js +101 -50
- package/src/verify/label.js +7 -8
- package/src/verify/labels.js +4 -3
- package/src/verify/metastatement/qualified.js +14 -11
- package/src/verify/statement/qualified.js +10 -10
package/src/mixins/context.js
CHANGED
|
@@ -26,7 +26,7 @@ function getConstructors() { return this.context.getConstructors(); }
|
|
|
26
26
|
|
|
27
27
|
function findTypeByTypeName(typeName) { return this.context.findTypeByTypeName(typeName); }
|
|
28
28
|
|
|
29
|
-
function findTypeByTypeNode(
|
|
29
|
+
function findTypeByTypeNode(typeNode) { return this.context.findTypeByTypeNode(typeNode); }
|
|
30
30
|
|
|
31
31
|
function findMetavariableByName(name) { return this.context.findMetavariableByName(name); }
|
|
32
32
|
|
|
@@ -36,19 +36,23 @@ function isTypePresentByTypeNode(typeNode) { return this.context.isTypePresentBy
|
|
|
36
36
|
|
|
37
37
|
function isMetavariablePresentByName(name) { return this.context.isMetavariablePresentByName(name); }
|
|
38
38
|
|
|
39
|
-
function
|
|
39
|
+
function isLabelPresentByMetavariableNode(metavariableNode) { return this.context.isLabelPresentByMetavariableNode(metavariableNode); }
|
|
40
40
|
|
|
41
|
-
function
|
|
41
|
+
function findLabelByMetavariableNode(metavariableNode) { return this.context.findLabelByMetavariableNode(metavariableNode); }
|
|
42
42
|
|
|
43
|
-
function
|
|
43
|
+
function findRuleByMetavariableNode(metavariableNode) { return this.context.findRuleByMetavariableNode(metavariableNode); }
|
|
44
44
|
|
|
45
|
-
function
|
|
45
|
+
function findAxiomByMetavariableNode(metavariableNode) { return this.context.findAxiomByMetavariableNode(metavariableNode); }
|
|
46
46
|
|
|
47
|
-
function
|
|
47
|
+
function findLemmaByMetavariableNode(metavariableNode) { return this.context.findLemmaByMetavariableNode(metavariableNode); }
|
|
48
48
|
|
|
49
|
-
function
|
|
49
|
+
function findTheoremByMetavariableNode(metavariableNode) { return this.context.findTheoremByMetavariableNode(metavariableNode); }
|
|
50
50
|
|
|
51
|
-
function
|
|
51
|
+
function findMetaLemmaByMetavariableNode(metavariableNode) { return this.context.findMetaLemmaByMetavariableNode(metavariableNode); }
|
|
52
|
+
|
|
53
|
+
function findConjectureByMetavariableNode(metavariableNode) { return this.context.findConjectureByMetavariableNode(metavariableNode); }
|
|
54
|
+
|
|
55
|
+
function findMetatheoremByMetavariableNode(metavariableNode) { return this.context.findMetatheoremByMetavariableNode(metavariableNode); }
|
|
52
56
|
|
|
53
57
|
function nodeAsString(node) { return this.context.nodeAsString(node); }
|
|
54
58
|
|
|
@@ -73,13 +77,15 @@ const contextMixins = {
|
|
|
73
77
|
isTypePresentByTypeName,
|
|
74
78
|
isTypePresentByTypeNode,
|
|
75
79
|
isMetavariablePresentByName,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
isLabelPresentByMetavariableNode,
|
|
81
|
+
findLabelByMetavariableNode,
|
|
82
|
+
findRuleByMetavariableNode,
|
|
83
|
+
findAxiomByMetavariableNode,
|
|
84
|
+
findLemmaByMetavariableNode,
|
|
85
|
+
findTheoremByMetavariableNode,
|
|
86
|
+
findMetaLemmaByMetavariableNode,
|
|
87
|
+
findConjectureByMetavariableNode,
|
|
88
|
+
findMetatheoremByMetavariableNode,
|
|
83
89
|
nodeAsString,
|
|
84
90
|
nodesAsString
|
|
85
91
|
};
|
package/src/premise.js
CHANGED
|
@@ -9,11 +9,9 @@ import { nodeAsString } from "./utilities/string";
|
|
|
9
9
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
10
10
|
import { metastatementNodeFromMetastatementString } from "./utilities/node";
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const subproofAssertionNodeQuery = nodeQuery("/metastatement/subproofAssertion!"),
|
|
13
13
|
ruleSubproofPremiseMetastatementQuery = nodesQuery("/ruleSubproof/premise/unqualifiedMetastatement!/metastatement!"),
|
|
14
|
-
|
|
15
|
-
subproofSubDerivationLastStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!"),
|
|
16
|
-
ruleSubproofAssertionMetastatementNodesQuery = nodesQuery("/ruleSubproofAssertion/metastatement"),
|
|
14
|
+
subproofAssertionMetastatementNodesQuery = nodesQuery("/subproofAssertion/metastatement"),
|
|
17
15
|
ruleSubproofSubDerivationLastMetastatementQuery = nodeQuery("/ruleSubproof/ruleSubDerivation/qualifiedMetastatement|unqualifiedMetastatement[-1]/metastatement!");
|
|
18
16
|
|
|
19
17
|
export default class Premise {
|
|
@@ -25,45 +23,6 @@ export default class Premise {
|
|
|
25
23
|
return this.metastatementNode;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
matchSubproofNode(subproofNode, substitutions, fileContext, statementLocalContext) {
|
|
29
|
-
let subproofNodeMatches = false;
|
|
30
|
-
|
|
31
|
-
const subproofAssertionNode = ruleSubproofAssertionNodeQuery(this.metastatementNode);
|
|
32
|
-
|
|
33
|
-
if (subproofAssertionNode !== null) {
|
|
34
|
-
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
35
|
-
subproofSubDerivationLastStatementNode = subproofSubDerivationLastStatementNodeQuery(subproofNode),
|
|
36
|
-
subproofStatementNodes = [
|
|
37
|
-
...subproofSuppositionStatementNodes,
|
|
38
|
-
subproofSubDerivationLastStatementNode
|
|
39
|
-
],
|
|
40
|
-
ruleSubproofAssertionMetastatementNodes = ruleSubproofAssertionMetastatementNodesQuery(subproofAssertionNode),
|
|
41
|
-
subproofStatementNodesLength = subproofStatementNodes.length,
|
|
42
|
-
ruleSubproofAssertionMetastatementNodesLength = ruleSubproofAssertionMetastatementNodes.length;
|
|
43
|
-
|
|
44
|
-
if (subproofStatementNodesLength === ruleSubproofAssertionMetastatementNodesLength) {
|
|
45
|
-
subproofNodeMatches = match(ruleSubproofAssertionMetastatementNodes, subproofStatementNodes, (ruleSubproofAssertionMetastatementNode, subproofStatementNode) => {
|
|
46
|
-
const nonTerminalNodeA = ruleSubproofAssertionMetastatementNode, ///
|
|
47
|
-
nonTerminalNodeB = subproofStatementNode, ///
|
|
48
|
-
fileContextA = fileContext, ///
|
|
49
|
-
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
50
|
-
localContextB = statementLocalContext, ///
|
|
51
|
-
nonTerminalNodeVerified = intrinsicLevelAgainstMetaLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
52
|
-
const verifiedAhead = true;
|
|
53
|
-
|
|
54
|
-
return verifiedAhead;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
if (nonTerminalNodeVerified) {
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return subproofNodeMatches;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
26
|
matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext) {
|
|
68
27
|
const nonTerminalNodeA = this.metastatementNode, ///
|
|
69
28
|
nonTerminalNodeB = statementNode, ///
|
|
@@ -83,9 +42,9 @@ export default class Premise {
|
|
|
83
42
|
matchRuleSubproofNode(ruleSubproofNode, substitutions, fileContext, metastatementLocalMetaContext) {
|
|
84
43
|
let ruleSubproofNodeMatches = false;
|
|
85
44
|
|
|
86
|
-
const
|
|
45
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.metastatementNode);
|
|
87
46
|
|
|
88
|
-
if (
|
|
47
|
+
if (subproofAssertionNode !== null) {
|
|
89
48
|
const ruleSubproofPremiseMetastatement = ruleSubproofPremiseMetastatementQuery(ruleSubproofNode),
|
|
90
49
|
ruleSubproofSubDerivationLastMetastatement = ruleSubproofSubDerivationLastMetastatementQuery(ruleSubproofNode),
|
|
91
50
|
ruleSubproofMetastatementNodes = [
|
|
@@ -93,12 +52,12 @@ export default class Premise {
|
|
|
93
52
|
ruleSubproofSubDerivationLastMetastatement
|
|
94
53
|
],
|
|
95
54
|
ruleSubproofMetastatementNodesLength = ruleSubproofMetastatementNodes.length,
|
|
96
|
-
|
|
97
|
-
|
|
55
|
+
subproofAssertionMetastatementNodes = subproofAssertionMetastatementNodesQuery(subproofAssertionNode),
|
|
56
|
+
subproofAssertionMetastatementNodesLength = subproofAssertionMetastatementNodes.length;
|
|
98
57
|
|
|
99
|
-
if (ruleSubproofMetastatementNodesLength ===
|
|
100
|
-
ruleSubproofNodeMatches = match(
|
|
101
|
-
const nonTerminalNodeA =
|
|
58
|
+
if (ruleSubproofMetastatementNodesLength === subproofAssertionMetastatementNodesLength) {
|
|
59
|
+
ruleSubproofNodeMatches = match(subproofAssertionMetastatementNodes, ruleSubproofMetastatementNodes, (subproofAssertionMetastatementNode, ruleSubproofMetastatementNode) => {
|
|
60
|
+
const nonTerminalNodeA = subproofAssertionMetastatementNode, ///
|
|
102
61
|
nonTerminalNodeB = ruleSubproofMetastatementNode, ///
|
|
103
62
|
fileContextA = fileContext, ///
|
|
104
63
|
localContextA = LocalContext.fromFileContext(fileContextA),
|
package/src/rule.js
CHANGED
|
@@ -99,9 +99,9 @@ export default class Rule {
|
|
|
99
99
|
return metastatementNatches;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
matchLabelMetavariableNode(
|
|
102
|
+
matchLabelMetavariableNode(metavariableNode) {
|
|
103
103
|
const labelMetavariableNodeMatches = this.labels.some((label) => {
|
|
104
|
-
const node =
|
|
104
|
+
const node = metavariableNode, ///
|
|
105
105
|
labelMatchesNode = label.matchNode(node);
|
|
106
106
|
|
|
107
107
|
if (labelMatchesNode) {
|
|
@@ -183,16 +183,7 @@ export default class Rule {
|
|
|
183
183
|
|
|
184
184
|
function matchPremise(premise, proofSteps, substitutions, fileContext, statementLocalContext) {
|
|
185
185
|
const proofStep = prune(proofSteps, (proofStep) => {
|
|
186
|
-
const
|
|
187
|
-
statementNode = proofStep.getStatementNode()
|
|
188
|
-
|
|
189
|
-
if (subproofNode !== null) {
|
|
190
|
-
const subProofNodeMatches = premise.matchSubproofNode(subproofNode, substitutions, fileContext, statementLocalContext);
|
|
191
|
-
|
|
192
|
-
if (!subProofNodeMatches) { ///
|
|
193
|
-
return true;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
186
|
+
const statementNode = proofStep.getStatementNode()
|
|
196
187
|
|
|
197
188
|
if (statementNode !== null) {
|
|
198
189
|
const statementNodeMatches = premise.matchStatementNode(statementNode, substitutions, fileContext, statementLocalContext);
|
package/src/step/metaproof.js
CHANGED
|
@@ -4,8 +4,8 @@ import { first, second } from "../utilities/array";
|
|
|
4
4
|
import { matchMetastatement } from "../utilities/metaproof";
|
|
5
5
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
6
6
|
|
|
7
|
-
const metastatementNodesQuery = nodesQuery("/
|
|
8
|
-
ruleSubproofAssertionNodeQuery = nodeQuery("/metastatement/
|
|
7
|
+
const metastatementNodesQuery = nodesQuery("/subproofAssertion/metastatement"),
|
|
8
|
+
ruleSubproofAssertionNodeQuery = nodeQuery("/metastatement/subproofAssertion"),
|
|
9
9
|
qualifiedOrUnqualifiedMetastatementMetastatementNodesQuery = nodesQuery("/ruleSubproof/qualifiedMetastatement|unqualifiedMetastatement/metastatement!");
|
|
10
10
|
|
|
11
11
|
export default class MetaproofStep {
|
package/src/supposition.js
CHANGED
|
@@ -2,16 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import intrinsicLevelNodesVerifier from "./verifier/nodes/intrinsicLevel";
|
|
4
4
|
|
|
5
|
-
import { match } from "./utilities/array";
|
|
6
5
|
import { nodeAsString } from "./utilities/string";
|
|
7
|
-
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
6
|
import { statementNodeFromStatementString } from "./utilities/node";
|
|
9
7
|
|
|
10
|
-
const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
11
|
-
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
12
|
-
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
13
|
-
subproofSubDerivationLastStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!");
|
|
14
|
-
|
|
15
8
|
export default class Supposition {
|
|
16
9
|
constructor(statementNode) {
|
|
17
10
|
this.statementNode = statementNode;
|
|
@@ -21,44 +14,6 @@ export default class Supposition {
|
|
|
21
14
|
return this.statementNode;
|
|
22
15
|
}
|
|
23
16
|
|
|
24
|
-
matchSubproofNode(subproofNode, substitutions, localContext, statementLocalContext) {
|
|
25
|
-
let subproofNodeMatches = false;
|
|
26
|
-
|
|
27
|
-
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
28
|
-
|
|
29
|
-
if (subproofAssertionNode !== null) {
|
|
30
|
-
const subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
31
|
-
subproofSubDerivationLastStatementNode = subproofSubDerivationLastStatementNodeQuery(subproofNode),
|
|
32
|
-
subproofStatementNodes = [
|
|
33
|
-
...subproofSuppositionStatementNodes,
|
|
34
|
-
subproofSubDerivationLastStatementNode
|
|
35
|
-
],
|
|
36
|
-
subproofAssertionStatementNodes = subproofAssertionStatementNodesQuery(subproofAssertionNode),
|
|
37
|
-
subproofStatementNodesLength = subproofStatementNodes.length,
|
|
38
|
-
subproofAssertionStatementNodesLength = subproofAssertionStatementNodes.length;
|
|
39
|
-
|
|
40
|
-
if (subproofStatementNodesLength === subproofAssertionStatementNodesLength) {
|
|
41
|
-
subproofNodeMatches = match(subproofAssertionStatementNodes, subproofStatementNodes, (subproofAssertionStatementNode, subproofStatementNode) => {
|
|
42
|
-
const nonTerminalNodeA = subproofAssertionStatementNode, ///
|
|
43
|
-
nonTerminalNodeB = subproofStatementNode, ///
|
|
44
|
-
localContextA = localContext, ///
|
|
45
|
-
localContextB = statementLocalContext, ///
|
|
46
|
-
nonTerminalNodeVerified = intrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutions, localContextA, localContextB, () => {
|
|
47
|
-
const verifiedAhead = true;
|
|
48
|
-
|
|
49
|
-
return verifiedAhead;
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
if (nonTerminalNodeVerified) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return subproofNodeMatches;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
17
|
matchStatementNode(statementNode, substitutions, localContext, statementLocalContext) {
|
|
63
18
|
const nonTerminalNodeA = this.statementNode, ///
|
|
64
19
|
nonTerminalNodeB = statementNode, ///
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Declaration from "../declaration"
|
|
3
4
|
import referenceMetaType from "../metaType/reference";
|
|
4
5
|
import metastatementNodeVerifier from "../verifier/node/metastatement";
|
|
5
6
|
|
|
@@ -8,7 +9,7 @@ import { nodeQuery } from "../utilities/query";
|
|
|
8
9
|
const metavariableNodeQuery = nodeQuery("/declaration/metavariable!"),
|
|
9
10
|
metastatementNodeQuery = nodeQuery("/declaration/metastatement!");
|
|
10
11
|
|
|
11
|
-
export default function verifyDeclaration(declarationNode,
|
|
12
|
+
export default function verifyDeclaration(declarationNode, declarations, localMetaContext) {
|
|
12
13
|
let declarationVerified = false;
|
|
13
14
|
|
|
14
15
|
const declarationString = localMetaContext.nodeAsString(declarationNode);
|
|
@@ -16,31 +17,26 @@ export default function verifyDeclaration(declarationNode, derived, localMetaCon
|
|
|
16
17
|
localMetaContext.trace(`Verifying the '${declarationString}' declaration...`, declarationNode);
|
|
17
18
|
|
|
18
19
|
const metavariableNode = metavariableNodeQuery(declarationNode),
|
|
19
|
-
|
|
20
|
+
metavariableVerified = verifyMetavariable(metavariableNode, localMetaContext);
|
|
20
21
|
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
22
|
+
if (metavariableVerified) {
|
|
23
|
+
const metastatementNode = metastatementNodeQuery(declarationNode);
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const { verifyMetastatement } = metastatementNodeVerifier,
|
|
26
|
+
derived = false,
|
|
27
|
+
assignments = [],
|
|
28
|
+
metastatementVerified = verifyMetastatement(metastatementNode, assignments, derived, localMetaContext, () => {
|
|
29
|
+
const verifiedAhead = true;
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
assignments = [],
|
|
30
|
-
metastatementVerified = verifyMetastatement(metastatementNode, assignments, derived, localMetaContext, () => {
|
|
31
|
-
const verifiedAhead = true;
|
|
31
|
+
return verifiedAhead;
|
|
32
|
+
});
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
if (metastatementVerified) {
|
|
35
|
+
const declaration = Declaration.fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
} else {
|
|
39
|
-
const referenceMetaTypeName = referenceMetaType.getName(),
|
|
40
|
-
metavariableString = localMetaContext.nodeAsString(metavariableNode),
|
|
41
|
-
metaTypeString = metaType.asString();
|
|
37
|
+
declarations.push(declaration);
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
declarationVerified = true;
|
|
44
40
|
}
|
|
45
41
|
}
|
|
46
42
|
|
|
@@ -49,4 +45,35 @@ export default function verifyDeclaration(declarationNode, derived, localMetaCon
|
|
|
49
45
|
}
|
|
50
46
|
|
|
51
47
|
return declarationVerified;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function verifyMetavariable(metavariableNode, localMetaContext) {
|
|
51
|
+
let metavariableVerified = false;
|
|
52
|
+
|
|
53
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
54
|
+
|
|
55
|
+
localMetaContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
56
|
+
|
|
57
|
+
const metavariable = localMetaContext.findMetavariableByMetavariableNode(metavariableNode, localMetaContext);
|
|
58
|
+
|
|
59
|
+
if (metavariable !== null) {
|
|
60
|
+
const metaType = metavariable.getMetaType();
|
|
61
|
+
|
|
62
|
+
if (metaType === referenceMetaType) {
|
|
63
|
+
metavariableVerified = true;
|
|
64
|
+
} else {
|
|
65
|
+
const referenceMetaTypeName = referenceMetaType.getName(),
|
|
66
|
+
metaTypeString = metaType.asString();
|
|
67
|
+
|
|
68
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${referenceMetaTypeName}'.`, metavariableNode);
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (metavariableVerified) {
|
|
75
|
+
localMetaContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return metavariableVerified;
|
|
52
79
|
}
|
package/src/verify/frame.js
CHANGED
|
@@ -1,30 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Frame from "../frame";
|
|
4
|
+
import frameMetaType from "../metaType/frame";
|
|
3
5
|
import verifyDeclaration from "../verify/declaration";
|
|
4
6
|
|
|
7
|
+
import { push } from "../utilities/array";
|
|
5
8
|
import { nodesQuery } from "../utilities/query";
|
|
6
9
|
|
|
7
|
-
const declarationNodesQuery = nodesQuery("/frame/declaration")
|
|
10
|
+
const declarationNodesQuery = nodesQuery("/frame/declaration"),
|
|
11
|
+
metavariableNodesQuery = nodesQuery("/frame/metavariable");
|
|
8
12
|
|
|
9
|
-
export default function verifyFrame(frameNode, derived, localMetaContext) {
|
|
13
|
+
export default function verifyFrame(frameNode, frames, derived, localMetaContext) {
|
|
10
14
|
let frameVerified;
|
|
11
15
|
|
|
12
16
|
const frameString = localMetaContext.nodeAsString(frameNode);
|
|
13
17
|
|
|
14
18
|
localMetaContext.trace(`Verifying the '${frameString}' frame...`, frameNode);
|
|
15
19
|
|
|
16
|
-
const
|
|
20
|
+
const declarations = [],
|
|
21
|
+
declarationNodes = declarationNodesQuery(frameNode),
|
|
17
22
|
declarationsVerified = declarationNodes.every((declarationNode) => {
|
|
18
|
-
const declarationVerified = verifyDeclaration(declarationNode,
|
|
23
|
+
const declarationVerified = verifyDeclaration(declarationNode, declarations, localMetaContext);
|
|
19
24
|
|
|
20
25
|
return declarationVerified;
|
|
21
26
|
});
|
|
22
27
|
|
|
23
|
-
|
|
28
|
+
if (declarationsVerified) {
|
|
29
|
+
const metavariableNodes = metavariableNodesQuery(frameNode),
|
|
30
|
+
metavariablesVerified = metavariableNodes.every((metavariableNode) => {
|
|
31
|
+
const metavariableVerified = verifyMetavariable(metavariableNode, declarations, localMetaContext);
|
|
32
|
+
|
|
33
|
+
return metavariableVerified;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (metavariablesVerified) {
|
|
37
|
+
const frame = Frame.fromDeclarations(declarations);
|
|
38
|
+
|
|
39
|
+
frames.push(frame);
|
|
40
|
+
|
|
41
|
+
frameVerified = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
24
44
|
|
|
25
45
|
if (frameVerified) {
|
|
26
46
|
localMetaContext.debug(`...verified the '${frameString}' frame.`, frameNode);
|
|
27
47
|
}
|
|
28
48
|
|
|
29
49
|
return frameVerified;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function verifyMetavariable(metavariableNode, declarations, localMetaContext) {
|
|
53
|
+
let metavariableVerified = false;
|
|
54
|
+
|
|
55
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
56
|
+
|
|
57
|
+
localMetaContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
58
|
+
|
|
59
|
+
const metavariable = localMetaContext.findMetavariableByMetavariableNode(metavariableNode, localMetaContext);
|
|
60
|
+
|
|
61
|
+
if (metavariable !== null) {
|
|
62
|
+
const metaType = metavariable.getMetaType();
|
|
63
|
+
|
|
64
|
+
if (metaType === frameMetaType) {
|
|
65
|
+
const judgement = localMetaContext.findJudgementByMetavariableNode(metavariableNode);
|
|
66
|
+
|
|
67
|
+
if (judgement !== null) {
|
|
68
|
+
const judgementDeclarations = judgement.getDeclarations();
|
|
69
|
+
|
|
70
|
+
push(declarations, judgementDeclarations);
|
|
71
|
+
|
|
72
|
+
metavariableVerified = true;
|
|
73
|
+
} else {
|
|
74
|
+
localMetaContext.debug(`There is no judgement for the '${metavariableString}' metavariable.`, metavariableNode);
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
const frameMetaTypeName = frameMetaType.getName(),
|
|
78
|
+
metaTypeString = metaType.asString();
|
|
79
|
+
|
|
80
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${frameMetaTypeName}'.`, metavariableNode);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (metavariableVerified) {
|
|
87
|
+
localMetaContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return metavariableVerified;
|
|
30
91
|
}
|
package/src/verify/judgement.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Judgement from "../judgement";
|
|
3
4
|
import verifyFrame from "../verify/frame";
|
|
4
5
|
import frameMetaType from "../metaType/frame";
|
|
6
|
+
import JudgementAssignment from "../assignment/judgement";
|
|
5
7
|
|
|
8
|
+
import { first } from "../utilities/array";
|
|
6
9
|
import { nodeQuery } from "../utilities/query";
|
|
7
10
|
|
|
8
11
|
const frameNodeQuery = nodeQuery("/judgement/frame!"),
|
|
@@ -39,38 +42,59 @@ function verifyDerivedJudgement(judgementNode, assignments, derived, localMetaCo
|
|
|
39
42
|
let derivedJudgementVerified = false;
|
|
40
43
|
|
|
41
44
|
if (derived) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
45
|
+
const judgementString = localMetaContext.nodeAsString(judgementNode);
|
|
46
|
+
|
|
47
|
+
localMetaContext.trace(`Verifying the '${judgementString}' derived judgement...`, judgementNode);
|
|
48
|
+
|
|
49
|
+
const metavariableNode = metavariableNodeQuery(judgementNode),
|
|
50
|
+
metavariableVerified = verifyMetavariable(metavariableNode, localMetaContext);
|
|
51
|
+
|
|
52
|
+
if (metavariableVerified) {
|
|
53
|
+
const judgement = localMetaContext.findJudgementByMetavariableNode(metavariableNode);
|
|
54
|
+
|
|
55
|
+
if (judgement !== null) {
|
|
56
|
+
const frames = [],
|
|
57
|
+
frameNode = frameNodeQuery(judgementNode),
|
|
58
|
+
frameVerified = verifyFrame(frameNode, frames, derived, localMetaContext);
|
|
59
|
+
|
|
60
|
+
if (frameVerified) {
|
|
61
|
+
const firstFrame = first(frames),
|
|
62
|
+
frame = firstFrame, ///
|
|
63
|
+
frameSingular = frame.isSingular();
|
|
64
|
+
|
|
65
|
+
if (frameSingular) {
|
|
66
|
+
const declaration = frame.getDeclaration(),
|
|
67
|
+
metavariableNode = declaration.getMetavariableNode(),
|
|
68
|
+
metaLemma = localMetaContext.findMetaLemmaByMetavariableNode(metavariableNode),
|
|
69
|
+
metatheorem = localMetaContext.findMetatheoremByMetavariableNode(metavariableNode),
|
|
70
|
+
metaLemmaMetatheorem = (metaLemma || metatheorem); ///
|
|
71
|
+
|
|
72
|
+
if (metaLemmaMetatheorem !== null) {
|
|
73
|
+
const judgementMatchesMetaLemmaMetatheorem = judgement.matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem),
|
|
74
|
+
declarationMatchesMetaLemmaMetatheorem = declaration.matchMetaLemmaOrMetaTheorem(metaLemmaMetatheorem);
|
|
75
|
+
|
|
76
|
+
derivedJudgementVerified = (judgementMatchesMetaLemmaMetatheorem && declarationMatchesMetaLemmaMetatheorem);
|
|
77
|
+
} else {
|
|
78
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
79
|
+
|
|
80
|
+
localMetaContext.debug(`There are no meta-lemmas or metatheorems corresponding to the '${metavariableString}' metavariable.`, judgementNode);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
const frameString = localMetaContext.nodeAsString(frameNode);
|
|
84
|
+
|
|
85
|
+
localMetaContext.debug(`The '${frameString}' is not singular.`, judgementNode);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
90
|
+
|
|
91
|
+
localMetaContext.debug(`There is no judgement present for the '${metavariableString}' metavariable.`, judgementNode);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (derivedJudgementVerified) {
|
|
96
|
+
localMetaContext.debug(`...verified the '${judgementString}' derived judgement.`, judgementNode);
|
|
97
|
+
}
|
|
74
98
|
}
|
|
75
99
|
|
|
76
100
|
return derivedJudgementVerified;
|
|
@@ -85,27 +109,23 @@ function verifyStatedJudgement(judgementNode, assignments, derived, localMetaCon
|
|
|
85
109
|
localMetaContext.trace(`Verifying the '${judgementString}' stated judgement...`, judgementNode);
|
|
86
110
|
|
|
87
111
|
const metavariableNode = metavariableNodeQuery(judgementNode),
|
|
88
|
-
|
|
112
|
+
metavariableVerified = verifyMetavariable(metavariableNode, localMetaContext);
|
|
89
113
|
|
|
90
|
-
if (
|
|
91
|
-
const
|
|
114
|
+
if (metavariableVerified) {
|
|
115
|
+
const frames = [],
|
|
116
|
+
frameNode = frameNodeQuery(judgementNode),
|
|
117
|
+
frameVerified = verifyFrame(frameNode, frames, derived, localMetaContext);
|
|
92
118
|
|
|
93
|
-
if (
|
|
94
|
-
const
|
|
119
|
+
if (frameVerified) {
|
|
120
|
+
const firstFrame = first(frames),
|
|
121
|
+
frame = firstFrame, ///
|
|
122
|
+
judgement = Judgement.fromJudgementNodeFrameAndMetavariableNode(judgementNode, frame, metavariableNode),
|
|
123
|
+
judgementAssignment = JudgementAssignment.fromJudgement(judgement),
|
|
124
|
+
assignment = judgementAssignment;
|
|
95
125
|
|
|
96
|
-
|
|
97
|
-
const frameVerified = verifyFrame(frameNode, derived, localMetaContext);
|
|
98
|
-
|
|
99
|
-
statedJudgementVerified = frameVerified; ///
|
|
100
|
-
} else {
|
|
101
|
-
localMetaContext.debug(`The right hand side of the '${judgementString}' judgement must be a frame.`, judgementNode);
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
const frameMetaTypeName = frameMetaType.getName(),
|
|
105
|
-
metavariableString = localMetaContext.nodeAsString(metavariableNode),
|
|
106
|
-
metaTypeString = metaType.asString();
|
|
126
|
+
assignments.push(assignment);
|
|
107
127
|
|
|
108
|
-
|
|
128
|
+
statedJudgementVerified = true;
|
|
109
129
|
}
|
|
110
130
|
}
|
|
111
131
|
|
|
@@ -115,4 +135,35 @@ function verifyStatedJudgement(judgementNode, assignments, derived, localMetaCon
|
|
|
115
135
|
}
|
|
116
136
|
|
|
117
137
|
return statedJudgementVerified;
|
|
118
|
-
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function verifyMetavariable(metavariableNode, localMetaContext) {
|
|
141
|
+
let metavariableVerified = false;
|
|
142
|
+
|
|
143
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
144
|
+
|
|
145
|
+
localMetaContext.trace(`Verifying the '${metavariableString}' metavariable...`, metavariableNode);
|
|
146
|
+
|
|
147
|
+
const metavariable = localMetaContext.findMetavariableByMetavariableNode(metavariableNode, localMetaContext);
|
|
148
|
+
|
|
149
|
+
if (metavariable !== null) {
|
|
150
|
+
const metaType = metavariable.getMetaType();
|
|
151
|
+
|
|
152
|
+
if (metaType === frameMetaType) {
|
|
153
|
+
metavariableVerified = true;
|
|
154
|
+
} else {
|
|
155
|
+
const frameMetaTypeName = frameMetaType.getName(),
|
|
156
|
+
metaTypeString = metaType.asString();
|
|
157
|
+
|
|
158
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable's meta-type is '${metaTypeString}' when it should be '${frameMetaTypeName}'.`, metavariableNode);
|
|
159
|
+
}
|
|
160
|
+
} else {
|
|
161
|
+
localMetaContext.debug(`The '${metavariableString}' metavariable is not present'.`, metavariableNode);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (metavariableVerified) {
|
|
165
|
+
localMetaContext.debug(`...verified the '${metavariableString}' metavariable.`, metavariableNode);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return metavariableVerified;
|
|
169
|
+
}
|