occam-verify-cli 0.0.502 → 0.0.504
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/axiom.js +4 -4
- package/lib/axiomLemmaTheorem.js +58 -58
- package/lib/consequence.js +157 -0
- package/lib/lemma.js +4 -4
- package/lib/metaSupposition.js +214 -0
- package/lib/supposition.js +214 -0
- package/lib/theorem.js +4 -4
- package/lib/verify/axiom.js +11 -11
- package/lib/verify/consequence.js +35 -0
- package/lib/verify/derivation.js +7 -7
- package/lib/verify/lemma.js +12 -12
- package/lib/verify/metaDerivation.js +7 -7
- package/lib/verify/metaSupposition.js +41 -0
- package/lib/verify/supposition.js +41 -0
- package/lib/verify/theorem.js +12 -12
- package/package.json +3 -3
- package/src/axiom.js +1 -1
- package/src/axiomLemmaTheorem.js +57 -57
- package/src/consequence.js +187 -0
- package/src/lemma.js +1 -1
- package/src/metaSupposition.js +235 -0
- package/src/supposition.js +235 -0
- package/src/theorem.js +1 -1
- package/src/verify/axiom.js +17 -17
- package/src/verify/consequence.js +34 -0
- package/src/verify/derivation.js +8 -8
- package/src/verify/lemma.js +18 -18
- package/src/verify/metaDerivation.js +8 -8
- package/src/verify/metaSupposition.js +44 -0
- package/src/verify/supposition.js +44 -0
- package/src/verify/theorem.js +18 -18
- package/lib/antecedent.js +0 -214
- package/lib/consequent.js +0 -157
- package/lib/metaAntecedent.js +0 -214
- package/lib/verify/antecedent.js +0 -41
- package/lib/verify/consequent.js +0 -35
- package/lib/verify/metaAntecedent.js +0 -41
- package/src/antecedent.js +0 -235
- package/src/consequent.js +0 -187
- package/src/metaAntecedent.js +0 -235
- package/src/verify/antecedent.js +0 -44
- package/src/verify/consequent.js +0 -34
- package/src/verify/metaAntecedent.js +0 -44
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Substitution from "./substitution";
|
|
4
|
+
|
|
5
|
+
import { first } from "./utilities/array";
|
|
6
|
+
import { nodeAsString } from "./utilities/string";
|
|
7
|
+
import { nodeQuery, nodesQuery } from "./utilities/query";
|
|
8
|
+
import { variableNameFromVariableNode } from "./utilities/query";
|
|
9
|
+
import { statementNodeFromStatementString } from "./utilities/string";
|
|
10
|
+
import { VARIABLE_RULE_NAME, STATEMENT_RULE_NAME } from "./ruleNames";
|
|
11
|
+
|
|
12
|
+
const statementNodesQuery = nodesQuery("/subproofAssertion/statement"),
|
|
13
|
+
subproofAssertionNodeQuery = nodeQuery("/statement/subproofAssertion!"),
|
|
14
|
+
unqualifiedStatementStatementNodesQuery = nodesQuery("/subproof/unqualifiedStatement/statement!"),
|
|
15
|
+
qualifiedOrUnqualifiedStatementStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!");
|
|
16
|
+
|
|
17
|
+
export default class Supposition {
|
|
18
|
+
constructor(statementNode) {
|
|
19
|
+
this.statementNode = statementNode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
getStatementNode() {
|
|
23
|
+
return this.statementNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
matchSubproofNode(subproofNode, substitutions) {
|
|
27
|
+
let subproofNodeMatches = false;
|
|
28
|
+
|
|
29
|
+
const subproofAssertionNode = subproofAssertionNodeQuery(this.statementNode);
|
|
30
|
+
|
|
31
|
+
if (subproofAssertionNode !== null) {
|
|
32
|
+
const subproofAssertionStatementNodes = statementNodesQuery(subproofAssertionNode),
|
|
33
|
+
unqualifiedStatementStatementNodes = unqualifiedStatementStatementNodesQuery(subproofNode),
|
|
34
|
+
qualifiedOrUnqualifiedStatementStatementNode = qualifiedOrUnqualifiedStatementStatementNodeQuery(subproofNode),
|
|
35
|
+
statementNodes = [
|
|
36
|
+
...unqualifiedStatementStatementNodes,
|
|
37
|
+
qualifiedOrUnqualifiedStatementStatementNode
|
|
38
|
+
],
|
|
39
|
+
statementNodesLength = statementNodes.length,
|
|
40
|
+
subproofAssertionStatementNodesLength = subproofAssertionStatementNodes.length;
|
|
41
|
+
|
|
42
|
+
if (statementNodesLength === subproofAssertionStatementNodesLength) {
|
|
43
|
+
subproofNodeMatches = subproofAssertionStatementNodes.every((subproofAssertionStatementNode, index) => {
|
|
44
|
+
const statementNode = statementNodes[index],
|
|
45
|
+
nonTerminalNode = statementNode, ///
|
|
46
|
+
suppositionNonTerminalNode = subproofAssertionStatementNode, ///
|
|
47
|
+
suppositionNonTerminalNodeMatches = matchSuppositionNonTerminalNode(suppositionNonTerminalNode, nonTerminalNode, substitutions);
|
|
48
|
+
|
|
49
|
+
if (suppositionNonTerminalNodeMatches) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return subproofNodeMatches;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
matchStatementNode(statementNode, substitutions) {
|
|
60
|
+
const nonTerminalNode = statementNode, ///
|
|
61
|
+
suppositionNonTerminalNode = this.statementNode, ///
|
|
62
|
+
suppositionNonTerminalNodeMatches = matchSuppositionNonTerminalNode(suppositionNonTerminalNode, nonTerminalNode, substitutions),
|
|
63
|
+
statementNodeMatches = suppositionNonTerminalNodeMatches; ///
|
|
64
|
+
|
|
65
|
+
return statementNodeMatches;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
toJSON() {
|
|
69
|
+
const statementString = nodeAsString(this.statementNode),
|
|
70
|
+
statement = statementString, ///
|
|
71
|
+
json = {
|
|
72
|
+
statement
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return json;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static fromJSON(json, releaseContext) {
|
|
79
|
+
const { statement } = json,
|
|
80
|
+
statementString = statement, ///
|
|
81
|
+
statementNode = statementNodeFromStatementString(statementString, releaseContext),
|
|
82
|
+
supposition = new Supposition(statementNode);
|
|
83
|
+
|
|
84
|
+
return supposition;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static fromStatementNode(statementNode) {
|
|
88
|
+
const supposition = new Supposition(statementNode);
|
|
89
|
+
|
|
90
|
+
return supposition;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function matchSuppositionNode(suppositionNode, node, substitutions) {
|
|
95
|
+
let suppositionNodeMatches = false;
|
|
96
|
+
|
|
97
|
+
const nodeTerminalNode = node.isTerminalNode(),
|
|
98
|
+
ruleNodeTerminalNode = suppositionNode.isTerminalNode();
|
|
99
|
+
|
|
100
|
+
if (nodeTerminalNode === ruleNodeTerminalNode) {
|
|
101
|
+
if (nodeTerminalNode) {
|
|
102
|
+
const terminalNode = node, ///
|
|
103
|
+
suppositionTerminalNode = suppositionNode, ///
|
|
104
|
+
suppositionTerminalNodeMatches = matchSuppositionTerminalNode(suppositionTerminalNode, terminalNode, substitutions);
|
|
105
|
+
|
|
106
|
+
suppositionNodeMatches = suppositionTerminalNodeMatches; ///
|
|
107
|
+
} else {
|
|
108
|
+
const nonTerminalNode = node, ///
|
|
109
|
+
suppositionNonTerminalNode = suppositionNode, ///
|
|
110
|
+
suppositionNonTerminalNodeMatches = matchSuppositionNonTerminalNode(suppositionNonTerminalNode, nonTerminalNode, substitutions);
|
|
111
|
+
|
|
112
|
+
suppositionNodeMatches = suppositionNonTerminalNodeMatches; ///
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return suppositionNodeMatches;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function matchSuppositionNodes(suppositionNodes, nodes, substitutions) {
|
|
120
|
+
let suppositionNodesMatches = false;
|
|
121
|
+
|
|
122
|
+
const nodesLength = nodes.length,
|
|
123
|
+
suppositionNodesLength = suppositionNodes.length;
|
|
124
|
+
|
|
125
|
+
if (nodesLength === suppositionNodesLength) {
|
|
126
|
+
suppositionNodesMatches = nodes.every((node, index) => {
|
|
127
|
+
const suppositionNode = suppositionNodes[index],
|
|
128
|
+
suppositionNodeMatches = matchSuppositionNode(suppositionNode, node, substitutions);
|
|
129
|
+
|
|
130
|
+
if (suppositionNodeMatches) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return suppositionNodesMatches;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function matchSuppositionVariable(suppositionVariableNode, nodes, substitutions) {
|
|
140
|
+
let suppositionVariableMatches;
|
|
141
|
+
|
|
142
|
+
const suppositionVariableName = variableNameFromVariableNode(suppositionVariableNode),
|
|
143
|
+
substitution = substitutions.find((substitution) => {
|
|
144
|
+
const variableName = substitution.getVariableName();
|
|
145
|
+
|
|
146
|
+
if (variableName === suppositionVariableName) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}) || null;
|
|
150
|
+
|
|
151
|
+
if (substitution !== null) {
|
|
152
|
+
const substitutionNodesMatch = substitution.matchNodes(nodes);
|
|
153
|
+
|
|
154
|
+
suppositionVariableMatches = substitutionNodesMatch; ///
|
|
155
|
+
} else {
|
|
156
|
+
const variableName = suppositionVariableName, ///
|
|
157
|
+
substitution = Substitution.fromVariableNameAndNodes(variableName, nodes);
|
|
158
|
+
|
|
159
|
+
substitutions.push(substitution);
|
|
160
|
+
|
|
161
|
+
suppositionVariableMatches = true;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return suppositionVariableMatches;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function matchSuppositionTerminalNode(suppositionTerminalNode, terminalNode, substitutions) {
|
|
168
|
+
const matches = suppositionTerminalNode.match(terminalNode),
|
|
169
|
+
suppositionTerminalNodeMatches = matches;
|
|
170
|
+
|
|
171
|
+
return suppositionTerminalNodeMatches;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function matchSuppositionNonTerminalNode(suppositionNonTerminalNode, nonTerminalNode, substitutions) {
|
|
175
|
+
let suppositionNonTerminalNodeMatches = false;
|
|
176
|
+
|
|
177
|
+
const ruleName = nonTerminalNode.getRuleName(),
|
|
178
|
+
suppositionRuleName = suppositionNonTerminalNode.getRuleName(); ///
|
|
179
|
+
|
|
180
|
+
if (ruleName === suppositionRuleName) {
|
|
181
|
+
const childNodes = nonTerminalNode.getChildNodes(),
|
|
182
|
+
suppositionChildNodes = suppositionNonTerminalNode.getChildNodes(),
|
|
183
|
+
nodes = childNodes, ///
|
|
184
|
+
suppositionNodes = suppositionChildNodes, ///
|
|
185
|
+
suppositionChildNodesMatches = matchSuppositionNodes(suppositionNodes, nodes, substitutions);
|
|
186
|
+
|
|
187
|
+
suppositionNonTerminalNodeMatches = suppositionChildNodesMatches; ///
|
|
188
|
+
|
|
189
|
+
if (!suppositionNonTerminalNodeMatches) {
|
|
190
|
+
const ruleNameStatementRuleName = (ruleName === STATEMENT_RULE_NAME);
|
|
191
|
+
|
|
192
|
+
if (ruleNameStatementRuleName) {
|
|
193
|
+
const statementNode = nonTerminalNode, ///
|
|
194
|
+
suppositionStatementNode = suppositionNonTerminalNode, ///
|
|
195
|
+
suppositionStatementNodeMatches = matchSuppositionStatementNode(suppositionStatementNode, statementNode, substitutions);
|
|
196
|
+
|
|
197
|
+
suppositionNonTerminalNodeMatches = suppositionStatementNodeMatches; ///
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return suppositionNonTerminalNodeMatches;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function matchSuppositionStatementNode(suppositionStatementNode, statementNode, substitutions) {
|
|
206
|
+
let suppositionStatementNodeMatches = false;
|
|
207
|
+
|
|
208
|
+
const suppositionNonTerminalNode = suppositionStatementNode, ///
|
|
209
|
+
suppositionChildNodes = suppositionNonTerminalNode.getChildNodes(),
|
|
210
|
+
suppositionChildNodesLength = suppositionChildNodes.length;
|
|
211
|
+
|
|
212
|
+
if (suppositionChildNodesLength === 1) {
|
|
213
|
+
const firstSuppositionChildNode = first(suppositionChildNodes),
|
|
214
|
+
suppositionChildNode = firstSuppositionChildNode, ///
|
|
215
|
+
suppositionChildNodeNonTerminalNode = suppositionChildNode.isNonTerminalNode();
|
|
216
|
+
|
|
217
|
+
if (suppositionChildNodeNonTerminalNode) {
|
|
218
|
+
const suppositionNonTerminalChildNode = suppositionChildNode, ///
|
|
219
|
+
suppositionNonTerminalChildNodeRuleName = suppositionNonTerminalChildNode.getRuleName(),
|
|
220
|
+
suppositionNonTerminalChildNodeRuleNameVariableRuleName = (suppositionNonTerminalChildNodeRuleName === VARIABLE_RULE_NAME);
|
|
221
|
+
|
|
222
|
+
if (suppositionNonTerminalChildNodeRuleNameVariableRuleName) {
|
|
223
|
+
const suppositionVariableNode = suppositionNonTerminalChildNode, ///
|
|
224
|
+
nonTerminalNode = statementNode, ///
|
|
225
|
+
childNodes = nonTerminalNode.getChildNodes(),
|
|
226
|
+
nodes = childNodes, ///
|
|
227
|
+
suppositionVariableMatches = matchSuppositionVariable(suppositionVariableNode, nodes, substitutions);
|
|
228
|
+
|
|
229
|
+
suppositionStatementNodeMatches = suppositionVariableMatches; ///
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return suppositionStatementNodeMatches;
|
|
235
|
+
}
|
package/src/theorem.js
CHANGED
|
@@ -9,5 +9,5 @@ export default class Theorem extends AxiomLemmaTheorem {
|
|
|
9
9
|
|
|
10
10
|
static fromJSON(json, releaseContext) { return AxiomLemmaTheorem.fromJSON(Theorem, json, releaseContext); }
|
|
11
11
|
|
|
12
|
-
static
|
|
12
|
+
static fromLabelsSuppositionsAndConsequence(labels, antecedents, consequence) { return AxiomLemmaTheorem.fromLabelsSuppositionsAndConsequence(Theorem, labels, antecedents, consequence); }
|
|
13
13
|
}
|
package/src/verify/axiom.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
import Axiom from "../axiom";
|
|
4
4
|
import ProofContext from "../context/proof";
|
|
5
5
|
import verifyLabels from "../verify/labels";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import verifySupposition from "../verify/supposition";
|
|
7
|
+
import verifyConsequence from "../verify/consequence";
|
|
8
8
|
|
|
9
9
|
import { first } from "../utilities/array";
|
|
10
10
|
import { nodesAsString } from "../utilities/string";
|
|
11
11
|
import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
12
12
|
|
|
13
13
|
const labelNodesQuery = nodesQuery("/axiom/label"),
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
consequenceNodeQuery = nodeQuery("/axiom/consequence!"),
|
|
15
|
+
suppositionsNodeQuery = nodesQuery("/axiom/supposition");
|
|
16
16
|
|
|
17
17
|
export default function verifyAxiom(axiomNode, fileContext) {
|
|
18
18
|
let axiomVerified = false;
|
|
@@ -29,25 +29,25 @@ export default function verifyAxiom(axiomNode, fileContext) {
|
|
|
29
29
|
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
30
30
|
|
|
31
31
|
if (labelsVerified) {
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
32
|
+
const suppositions = [],
|
|
33
|
+
suppositionNodes = suppositionsNodeQuery(axiomNode),
|
|
34
|
+
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
35
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, proofContext);
|
|
36
36
|
|
|
37
|
-
if (
|
|
37
|
+
if (suppositionVerified) {
|
|
38
38
|
return true;
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
if (suppositionsVerified) {
|
|
43
|
+
const consequences = [],
|
|
44
|
+
consequenceNode = consequenceNodeQuery(axiomNode),
|
|
45
|
+
consequenceVerified = verifyConsequence(consequenceNode, consequences, proofContext);
|
|
46
46
|
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
axiom = Axiom.
|
|
47
|
+
if (consequenceVerified) {
|
|
48
|
+
const firstConsequence = first(consequences),
|
|
49
|
+
consequence = firstConsequence, ///
|
|
50
|
+
axiom = Axiom.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
|
|
51
51
|
|
|
52
52
|
fileContext.addAxiom(axiom);
|
|
53
53
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import Consequence from "../consequence";
|
|
4
|
+
|
|
5
|
+
import { nodeQuery } from "../utilities/query";
|
|
6
|
+
import { nodeAsString } from "../utilities/string";
|
|
7
|
+
|
|
8
|
+
const statementNodeQuery = nodeQuery("/consequence/unqualifiedStatement!/statement!");
|
|
9
|
+
|
|
10
|
+
export default function verifyConsequence(consequenceNode, consequences, proofContext) {
|
|
11
|
+
let consequenceVerified = false;
|
|
12
|
+
|
|
13
|
+
proofContext.begin(consequenceNode);
|
|
14
|
+
|
|
15
|
+
const consequenceString = nodeAsString(consequenceNode);
|
|
16
|
+
|
|
17
|
+
proofContext.debug(`Verifying the ${consequenceString} consequence...`);
|
|
18
|
+
|
|
19
|
+
const statementNode = statementNodeQuery(consequenceNode);
|
|
20
|
+
|
|
21
|
+
if (statementNode !== null) {
|
|
22
|
+
const consequence = Consequence.fromStatementNode(statementNode);
|
|
23
|
+
|
|
24
|
+
consequences.push(consequence);
|
|
25
|
+
|
|
26
|
+
consequenceVerified = true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
consequenceVerified ?
|
|
30
|
+
proofContext.complete(consequenceNode) :
|
|
31
|
+
proofContext.halt(consequenceNode);
|
|
32
|
+
|
|
33
|
+
return consequenceVerified;
|
|
34
|
+
}
|
package/src/verify/derivation.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import ProofStep from "../step/proof";
|
|
4
4
|
import ProofContext from "../context/proof";
|
|
5
|
-
import
|
|
5
|
+
import verifySupposition from "./supposition";
|
|
6
6
|
import verifyQualifiedStatement from "../verify/statement/qualified";
|
|
7
7
|
import verifyUnqualifiedStatement from "../verify/statement/unqualified";
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ import { SUBPROOF_RULE_NAME, QUALIFIED_STATEMENT_RULE_NAME, UNQUALIFIED_STATEMEN
|
|
|
11
11
|
|
|
12
12
|
const childNodesQuery = nodesQuery("/derivation|subDerivation/*"),
|
|
13
13
|
statementNodeQuery = nodeQuery("/qualifiedStatement|unqualifiedStatement/statement!"),
|
|
14
|
-
|
|
14
|
+
suppositionNodesQuery = nodesQuery("/subproof/supposition"),
|
|
15
15
|
subDerivationNodeQuery = nodeQuery("/subproof/subDerivation");
|
|
16
16
|
|
|
17
17
|
export default function verifyDerivation(derivationNode, proofContext) {
|
|
@@ -63,17 +63,17 @@ function verifySubproof(subproofNode, proofContext) {
|
|
|
63
63
|
|
|
64
64
|
proofContext = ProofContext.fromProofContext(proofContext); ///
|
|
65
65
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
66
|
+
const suppositions = [],
|
|
67
|
+
suppositionNodes = suppositionNodesQuery(subproofNode),
|
|
68
|
+
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
69
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, proofContext);
|
|
70
70
|
|
|
71
|
-
if (
|
|
71
|
+
if (suppositionVerified) {
|
|
72
72
|
return true;
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
if (
|
|
76
|
+
if (suppositionsVerified) {
|
|
77
77
|
const subDerivationNode = subDerivationNodeQuery(subproofNode),
|
|
78
78
|
subDerivationVerified = verifySubDerivation(subDerivationNode, proofContext);
|
|
79
79
|
|
package/src/verify/lemma.js
CHANGED
|
@@ -4,8 +4,8 @@ import Lemma from "../lemma";
|
|
|
4
4
|
import verifyProof from "../verify/proof";
|
|
5
5
|
import ProofContext from "../context/proof";
|
|
6
6
|
import verifyLabels from "../verify/labels";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import verifySupposition from "./supposition";
|
|
8
|
+
import verifyConsequence from "./consequence";
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
11
|
import { EMPTY_STRING } from "../constants";
|
|
@@ -14,8 +14,8 @@ import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
|
14
14
|
|
|
15
15
|
const proofNodeQuery = nodeQuery("/lemma/proof!"),
|
|
16
16
|
labelNodesQuery = nodesQuery("/lemma/label"),
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
consequenceNodeQuery = nodeQuery("/lemma/consequence!"),
|
|
18
|
+
suppositionsNodeQuery = nodesQuery("/lemma/supposition");
|
|
19
19
|
|
|
20
20
|
export default function verifyLemma(lemmaNode, fileContext) {
|
|
21
21
|
let lemmaVerified = false;
|
|
@@ -34,29 +34,29 @@ export default function verifyLemma(lemmaNode, fileContext) {
|
|
|
34
34
|
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
35
35
|
|
|
36
36
|
if (labelsVerified) {
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
37
|
+
const suppositions = [],
|
|
38
|
+
suppositionNodes = suppositionsNodeQuery(lemmaNode),
|
|
39
|
+
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
40
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, proofContext);
|
|
41
41
|
|
|
42
|
-
if (
|
|
42
|
+
if (suppositionVerified) {
|
|
43
43
|
return true;
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
if (
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
if (suppositionsVerified) {
|
|
48
|
+
const consequences = [],
|
|
49
|
+
consequenceNode = consequenceNodeQuery(lemmaNode),
|
|
50
|
+
consequenceVerified = verifyConsequence(consequenceNode, consequences, proofContext);
|
|
51
51
|
|
|
52
|
-
if (
|
|
52
|
+
if (consequenceVerified) {
|
|
53
53
|
const proofNode = proofNodeQuery(lemmaNode),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
proofVerified = verifyProof(proofNode,
|
|
54
|
+
firstConsequence = first(consequences),
|
|
55
|
+
consequence = firstConsequence, ///
|
|
56
|
+
proofVerified = verifyProof(proofNode, consequence, proofContext);
|
|
57
57
|
|
|
58
58
|
if (proofVerified) {
|
|
59
|
-
const lemma = Lemma.
|
|
59
|
+
const lemma = Lemma.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
|
|
60
60
|
|
|
61
61
|
fileContext.addLemma(lemma);
|
|
62
62
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import MetaproofStep from "../step/metaproof";
|
|
4
4
|
import MetaproofContext from "../context/metaproof";
|
|
5
|
-
import
|
|
5
|
+
import verifyMetaSupposition from "../verify/metaSupposition";
|
|
6
6
|
import verifyQualifiedMetastatement from "../verify/metastatement/qualified";
|
|
7
7
|
import verifyUnqualifiedMetastatement from "../verify/metastatement/unqualified";
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ import { META_SUBPROOF_RULE_NAME, QUALIFIED_METASTATEMENT_RULE_NAME, UNQUALIFIED
|
|
|
11
11
|
|
|
12
12
|
const childNodesQuery = nodesQuery("/metaDerivation|metaSubDerivation/*"),
|
|
13
13
|
metastatementNodeQuery = nodeQuery("/qualifiedMetastatement|unqualifiedMetastatement/metastatement!"),
|
|
14
|
-
|
|
14
|
+
metaSuppositionNodesQuery = nodesQuery("/metaSubproof/metaSupposition"),
|
|
15
15
|
metaSubDerivationNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation");
|
|
16
16
|
|
|
17
17
|
export default function verifyMetaDerivation(metaDerivationNode, metaproofContext) {
|
|
@@ -63,17 +63,17 @@ function verifyMetaSubproof(metaSubproofNode, metaproofContext) {
|
|
|
63
63
|
|
|
64
64
|
metaproofContext = MetaproofContext.fromMetaproofContext(metaproofContext); ///
|
|
65
65
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
66
|
+
const metaSuppositions = [],
|
|
67
|
+
metaSuppositionNodes = metaSuppositionNodesQuery(metaSubproofNode),
|
|
68
|
+
metaSuppositionsVerified = metaSuppositionNodes.every((metaSuppositionNode) => {
|
|
69
|
+
const metaSuppositionVerified = verifyMetaSupposition(metaSuppositionNode, metaSuppositions, metaproofContext);
|
|
70
70
|
|
|
71
|
-
if (
|
|
71
|
+
if (metaSuppositionVerified) {
|
|
72
72
|
return true;
|
|
73
73
|
}
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
if (
|
|
76
|
+
if (metaSuppositionsVerified) {
|
|
77
77
|
const metaSubDerivationNode = metaSubDerivationNodeQuery(metaSubproofNode),
|
|
78
78
|
metaSubDerivationVerified = verifyMetaSubDerivation(metaSubDerivationNode, metaproofContext);
|
|
79
79
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import MetaproofStep from "../step/metaproof";
|
|
4
|
+
import MetaSupposition from "../metaSupposition";
|
|
5
|
+
import verifyMetastatement from "./metastatement";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "../utilities/query";
|
|
8
|
+
import { nodeAsString } from "../utilities/string";
|
|
9
|
+
|
|
10
|
+
const metastatementNodeQuery = nodeQuery("/metaSupposition/unqualifiedMetastatement!/metastatement!");
|
|
11
|
+
|
|
12
|
+
export default function verifyMetaSupposition(metaSuppositionNode, metaSuppositions, metaproofContext) {
|
|
13
|
+
let metaSuppositionVerified;
|
|
14
|
+
|
|
15
|
+
metaproofContext.begin(metaSuppositionNode);
|
|
16
|
+
|
|
17
|
+
const metaSuppositionString = nodeAsString(metaSuppositionNode);
|
|
18
|
+
|
|
19
|
+
metaproofContext.debug(`Verifying the ${metaSuppositionString} metaSupposition...`);
|
|
20
|
+
|
|
21
|
+
const metastatementNode = metastatementNodeQuery(metaSuppositionNode);
|
|
22
|
+
|
|
23
|
+
if (metastatementNode !== null) {
|
|
24
|
+
const qualified = false,
|
|
25
|
+
metastatementVerified = verifyMetastatement(metastatementNode, qualified, metaproofContext);
|
|
26
|
+
|
|
27
|
+
if (metastatementVerified) {
|
|
28
|
+
const metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode),
|
|
29
|
+
metaSupposition = MetaSupposition.fromMetastatementNode(metastatementNode);
|
|
30
|
+
|
|
31
|
+
metaSuppositions.push(metaSupposition);
|
|
32
|
+
|
|
33
|
+
metaproofContext.addMetaproofStep(metaproofStep);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
metaSuppositionVerified = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
metaSuppositionVerified ?
|
|
40
|
+
metaproofContext.complete(metaSuppositionNode) :
|
|
41
|
+
metaproofContext.halt(metaSuppositionNode);
|
|
42
|
+
|
|
43
|
+
return metaSuppositionVerified;
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import ProofStep from "../step/proof";
|
|
4
|
+
import Supposition from "../supposition";
|
|
5
|
+
import verifyStatement from "./statement";
|
|
6
|
+
|
|
7
|
+
import { nodeQuery } from "../utilities/query";
|
|
8
|
+
import { nodeAsString } from "../utilities/string";
|
|
9
|
+
|
|
10
|
+
const statementNodeQuery = nodeQuery("/supposition/unqualifiedStatement!/statement!");
|
|
11
|
+
|
|
12
|
+
export default function verifySupposition(suppositionNode, suppositions, proofContext) {
|
|
13
|
+
let suppositionVerified;
|
|
14
|
+
|
|
15
|
+
proofContext.begin(suppositionNode);
|
|
16
|
+
|
|
17
|
+
const suppositionString = nodeAsString(suppositionNode);
|
|
18
|
+
|
|
19
|
+
proofContext.debug(`Verifying the ${suppositionString} supposition...`);
|
|
20
|
+
|
|
21
|
+
const statementNode = statementNodeQuery(suppositionNode);
|
|
22
|
+
|
|
23
|
+
if (statementNode !== null) {
|
|
24
|
+
const qualified = false,
|
|
25
|
+
statementVerified = verifyStatement(statementNode, qualified, proofContext);
|
|
26
|
+
|
|
27
|
+
if (statementVerified) {
|
|
28
|
+
const proofStep = ProofStep.fromStatementNode(statementNode),
|
|
29
|
+
supposition = Supposition.fromStatementNode(statementNode);
|
|
30
|
+
|
|
31
|
+
suppositions.push(supposition);
|
|
32
|
+
|
|
33
|
+
proofContext.addProofStep(proofStep);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
suppositionVerified = true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
suppositionVerified ?
|
|
40
|
+
proofContext.complete(suppositionNode) :
|
|
41
|
+
proofContext.halt(suppositionNode);
|
|
42
|
+
|
|
43
|
+
return suppositionVerified;
|
|
44
|
+
}
|
package/src/verify/theorem.js
CHANGED
|
@@ -4,8 +4,8 @@ import Theorem from "../theorem";
|
|
|
4
4
|
import verifyProof from "../verify/proof";
|
|
5
5
|
import ProofContext from "../context/proof";
|
|
6
6
|
import verifyLabels from "../verify/labels";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import verifySupposition from "./supposition";
|
|
8
|
+
import verifyConsequence from "./consequence";
|
|
9
9
|
|
|
10
10
|
import { first } from "../utilities/array";
|
|
11
11
|
import { nodesAsString } from "../utilities/string";
|
|
@@ -13,8 +13,8 @@ import { nodeQuery, nodesQuery } from "../utilities/query";
|
|
|
13
13
|
|
|
14
14
|
const proofNodeQuery = nodeQuery("/theorem/proof!"),
|
|
15
15
|
labelNodesQuery = nodesQuery("/theorem/label"),
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
consequenceNodeQuery = nodeQuery("/theorem/consequence!"),
|
|
17
|
+
suppositionsNodeQuery = nodesQuery("/theorem/supposition");
|
|
18
18
|
|
|
19
19
|
export default function verifyTheorem(theoremNode, fileContext) {
|
|
20
20
|
let theoremVerified = false;
|
|
@@ -31,29 +31,29 @@ export default function verifyTheorem(theoremNode, fileContext) {
|
|
|
31
31
|
labelsVerified = verifyLabels(labelNodes, labels, fileContext);
|
|
32
32
|
|
|
33
33
|
if (labelsVerified) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
34
|
+
const suppositions = [],
|
|
35
|
+
suppositionNodes = suppositionsNodeQuery(theoremNode),
|
|
36
|
+
suppositionsVerified = suppositionNodes.every((suppositionNode) => {
|
|
37
|
+
const suppositionVerified = verifySupposition(suppositionNode, suppositions, proofContext);
|
|
38
38
|
|
|
39
|
-
if (
|
|
39
|
+
if (suppositionVerified) {
|
|
40
40
|
return true;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
-
if (
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
if (suppositionsVerified) {
|
|
45
|
+
const consequences = [],
|
|
46
|
+
consequenceNode = consequenceNodeQuery(theoremNode),
|
|
47
|
+
consequenceVerified = verifyConsequence(consequenceNode, consequences, proofContext);
|
|
48
48
|
|
|
49
|
-
if (
|
|
49
|
+
if (consequenceVerified) {
|
|
50
50
|
const proofNode = proofNodeQuery(theoremNode),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
proofVerified = verifyProof(proofNode,
|
|
51
|
+
firstConsequence = first(consequences),
|
|
52
|
+
consequence = firstConsequence, ///
|
|
53
|
+
proofVerified = verifyProof(proofNode, consequence, proofContext);
|
|
54
54
|
|
|
55
55
|
if (proofVerified) {
|
|
56
|
-
const theorem = Theorem.
|
|
56
|
+
const theorem = Theorem.fromLabelsSuppositionsAndConsequence(labels, suppositions, consequence);
|
|
57
57
|
|
|
58
58
|
fileContext.addTheorem(theorem);
|
|
59
59
|
|