occam-verify-cli 0.0.869 → 0.0.871
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 +13 -13
- package/lib/conclusion.js +3 -3
- package/lib/context/file.js +77 -73
- package/lib/equality.js +2 -4
- package/lib/equivalence.js +1 -1
- package/lib/label.js +5 -6
- package/lib/metaLemmaMetatheorem.js +13 -13
- package/lib/mixins/context.js +28 -28
- package/lib/premise.js +4 -4
- package/lib/rule.js +13 -13
- package/lib/ruleNames.js +1 -29
- package/lib/substitution/metastatementForMetavariable.js +3 -2
- package/lib/substitution/statementForMetavariable.js +27 -64
- package/lib/substitution/termForVariable.js +5 -5
- package/lib/utilities/name.js +8 -8
- package/lib/utilities/node.js +14 -14
- package/lib/utilities/query.js +4 -9
- package/lib/utilities/tokens.js +6 -6
- package/lib/utilities/verifier.js +86 -0
- package/lib/verifier/node/metastatement.js +41 -28
- package/lib/verifier/node/statementAsCombinator.js +41 -28
- package/lib/verifier/node/termAsConstructor.js +30 -22
- package/lib/verifier/nodes/equality.js +27 -32
- package/lib/verifier/nodes/intrinsicLevel.js +25 -34
- package/lib/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +270 -0
- package/lib/verifier/nodes/metaLevel.js +25 -34
- package/lib/verifier/nodes/statementAgainstCombinator.js +45 -49
- package/lib/verifier/nodes/termAgainstConstructor.js +24 -51
- package/lib/verify/argumentAgainstArgument.js +24 -0
- package/lib/verify/axiom.js +4 -4
- package/lib/verify/conjecture.js +4 -4
- package/lib/verify/containment.js +5 -5
- package/lib/verify/equality.js +9 -9
- package/lib/verify/label.js +8 -9
- package/lib/verify/labels.js +15 -8
- package/lib/verify/lemma.js +4 -4
- package/lib/verify/metaDerivation.js +19 -19
- package/lib/verify/metaLemma.js +4 -4
- package/lib/verify/metaproof.js +4 -6
- package/lib/verify/metastatement/qualified.js +3 -3
- package/lib/verify/metatheorem.js +4 -4
- package/lib/verify/metavariable.js +7 -5
- package/lib/verify/metavariableAgainstMetastatement.js +44 -0
- package/lib/verify/metavariableAgainstStatement.js +65 -0
- package/lib/verify/rule.js +4 -4
- package/lib/verify/statement/qualified.js +29 -29
- package/lib/verify/statement.js +4 -4
- package/lib/verify/statementAgainstMetaType.js +24 -0
- package/lib/verify/statementAtainstStatement.js +52 -0
- package/lib/verify/term.js +7 -8
- package/lib/verify/termAgainstTerm.js +22 -0
- package/lib/verify/termAgainstType.js +26 -0
- package/lib/verify/terms.js +2 -3
- package/lib/verify/theorem.js +4 -4
- package/lib/verify/type.js +7 -5
- package/lib/verify/typeAssertion.js +45 -40
- package/lib/verify/variable.js +7 -5
- package/lib/verify/variableAgainstTerm.js +70 -0
- package/package.json +4 -4
- package/src/axiomLemmaTheoremConjecture.js +13 -13
- package/src/conclusion.js +2 -2
- package/src/context/file.js +79 -73
- package/src/equality.js +3 -9
- package/src/equivalence.js +1 -1
- package/src/label.js +6 -7
- package/src/metaLemmaMetatheorem.js +13 -13
- package/src/mixins/context.js +17 -17
- package/src/premise.js +3 -3
- package/src/rule.js +13 -13
- package/src/ruleNames.js +0 -7
- package/src/substitution/metastatementForMetavariable.js +3 -1
- package/src/substitution/statementForMetavariable.js +32 -74
- package/src/substitution/termForVariable.js +3 -3
- package/src/utilities/name.js +7 -7
- package/src/utilities/node.js +13 -13
- package/src/utilities/query.js +3 -9
- package/src/utilities/tokens.js +4 -4
- package/src/utilities/verifier.js +46 -0
- package/src/verifier/node/metastatement.js +41 -34
- package/src/verifier/node/statementAsCombinator.js +39 -32
- package/src/verifier/node/termAsConstructor.js +30 -25
- package/src/verifier/nodes/equality.js +31 -36
- package/src/verifier/nodes/intrinsicLevel.js +30 -38
- package/src/verifier/nodes/intrinsicLevelAgainstMetaLevel.js +222 -0
- package/src/verifier/nodes/metaLevel.js +30 -38
- package/src/verifier/nodes/statementAgainstCombinator.js +52 -55
- package/src/verifier/nodes/termAgainstConstructor.js +30 -71
- package/src/verify/argumentAgainstArgument.js +15 -0
- package/src/verify/axiom.js +4 -4
- package/src/verify/conjecture.js +4 -4
- package/src/verify/containment.js +4 -4
- package/src/verify/equality.js +8 -8
- package/src/verify/label.js +8 -9
- package/src/verify/labels.js +17 -7
- package/src/verify/lemma.js +4 -4
- package/src/verify/metaDerivation.js +18 -18
- package/src/verify/metaLemma.js +6 -6
- package/src/verify/metaproof.js +3 -6
- package/src/verify/metastatement/qualified.js +5 -4
- package/src/verify/metatheorem.js +4 -4
- package/src/verify/metavariable.js +7 -5
- package/src/verify/metavariableAgainstMetastatement.js +42 -0
- package/src/verify/metavariableAgainstStatement.js +77 -0
- package/src/verify/rule.js +4 -4
- package/src/verify/statement/qualified.js +35 -30
- package/src/verify/statement.js +5 -5
- package/src/verify/statementAgainstMetaType.js +21 -0
- package/src/verify/statementAtainstStatement.js +60 -0
- package/src/verify/term.js +13 -17
- package/src/verify/termAgainstTerm.js +20 -0
- package/src/verify/termAgainstType.js +28 -0
- package/src/verify/terms.js +1 -3
- package/src/verify/theorem.js +4 -4
- package/src/verify/type.js +7 -5
- package/src/verify/typeAssertion.js +56 -55
- package/src/verify/variable.js +7 -5
- package/src/verify/variableAgainstTerm.js +86 -0
- package/lib/verifier/nodes/metaLevelToIntrinsicLevel.js +0 -327
- package/lib/verifier/nodes/substitution.js +0 -223
- package/lib/verify/givenMetavariable.js +0 -31
- package/lib/verify/givenType.js +0 -31
- package/lib/verify/givenVariable.js +0 -31
- package/lib/verify/termAndGivenType.js +0 -39
- package/src/verifier/nodes/metaLevelToIntrinsicLevel.js +0 -219
- package/src/verifier/nodes/substitution.js +0 -125
- package/src/verify/givenMetavariable.js +0 -31
- package/src/verify/givenType.js +0 -31
- package/src/verify/givenVariable.js +0 -31
- package/src/verify/termAndGivenType.js +0 -37
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import Metavariable from "../metavariable";
|
|
4
4
|
import MetavariableAssignment from "../assignment/metavariable";
|
|
5
|
-
import verifyGivenMetavariable from "../verify/givenMetavariable";
|
|
6
5
|
|
|
7
6
|
import { nodeQuery } from "../utilities/query";
|
|
8
7
|
|
|
@@ -44,16 +43,19 @@ export default function verifyMetavariable(metavariableNode, metaTypeNode, fileC
|
|
|
44
43
|
}
|
|
45
44
|
|
|
46
45
|
export function verifyStandaloneMetavariable(metavariableNode, localMetaContext, verifyAhead) {
|
|
47
|
-
let standaloneMetavariableVerified;
|
|
46
|
+
let standaloneMetavariableVerified = false;
|
|
48
47
|
|
|
49
48
|
const metavariableString = localMetaContext.nodeAsString(metavariableNode);
|
|
50
49
|
|
|
51
50
|
localMetaContext.trace(`Verifying the '${metavariableString}' standalone metavariable...`, metavariableNode);
|
|
52
51
|
|
|
53
|
-
const
|
|
54
|
-
givenMetavariableVerified = verifyGivenMetavariable(metavariableNode, metavariables, localMetaContext, verifyAhead);
|
|
52
|
+
const metavariablePresent = localMetaContext.isMetavariablePresentByMetavariableNode(metavariableNode);
|
|
55
53
|
|
|
56
|
-
|
|
54
|
+
if (metavariablePresent) {
|
|
55
|
+
const verifiedAhead = verifyAhead();
|
|
56
|
+
|
|
57
|
+
standaloneMetavariableVerified = verifiedAhead; ///
|
|
58
|
+
}
|
|
57
59
|
|
|
58
60
|
if (standaloneMetavariableVerified) {
|
|
59
61
|
localMetaContext.debug(`...verified the '${metavariableString}' standalone metavariable.`, metavariableNode);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetastatementForMetavariableSubstitution from "../substitution/metastatementForMetavariable";
|
|
4
|
+
|
|
5
|
+
export default function verifyMetavariableAgainstMetastatement(metavariableNode, metastatementNode, substitutions, localContextA, localMetaContextB, verifyAhead) {
|
|
6
|
+
let metavariableVerifiedAgainstMetastatement = false;
|
|
7
|
+
|
|
8
|
+
const substitution = substitutions.find((substitution) => {
|
|
9
|
+
const substitutionMatchesMetavariableNodeA = substitution.matchMetavariableNode(metavariableNode);
|
|
10
|
+
|
|
11
|
+
if (substitutionMatchesMetavariableNodeA) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
}) || null;
|
|
15
|
+
|
|
16
|
+
if (substitution !== null) {
|
|
17
|
+
const metastatementNodeMatches = substitution.matchMetastatementNode(metastatementNode);
|
|
18
|
+
|
|
19
|
+
if (metastatementNodeMatches) {
|
|
20
|
+
const verifiedAhead = verifyAhead();
|
|
21
|
+
|
|
22
|
+
metavariableVerifiedAgainstMetastatement = verifiedAhead; ///
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
let verifiedAhead;
|
|
26
|
+
|
|
27
|
+
const metastatementForMetavariableSubstitution = MetastatementForMetavariableSubstitution.fromMetavariableNodeAndMetastatementNode(metavariableNode, metastatementNode),
|
|
28
|
+
substitution = metastatementForMetavariableSubstitution; ///
|
|
29
|
+
|
|
30
|
+
substitutions.push(substitution);
|
|
31
|
+
|
|
32
|
+
verifiedAhead = verifyAhead();
|
|
33
|
+
|
|
34
|
+
if (!verifiedAhead) {
|
|
35
|
+
substitutions.pop();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
metavariableVerifiedAgainstMetastatement = verifiedAhead; ///
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return metavariableVerifiedAgainstMetastatement;
|
|
42
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
4
|
+
import verifyStatementAgainstStatement from "../verify/statementAtainstStatement";
|
|
5
|
+
import StatementForMetavariableSubstitution from "../substitution/statementForMetavariable";
|
|
6
|
+
|
|
7
|
+
export default function verifyMetavariableAgainstStatement(metavariableNode, statementNode, substitutionNode, substitutions, localContextA, localContextB, verifyAhead) {
|
|
8
|
+
let metavariableVerifiedAgainstStatement = false;
|
|
9
|
+
|
|
10
|
+
const substitution = substitutions.find((substitution) => {
|
|
11
|
+
const substitutionMatchesMetavariableNodeA = substitution.matchMetavariableNode(metavariableNode);
|
|
12
|
+
|
|
13
|
+
if (substitutionMatchesMetavariableNodeA) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}) || null;
|
|
17
|
+
|
|
18
|
+
if (substitution !== null) {
|
|
19
|
+
const substitutionStatementNode = substitution.getStatementNode();
|
|
20
|
+
|
|
21
|
+
if (substitutionNode !== null) {
|
|
22
|
+
const termForVariableSubstitution = TermForVariableSubstitution.fromSubstitutionNode(substitutionNode),
|
|
23
|
+
substitution = termForVariableSubstitution, ///
|
|
24
|
+
statementNodeA = substitutionStatementNode, ///
|
|
25
|
+
statementNodeB = statementNode, ///
|
|
26
|
+
statementVerifiedAgainstStatement = verifyStatementAgainstStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
27
|
+
|
|
28
|
+
if (statementVerifiedAgainstStatement) {
|
|
29
|
+
const verifiedAhead = verifyAhead();
|
|
30
|
+
|
|
31
|
+
metavariableVerifiedAgainstStatement = verifiedAhead; ///
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
const substitutionSubstitution = substitution.getSubstitution();
|
|
35
|
+
|
|
36
|
+
if (substitutionSubstitution !== null) {
|
|
37
|
+
localContextA = localContextB; ///
|
|
38
|
+
|
|
39
|
+
const substitution = substitutionSubstitution,
|
|
40
|
+
statementNodeA = statementNode, ///
|
|
41
|
+
statementNodeB = substitutionStatementNode, ///
|
|
42
|
+
statementVerifiedAgainstStatement = verifyStatementAgainstStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB);
|
|
43
|
+
|
|
44
|
+
if (statementVerifiedAgainstStatement) {
|
|
45
|
+
const verifiedAhead = verifyAhead();
|
|
46
|
+
|
|
47
|
+
metavariableVerifiedAgainstStatement = verifiedAhead; ///
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
const statementNodeMatches = substitution.matchStatementNode(statementNode);
|
|
51
|
+
|
|
52
|
+
if (statementNodeMatches) {
|
|
53
|
+
const verifiedAhead = verifyAhead();
|
|
54
|
+
|
|
55
|
+
metavariableVerifiedAgainstStatement = verifiedAhead; ///
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
let verifiedAhead;
|
|
61
|
+
|
|
62
|
+
const statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromMetavariableNodeStatementNodeAndSubstitutionNode(metavariableNode, statementNode, substitutionNode),
|
|
63
|
+
substitution = statementForMetavariableSubstitution; ///
|
|
64
|
+
|
|
65
|
+
substitutions.push(substitution);
|
|
66
|
+
|
|
67
|
+
verifiedAhead = verifyAhead();
|
|
68
|
+
|
|
69
|
+
if (!verifiedAhead) {
|
|
70
|
+
substitutions.pop();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
metavariableVerifiedAgainstStatement = verifiedAhead; ///
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return metavariableVerifiedAgainstStatement;
|
|
77
|
+
}
|
package/src/verify/rule.js
CHANGED
|
@@ -10,7 +10,7 @@ import verifyConclusion from "../verify/conclusion";
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const labelsNodeQuery = nodeQuery("/rule/labels!"),
|
|
14
14
|
premisesNodeQuery = nodesQuery("/rule/premise"),
|
|
15
15
|
ruleProofNodeQuery = nodeQuery("/rule/ruleProof!"),
|
|
16
16
|
conclusionNodeQuery = nodeQuery("/rule/conclusion!");
|
|
@@ -18,14 +18,14 @@ const labelNodesQuery = nodesQuery("/rule//reference/label"),
|
|
|
18
18
|
export default function verifyRule(ruleNode, fileContext) {
|
|
19
19
|
let ruleVerified = false;
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
labelsString = fileContext.
|
|
21
|
+
const labelsNode = labelsNodeQuery(ruleNode),
|
|
22
|
+
labelsString = fileContext.nodeAsString(labelsNode),
|
|
23
23
|
localMetaContext = LocalMetaContext.fromFileContext(fileContext);
|
|
24
24
|
|
|
25
25
|
fileContext.trace(`Verifying the '${labelsString}' rule...`, ruleNode);
|
|
26
26
|
|
|
27
27
|
const labels = [],
|
|
28
|
-
labelsVerified = verifyLabels(
|
|
28
|
+
labelsVerified = verifyLabels(labelsNode, labels, fileContext);
|
|
29
29
|
|
|
30
30
|
if (labelsVerified) {
|
|
31
31
|
const premises = [],
|
|
@@ -5,10 +5,10 @@ import verifyTypeAssertion from "../typeAssertion";
|
|
|
5
5
|
|
|
6
6
|
import { nodeQuery } from "../../utilities/query";
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
equalityNodeQuery = nodeQuery("/qualifiedStatement/statement/equality!"),
|
|
8
|
+
const equalityNodeQuery = nodeQuery("/qualifiedStatement/statement/equality!"),
|
|
10
9
|
statementNodeQuery = nodeQuery("/qualifiedStatement/statement!"),
|
|
11
|
-
typeAssertionNodeQuery = nodeQuery("/qualifiedStatement/statement/typeAssertion!")
|
|
10
|
+
typeAssertionNodeQuery = nodeQuery("/qualifiedStatement/statement/typeAssertion!"),
|
|
11
|
+
referenceMetavariableNodeQuery = nodeQuery("/qualifiedStatement/reference!/metavariable!");
|
|
12
12
|
|
|
13
13
|
export default function verifyQualifiedStatement(qualifiedStatementNode, assignments, derived, localContext) {
|
|
14
14
|
let qualifiedStatementVerified = false;
|
|
@@ -20,7 +20,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
20
20
|
|
|
21
21
|
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement...`, qualifiedStatementNode);
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const referenceMetavariableNode = referenceMetavariableNodeQuery(qualifiedStatementNode),
|
|
24
24
|
verifyQualifiedStatementFunctions = [
|
|
25
25
|
verifyQualifiedStatementAAgainstRule,
|
|
26
26
|
verifyQualifiedStatementAAgainstAxiom,
|
|
@@ -30,7 +30,7 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
30
30
|
];
|
|
31
31
|
|
|
32
32
|
qualifiedStatementVerified = verifyQualifiedStatementFunctions.some((verifyQualifiedStatementFunction) => { ///
|
|
33
|
-
const qualifiedStatementVerified = verifyQualifiedStatementFunction(qualifiedStatementNode,
|
|
33
|
+
const qualifiedStatementVerified = verifyQualifiedStatementFunction(qualifiedStatementNode, referenceMetavariableNode, localContext);
|
|
34
34
|
|
|
35
35
|
if (qualifiedStatementVerified) {
|
|
36
36
|
return true;
|
|
@@ -66,125 +66,130 @@ export default function verifyQualifiedStatement(qualifiedStatementNode, assignm
|
|
|
66
66
|
return qualifiedStatementVerified;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
function verifyQualifiedStatementAAgainstRule(qualifiedStatementNode,
|
|
69
|
+
function verifyQualifiedStatementAAgainstRule(qualifiedStatementNode, referenceMetavariableNode, localContext) {
|
|
70
70
|
let qualifiedStatementVerifiedAgainstRule = false;
|
|
71
71
|
|
|
72
|
-
const
|
|
72
|
+
const labelMetavariableNode = referenceMetavariableNode, ///
|
|
73
|
+
rule = localContext.findRuleByLabelMetavariableNode(labelMetavariableNode);
|
|
73
74
|
|
|
74
75
|
if (rule !== null) {
|
|
75
|
-
const
|
|
76
|
+
const referenceMetavariableString = localContext.nodeAsString(referenceMetavariableNode),
|
|
76
77
|
statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
77
78
|
statementLocalContext = localContext, ///
|
|
78
79
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
79
80
|
|
|
80
|
-
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${
|
|
81
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' rule...`, statementNode);
|
|
81
82
|
|
|
82
83
|
const ruleMatchesStatement = rule.matchStatement(statementNode, statementLocalContext);
|
|
83
84
|
|
|
84
85
|
qualifiedStatementVerifiedAgainstRule = ruleMatchesStatement; ///
|
|
85
86
|
|
|
86
87
|
if (qualifiedStatementVerifiedAgainstRule) {
|
|
87
|
-
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${
|
|
88
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' rule.`, statementNode);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
return qualifiedStatementVerifiedAgainstRule;
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
function verifyQualifiedStatementAAgainstAxiom(qualifiedStatementNode,
|
|
95
|
+
function verifyQualifiedStatementAAgainstAxiom(qualifiedStatementNode, referenceMetavariableNode, localContext) {
|
|
95
96
|
let qualifiedStatementVerifiedAgainstAxiom = false;
|
|
96
97
|
|
|
97
|
-
const
|
|
98
|
+
const labelMetavariableNode = referenceMetavariableNode, ///
|
|
99
|
+
axiom = localContext.findAxiomByLabelMetavariableNode(labelMetavariableNode);
|
|
98
100
|
|
|
99
101
|
if (axiom !== null) {
|
|
100
|
-
const
|
|
102
|
+
const referenceMetavariableString = localContext.nodeAsString(referenceMetavariableNode),
|
|
101
103
|
statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
102
104
|
statementLocalContext = localContext, ///
|
|
103
105
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
104
106
|
|
|
105
|
-
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${
|
|
107
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' axiom...`, statementNode);
|
|
106
108
|
|
|
107
109
|
const axiomMatchesStatement = axiom.matchStatement(statementNode, statementLocalContext);
|
|
108
110
|
|
|
109
111
|
qualifiedStatementVerifiedAgainstAxiom = axiomMatchesStatement; ///
|
|
110
112
|
|
|
111
113
|
if (qualifiedStatementVerifiedAgainstAxiom) {
|
|
112
|
-
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${
|
|
114
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' axiom.`, statementNode);
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
return qualifiedStatementVerifiedAgainstAxiom;
|
|
117
119
|
}
|
|
118
120
|
|
|
119
|
-
function verifyQualifiedStatementAAgainstLemma(qualifiedStatementNode,
|
|
121
|
+
function verifyQualifiedStatementAAgainstLemma(qualifiedStatementNode, referenceMetavariableNode, localContext) {
|
|
120
122
|
let qualifiedStatementVerifiedAgainstLemma = false;
|
|
121
123
|
|
|
122
|
-
const
|
|
124
|
+
const labelMetavariableNode = referenceMetavariableNode, ///
|
|
125
|
+
lemma = localContext.findLemmaByLabelMetavariableNode(labelMetavariableNode);
|
|
123
126
|
|
|
124
127
|
if (lemma !== null) {
|
|
125
|
-
const
|
|
128
|
+
const referenceMetavariableString = localContext.nodeAsString(referenceMetavariableNode),
|
|
126
129
|
statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
127
130
|
statementLocalContext = localContext, ///
|
|
128
131
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
129
132
|
|
|
130
|
-
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${
|
|
133
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' lemma...`, statementNode);
|
|
131
134
|
|
|
132
135
|
const lemmaMatchesStatement = lemma.matchStatement(statementNode, statementLocalContext);
|
|
133
136
|
|
|
134
137
|
qualifiedStatementVerifiedAgainstLemma = lemmaMatchesStatement; ///
|
|
135
138
|
|
|
136
139
|
if (qualifiedStatementVerifiedAgainstLemma) {
|
|
137
|
-
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${
|
|
140
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' lemma.`, statementNode);
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
|
|
141
144
|
return qualifiedStatementVerifiedAgainstLemma;
|
|
142
145
|
}
|
|
143
146
|
|
|
144
|
-
function verifyQualifiedStatementAAgainstTheorem(qualifiedStatementNode,
|
|
147
|
+
function verifyQualifiedStatementAAgainstTheorem(qualifiedStatementNode, referenceMetavariableNode, localContext) {
|
|
145
148
|
let qualifiedStatementVerifiedAgainstTheorem = false;
|
|
146
149
|
|
|
147
|
-
const
|
|
150
|
+
const labelMetavariableNode = referenceMetavariableNode, ///
|
|
151
|
+
theorem = localContext.findTheoremByLabelMetavariableNode(labelMetavariableNode);
|
|
148
152
|
|
|
149
153
|
if (theorem !== null) {
|
|
150
|
-
const
|
|
154
|
+
const referenceMetavariableString = localContext.nodeAsString(referenceMetavariableNode),
|
|
151
155
|
statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
152
156
|
statementLocalContext = localContext, ///
|
|
153
157
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
154
158
|
|
|
155
|
-
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${
|
|
159
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' theorem...`, statementNode);
|
|
156
160
|
|
|
157
161
|
const theoremMatchesStatement = theorem.matchStatement(statementNode, statementLocalContext);
|
|
158
162
|
|
|
159
163
|
qualifiedStatementVerifiedAgainstTheorem = theoremMatchesStatement; ///
|
|
160
164
|
|
|
161
165
|
if (qualifiedStatementVerifiedAgainstTheorem) {
|
|
162
|
-
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${
|
|
166
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' theorem.`, statementNode);
|
|
163
167
|
}
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
return qualifiedStatementVerifiedAgainstTheorem;
|
|
167
171
|
}
|
|
168
172
|
|
|
169
|
-
function verifyQualifiedStatementAAgainstConjecture(qualifiedStatementNode,
|
|
173
|
+
function verifyQualifiedStatementAAgainstConjecture(qualifiedStatementNode, referenceMetavariableNode, localContext) {
|
|
170
174
|
let qualifiedStatementVerifiedAgainstConjecture = false;
|
|
171
175
|
|
|
172
|
-
const
|
|
176
|
+
const labelMetavariableNode = referenceMetavariableNode, ///
|
|
177
|
+
conjecture = localContext.findConjectureByLabelMetavariableNode(labelMetavariableNode);
|
|
173
178
|
|
|
174
179
|
if (conjecture !== null) {
|
|
175
|
-
const
|
|
180
|
+
const referenceMetavariableString = localContext.nodeAsString(referenceMetavariableNode),
|
|
176
181
|
statementNode = statementNodeQuery(qualifiedStatementNode),
|
|
177
182
|
statementLocalContext = localContext, ///
|
|
178
183
|
qualifiedStatementString = localContext.nodeAsString(qualifiedStatementNode);
|
|
179
184
|
|
|
180
|
-
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${
|
|
185
|
+
localContext.trace(`Verifying the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' conjecture...`, statementNode);
|
|
181
186
|
|
|
182
187
|
const conjectureMatchesStatement = conjecture.matchStatement(statementNode, statementLocalContext);
|
|
183
188
|
|
|
184
189
|
qualifiedStatementVerifiedAgainstConjecture = conjectureMatchesStatement; ///
|
|
185
190
|
|
|
186
191
|
if (qualifiedStatementVerifiedAgainstConjecture) {
|
|
187
|
-
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${
|
|
192
|
+
localContext.debug(`...verified the '${qualifiedStatementString}' qualified statement against the '${referenceMetavariableString}' conjecture.`, statementNode);
|
|
188
193
|
}
|
|
189
194
|
}
|
|
190
195
|
|
package/src/verify/statement.js
CHANGED
|
@@ -12,9 +12,9 @@ import { nodeQuery } from "../utilities/query";
|
|
|
12
12
|
const termNodeQuery = nodeQuery("/statement/term!"),
|
|
13
13
|
equalityNodeQuery = nodeQuery("/statement/equality!"),
|
|
14
14
|
definingNodeQuery = nodeQuery("/statement/defining!"),
|
|
15
|
-
statementNodeQuery = nodeQuery("/
|
|
15
|
+
statementNodeQuery = nodeQuery("/metastatement/statement!"),
|
|
16
16
|
containmentNodeQuery = nodeQuery("/statement/containment!"),
|
|
17
|
-
|
|
17
|
+
metastatementNodeQuery = nodeQuery("/statement/metastatement!"),
|
|
18
18
|
typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!");
|
|
19
19
|
|
|
20
20
|
function verifyStatement(statementNode, assignments, derived, localContext, verifyAhead) {
|
|
@@ -151,11 +151,11 @@ function verifyStatementAboutContainment(statementNode, assignments, derived, lo
|
|
|
151
151
|
localContext.trace(`Verifying the '${statementString}' statement about containment...`, statementNode);
|
|
152
152
|
|
|
153
153
|
const termNode = termNodeQuery(statementNode),
|
|
154
|
-
|
|
155
|
-
containmentVerified = verifyContainment(termNode, containmentNode,
|
|
154
|
+
metastatementNode = metastatementNodeQuery(statementNode),
|
|
155
|
+
containmentVerified = verifyContainment(termNode, containmentNode, metastatementNode, localContext);
|
|
156
156
|
|
|
157
157
|
if (containmentVerified) {
|
|
158
|
-
statementNode = statementNodeQuery(
|
|
158
|
+
statementNode = statementNodeQuery(metastatementNode); ///
|
|
159
159
|
|
|
160
160
|
const verifyStatementFunctions = [
|
|
161
161
|
verifyStatementAsEquality,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { nodeQuery } from "../utilities/query";
|
|
4
|
+
import { STATEMENT_META_TYPE_NAME } from "../metaTypeNames";
|
|
5
|
+
|
|
6
|
+
const metaTypeTerminalNodeQuery = nodeQuery("/metaType/@meta-type!");
|
|
7
|
+
|
|
8
|
+
export default function verifyStatementAgainstMetaType(statementNode, metaTypeNode, localContext, verifyAhead) {
|
|
9
|
+
let statementVerifiedAgainstMetaType = false;
|
|
10
|
+
|
|
11
|
+
const metaTypeTerminalNode = metaTypeTerminalNodeQuery(metaTypeNode),
|
|
12
|
+
content = metaTypeTerminalNode.getContent();
|
|
13
|
+
|
|
14
|
+
if (content === STATEMENT_META_TYPE_NAME) {
|
|
15
|
+
const verifiedAhead = verifyAhead();
|
|
16
|
+
|
|
17
|
+
statementVerifiedAgainstMetaType = verifiedAhead; ///
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return statementVerifiedAgainstMetaType;
|
|
21
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import TermForVariableSubstitution from "../substitution/termForVariable";
|
|
4
|
+
import intrinsicLevelNodesVerifier from "../verifier/nodes/intrinsicLevel";
|
|
5
|
+
|
|
6
|
+
import { push } from "../utilities/array";
|
|
7
|
+
|
|
8
|
+
export default function verifyStatementAgainstStatement(statementNodeA, statementNodeB, substitution, substitutions, localContextA, localContextB) {
|
|
9
|
+
let statementVerifiedAgainstStatement = false;
|
|
10
|
+
|
|
11
|
+
const termForVariableSubstitution = TermForVariableSubstitution.fromSubstitutionAndSubstitutions(substitution, substitutions),
|
|
12
|
+
transformed = termForVariableSubstitution.isTransformed(substitution);
|
|
13
|
+
|
|
14
|
+
let substitutionsA = []; ///
|
|
15
|
+
|
|
16
|
+
if (transformed) {
|
|
17
|
+
const substitutionA = termForVariableSubstitution; ///
|
|
18
|
+
|
|
19
|
+
substitutionsA.push(substitutionA);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const nonTerminalNodeA = statementNodeA, ///
|
|
23
|
+
nonTerminalNodeB = statementNodeB, ///
|
|
24
|
+
nonTerminalNodeVerified = intrinsicLevelNodesVerifier.verifyNonTerminalNode(nonTerminalNodeA, nonTerminalNodeB, substitutionsA, localContextA, localContextB, () => {
|
|
25
|
+
const verifiedAhead = true;
|
|
26
|
+
|
|
27
|
+
return verifiedAhead;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (nonTerminalNodeVerified) {
|
|
31
|
+
if (!transformed) {
|
|
32
|
+
const substitutionB = termForVariableSubstitution, ///
|
|
33
|
+
substitutionsB = [
|
|
34
|
+
substitutionB
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
substitutionsA = transformSubstitutions(substitutionsA, substitutionsB);
|
|
38
|
+
|
|
39
|
+
push(substitutions, substitutionsA);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
statementVerifiedAgainstStatement = true;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return statementVerifiedAgainstStatement;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function transformSubstitutions(substitutionsA, substitutionsB) {
|
|
49
|
+
substitutionsA = substitutionsA.map((substitutionA) => {
|
|
50
|
+
const substitution = substitutionA, ///
|
|
51
|
+
substitutions = substitutionsB,
|
|
52
|
+
termForVariableSubstitution = TermForVariableSubstitution.fromSubstitutionAndSubstitutions(substitution, substitutions);
|
|
53
|
+
|
|
54
|
+
substitutionA = termForVariableSubstitution; ///
|
|
55
|
+
|
|
56
|
+
return substitutionA;
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return substitutionsA;
|
|
60
|
+
}
|
package/src/verify/term.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Term from "../term";
|
|
4
|
-
import termAgainstConstructorNodesVerifier from "../verifier/nodes/termAgainstConstructor";
|
|
5
|
-
import verifyGivenVariable from "../verify/givenVariable";
|
|
6
4
|
import bracketedConstructor from "../constructor/bracketed";
|
|
5
|
+
import termAgainstConstructorNodesVerifier from "../verifier/nodes/termAgainstConstructor";
|
|
7
6
|
|
|
8
7
|
import { first } from "../utilities/array";
|
|
9
8
|
import { nodeQuery } from "../utilities/query";
|
|
@@ -74,27 +73,24 @@ function verifyTermAsVariable(termNode, terms, localContext, verifyAhead) {
|
|
|
74
73
|
|
|
75
74
|
localContext.trace(`Verifying the '${termString}' term as a variable...`, termNode);
|
|
76
75
|
|
|
77
|
-
const
|
|
78
|
-
givenVariableVerified = verifyGivenVariable(variableNode, variables, localContext, () => {
|
|
79
|
-
let verifiedAhead;
|
|
76
|
+
const variable = localContext.findVariableByVariableNode(variableNode);
|
|
80
77
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
type = variable.getType(),
|
|
84
|
-
term = Term.fromTermNodeAndType(termNode, type);
|
|
78
|
+
if (variable !== null) {
|
|
79
|
+
let verifiedAhead;
|
|
85
80
|
|
|
86
|
-
|
|
81
|
+
const type = variable.getType(),
|
|
82
|
+
term = Term.fromTermNodeAndType(termNode, type);
|
|
87
83
|
|
|
88
|
-
|
|
84
|
+
terms.push(term);
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
terms.pop();
|
|
92
|
-
}
|
|
86
|
+
verifiedAhead = verifyAhead();
|
|
93
87
|
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
if (!verifiedAhead) {
|
|
89
|
+
terms.pop();
|
|
90
|
+
}
|
|
96
91
|
|
|
97
|
-
|
|
92
|
+
termVerifiedAsVariable = verifiedAhead; ///
|
|
93
|
+
}
|
|
98
94
|
|
|
99
95
|
if (termVerifiedAsVariable) {
|
|
100
96
|
localContext.debug(`...verified the '${termString}' term as a variable.`, termNode);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { areTermNodesEqual } from "../utilities/equivalences";
|
|
4
|
+
|
|
5
|
+
export default function verifyTermAgainstTerm(termNodeA, termNodeB, localContext, verifyAhead) {
|
|
6
|
+
let termVerifiedAgainstTerm = false;
|
|
7
|
+
|
|
8
|
+
const leftTermNode = termNodeA, ///
|
|
9
|
+
rightTermNode = termNodeB, ///
|
|
10
|
+
equivalences = localContext.getEquivalences(),
|
|
11
|
+
termNodesEqual = areTermNodesEqual(leftTermNode, rightTermNode, equivalences);
|
|
12
|
+
|
|
13
|
+
if (termNodesEqual) {
|
|
14
|
+
const verifiedAhead = verifyAhead();
|
|
15
|
+
|
|
16
|
+
termVerifiedAgainstTerm = verifiedAhead; ///
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return termVerifiedAgainstTerm;
|
|
20
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { first } from "../utilities/array";
|
|
4
|
+
|
|
5
|
+
export default function verifyTermAgainstType(termNode, typeNode, localContext, verifyAhead, verifyTerm) {
|
|
6
|
+
let termVerifiedAgainstType;
|
|
7
|
+
|
|
8
|
+
const terms = [],
|
|
9
|
+
termVerified = verifyTerm(termNode, terms, localContext, () => {
|
|
10
|
+
let verifiedAhead = false;
|
|
11
|
+
|
|
12
|
+
const firstTerm = first(terms),
|
|
13
|
+
term = firstTerm, ///
|
|
14
|
+
termType = term.getType(),
|
|
15
|
+
type = localContext.findTypeByTypeNode(typeNode),
|
|
16
|
+
termTypeEqualToOrSubTypeOfType = termType.isEqualToOrSubTypeOf(type);
|
|
17
|
+
|
|
18
|
+
if (termTypeEqualToOrSubTypeOfType) {
|
|
19
|
+
verifiedAhead = verifyAhead();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return verifiedAhead;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
termVerifiedAgainstType = termVerified; ///
|
|
26
|
+
|
|
27
|
+
return termVerifiedAgainstType;
|
|
28
|
+
}
|
package/src/verify/terms.js
CHANGED
|
@@ -18,9 +18,7 @@ export default function verifyTerms(termNodes, terms, localContext, verifyAhead)
|
|
|
18
18
|
let verifiedAhead;
|
|
19
19
|
|
|
20
20
|
const secondTermVerified = verifyTerm(secondTermNode, terms, localContext, () => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
verifiedAhead = verifyAhead();
|
|
21
|
+
const verifiedAhead = verifyAhead();
|
|
24
22
|
|
|
25
23
|
return verifiedAhead;
|
|
26
24
|
});
|
package/src/verify/theorem.js
CHANGED
|
@@ -11,21 +11,21 @@ import { first } from "../utilities/array";
|
|
|
11
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
12
|
|
|
13
13
|
const proofNodeQuery = nodeQuery("/theorem/proof!"),
|
|
14
|
-
|
|
14
|
+
labelsNodeQuery = nodeQuery("/theorem/labels!"),
|
|
15
15
|
consequentNodeQuery = nodeQuery("/theorem/consequent!"),
|
|
16
16
|
suppositionsNodeQuery = nodesQuery("/theorem/supposition");
|
|
17
17
|
|
|
18
18
|
export default function verifyTheorem(theoremNode, fileContext) {
|
|
19
19
|
let theoremVerified = false;
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
labelsString = fileContext.
|
|
21
|
+
const labelsNode = labelsNodeQuery(theoremNode),
|
|
22
|
+
labelsString = fileContext.nodeAsString(labelsNode),
|
|
23
23
|
localContext = LocalContext.fromFileContext(fileContext);
|
|
24
24
|
|
|
25
25
|
fileContext.trace(`Verifying the '${labelsString}' theorem...`, theoremNode);
|
|
26
26
|
|
|
27
27
|
const labels = [],
|
|
28
|
-
labelsVerified = verifyLabels(
|
|
28
|
+
labelsVerified = verifyLabels(labelsNode, labels, fileContext);
|
|
29
29
|
|
|
30
30
|
if (labelsVerified) {
|
|
31
31
|
const suppositions = [],
|
package/src/verify/type.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Type from "../type";
|
|
4
|
-
import verifyGivenType from "../verify/givenType";
|
|
5
4
|
|
|
6
5
|
import { typeNameFromTypeNode } from "../utilities/name";
|
|
7
6
|
|
|
@@ -52,16 +51,19 @@ export default function verifyType(typeNode, superTypeNode, fileContext) {
|
|
|
52
51
|
}
|
|
53
52
|
|
|
54
53
|
export function verifyStandaloneType(typeNode, localContext, verifyAhead) {
|
|
55
|
-
let standaloneTypeVerified;
|
|
54
|
+
let standaloneTypeVerified = false;
|
|
56
55
|
|
|
57
56
|
const typeString = localContext.nodeAsString(typeNode);
|
|
58
57
|
|
|
59
58
|
localContext.trace(`Verifying the '${typeString}' standalone type...`, typeNode);
|
|
60
59
|
|
|
61
|
-
const
|
|
62
|
-
givenTypeVerified = verifyGivenType(typeNode, types, localContext, verifyAhead);
|
|
60
|
+
const typePresent = localContext.isTypePresentByTypeNode(typeNode);
|
|
63
61
|
|
|
64
|
-
|
|
62
|
+
if (typePresent) {
|
|
63
|
+
const verifiedAhead = verifyAhead();
|
|
64
|
+
|
|
65
|
+
standaloneTypeVerified = verifiedAhead; ///
|
|
66
|
+
}
|
|
65
67
|
|
|
66
68
|
if (standaloneTypeVerified) {
|
|
67
69
|
localContext.debug(`...verified the '${typeString}' standalone type.`, typeNode);
|