occam-verify-cli 0.0.1003 → 0.0.1006
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/bin/utilities/releaseContext.js +9 -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 +74 -14
- package/lib/context/file.js +191 -31
- package/lib/context/local.js +37 -49
- package/lib/context/release.js +25 -81
- 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 -55
- 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 -61
- 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 +5 -6
- 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 +1 -1
- package/src/assertion/subproof.js +84 -0
- package/src/assignment/metavariable.js +2 -2
- package/src/combinator.js +45 -15
- package/src/conclusion.js +85 -13
- package/src/context/file.js +223 -11
- package/src/context/local.js +12 -16
- package/src/context/release.js +31 -100
- 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 +138 -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 +96 -51
- 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 +5 -8
- 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/premise.js
CHANGED
|
@@ -1,73 +1,167 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import ProofStep from "./proofStep";
|
|
4
|
+
import LocalContext from "./context/local";
|
|
3
5
|
import metaLevelUnifier from "./unifier/metaLevel";
|
|
6
|
+
import SubproofAssertion from "./assertion/subproof";
|
|
7
|
+
import UnqualifiedStatement from "./statement/unqualified";
|
|
4
8
|
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
9
|
+
import { trim } from "./utilities/string";
|
|
10
|
+
import { nodeQuery } from "./utilities/query";
|
|
11
|
+
import { assignAssignments } from "./utilities/assignments";
|
|
8
12
|
|
|
9
|
-
const
|
|
10
|
-
subproofAssertionStatementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
11
|
-
subproofSuppositionStatementNodesQuery = nodesQuery("/subproof/supposition/unqualifiedStatement/statement!"),
|
|
12
|
-
subproofLastProofStepStatementNodeQuery = nodeQuery("/subproof/subDerivation/lastProofStep/unqualifiedStatement|qualifiedStatement/statement!");
|
|
13
|
+
const unqualifiedStatementNodeQuery = nodeQuery("/premise/unqualifiedStatement");
|
|
13
14
|
|
|
14
15
|
export default class Premise {
|
|
15
|
-
constructor(
|
|
16
|
-
this.
|
|
16
|
+
constructor(fileContext, unqualifiedStatement) {
|
|
17
|
+
this.fileContext = fileContext;
|
|
18
|
+
this.unqualifiedStatement = unqualifiedStatement;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
return this.
|
|
21
|
+
getFileContext() {
|
|
22
|
+
return this.fileContext;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
getUnqualifiedStatement() {
|
|
26
|
+
return this.unqualifiedStatement;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
getString() { return this.unqualifiedStatement.getString(); }
|
|
30
|
+
|
|
31
|
+
getStatement() { return this.unqualifiedStatement.getStatement(); }
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
nodeB = statementNodeB, ///
|
|
29
|
-
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
33
|
+
unifyProofStep(proofStep, substitutions, localContext) {
|
|
34
|
+
let proofStepUnified = false;
|
|
30
35
|
|
|
31
|
-
|
|
36
|
+
const subproof = proofStep.getSubproof(),
|
|
37
|
+
statement = proofStep.getStatement();
|
|
38
|
+
|
|
39
|
+
substitutions.snapshot();
|
|
40
|
+
|
|
41
|
+
if (false) {
|
|
42
|
+
///
|
|
43
|
+
} else if (subproof !== null) {
|
|
44
|
+
proofStepUnified = this.unifySubproof(subproof, substitutions, localContext);
|
|
45
|
+
} else if (statement !== null) {
|
|
46
|
+
proofStepUnified = this.unifyStatement(statement, substitutions, localContext);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
proofStepUnified ?
|
|
50
|
+
substitutions.continue() :
|
|
51
|
+
substitutions.rollback(localContext);
|
|
52
|
+
|
|
53
|
+
return proofStepUnified;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
unifyStatement(statement, substitutions, localContext) {
|
|
57
|
+
let statementUnified;
|
|
58
|
+
|
|
59
|
+
const premise = this, ///
|
|
60
|
+
statementString = statement.getString(),
|
|
61
|
+
premiseStatement = premise.getStatement(),
|
|
62
|
+
premiseStatementString = premiseStatement.getString();
|
|
63
|
+
|
|
64
|
+
localContext.trace(`Unifying the '${statementString}' statement with the premise's '${premiseStatementString}' statement...`);
|
|
65
|
+
|
|
66
|
+
const statementNode = statement.getNode(),
|
|
67
|
+
premiseStatementNode = premiseStatement.getNode(),
|
|
68
|
+
nodeA = premiseStatementNode, ///
|
|
69
|
+
nodeB = statementNode, ///
|
|
70
|
+
fileContextA = this.fileContext, ///
|
|
71
|
+
localContextA = LocalContext.fromFileContext(fileContextA),
|
|
72
|
+
localContextB = localContext, ///
|
|
73
|
+
unified = metaLevelUnifier.unify(nodeA, nodeB, substitutions, localContextA, localContextB);
|
|
74
|
+
|
|
75
|
+
statementUnified = unified; ///
|
|
76
|
+
|
|
77
|
+
if (statementUnified) {
|
|
78
|
+
localContext.debug(`...unified the '${statementString}' statement with the premise's '${premiseStatementString}' statement.`);
|
|
32
79
|
}
|
|
33
80
|
|
|
34
81
|
return statementUnified;
|
|
35
82
|
}
|
|
36
83
|
|
|
37
|
-
unifySubproof(
|
|
84
|
+
unifySubproof(subproof, substitutions, localContext) {
|
|
38
85
|
let subproofUnified = false;
|
|
39
86
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (unified) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
87
|
+
const premise = this, ///
|
|
88
|
+
subproofString = subproof.getString(),
|
|
89
|
+
premiseStatement = premise.getStatement(),
|
|
90
|
+
premiseStatementString = premiseStatement.getString();
|
|
91
|
+
|
|
92
|
+
localContext.trace(`Unifying the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement...`);
|
|
93
|
+
|
|
94
|
+
const statement = this.unqualifiedStatement.getStatement(),
|
|
95
|
+
statementNode = statement.getNode(),
|
|
96
|
+
subproofAssertion = SubproofAssertion.fromStatementNode(statementNode, this.fileContext);
|
|
97
|
+
|
|
98
|
+
if (subproofAssertion !== null) {
|
|
99
|
+
subproofUnified = subproofAssertion.unifySubproof(subproof, substitutions, localContext);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (subproofUnified) {
|
|
103
|
+
localContext.debug(`...unified the '${subproofString}' subproof with the premise's '${premiseStatementString}' statement.`);
|
|
63
104
|
}
|
|
64
105
|
|
|
65
106
|
return subproofUnified;
|
|
66
107
|
}
|
|
67
108
|
|
|
68
|
-
|
|
69
|
-
|
|
109
|
+
verify(localContext) {
|
|
110
|
+
let verified = false,
|
|
111
|
+
premiseString = this.getString(); ///
|
|
112
|
+
|
|
113
|
+
premiseString = trim(premiseString); ///
|
|
114
|
+
|
|
115
|
+
if (this.unqualifiedStatement !== null) {
|
|
116
|
+
localContext.trace(`Verifying the '${premiseString}' premise...`);
|
|
117
|
+
|
|
118
|
+
const stated = true,
|
|
119
|
+
assignments = [],
|
|
120
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(assignments, stated, localContext);
|
|
121
|
+
|
|
122
|
+
if (unqualifiedStatementVerified) {
|
|
123
|
+
const assignmentsAssigned = assignAssignments(assignments, localContext);
|
|
124
|
+
|
|
125
|
+
if (assignmentsAssigned) {
|
|
126
|
+
const proofStep = ProofStep.fromUnqualifiedStatement(this.unqualifiedStatement);
|
|
127
|
+
|
|
128
|
+
localContext.addProofStep(proofStep);
|
|
129
|
+
|
|
130
|
+
verified = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (verified) {
|
|
135
|
+
localContext.debug(`...verified the '${premiseString}' premise.`);
|
|
136
|
+
}
|
|
137
|
+
} else {
|
|
138
|
+
localContext.debug(`The '${premiseString}' premise cannot be verified because it is nonsense.`);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return verified;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
toJSON() {
|
|
145
|
+
const unqualifiedStatementString = this.unqualifiedStatement.getString(),
|
|
146
|
+
unqualifiedStatement = unqualifiedStatementString, ///
|
|
147
|
+
json = {
|
|
148
|
+
unqualifiedStatement
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return json;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static fromJSON(json, fileContext) {
|
|
155
|
+
let premise = null;
|
|
70
156
|
|
|
71
157
|
return premise;
|
|
72
158
|
}
|
|
159
|
+
|
|
160
|
+
static fromPremiseNode(premiseNode, fileContext) {
|
|
161
|
+
const unqualifiedStatementNode = unqualifiedStatementNodeQuery(premiseNode),
|
|
162
|
+
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
163
|
+
premise = new Premise(fileContext, unqualifiedStatement);
|
|
164
|
+
|
|
165
|
+
return premise
|
|
166
|
+
}
|
|
73
167
|
}
|
package/src/proof.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Derivation from "./derivation";
|
|
4
|
+
import LocalContext from "./context/local";
|
|
5
|
+
|
|
6
|
+
import { nodeQuery } from "./utilities/query";
|
|
7
|
+
|
|
8
|
+
const derivationNodeQuery = nodeQuery("/proof/derivation");
|
|
9
|
+
|
|
10
|
+
export default class Proof {
|
|
11
|
+
constructor(derivation) {
|
|
12
|
+
this.derivation = derivation;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
getDerivation() {
|
|
16
|
+
return this.derivation;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
getLastProofStep() { return this.derivation.getLastProofStep(); }
|
|
20
|
+
|
|
21
|
+
verify(substitutions, conclusion, localContext) {
|
|
22
|
+
let verified = false;
|
|
23
|
+
|
|
24
|
+
localContext = LocalContext.fromLocalContext(localContext); ///
|
|
25
|
+
|
|
26
|
+
const derivationVerified = this.derivation.verify(substitutions, localContext);
|
|
27
|
+
|
|
28
|
+
if (derivationVerified) {
|
|
29
|
+
const lastProofStep = localContext.getLastProofStep();
|
|
30
|
+
|
|
31
|
+
if (lastProofStep !== null) {
|
|
32
|
+
const lastProofStep = this.getLastProofStep(),
|
|
33
|
+
conclusionStatement = conclusion.getStatement(),
|
|
34
|
+
lastProofStepStatement = lastProofStep.getStatement(),
|
|
35
|
+
conclusionStatementEqualToLastProofStepStatement = conclusionStatement.isEqualTo(lastProofStepStatement);
|
|
36
|
+
|
|
37
|
+
if (conclusionStatementEqualToLastProofStepStatement) {
|
|
38
|
+
verified = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return verified;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromProofNode(proofNode, fileContext) {
|
|
47
|
+
let proof = null;
|
|
48
|
+
|
|
49
|
+
if (proofNode !== null) {
|
|
50
|
+
const derivationNode = derivationNodeQuery(proofNode),
|
|
51
|
+
derivation = Derivation.fromDerivationNode(derivationNode, fileContext);
|
|
52
|
+
|
|
53
|
+
proof = new Proof(derivation);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return proof;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/proofStep.js
CHANGED
|
@@ -1,45 +1,115 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import shim from "./shim";
|
|
4
|
+
import Subproof from "./subproof";
|
|
5
|
+
import QualifiedStatement from "./statement/qualified";
|
|
6
|
+
import UnqualifiedStatement from "./statement/unqualified";
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
import { nodeQuery } from "./utilities/query";
|
|
9
|
+
|
|
10
|
+
const subproofNodeQuery = nodeQuery("/proofStep|lastProofStep/subproof"),
|
|
11
|
+
qualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/qualifiedStatement"),
|
|
12
|
+
unqualifiedStatementNodeQuery = nodeQuery("/proofStep|lastProofStep/unqualifiedStatement");
|
|
13
|
+
|
|
14
|
+
class ProofStep {
|
|
15
|
+
constructor(subproof, qualifiedStatement, unqualifiedStatement) {
|
|
16
|
+
this.subproof = subproof;
|
|
17
|
+
this.qualifiedStatement = qualifiedStatement;
|
|
18
|
+
this.unqualifiedStatement = unqualifiedStatement;
|
|
9
19
|
}
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
return this.
|
|
21
|
+
getSubproof() {
|
|
22
|
+
return this.subproof;
|
|
13
23
|
}
|
|
14
24
|
|
|
15
|
-
|
|
16
|
-
return this.
|
|
25
|
+
getQualifiedStatement() {
|
|
26
|
+
return this.qualifiedStatement;
|
|
17
27
|
}
|
|
18
28
|
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
getUnqualifiedStatement() {
|
|
30
|
+
return this.unqualifiedStatement;
|
|
31
|
+
}
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
getStatement() {
|
|
34
|
+
let statement = null;
|
|
35
|
+
|
|
36
|
+
if (this.qualifiedStatement !== null) {
|
|
37
|
+
statement = this.qualifiedStatement.getStatement();
|
|
38
|
+
}
|
|
25
39
|
|
|
26
|
-
|
|
40
|
+
if (this.unqualifiedStatement !== null) {
|
|
41
|
+
statement = this.unqualifiedStatement.getStatement();
|
|
27
42
|
}
|
|
28
43
|
|
|
29
|
-
return
|
|
44
|
+
return statement;
|
|
30
45
|
}
|
|
31
46
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
// unifyStatement(statementB, equivalences, localContextA, localContextB) {
|
|
48
|
+
// let statementUnified = false;
|
|
49
|
+
//
|
|
50
|
+
// if (this.statement !== null) {
|
|
51
|
+
// const statementA = this.statement, ///
|
|
52
|
+
// statementUnifiedWithStatement = unifyStatementWithStatementGivenEquivalences(statementA, statementB, equivalences, localContextA, localContextB);
|
|
53
|
+
//
|
|
54
|
+
// statementUnified = statementUnifiedWithStatement; ///
|
|
55
|
+
// }
|
|
56
|
+
//
|
|
57
|
+
// return statementUnified;
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
verify(substitutions, localContext) {
|
|
61
|
+
let verified = false;
|
|
62
|
+
|
|
63
|
+
if (false) {
|
|
64
|
+
///
|
|
65
|
+
} else if (this.subproof !== null) {
|
|
66
|
+
const subproofVerified = this.subproof.verify(substitutions, localContext);
|
|
67
|
+
|
|
68
|
+
verified = subproofVerified; ///
|
|
69
|
+
} else if (this.qualifiedStatement !== null) {
|
|
70
|
+
const qualifiedStatementVerified = this.qualifiedStatement.verify(substitutions, localContext);
|
|
71
|
+
|
|
72
|
+
verified = qualifiedStatementVerified; ///
|
|
73
|
+
} else if (this.unqualifiedStatement !== null) {
|
|
74
|
+
const stated = true,
|
|
75
|
+
assignments = [],
|
|
76
|
+
unqualifiedStatementVerified = this.unqualifiedStatement.verify(stated, assignments, localContext);
|
|
77
|
+
|
|
78
|
+
verified = unqualifiedStatementVerified; ///
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (verified) {
|
|
82
|
+
const proofStep = this; ///
|
|
83
|
+
|
|
84
|
+
localContext.addProofStep(proofStep);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return verified;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static fromProofStepNode(proofStepNode, fileContext) {
|
|
91
|
+
const subproofNode = subproofNodeQuery(proofStepNode),
|
|
92
|
+
qualifiedStatementNode = qualifiedStatementNodeQuery(proofStepNode),
|
|
93
|
+
unqualifiedStatementNode = unqualifiedStatementNodeQuery(proofStepNode),
|
|
94
|
+
subproof = Subproof.fromSubproofNode(subproofNode, fileContext),
|
|
95
|
+
qualifiedStatement = QualifiedStatement.fromQualifiedStatementNode(qualifiedStatementNode, fileContext),
|
|
96
|
+
unqualifiedStatement = UnqualifiedStatement.fromUnqualifiedStatementNode(unqualifiedStatementNode, fileContext),
|
|
97
|
+
proofStep = new ProofStep(subproof, qualifiedStatement, unqualifiedStatement);
|
|
35
98
|
|
|
36
99
|
return proofStep;
|
|
37
100
|
}
|
|
38
101
|
|
|
39
|
-
static
|
|
40
|
-
const
|
|
41
|
-
|
|
102
|
+
static fromUnqualifiedStatement(unqualifiedStatement) {
|
|
103
|
+
const subproof = null,
|
|
104
|
+
qualifiedStatement = null,
|
|
105
|
+
proofStep = new ProofStep(subproof, qualifiedStatement, unqualifiedStatement);
|
|
42
106
|
|
|
43
107
|
return proofStep;
|
|
44
108
|
}
|
|
45
109
|
}
|
|
110
|
+
|
|
111
|
+
Object.assign(shim, {
|
|
112
|
+
ProofStep
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export default ProofStep;
|
package/src/reference.js
CHANGED
|
@@ -1,30 +1,76 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import Metavariable from "./metavariable";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "./utilities/query";
|
|
6
|
+
|
|
7
|
+
const metavariableNodeQuery = nodeQuery("//reference/metavariable");
|
|
4
8
|
|
|
5
9
|
export default class Reference {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
10
|
+
constructor(metavariable) {
|
|
11
|
+
this.metavariable = metavariable;
|
|
8
12
|
}
|
|
9
13
|
|
|
14
|
+
getMetavariable() {
|
|
15
|
+
return this.metavariable;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getString() { return this.metavariable.getString(); }
|
|
19
|
+
|
|
20
|
+
matchMetavariableNode(metavariableNode) { return this.metavariable.matchMetavariableNode(metavariableNode); }
|
|
21
|
+
|
|
10
22
|
getMetavariableNode() {
|
|
11
|
-
|
|
23
|
+
const metavariableNode = this.metavariable.getNode();
|
|
24
|
+
|
|
25
|
+
return metavariableNode;
|
|
12
26
|
}
|
|
13
27
|
|
|
14
|
-
|
|
15
|
-
|
|
28
|
+
verify(fileContext) {
|
|
29
|
+
let verified;
|
|
30
|
+
|
|
31
|
+
const referenceString = this.getString(); ///
|
|
32
|
+
|
|
33
|
+
fileContext.trace(`Verifying the '${referenceString}' reference...`);
|
|
34
|
+
|
|
35
|
+
verified = true;
|
|
16
36
|
|
|
17
|
-
|
|
37
|
+
if (verified) {
|
|
38
|
+
fileContext.debug(`...verified the '${referenceString}' reference.`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return verified;
|
|
18
42
|
}
|
|
19
43
|
|
|
20
|
-
|
|
21
|
-
const
|
|
44
|
+
toJSON() {
|
|
45
|
+
const metavariableJSON = this.metavariable.toJSON(),
|
|
46
|
+
metavariable = metavariableJSON, ///
|
|
47
|
+
string = this.string,
|
|
48
|
+
json = {
|
|
49
|
+
string,
|
|
50
|
+
metavariable
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return json;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static fromJSON(json, fileContext) {
|
|
57
|
+
const { string } = json;
|
|
58
|
+
|
|
59
|
+
let { metavariable } = json;
|
|
22
60
|
|
|
23
|
-
|
|
61
|
+
json = metavariable; ///
|
|
62
|
+
|
|
63
|
+
metavariable = Metavariable.fromJSON(json, fileContext);
|
|
64
|
+
|
|
65
|
+
const reference = new Reference(string, metavariable);
|
|
66
|
+
|
|
67
|
+
return reference;
|
|
24
68
|
}
|
|
25
69
|
|
|
26
|
-
static
|
|
27
|
-
const
|
|
70
|
+
static fromReferenceNode(referenceNode, fileContext) {
|
|
71
|
+
const metavariableNode = metavariableNodeQuery(referenceNode),
|
|
72
|
+
metavariable = Metavariable.fromMetavariableNode(metavariableNode, fileContext),
|
|
73
|
+
reference = new Reference(metavariable);
|
|
28
74
|
|
|
29
75
|
return reference;
|
|
30
76
|
}
|