occam-verify-cli 0.0.491 → 0.0.494

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.
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+
3
+ import MetaSubstitution from "./metaSubstitution";
4
+
5
+ import { first } from "./utilities/array";
6
+ import { nodeAsString } from "./utilities/string";
7
+ import { nodeQuery, nodesQuery } from "./utilities/query";
8
+ import { metavariableNameFromMetavariableNode } from "./utilities/query";
9
+ import { metastatementNodeFromMetastatementString } from "./utilities/string";
10
+ import { METAVARIABLE_RULE_NAME, METASTATEMENT_RULE_NAME } from "./ruleNames";
11
+
12
+ const metastatementNodesQuery = nodesQuery("/metaSubproofAssertion/metastatement"),
13
+ metaSubproofAssertionNodeQuery = nodeQuery("/metastatement/metaSubproofAssertion!"),
14
+ unqualifiedMetastatementMetastatementNodesQuery = nodesQuery("/metaSubproof/unqualifiedMetastatement/metastatement!"),
15
+ qualifiedOrUnqualifiedMetastatementMetastatementNodeQuery = nodeQuery("/metaSubproof/subDerivation/qualifiedMetastatement|unqualifiedMetastatement[-1]/metastatement!");
16
+
17
+ export default class MetaAntecedent {
18
+ constructor(metastatementNode) {
19
+ this.metastatementNode = metastatementNode;
20
+ }
21
+
22
+ getMetastatementNode() {
23
+ return this.metastatementNode;
24
+ }
25
+
26
+ matchSubproofNode(metaSubproofNode, metaSubstitutions) {
27
+ let metaSubproofNodeMatches = false;
28
+
29
+ const metaSubproofAssertionNode = metaSubproofAssertionNodeQuery(this.metastatementNode);
30
+
31
+ if (metaSubproofAssertionNode !== null) {
32
+ const metaSubproofAssertionMetastatementNodes = metastatementNodesQuery(metaSubproofAssertionNode),
33
+ unqualifiedMetastatementMetastatementNodes = unqualifiedMetastatementMetastatementNodesQuery(metaSubproofNode),
34
+ qualifiedOrUnqualifiedMetastatementMetastatementNode = qualifiedOrUnqualifiedMetastatementMetastatementNodeQuery(metaSubproofNode),
35
+ metastatementNodes = [
36
+ ...unqualifiedMetastatementMetastatementNodes,
37
+ qualifiedOrUnqualifiedMetastatementMetastatementNode
38
+ ],
39
+ metastatementNodesLength = metastatementNodes.length,
40
+ metaSubproofAssertionMetastatementNodesLength = metaSubproofAssertionMetastatementNodes.length;
41
+
42
+ if (metastatementNodesLength === metaSubproofAssertionMetastatementNodesLength) {
43
+ metaSubproofNodeMatches = metaSubproofAssertionMetastatementNodes.every((metaSubproofAssertionMetastatementNode, index) => {
44
+ const metastatementNode = metastatementNodes[index],
45
+ nonTerminalNode = metastatementNode, ///
46
+ metaAntecedentNonTerminalNode = metaSubproofAssertionMetastatementNode, ///
47
+ metaAntecedentNonTerminalNodeMatches = matchMetaAntecedentNonTerminalNode(metaAntecedentNonTerminalNode, nonTerminalNode, metaSubstitutions);
48
+
49
+ if (metaAntecedentNonTerminalNodeMatches) {
50
+ return true;
51
+ }
52
+ });
53
+ }
54
+ }
55
+
56
+ return metaSubproofNodeMatches;
57
+ }
58
+
59
+ matchMetastatementNode(metastatementNode, metaSubstitutions) {
60
+ const nonTerminalNode = metastatementNode, ///
61
+ metaAntecedentNonTerminalNode = this.metastatementNode, ///
62
+ metaAntecedentNonTerminalNodeMatches = matchMetaAntecedentNonTerminalNode(metaAntecedentNonTerminalNode, nonTerminalNode, metaSubstitutions),
63
+ metastatementNodeMatches = metaAntecedentNonTerminalNodeMatches; ///
64
+
65
+ return metastatementNodeMatches;
66
+ }
67
+
68
+ toJSON() {
69
+ const metastatementString = nodeAsString(this.metastatementNode),
70
+ metastatement = metastatementString, ///
71
+ json = {
72
+ metastatement
73
+ };
74
+
75
+ return json;
76
+ }
77
+
78
+ static fromJSON(json, releaseContext) {
79
+ const { metastatement } = json,
80
+ metastatementString = metastatement, ///
81
+ metastatementNode = metastatementNodeFromMetastatementString(metastatementString, releaseContext),
82
+ metaAntecedent = new MetaAntecedent(metastatementNode);
83
+
84
+ return metaAntecedent;
85
+ }
86
+
87
+ static fromMetastatementNode(metastatementNode) {
88
+ const metaAntecedent = new MetaAntecedent(metastatementNode);
89
+
90
+ return metaAntecedent;
91
+ }
92
+ }
93
+
94
+ function matchMetaAntecedentNode(metaAntecedentNode, node, metaSubstitutions) {
95
+ let metaAntecedentNodeMatches = false;
96
+
97
+ const nodeTerminalNode = node.isTerminalNode(),
98
+ ruleNodeTerminalNode = metaAntecedentNode.isTerminalNode();
99
+
100
+ if (nodeTerminalNode === ruleNodeTerminalNode) {
101
+ if (nodeTerminalNode) {
102
+ const terminalNode = node, ///
103
+ metaAntecedentTerminalNode = metaAntecedentNode, ///
104
+ metaAntecedentTerminalNodeMatches = matchMetaAntecedentTerminalNode(metaAntecedentTerminalNode, terminalNode, metaSubstitutions);
105
+
106
+ metaAntecedentNodeMatches = metaAntecedentTerminalNodeMatches; ///
107
+ } else {
108
+ const nonTerminalNode = node, ///
109
+ metaAntecedentNonTerminalNode = metaAntecedentNode, ///
110
+ metaAntecedentNonTerminalNodeMatches = matchMetaAntecedentNonTerminalNode(metaAntecedentNonTerminalNode, nonTerminalNode, metaSubstitutions);
111
+
112
+ metaAntecedentNodeMatches = metaAntecedentNonTerminalNodeMatches; ///
113
+ }
114
+ }
115
+
116
+ return metaAntecedentNodeMatches;
117
+ }
118
+
119
+ function matchMetaAntecedentNodes(metaAntecedentNodes, nodes, metaSubstitutions) {
120
+ let metaAntecedentNodesMatches = false;
121
+
122
+ const nodesLength = nodes.length,
123
+ metaAntecedentNodesLength = metaAntecedentNodes.length;
124
+
125
+ if (nodesLength === metaAntecedentNodesLength) {
126
+ metaAntecedentNodesMatches = nodes.every((node, index) => {
127
+ const metaAntecedentNode = metaAntecedentNodes[index],
128
+ metaAntecedentNodeMatches = matchMetaAntecedentNode(metaAntecedentNode, node, metaSubstitutions);
129
+
130
+ if (metaAntecedentNodeMatches) {
131
+ return true;
132
+ }
133
+ });
134
+ }
135
+
136
+ return metaAntecedentNodesMatches;
137
+ }
138
+
139
+ function matchMetaAntecedentMetavariable(metaAntecedentMetavariableNode, nodes, metaSubstitutions) {
140
+ let metaAntecedentMetavariableMatches;
141
+
142
+ const metaAntecedentMetavariableName = metavariableNameFromMetavariableNode(metaAntecedentMetavariableNode),
143
+ metaSubstitution = metaSubstitutions.find((metaSubstitution) => {
144
+ const metavariableName = metaSubstitution.getMetavariableName();
145
+
146
+ if (metavariableName === metaAntecedentMetavariableName) {
147
+ return true;
148
+ }
149
+ }) || null;
150
+
151
+ if (metaSubstitution !== null) {
152
+ const metaSubstitutionNodesMatch = metaSubstitution.matchNodes(nodes);
153
+
154
+ metaAntecedentMetavariableMatches = metaSubstitutionNodesMatch; ///
155
+ } else {
156
+ const metavariableName = metaAntecedentMetavariableName, ///
157
+ metaSubstitution = MetaSubstitution.fromMetavariableNameAndNodes(metavariableName, nodes);
158
+
159
+ metaSubstitutions.push(metaSubstitution);
160
+
161
+ metaAntecedentMetavariableMatches = true;
162
+ }
163
+
164
+ return metaAntecedentMetavariableMatches;
165
+ }
166
+
167
+ function matchMetaAntecedentTerminalNode(metaAntecedentTerminalNode, terminalNode, metaSubstitutions) {
168
+ const matches = metaAntecedentTerminalNode.match(terminalNode),
169
+ metaAntecedentTerminalNodeMatches = matches;
170
+
171
+ return metaAntecedentTerminalNodeMatches;
172
+ }
173
+
174
+ function matchMetaAntecedentNonTerminalNode(metaAntecedentNonTerminalNode, nonTerminalNode, metaSubstitutions) {
175
+ let metaAntecedentNonTerminalNodeMatches = false;
176
+
177
+ const ruleName = nonTerminalNode.getRuleName(),
178
+ metaAntecedentRuleName = metaAntecedentNonTerminalNode.getRuleName(); ///
179
+
180
+ if (ruleName === metaAntecedentRuleName) {
181
+ const childNodes = nonTerminalNode.getChildNodes(),
182
+ metaAntecedentChildNodes = metaAntecedentNonTerminalNode.getChildNodes(),
183
+ nodes = childNodes, ///
184
+ metaAntecedentNodes = metaAntecedentChildNodes, ///
185
+ metaAntecedentChildNodesMatches = matchMetaAntecedentNodes(metaAntecedentNodes, nodes, metaSubstitutions);
186
+
187
+ metaAntecedentNonTerminalNodeMatches = metaAntecedentChildNodesMatches; ///
188
+
189
+ if (!metaAntecedentNonTerminalNodeMatches) {
190
+ const ruleNameMetastatementRuleName = (ruleName === METASTATEMENT_RULE_NAME);
191
+
192
+ if (ruleNameMetastatementRuleName) {
193
+ const metastatementNode = nonTerminalNode, ///
194
+ metaAntecedentMetastatementNode = metaAntecedentNonTerminalNode, ///
195
+ metaAntecedentMetastatementNodeMatches = matchMetaAntecedentMetastatementNode(metaAntecedentMetastatementNode, metastatementNode, metaSubstitutions);
196
+
197
+ metaAntecedentNonTerminalNodeMatches = metaAntecedentMetastatementNodeMatches; ///
198
+ }
199
+ }
200
+ }
201
+
202
+ return metaAntecedentNonTerminalNodeMatches;
203
+ }
204
+
205
+ function matchMetaAntecedentMetastatementNode(metaAntecedentMetastatementNode, metastatementNode, metaSubstitutions) {
206
+ let metaAntecedentMetastatementNodeMatches = false;
207
+
208
+ const metaAntecedentNonTerminalNode = metaAntecedentMetastatementNode, ///
209
+ metaAntecedentChildNodes = metaAntecedentNonTerminalNode.getChildNodes(),
210
+ metaAntecedentChildNodesLength = metaAntecedentChildNodes.length;
211
+
212
+ if (metaAntecedentChildNodesLength === 1) {
213
+ const firstMetaAntecedentChildNode = first(metaAntecedentChildNodes),
214
+ metaAntecedentChildNode = firstMetaAntecedentChildNode, ///
215
+ metaAntecedentChildNodeNonTerminalNode = metaAntecedentChildNode.isNonTerminalNode();
216
+
217
+ if (metaAntecedentChildNodeNonTerminalNode) {
218
+ const metaAntecedentNonTerminalChildNode = metaAntecedentChildNode, ///
219
+ metaAntecedentNonTerminalChildNodeRuleName = metaAntecedentNonTerminalChildNode.getRuleName(),
220
+ metaAntecedentNonTerminalChildNodeRuleNameMetavariableRuleName = (metaAntecedentNonTerminalChildNodeRuleName === METAVARIABLE_RULE_NAME);
221
+
222
+ if (metaAntecedentNonTerminalChildNodeRuleNameMetavariableRuleName) {
223
+ const metaAntecedentMetavariableNode = metaAntecedentNonTerminalChildNode, ///
224
+ nonTerminalNode = metastatementNode, ///
225
+ childNodes = nonTerminalNode.getChildNodes(),
226
+ nodes = childNodes, ///
227
+ metaAntecedentMetavariableMatches = matchMetaAntecedentMetavariable(metaAntecedentMetavariableNode, nodes, metaSubstitutions);
228
+
229
+ metaAntecedentMetastatementNodeMatches = metaAntecedentMetavariableMatches; ///
230
+ }
231
+ }
232
+ }
233
+
234
+ return metaAntecedentMetastatementNodeMatches;
235
+ }
package/src/premise.js CHANGED
@@ -12,8 +12,8 @@ import { STATEMENT_RULE_NAME, METASTATEMENT_RULE_NAME, METAVARIABLE_RULE_NAME }
12
12
 
13
13
  const metastatementNodesQuery = nodesQuery("/metaSubproofAssertion/metastatement"),
14
14
  metaSubproofAssertionNodeQuery = nodeQuery("/metastatement/metaSubproofAssertion!"),
15
- unqualifiedStatementStatementNodesQuery = nodesQuery("/subproof/unqualifiedStatement/statement!"),
16
- unqualifiedMetastatementMetastatementNodesQuery = nodesQuery("/metaSubproof/unqualifiedMetastatement/metastatement!"),
15
+ unqualifiedStatementStatementNodesQuery = nodesQuery("/subproof/antecedent/unqualifiedStatement!/statement!"),
16
+ unqualifiedMetastatementMetastatementNodesQuery = nodesQuery("/metaSubproof/metaAntecedent/unqualifiedMetastatement!/metastatement!"),
17
17
  qualifiedOrUnqualifiedStatementStatementNodeQuery = nodeQuery("/subproof/subDerivation/qualifiedStatement|unqualifiedStatement[-1]/statement!"),
18
18
  qualifiedOrUnqualifiedMetastatementMetastatementNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation/qualifiedMetastatement|unqualifiedMetastatement[-1]/metastatement!");
19
19
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  import ProofStep from "../step/proof";
4
4
  import Antecedent from "../antecedent";
5
+ import verifyStatement from "./statement";
5
6
 
6
7
  import { nodeQuery } from "../utilities/query";
7
8
  import { nodeAsString } from "../utilities/string";
8
- import verifyStatement from "./statement";
9
9
 
10
10
  const statementNodeQuery = nodeQuery("/antecedent/unqualifiedStatement!/statement!");
11
11
 
@@ -1,58 +1,53 @@
1
1
  "use strict";
2
2
 
3
- import Variable from "../variable";
3
+ import Variable from "../../variable";
4
4
 
5
- import { first } from "../utilities/array";
6
- import { nodeAsString } from "../utilities/string";
7
- import { nodeQuery, typeNameFromTypeNode } from "../utilities/query";
8
- import { verifyTermAsVariable, verifyTermAgainstConstructors } from "../verify/term";
5
+ import { first } from "../../utilities/array";
6
+ import { nodeAsString } from "../../utilities/string";
7
+ import { nodeQuery, typeNameFromTypeNode } from "../../utilities/query";
8
+ import { verifyTermAsVariable, verifyTermAgainstConstructors } from "../../verify/term";
9
9
 
10
10
  const termNodeQuery = nodeQuery("/typeAssertion/term"),
11
- typeNodeQuery = nodeQuery("/typeAssertion/type"),
12
- typeAssertionNodeQuery = nodeQuery("/statement/typeAssertion!");
11
+ typeNodeQuery = nodeQuery("/typeAssertion/type");
13
12
 
14
- export default function verifyStatementTypeAssertion(statementNode, qualified, proofContext) {
15
- let statementTypeAssertionVerified = false;
13
+ export default function verifyStatementTypeAssertion(typeAssertionNode, qualified, proofContext) {
14
+ let typeAssertionVerified = false;
16
15
 
17
- proofContext.begin(statementNode);
16
+ proofContext.begin(typeAssertionNode);
18
17
 
19
- const statementString = nodeAsString(statementNode);
18
+ const statementString = nodeAsString(typeAssertionNode);
20
19
 
21
- proofContext.debug(`Verifying the '${statementString}' statement type assertion...`);
20
+ proofContext.debug(`Verifying the '${statementString}' type assertion...`);
22
21
 
23
- const typeAssertionNode = typeAssertionNodeQuery(statementNode);
22
+ const typeNode = typeNodeQuery(typeAssertionNode),
23
+ typeName = typeNameFromTypeNode(typeNode),
24
+ typePresent = proofContext.isTypePresentByTypeName(typeName);
24
25
 
25
- if (typeAssertionNode !== null) {
26
- const typeNode = typeNodeQuery(typeAssertionNode),
27
- typeName = typeNameFromTypeNode(typeNode),
28
- typePresent = proofContext.isTypePresentByTypeName(typeName);
29
-
30
- if (!typePresent) {
31
- proofContext.error(`The ${typeName} type is not present.`);
32
- } else {
33
- if (!statementTypeAssertionVerified) {
34
- const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, qualified, proofContext);
26
+ if (!typePresent) {
27
+ proofContext.error(`The ${typeName} type is not present.`);
28
+ } else {
29
+ if (!typeAssertionVerified) {
30
+ const variableTypeAssertionVerified = verifyVariableTypeAssertion(typeAssertionNode, qualified, proofContext);
35
31
 
36
- statementTypeAssertionVerified = variableTypeAssertionVerified; ///
37
- }
32
+ typeAssertionVerified = variableTypeAssertionVerified; ///
33
+ }
38
34
 
39
- if (!statementTypeAssertionVerified) {
40
- const termTypeAssertionVerified = verifyTermTypeAssertion(typeAssertionNode, qualified, proofContext);
35
+ if (!typeAssertionVerified) {
36
+ const termTypeAssertionVerified = verifyTermTypeAssertion(typeAssertionNode, qualified, proofContext);
41
37
 
42
- statementTypeAssertionVerified = termTypeAssertionVerified; ///
43
- }
38
+ typeAssertionVerified = termTypeAssertionVerified; ///
44
39
  }
45
40
  }
46
41
 
47
- if (statementTypeAssertionVerified) {
42
+ if (typeAssertionVerified) {
48
43
  proofContext.info(`Verified the '${statementString}' statement type assertion.`);
49
44
  }
50
45
 
51
- statementTypeAssertionVerified ?
52
- proofContext.complete(statementNode) :
53
- proofContext.halt(statementNode);
46
+ typeAssertionVerified ?
47
+ proofContext.complete(typeAssertionNode) :
48
+ proofContext.halt(typeAssertionNode);
54
49
 
55
- return statementTypeAssertionVerified;
50
+ return typeAssertionVerified;
56
51
  }
57
52
 
58
53
  function verifyVariableTypeAssertion(typeAssertionNode, qualified, proofContext) {
@@ -2,6 +2,7 @@
2
2
 
3
3
  import ProofStep from "../step/proof";
4
4
  import ProofContext from "../context/proof";
5
+ import verifyAntecedent from "./antecedent";
5
6
  import verifyQualifiedStatement from "../verify/statement/qualified";
6
7
  import verifyUnqualifiedStatement from "../verify/statement/unqualified";
7
8
 
@@ -10,8 +11,8 @@ import { SUBPROOF_RULE_NAME, QUALIFIED_STATEMENT_RULE_NAME, UNQUALIFIED_STATEMEN
10
11
 
11
12
  const childNodesQuery = nodesQuery("/derivation|subDerivation/*"),
12
13
  statementNodeQuery = nodeQuery("/qualifiedStatement|unqualifiedStatement/statement!"),
13
- subDerivationNodeQuery = nodeQuery("/subproof/subDerivation"),
14
- unqualifiedStatementNodesQuery = nodesQuery("/subproof/unqualifiedStatement");
14
+ antecedentNodesQuery = nodesQuery("/subproof/antecedent"),
15
+ subDerivationNodeQuery = nodeQuery("/subproof/subDerivation");
15
16
 
16
17
  export default function verifyDerivation(derivationNode, proofContext) {
17
18
  let derivationVerified;
@@ -20,7 +21,7 @@ export default function verifyDerivation(derivationNode, proofContext) {
20
21
 
21
22
  const childNodes = childNodesQuery(derivationNode);
22
23
 
23
- derivationVerified = childNodes.every((childNode) => { ///
24
+ derivationVerified = childNodes.every((childNode) => {
24
25
  const childVerified = verifyChild(childNode, proofContext);
25
26
 
26
27
  if (childVerified) {
@@ -36,13 +37,13 @@ export default function verifyDerivation(derivationNode, proofContext) {
36
37
  }
37
38
 
38
39
  function verifySubDerivation(subDerivationNode, proofContext) {
39
- let derivationVerified;
40
+ let subDerivationVerified;
40
41
 
41
42
  proofContext.begin(subDerivationNode);
42
43
 
43
44
  const childNodes = childNodesQuery(subDerivationNode);
44
45
 
45
- derivationVerified = childNodes.every((childNode) => { ///
46
+ subDerivationVerified = childNodes.every((childNode) => {
46
47
  const childVerified = verifyChild(childNode, proofContext);
47
48
 
48
49
  if (childVerified) {
@@ -50,11 +51,11 @@ function verifySubDerivation(subDerivationNode, proofContext) {
50
51
  }
51
52
  });
52
53
 
53
- derivationVerified ?
54
+ subDerivationVerified ?
54
55
  proofContext.complete(subDerivationNode) :
55
56
  proofContext.halt(subDerivationNode);
56
57
 
57
- return derivationVerified;
58
+ return subDerivationVerified;
58
59
  }
59
60
 
60
61
  function verifySubproof(subproofNode, proofContext) {
@@ -62,23 +63,17 @@ function verifySubproof(subproofNode, proofContext) {
62
63
 
63
64
  proofContext = ProofContext.fromProofContext(proofContext); ///
64
65
 
65
- const unqualifiedStatementNodes = unqualifiedStatementNodesQuery(subproofNode),
66
- unqualifiedStatementsVerified = unqualifiedStatementNodes.every((unqualifiedStatementNode) => {
67
- const unqualifiedStatementVerified = verifyUnqualifiedStatement(unqualifiedStatementNode, proofContext);
66
+ const antecedents = [],
67
+ antecedentNodes = antecedentNodesQuery(subproofNode),
68
+ antecedentsVerified = antecedentNodes.every((antecedentNode) => {
69
+ const antecedentVerified = verifyAntecedent(antecedentNode, antecedents, proofContext);
68
70
 
69
- if (unqualifiedStatementVerified) {
71
+ if (antecedentVerified) {
70
72
  return true;
71
73
  }
72
74
  });
73
75
 
74
- if (unqualifiedStatementsVerified) {
75
- unqualifiedStatementNodes.forEach((unqualifiedStatementNode) => {
76
- const statementNode = statementNodeQuery(unqualifiedStatementNode),
77
- proofStep = ProofStep.fromStatementNode(statementNode);
78
-
79
- proofContext.addProofStep(proofStep);
80
- });
81
-
76
+ if (antecedentsVerified) {
82
77
  const subDerivationNode = subDerivationNodeQuery(subproofNode),
83
78
  subDerivationVerified = verifySubDerivation(subDerivationNode, proofContext);
84
79
 
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ import MetaproofStep from "../step/metaproof";
4
+ import MetaAntecedent from "../metaAntecedent";
5
+ import verifyMetastatement from "./metastatement";
6
+
7
+ import { nodeQuery } from "../utilities/query";
8
+ import { nodeAsString } from "../utilities/string";
9
+
10
+ const metastatementNodeQuery = nodeQuery("/metaAntecedent/unqualifiedMetastatement!/metastatement!");
11
+
12
+ export default function verifyMetaAntecedent(metaAntecedentNode, metaAntecedents, metaproofContext) {
13
+ let metaAntecedentVerified;
14
+
15
+ metaproofContext.begin(metaAntecedentNode);
16
+
17
+ const metaAntecedentString = nodeAsString(metaAntecedentNode);
18
+
19
+ metaproofContext.debug(`Verifying the ${metaAntecedentString} metaAntecedent...`);
20
+
21
+ const metastatementNode = metastatementNodeQuery(metaAntecedentNode);
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
+ metaAntecedent = MetaAntecedent.fromMetastatementNode(metastatementNode);
30
+
31
+ metaAntecedents.push(metaAntecedent);
32
+
33
+ metaproofContext.addMetaproofStep(metaproofStep);
34
+ }
35
+
36
+ metaAntecedentVerified = true;
37
+ }
38
+
39
+ metaAntecedentVerified ?
40
+ metaproofContext.complete(metaAntecedentNode) :
41
+ metaproofContext.halt(metaAntecedentNode);
42
+
43
+ return metaAntecedentVerified;
44
+ }
@@ -2,6 +2,7 @@
2
2
 
3
3
  import MetaproofStep from "../step/metaproof";
4
4
  import MetaproofContext from "../context/metaproof";
5
+ import verifyMetaAntecedent from "../verify/metaAntecedent";
5
6
  import verifyQualifiedMetastatement from "../verify/metastatement/qualified";
6
7
  import verifyUnqualifiedMetastatement from "../verify/metastatement/unqualified";
7
8
 
@@ -10,8 +11,8 @@ import { META_SUBPROOF_RULE_NAME, QUALIFIED_METASTATEMENT_RULE_NAME, UNQUALIFIED
10
11
 
11
12
  const childNodesQuery = nodesQuery("/metaDerivation|metaSubDerivation/*"),
12
13
  metastatementNodeQuery = nodeQuery("/qualifiedMetastatement|unqualifiedMetastatement/metastatement!"),
13
- metaSubDerivationNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation"),
14
- unqualifiedMetastatementNodesQuery = nodesQuery("/metaSubproof/unqualifiedMetastatement");
14
+ metaAntecedentNodesQuery = nodesQuery("/metaSubproof/metaAntecedent"),
15
+ metaSubDerivationNodeQuery = nodeQuery("/metaSubproof/metaSubDerivation");
15
16
 
16
17
  export default function verifyMetaDerivation(metaDerivationNode, metaproofContext) {
17
18
  let metaDerivationVerified;
@@ -20,7 +21,7 @@ export default function verifyMetaDerivation(metaDerivationNode, metaproofContex
20
21
 
21
22
  const childNodes = childNodesQuery(metaDerivationNode);
22
23
 
23
- metaDerivationVerified = childNodes.every((childNode) => { ///
24
+ metaDerivationVerified = childNodes.every((childNode) => {
24
25
  const childVerified = verifyChild(childNode, metaproofContext);
25
26
 
26
27
  if (childVerified) {
@@ -36,13 +37,13 @@ export default function verifyMetaDerivation(metaDerivationNode, metaproofContex
36
37
  }
37
38
 
38
39
  function verifyMetaSubDerivation(metaSubDerivationNode, metaproofContext) {
39
- let metaDerivationVerified;
40
+ let metaSubDerivationVerified;
40
41
 
41
42
  metaproofContext.begin(metaSubDerivationNode);
42
43
 
43
44
  const childNodes = childNodesQuery(metaSubDerivationNode);
44
45
 
45
- metaDerivationVerified = childNodes.every((childNode) => { ///
46
+ metaSubDerivationVerified = childNodes.every((childNode) => {
46
47
  const childVerified = verifyChild(childNode, metaproofContext);
47
48
 
48
49
  if (childVerified) {
@@ -50,11 +51,11 @@ function verifyMetaSubDerivation(metaSubDerivationNode, metaproofContext) {
50
51
  }
51
52
  });
52
53
 
53
- metaDerivationVerified ?
54
+ metaSubDerivationVerified ?
54
55
  metaproofContext.complete(metaSubDerivationNode) :
55
56
  metaproofContext.halt(metaSubDerivationNode);
56
57
 
57
- return metaDerivationVerified;
58
+ return metaSubDerivationVerified;
58
59
  }
59
60
 
60
61
  function verifyMetaSubproof(metaSubproofNode, metaproofContext) {
@@ -62,23 +63,17 @@ function verifyMetaSubproof(metaSubproofNode, metaproofContext) {
62
63
 
63
64
  metaproofContext = MetaproofContext.fromMetaproofContext(metaproofContext); ///
64
65
 
65
- const unqualifiedMetastatementNodes = unqualifiedMetastatementNodesQuery(metaSubproofNode),
66
- unqualifiedMetastatementsVerified = unqualifiedMetastatementNodes.every((unqualifiedMetastatementNode) => {
67
- const unqualifiedMetastatementVerified = verifyUnqualifiedMetastatement(unqualifiedMetastatementNode, metaproofContext);
66
+ const metaAntecedents = [],
67
+ metaAntecedentNodes = metaAntecedentNodesQuery(metaSubproofNode),
68
+ metaAntecedentsVerified = metaAntecedentNodes.every((metaAntecedentNode) => {
69
+ const metaAntecedentVerified = verifyMetaAntecedent(metaAntecedentNode, metaAntecedents, metaproofContext);
68
70
 
69
- if (unqualifiedMetastatementVerified) {
71
+ if (metaAntecedentVerified) {
70
72
  return true;
71
73
  }
72
74
  });
73
75
 
74
- if (unqualifiedMetastatementsVerified) {
75
- unqualifiedMetastatementNodes.forEach((unqualifiedMetastatementNode) => {
76
- const metastatementNode = metastatementNodeQuery(unqualifiedMetastatementNode),
77
- metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
78
-
79
- metaproofContext.addMetaproofStep(metaproofStep);
80
- });
81
-
76
+ if (metaAntecedentsVerified) {
82
77
  const metaSubDerivationNode = metaSubDerivationNodeQuery(metaSubproofNode),
83
78
  metaSubDerivationVerified = verifyMetaSubDerivation(metaSubDerivationNode, metaproofContext);
84
79
 
@@ -1,15 +1,11 @@
1
1
  "use strict";
2
2
 
3
- import MetaproofStep from "../step/metaproof";
4
3
  import verifyMetaDerivation from "../verify/metaDerivation";
5
- import verifyQualifiedMetastatement from "./metastatement/qualified";
6
4
 
7
5
  import { matchNode } from "../utilities/node";
8
6
  import { nodeQuery } from "../utilities/query";
9
7
 
10
- const metastatementNodeQuery = nodeQuery("/qualifiedMetastatement/metastatement!"),
11
- metaDerivationNodeQuery = nodeQuery("/metaproof/metaDerivation!"),
12
- qualifiedMetastatementNodeQuery = nodeQuery("/metaproof/qualifiedMetastatement!");
8
+ const metaDerivationNodeQuery = nodeQuery("/metaproof/metaDerivation!");
13
9
 
14
10
  export default function verifyMetaproof(metaproofNode, conclusion, metaproofContext) {
15
11
  let metaproofVerified = false;
@@ -17,27 +13,9 @@ export default function verifyMetaproof(metaproofNode, conclusion, metaproofCont
17
13
  metaproofContext.begin(metaproofNode);
18
14
 
19
15
  const metaDerivationNode = metaDerivationNodeQuery(metaproofNode),
20
- qualifiedMetastatementNode = qualifiedMetastatementNodeQuery(metaproofNode);
16
+ metaDerivationVerified = verifyMetaDerivation(metaDerivationNode, metaproofContext);
21
17
 
22
- let metaDerivationVerified = false,
23
- qualifiedMetastatementVerified = false;
24
-
25
- if (metaDerivationNode !== null) {
26
- metaDerivationVerified = verifyMetaDerivation(metaDerivationNode, metaproofContext);
27
- }
28
-
29
- if (qualifiedMetastatementNode !== null) {
30
- qualifiedMetastatementVerified = verifyQualifiedMetastatement(qualifiedMetastatementNode, metaproofContext);
31
-
32
- if (qualifiedMetastatementVerified) {
33
- const metastatementNode = metastatementNodeQuery(qualifiedMetastatementNode),
34
- metaproofStep = MetaproofStep.fromMetastatementNode(metastatementNode);
35
-
36
- metaproofContext.addMetaproofStep(metaproofStep);
37
- }
38
- }
39
-
40
- if (metaDerivationVerified || qualifiedMetastatementVerified) {
18
+ if (metaDerivationVerified) {
41
19
  const lastMetaproofStep = metaproofContext.getLastMetaproofStep(),
42
20
  metaproofStep = lastMetaproofStep, ///
43
21
  metastatementNode = metaproofStep.getMetastatementNode(),
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ export default function verifyMetastatement(metastatementNode, qualified, metaproofContext) {
4
+ let metastatementVerified = true;
5
+
6
+ metaproofContext.begin(metastatementNode);
7
+
8
+ ///
9
+
10
+ metastatementVerified ?
11
+ metaproofContext.complete(metastatementNode) :
12
+ metaproofContext.halt(metastatementNode);
13
+
14
+ return metastatementVerified;
15
+ }