occam-verify-cli 0.0.864 → 0.0.866
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 +7 -7
- package/lib/context/file.js +162 -60
- package/lib/context/local.js +4 -4
- package/lib/context/release.js +32 -1
- package/lib/label.js +6 -6
- package/lib/metaConsequent.js +88 -0
- package/lib/metaLemma.js +126 -0
- package/lib/metaLemmaMetatheorem.js +196 -0
- package/lib/metaSupposition.js +140 -0
- package/lib/metaType.js +33 -3
- package/lib/metaTypeNames.js +13 -4
- package/lib/metaTypes.js +9 -4
- package/lib/metatheorem.js +126 -0
- package/lib/mixins/context.js +30 -22
- package/lib/rule.js +7 -7
- package/lib/ruleNames.js +5 -1
- package/lib/step/metaproof.js +18 -4
- package/lib/type.js +9 -1
- package/lib/utilities/name.js +52 -0
- package/lib/utilities/query.js +1 -38
- package/lib/verifier/node/metastatement.js +3 -3
- package/lib/verifier/nodes/statementAgainstCombinator.js +4 -4
- package/lib/verifier/nodes/termAgainstConstructor.js +3 -3
- package/lib/verifier/nodes.js +10 -10
- package/lib/verify/declaration/metavariable.js +4 -4
- package/lib/verify/declaration/topLevel.js +11 -3
- package/lib/verify/givenMetavariable.js +31 -0
- package/lib/verify/givenType.js +2 -3
- package/lib/verify/label.js +3 -4
- package/lib/verify/metaConsequent.js +36 -0
- package/lib/verify/metaDerivation.js +111 -0
- package/lib/verify/metaLemma.js +51 -0
- package/lib/verify/metaSupposition.js +40 -0
- package/lib/verify/metaSuppositions.js +28 -0
- package/lib/verify/metaproof.js +34 -0
- package/lib/verify/metastatement/qualified.js +2 -2
- package/lib/verify/metatheorem.js +50 -0
- package/lib/verify/metavariable.js +30 -10
- package/lib/verify/proof.js +3 -3
- package/lib/verify/statement/qualified.js +28 -28
- package/lib/verify/termAsConstructor.js +4 -5
- package/lib/verify/type.js +18 -20
- package/lib/verify/variable.js +13 -16
- package/package.json +4 -4
- package/src/axiomLemmaTheoremConjecture.js +6 -6
- package/src/context/file.js +187 -73
- package/src/context/local.js +1 -1
- package/src/context/release.js +37 -0
- package/src/label.js +4 -6
- package/src/metaConsequent.js +58 -0
- package/src/metaLemma.js +9 -0
- package/src/metaLemmaMetatheorem.js +194 -0
- package/src/metaSupposition.js +103 -0
- package/src/metaType.js +23 -3
- package/src/metaTypeNames.js +1 -0
- package/src/metaTypes.js +8 -1
- package/src/metatheorem.js +9 -0
- package/src/mixins/context.js +20 -14
- package/src/rule.js +6 -6
- package/src/ruleNames.js +1 -0
- package/src/step/metaproof.js +20 -4
- package/src/type.js +10 -0
- package/src/utilities/name.js +50 -0
- package/src/utilities/query.js +0 -47
- package/src/verifier/node/metastatement.js +2 -1
- package/src/verifier/nodes/statementAgainstCombinator.js +3 -3
- package/src/verifier/nodes/termAgainstConstructor.js +3 -4
- package/src/verifier/nodes.js +9 -9
- package/src/verify/declaration/metavariable.js +4 -3
- package/src/verify/declaration/topLevel.js +14 -0
- package/src/verify/givenMetavariable.js +31 -0
- package/src/verify/givenType.js +1 -4
- package/src/verify/label.js +2 -5
- package/src/verify/metaConsequent.js +36 -0
- package/src/verify/metaDerivation.js +151 -0
- package/src/verify/metaLemma.js +67 -0
- package/src/verify/metaSupposition.js +44 -0
- package/src/verify/metaSuppositions.js +17 -0
- package/src/verify/metaproof.js +32 -0
- package/src/verify/metastatement/qualified.js +2 -3
- package/src/verify/metatheorem.js +62 -0
- package/src/verify/metavariable.js +46 -16
- package/src/verify/proof.js +2 -2
- package/src/verify/statement/qualified.js +27 -23
- package/src/verify/termAsConstructor.js +4 -6
- package/src/verify/type.js +20 -22
- package/src/verify/variable.js +14 -17
|
@@ -4,7 +4,7 @@ import NodesVerifier from "../../verifier/nodes";
|
|
|
4
4
|
import termAgainstConstructorNodesVerifier from "../../verifier/nodes/termAgainstConstructor";
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../../utilities/query";
|
|
7
|
-
import {
|
|
7
|
+
import { STATEMENT_META_TYPE_NAME } from "../../metaTypeNames";
|
|
8
8
|
import { ARGUMENT_RULE_NAME, META_ARGUMENT_RULE_NAME } from "../../ruleNames";
|
|
9
9
|
|
|
10
10
|
const metaTypeNodeQuery = nodeQuery("/metaArgument/metaType!"),
|
|
@@ -71,10 +71,10 @@ class StatementAgainstCombinatorNodesVerifier extends NodesVerifier {
|
|
|
71
71
|
} else {
|
|
72
72
|
const combinatorMetaTypeTerminalNode = metaTypeTerminalNodeQuery(combinatorMetaTYpeNode),
|
|
73
73
|
content = combinatorMetaTypeTerminalNode.getContent(),
|
|
74
|
-
contentStatementMetaType = (content ===
|
|
74
|
+
contentStatementMetaType = (content === STATEMENT_META_TYPE_NAME);
|
|
75
75
|
|
|
76
76
|
if (!contentStatementMetaType) {
|
|
77
|
-
localContext.debug(`Expected the meta-type of the combinator to be '${
|
|
77
|
+
localContext.debug(`Expected the meta-type of the combinator to be '${STATEMENT_META_TYPE_NAME}' but got '${content}' instead.`, metaArgumentNode);
|
|
78
78
|
} else {
|
|
79
79
|
const verifiedAhead = verifyAhead();
|
|
80
80
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import NodesVerifier from "../../verifier/nodes";
|
|
4
4
|
|
|
5
5
|
import { first } from "../../utilities/array";
|
|
6
|
+
import { nodeQuery } from "../../utilities/query";
|
|
6
7
|
import { ARGUMENT_RULE_NAME } from "../../ruleNames";
|
|
7
|
-
import { nodeQuery, typeNameFromTypeNode } from "../../utilities/query";
|
|
8
8
|
|
|
9
9
|
const termNodeQuery = nodeQuery("/argument/term!"),
|
|
10
10
|
typeNodeQuery = nodeQuery("/argument/type!");
|
|
@@ -74,11 +74,10 @@ class TermAgainstConstructorNodesVerifier extends NodesVerifier {
|
|
|
74
74
|
termVerified = verifyTerm(termNode, terms, localContext, () => {
|
|
75
75
|
let verifiedAhead = false;
|
|
76
76
|
|
|
77
|
-
const
|
|
78
|
-
firstTerm = first(terms),
|
|
77
|
+
const firstTerm = first(terms),
|
|
79
78
|
term = firstTerm, ///
|
|
80
79
|
termType = term.getType(),
|
|
81
|
-
constructorType = localContext.
|
|
80
|
+
constructorType = localContext.findTypeByTypeNode(constructorTypeNode),
|
|
82
81
|
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(constructorType);
|
|
83
82
|
|
|
84
83
|
if (termTypeEqualToOrSubTypeOfType) {
|
package/src/verifier/nodes.js
CHANGED
|
@@ -31,7 +31,7 @@ export default class NodesVerifier {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
verifyChildNodes(childNodesA, childNodesB, ...remainingArguments) {
|
|
34
|
-
let
|
|
34
|
+
let childNodesVerified = false;
|
|
35
35
|
|
|
36
36
|
const childNodesALength = childNodesA.length,
|
|
37
37
|
childNodesBLength = childNodesB.length;
|
|
@@ -45,11 +45,11 @@ export default class NodesVerifier {
|
|
|
45
45
|
const index = 0,
|
|
46
46
|
childNodesVerifyAhead = this.verifyChildNodesAhead(index, childNodesA, childNodesB, ...remainingArguments);
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
childNodesVerified = childNodesVerifyAhead; ///
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
return
|
|
52
|
+
return childNodesVerified;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
verifyTerminalNode(terminalNodeA, terminalNodeB, ...remainingArguments) { ///
|
|
@@ -74,16 +74,16 @@ export default class NodesVerifier {
|
|
|
74
74
|
nonTerminalNodeBChildNodes = nonTerminalNodeB.getChildNodes(),
|
|
75
75
|
childNodesA = nonTerminalNodeAChildNodes, ///
|
|
76
76
|
childNodesB = nonTerminalNodeBChildNodes, ///
|
|
77
|
-
|
|
77
|
+
childNodesVerified = this.verifyChildNodes(childNodesA, childNodesB, ...remainingArguments);
|
|
78
78
|
|
|
79
|
-
nonTerminalNodeVerified =
|
|
79
|
+
nonTerminalNodeVerified = childNodesVerified; ///
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
return nonTerminalNodeVerified;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
verifyChildNodesAhead(index, childNodesA, childNodesB, ...remainingArguments) {
|
|
86
|
-
let
|
|
86
|
+
let childNodesVerified;
|
|
87
87
|
|
|
88
88
|
const verifyAhead = remainingArguments.pop(), ///
|
|
89
89
|
childNodesALength = childNodesA.length;
|
|
@@ -91,7 +91,7 @@ export default class NodesVerifier {
|
|
|
91
91
|
if (index === childNodesALength) {
|
|
92
92
|
const verifiedAhead = verifyAhead();
|
|
93
93
|
|
|
94
|
-
|
|
94
|
+
childNodesVerified = verifiedAhead; ///
|
|
95
95
|
} else {
|
|
96
96
|
const childNodeA = childNodesA[index],
|
|
97
97
|
childNodeB = childNodesB[index],
|
|
@@ -106,9 +106,9 @@ export default class NodesVerifier {
|
|
|
106
106
|
return childNodesVerifyAhead;
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
childNodesVerified = nodeVerified; ///
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
return
|
|
112
|
+
return childNodesVerified;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -12,16 +12,17 @@ export default function verifyMetavariableDeclaration(metavariableDeclarationNod
|
|
|
12
12
|
|
|
13
13
|
const metaTypeNode = metaTypeNodeQuery(metavariableDeclarationNode),
|
|
14
14
|
metavariableNode = metavariableNodeQuery(metavariableDeclarationNode),
|
|
15
|
-
|
|
15
|
+
metaTypeString = fileContext.nodeAsString(metaTypeNode),
|
|
16
|
+
metavariableString = fileContext.nodeAsString(metavariableNode);
|
|
16
17
|
|
|
17
|
-
fileContext.trace(`Verifying the '${metavariableString}' metavariable declaration...`, metavariableDeclarationNode);
|
|
18
|
+
fileContext.trace(`Verifying the '${metavariableString}:${metaTypeString}' metavariable declaration...`, metavariableDeclarationNode);
|
|
18
19
|
|
|
19
20
|
const metavariableVVerified = verifyMetavariable(metavariableNode, metaTypeNode, fileContext);
|
|
20
21
|
|
|
21
22
|
metavariableDeclarationVerified = metavariableVVerified; ///
|
|
22
23
|
|
|
23
24
|
if (metavariableDeclarationVerified) {
|
|
24
|
-
fileContext.debug(`...verified the '${metavariableString}' metavariable declaration.`, metavariableDeclarationNode);
|
|
25
|
+
fileContext.debug(`...verified the '${metavariableString}:${metaTypeString}' metavariable declaration.`, metavariableDeclarationNode);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
return metavariableDeclarationVerified;
|
|
@@ -4,7 +4,9 @@ import verifyRule from "../../verify/rule";
|
|
|
4
4
|
import verifyAxiom from "../../verify/axiom";
|
|
5
5
|
import verifyLemma from "../../verify/lemma";
|
|
6
6
|
import verifyTheorem from "../../verify/theorem";
|
|
7
|
+
import verifyMetaLemma from "../../verify/metaLemma";
|
|
7
8
|
import verifyConjecture from "../../verify/conjecture";
|
|
9
|
+
import verifyMetatheorem from "../../verify/metatheorem";
|
|
8
10
|
import verifyTypeDeclaration from "../../verify/declaration/type";
|
|
9
11
|
import verifyVariableDeclaration from "../../verify/declaration/variable";
|
|
10
12
|
import verifyCombinatorDeclaration from "../../verify/declaration/combinator";
|
|
@@ -17,7 +19,9 @@ const ruleNodeQuery = nodeQuery("/topLevelDeclaration/rule!"),
|
|
|
17
19
|
axiomNodeQuery = nodeQuery("/topLevelDeclaration/axiom!"),
|
|
18
20
|
lemmaNodeQuery = nodeQuery("/topLevelDeclaration/lemma!"),
|
|
19
21
|
theoremNodeQuery = nodeQuery("/topLevelDeclaration/theorem!"),
|
|
22
|
+
metaLemmaNodeQuery = nodeQuery("/topLevelDeclaration/metaLemma!"),
|
|
20
23
|
conjectureNodeQuery = nodeQuery("/topLevelDeclaration/conjecture!"),
|
|
24
|
+
metatheoremNodeQuery = nodeQuery("/topLevelDeclaration/metatheorem!"),
|
|
21
25
|
typeDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/typeDeclaration!"),
|
|
22
26
|
variableDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/variableDeclaration!"),
|
|
23
27
|
combinatorDeclarationNodeQuery = nodeQuery("/topLevelDeclaration/combinatorDeclaration!"),
|
|
@@ -32,7 +36,9 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
|
|
|
32
36
|
axiomNode = axiomNodeQuery(node),
|
|
33
37
|
lemmaNode = lemmaNodeQuery(node),
|
|
34
38
|
theoremNode = theoremNodeQuery(node),
|
|
39
|
+
metaLemmaNode = metaLemmaNodeQuery(node),
|
|
35
40
|
conjectureNode = conjectureNodeQuery(node),
|
|
41
|
+
metatheoremNode = metatheoremNodeQuery(node),
|
|
36
42
|
typeDeclarationNode = typeDeclarationNodeQuery(node),
|
|
37
43
|
variableDeclarationNode = variableDeclarationNodeQuery(node),
|
|
38
44
|
combinatorDeclarationNode = combinatorDeclarationNodeQuery(node),
|
|
@@ -57,10 +63,18 @@ export default function verifyTopLevelDeclaration(topLevelDeclarationNode, fileC
|
|
|
57
63
|
const theoremVerified = verifyTheorem(theoremNode, fileContext);
|
|
58
64
|
|
|
59
65
|
topLevelDeclarationVerified = theoremVerified; ///
|
|
66
|
+
} else if (metaLemmaNode !== null) {
|
|
67
|
+
const metaLemmaVerified = verifyMetaLemma(metaLemmaNode, fileContext);
|
|
68
|
+
|
|
69
|
+
topLevelDeclarationVerified = metaLemmaVerified; ///
|
|
60
70
|
} else if (conjectureNode !== null) {
|
|
61
71
|
const conjectureVerified = verifyConjecture(conjectureNode, fileContext);
|
|
62
72
|
|
|
63
73
|
topLevelDeclarationVerified = conjectureVerified; ///
|
|
74
|
+
} else if (metatheoremNode !== null) {
|
|
75
|
+
const metatheoremVerified = verifyMetatheorem(metatheoremNode, fileContext);
|
|
76
|
+
|
|
77
|
+
topLevelDeclarationVerified = metatheoremVerified; ///
|
|
64
78
|
} else if (typeDeclarationNode !== null) {
|
|
65
79
|
const typeDeclarationVerified = verifyTypeDeclaration(typeDeclarationNode, fileContext);
|
|
66
80
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default function verifyGivenMetavariable(metavariableNode, metavariables, localMetaContext, verifyAhead) {
|
|
4
|
+
let givenMetavariableVerified = false;
|
|
5
|
+
|
|
6
|
+
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
7
|
+
|
|
8
|
+
localMetaContext.trace(`Verifying the '${metavariableString}' given metavariable...`, metavariableNode);
|
|
9
|
+
|
|
10
|
+
const metavariable = localMetaContext.findMetavariableByMetavariableNode(metavariableNode);
|
|
11
|
+
|
|
12
|
+
if (metavariable !== null) {
|
|
13
|
+
let verifiedAhead;
|
|
14
|
+
|
|
15
|
+
metavariables.push(metavariable);
|
|
16
|
+
|
|
17
|
+
verifiedAhead = verifyAhead();
|
|
18
|
+
|
|
19
|
+
if (!verifiedAhead) {
|
|
20
|
+
metavariables.pop();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
givenMetavariableVerified = verifiedAhead; ///
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (givenMetavariableVerified) {
|
|
27
|
+
localMetaContext.debug(`...verified the '${metavariableString}' given metavariable.`, metavariableNode);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return givenMetavariableVerified;
|
|
31
|
+
}
|
package/src/verify/givenType.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { typeNameFromTypeNode } from "../utilities/query";
|
|
4
|
-
|
|
5
3
|
export default function verifyGivenType(typeNode, types, localContext, verifyAhead) {
|
|
6
4
|
let givenTypeVerified = false;
|
|
7
5
|
|
|
@@ -9,8 +7,7 @@ export default function verifyGivenType(typeNode, types, localContext, verifyAhe
|
|
|
9
7
|
|
|
10
8
|
localContext.trace(`Verifying the given '${typeString}' type...`, typeNode);
|
|
11
9
|
|
|
12
|
-
const
|
|
13
|
-
type = localContext.findTypeByTypeName(typeName);
|
|
10
|
+
const type = localContext.findTypeByTypeNode(typeNode);
|
|
14
11
|
|
|
15
12
|
if (type !== null) {
|
|
16
13
|
let verifiedAhead;
|
package/src/verify/label.js
CHANGED
|
@@ -2,17 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
import Label from "../label";
|
|
4
4
|
|
|
5
|
-
import { labelNameFromLabelNode } from "../utilities/query";
|
|
6
|
-
|
|
7
5
|
export default function verifyLabel(labelNode, labels, fileContext) {
|
|
8
6
|
let labelVerified = false;
|
|
9
7
|
|
|
10
|
-
const
|
|
11
|
-
labelString = fileContext.nodeAsString(labelNode);
|
|
8
|
+
const labelString = fileContext.nodeAsString(labelNode);
|
|
12
9
|
|
|
13
10
|
fileContext.trace(`Verifying the '${labelString}' label...`, labelNode);
|
|
14
11
|
|
|
15
|
-
const labelPresent = fileContext.
|
|
12
|
+
const labelPresent = fileContext.isLabelPresentByLabelNode(labelNode);
|
|
16
13
|
|
|
17
14
|
if (labelPresent) {
|
|
18
15
|
const labelString = fileContext.nodeAsString(labelNode);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetaConsequent from "../metaConsequent";
|
|
4
|
+
import verifyUnqualifiedMetastatement from "./metastatement/unqualified";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
|
|
8
|
+
const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!"),
|
|
9
|
+
unqualifiedMetastatementNodeQuery = nodeQuery("/metaConsequent/unqualifiedMetastatement!");
|
|
10
|
+
|
|
11
|
+
export default function verifyMetaConsequent(metaConsequentNode, metaConsequents, localContext) {
|
|
12
|
+
let metaConsequentVerified = false;
|
|
13
|
+
|
|
14
|
+
const metaConsequentString = localContext.nodeAsString(metaConsequentNode);
|
|
15
|
+
|
|
16
|
+
localContext.trace(`Verifying the '${metaConsequentString}' meta-consequent...`, metaConsequentNode);
|
|
17
|
+
|
|
18
|
+
const derived = false,
|
|
19
|
+
unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(metaConsequentNode),
|
|
20
|
+
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, derived, localContext);
|
|
21
|
+
|
|
22
|
+
if (unqualifiedMetastatementVerified) {
|
|
23
|
+
metaConsequentVerified = true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (metaConsequentVerified) {
|
|
27
|
+
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
|
|
28
|
+
metaConsequent = MetaConsequent.fromMetastatementNode(metastatementNode);
|
|
29
|
+
|
|
30
|
+
metaConsequents.push(metaConsequent);
|
|
31
|
+
|
|
32
|
+
localContext.debug(`...verified the '${metaConsequentString}' meta-consequent.`, metaConsequentNode);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return metaConsequentVerified;
|
|
36
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import LocalContext from "../context/local";
|
|
4
|
+
import MetaproofStep from "../step/metaproof";
|
|
5
|
+
import verifyMetaSuppositions from "../verify/metaSuppositions";
|
|
6
|
+
import verifyQualifiedMetastatement from "../verify/metastatement/qualified";
|
|
7
|
+
import verifyUnqualifiedMetastatement from "../verify/metastatement/unqualified";
|
|
8
|
+
|
|
9
|
+
import { assignAssignment } from "../utilities/assignments";
|
|
10
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
11
|
+
import { META_SUBPROOF_RULE_NAME, QUALIFIED_METASTATEMENT_RULE_NAME, UNQUALIFIED_METASTATEMENT_RULE_NAME } from "../ruleNames";
|
|
12
|
+
|
|
13
|
+
const childNodesQuery = nodesQuery("/metaDerivation|metaSubDerivation/*"),
|
|
14
|
+
metastatementNodeQuery = nodeQuery("/qualifiedMetastatement|unqualifiedMetastatement/metastatement!"),
|
|
15
|
+
metaSuppositionNodesQuery = nodesQuery("/metaSubproof/metaSupposition"),
|
|
16
|
+
metaSubDerivationNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation");
|
|
17
|
+
|
|
18
|
+
export default function verifyMetaDerivation(metaDerivationNode, localContext) {
|
|
19
|
+
let metaDerivationVerified;
|
|
20
|
+
|
|
21
|
+
const childNodes = childNodesQuery(metaDerivationNode);
|
|
22
|
+
|
|
23
|
+
metaDerivationVerified = childNodes.every((childNode) => {
|
|
24
|
+
const childVerified = verifyChild(childNode, localContext);
|
|
25
|
+
|
|
26
|
+
if (childVerified) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return metaDerivationVerified;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function verifyMetaSubDerivation(metaSubDerivationNode, localContext) {
|
|
35
|
+
let metaSubDerivationVerified;
|
|
36
|
+
|
|
37
|
+
const childNodes = childNodesQuery(metaSubDerivationNode);
|
|
38
|
+
|
|
39
|
+
metaSubDerivationVerified = childNodes.every((childNode) => {
|
|
40
|
+
const childVerified = verifyChild(childNode, localContext);
|
|
41
|
+
|
|
42
|
+
if (childVerified) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return metaSubDerivationVerified;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function verifyMetaSubproof(metaSubproofNode, localContext) {
|
|
51
|
+
let metaSubproofVerified = false;
|
|
52
|
+
|
|
53
|
+
localContext = LocalContext.fromLocalContext(localContext); ///
|
|
54
|
+
|
|
55
|
+
const metaSuppositions = [],
|
|
56
|
+
metaSuppositionNodes = metaSuppositionNodesQuery(metaSubproofNode),
|
|
57
|
+
metaSuppositionsVerified = verifyMetaSuppositions(metaSuppositionNodes, metaSuppositions, localContext);
|
|
58
|
+
|
|
59
|
+
if (metaSuppositionsVerified) {
|
|
60
|
+
const metaSubDerivationNode = metaSubDerivationNodeQuery(metaSubproofNode),
|
|
61
|
+
metaSubDerivationVerified = verifyMetaSubDerivation(metaSubDerivationNode, localContext);
|
|
62
|
+
|
|
63
|
+
if (metaSubDerivationVerified) {
|
|
64
|
+
metaSubproofVerified = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return metaSubproofVerified;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function verifyChild(childNode, localContext) {
|
|
72
|
+
let childVerified = false;
|
|
73
|
+
|
|
74
|
+
const childNodeRuleName = childNode.getRuleName();
|
|
75
|
+
|
|
76
|
+
switch (childNodeRuleName) {
|
|
77
|
+
case META_SUBPROOF_RULE_NAME: {
|
|
78
|
+
let metaSubproofVerified;
|
|
79
|
+
|
|
80
|
+
const metaSubproofNode = childNode; ///
|
|
81
|
+
|
|
82
|
+
metaSubproofVerified = verifyMetaSubproof(metaSubproofNode, localContext);
|
|
83
|
+
|
|
84
|
+
if (metaSubproofVerified) {
|
|
85
|
+
const metaproofStep = MetaproofStep.fromMetaSubproofNode(metaSubproofNode);
|
|
86
|
+
|
|
87
|
+
localContext.addMetaproofStep(metaproofStep);
|
|
88
|
+
|
|
89
|
+
childVerified = true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
case QUALIFIED_METASTATEMENT_RULE_NAME: {
|
|
96
|
+
let qualifiedMetastatementVerified;
|
|
97
|
+
|
|
98
|
+
const derived = true,
|
|
99
|
+
assignments = [],
|
|
100
|
+
qualifiedMetastatementNode = childNode; ///
|
|
101
|
+
|
|
102
|
+
qualifiedMetastatementVerified = verifyQualifiedMetastatement(qualifiedMetastatementNode, assignments, derived, localContext);
|
|
103
|
+
|
|
104
|
+
if (qualifiedMetastatementVerified) {
|
|
105
|
+
const assignmentAssigned = assignAssignment(assignments, localContext);
|
|
106
|
+
|
|
107
|
+
qualifiedMetastatementVerified = assignmentAssigned; ///
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (qualifiedMetastatementVerified) {
|
|
111
|
+
const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode),
|
|
112
|
+
metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
|
|
113
|
+
|
|
114
|
+
localContext.addMetaproofStep(metaproofStep);
|
|
115
|
+
|
|
116
|
+
childVerified = true; ///
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
case UNQUALIFIED_METASTATEMENT_RULE_NAME: {
|
|
123
|
+
let unqualifiedMetastatementVerified;
|
|
124
|
+
|
|
125
|
+
const derived = true,
|
|
126
|
+
assignments = [],
|
|
127
|
+
unqualifiedMetastatementNode = childNode; ///
|
|
128
|
+
|
|
129
|
+
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, assignments, derived, localContext);
|
|
130
|
+
|
|
131
|
+
if (unqualifiedMetastatementVerified) {
|
|
132
|
+
const assignmentAssigned = assignAssignment(assignments, localContext);
|
|
133
|
+
|
|
134
|
+
unqualifiedMetastatementVerified = assignmentAssigned; ///
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
if (unqualifiedMetastatementVerified) {
|
|
138
|
+
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
|
|
139
|
+
metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
|
|
140
|
+
|
|
141
|
+
localContext.addMetaproofStep(metaproofStep);
|
|
142
|
+
|
|
143
|
+
childVerified = true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return childVerified;
|
|
151
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetaLemma from "../metaLemma";
|
|
4
|
+
import verifyLabels from "../verify/labels";
|
|
5
|
+
import verifyMetaProof from "../verify/metaproof";
|
|
6
|
+
import LocalMetaContext from "../context/localMeta";
|
|
7
|
+
import verifyMetaConsequent from "../verify/metaConsequent";
|
|
8
|
+
import verifyMetaSuppositions from "../verify/metaSuppositions";
|
|
9
|
+
|
|
10
|
+
import { first } from "../utilities/array";
|
|
11
|
+
import { EMPTY_STRING } from "../constants";
|
|
12
|
+
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
13
|
+
|
|
14
|
+
const labelNodesQuery = nodesQuery("/metaLemma//labels/label"),
|
|
15
|
+
metaproofNodeQuery = nodeQuery("/metaLemma/metaproof!"),
|
|
16
|
+
metaConsequentNodeQuery = nodeQuery("/metaLemma/metaConsequent!"),
|
|
17
|
+
metaSuppositionsNodeQuery = nodesQuery("/metaLemma/metaSupposition");
|
|
18
|
+
|
|
19
|
+
export default function verifyMetaLemma(metaLemmaNode, fileContext) {
|
|
20
|
+
let metaLemmaVerified = false;
|
|
21
|
+
|
|
22
|
+
const labelNodes = labelNodesQuery(metaLemmaNode),
|
|
23
|
+
labelsString = fileContext.nodesAsString(labelNodes),
|
|
24
|
+
localMetaContext = LocalMetaContext.fromFileContext(fileContext);
|
|
25
|
+
|
|
26
|
+
(labelsString === EMPTY_STRING) ?
|
|
27
|
+
fileContext.trace(`Verifying a meta-lLemma...`, metaLemmaNode) :
|
|
28
|
+
fileContext.trace(`Verifying the '${labelsString}' meta-lLemma...`, metaLemmaNode);
|
|
29
|
+
|
|
30
|
+
const labels = [],
|
|
31
|
+
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
32
|
+
|
|
33
|
+
if (labelsVerified) {
|
|
34
|
+
const metaSuppositions = [],
|
|
35
|
+
metaSuppositionNodes = metaSuppositionsNodeQuery(metaLemmaNode),
|
|
36
|
+
metaSuppositionsVerified = verifyMetaSuppositions(metaSuppositionNodes, metaSuppositions, localMetaContext);
|
|
37
|
+
|
|
38
|
+
if (metaSuppositionsVerified) {
|
|
39
|
+
const metaConsequents = [],
|
|
40
|
+
metaConsequentNode = metaConsequentNodeQuery(metaLemmaNode),
|
|
41
|
+
metaConsequentVerified = verifyMetaConsequent(metaConsequentNode, metaConsequents, localMetaContext);
|
|
42
|
+
|
|
43
|
+
if (metaConsequentVerified) {
|
|
44
|
+
const metaproofNode = metaproofNodeQuery(metaLemmaNode),
|
|
45
|
+
firstMetaConsequent = first(metaConsequents),
|
|
46
|
+
metaConsequent = firstMetaConsequent, ///
|
|
47
|
+
metaproofVerified = verifyMetaProof(metaproofNode, metaConsequent, localMetaContext);
|
|
48
|
+
|
|
49
|
+
if (metaproofVerified) {
|
|
50
|
+
const metaLemma = MetaLemma.fromLabelsMetaSuppositionsMetaConsequentAndLocalMetaContext(labels, metaSuppositions, metaConsequent, localMetaContext);
|
|
51
|
+
|
|
52
|
+
fileContext.addMetaLemma(metaLemma);
|
|
53
|
+
|
|
54
|
+
metaLemmaVerified = true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (metaLemmaVerified) {
|
|
61
|
+
(labelsString === EMPTY_STRING) ?
|
|
62
|
+
fileContext.debug(`...verified the meta-lemma.`, metaLemmaNode) :
|
|
63
|
+
fileContext.debug(`...verified the '${labelsString}' meta-lemma.`, metaLemmaNode);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return metaLemmaVerified;
|
|
67
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetaproofStep from "../step/metaproof";
|
|
4
|
+
import MetaSupposition from "../metaSupposition";
|
|
5
|
+
import verifyUnqualifiedMetastatement from "../verify/metastatement/unqualified";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "../utilities/query";
|
|
8
|
+
import { assignAssignment } from "../utilities/assignments";
|
|
9
|
+
|
|
10
|
+
const metastatementNodeQuery = nodeQuery("/unqualifiedMetastatement/metastatement!"),
|
|
11
|
+
unqualifiedMetastatementNodeQuery = nodeQuery("/metaSupposition/unqualifiedMetastatement!");
|
|
12
|
+
|
|
13
|
+
export default function verifyMetaSupposition(metaSuppositionNode, metaSuppositions, localContext) {
|
|
14
|
+
let metaSuppositionVerified = false;
|
|
15
|
+
|
|
16
|
+
const metaSuppositionString = localContext.nodeAsString(metaSuppositionNode);
|
|
17
|
+
|
|
18
|
+
localContext.trace(`Verifying the '${metaSuppositionString}' meta-supposition...`, metaSuppositionNode);
|
|
19
|
+
|
|
20
|
+
const derived = false,
|
|
21
|
+
assignments = [],
|
|
22
|
+
unqualifiedMetastatementNode = unqualifiedMetastatementNodeQuery(metaSuppositionNode),
|
|
23
|
+
unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, assignments, derived, localContext);
|
|
24
|
+
|
|
25
|
+
if (unqualifiedMetastatementVerified) {
|
|
26
|
+
const assignmentAssigned = assignAssignment(assignments, localContext);
|
|
27
|
+
|
|
28
|
+
metaSuppositionVerified = assignmentAssigned; ///
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (metaSuppositionVerified) {
|
|
32
|
+
const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
|
|
33
|
+
metaSupposition = MetaSupposition.fromMetastatementNode(metastatementNode),
|
|
34
|
+
metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
|
|
35
|
+
|
|
36
|
+
metaSuppositions.push(metaSupposition);
|
|
37
|
+
|
|
38
|
+
localContext.addMetaproofStep(metaproofStep);
|
|
39
|
+
|
|
40
|
+
localContext.debug(`...verified the '${metaSuppositionString}' meta-supposition.`, metaSuppositionNode);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return metaSuppositionVerified;
|
|
44
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import verifyMetaSupposition from "../verify/metaSupposition";
|
|
4
|
+
|
|
5
|
+
export default function verifyMetaSuppositions(metaSuppositionNodes, metaSuppositions, localContext) {
|
|
6
|
+
let metaSuppositionsVerified;
|
|
7
|
+
|
|
8
|
+
metaSuppositionsVerified = metaSuppositionNodes.every((metaSuppositionNode) => {
|
|
9
|
+
const metaSuppositionVerified = verifyMetaSupposition(metaSuppositionNode, metaSuppositions, localContext);
|
|
10
|
+
|
|
11
|
+
if (metaSuppositionVerified) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return metaSuppositionsVerified;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import LocalContext from "../context/local";
|
|
4
|
+
import verifyMetaDerivation from "../verify/metaDerivation";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "../utilities/query";
|
|
7
|
+
|
|
8
|
+
const metaDerivationNodeQuery = nodeQuery("/metaproof/metaDerivation!");
|
|
9
|
+
|
|
10
|
+
export default function verifyMetaproof(metaproofNode, conclusion, localContext) {
|
|
11
|
+
let metaproofVerified = false;
|
|
12
|
+
|
|
13
|
+
localContext = LocalContext.fromLocalContext(localContext); ///
|
|
14
|
+
|
|
15
|
+
const metaDerivationNode = metaDerivationNodeQuery(metaproofNode),
|
|
16
|
+
metaDerivationVerified = verifyMetaDerivation(metaDerivationNode, localContext);
|
|
17
|
+
|
|
18
|
+
if (metaDerivationVerified) {
|
|
19
|
+
const lastMetaproofStep = localContext.getLastMetaproofStep();
|
|
20
|
+
|
|
21
|
+
if (lastMetaproofStep !== null) {
|
|
22
|
+
const metaproofStep = lastMetaproofStep, ///
|
|
23
|
+
metastatementNode = metaproofStep.getMetastatementNode(),
|
|
24
|
+
conclusionMetastatementNode = conclusion.getMetastatementNode(),
|
|
25
|
+
metastatementNodeMatchesConclusionMetastatementNode = metastatementNode.match(conclusionMetastatementNode);
|
|
26
|
+
|
|
27
|
+
metaproofVerified = metastatementNodeMatchesConclusionMetastatementNode; ///
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return metaproofVerified;
|
|
32
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { nodeQuery
|
|
3
|
+
import { nodeQuery } from "../../utilities/query";
|
|
4
4
|
|
|
5
5
|
const referenceNodeQuery = nodeQuery("/qualifiedMetastatement/qualification!/reference!"),
|
|
6
6
|
metastatementNodeQuery = nodeQuery("/qualifiedMetastatement/metastatement!");
|
|
@@ -17,8 +17,7 @@ export default function verifyQualifiedMetastatement(qualifiedMetastatementNode,
|
|
|
17
17
|
localMetaContext.trace(`Verifying the '${metastatementString}' qualified metastatement...`, qualifiedMetastatementNode);
|
|
18
18
|
|
|
19
19
|
const referenceNode = referenceNodeQuery(qualifiedMetastatementNode),
|
|
20
|
-
|
|
21
|
-
rule = localMetaContext.findRuleByReferenceName(referenceName);
|
|
20
|
+
rule = localMetaContext.findRuleByReferenceNode(referenceNode);
|
|
22
21
|
|
|
23
22
|
if (rule !== null) {
|
|
24
23
|
const ruleMatchesMetastatement = rule.matchMetastatement(metastatementNode, metastatementLocalMetaContext);
|