occam-verify-cli 0.0.1002 → 0.0.1005
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/README.md +0 -2
- package/bin/abbreviations.js +1 -3
- package/bin/action/help.js +0 -2
- package/bin/action/verify.js +4 -24
- package/bin/defaults.js +0 -2
- package/bin/main.js +3 -4
- package/bin/options.js +0 -2
- package/lib/assertion/subproof.js +106 -0
- package/lib/assignment/metavariable.js +2 -2
- package/lib/combinator.js +50 -16
- package/lib/conclusion.js +73 -14
- package/lib/context/file.js +191 -31
- package/lib/context/local.js +37 -49
- package/lib/context/release.js +42 -35
- package/lib/context/release.other.js +605 -0
- package/lib/declaration/combinator.js +83 -0
- package/lib/derivation.js +86 -0
- package/lib/equality.js +3 -11
- package/lib/index.js +1 -1
- package/lib/judgement.js +3 -10
- package/lib/label.js +58 -16
- package/lib/log.js +3 -11
- package/lib/metaType.js +31 -19
- package/lib/metavariable.js +39 -12
- package/lib/mixins/statement/qualified/unify.js +118 -0
- package/lib/mixins/statement/unify.js +57 -0
- package/lib/mixins/statement/verify.js +184 -0
- package/lib/node/statement/combinator/bracketed.js +15 -11
- package/lib/ocmbinator/bracketed.js +52 -8
- package/lib/premise.js +109 -56
- package/lib/proof.js +91 -0
- package/lib/proofStep.js +78 -25
- package/lib/reference.js +62 -16
- package/lib/rule.js +146 -26
- package/lib/ruleNames.js +5 -5
- package/lib/statement/qualified.js +127 -0
- package/lib/statement/unqualified.js +89 -0
- package/lib/statement.js +176 -0
- package/lib/subDerivation.js +86 -0
- package/lib/subproof.js +155 -0
- package/lib/substitution/frameForMetavariable.js +14 -15
- package/lib/substitution/statementForMetavariable.js +23 -24
- package/lib/substitution/termForVariable.js +11 -12
- package/lib/substitution.js +9 -2
- package/lib/substitutions.js +14 -14
- package/lib/supposition.js +92 -60
- package/lib/unifier/statementWithCombinator.js +3 -3
- package/lib/unify/metavariableWithFrame.js +2 -2
- package/lib/unify/metavariableWithStatement.js +2 -2
- package/lib/unify/metavariableWithStatementGivenSubstitution.js +2 -2
- package/lib/unify/variableWithTerm.js +2 -2
- package/lib/utilities/node.js +13 -11
- package/lib/utilities/releaseContext.js +3 -3
- package/lib/utilities/string.js +8 -2
- package/lib/utilities/subproof.js +5 -5
- package/lib/utilities/tokens.js +10 -10
- package/lib/variable.js +1 -10
- package/lib/verifier/metaLevel.js +2 -2
- package/lib/verifier/topLevel.js +5 -5
- package/lib/verify/axiom.js +3 -5
- package/lib/verify/conjecture.js +4 -7
- package/lib/verify/consequent.js +2 -3
- package/lib/verify/declaration/combinator.js +2 -14
- package/lib/verify/declaration/metavariable.js +9 -10
- package/lib/verify/files.js +4 -4
- package/lib/verify/frame.js +12 -12
- package/lib/verify/lemma.js +4 -7
- package/lib/verify/metaLemma.js +4 -7
- package/lib/verify/metatheorem.js +4 -7
- package/lib/verify/proofStep.js +2 -31
- package/lib/verify/theorem.js +4 -7
- package/package.json +4 -4
- package/src/assertion/subproof.js +84 -0
- package/src/assignment/metavariable.js +2 -2
- package/src/combinator.js +45 -15
- package/src/conclusion.js +83 -13
- package/src/context/file.js +223 -11
- package/src/context/local.js +12 -16
- package/src/context/release.js +57 -39
- package/src/context/release.other.js +547 -0
- package/src/declaration/combinator.js +44 -0
- package/src/derivation.js +50 -0
- package/src/equality.js +2 -9
- package/src/index.js +0 -1
- package/src/judgement.js +2 -8
- package/src/label.js +56 -13
- package/src/log.js +2 -9
- package/src/metaType.js +26 -14
- package/src/metavariable.js +57 -9
- package/src/mixins/statement/qualified/unify.js +186 -0
- package/src/mixins/statement/unify.js +70 -0
- package/src/mixins/statement/verify.js +274 -0
- package/src/node/statement/combinator/bracketed.js +4 -3
- package/src/ocmbinator/bracketed.js +15 -12
- package/src/premise.js +136 -44
- package/src/proof.js +58 -0
- package/src/proofStep.js +92 -22
- package/src/reference.js +58 -12
- package/src/rule.js +199 -30
- package/src/ruleNames.js +1 -1
- package/src/statement/qualified.js +104 -0
- package/src/statement/unqualified.js +60 -0
- package/src/statement.js +179 -0
- package/src/subDerivation.js +52 -0
- package/src/subproof.js +99 -0
- package/src/substitution/frameForMetavariable.js +20 -17
- package/src/substitution/statementForMetavariable.js +31 -29
- package/src/substitution/termForVariable.js +15 -14
- package/src/substitution.js +8 -0
- package/src/substitutions.js +12 -13
- package/src/supposition.js +94 -44
- package/src/unifier/statementWithCombinator.js +6 -3
- package/src/unify/metavariableWithFrame.js +1 -1
- package/src/unify/metavariableWithStatement.js +1 -1
- package/src/unify/metavariableWithStatementGivenSubstitution.js +1 -1
- package/src/unify/variableWithTerm.js +1 -1
- package/src/utilities/node.js +18 -12
- package/src/utilities/releaseContext.js +2 -2
- package/src/utilities/string.js +6 -2
- package/src/utilities/subproof.js +2 -2
- package/src/utilities/tokens.js +7 -7
- package/src/variable.js +0 -10
- package/src/verifier/metaLevel.js +3 -2
- package/src/verifier/topLevel.js +6 -4
- package/src/verify/axiom.js +1 -2
- package/src/verify/conjecture.js +2 -3
- package/src/verify/consequent.js +1 -1
- package/src/verify/declaration/combinator.js +0 -20
- package/src/verify/declaration/metavariable.js +8 -12
- package/src/verify/files.js +3 -3
- package/src/verify/frame.js +11 -11
- package/src/verify/lemma.js +2 -3
- package/src/verify/metaLemma.js +2 -3
- package/src/verify/metatheorem.js +2 -3
- package/src/verify/proofStep.js +0 -41
- package/src/verify/theorem.js +2 -3
- package/lib/tokens/combinatorStatement/bracketed.js +0 -17
- package/lib/unify/premiseWithProofStep.js +0 -41
- package/lib/unify/premisesWithProofSteps.js +0 -31
- package/lib/unify/qualifiedStatement.js +0 -136
- package/lib/unify/statementWithBracketedCombinator.js +0 -30
- package/lib/unify/statementWithCombinator.js +0 -29
- package/lib/unify/statementWithCombinators.js +0 -31
- package/lib/unify/statementWithMetaType.js +0 -24
- package/lib/verify/conclusion.js +0 -39
- package/lib/verify/derivation.js +0 -31
- package/lib/verify/label.js +0 -37
- package/lib/verify/labels.js +0 -28
- package/lib/verify/premise.js +0 -45
- package/lib/verify/premises.js +0 -28
- package/lib/verify/proof.js +0 -34
- package/lib/verify/rule.js +0 -56
- package/lib/verify/statement/qualified.js +0 -41
- package/lib/verify/statement/unqualified.js +0 -45
- package/lib/verify/statement.js +0 -219
- package/lib/verify/statementAsCombinator.js +0 -33
- package/lib/verify/statementGivenMetaType.js +0 -52
- package/lib/verify/subproof.js +0 -34
- package/lib/verify/supposition.js +0 -45
- package/lib/verify/suppositions.js +0 -28
- package/src/tokens/combinatorStatement/bracketed.js +0 -10
- package/src/unify/premiseWithProofStep.js +0 -54
- package/src/unify/premisesWithProofSteps.js +0 -23
- package/src/unify/qualifiedStatement.js +0 -208
- package/src/unify/statementWithBracketedCombinator.js +0 -22
- package/src/unify/statementWithCombinator.js +0 -22
- package/src/unify/statementWithCombinators.js +0 -23
- package/src/unify/statementWithMetaType.js +0 -14
- package/src/verify/conclusion.js +0 -40
- package/src/verify/derivation.js +0 -23
- package/src/verify/label.js +0 -34
- package/src/verify/labels.js +0 -17
- package/src/verify/premise.js +0 -49
- package/src/verify/premises.js +0 -17
- package/src/verify/proof.js +0 -31
- package/src/verify/rule.js +0 -71
- package/src/verify/statement/qualified.js +0 -40
- package/src/verify/statement/unqualified.js +0 -49
- package/src/verify/statement.js +0 -312
- package/src/verify/statementAsCombinator.js +0 -27
- package/src/verify/statementGivenMetaType.js +0 -52
- package/src/verify/subproof.js +0 -32
- package/src/verify/supposition.js +0 -49
- package/src/verify/suppositions.js +0 -17
package/src/supposition.js
CHANGED
|
@@ -1,72 +1,122 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import ProofStep from "./proofStep";
|
|
4
|
+
import UnqualifiedStatement from "./statement/unqualified";
|
|
5
|
+
|
|
3
6
|
import metaLevelUnifier from "./unifier/metaLevel";
|
|
4
7
|
|
|
5
8
|
import { match } from "./utilities/array";
|
|
6
|
-
import {
|
|
9
|
+
import { assignAssignments } from "./utilities/assignments";
|
|
7
10
|
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
11
|
|
|
9
12
|
const subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
13
|
+
unqualifiedStatementNodeQuery = nodeQuery("/supposition/unqualifiedStatement"),
|
|
10
14
|
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
11
15
|
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
12
16
|
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
|
|
13
17
|
|
|
14
18
|
export default class Supposition {
|
|
15
|
-
constructor(
|
|
16
|
-
this.
|
|
19
|
+
constructor(fileContext, unqualifiedStatement) {
|
|
20
|
+
this.fileContext = fileContext;
|
|
21
|
+
this.unqualifiedStatement = unqualifiedStatement;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
return this.
|
|
24
|
+
getFileContext() {
|
|
25
|
+
return this.fileContext;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
getUnqualifiedStatement() {
|
|
29
|
+
return this.unqualifiedStatement;
|
|
30
|
+
}
|
|
25
31
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
getString() { return this.unqualifiedStatement.getString(); }
|
|
33
|
+
|
|
34
|
+
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
35
|
+
|
|
36
|
+
// unifyStatement(statementNodeB, substitutions, localContextA, localContextB) {
|
|
37
|
+
// let statementUnified = false;
|
|
38
|
+
//
|
|
39
|
+
// if (this.statementNode !== null) {
|
|
40
|
+
// const nodeA = this.statementNode, ///
|
|
41
|
+
// nodeB = statementNodeB, ///
|
|
42
|
+
// unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
43
|
+
//
|
|
44
|
+
// statementUnified = unified; ///
|
|
45
|
+
// }
|
|
46
|
+
//
|
|
47
|
+
// return statementUnified;
|
|
48
|
+
// }
|
|
49
|
+
|
|
50
|
+
// unifySubproof(subproofNodeB, substitutions, localContextA, localContextB) {
|
|
51
|
+
// let subproofUnified = false;
|
|
52
|
+
//
|
|
53
|
+
// if (this.statementNode !== null) {
|
|
54
|
+
// const statementNodeA = this.statementNode,
|
|
55
|
+
// subproofAssertionNodeA = subproofAssertionNodeQuery(statementNodeA); ///
|
|
56
|
+
//
|
|
57
|
+
// if (subproofAssertionNodeA !== null) {
|
|
58
|
+
// const subproofAssertionStatementNodesA = subproofAssertionStatementNodesQuery(subproofAssertionNodeA), ///
|
|
59
|
+
// subproofSuppositionStatementNodesB = subproofSuppositionStatementNodesQuery(subproofNodeB), ///
|
|
60
|
+
// subproofLastProofStepStatementNodeB = subproofLastProofStepStatementNodeQuery(subproofNodeB), ///
|
|
61
|
+
// subproofStatementNodesB = [
|
|
62
|
+
// ...subproofSuppositionStatementNodesB,
|
|
63
|
+
// subproofLastProofStepStatementNodeB
|
|
64
|
+
// ];
|
|
65
|
+
//
|
|
66
|
+
// subproofUnified = match(subproofAssertionStatementNodesA, subproofStatementNodesB, (subproofAssertionStatementNodeA, subproofStatementNodeB) => {
|
|
67
|
+
// const nodeA = subproofAssertionStatementNodeA, ///
|
|
68
|
+
// nodeB = subproofStatementNodeB, ///
|
|
69
|
+
// unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
70
|
+
//
|
|
71
|
+
// if (unified) {
|
|
72
|
+
// return true;
|
|
73
|
+
// }
|
|
74
|
+
// });
|
|
75
|
+
// }
|
|
76
|
+
// }
|
|
77
|
+
//
|
|
78
|
+
// return subproofUnified;
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
verify(localContext) {
|
|
82
|
+
let verified = false;
|
|
83
|
+
|
|
84
|
+
const suppositionString = this.getString(); ///
|
|
85
|
+
|
|
86
|
+
if (this.unqualifiedStatement !== null) {
|
|
87
|
+
localContext.trace(`Verifying the '${suppositionString}' supposition...`);
|
|
88
|
+
|
|
89
|
+
const stated = true,
|
|
90
|
+
assignments = [],
|
|
91
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
92
|
+
|
|
93
|
+
if (unqualifiedStatementVerified) {
|
|
94
|
+
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
95
|
+
|
|
96
|
+
if (assignmentsAssigned) {
|
|
97
|
+
const proofStep = ProofStep.fromUnqualifiedStatement(this.unqualifiedStatement);
|
|
98
|
+
|
|
99
|
+
localContext.addProofStep(proofStep);
|
|
100
|
+
|
|
101
|
+
verified = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
30
104
|
|
|
31
|
-
|
|
105
|
+
} else {
|
|
106
|
+
localContext.debug(`The '${suppositionString}' supposition cannot be verified because it is nonsense.`);
|
|
32
107
|
}
|
|
33
108
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
unifySubproof(subproofNodeB, substitutions, localContextA, localContextB) {
|
|
38
|
-
let subproofUnified = false;
|
|
39
|
-
|
|
40
|
-
if (this.statementNode !== null) {
|
|
41
|
-
const statementNodeA = this.statementNode,
|
|
42
|
-
subproofAssertionNodeA = subproofAssertionNodeQuery(statementNodeA); ///
|
|
43
|
-
|
|
44
|
-
if (subproofAssertionNodeA !== null) {
|
|
45
|
-
const subproofAssertionStatementNodesA = subproofAssertionStatementNodesQuery(subproofAssertionNodeA), ///
|
|
46
|
-
subproofSuppositionStatementNodesB = subproofSuppositionStatementNodesQuery(subproofNodeB), ///
|
|
47
|
-
subproofLastProofStepStatementNodeB = subproofLastProofStepStatementNodeQuery(subproofNodeB), ///
|
|
48
|
-
subproofStatementNodesB = [
|
|
49
|
-
...subproofSuppositionStatementNodesB,
|
|
50
|
-
subproofLastProofStepStatementNodeB
|
|
51
|
-
];
|
|
52
|
-
|
|
53
|
-
subproofUnified = match(subproofAssertionStatementNodesA, subproofStatementNodesB, (subproofAssertionStatementNodeA, subproofStatementNodeB) => {
|
|
54
|
-
const nodeA = subproofAssertionStatementNodeA, ///
|
|
55
|
-
nodeB = subproofStatementNodeB, ///
|
|
56
|
-
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
57
|
-
|
|
58
|
-
if (unified) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
109
|
+
if (verified) {
|
|
110
|
+
localContext.debug(`...verified the '${suppositionString}' supposition.`);
|
|
63
111
|
}
|
|
64
112
|
|
|
65
|
-
return
|
|
113
|
+
return verified;
|
|
66
114
|
}
|
|
67
115
|
|
|
68
|
-
static
|
|
69
|
-
const
|
|
116
|
+
static fromSuppositionNode(suppositionNode, fileContext) {
|
|
117
|
+
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(suppositionNode),
|
|
118
|
+
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
119
|
+
supposition = new Supposition(fileContext, unqualifiedStatement);
|
|
70
120
|
|
|
71
121
|
return supposition;
|
|
72
122
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import shim from "../shim";
|
|
3
4
|
import Unifier from "../unifier";
|
|
4
5
|
import unifyTermWithType from "../unify/termWithType";
|
|
5
6
|
import unifyFrameWithMetaType from "../unify/frameWithMetaType";
|
|
6
|
-
import unifyStatementWithMetaType from "../unify/statementWithMetaType";
|
|
7
7
|
|
|
8
8
|
import { nodeQuery } from "../utilities/query";
|
|
9
9
|
|
|
@@ -31,9 +31,12 @@ class StatementWithCombinatorUnifier extends Unifier {
|
|
|
31
31
|
nodeQueryA: statementNodeQuery,
|
|
32
32
|
nodeQueryB: metaTypeNodeQuery,
|
|
33
33
|
unify: (statementNodeA, metaTypeNodeB, assignments, stated, localContext) => {
|
|
34
|
-
const
|
|
34
|
+
const { MetaType, Statement } = shim,
|
|
35
|
+
metaTypeNode = metaTypeNodeB, ///
|
|
35
36
|
statementNode = statementNodeA, ///
|
|
36
|
-
|
|
37
|
+
metaType = MetaType.fromMetaTypeNode(metaTypeNode, localContext),
|
|
38
|
+
statement = Statement.fromStatementNode(statementNode, localContext),
|
|
39
|
+
statementUnifiedWithMetaType = statement.unifyWithMetaType(metaType, assignments, stated, localContext);
|
|
37
40
|
|
|
38
41
|
return statementUnifiedWithMetaType;
|
|
39
42
|
}
|
|
@@ -27,7 +27,7 @@ export default function unifyMetavariableWithFrame(metavariableNodeA, frameNodeB
|
|
|
27
27
|
} else {
|
|
28
28
|
const frameNode = frameNodeB, ///
|
|
29
29
|
metavariableNode = metavariableNodeA, ///
|
|
30
|
-
frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameNodeAndMetavariableNode(frameNode, metavariableNode),
|
|
30
|
+
frameForMetavariableSubstitution = FrameForMetavariableSubstitution.fromFrameNodeAndMetavariableNode(frameNode, metavariableNode, localContextA, localContextB),
|
|
31
31
|
substitution = frameForMetavariableSubstitution; ///
|
|
32
32
|
|
|
33
33
|
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
@@ -27,7 +27,7 @@ export default function unifyMetavariableWithStatement(metavariableNodeA, statem
|
|
|
27
27
|
} else {
|
|
28
28
|
const statementNode = statementNodeB, ///
|
|
29
29
|
metavariableNode = metavariableNodeA, ///
|
|
30
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeAndMetavariableNode(statementNode, metavariableNode),
|
|
30
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeAndMetavariableNode(statementNode, metavariableNode, localContextA, localContextB),
|
|
31
31
|
substitution = statementForMetavariableSubstitution; ///
|
|
32
32
|
|
|
33
33
|
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
@@ -28,7 +28,7 @@ export default function unifyMetavariableWithStatementGivenSubstitution(metavari
|
|
|
28
28
|
const statementNode = statementNodeB, ///
|
|
29
29
|
substitutionNode = substitutionNodeA, ///
|
|
30
30
|
metavariableNode = metavariableNodeA, ///
|
|
31
|
-
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeMetavariableNodeAndSubstitutionNode(statementNode, metavariableNode, substitutionNode),
|
|
31
|
+
statementForMetavariableSubstitution = StatementForMetavariableSubstitution.fromStatementNodeMetavariableNodeAndSubstitutionNode(statementNode, metavariableNode, substitutionNode, localContextA, localContextB),
|
|
32
32
|
substitution = statementForMetavariableSubstitution; ///
|
|
33
33
|
|
|
34
34
|
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
|
@@ -24,7 +24,7 @@ export default function unifyVariableWithTerm(variableNodeA, termNodeB, substitu
|
|
|
24
24
|
} else {
|
|
25
25
|
const termNode = termNodeB, ///
|
|
26
26
|
variableNode = variableNodeA, ///
|
|
27
|
-
termForVariableSubstitution = TermForVariableSubstitution.fromTernNodeAndVariableNode(termNode, variableNode),
|
|
27
|
+
termForVariableSubstitution = TermForVariableSubstitution.fromTernNodeAndVariableNode(termNode, variableNode, localContextA, localContextB),
|
|
28
28
|
substitution = termForVariableSubstitution; ///
|
|
29
29
|
|
|
30
30
|
substitutions.addSubstitution(substitution, localContextA, localContextB);
|
package/src/utilities/node.js
CHANGED
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
import { parsersUtilities } from "occam-custom-grammars";
|
|
4
4
|
|
|
5
|
+
import { nodeQuery } from "../utilities/query";
|
|
5
6
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
6
|
-
import { TERM_RULE_NAME,
|
|
7
|
-
import { termTokensFromTermString,
|
|
7
|
+
import { TERM_RULE_NAME, UNQUALIFIED_STATEMENT_RULE_NAME } from "../ruleNames";
|
|
8
|
+
import { termTokensFromTermString, unqualifiedStatementTokensFromUnqualifiedStatementString } from "../utilities/tokens";
|
|
8
9
|
|
|
9
|
-
const {
|
|
10
|
+
const { nominalParserFromCombinedCustomGrammar } = parsersUtilities;
|
|
10
11
|
|
|
11
12
|
const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
12
|
-
|
|
13
|
+
nominalParser = nominalParserFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
14
|
+
|
|
15
|
+
const statementNodeQuery = nodeQuery("/unqualifiedStatement/statement");
|
|
13
16
|
|
|
14
17
|
export function termNodeFromTermString(termString, lexer, parser) {
|
|
15
18
|
const termTokens = termTokensFromTermString(termString, lexer),
|
|
@@ -19,8 +22,11 @@ export function termNodeFromTermString(termString, lexer, parser) {
|
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export function statementNodeFromStatementString(statementString, lexer, parser) {
|
|
22
|
-
const
|
|
23
|
-
|
|
25
|
+
const unqualifiedStatementString = `${statementString}
|
|
26
|
+
`,
|
|
27
|
+
unqualifiedStatementTokens = unqualifiedStatementTokensFromUnqualifiedStatementString(unqualifiedStatementString, lexer),
|
|
28
|
+
unqualifiedStatementNode = unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser),
|
|
29
|
+
statementNode = statementNodeQuery(unqualifiedStatementNode);
|
|
24
30
|
|
|
25
31
|
return statementNode;
|
|
26
32
|
}
|
|
@@ -33,15 +39,15 @@ export function termNodeFromTermTokens(termTokens, parser) {
|
|
|
33
39
|
return termNode;
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
export function
|
|
37
|
-
const tokens =
|
|
38
|
-
ruleName =
|
|
39
|
-
|
|
42
|
+
export function unqualifiedStatementNodeFromUnqualifiedStatementTokens(unqualifiedStatementTokens, parser) {
|
|
43
|
+
const tokens = unqualifiedStatementTokens, ///
|
|
44
|
+
ruleName = UNQUALIFIED_STATEMENT_RULE_NAME,
|
|
45
|
+
unqualifiedStatementNode = nodeFromTokensRuleNameAndParser(tokens, ruleName, parser);
|
|
40
46
|
|
|
41
|
-
return
|
|
47
|
+
return unqualifiedStatementNode;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser =
|
|
50
|
+
function nodeFromTokensRuleNameAndParser(tokens, ruleName, parser = nominalParser) {
|
|
45
51
|
const ruleMap = parser.getRuleMap(),
|
|
46
52
|
rule = ruleMap[ruleName],
|
|
47
53
|
node = parser.parse(tokens, rule);
|
|
@@ -105,12 +105,12 @@ export function initialiseReleaseContext(dependency, context) {
|
|
|
105
105
|
const dependencyReleaseContextsInitialised = initialiseDependencyReleaseContexts(dependency, releaseContext, context);
|
|
106
106
|
|
|
107
107
|
if (dependencyReleaseContextsInitialised) {
|
|
108
|
-
const { log
|
|
108
|
+
const { log } = context,
|
|
109
109
|
releaseContexts = retrieveReleaseContexts(releaseContext, releaseContextMap);
|
|
110
110
|
|
|
111
111
|
log.debug(`Initialising the '${dependencyName}' context...`);
|
|
112
112
|
|
|
113
|
-
releaseContextInitialised = releaseContext.initialise(releaseContexts
|
|
113
|
+
releaseContextInitialised = releaseContext.initialise(releaseContexts);
|
|
114
114
|
|
|
115
115
|
releaseContextInitialised ?
|
|
116
116
|
log.info(`...initialised the '${dependencyName}' context.`) :
|
package/src/utilities/string.js
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { COMMA, EMPTY_STRING } from "../constants";
|
|
4
4
|
|
|
5
|
+
export function trim(string) {
|
|
6
|
+
string = string.replace(/\s+$/, EMPTY_STRING); ///
|
|
7
|
+
|
|
8
|
+
return string;
|
|
9
|
+
}
|
|
10
|
+
|
|
5
11
|
export function nodeAsString(node, tokens) {
|
|
6
12
|
let string;
|
|
7
13
|
|
|
@@ -17,8 +23,6 @@ export function nodeAsString(node, tokens) {
|
|
|
17
23
|
string = nonTerminalNodeAsString(nonTerminalNode, tokens);
|
|
18
24
|
}
|
|
19
25
|
|
|
20
|
-
string = string.replace(/\s+$/, EMPTY_STRING);
|
|
21
|
-
|
|
22
26
|
return string;
|
|
23
27
|
}
|
|
24
28
|
|
|
@@ -6,8 +6,8 @@ import { nodeAsString, nodesAsString } from "./string";
|
|
|
6
6
|
const subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
7
7
|
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
|
|
8
8
|
|
|
9
|
-
export function
|
|
10
|
-
const tokens =
|
|
9
|
+
export function subproofStringFromSubproofNode(subproofNode, fileContext) {
|
|
10
|
+
const tokens = fileContext.getTokens(),
|
|
11
11
|
subproofSuppositionStatementNodes = subproofSuppositionStatementNodesQuery(subproofNode),
|
|
12
12
|
subproofLastProofStepStatementNode = subproofLastProofStepStatementNodeQuery(subproofNode),
|
|
13
13
|
subproofSuppositionStatementsString = nodesAsString(subproofSuppositionStatementNodes, tokens),
|
package/src/utilities/tokens.js
CHANGED
|
@@ -4,10 +4,10 @@ import { lexersUtilities } from "occam-custom-grammars";
|
|
|
4
4
|
|
|
5
5
|
import { combinedCustomGrammarFromNothing } from "./customGrammar";
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const { nominalLexerFromCombinedCustomGrammar } = lexersUtilities;
|
|
8
8
|
|
|
9
9
|
const combinedCustomGrammar = combinedCustomGrammarFromNothing(),
|
|
10
|
-
|
|
10
|
+
nominalLexer = nominalLexerFromCombinedCustomGrammar(combinedCustomGrammar);
|
|
11
11
|
|
|
12
12
|
export function termTokensFromTermString(termString, lexer) {
|
|
13
13
|
const content = termString, ///
|
|
@@ -16,14 +16,14 @@ export function termTokensFromTermString(termString, lexer) {
|
|
|
16
16
|
return termTokens;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export function
|
|
20
|
-
const content =
|
|
21
|
-
|
|
19
|
+
export function unqualifiedStatementTokensFromUnqualifiedStatementString(unqualifiedStatementString, lexer) {
|
|
20
|
+
const content = unqualifiedStatementString, ///
|
|
21
|
+
unqualifiedStatementTokens = tokensFromContentAndLexer(content, lexer);
|
|
22
22
|
|
|
23
|
-
return
|
|
23
|
+
return unqualifiedStatementTokens;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function tokensFromContentAndLexer(content, lexer =
|
|
26
|
+
function tokensFromContentAndLexer(content, lexer = nominalLexer) {
|
|
27
27
|
const tokens = lexer.tokenise(content);
|
|
28
28
|
|
|
29
29
|
return tokens;
|
package/src/variable.js
CHANGED
|
@@ -46,16 +46,6 @@ export default class Variable {
|
|
|
46
46
|
return nodeAndTypeMatch;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
asString(tokens) {
|
|
50
|
-
const typeName = this.type.getName();
|
|
51
|
-
|
|
52
|
-
let string = nodeAsString(this.node, tokens);
|
|
53
|
-
|
|
54
|
-
string = `${string}:${typeName}`; ///
|
|
55
|
-
|
|
56
|
-
return string;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
49
|
static fromVariableNodeAndType(variableNode, type) {
|
|
60
50
|
const node = variableNode, ///
|
|
61
51
|
variable = new Variable(node, type);
|
|
@@ -25,8 +25,9 @@ class MetaLevelVerifier extends Verifier {
|
|
|
25
25
|
{
|
|
26
26
|
nodeQuery: statementNodeQuery,
|
|
27
27
|
verify: (statementNode, assignments, stated, localContext) => {
|
|
28
|
-
const {
|
|
29
|
-
|
|
28
|
+
const { Statement } = shim,
|
|
29
|
+
statement = Statement.fromStatementNode(statementNode, localContext),
|
|
30
|
+
statementVerified = statement.verify(assignments, stated, localContext);
|
|
30
31
|
|
|
31
32
|
return statementVerified;
|
|
32
33
|
}
|
package/src/verifier/topLevel.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import Rule from "../rule";
|
|
3
4
|
import Verifier from "../verifier";
|
|
4
5
|
import verifyError from "../verify/error";
|
|
5
|
-
import verifyRule from "../verify/rule";
|
|
6
6
|
import verifyAxiom from "../verify/axiom";
|
|
7
7
|
import verifyLemma from "../verify/lemma";
|
|
8
8
|
import verifyTheorem from "../verify/theorem";
|
|
9
9
|
import verifyMetaLemma from "../verify/metaLemma";
|
|
10
10
|
import verifyConjecture from "../verify/conjecture";
|
|
11
11
|
import verifyMetatheorem from "../verify/metatheorem";
|
|
12
|
+
import CombinatorDeclaration from "../declaration/combinator";
|
|
12
13
|
import verifyTypeDeclaration from "../verify/declaration/type";
|
|
13
14
|
import verifyVariableDeclaration from "../verify/declaration/variable";
|
|
14
|
-
import verifyCombinatorDeclaration from "../verify/declaration/combinator";
|
|
15
15
|
import verifyConstructorDeclaration from "../verify/declaration/constructor";
|
|
16
16
|
import verifyMetavariableDeclaration from "../verify/declaration/metavariable";
|
|
17
17
|
|
|
@@ -55,7 +55,8 @@ class TopLevelVerifier extends Verifier {
|
|
|
55
55
|
{
|
|
56
56
|
nodeQuery: ruleNodeQuery,
|
|
57
57
|
verify: (ruleNode, fileContext) => {
|
|
58
|
-
const
|
|
58
|
+
const rule = Rule.fromRuleNode(ruleNode, fileContext),
|
|
59
|
+
ruleVerified = rule.verify(fileContext);
|
|
59
60
|
|
|
60
61
|
return ruleVerified;
|
|
61
62
|
}
|
|
@@ -127,7 +128,8 @@ class TopLevelVerifier extends Verifier {
|
|
|
127
128
|
{
|
|
128
129
|
nodeQuery: combinatorDeclarationNodeQuery,
|
|
129
130
|
verify: (combinatorDeclarationNode, fileContext) => {
|
|
130
|
-
const
|
|
131
|
+
const combinatorDeclaration = CombinatorDeclaration.fromCombinatorDeclarationNode(combinatorDeclarationNode, fileContext),
|
|
132
|
+
combinatorDeclarationVerified = combinatorDeclaration.verify(fileContext);
|
|
131
133
|
|
|
132
134
|
return combinatorDeclarationVerified;
|
|
133
135
|
}
|
package/src/verify/axiom.js
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import Axiom from "../axiom";
|
|
4
4
|
import LocalContext from "../context/local";
|
|
5
|
-
import verifyLabels from "../verify/labels";
|
|
6
5
|
import Substitutions from "../substitutions";
|
|
7
6
|
import verifyConsequent from "../verify/consequent";
|
|
8
|
-
import verifySuppositions from "../verify/suppositions";
|
|
7
|
+
// import verifySuppositions from "../verify/suppositions";
|
|
9
8
|
|
|
10
9
|
import { first } from "../utilities/array";
|
|
11
10
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
package/src/verify/conjecture.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import Conjecture from "../conjecture";
|
|
4
|
-
import verifyProof from "../verify/proof";
|
|
5
|
-
import verifyLabels from "../verify/labels";
|
|
4
|
+
// import verifyProof from "../verify/proof";
|
|
6
5
|
import LocalContext from "../context/local";
|
|
7
6
|
import Substitutions from "../substitutions";
|
|
8
7
|
import verifyConsequent from "../verify/consequent";
|
|
9
|
-
import verifySuppositions from "../verify/suppositions";
|
|
8
|
+
// import verifySuppositions from "../verify/suppositions";
|
|
10
9
|
|
|
11
10
|
import { first } from "../utilities/array";
|
|
12
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
package/src/verify/consequent.js
CHANGED
|
@@ -2,25 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
import verifyStatementAsCombinator from "../../verify/statementAsCombinator";
|
|
4
4
|
|
|
5
|
-
import { nodeQuery } from "../../utilities/query";
|
|
6
|
-
|
|
7
|
-
const statementNodeQuery = nodeQuery("/combinatorDeclaration/statement");
|
|
8
|
-
|
|
9
5
|
export default function verifyCombinatorDeclaration(combinatorDeclarationNode, fileContext) {
|
|
10
|
-
let combinatorDeclarationVerified;
|
|
11
|
-
|
|
12
|
-
const statementNode = statementNodeQuery(combinatorDeclarationNode),
|
|
13
|
-
statementString = fileContext.nodeAsString(statementNode);
|
|
14
|
-
|
|
15
|
-
fileContext.trace(`Verifying the '${statementString}' combinator declaration...`, combinatorDeclarationNode);
|
|
16
|
-
|
|
17
|
-
const statementVerifiedAsCombinator = verifyStatementAsCombinator(statementNode, fileContext);
|
|
18
|
-
|
|
19
|
-
combinatorDeclarationVerified = statementVerifiedAsCombinator; ///
|
|
20
|
-
|
|
21
|
-
if (combinatorDeclarationVerified) {
|
|
22
|
-
fileContext.debug(`...verified the '${statementString}' combinator declaration.`, combinatorDeclarationNode);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return combinatorDeclarationVerified;
|
|
26
6
|
}
|
|
@@ -5,7 +5,6 @@ import MetavariableAssignment from "../../assignment/metavariable";
|
|
|
5
5
|
|
|
6
6
|
import { first } from "../../utilities/array";
|
|
7
7
|
import { nodeQuery } from "../../utilities/query";
|
|
8
|
-
import { metavariableNameFromMetavariableNode } from "../../utilities/name";
|
|
9
8
|
|
|
10
9
|
const termNodeQuery = nodeQuery("/argument/term"),
|
|
11
10
|
typeNodeQuery = nodeQuery("/argument/type"),
|
|
@@ -21,14 +20,14 @@ export default function verifyMetavariableDeclaration(metavariableDeclarationNod
|
|
|
21
20
|
metaTypeString = fileContext.nodeAsString(metaTypeNode),
|
|
22
21
|
metavariableString = fileContext.nodeAsString(metavariableNode);
|
|
23
22
|
|
|
24
|
-
fileContext.trace(`Verifying the '${metavariableString}:${metaTypeString}' metavariable declaration
|
|
23
|
+
fileContext.trace(`Verifying the '${metavariableString}:${metaTypeString}' metavariable declaration...`);
|
|
25
24
|
|
|
26
25
|
const metavariableVVerified = verifyMetavariable(metavariableNode, metaTypeNode, fileContext);
|
|
27
26
|
|
|
28
27
|
metavariableDeclarationVerified = metavariableVVerified; ///
|
|
29
28
|
|
|
30
29
|
if (metavariableDeclarationVerified) {
|
|
31
|
-
fileContext.debug(`...verified the '${metavariableString}:${metaTypeString}' metavariable declaration
|
|
30
|
+
fileContext.debug(`...verified the '${metavariableString}:${metaTypeString}' metavariable declaration.`);
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
return metavariableDeclarationVerified;
|
|
@@ -39,12 +38,12 @@ function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
|
|
|
39
38
|
|
|
40
39
|
const metavariableString = fileContext.nodeAsString(metavariableNode);
|
|
41
40
|
|
|
42
|
-
fileContext.trace(`Verifying the '${metavariableString}' metavariable
|
|
41
|
+
fileContext.trace(`Verifying the '${metavariableString}' metavariable...`);
|
|
43
42
|
|
|
44
43
|
const metavariablePresent = fileContext.isMetavariablePresentByMetavariableNode(metavariableNode);
|
|
45
44
|
|
|
46
45
|
if (metavariablePresent) {
|
|
47
|
-
fileContext.debug(`The metavariable '${metavariableString}' is already present
|
|
46
|
+
fileContext.debug(`The metavariable '${metavariableString}' is already present.`);
|
|
48
47
|
} else {
|
|
49
48
|
const termTypes = [],
|
|
50
49
|
metaTypes = [],
|
|
@@ -70,10 +69,7 @@ function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
|
|
|
70
69
|
termType = firstTermType; ///
|
|
71
70
|
}
|
|
72
71
|
|
|
73
|
-
const
|
|
74
|
-
node = metavariableNode, ///
|
|
75
|
-
name = metavariableName, ///
|
|
76
|
-
metavariable = Metavariable.fromNodeNameTermTypeAndMetaType(node, name, termType, metaType),
|
|
72
|
+
const metavariable = Metavariable.fromMetavariableNodeNameTermTypeAndMetaType(metavariableNode, termType, metaType, fileContext),
|
|
77
73
|
metavariableAssignment = MetavariableAssignment.fromMetavariable(metavariable),
|
|
78
74
|
metavariableAssigned = metavariableAssignment.assign(fileContext);
|
|
79
75
|
|
|
@@ -84,7 +80,7 @@ function verifyMetavariable(metavariableNode, metaTypeNode, fileContext) {
|
|
|
84
80
|
}
|
|
85
81
|
|
|
86
82
|
if (metavariableVerified) {
|
|
87
|
-
fileContext.debug(`...verified the '${metavariableString}' metavariable
|
|
83
|
+
fileContext.debug(`...verified the '${metavariableString}' metavariable.`);
|
|
88
84
|
}
|
|
89
85
|
|
|
90
86
|
return metavariableVerified;
|
|
@@ -103,7 +99,7 @@ function verifyArgument(argumentNode, termTypes, fileContext) {
|
|
|
103
99
|
} else {
|
|
104
100
|
const termString = fileContext.nodeAsString(termNode);
|
|
105
101
|
|
|
106
|
-
fileContext.debug(`The '${termString}' term was found when a type should have been present
|
|
102
|
+
fileContext.debug(`The '${termString}' term was found when a type should have been present.`);
|
|
107
103
|
}
|
|
108
104
|
const typeNode = typeNodeQuery(argumentNode);
|
|
109
105
|
|
|
@@ -119,7 +115,7 @@ function verifyArgument(argumentNode, termTypes, fileContext) {
|
|
|
119
115
|
} else {
|
|
120
116
|
const typeString = fileContext.nodeAsString(typeNode);
|
|
121
117
|
|
|
122
|
-
fileContext.debug(`The '${typeString}' type is not present
|
|
118
|
+
fileContext.debug(`The '${typeString}' type is not present.`);
|
|
123
119
|
}
|
|
124
120
|
}
|
|
125
121
|
}
|
package/src/verify/files.js
CHANGED
|
@@ -6,7 +6,7 @@ import { filePathUtilities } from "occam-entities";
|
|
|
6
6
|
|
|
7
7
|
import { filter, leftDifference } from "../utilities/array";
|
|
8
8
|
|
|
9
|
-
const {
|
|
9
|
+
const { isFilePathNominalFilePath } = filePathUtilities;
|
|
10
10
|
|
|
11
11
|
export default function verifyFiles(releaseContext) {
|
|
12
12
|
let filesVerified = false;
|
|
@@ -14,9 +14,9 @@ export default function verifyFiles(releaseContext) {
|
|
|
14
14
|
const filePaths = releaseContext.getFilePaths();
|
|
15
15
|
|
|
16
16
|
filter(filePaths, (filePath) => {
|
|
17
|
-
const
|
|
17
|
+
const filePathNominalFilePath = isFilePathNominalFilePath(filePath);
|
|
18
18
|
|
|
19
|
-
if (
|
|
19
|
+
if (filePathNominalFilePath) {
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
22
|
})
|